[cdo] 01/06: New upstream 1.7.0

Alastair McKinstry mckinstry at moszumanska.debian.org
Thu Jun 9 07:45:28 UTC 2016


This is an automated email from the git hooks/post-receive script.

mckinstry pushed a commit to tag debian/1.7.0+dfsg.1-1
in repository cdo.

commit 44c5431a16ec0990b6d1f9b7391aa0bc73778767
Author: Alastair McKinstry <mckinstry at debian.org>
Date:   Wed Oct 28 14:36:46 2015 +0000

    New upstream 1.7.0
---
 AUTHORS                                     |     1 -
 ChangeLog                                   |   183 +
 Makefile.am                                 |     2 +-
 Makefile.in                                 |     4 +-
 NEWS                                        |    32 +
 OPERATORS                                   |    63 +-
 cdo.spec                                    |     2 +-
 config/default                              |   148 +-
 configure                                   |   273 +-
 configure.ac                                |    28 +-
 contrib/Makefile.am                         |     2 +-
 contrib/Makefile.in                         |     4 +-
 contrib/cdoCompletion.bash                  |    47 +
 contrib/cdoCompletion.tcsh                  |    47 +
 contrib/cdoCompletion.zsh                   |    47 +
 contrib/python/cdo.py                       |   422 -
 doc/cdo.pdf                                 |   Bin 1455478 -> 1414096 bytes
 doc/cdo_eca.pdf                             |   Bin 0 -> 213128 bytes
 doc/cdo_refcard.pdf                         |   Bin 97809 -> 91167 bytes
 libcdi/AUTHORS                              |     7 +
 libcdi/ChangeLog                            |    43 +
 libcdi/Makefile.in                          |     7 +-
 libcdi/NEWS                                 |    12 +
 libcdi/acinclude.m4                         |    16 -
 libcdi/aclocal.m4                           |     4 +
 libcdi/app/Makefile.in                      |     7 +-
 libcdi/app/cdi.c                            |    72 +-
 libcdi/app/createtable.c                    |    16 +-
 libcdi/app/printinfo.h                      |    84 +-
 libcdi/config/config.guess                  |     5 +-
 libcdi/config/default                       |    17 +-
 libcdi/configure                            | 30740 ++++++++++++++------------
 libcdi/configure.ac                         |    83 +-
 libcdi/doc/cdi_cman.pdf                     |   Bin 332301 -> 332635 bytes
 libcdi/doc/cdi_fman.pdf                     |   Bin 360652 -> 360969 bytes
 libcdi/examples/Makefile.in                 |     7 +-
 libcdi/examples/pio/Makefile.in             |     7 +-
 libcdi/examples/pio/collectData.c           |    60 +-
 libcdi/examples/pio/collectDataNStreams.c   |    24 +-
 libcdi/examples/pio/compareResourcesArray.c |    14 +-
 libcdi/interfaces/Makefile.in               |     7 +-
 libcdi/interfaces/f2003/bindGen.rb          |   918 +-
 libcdi/interfaces/python/CdiObj.py          |   704 +-
 libcdi/interfaces/python/cdiobj_wrap.cpp    | 19864 ++++++++---------
 libcdi/m4/acx_cfortran_flags.m4             |   171 +
 libcdi/m4/acx_check_cfortran.m4             |   275 +
 libcdi/m4/acx_check_strptr_convert.m4       |     5 +-
 libcdi/m4/acx_lt_problems.m4                |    96 +
 libcdi/m4/kpse_libtool.m4                   |    37 +
 libcdi/m4/starlink_fpp.m4                   |     9 +-
 libcdi/src/Makefile.am                      |    65 +-
 libcdi/src/Makefile.in                      |   784 +-
 libcdi/src/basetime.c                       |     1 +
 libcdi/src/binary.c                         |    95 +-
 libcdi/src/binary.h                         |    14 +
 libcdi/src/calendar.c                       |    59 +-
 libcdi/src/calendar.h                       |     5 +
 libcdi/src/cdf.c                            |     8 +-
 libcdi/src/cdf.h                            |     2 +
 libcdi/src/cdf_int.c                        |   246 +-
 libcdi/src/cdf_int.h                        |     3 +
 libcdi/src/cdi.h                            |   275 +-
 libcdi/src/cdi.inc                          |   241 +-
 libcdi/src/cdiFortran.c                     |   137 +-
 libcdi/src/cdi_cksum.c                      |    10 +
 libcdi/src/cdi_cksum.h                      |    10 +
 libcdi/src/cdi_error.c                      |     3 +-
 libcdi/src/cdi_int.c                        |   111 +-
 libcdi/src/cdi_int.h                        |   145 +-
 libcdi/src/cdi_limits.h                     |     7 +-
 libcdi/src/cdi_util.c                       |    73 +-
 libcdi/src/cdilib.c                         | 11827 ++++++----
 libcdi/src/cdipio.h                         |   125 +-
 libcdi/src/cdipio.inc                       |   130 +-
 libcdi/src/cdipioFortran.c                  |    59 +
 libcdi/src/cfortran.h                       |   329 +-
 libcdi/src/cgribexlib.c                     |   199 +-
 libcdi/src/cksum.c                          |     3 +-
 libcdi/src/cksum.h                          |     9 +
 libcdi/src/config.h.in                      |    36 +-
 libcdi/src/create_uuid.h                    |    10 +
 libcdi/src/datetime.h                       |    13 +
 libcdi/src/dmemory.c                        |   343 +-
 libcdi/src/dmemory.h                        |    54 +-
 libcdi/src/error.c                          |     8 +
 libcdi/src/exse.h                           |     9 +
 libcdi/src/extralib.c                       |   190 +-
 libcdi/src/file.c                           |    77 +-
 libcdi/src/gaussgrid.c                      |    20 +-
 libcdi/src/gribapi.c                        |    19 +-
 libcdi/src/gribapi.h                        |    35 +-
 libcdi/src/gribapi_utilities.c              |   150 +-
 libcdi/src/gribapi_utilities.h              |    10 +
 libcdi/src/grid.c                           |   452 +-
 libcdi/src/grid.h                           |    32 +-
 libcdi/src/ieg.h                            |    28 +-
 libcdi/src/ieglib.c                         |   330 +-
 libcdi/src/input_file.c                     |    39 +-
 libcdi/src/input_file.h                     |    14 +-
 libcdi/src/institution.c                    |    25 +-
 libcdi/src/iterator.c                       |   407 +-
 libcdi/src/iterator.h                       |    16 +-
 libcdi/src/iterator_fallback.c              |   132 +-
 libcdi/src/iterator_fallback.h              |    48 +-
 libcdi/src/iterator_grib.c                  |   401 +-
 libcdi/src/iterator_grib.h                  |    49 +-
 libcdi/src/mo_cdi.f90                       | 14128 ++++++------
 libcdi/src/model.c                          |    29 +-
 libcdi/src/namespace.c                      |    58 +-
 libcdi/src/namespace.h                      |    16 +-
 libcdi/src/pio.c                            |   153 -
 libcdi/src/pio.h                            |     8 +-
 libcdi/src/pio_cdf_int.c                    |     4 +-
 libcdi/src/pio_cdf_int.h                    |    12 +-
 libcdi/src/pio_client.c                     |   247 +-
 libcdi/src/pio_client.h                     |    10 +
 libcdi/src/pio_comm.c                       |   841 +-
 libcdi/src/pio_comm.h                       |    93 +-
 libcdi/src/pio_conf.c                       |   296 +
 libcdi/src/pio_conf.h                       |    87 +
 libcdi/src/pio_dbuffer.c                    |     8 +-
 libcdi/src/pio_id_set.h                     |    67 +
 libcdi/src/pio_impl.h                       |    28 +-
 libcdi/src/pio_interface.c                  |   828 +-
 libcdi/src/pio_interface.h                  |    10 +-
 libcdi/src/pio_list_set.c                   |    11 +-
 libcdi/src/pio_mpi_fw_at_all.c              |   232 +
 libcdi/src/pio_mpi_fw_at_reblock.c          |   561 +
 libcdi/src/pio_mpi_fw_ordered.c             |   211 +
 libcdi/src/pio_mpinonb.c                    |   109 +-
 libcdi/src/pio_posixasynch.c                |    81 +-
 libcdi/src/pio_posixfpguardsendrecv.c       |   174 +-
 libcdi/src/pio_posixnonb.c                  |   132 +-
 libcdi/src/pio_record_send.c                |    68 +-
 libcdi/src/pio_roles.c                      |   132 +
 libcdi/src/pio_rpc.c                        |    60 +
 libcdi/src/pio_rpc.h                        |    57 +-
 libcdi/src/pio_serialize.c                  |     6 +-
 libcdi/src/pio_serialize.h                  |    12 +-
 libcdi/src/pio_server.c                     |  1838 +-
 libcdi/src/pio_server.h                     |     4 +-
 libcdi/src/pio_util.c                       |   113 +-
 libcdi/src/pio_util.h                       |    16 +-
 libcdi/src/proprietarySystemWorkarounds.c   |    45 -
 libcdi/src/proprietarySystemWorkarounds.h   |     8 -
 libcdi/src/referenceCounting.c              |    19 +-
 libcdi/src/referenceCounting.h              |    12 +-
 libcdi/src/resource_handle.c                |    27 +-
 libcdi/src/resource_handle.h                |     5 +-
 libcdi/src/resource_unpack.c                |    17 +-
 libcdi/src/resource_unpack.h                |    14 +-
 libcdi/src/serialize.c                      |    10 +
 libcdi/src/serialize.h                      |    10 +-
 libcdi/src/service.h                        |    20 +-
 libcdi/src/servicelib.c                     |   245 +-
 libcdi/src/stream.c                         |   380 +-
 libcdi/src/stream_cdf.c                     |  1543 +-
 libcdi/src/stream_cgribex.c                 |   173 +-
 libcdi/src/stream_ext.c                     |    45 +-
 libcdi/src/stream_fcommon.c                 |     5 +-
 libcdi/src/stream_fcommon.h                 |     5 -
 libcdi/src/stream_grb.c                     |    72 +-
 libcdi/src/stream_gribapi.c                 |   502 +-
 libcdi/src/stream_gribapi.h                 |     4 -
 libcdi/src/stream_history.c                 |     2 +-
 libcdi/src/stream_ieg.c                     |   100 +-
 libcdi/src/stream_record.c                  |    69 +-
 libcdi/src/stream_srv.c                     |    71 +-
 libcdi/src/stream_var.c                     |    80 +-
 libcdi/src/subtype.c                        |   868 +
 libcdi/src/subtype.h                        |   105 +
 libcdi/src/swap.c                           |    29 +-
 libcdi/src/table.c                          |    56 +-
 libcdi/src/table.h                          |    12 +-
 libcdi/src/taxis.c                          |    63 +-
 libcdi/src/taxis.h                          |     4 +-
 libcdi/src/timebase.c                       |     9 +
 libcdi/src/timebase.h                       |    10 +
 libcdi/src/tsteps.c                         |    38 +-
 libcdi/src/util.c                           |    99 +-
 libcdi/src/varscan.c                        |   784 +-
 libcdi/src/varscan.h                        |    14 +-
 libcdi/src/version.c                        |     4 +-
 libcdi/src/vlist.c                          |   333 +-
 libcdi/src/vlist.h                          |    53 +-
 libcdi/src/vlist_att.c                      |    17 +-
 libcdi/src/vlist_var.c                      |   329 +-
 libcdi/src/zaxis.c                          |   288 +-
 libcdi/src/zaxis.h                          |    16 +-
 libcdi/tests/Makefile.am                    |    12 +-
 libcdi/tests/Makefile.in                    |    75 +-
 libcdi/tests/cksum_read.c                   |    10 +-
 libcdi/tests/cksum_verify.c                 |     8 +-
 libcdi/tests/cksum_write.c                  |    63 +-
 libcdi/tests/deco2d_model.c                 |    98 +-
 libcdi/tests/pio_cksum_mpi_fw_at_all.in     |     9 +
 libcdi/tests/pio_cksum_mpi_fw_at_reblock.in |     9 +
 libcdi/tests/pio_cksum_mpi_fw_ordered.in    |     9 +
 libcdi/tests/pio_write.c                    |   185 +-
 libcdi/tests/pio_write.h                    |     3 +
 libcdi/tests/pio_write_run.in               |    22 +-
 libcdi/tests/simple_model.c                 |    88 +-
 libcdi/tests/simple_model_helper.c          |     2 +-
 libcdi/tests/simple_model_helper.h          |    10 +-
 libcdi/tests/stream_cksum.c                 |    10 +-
 libcdi/tests/test_byteswap.c                |    13 +
 libcdi/tests/test_cdf_read.c                |    23 +-
 libcdi/tests/test_cdf_write.c               |    15 +-
 libcdi/tests/test_grib.c                    |    14 +-
 libcdi/tests/test_resource_copy.c           |    24 +-
 libcdi/tests/test_table.c                   |    10 +
 m4/._ax_pthread.m4                          |   Bin 197 -> 0 bytes
 m4/acx_options.m4                           |    59 +-
 src/Adisit.c                                |    20 +-
 src/Afterburner.c                           |    89 +-
 src/Arith.c                                 |    79 +-
 src/Arithc.c                                |    48 +-
 src/Arithdays.c                             |     6 +-
 src/Arithlat.c                              |    10 +-
 src/CDIread.c                               |    21 +-
 src/CDItest.c                               |     6 +-
 src/CDIwrite.c                              |    39 +-
 src/CMOR.c                                  |    51 +
 src/Cat.c                                   |     6 +-
 src/Change.c                                |    18 +-
 src/Change_e5slm.c                          |    18 +-
 src/Cloudlayer.c                            |    69 +-
 src/Collgrid.c                              |   300 +-
 src/Command.c                               |    56 +-
 src/Comp.c                                  |    22 +-
 src/Compc.c                                 |    10 +-
 src/Complextorect.c                         |    12 +-
 src/Cond.c                                  |    30 +-
 src/Cond2.c                                 |    34 +-
 src/Condc.c                                 |    10 +-
 src/Consecstat.c                            |     4 +-
 src/Copy.c                                  |     8 +-
 src/Deltime.c                               |     4 +-
 src/Derivepar.c                             |    46 +-
 src/Detrend.c                               |    55 +-
 src/Diff.c                                  |    69 +-
 src/Distgrid.c                              |   168 +-
 src/Duplicate.c                             |    16 +-
 src/EOFs.c                                  |    55 +-
 src/EcaIndices.c                            |   114 +-
 src/Echam5ini.c                             |    96 +-
 src/Enlarge.c                               |    10 +-
 src/Enlargegrid.c                           |    38 +-
 src/Ensstat.c                               |    65 +-
 src/Ensstat3.c                              |    84 +-
 src/Ensval.c                                |    74 +-
 src/Eof3d.c                                 |    95 +-
 src/Eofcoeff.c                              |    26 +-
 src/Eofcoeff3d.c                            |    34 +-
 src/Exprf.c                                 |    21 +-
 src/FC.c                                    |    16 +-
 src/Filedes.c                               |     2 +-
 src/Fillmiss.c                              |   297 +-
 src/Filter.c                                |    72 +-
 src/Fldrms.c                                |    34 +-
 src/Fldstat.c                               |    47 +-
 src/Fldstat2.c                              |    79 +-
 src/Fourier.c                               |    45 +-
 src/Gengrid.c                               |    19 +-
 src/Gradsdes.c                              |    84 +-
 src/Gridboxstat.c                           |   153 +-
 src/Gridcell.c                              |    18 +-
 src/Gridsearch.c                            |     2 +-
 src/Harmonic.c                              |    35 +-
 src/Hi.c                                    |    20 +-
 src/Histogram.c                             |    34 +-
 src/Importamsr.c                            |    24 +-
 src/Importbinary.c                          |    58 +-
 src/Importcmsaf.c                           |   229 +-
 src/Importobs.c                             |   215 +-
 src/Info.c                                  |    23 +-
 src/Input.c                                 |    29 +-
 src/Intgrid.c                               |    54 +-
 src/Intgridtraj.c                           |    26 +-
 src/Intlevel.c                              |    63 +-
 src/Intlevel3d.c                            |    76 +-
 src/Intntime.c                              |    46 +-
 src/Inttime.c                               |    42 +-
 src/Intyear.c                               |    18 +-
 src/Invert.c                                |    58 +-
 src/Invertlev.c                             |    97 +-
 src/Isosurface.c                            |    27 +-
 src/Kvl.c                                   |     8 +-
 src/Log.c                                   |     2 +-
 src/Maggraph.c                              |    82 +-
 src/Magplot.c                               |    42 +-
 src/Magvector.c                             |    22 +-
 src/Makefile.am                             |    28 +-
 src/Makefile.in                             |   373 +-
 src/Maskbox.c                               |   207 +-
 src/Mastrfu.c                               |    34 +-
 src/Math.c                                  |   182 +-
 src/Merge.c                                 |    62 +-
 src/Mergegrid.c                             |    40 +-
 src/Mergetime.c                             |    22 +-
 src/Merstat.c                               |    71 +-
 src/Monarith.c                              |    26 +-
 src/Mrotuv.c                                |    50 +-
 src/Mrotuvb.c                               |    61 +-
 src/Ninfo.c                                 |     2 +-
 src/Nmltest.c                               |     2 +-
 src/Output.c                                |    20 +-
 src/Outputgmt.c                             |    64 +-
 src/Pack.c                                  |    10 +-
 src/Pinfo.c                                 |    10 +-
 src/Pressure.c                              |    68 +-
 src/Regres.c                                |    18 +-
 src/Remap.c                                 |   201 +-
 src/Remapeta.c                              |   119 +-
 src/Replace.c                               |    95 +-
 src/Replacevalues.c                         |     6 +-
 src/Rhopot.c                                |    20 +-
 src/Rotuv.c                                 |    71 +-
 src/Runpctl.c                               |    28 +-
 src/Runstat.c                               |    68 +-
 src/SSOpar.c                                |    54 +-
 src/Seascount.c                             |    37 +-
 src/Seaspctl.c                              |    54 +-
 src/Seasstat.c                              |    97 +-
 src/Selbox.c                                |   588 +-
 src/Select.c                                |    78 +-
 src/Seloperator.c                           |     6 +-
 src/Seltime.c                               |    76 +-
 src/Selvar.c                                |    53 +-
 src/Set.c                                   |    10 +-
 src/Setbox.c                                |    10 +-
 src/Setgatt.c                               |     6 +-
 src/Setgrid.c                               |    42 +-
 src/Sethalo.c                               |    94 +-
 src/Setmiss.c                               |     6 +-
 src/Setpartab.c                             |    38 +-
 src/Setrcaname.c                            |     6 +-
 src/Settime.c                               |    10 +-
 src/Setzaxis.c                              |    18 +-
 src/Showinfo.c                              |   138 +-
 src/Sinfo.c                                 |    42 +-
 src/Smooth9.c                               |    16 +-
 src/Sort.c                                  |   106 +-
 src/Sorttimestamp.c                         |    22 +-
 src/Specinfo.c                              |     2 +-
 src/Spectral.c                              |    18 +-
 src/Spectrum.c                              |    42 +-
 src/Split.c                                 |    93 +-
 src/Splitrec.c                              |     6 +-
 src/Splitsel.c                              |    18 +-
 src/Splittime.c                             |    62 +-
 src/Splityear.c                             |   103 +-
 src/StringUtilities.c                       |     2 +-
 src/Subtrend.c                              |    10 +-
 src/Tee.c                                   |     6 +-
 src/Templates.c                             |    12 +-
 src/Test.c                                  |    18 +-
 src/Tests.c                                 |    10 +-
 src/Timcount.c                              |    14 +-
 src/Timpctl.c                               |    20 +-
 src/Timselpctl.c                            |    22 +-
 src/Timselstat.c                            |    48 +-
 src/Timsort.c                               |    36 +-
 src/Timstat.c                               |    46 +-
 src/Timstat2.c                              |    48 +-
 src/Timstat3.c                              |    44 +-
 src/Tinfo.c                                 |    76 +-
 src/Tocomplex.c                             |     8 +-
 src/Transpose.c                             |    18 +-
 src/Trend.c                                 |    18 +-
 src/Trms.c                                  |    26 +-
 src/Tstepcount.c                            |    26 +-
 src/Vardup.c                                |    71 +-
 src/Vargen.c                                |   277 +-
 src/Varrms.c                                |    25 +-
 src/Vertcum.c                               |   247 +
 src/Vertintap.c                             |   213 +-
 src/Vertintml.c                             |   167 +-
 src/Vertstat.c                              |   128 +-
 src/Vertwind.c                              |    47 +-
 src/Wct.c                                   |    10 +-
 src/Wind.c                                  |    22 +-
 src/Writegrid.c                             |     6 +-
 src/Writerandom.c                           |    26 +-
 src/XTimstat.c                              |   539 +
 src/YAR.c                                   |    62 +-
 src/Ydayarith.c                             |    26 +-
 src/Ydaypctl.c                              |    24 +-
 src/Ydaystat.c                              |   100 +-
 src/Ydrunpctl.c                             |    41 +-
 src/Ydrunstat.c                             |    57 +-
 src/Yearmonstat.c                           |    20 +-
 src/Yhourarith.c                            |    26 +-
 src/Yhourstat.c                             |    29 +-
 src/Ymonarith.c                             |    54 +-
 src/Ymonpctl.c                              |    41 +-
 src/Ymonstat.c                              |    29 +-
 src/Yseaspctl.c                             |   126 +-
 src/Yseasstat.c                             |   124 +-
 src/Zonstat.c                               |    67 +-
 src/after_dvtrans.c                         |     6 +-
 src/after_fctrans.c                         |    28 +-
 src/after_namelist.c                        |     8 +-
 src/after_sptrans.c                         |    66 +-
 src/after_vertint.c                         |    53 +-
 src/afterburner.h                           |     3 +
 src/afterburnerlib.c                        |   106 +-
 src/cdo.c                                   |   377 +-
 src/cdo.h                                   |     6 -
 src/cdo_getopt.c                            |    10 +-
 src/cdo_history.c                           |    77 +-
 src/cdo_int.h                               |    15 +-
 src/cdo_task.c                              |   233 +
 src/cdo_task.h                              |     9 +
 src/cdo_vlist.c                             |    94 +-
 src/cdotest.c                               |    28 +-
 src/clipping/area.c                         |     8 +-
 src/clipping/clipping.c                     |    42 +-
 src/clipping/grid.h                         |     2 +-
 src/clipping/grid_cell.c                    |     8 +-
 src/clipping/intersection.c                 |    52 +-
 src/clipping/utils.c                        |     4 +-
 src/clipping/utils.h                        |     2 +-
 src/color.c                                 |     7 +-
 src/config.h.in                             |    12 +-
 src/datetime.c                              |    17 +-
 src/datetime.h                              |     5 +
 src/dmemory.h                               |    59 +-
 src/dtypes.h                                |    48 -
 src/ecacore.c                               |   237 +-
 src/exception.c                             |     8 +-
 src/expr.c                                  |   349 +-
 src/expr.h                                  |    10 +-
 src/expr_yacc.c                             |   984 +-
 src/expr_yacc.h                             |    78 +-
 src/features.c                              |    25 +
 src/field.c                                 |    65 +-
 src/field.h                                 |    43 +-
 src/field2.c                                |   179 +-
 src/fieldc.c                                |    18 +
 src/fieldmem.c                              |    76 +-
 src/fieldmer.c                              |   161 +-
 src/fieldzon.c                              |   161 +-
 src/functs.h                                |    11 +-
 src/gradsdeslib.c                           |    22 +-
 src/gradsdeslib.h                           |     2 +-
 src/grid.c                                  |   293 +-
 src/grid.h                                  |    14 +-
 src/grid_area.c                             |    27 +-
 src/grid_gme.c                              |    70 +-
 src/grid_lcc.c                              |     2 +-
 src/grid_rot.c                              |    14 +-
 src/grid_search.c                           |   449 +
 src/grid_search.h                           |    53 +
 src/griddes.c                               |   201 +-
 src/griddes_h5.c                            |    16 +-
 src/griddes_nc.c                            |    24 +-
 src/gridreference.c                         |     2 +
 src/hetaeta.c                               |   486 +-
 src/hetaeta.h                               |     4 +
 src/institution.c                           |    17 +-
 src/interpol.c                              |   190 +-
 src/job.c                                   |    14 +-
 src/kdtreelib/kdtree.h                      |   173 +
 src/kdtreelib/kdtree_cartesian.c            |   531 +
 src/kdtreelib/kdtree_common.c               |   340 +
 src/kdtreelib/kdtree_spherical.c            |   687 +
 src/kdtreelib/pmergesort.c                  |   158 +
 src/kdtreelib/pqueue.c                      |   533 +
 src/kdtreelib/pqueue.h                      |    24 +
 src/kvlist.c                                |    19 +-
 src/list.c                                  |    10 +-
 src/magics_template_parser.c                |    14 +-
 src/merge_sort2.c                           |     8 +-
 src/merge_sort2.h                           |     7 +-
 src/modules.c                               |   132 +-
 src/modules.h                               |     2 +-
 src/namelist.c                              |    36 +-
 src/nearpt3c.h                              |    17 +
 src/normal.c                                |     1 +
 src/nth_element.c                           |    11 +-
 src/nth_element.h                           |     2 +-
 src/operator_help.h                         |   972 +-
 src/percentiles.c                           |   491 +-
 src/percentiles.h                           |    54 +-
 src/{percentiles.c => percentiles_hist.c}   |    42 +-
 src/{percentiles.h => percentiles_hist.h}   |     6 +-
 src/pipe.c                                  |    43 +-
 src/printinfo.h                             |    84 +-
 src/process.c                               |   157 +-
 src/pstream.c                               |   270 +-
 src/readline.c                              |     2 +-
 src/realtime.c                              |     2 +-
 src/remap.h                                 |    20 +-
 src/remap_bicubic_scrip.c                   |    45 +-
 src/remap_bilinear_scrip.c                  |    67 +-
 src/remap_conserv.c                         |   107 +-
 src/remap_conserv_scrip.c                   |    98 +-
 src/remap_distwgt.c                         |   564 +
 src/remap_distwgt_scrip.c                   |   513 -
 src/remap_scrip_io.c                        |    60 +-
 src/remap_search_latbins.c                  |    18 +-
 src/remap_search_reg2d.c                    |    17 +-
 src/remap_store_link.c                      |   197 +-
 src/remap_store_link.h                      |    20 +-
 src/remap_store_link_cnsrv.c                |    22 +-
 src/remaplib.c                              |   315 +-
 src/remapsort.c                             |    33 +-
 src/specspace.c                             |    67 +-
 src/statistic.c                             |    58 +-
 src/statistic.h                             |     4 +
 src/stdnametable.c                          |     6 +-
 src/table.c                                 |    31 +-
 src/template_parser.c                       |     2 +-
 src/text.c                                  |     2 +-
 src/text.h                                  |     2 +
 src/userlog.c                               |    92 +-
 src/util.c                                  |   161 +-
 src/util.h                                  |    26 +-
 src/zaxis.c                                 |    16 +-
 test/Afterburner.test.in                    |    17 +-
 test/Enspctl.test.in                        |    47 +
 test/Ensstat.test.in                        |    47 +
 test/File.test.in                           |    16 +-
 test/Fldpctl.test.in                        |    45 +
 test/Fldstat.test.in                        |    45 +
 test/Genweights.test.in                     |     8 +-
 test/Makefile.am                            |     4 +-
 test/Makefile.in                            |    30 +-
 test/Remap.test.in                          |     8 +-
 test/Ymonstat.test.in                       |    42 +
 test/data/._netcdf_testfile01.nc            |   Bin 197 -> 0 bytes
 test/data/Makefile.am                       |     6 +-
 test/data/Makefile.in                       |     8 +-
 test/data/enspctl100_ref                    |   Bin 0 -> 624 bytes
 test/data/enspctl1_ref                      |   Bin 0 -> 624 bytes
 test/data/enspctl20_ref                     |   Bin 0 -> 624 bytes
 test/data/enspctl25_ref                     |   Bin 0 -> 624 bytes
 test/data/enspctl33_ref                     |   Bin 0 -> 624 bytes
 test/data/enspctl50_ref                     |   Bin 0 -> 624 bytes
 test/data/enspctl66_ref                     |   Bin 0 -> 624 bytes
 test/data/enspctl75_ref                     |   Bin 0 -> 624 bytes
 test/data/enspctl80_ref                     |   Bin 0 -> 624 bytes
 test/data/enspctl99_ref                     |   Bin 0 -> 624 bytes
 test/data/fldavg_ref                        |   Bin 0 -> 104 bytes
 test/data/fldmax_ref                        |   Bin 0 -> 104 bytes
 test/data/fldmean_ref                       |   Bin 0 -> 104 bytes
 test/data/fldmin_ref                        |   Bin 0 -> 104 bytes
 test/data/fldpctl100_ref                    |   Bin 0 -> 104 bytes
 test/data/fldpctl1_ref                      |   Bin 0 -> 104 bytes
 test/data/fldpctl20_ref                     |   Bin 0 -> 104 bytes
 test/data/fldpctl25_ref                     |   Bin 0 -> 104 bytes
 test/data/fldpctl33_ref                     |   Bin 0 -> 104 bytes
 test/data/fldpctl50_ref                     |   Bin 0 -> 104 bytes
 test/data/fldpctl66_ref                     |   Bin 0 -> 104 bytes
 test/data/fldpctl75_ref                     |   Bin 0 -> 104 bytes
 test/data/fldpctl80_ref                     |   Bin 0 -> 104 bytes
 test/data/fldpctl99_ref                     |   Bin 0 -> 104 bytes
 test/data/fldstd1_ref                       |   Bin 0 -> 104 bytes
 test/data/fldstd_ref                        |   Bin 0 -> 104 bytes
 test/data/fldsum_ref                        |   Bin 0 -> 104 bytes
 test/data/fldvar1_ref                       |   Bin 0 -> 104 bytes
 test/data/fldvar_ref                        |   Bin 0 -> 104 bytes
 test/data/ymonavg_ref                       |   Bin 0 -> 624 bytes
 test/data/ymonmax_ref                       |   Bin 0 -> 624 bytes
 test/data/ymonmean_ref                      |   Bin 0 -> 624 bytes
 test/data/ymonmin_ref                       |   Bin 0 -> 624 bytes
 test/data/ymonstd1_ref                      |   Bin 0 -> 624 bytes
 test/data/ymonstd_ref                       |   Bin 0 -> 624 bytes
 test/data/ymonsum_ref                       |   Bin 0 -> 624 bytes
 test/data/ymonvar1_ref                      |   Bin 0 -> 624 bytes
 test/data/ymonvar_ref                       |   Bin 0 -> 624 bytes
 572 files changed, 68651 insertions(+), 56671 deletions(-)

diff --git a/AUTHORS b/AUTHORS
index 5f7e5f2..9898518 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -1,4 +1,3 @@
-
 Uwe Schulzweida, <uwe.schulzweida AT mpimet.mpg.de>, is the main author.
 Ralf Mueller, <ralf.mueller AT mpimet.mpg.de>
 Luis Kornblueh, <luis.kornblueh AT mpimet.mpg.de>
diff --git a/ChangeLog b/ChangeLog
index 238246d..5f3e60d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,188 @@
 2015-10-28  Uwe Schulzweida
 
+	* using CDI library version 1.7.0
+	* Version 1.7.0 released
+
+2015-10-23  Uwe Schulzweida
+
+	* New operator: setmisstodis - Set missing value to the distance-weighted average of the nearest neighbors
+
+2015-10-17  Uwe Schulzweida
+
+	* diff: set checkrel=TRUE
+
+2015-10-11  Uwe Schulzweida
+
+	* removed obsolate  option -p
+
+2015-10-08  Uwe Schulzweida
+
+	* rotuvb: fix parameter parse error for var names starting with a digit
+
+2015-09-30  Uwe Schulzweida
+
+	* usvs_to_uv: if ( rla < 0.0 ) rla += 360.0  (bug fix) [report: Laura Niederdrenk]
+
+2015-09-25  Uwe Schulzweida
+
+        * added operator sortparam to sort all variables by there parameter number
+
+2015-09-15  Uwe Schulzweida
+
+        * merge: search for first time variing stream
+
+2015-09-06  Uwe Schulzweida
+
+	* Select: set default time of enddate to 23:59:59
+
+2015-08-22  Uwe Schulzweida
+
+	* src/Makefile.am: removed -lstd++ (bug fix)
+
+2015-08-19  Uwe Schulzweida
+
+	* expr: added support for calculations with var1[n] and var2[1]
+
+2015-08-18  Uwe Schulzweida
+
+        * ap2pl: use upper level of air_pressure if surface pressure not found
+
+2015-08-14  Uwe Schulzweida
+
+	* select: select also ps for variables on hybrid sigma pressure levels
+
+2015-08-12  Uwe Schulzweida
+
+	* selmon: does not work with negative years (bug fix) [report: Tim Br�cher]
+
+2015-08-08  Uwe Schulzweida
+
+        * replaced farcmul(array, 1./nsets) by farcdiv(array, (double)nsets) to get exactly the same result with and without missvals
+
+2015-08-05  Uwe Schulzweida
+
+	* ap2pl: changed to generalized height
+
+2015-07-27  Uwe Schulzweida
+
+	* removed configure option --with-jasper
+	* remapnn/dis: replaced scrip search by kdtree
+
+2015-07-23  Uwe Schulzweida
+
+	* changed option --history to --no_history
+
+2015-07-21  Uwe Schulzweida
+
+	* tinfo: optimize calculation of monthly and yearly increment
+
+2015-07-16  Uwe Schulzweida
+
+	* collgrid: added support for curvilinear grids
+
+2015-06-27  Uwe Schulzweida
+
+	* New operator: setmisstonn - Set missing value to nearest neightbour
+
+2015-06-26  Uwe Schulzweida
+
+	* remapdis: fixed seg fault on blizzard with large target grid (possibly compiler bug)
+
+2015-06-21  Uwe Schulzweida
+
+	* topo, temp, mask: added optional parameter for target grid
+
+2015-06-19  Uwe Schulzweida
+
+        * for: added docu
+
+2015-06-18  Uwe Schulzweida
+
+	* Ydrunstat: don't set the year to the minimum of years found on output timestep
+	* Ydaystat: set the year to the minimum of years found on output timestep
+
+2015-06-17  Uwe Schulzweida
+
+	* bug fix if table filename is a directory [Bug #5891]
+
+2015-06-12  Uwe Schulzweida
+
+	* diff: disable checkrel
+
+2015-06-10  Karl-Hermann Wieners
+
+	* expr: operators return 0 for arithmetics on constants [Bug #5875]
+
+2015-06-03  Uwe Schulzweida
+
+	* removed flag CMP_CODE
+	* replace: compare only parameter name; removed check of parameter number
+	* setpartabn: replace vlistDefVarCode() by vlistDefVarParam()
+
+2015-06-01  Uwe Schulzweida
+
+	* vertvar, vertstd: changed to weighted var/std if layer bounds are available
+
+2015-05-29  Uwe Schulzweida
+
+	* yseaspctl: check of verification date failed [Bug #5810]
+
+2015-05-28  Uwe Schulzweida
+
+	* Remap: fixed memory leak for r=max_remaps-1
+
+2015-05-26  Uwe Schulzweida
+
+	* New operator: vertstd1  - Vertical standard deviation [Divisor is (n-1)]
+	* New operator: vertvar1  - Vertical variance [Divisor is (n-1)]
+	* New operator: gridboxstd1 - Gridbox standard deviation [Divisor is (n-1)]
+	* New operator: gridboxvar1 - Gridbox variance [Divisor is (n-1)]
+	* New operator: merstd1  - Meridional standard deviation [Divisor is (n-1)]
+	* New operator: mervar1  - Meridional variance [Divisor is (n-1)]
+	* New operator: zonstd1  - Zonal standard deviation [Divisor is (n-1)]
+	* New operator: zonvar1  - Zonal variance [Divisor is (n-1)]
+
+2015-05-22  Uwe Schulzweida
+
+	* New operator: yseasvar1  - Multi-year seasonally variance [Divisor is (n-1)]
+	* New operator: yseasstd1  - Multi-year seasonally standard deviation [Divisor is (n-1)]
+	* New operator: seasvar1  - Seasonal variance [Divisor is (n-1)]
+	* New operator: seasstd1  - Seasonal standard deviation [Divisor is (n-1)]
+
+2015-05-21  Uwe Schulzweida
+
+	* after: extent incomming GEOPOTHEIGHT on full 3d hybrid levels to half 3d hybrid levels (bug fix)
+
+2015-05-19  Uwe Schulzweida
+
+        * Fldstat2: added support for option --reduce_dim
+
+2015-05-18  Uwe Schulzweida
+
+        * splityear*: support for constant fields is missing [Bug #5759]
+
+2015-05-17  Uwe Schulzweida
+
+	* env. CDO_TIMESTAT_DATE does not work [Bug #5758]
+
+2015-05-02  Uwe Schulzweida
+
+	* sqr: added support for complex numbers
+
+2015-05-01  Uwe Schulzweida
+
+	* masklonlatbox: added support for curvilinear grids
+
+2015-04-29  Uwe Schulzweida
+
+	* remapbil: optimized version without weights
+
+2015-04-28  Uwe Schulzweida
+
+	* selgrid: added parameter type var=varname to select all variables with the same grid as varname
+
+2015-04-28  Uwe Schulzweida
+
 	* using CDI library version 1.6.9
 	* Version 1.6.9 released
 	* clipping: update to YAC version 1.0.3
diff --git a/Makefile.am b/Makefile.am
index 77c6908..d55fc98 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,7 +1,7 @@
 # Process this file with automake to produce Makefile.in
 SUBDIRS = libcdi src contrib test/data test
 #
-EXTRA_DIST=config/default OPERATORS doc/cdo.pdf doc/cdo_refcard.pdf cdo.spec README
+EXTRA_DIST=config/default OPERATORS doc/cdo.pdf doc/cdo_eca.pdf doc/cdo_refcard.pdf cdo.spec README
 #
 ACLOCAL_AMFLAGS = -I m4
 #
diff --git a/Makefile.in b/Makefile.in
index 1d1ead8..d637110 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -218,6 +218,7 @@ CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
 CLDFLAGS = @CLDFLAGS@
 CLIBS = @CLIBS@
+CMOR_LIBS = @CMOR_LIBS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CURL_INCLUDE = @CURL_INCLUDE@
@@ -263,7 +264,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-JASPER_LIBS = @JASPER_LIBS@
 LD = @LD@
 LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
@@ -379,7 +379,7 @@ top_srcdir = @top_srcdir@
 # Process this file with automake to produce Makefile.in
 SUBDIRS = libcdi src contrib test/data test
 #
-EXTRA_DIST = config/default OPERATORS doc/cdo.pdf doc/cdo_refcard.pdf cdo.spec README
+EXTRA_DIST = config/default OPERATORS doc/cdo.pdf doc/cdo_eca.pdf doc/cdo_refcard.pdf cdo.spec README
 #
 ACLOCAL_AMFLAGS = -I m4
 #
diff --git a/NEWS b/NEWS
index 9aedde5..d864dda 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,38 @@
 CDO NEWS
 --------
 
+Version 1.7.0 (28 October 2015):
+
+   New features:
+     * added support for netCDF Scalar Coordinate Variables
+     * added support for hybrid sigma pressure coordinates following the CF convention
+     * added option --percentile to select different percentile methods
+       Available methods: nrank, nist, numpy, numpy_lower, numpy_higher, numpy_nearest
+     * distgrid: added support for curvilinear grids
+     * collgrid: added support for curvilinear grids
+   New operators:
+     * remapycon: First order conservative remapping (new implementation of remapcon)
+     * genycon: Generate 1st order conservative remap weights (new implementation of gencon)
+     * setmisstonn: Set missing value to nearest neightbor
+     * setmisstodis: Set missing value to the distance-weighted average of the nearest neighbors
+     * ap2pl: Interpolate 3D variables on hybrid sigma height coordinates to pressure levels
+     * vertstd1: Vertical standard deviation [Divisor is (n-1)]
+     * vertvar1: Vertical variance [Divisor is (n-1)]
+     * seasvar1: Seasonal variance [Divisor is (n-1)]
+     * seasstd1: Seasonal standard deviation [Divisor is (n-1)]
+     * yseasvar1: Multi-year seasonally variance [Divisor is (n-1)]
+     * yseasstd1: Multi-year seasonally standard deviation [Divisor is (n-1)]
+   Changed operators:
+     * remapnn, remapdis: replaced scrip search by kdtree (optimization)
+     * vertvar, vertstd: changed to weighted var/std if layer bounds are available
+   Fixed bugs:
+     * cdo -t table_file does not complain if table_file is a directory [Bug #5891]
+     * expr: operators return 0 for arithmetics on constants [Bug #5875]
+     * env. CDO_TIMESTAT_DATE does not work [Bug #5758]
+     * splityear*: support for constant fields is missing [Bug #5759]
+     * yseaspctl: check of verification date failed [Bug #5810]
+     * Converting rotated lat-lon netcdf to/from grib: flip sign of the angle of rotation [Bug #5870]
+
 Version 1.6.9 (28 April 2015):
 
    New features:
diff --git a/OPERATORS b/OPERATORS
index 8594c75..e6a283e 100644
--- a/OPERATORS
+++ b/OPERATORS
@@ -163,6 +163,8 @@ Operator catalog:
    Setmiss       setmisstoc      Set missing value to constant
    Setmiss       setrtomiss      Set range to missing value
    Setmiss       setvrange       Set valid range
+   Setmiss       setmisstonn     Set missing value to nearest neighbor
+   Setmiss       setmisstodis    Set missing value to distance-weighted average
 -------------------------------------------------------------
    Arithmetic
 -------------------------------------------------------------
@@ -255,31 +257,39 @@ Operator catalog:
    Zonstat       zonsum          Zonal sum
    Zonstat       zonmean         Zonal mean
    Zonstat       zonavg          Zonal average
-   Zonstat       zonvar          Zonal variance
    Zonstat       zonstd          Zonal standard deviation
+   Zonstat       zonstd1         Zonal standard deviation
+   Zonstat       zonvar          Zonal variance
+   Zonstat       zonvar1         Zonal variance
    Zonstat       zonpctl         Zonal percentiles
    Merstat       mermin          Meridional minimum
    Merstat       mermax          Meridional maximum
    Merstat       mersum          Meridional sum
    Merstat       mermean         Meridional mean
    Merstat       meravg          Meridional average
-   Merstat       mervar          Meridional variance
    Merstat       merstd          Meridional standard deviation
+   Merstat       merstd1         Meridional standard deviation
+   Merstat       mervar          Meridional variance
+   Merstat       mervar1         Meridional variance
    Merstat       merpctl         Meridional percentiles
    Gridboxstat   gridboxmin      Gridbox minimum
    Gridboxstat   gridboxmax      Gridbox maximum
    Gridboxstat   gridboxsum      Gridbox sum
    Gridboxstat   gridboxmean     Gridbox mean
    Gridboxstat   gridboxavg      Gridbox average
-   Gridboxstat   gridboxvar      Gridbox variance
    Gridboxstat   gridboxstd      Gridbox standard deviation
+   Gridboxstat   gridboxstd1     Gridbox standard deviation
+   Gridboxstat   gridboxvar      Gridbox variance
+   Gridboxstat   gridboxvar1     Gridbox variance
    Vertstat      vertmin         Vertical minimum
    Vertstat      vertmax         Vertical maximum
    Vertstat      vertsum         Vertical sum
    Vertstat      vertmean        Vertical mean
    Vertstat      vertavg         Vertical average
-   Vertstat      vertvar         Vertical variance
    Vertstat      vertstd         Vertical standard deviation
+   Vertstat      vertstd1        Vertical standard deviation
+   Vertstat      vertvar         Vertical variance
+   Vertstat      vertvar1        Vertical variance
    Timselstat    timselmin       Time range minimum
    Timselstat    timselmax       Time range maximum
    Timselstat    timselsum       Time range sum
@@ -356,8 +366,10 @@ Operator catalog:
    Seasstat      seassum         Seasonal sum
    Seasstat      seasmean        Seasonal mean
    Seasstat      seasavg         Seasonal average
-   Seasstat      seasvar         Seasonal variance
    Seasstat      seasstd         Seasonal standard deviation
+   Seasstat      seasstd1        Seasonal standard deviation
+   Seasstat      seasvar         Seasonal variance
+   Seasstat      seasvar1        Seasonal variance
    Seaspctl      seaspctl        Seasonal percentiles
    Yhourstat     yhourmin        Multi-year hourly minimum
    Yhourstat     yhourmax        Multi-year hourly maximum
@@ -393,8 +405,10 @@ Operator catalog:
    Yseasstat     yseassum        Multi-year seasonal sum
    Yseasstat     yseasmean       Multi-year seasonal mean
    Yseasstat     yseasavg        Multi-year seasonal average
-   Yseasstat     yseasvar        Multi-year seasonal variance
    Yseasstat     yseasstd        Multi-year seasonal standard deviation
+   Yseasstat     yseasstd1       Multi-year seasonal standard deviation
+   Yseasstat     yseasvar        Multi-year seasonal variance
+   Yseasstat     yseasvar1       Multi-year seasonal variance
    Yseaspctl     yseaspctl       Multi-year seasonal percentiles
    Ydrunstat     ydrunmin        Multi-year daily running minimum
    Ydrunstat     ydrunmax        Multi-year daily running maximum
@@ -431,24 +445,27 @@ Operator catalog:
 -------------------------------------------------------------
    Interpolation
 -------------------------------------------------------------
-   Remapgrid     remapbil        Bilinear interpolation
-   Remapgrid     remapbic        Bicubic interpolation
-   Remapgrid     remapdis        Distance-weighted average remapping
-   Remapgrid     remapnn         Nearest neighbor remapping
-   Remapgrid     remapcon        First order conservative remapping
-   Remapgrid     remapcon2       Second order conservative remapping
-   Remapgrid     remaplaf        Largest area fraction remapping
-   Genweights    genbil          Generate bilinear interpolation weights
-   Genweights    genbic          Generate bicubic interpolation weights
-   Genweights    gendis          Generate distance-weighted average remap weights
-   Genweights    gennn           Generate nearest neighbor remap weights
-   Genweights    gencon          Generate 1st order conservative remap weights
-   Genweights    gencon2         Generate 2nd order conservative remap weights
-   Genweights    genlaf          Generate largest area fraction remap weights
-   Remap         remap           SCRIP grid remapping
+   Remapbil      remapbil        Bilinear interpolation
+   Remapbil      genbil          Generate bilinear interpolation weights
+   Remapbic      remapbic        Bicubic interpolation
+   Remapbic      genbic          Generate bicubic interpolation weights
+   Remapnn       remapnn         Nearest neighbor remapping
+   Remapnn       gennn           Generate nearest neighbor remap weights
+   Remapdis      remapdis        Distance-weighted average remapping
+   Remapdis      gendis          Generate distance-weighted average remap weights
+   Remapycon     remapycon       First order conservative remapping
+   Remapycon     genycon         Generate 1st order conservative remap weights
+   Remapcon      remapcon        First order conservative remapping
+   Remapcon      gencon          Generate 1st order conservative remap weights
+   Remapcon2     remapcon2       Second order conservative remapping
+   Remapcon2     gencon2         Generate 2nd order conservative remap weights
+   Remaplaf      remaplaf        Largest area fraction remapping
+   Remaplaf      genlaf          Generate largest area fraction remap weights
+   Remap         remap           Grid remapping
    Remapeta      remapeta        Remap vertical hybrid level
    Vertint       ml2pl           Model to pressure level interpolation
    Vertint       ml2hl           Model to height level interpolation
+   Vertintap     ap2pl           Model to pressure level interpolation
    Intlevel      intlevel        Linear level interpolation
    Intlevel3d    intlevel3d      Linear level interpolation onto a 3d vertical coordinate
    Intlevel3d    intlevelx3d     like intlevel3d but with extrapolation
@@ -500,6 +517,8 @@ Operator catalog:
    Timsort       timsort         Sort over the time
    Vargen        const           Create a constant field
    Vargen        random          Create a field with random numbers
+   Vargen        topo            Create a field with topography
+   Vargen        for             Create a time series
    Vargen        stdatm          Create values for pressure and temperature for hydrostatic atmosphere
    Rotuv         rotuvb          Backward rotation
    Mastrfu       mastrfu         Mass stream function
@@ -518,8 +537,6 @@ Operator catalog:
    Strbre        strbre          Strong breeze days index per time period
    Strgal        strgal          Strong gale days index per time period
    Hurr          hurr            Hurricane days index per time period
-   Fillmiss      fillmiss        Fill missing values
-   Fillmiss      fillmiss2       Fill missing values
 -------------------------------------------------------------
    Climate indices
 -------------------------------------------------------------
diff --git a/cdo.spec b/cdo.spec
index 68401e9..44e87cc 100644
--- a/cdo.spec
+++ b/cdo.spec
@@ -4,7 +4,7 @@
 
 Name:           cdo
 #BuildRequires:  
-Version:        1.6.9
+Version:        1.7.0
 Release:        1
 Summary:        Climate Data Operators
 License:        GNU GENERAL PUBLIC LICENSE Version 2, June 1991
diff --git a/config/default b/config/default
index beee417..7216c98 100755
--- a/config/default
+++ b/config/default
@@ -29,82 +29,126 @@ set -x
 case "${HOSTNAME}" in
 # i386-apple-darwin10
     bailung*|d133*|d134*)
-        CDOLIBS="--with-fftw3 \
-                 --with-jasper=$HOME/local \
-                 --with-grib_api=$HOME/local/gribapi-1.12.3 \
-                 --with-netcdf=$HOME/local \
-                 --with-hdf5=$HOME/local \
-                 --with-szlib=$HOME/local \
-                 --with-udunits2=$HOME/local/udunits-2.1.24 \
+        CDOLIBS="--enable-nearpt3 \
+                 --with-fftw3 \
+                 --with-grib_api=$HOME/local/grib_api-1.13.1 \
+                 --with-netcdf=$HOME/local/netcdf-c-4.3.3.1-threadsafe \
+                 --with-hdf5=$HOME/local/hdf5-1.8.15-threadsafe \
+                 --with-udunits2=/opt/local \
+                 --with-curl=/opt/local \
                  --with-proj=/opt/local \
-                 --with-curl=/opt/local"
+                 --with-szlib=$HOME/local"
 
         if  test "$COMP" = icc ; then
 	  ${CONFPATH}configure  \
                     $CDOLIBS \
-                    LIBS="-L/opt/local/lib -lopenjpeg" \
-	            CC=icc CFLAGS="-g -Wall -O2 -vec-report2 -march=native -fp-model source -fast-transcendentals"
+	            CC=icc CFLAGS="-g -Wall -Wwrite-strings -O2 -qopt-report=5 -march=native" CXX=icpc
+        elif  test "$COMP" = icpc ; then
+	  ${CONFPATH}configure  \
+                    $CDOLIBS \
+	            CC=icpc CFLAGS="-g -std=c++11 -Wall -O2 -qopt-report=5 -march=native"
+        elif  test "$COMP" = clang++ ; then
+	  ${CONFPATH}configure  \
+                    $CDOLIBS \
+	            CC=clang++ CFLAGS="-g -Wall -O3"
         elif  test "$COMP" = clang ; then
 	  ${CONFPATH}configure  \
                     $CDOLIBS \
-                    LIBS="-L/opt/local/lib -lopenjpeg" \
-	            CC=clang CFLAGS="-g -Wall -O3"
+	            CC=clang CFLAGS="-g -Wall -Wwrite-strings -O3"
+        elif  test "$COMP" = g++ ; then
+	  ${CONFPATH}configure  \
+                    $CDOLIBS \
+	            CC=g++ CFLAGS="-g -std=c++14 -Wall -W -Wfloat-equal -pedantic -O3 -march=native"
         else
 	  ${CONFPATH}configure --prefix=$HOME/local \
                     --enable-maintainer-mode \
                     $CDOLIBS \
-                    LIBS="-L/opt/local/lib -lopenjpeg" \
-	            CC=gcc CFLAGS="-g -pipe -Wall -W -Wfloat-equal -pedantic -O3 -march=native -fstack-protector"
+	            CC=gcc CFLAGS="-g -pipe -Wall -W -Wfloat-equal -Wwrite-strings -pedantic -O3 -march=native -fstack-protector"
 #                    --with-libxml2=/usr 
 #                    --with-magics=/Users/m214003/local/magics-2.14.9
         fi
 	;;
     hama*)
 #        CDOLIBS="--with-fftw3 \
-#                 --with-jasper=/opt/local \
-#                 --with-grib_api=$HOME/local/gribapi-1.13.0 \
 #                 --with-netcdf=/opt/local \
 #                 --with-hdf5=/opt/local \
 #                 --with-szlib=$HOME/local \
 #                 --with-proj=/opt/local \
+#                 --with-cmor=/Users/m214003/work/CMOR \
 #                 --with-curl=/opt/local"
-        CDOLIBS="--with-fftw3 \
+        CDOLIBS="--enable-nearpt3 \
+                 --with-fftw3 \
                  --with-grib_api=$HOME/local/gribapi-1.13.0 \
                  --with-netcdf=$HOME/local \
-                 --with-hdf5=$HOME/local"
+                 --with-hdf5=$HOME/local \
+                 --with-proj=/opt/local"
 
         if  test "$COMP" = icc ; then
 	  ${CONFPATH}configure --prefix=$HOME/local \
                     $CDOLIBS \
-	            CC=icc CFLAGS="-g -Wall -O2 -qopt-report=5 -march=native -openmp -fp-model source -fast-transcendentals"
+	            CC=icc CFLAGS="-g -Wall -Wwrite-strings -O2 -qopt-report=5 -march=native" CXX=icpc
+        elif  test "$COMP" = icpc ; then
+	  ${CONFPATH}configure  \
+                    $CDOLIBS \
+	            CC=icpc CFLAGS="-g -std=c++11 -Wall -O2 -qopt-report=5 -march=native"
+        elif  test "$COMP" = clang++ ; then
+	  ${CONFPATH}configure  \
+                    $CDOLIBS \
+	            CC=clang++ CFLAGS="-g -Wall -O3"
         elif  test "$COMP" = clang ; then
 	  ${CONFPATH}configure  \
                     $CDOLIBS \
-	            CC=clang CFLAGS="-g -Wall -Ofast -march=native"
+	            CC=clang CFLAGS="-g -Wall -Wwrite-strings -Ofast -march=native"
+        elif  test "$COMP" = g++ ; then
+	  ${CONFPATH}configure  \
+                    $CDOLIBS \
+	            CC=g++ CFLAGS="-g -std=c++14 -Wall -W -Wfloat-equal -pedantic -O3"
         else
 	  ${CONFPATH}configure --prefix=$HOME/local \
                     --enable-maintainer-mode \
                     $CDOLIBS \
-	            CC=gcc CFLAGS="-g -pipe -Wall -W -Wfloat-equal -pedantic -O3 -fstack-protector"
+	            CC=gcc CFLAGS="-g -std=c11 -pipe -Wall -Wwrite-strings -W -Wfloat-equal -pedantic -O3 -march=native -fstack-protector -Wa,-q"
 #                    --with-libxml2=/usr \
 #                    --with-magics=/Users/m214003/local/Magics-2.18.14nio \
         fi
 	;;
+    daint*)
+        if  test "$COMP" = icc ; then
+          CDOLIBS="--with-netcdf=/opt/cray/netcdf/4.3.3.1/INTEL/14.0"
+	  ${CONFPATH}configure --prefix=$HOME/local \
+                    $CDOLIBS \
+	            CC=icc CFLAGS="-g -Wall -O2 -qopt-report=5 -march=native -openmp"
+        elif  test "$COMP" = pgcc ; then
+          CDOLIBS="--with-netcdf=/opt/cray/netcdf/4.3.3.1/PGI/15.3"
+	  ${CONFPATH}configure --disable-openmp \
+                    $CDOLIBS \
+	            CC=pgcc CFLAGS="-g -O2"
+        elif  test "$COMP" = cray ; then
+          CDOLIBS="--with-netcdf=/opt/cray/netcdf/4.3.3.1/CRAY/8.3"
+	  ${CONFPATH}configure --disable-openmp \
+                    $CDOLIBS \
+	            CC=cc CFLAGS="-g -O2 -h noomp"
+        else
+          CDOLIBS="--with-netcdf=/opt/cray/netcdf/4.3.3.1/GNU/4.9"
+	  ${CONFPATH}configure --prefix=$HOME/local \
+                    $CDOLIBS \
+	            CC=gcc CFLAGS="-g -pipe -Wall -W -Wfloat-equal -pedantic -O3 -march=native -fstack-protector -Wa,-q"
+        fi
+	;;
 # x86_64-squeeze-x64-linux
     thunder*)
-        CDOLIBS="--with-jasper=/sw/squeeze-x64/jasper-1.900.1-static \
-                    --with-grib_api=/sw/squeeze-x64/grib_api-1.13.0-static-gccsys \
-                    --with-netcdf=/sw/squeeze-x64/netcdf-4.2-static \
-                    --with-hdf5=/sw/squeeze-x64/hdf5-1.8.8-static \
-                    --with-szlib=/sw/squeeze-x64/szip-2.1 \
-                    --with-udunits2=/sw/squeeze-x64/udunits-2.1.19 \
-                    --with-proj=/sw/squeeze-x64/proj-4.7.0"
+        CDOLIBS="--with-grib_api=/sw/squeeze-x64/grib_api-1.13.0-static-gccsys \
+                 --with-netcdf=/sw/squeeze-x64/netcdf-4.2-static \
+                 --with-hdf5=/sw/squeeze-x64/hdf5-1.8.8-static \
+                 --with-szlib=/sw/squeeze-x64/szip-2.1 \
+                 --with-udunits2=/sw/squeeze-x64/udunits-2.1.19 \
+                 --with-proj=/sw/squeeze-x64/proj-4.7.0"
 
         if  test "$COMP" = icc ; then
           ${CONFPATH}configure --prefix=$HOME/local --exec_prefix=$HOME/local/thunder \
                     --with-fftw3 \
                     $CDOLIBS \
-	            CC=icc CFLAGS="-g -Wall -O2 -qopt-report=5 -march=native -fp-model source -fast-transcendentals"
+	            CC=icc CFLAGS="-g -Wall -O2 -qopt-report=5 -march=native"
         elif  test "$COMP" = pgcc ; then
           ${CONFPATH}configure --prefix=$HOME/local --exec_prefix=$HOME/local/thunder \
                     $CDOLIBS \
@@ -116,6 +160,31 @@ case "${HOSTNAME}" in
                     CC=gcc CFLAGS='-g -Wall -O3'
 	fi
 	;;
+# mistral
+    mlogin*)
+        CDOLIBS="--with-grib_api=/sw/rhel6-x64/grib_api/grib_api-1.13.0-gcc48 \
+                 --with-netcdf=/sw/rhel6-x64/netcdf/netcdf_c-4.3.2-gcc48 \
+                 --with-hdf5=/sw/rhel6-x64/hdf5/hdf5-1.8.14-threadsafe-gcc48 \
+                 --with-szlib=/sw/rhel6-x64/sys/szip-2.1-gcc48 \
+                 --with-udunits2=/sw/rhel6-x64/util/udunits-2.2.17-gcc48 \
+                 --with-proj=/sw/rhel6-x64/graphics/proj4-4.9.1-gcc48"
+
+        if  test "$COMP" = icc ; then
+          ${CONFPATH}configure --prefix=$HOME/local \
+                    --with-fftw3 \
+                    $CDOLIBS \
+	            CC=icc CFLAGS="-g -Wall -O2 -qopt-report=5 -march=native"
+        elif  test "$COMP" = pgcc ; then
+          ${CONFPATH}configure --disable-openmp \
+                    $CDOLIBS \
+	            CC=pgcc CFLAGS="-g -fast"
+	else
+          ${CONFPATH}configure --prefix=$HOME/local \
+                    --with-fftw3 \
+                    $CDOLIBS \
+                    CC=gcc CFLAGS='-g -Wall -O3 -march=native'
+	fi
+	;;
 # x86_64-unknown-linux-gnu
     btc*)
         if  test "$COMP" = icc ; then
@@ -124,7 +193,7 @@ case "${HOSTNAME}" in
 	            --with-netcdf=/lustre/sw/rhel6-x64/netcdf/netcdf_c-4.3.2-intel15 \
                     --with-hdf5=/lustre/sw/rhel6-x64/hdf5/hdf5-1.8.14-threadsafe-intel15 \
                     --with-fftw3 \
-	            CC=icc CFLAGS="-g -Wall -O2 -qopt-report=5 -xCORE-AVX2 -fp-model source -fast-transcendentals"
+	            CC=icc CFLAGS="-g -Wall -O2 -qopt-report=5 -xCORE-AVX2"
 	else
           ${CONFPATH}configure --prefix=$HOME/local \
                     --with-grib_api=/lustre/sw/rhel6-x64/grib_api/grib_api-1.13.0-gcc48 \
@@ -147,20 +216,18 @@ case "${HOSTNAME}" in
                     CC=icc CFLAGS="-g -O2 -Wall -fno-alias"
 	;;
 # x86_64-archlinux
-    thingol*)
+    luthien*)
  	${CONFPATH}configure --prefix=$HOME/local \
                     --program-suffix=-dev \
                     --enable-maintainer-mode \
-	            --with-netcdf=$HOME/src/cdo/branches/libs4cdo/build-dev \
-	              --with-hdf5=$HOME/src/cdo/branches/libs4cdo/build-dev \
-                     --with-szlib=$HOME/src/cdo/branches/libs4cdo/build-dev \
-                  --with-grib_api=$HOME/src/cdo/branches/libs4cdo/build-dev \
-                    --with-jasper=$HOME/src/cdo/branches/libs4cdo/build-dev \
-                    --with-magics=$HOME/src/cdo/branches/libs4cdo/build-dev \
-                    --with-libxml2=/usr \
+	            --with-netcdf \
+	              --with-hdf5 \
+                     --with-szlib \
+                  --with-grib_api \
+                  --with-udunits2 \
+                  --with-proj \
                       --with-pic \
-                      CC=gcc CFLAGS="-g -Wall -O2 -DWITH_DATA" \
-                      LDFLAGS='-L/home/ram/local/netcdf-4.1.2/lib -L/usr/lib64 -L/usr/lib -lhdf5_hl -lhdf5  -lz -lm -lhdf5_hl -lhdf5 -lz  -lcurl -L/usr/local/lib64 -L/usr/X11R6/lib64 -lpangocairo-1.0 -lpango-1.0 -lgobject-2.0 -lglib-2.0 -lcairo   -lexpat -lpthread -lfontconfig -lz -lgd -lproj -lgrib_api -lpng -lxml2 -lm -ljasper -lopenjpeg   -L/home/ram/local/netcdf-4.1.2/lib -lnetcdf_c++ -lnetcdf  -lcurl  -lstdc++ -lgfortran'
+                      CC=gcc CFLAGS="-g -Wall -O2 -DWITH_DATA" LIBS=-lopenjpeg
 	;;
 # standard workstations at MPI-M x86_64-lenny
     mpipc* )
@@ -219,7 +286,6 @@ case "${HOSTNAME}" in
                     --with-proj=/sw/centos58-x64/proj-4.7.0 \
                     --with-hdf5=/sw/centos58-x64/hdf5-1.8.10-patch1 \
                     --with-udunits2=/sw/centos58-x64/udunits-2.1.19 \
-                    --with-jasper=/sw/centos58-x64/jasper-1.900.1 \
                     --with-grib_api=/sw/centos58-x64/grib_api-1.12.3 \
                     --with-netcdf=/sw/centos58-x64/netcdf-4.2.1.1 \
                     --with-szlib=/sw/centos58-x64/szip-2.1 \
diff --git a/configure b/configure
index 426a0fd..cc5ef9b 100755
--- a/configure
+++ b/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for cdo 1.6.9.
+# Generated by GNU Autoconf 2.68 for cdo 1.7.0.
 #
 # Report bugs to <http://mpimet.mpg.de/cdo>.
 #
@@ -570,8 +570,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='cdo'
 PACKAGE_TARNAME='cdo'
-PACKAGE_VERSION='1.6.9'
-PACKAGE_STRING='cdo 1.6.9'
+PACKAGE_VERSION='1.7.0'
+PACKAGE_STRING='cdo 1.7.0'
 PACKAGE_BUGREPORT='http://mpimet.mpg.de/cdo'
 PACKAGE_URL=''
 
@@ -653,7 +653,7 @@ ENABLE_GRIB
 ENABLE_GRIBAPI
 GRIB_API_LIBS
 GRIB_API_INCLUDE
-JASPER_LIBS
+CMOR_LIBS
 NETCDF_LIBS
 NETCDF_INCLUDE
 NETCDF_ROOT
@@ -685,9 +685,9 @@ am__fastdepCXX_TRUE
 CXXDEPMODE
 ac_ct_CXX
 CXXFLAGS
-CXX
 AS
 OPENMP_CFLAGS
+CXX
 CPP
 OTOOL64
 OTOOL
@@ -824,7 +824,7 @@ with_zlib
 with_szlib
 with_hdf5
 with_netcdf
-with_jasper
+with_cmor
 with_grib_api
 enable_grib
 enable_cgribex
@@ -1395,7 +1395,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures cdo 1.6.9 to adapt to many kinds of systems.
+\`configure' configures cdo 1.7.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1465,7 +1465,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of cdo 1.6.9:";;
+     short | recursive ) echo "Configuration of cdo 1.7.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1520,14 +1520,11 @@ Optional Packages:
                           location of hdf5 library, NETCDF4 requires hdf5 high
                           level interface
   --with-netcdf=<yes|no|directory> (default=no)
-                          location of netcdf library (lib and include subdirs)
-  --with-jasper=<directory>
-                          Specify location of JASPER library. You must specify
-                          its location if GRIB_API was built with JASPER.
-  --with-grib_api=<yes|no|directory>
-                          library for grib2 compression; if a directory is
-                          given, it will be used as a value for
-                          --with-jasper-root
+                          location of netCDF library (lib and include subdirs)
+  --with-cmor=<directory> Specify location of CMOR library.
+  --with-grib_api=<yes|no|directory> (default=no)
+                          location of GRIB_API library (lib and include
+                          subdirs)
   --with-fftw3            enable support for fftw3
   --with-proj=<directory> Specify location of PROJ library for cartographic
                           projections.
@@ -1619,7 +1616,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-cdo configure 1.6.9
+cdo configure 1.7.0
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -2212,7 +2209,7 @@ cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by cdo $as_me 1.6.9, which was
+It was created by cdo $as_me 1.7.0, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -3161,7 +3158,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='cdo'
- VERSION='1.6.9'
+ VERSION='1.7.0'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -12099,6 +12096,98 @@ else
   CC="$ac_cv_prog_CC"
 fi
 
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}g++", so it can be a program name with args.
+set dummy ${ac_tool_prefix}g++; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CXX="${ac_tool_prefix}g++"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CXX"; then
+  ac_ct_CXX=$CXX
+  # Extract the first word of "g++", so it can be a program name with args.
+set dummy g++; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CXX="g++"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_CXX" = x; then
+    CXX=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CXX=$ac_ct_CXX
+  fi
+else
+  CXX="$ac_cv_prog_CXX"
+fi
+
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5
 $as_echo_n "checking for $CC option to accept ISO C99... " >&6; }
 if ${ac_cv_prog_cc_c99+:} false; then :
@@ -17479,7 +17568,7 @@ case "$CC" in
   icc*)   COMP_VERSION=`$CC --version | head -n 1`;;
   sxc*)   COMP_VERSION=`$CC -V 2>&1   | tail -n 1`;;
   xlc*)   COMP_VERSION=`$CC -qversion 2>&1   | head -n 1`;;
-  *)      COMP_VERSION=`$CC -V 2>&1   | head -n 1` | grep -v error;;
+  *)      COMP_VERSION=`$CC -V 2>&1   | head -n 1 | grep -v error`;;
 esac
 
 if test -z "$COMP_VERSION" ; then COMP_VERSION="unknown"; fi;
@@ -17600,29 +17689,35 @@ fi
 done
 
 #  ----------------------------------------------------------------------
+#  Enable NEARPT3 support
+# AC_MSG_CHECKING([for nearpt3 support])
+# AC_ARG_ENABLE([nearpt3], AS_HELP_STRING([--enable-nearpt3],[nearpt3 support [default=no]]))
+# AS_IF([test "x$enable_nearpt3" = "xyes"], [
+#   AC_DEFINE(ENABLE_NEARPT3, [1], [Define to 1 for nearpt3 support])
+# ])
+# AC_MSG_RESULT([$enable_nearpt3])
+# AC_SUBST([ENABLE_NEARPT3],[$enable_nearpt3])
+# AM_CONDITIONAL([ENABLE_NEARPT3],[test x$enable_nearpt3 = 'xyes'])
+#  ----------------------------------------------------------------------
 #  Enable DATA support
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DATA support" >&5
 $as_echo_n "checking for DATA support... " >&6; }
 # Check whether --enable-data was given.
 if test "${enable_data+set}" = set; then :
-  enableval=$enable_data; if test "x$enable_data" != 'xno'; then :
+  enableval=$enable_data;
+fi
 
-$as_echo "#define ENABLE_DATA 1" >>confdefs.h
+if test "x$enable_data" != 'xno'; then :
 
-                      enable_grib=yes
-fi
-else
 
 $as_echo "#define ENABLE_DATA 1" >>confdefs.h
 
-               enable_data=yes
-fi
 
+fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_data" >&5
 $as_echo "$enable_data" >&6; }
 ENABLE_DATA=$enable_data
 
-
 #  ----------------------------------------------------------------------
 CFLAGS="$CFLAGS ${OPENMP_CFLAGS}"
 #  ----------------------------------------------------------------------
@@ -18920,8 +19015,8 @@ ENABLE_NC4HDF5=no
 if test "${with_netcdf+set}" = set; then :
   withval=$with_netcdf; case "$with_netcdf" in #(
   no) :
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for netcdf library" >&5
-$as_echo_n "checking for netcdf library... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for netCDF library" >&5
+$as_echo_n "checking for netCDF library... " >&6; }
                            { $as_echo "$as_me:${as_lineno-$LINENO}: result: suppressed" >&5
 $as_echo "suppressed" >&6; } ;; #(
   yes) :
@@ -18995,7 +19090,7 @@ $as_echo "#define HAVE_LIBNETCDF 1" >>confdefs.h
 
                                             ENABLE_NETCDF=yes
 else
-  as_fn_error $? "Could not link to netcdf library" "$LINENO" 5
+  as_fn_error $? "Could not link to netCDF library" "$LINENO" 5
 fi
 
                             NETCDF_LIBS=" -lnetcdf"
@@ -19340,33 +19435,33 @@ fi
 
 
 #  ----------------------------------------------------------------------
-#  Link application with JASPER library (needed for GRIB2 compression)
-JASPER_LIBS=''
+#  Link application with CMOR library
+CMOR_LIBS=''
 
-# Check whether --with-jasper was given.
-if test "${with_jasper+set}" = set; then :
-  withval=$with_jasper; case "$with_jasper" in #(
+# Check whether --with-cmor was given.
+if test "${with_cmor+set}" = set; then :
+  withval=$with_cmor; case "$with_cmor" in #(
   no) :
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jasper library" >&5
-$as_echo_n "checking for jasper library... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for cmor library" >&5
+$as_echo_n "checking for cmor library... " >&6; }
                            { $as_echo "$as_me:${as_lineno-$LINENO}: result: suppressed" >&5
 $as_echo "suppressed" >&6; } ;; #(
   yes) :
-    for ac_header in jasper.h
+    for ac_header in cmor.h
 do :
-  ac_fn_c_check_header_mongrel "$LINENO" "jasper.h" "ac_cv_header_jasper_h" "$ac_includes_default"
-if test "x$ac_cv_header_jasper_h" = xyes; then :
+  ac_fn_c_check_header_mongrel "$LINENO" "cmor.h" "ac_cv_header_cmor_h" "$ac_includes_default"
+if test "x$ac_cv_header_cmor_h" = xyes; then :
   cat >>confdefs.h <<_ACEOF
-#define HAVE_JASPER_H 1
+#define HAVE_CMOR_H 1
 _ACEOF
 
 fi
 
 done
 
-                            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing jas_init" >&5
-$as_echo_n "checking for library containing jas_init... " >&6; }
-if ${ac_cv_search_jas_init+:} false; then :
+                            { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing cmor_load_table" >&5
+$as_echo_n "checking for library containing cmor_load_table... " >&6; }
+if ${ac_cv_search_cmor_load_table+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
@@ -19379,16 +19474,16 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char jas_init ();
+char cmor_load_table ();
 int
 main ()
 {
-return jas_init ();
+return cmor_load_table ();
   ;
   return 0;
 }
 _ACEOF
-for ac_lib in '' jasper; do
+for ac_lib in '' cmor; do
   if test -z "$ac_lib"; then
     ac_res="none required"
   else
@@ -19396,44 +19491,44 @@ for ac_lib in '' jasper; do
     LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
   fi
   if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_jas_init=$ac_res
+  ac_cv_search_cmor_load_table=$ac_res
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext
-  if ${ac_cv_search_jas_init+:} false; then :
+  if ${ac_cv_search_cmor_load_table+:} false; then :
   break
 fi
 done
-if ${ac_cv_search_jas_init+:} false; then :
+if ${ac_cv_search_cmor_load_table+:} false; then :
 
 else
-  ac_cv_search_jas_init=no
+  ac_cv_search_cmor_load_table=no
 fi
 rm conftest.$ac_ext
 LIBS=$ac_func_search_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_jas_init" >&5
-$as_echo "$ac_cv_search_jas_init" >&6; }
-ac_res=$ac_cv_search_jas_init
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_cmor_load_table" >&5
+$as_echo "$ac_cv_search_cmor_load_table" >&6; }
+ac_res=$ac_cv_search_cmor_load_table
 if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
-$as_echo "#define HAVE_LIBJASPER 1" >>confdefs.h
+$as_echo "#define HAVE_LIBCMOR 1" >>confdefs.h
 
 else
-  as_fn_error $? "Could not link to jasper library! Required for GRIB_API" "$LINENO" 5
+  as_fn_error $? "Could not link to cmor library!" "$LINENO" 5
 fi
 
-                            JASPER_LIBS=" -ljasper"
+                            CMOR_LIBS=" -lcmor"
  ;; #(
   *) :
-    JASPER_ROOT=$with_jasper
-                          if test -d "$JASPER_ROOT"; then :
-  LDFLAGS="$LDFLAGS -L$JASPER_ROOT/lib"
-                                 CPPFLAGS="$CPPFLAGS -I$JASPER_ROOT/include"
-                                 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing jas_stream_memopen" >&5
-$as_echo_n "checking for library containing jas_stream_memopen... " >&6; }
-if ${ac_cv_search_jas_stream_memopen+:} false; then :
+    CMOR_ROOT=$with_cmor
+                          if test -d "$CMOR_ROOT"; then :
+  LDFLAGS="$LDFLAGS -L$CMOR_ROOT/lib"
+                                 CPPFLAGS="$CPPFLAGS -I$CMOR_ROOT/include"
+                                 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing cmor_load_table" >&5
+$as_echo_n "checking for library containing cmor_load_table... " >&6; }
+if ${ac_cv_search_cmor_load_table+:} false; then :
   $as_echo_n "(cached) " >&6
 else
   ac_func_search_save_LIBS=$LIBS
@@ -19446,16 +19541,16 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 #ifdef __cplusplus
 extern "C"
 #endif
-char jas_stream_memopen ();
+char cmor_load_table ();
 int
 main ()
 {
-return jas_stream_memopen ();
+return cmor_load_table ();
   ;
   return 0;
 }
 _ACEOF
-for ac_lib in '' jasper; do
+for ac_lib in '' cmor; do
   if test -z "$ac_lib"; then
     ac_res="none required"
   else
@@ -19463,44 +19558,44 @@ for ac_lib in '' jasper; do
     LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
   fi
   if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_jas_stream_memopen=$ac_res
+  ac_cv_search_cmor_load_table=$ac_res
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext
-  if ${ac_cv_search_jas_stream_memopen+:} false; then :
+  if ${ac_cv_search_cmor_load_table+:} false; then :
   break
 fi
 done
-if ${ac_cv_search_jas_stream_memopen+:} false; then :
+if ${ac_cv_search_cmor_load_table+:} false; then :
 
 else
-  ac_cv_search_jas_stream_memopen=no
+  ac_cv_search_cmor_load_table=no
 fi
 rm conftest.$ac_ext
 LIBS=$ac_func_search_save_LIBS
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_jas_stream_memopen" >&5
-$as_echo "$ac_cv_search_jas_stream_memopen" >&6; }
-ac_res=$ac_cv_search_jas_stream_memopen
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_cmor_load_table" >&5
+$as_echo "$ac_cv_search_cmor_load_table" >&6; }
+ac_res=$ac_cv_search_cmor_load_table
 if test "$ac_res" != no; then :
   test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
 
-$as_echo "#define HAVE_LIBJASPER 1" >>confdefs.h
+$as_echo "#define HAVE_LIBCMOR 1" >>confdefs.h
 
 else
-  as_fn_error $? "Could not link to jasper library! Required for GRIB_API" "$LINENO" 5
+  as_fn_error $? "Could not link to cmor library!" "$LINENO" 5
 fi
 
-                                 JASPER_LIBS=" -L$JASPER_ROOT/lib -ljasper"
+                                 CMOR_LIBS=" -L$CMOR_ROOT/lib -lcmor"
 else
-  as_fn_error $? "$JASPER_ROOT is not a directory! JASPER suppressed" "$LINENO" 5
+  as_fn_error $? "$CMOR_ROOT is not a directory! CMOR suppressed" "$LINENO" 5
 fi ;; #(
   *) :
      ;;
 esac
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the JASPER library" >&5
-$as_echo_n "checking for the JASPER library... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for the CMOR library" >&5
+$as_echo_n "checking for the CMOR library... " >&6; }
              { $as_echo "$as_me:${as_lineno-$LINENO}: result: suppressed" >&5
 $as_echo "suppressed" >&6; }
 fi
@@ -21139,6 +21234,8 @@ ac_config_files="$ac_config_files test/Cat.test test/Gridarea.test test/Genweigh
 
 ac_config_files="$ac_config_files test/Select.test test/Spectral.test test/Timstat.test test/Vertint.test"
 
+ac_config_files="$ac_config_files test/Ymonstat.test test/Fldstat.test test/Fldpctl.test test/Ensstat.test test/Enspctl.test"
+
 ac_config_files="$ac_config_files test/Afterburner.test test/Detrend.test test/Arith.test test/Gradsdes.test"
 
 ac_config_files="$ac_config_files test/wildcard.test"
@@ -21719,7 +21816,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by cdo $as_me 1.6.9, which was
+This file was extended by cdo $as_me 1.7.0, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -21785,7 +21882,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-cdo config.status 1.6.9
+cdo config.status 1.7.0
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
@@ -22304,6 +22401,11 @@ do
     "test/Spectral.test") CONFIG_FILES="$CONFIG_FILES test/Spectral.test" ;;
     "test/Timstat.test") CONFIG_FILES="$CONFIG_FILES test/Timstat.test" ;;
     "test/Vertint.test") CONFIG_FILES="$CONFIG_FILES test/Vertint.test" ;;
+    "test/Ymonstat.test") CONFIG_FILES="$CONFIG_FILES test/Ymonstat.test" ;;
+    "test/Fldstat.test") CONFIG_FILES="$CONFIG_FILES test/Fldstat.test" ;;
+    "test/Fldpctl.test") CONFIG_FILES="$CONFIG_FILES test/Fldpctl.test" ;;
+    "test/Ensstat.test") CONFIG_FILES="$CONFIG_FILES test/Ensstat.test" ;;
+    "test/Enspctl.test") CONFIG_FILES="$CONFIG_FILES test/Enspctl.test" ;;
     "test/Afterburner.test") CONFIG_FILES="$CONFIG_FILES test/Afterburner.test" ;;
     "test/Detrend.test") CONFIG_FILES="$CONFIG_FILES test/Detrend.test" ;;
     "test/Arith.test") CONFIG_FILES="$CONFIG_FILES test/Arith.test" ;;
@@ -23813,6 +23915,11 @@ _LT_EOF
     "test/Spectral.test":F) chmod a+x "$ac_file" ;;
     "test/Timstat.test":F) chmod a+x "$ac_file" ;;
     "test/Vertint.test":F) chmod a+x "$ac_file" ;;
+    "test/Ymonstat.test":F) chmod a+x "$ac_file" ;;
+    "test/Fldstat.test":F) chmod a+x "$ac_file" ;;
+    "test/Fldpctl.test":F) chmod a+x "$ac_file" ;;
+    "test/Ensstat.test":F) chmod a+x "$ac_file" ;;
+    "test/Enspctl.test":F) chmod a+x "$ac_file" ;;
     "test/Afterburner.test":F) chmod a+x "$ac_file" ;;
     "test/Detrend.test":F) chmod a+x "$ac_file" ;;
     "test/Arith.test":F) chmod a+x "$ac_file" ;;
diff --git a/configure.ac b/configure.ac
index a56f200..8d8b8d9 100644
--- a/configure.ac
+++ b/configure.ac
@@ -4,7 +4,7 @@
 #  autoconf 2.68
 #  libtool  2.4.2
 
-AC_INIT([cdo], [1.6.9], [http://mpimet.mpg.de/cdo])
+AC_INIT([cdo], [1.7.0], [http://mpimet.mpg.de/cdo])
 
 AC_DEFINE_UNQUOTED(CDO, ["$PACKAGE_VERSION"], [CDO version])
 
@@ -27,6 +27,7 @@ LT_INIT
 
 # Check building environment
 AC_CHECK_TOOL([CC],[gcc],[:])
+AC_CHECK_TOOL([CXX],[g++],[:])
 AC_PROG_CC_C99
 AM_PROG_CC_C_O
 AC_C_RESTRICT
@@ -83,7 +84,7 @@ case "$CC" in
   icc*)   COMP_VERSION=`$CC --version | head -n 1`;;
   sxc*)   COMP_VERSION=`$CC -V 2>&1   | tail -n 1`;;
   xlc*)   COMP_VERSION=`$CC -qversion 2>&1   | head -n 1`;;
-  *)      COMP_VERSION=`$CC -V 2>&1   | head -n 1` | grep -v error;;
+  *)      COMP_VERSION=`$CC -V 2>&1   | head -n 1 | grep -v error`;;
 esac
 
 if test -z "$COMP_VERSION" ; then COMP_VERSION="unknown"; fi;
@@ -115,18 +116,24 @@ AC_CHECK_DECLS([isnan],,,[AC_INCLUDES_DEFAULT
 @%:@include <math.h>])
 AC_CHECK_FUNCS(sqrtl)
 #  ----------------------------------------------------------------------
+#  Enable NEARPT3 support
+# AC_MSG_CHECKING([for nearpt3 support])
+# AC_ARG_ENABLE([nearpt3], AS_HELP_STRING([--enable-nearpt3],[nearpt3 support [default=no]]))
+# AS_IF([test "x$enable_nearpt3" = "xyes"], [
+#   AC_DEFINE(ENABLE_NEARPT3, [1], [Define to 1 for nearpt3 support])
+# ])
+# AC_MSG_RESULT([$enable_nearpt3])
+# AC_SUBST([ENABLE_NEARPT3],[$enable_nearpt3])
+# AM_CONDITIONAL([ENABLE_NEARPT3],[test x$enable_nearpt3 = 'xyes'])
+#  ----------------------------------------------------------------------
 #  Enable DATA support
 AC_MSG_CHECKING([for DATA support])
-AC_ARG_ENABLE([data],
-              [AS_HELP_STRING([--enable-data],[DATA support [default=yes]])],
-              [AS_IF([test "x$enable_data" != 'xno'],
-                     [AC_DEFINE(ENABLE_DATA, [1], [Define to 1 for DATA support])
-                      enable_grib=yes])],
-              [AC_DEFINE(ENABLE_DATA, [1], [Define to 1 for DATA support])
-               enable_data=yes])
+AC_ARG_ENABLE([data], AS_HELP_STRING([--enable-data],[DATA support [default=yes]]))
+AS_IF([test "x$enable_data" != 'xno'], [
+  AC_DEFINE(ENABLE_DATA, [1], [Define to 1 for DATA support])
+])
 AC_MSG_RESULT([$enable_data])
 AC_SUBST([ENABLE_DATA],[$enable_data])
-
 #  ----------------------------------------------------------------------
 CFLAGS="$CFLAGS ${OPENMP_CFLAGS}"
 #  ----------------------------------------------------------------------
@@ -227,6 +234,7 @@ AC_PROG_AWK
 AC_CONFIG_FILES([test/File.test test/Read_grib.test test/Read_netcdf.test test/Copy_netcdf.test],[chmod a+x "$ac_file"])
 AC_CONFIG_FILES([test/Cat.test test/Gridarea.test test/Genweights.test test/Remap.test],[chmod a+x "$ac_file"])
 AC_CONFIG_FILES([test/Select.test test/Spectral.test test/Timstat.test test/Vertint.test],[chmod a+x "$ac_file"])
+AC_CONFIG_FILES([test/Ymonstat.test test/Fldstat.test test/Fldpctl.test test/Ensstat.test test/Enspctl.test],[chmod a+x "$ac_file"])
 AC_CONFIG_FILES([test/Afterburner.test test/Detrend.test test/Arith.test test/Gradsdes.test],[chmod a+x "$ac_file"])
 AC_CONFIG_FILES([test/wildcard.test],[chmod a+x "$ac_file"])
 AC_CONFIG_FILES([Makefile src/Makefile contrib/Makefile test/Makefile test/data/Makefile cdo.spec cdo.settings])
diff --git a/contrib/Makefile.am b/contrib/Makefile.am
index 12dab6b..bd25d2a 100644
--- a/contrib/Makefile.am
+++ b/contrib/Makefile.am
@@ -1,4 +1,4 @@
-EXTRA_DIST = makecompl.rb cdoCompletion.bash cdoCompletion.tcsh cdoCompletion.zsh python/cdo.py
+EXTRA_DIST = makecompl.rb cdoCompletion.bash cdoCompletion.tcsh cdoCompletion.zsh
 CLEANFILES = 
 
 completions:
diff --git a/contrib/Makefile.in b/contrib/Makefile.in
index e867279..bbc9966 100644
--- a/contrib/Makefile.in
+++ b/contrib/Makefile.in
@@ -129,6 +129,7 @@ CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
 CLDFLAGS = @CLDFLAGS@
 CLIBS = @CLIBS@
+CMOR_LIBS = @CMOR_LIBS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CURL_INCLUDE = @CURL_INCLUDE@
@@ -174,7 +175,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-JASPER_LIBS = @JASPER_LIBS@
 LD = @LD@
 LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
@@ -286,7 +286,7 @@ target_alias = @target_alias@
 top_build_prefix = @top_build_prefix@
 top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
-EXTRA_DIST = makecompl.rb cdoCompletion.bash cdoCompletion.tcsh cdoCompletion.zsh python/cdo.py
+EXTRA_DIST = makecompl.rb cdoCompletion.bash cdoCompletion.tcsh cdoCompletion.zsh
 CLEANFILES = $(am__append_1)
 all: all-am
 
diff --git a/contrib/cdoCompletion.bash b/contrib/cdoCompletion.bash
index 2a24f5c..948aa02 100644
--- a/contrib/cdoCompletion.bash
+++ b/contrib/cdoCompletion.bash
@@ -2,6 +2,8 @@ complete -W "
 -- \
 -- \
 -- \
+-- \
+-- \
 -L \
 -M \
 -O \
@@ -63,6 +65,7 @@ chunit -chunit \
 chvar -chvar \
 cloudlayer -cloudlayer \
 cmd -cmd \
+cmor -cmor \
 collgrid -collgrid \
 com -com \
 command -command \
@@ -238,8 +241,10 @@ gridboxmax -gridboxmax \
 gridboxmean -gridboxmean \
 gridboxmin -gridboxmin \
 gridboxstd -gridboxstd \
+gridboxstd1 -gridboxstd1 \
 gridboxsum -gridboxsum \
 gridboxvar -gridboxvar \
+gridboxvar1 -gridboxvar1 \
 griddes -griddes \
 griddes2 -griddes2 \
 griddx -griddx \
@@ -342,8 +347,10 @@ mermean -mermean \
 mermin -mermin \
 merpctl -merpctl \
 merstd -merstd \
+merstd1 -merstd1 \
 mersum -mersum \
 mervar -mervar \
+mervar1 -mervar1 \
 min -min \
 ml2hl -ml2hl \
 ml2hl_lp -ml2hl_lp \
@@ -467,8 +474,10 @@ seasmean -seasmean \
 seasmin -seasmin \
 seaspctl -seaspctl \
 seasstd -seasstd \
+seasstd1 -seasstd1 \
 seassum -seassum \
 seasvar -seasvar \
+seasvar1 -seasvar1 \
 seinfo -seinfo \
 seinfoc -seinfoc \
 seinfon -seinfon \
@@ -520,6 +529,8 @@ sethalo -sethalo \
 setlevel -setlevel \
 setltype -setltype \
 setmisstoc -setmisstoc \
+setmisstodis -setmisstodis \
+setmisstonn -setmisstonn \
 setmissval -setmissval \
 setmon -setmon \
 setname -setname \
@@ -573,6 +584,7 @@ sort -sort \
 sortcode -sortcode \
 sortlevel -sortlevel \
 sortname -sortname \
+sortparam -sortparam \
 sorttaxis -sorttaxis \
 sorttimestamp -sorttimestamp \
 sortvar -sortvar \
@@ -667,19 +679,50 @@ varrms -varrms \
 vct -vct \
 vct2 -vct2 \
 vertavg -vertavg \
+vertcum -vertcum \
+vertcumhl -vertcumhl \
 vertint -vertint \
 vertmax -vertmax \
 vertmean -vertmean \
 vertmin -vertmin \
 vertstd -vertstd \
+vertstd1 -vertstd1 \
 vertsum -vertsum \
 vertvar -vertvar \
+vertvar1 -vertvar1 \
 vertwind -vertwind \
 vlist -vlist \
 wct -wct \
 write_e5ml -write_e5ml \
 writegrid -writegrid \
 writerandom -writerandom \
+xmonavg -xmonavg \
+xmonmax -xmonmax \
+xmonmean -xmonmean \
+xmonmin -xmonmin \
+xmonstd -xmonstd \
+xmonstd1 -xmonstd1 \
+xmonsum -xmonsum \
+xmonvar -xmonvar \
+xmonvar1 -xmonvar1 \
+xtimavg -xtimavg \
+xtimmax -xtimmax \
+xtimmean -xtimmean \
+xtimmin -xtimmin \
+xtimstd -xtimstd \
+xtimstd1 -xtimstd1 \
+xtimsum -xtimsum \
+xtimvar -xtimvar \
+xtimvar1 -xtimvar1 \
+xyearavg -xyearavg \
+xyearmax -xyearmax \
+xyearmean -xyearmean \
+xyearmin -xyearmin \
+xyearstd -xyearstd \
+xyearstd1 -xyearstd1 \
+xyearsum -xyearsum \
+xyearvar -xyearvar \
+xyearvar1 -xyearvar1 \
 yarbil -yarbil \
 yarcon -yarcon \
 yarnn -yarnn \
@@ -756,9 +799,11 @@ yseasmin -yseasmin \
 yseasmul -yseasmul \
 yseaspctl -yseaspctl \
 yseasstd -yseasstd \
+yseasstd1 -yseasstd1 \
 yseassub -yseassub \
 yseassum -yseassum \
 yseasvar -yseasvar \
+yseasvar1 -yseasvar1 \
 zaxisdes -zaxisdes \
 zonavg -zonavg \
 zonmax -zonmax \
@@ -767,6 +812,8 @@ zonmin -zonmin \
 zonpctl -zonpctl \
 zonrange -zonrange \
 zonstd -zonstd \
+zonstd1 -zonstd1 \
 zonsum -zonsum \
 zonvar -zonvar \
+zonvar1 -zonvar1 \
 " -f cdo
diff --git a/contrib/cdoCompletion.tcsh b/contrib/cdoCompletion.tcsh
index d040bc9..839531f 100644
--- a/contrib/cdoCompletion.tcsh
+++ b/contrib/cdoCompletion.tcsh
@@ -2,6 +2,8 @@ set cdoCmpl = (\
 - \
 - \
 - \
+- \
+- \
 L \
 M \
 O \
@@ -63,6 +65,7 @@ chunit \
 chvar \
 cloudlayer \
 cmd \
+cmor \
 collgrid \
 com \
 command \
@@ -238,8 +241,10 @@ gridboxmax \
 gridboxmean \
 gridboxmin \
 gridboxstd \
+gridboxstd1 \
 gridboxsum \
 gridboxvar \
+gridboxvar1 \
 griddes \
 griddes2 \
 griddx \
@@ -342,8 +347,10 @@ mermean \
 mermin \
 merpctl \
 merstd \
+merstd1 \
 mersum \
 mervar \
+mervar1 \
 min \
 ml2hl \
 ml2hl_lp \
@@ -467,8 +474,10 @@ seasmean \
 seasmin \
 seaspctl \
 seasstd \
+seasstd1 \
 seassum \
 seasvar \
+seasvar1 \
 seinfo \
 seinfoc \
 seinfon \
@@ -520,6 +529,8 @@ sethalo \
 setlevel \
 setltype \
 setmisstoc \
+setmisstodis \
+setmisstonn \
 setmissval \
 setmon \
 setname \
@@ -573,6 +584,7 @@ sort \
 sortcode \
 sortlevel \
 sortname \
+sortparam \
 sorttaxis \
 sorttimestamp \
 sortvar \
@@ -667,19 +679,50 @@ varrms \
 vct \
 vct2 \
 vertavg \
+vertcum \
+vertcumhl \
 vertint \
 vertmax \
 vertmean \
 vertmin \
 vertstd \
+vertstd1 \
 vertsum \
 vertvar \
+vertvar1 \
 vertwind \
 vlist \
 wct \
 write_e5ml \
 writegrid \
 writerandom \
+xmonavg \
+xmonmax \
+xmonmean \
+xmonmin \
+xmonstd \
+xmonstd1 \
+xmonsum \
+xmonvar \
+xmonvar1 \
+xtimavg \
+xtimmax \
+xtimmean \
+xtimmin \
+xtimstd \
+xtimstd1 \
+xtimsum \
+xtimvar \
+xtimvar1 \
+xyearavg \
+xyearmax \
+xyearmean \
+xyearmin \
+xyearstd \
+xyearstd1 \
+xyearsum \
+xyearvar \
+xyearvar1 \
 yarbil \
 yarcon \
 yarnn \
@@ -756,9 +799,11 @@ yseasmin \
 yseasmul \
 yseaspctl \
 yseasstd \
+yseasstd1 \
 yseassub \
 yseassum \
 yseasvar \
+yseasvar1 \
 zaxisdes \
 zonavg \
 zonmax \
@@ -767,6 +812,8 @@ zonmin \
 zonpctl \
 zonrange \
 zonstd \
+zonstd1 \
 zonsum \
 zonvar \
+zonvar1 \
 ); complete cdo 'c/-/$cdoCmpl/' 'n/*/f/'
diff --git a/contrib/cdoCompletion.zsh b/contrib/cdoCompletion.zsh
index 2373dfe..7dc2836 100644
--- a/contrib/cdoCompletion.zsh
+++ b/contrib/cdoCompletion.zsh
@@ -2,6 +2,8 @@ compctl -k "(
 -- \
 -- \
 -- \
+-- \
+-- \
 -L \
 -M \
 -O \
@@ -63,6 +65,7 @@ chunit -chunit \
 chvar -chvar \
 cloudlayer -cloudlayer \
 cmd -cmd \
+cmor -cmor \
 collgrid -collgrid \
 com -com \
 command -command \
@@ -238,8 +241,10 @@ gridboxmax -gridboxmax \
 gridboxmean -gridboxmean \
 gridboxmin -gridboxmin \
 gridboxstd -gridboxstd \
+gridboxstd1 -gridboxstd1 \
 gridboxsum -gridboxsum \
 gridboxvar -gridboxvar \
+gridboxvar1 -gridboxvar1 \
 griddes -griddes \
 griddes2 -griddes2 \
 griddx -griddx \
@@ -342,8 +347,10 @@ mermean -mermean \
 mermin -mermin \
 merpctl -merpctl \
 merstd -merstd \
+merstd1 -merstd1 \
 mersum -mersum \
 mervar -mervar \
+mervar1 -mervar1 \
 min -min \
 ml2hl -ml2hl \
 ml2hl_lp -ml2hl_lp \
@@ -467,8 +474,10 @@ seasmean -seasmean \
 seasmin -seasmin \
 seaspctl -seaspctl \
 seasstd -seasstd \
+seasstd1 -seasstd1 \
 seassum -seassum \
 seasvar -seasvar \
+seasvar1 -seasvar1 \
 seinfo -seinfo \
 seinfoc -seinfoc \
 seinfon -seinfon \
@@ -520,6 +529,8 @@ sethalo -sethalo \
 setlevel -setlevel \
 setltype -setltype \
 setmisstoc -setmisstoc \
+setmisstodis -setmisstodis \
+setmisstonn -setmisstonn \
 setmissval -setmissval \
 setmon -setmon \
 setname -setname \
@@ -573,6 +584,7 @@ sort -sort \
 sortcode -sortcode \
 sortlevel -sortlevel \
 sortname -sortname \
+sortparam -sortparam \
 sorttaxis -sorttaxis \
 sorttimestamp -sorttimestamp \
 sortvar -sortvar \
@@ -667,19 +679,50 @@ varrms -varrms \
 vct -vct \
 vct2 -vct2 \
 vertavg -vertavg \
+vertcum -vertcum \
+vertcumhl -vertcumhl \
 vertint -vertint \
 vertmax -vertmax \
 vertmean -vertmean \
 vertmin -vertmin \
 vertstd -vertstd \
+vertstd1 -vertstd1 \
 vertsum -vertsum \
 vertvar -vertvar \
+vertvar1 -vertvar1 \
 vertwind -vertwind \
 vlist -vlist \
 wct -wct \
 write_e5ml -write_e5ml \
 writegrid -writegrid \
 writerandom -writerandom \
+xmonavg -xmonavg \
+xmonmax -xmonmax \
+xmonmean -xmonmean \
+xmonmin -xmonmin \
+xmonstd -xmonstd \
+xmonstd1 -xmonstd1 \
+xmonsum -xmonsum \
+xmonvar -xmonvar \
+xmonvar1 -xmonvar1 \
+xtimavg -xtimavg \
+xtimmax -xtimmax \
+xtimmean -xtimmean \
+xtimmin -xtimmin \
+xtimstd -xtimstd \
+xtimstd1 -xtimstd1 \
+xtimsum -xtimsum \
+xtimvar -xtimvar \
+xtimvar1 -xtimvar1 \
+xyearavg -xyearavg \
+xyearmax -xyearmax \
+xyearmean -xyearmean \
+xyearmin -xyearmin \
+xyearstd -xyearstd \
+xyearstd1 -xyearstd1 \
+xyearsum -xyearsum \
+xyearvar -xyearvar \
+xyearvar1 -xyearvar1 \
 yarbil -yarbil \
 yarcon -yarcon \
 yarnn -yarnn \
@@ -756,9 +799,11 @@ yseasmin -yseasmin \
 yseasmul -yseasmul \
 yseaspctl -yseaspctl \
 yseasstd -yseasstd \
+yseasstd1 -yseasstd1 \
 yseassub -yseassub \
 yseassum -yseassum \
 yseasvar -yseasvar \
+yseasvar1 -yseasvar1 \
 zaxisdes -zaxisdes \
 zonavg -zonavg \
 zonmax -zonmax \
@@ -767,6 +812,8 @@ zonmin -zonmin \
 zonpctl -zonpctl \
 zonrange -zonrange \
 zonstd -zonstd \
+zonstd1 -zonstd1 \
 zonsum -zonsum \
 zonvar -zonvar \
+zonvar1 -zonvar1 \
 )" -f cdo
diff --git a/contrib/python/cdo.py b/contrib/python/cdo.py
deleted file mode 100644
index 710ed36..0000000
--- a/contrib/python/cdo.py
+++ /dev/null
@@ -1,422 +0,0 @@
-import os,re,subprocess,tempfile,random,string
-
-# Copyright (C) 2011-2012 Ralf Mueller, ralf.mueller at zmaw.de
-# See COPYING file for copying and redistribution conditions.
-# 
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; version 2 of the License.
-# 
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-# GNU General Public License for more details.
-
-def auto_doc(tool, cdo_self):
-    """Generate the __doc__ string of the decorated function by calling the cdo help command"""
-    def desc(func):
-        func.__doc__ = cdo_self.call([cdo_self.CDO, '-h', tool]).get('stdout')
-        return func
-    return desc
-
-class CDOException(Exception):
-
-    def __init__(self, stdout, stderr, returncode):
-        super(CDOException, self).__init__()
-        self.stdout     = stdout
-        self.stderr     = stderr
-        self.returncode = returncode
-        self.msg        = '(returncode:%s) %s' % (returncode, stderr)
-
-    def __str__(self):
-        return self.msg
-
-class Cdo(object):
-
-  def __init__(self,returnCdf=False,returnNoneOnError=False,forceOutput=True,cdfMod='scipy',debug=False):
-    # Since cdo-1.5.4 undocumented operators are given with the -h option. For
-    # earlier version, they have to be provided manually
-    self.undocumentedOperators = ['anomaly','beta','boxavg','change_e5lsm','change_e5mask',
-        'change_e5slm','chisquare','chvar','cloudlayer','cmd','com','command','complextorect',
-        'covar0','covar0r','daycount','daylogs','del29feb','delday','delete','deltap','deltap_fl',
-        'delvar','diffv','divcoslat','dumplogo','dumplogs','duplicate','eca_r1mm','enlargegrid',
-        'ensrkhistspace','ensrkhisttime','eof3d','eof3dspatial','eof3dtime','export_e5ml',
-        'export_e5res','fc2gp','fc2sp','fillmiss','fisher','fldcovar','fldrms','fourier','fpressure',
-        'gather','gengrid','geopotheight','ggstat','ggstats','globavg','gp2fc','gradsdes',
-        'gridverify','harmonic','hourcount','hpressure','ifs2icon','import_e5ml','import_e5res',
-        'import_obs','imtocomplex','infos','infov','interpolate','intgrid','intgridbil',
-        'intgridtraj','intpoint','isosurface','lmavg','lmean','lmmean','lmstd','log','lsmean',
-        'meandiff2test','mergegrid','mod','moncount','monlogs','mrotuv','mrotuvb','mulcoslat','ncode',
-        'ncopy','nmltest','normal','nvar','outputbounds','outputboundscpt','outputcenter',
-        'outputcenter2','outputcentercpt','outputkey','outputtri','outputvector','outputvrml',
-        'pardup','parmul','pinfo','pinfov','pressure_fl','pressure_hl','read_e5ml','remapcon1',
-        'remapdis1','retocomplex','scalllogo','scatter','seascount','select','selgridname',
-        'seloperator','selvar','selzaxisname','setrcaname','setvar','showvar','sinfov','smemlogo',
-        'snamelogo','sort','sortcode','sortlevel','sortname','sorttaxis','sorttimestamp','sortvar',
-        'sp2fc','specinfo','spectrum','sperclogo','splitvar','stimelogo','studentt','template1',
-        'template2','test','test2','testdata','thinout','timcount','timcovar','tinfo','transxy','trms',
-        'tstepcount','vardes','vardup','varmul','varquot2test','varrms','vertwind','write_e5ml',
-        'writegrid','writerandom','yearcount']
-
-    if os.environ.has_key('CDO'):
-      self.CDO = os.environ['CDO']
-    else:
-      self.CDO = 'cdo'
-
-    self.operators              = self.getOperators()
-    self.returnCdf              = returnCdf
-    self.returnNoneOnError      = returnNoneOnError
-    self.tempfile               = MyTempfile()
-    self.forceOutput            = forceOutput
-    self.cdfMod                 = cdfMod
-    self.debug                  = debug
-    self.outputOperatorsPattern = '(diff|info|output|griddes|zaxisdes|show|ncode|ndate|nlevel|nmon|nvar|nyear|ntime|npar|gradsdes|pardes)'
-
-    self.libs        = self.getSupportedLibs()
-
-  def __dir__(self):
-    res = dir(type(self)) + list(self.__dict__.keys())
-    res.extend(self.operators)
-    return res
-
-  def call(self,cmd,environment=None):
-    if self.debug:
-      print '# DEBUG ====================================================================='
-      if None != environment:
-        for k,v in environment.items():
-          print "ENV: " + k + " = " + v
-      print 'CALL:'+' '.join(cmd)
-      print '# DEBUG ====================================================================='
-
-    proc = subprocess.Popen(' '.join(cmd),
-                            shell  = True,
-                            stderr = subprocess.PIPE,
-                            stdout = subprocess.PIPE,
-                            env    = environment)
-    retvals = proc.communicate()
-    return {"stdout"     : retvals[0]
-           ,"stderr"     : retvals[1]
-           ,"returncode" : proc.returncode}
-
-  def hasError(self,method_name,cmd,retvals):
-    if (self.debug):
-      print("RETURNCODE:"+retvals["returncode"].__str__())
-    if ( 0 != retvals["returncode"] ):
-      print("Error in calling operator " + method_name + " with:")
-      print(">>> "+' '.join(cmd)+"<<<")
-      print(retvals["stderr"])
-      return True
-    else:
-      return False
-
-  def __getattr__(self, method_name):
-
-    @auto_doc(method_name, self)
-    def get(self, *args,**kwargs):
-      operator          = [method_name]
-      operatorPrintsOut = re.search(self.outputOperatorsPattern,method_name)
-
-      if args.__len__() != 0:
-        for arg in args:
-          operator.append(arg.__str__())
-
-      #build the cdo command
-      #1. the cdo command
-      cmd = [self.CDO]
-      #2. options
-      if 'options' in kwargs:
-          cmd += kwargs['options'].split()
-      #3. operator(s)
-      cmd.append(','.join(operator))
-      #4. input files or operators
-      if 'input' in kwargs:
-        if isinstance(kwargs["input"], basestring):
-            cmd.append(kwargs["input"])
-        else:
-            #we assume it's either a list, a tuple or any iterable.
-            cmd += kwargs["input"]
-
-      if not kwargs.__contains__("force"):
-        kwargs["force"] = self.forceOutput
-
-      if operatorPrintsOut:
-        retvals = self.call(cmd)
-        if ( not self.hasError(method_name,cmd,retvals) ):
-          r = map(string.strip,retvals["stdout"].split(os.linesep))
-          return r[:len(r)-1]
-        else:
-          if self.returnNoneOnError:
-            return None
-          else:
-            raise CDOException(**retvals)
-      else:
-        if kwargs["force"] or \
-           (kwargs.__contains__("output") and not os.path.isfile(kwargs["output"])):
-          if not kwargs.__contains__("output") or None == kwargs["output"]:
-            kwargs["output"] = self.tempfile.path()
-
-          cmd.append(kwargs["output"])
-          if kwargs.__contains__("env"):
-            environment = kwargs["env"]
-          else:
-            environment = None
-
-          retvals = self.call(cmd,environment=environment)
-          if self.hasError(method_name,cmd,retvals):
-            if self.returnNoneOnError:
-              return None
-            else:
-              raise CDOException(**retvals)
-        else:
-          if self.debug:
-            print("Use existing file'"+kwargs["output"]+"'")
-
-      if not kwargs.__contains__("returnCdf"):
-        kwargs["returnCdf"] = False
-
-      if not None == kwargs.get("returnArray"):
-        return self.readArray(kwargs["output"],kwargs["returnArray"])
-      elif not None == kwargs.get("returnMaArray"):
-        return self.readMaArray(kwargs["output"],kwargs["returnMaArray"])
-      elif self.returnCdf or kwargs["returnCdf"]:
-        if not self.returnCdf:
-          self.loadCdf()
-        return self.readCdf(kwargs["output"])
-      else:
-        return kwargs["output"]
-
-    if ((method_name in self.__dict__) or (method_name in self.operators)):
-      if self.debug:
-        print("Found method:" + method_name)
-
-      #cache the method for later
-      setattr(self.__class__, method_name, get)
-      return get.__get__(self)
-    else:
-      # If the method isn't in our dictionary, act normal.
-      print("#=====================================================")
-      print("Cannot find method:" + method_name)
-      raise AttributeError, "Unknown method '" + method_name +"'!"
-
-  def getOperators(self):
-    import os
-    proc = subprocess.Popen([self.CDO,'-h'],stderr = subprocess.PIPE,stdout = subprocess.PIPE)
-    ret  = proc.communicate()
-    l    = ret[1].find("Operators:")
-    ops  = ret[1][l:-1].split(os.linesep)[1:-1]
-    endI = ops.index('')
-    s    = ' '.join(ops[:endI]).strip()
-    s    = re.sub("\s+" , " ", s)
-    return list(set(s.split(" ") + self.undocumentedOperators))
-
-  def loadCdf(self):
-    if self.cdfMod == "scipy":
-      try:
-        import scipy.io.netcdf as cdf
-        self.cdf    = cdf
-      except:
-        print "Could not load scipy.io.netcdf - try to load nercdf4"
-        self.cdfMod = "netcdf4" 
-
-    if self.cdfMod == "netcdf4":
-      try:
-        import netCDF4 as cdf
-        self.cdf    = cdf
-      except:
-        raise ImportError,"scipy or python-netcdf4 module is required to return numpy arrays."
-
-  def getSupportedLibs(self,force=False):
-    proc = subprocess.Popen(self.CDO + ' -V',
-        shell  = True,
-        stderr = subprocess.PIPE,
-        stdout = subprocess.PIPE)
-    retvals = proc.communicate()
-
-    withs     = list(re.findall('(with|Features): (.*)',retvals[1])[0])[1].split(' ')
-    libs      = re.findall('(\w+) library version : (\d+\.\d+\.\d+)',retvals[1])
-    libraries = dict({})
-    for w in withs:
-      libraries[w.lower()] = True
-
-    for lib in libs:
-      l,v = lib
-      libraries[l.lower()] = v
-
-    return libraries
-
-  def setReturnArray(self,value=True):
-    self.returnCdf = value
-    if value:
-      self.loadCdf()
-
-
-  def unsetReturnArray(self):
-    self.setReturnArray(False)
-
-  def hasCdo(self,path=None):
-    if path is None:
-      path = self.CDO
-
-    if os.path.isfile(path) and os.access(path, os.X_OK):
-      return True
-    return False
-
-  def checkCdo(self):
-    if (self.hasCdo()):
-      call = [self.CDO,' -V']
-      proc = subprocess.Popen(' '.join(call),
-          shell  = True,
-          stderr = subprocess.PIPE,
-          stdout = subprocess.PIPE)
-      retvals = proc.communicate()
-      print retvals
-
-  def setCdo(self,value):
-    self.CDO       = value
-    self.operators = self.getOperators()
-
-  def getCdo(self):
-    return self.CDO
-
-  def hasLib(self,lib):
-    return lib in self.libs
-    return false
-
-  def libsVersion(self,lib):
-    if not self.hasLib(lib):
-      raise AttributeError, "Cdo does NOT have support for '#{lib}'"
-    else:
-      if True != self.libs[lib]:
-        return self.libs[lib]
-      else:
-        print "No version information available about '" + lib + "'"
-        return False
-
-  #==================================================================
-  # Addional operators:
-  #------------------------------------------------------------------
-  def module_version(self):
-    '1.2.3'
-
-  def version(self):
-    # return CDO's version
-    proc = subprocess.Popen([self.CDO,'-h'],stderr = subprocess.PIPE,stdout = subprocess.PIPE)
-    ret  = proc.communicate()
-    cdo_help   = ret[1]
-    match = re.search("CDO version (\d.*), Copyright",cdo_help)
-    return match.group(1)
-
-  def boundaryLevels(self,**kwargs):
-    ilevels         = map(float,self.showlevel(input = kwargs['input'])[0].split())
-    bound_levels    = []
-    bound_levels.insert(0,0)
-    for i in range(1,len(ilevels)+1):
-      bound_levels.insert(i,bound_levels[i-1] + 2*(ilevels[i-1]-bound_levels[i-1]))
-
-    return bound_levels
-
-  def thicknessOfLevels(self,**kwargs):
-    bound_levels = self.boundaryLevels(**kwargs)
-    delta_levels    = []
-    for i in range(0,len(bound_levels)):
-      v = bound_levels[i]
-      if 0 == i:
-        continue
-
-      delta_levels.append(v - bound_levels[i-1])
-
-    return delta_levels
-
-  def readCdf(self,iFile):
-    """Return a cdf handle created by the available cdf library. python-netcdf4 and scipy suported (default:scipy)"""
-    if not self.returnCdf:
-      self.loadCdf()
-
-    if ( "scipy" == self.cdfMod):
-      #making it compatible to older scipy versions
-      fileObj =  self.cdf.netcdf_file(iFile, mode='r')
-    elif ( "netcdf4" == self.cdfMod ):
-      fileObj = self.cdf.Dataset(iFile)
-    else:
-      raise ImportError,"Could not import data from file '" + iFile + "'"
-
-    retval = fileObj
-    return retval
-
-  def openCdf(self,iFile):
-    """Return a cdf handle created by the available cdf library. python-netcdf4 and scipy suported (default:scipy)"""
-    if not self.returnCdf:
-      self.loadCdf()
-
-    if ( "scipy" == self.cdfMod):
-      #making it compatible to older scipy versions
-      print("Use scipy")
-      fileObj =  self.cdf.netcdf_file(iFile, mode='r+')
-    elif ( "netcdf4" == self.cdfMod ):
-      print("Use netcdf4")
-      fileObj = self.cdf.Dataset(iFile,'r+')
-    else:
-      raise ImportError,"Could not import data from file '" + iFile + "'"
-
-    retval = fileObj
-    return retval
-
-  def readArray(self,iFile,varname):
-    """Direcly return a numpy array for a given variable name"""
-    filehandle = self.readCdf(iFile)
-    if varname in filehandle.variables:
-      # return the data array
-      return filehandle.variables[varname][:]
-    else:
-      print "Cannot find variable '" + varname +"'"
-      return False
-
-  def readMaArray(self,iFile,varname):
-    """Create a masked array based on cdf's FillValue"""
-    fileObj =  self.readCdf(iFile)
-
-    #.data is not backwards compatible to old scipy versions, [:] is
-    data = fileObj.variables[varname][:]
-
-    # load numpy if available
-    try:
-      import numpy as np
-    except:
-      raise ImportError,"numpy is required to return masked arrays."
-
-    if hasattr(fileObj.variables[varname],'_FillValue'):
-      #return masked array
-      retval = np.ma.array(data,mask=data == fileObj.variables[varname]._FillValue)
-    else:
-      #generate dummy mask which is always valid
-      retval = np.ma.array(data,mask=data != data )
-
-    return retval
-
-# Helper module for easy temp file handling
-class MyTempfile(object):
-
-  __tempfiles = []
-
-  def __init__(self):
-    self.persistent_tempfile = False
-
-  def __del__(self):
-    # remove temporary files
-    for filename in self.__class__.__tempfiles:
-      if os.path.isfile(filename):
-        os.remove(filename)
-
-  def setPersist(self,value):
-    self.persistent_tempfiles = value
-
-  def path(self):
-    if not self.persistent_tempfile:
-      t = tempfile.NamedTemporaryFile(delete=True,prefix='cdoPy')
-      self.__class__.__tempfiles.append(t.name)
-      t.close()
-
-      return t.name
-    else:
-      N =10000000 
-      t = "_"+random.randint(N).__str__()
diff --git a/doc/cdo.pdf b/doc/cdo.pdf
index 2bf841f..8310717 100644
Binary files a/doc/cdo.pdf and b/doc/cdo.pdf differ
diff --git a/doc/cdo_eca.pdf b/doc/cdo_eca.pdf
new file mode 100644
index 0000000..99ff09e
Binary files /dev/null and b/doc/cdo_eca.pdf differ
diff --git a/doc/cdo_refcard.pdf b/doc/cdo_refcard.pdf
index 7327f94..acd98c9 100644
Binary files a/doc/cdo_refcard.pdf and b/doc/cdo_refcard.pdf differ
diff --git a/libcdi/AUTHORS b/libcdi/AUTHORS
index 06ecddb..08efd74 100644
--- a/libcdi/AUTHORS
+++ b/libcdi/AUTHORS
@@ -1 +1,8 @@
 Uwe Schulzweida <uwe.schulzweida AT mpimet.mpg.de>
+Luis Kornblueh <luis.kornblueh AT mpimet.mpg.de>
+Ralf Mueller <ralf.mueller AT mpimet.mpg.de>
+Deike Kleberg <deike.kleberg AT mpimet.mpg.de> Initial version of CDI-PIO
+Thomas Jahns <jahns AT dkrz.de>
+Florian Prill <florian.prill AT dwd.de>
+Daniel Reinert <daniel.reinert AT dwd.de>
+Nathanael Huebbe <nathanael.huebbe AT informatik.uni-hamburg.de>
diff --git a/libcdi/ChangeLog b/libcdi/ChangeLog
index 795319a..01c8edf 100644
--- a/libcdi/ChangeLog
+++ b/libcdi/ChangeLog
@@ -1,3 +1,46 @@
+2015-10-27  Uwe Schulzweida
+
+	* Version 1.7.0 released
+        * using CGRIBEX library version 1.7.3
+	* using EXSE library version 1.4.0
+
+2015-10-06  Uwe Schulzweida
+
+	* netcdf: added support for 2D generic grids which share one dimension (bug fix)
+
+2015-09-15  Uwe Schulzweida
+
+	* gridCompare: check only UUID of unstructured grids if coordinates are missing
+
+2015-09-10  Uwe Schulzweida
+
+	* GRIB rotated grids: invert angle of rotation (north to south pole) (bug fix)
+
+2015-08-18  Uwe Schulzweida
+
+	* added support for netCDF Scalar Coordinate Variables
+
+2015-08-11  Uwe Schulzweida
+
+	* bug fix for scanning the  WRF time axis
+
+2015-08-07  Uwe Schulzweida
+
+	* cdiStreamSetupVlist: added call to vlist_unlock(vlistID) (bug fix)
+
+2015-06-16  Uwe Schulzweida
+
+	* merge changes from branches/cdi-tiles [from Florian Prill]
+	* added rubyVersionCheck.patch [from Nathanael Huebbe]
+
+2015-06-02  Uwe Schulzweida
+
+	* gribapiDefParam: check range of parameter number
+
+2015-05-28  Uwe Schulzweida
+
+	* dmemory: added env. MEMORY_INFO
+
 2015-04-28  Uwe Schulzweida
 
 	* Version 1.6.9 released
diff --git a/libcdi/Makefile.in b/libcdi/Makefile.in
index 66cd526..ef20cd3 100644
--- a/libcdi/Makefile.in
+++ b/libcdi/Makefile.in
@@ -97,18 +97,22 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps =  \
 	$(top_srcdir)/m4/acx_assert_lang_is_fortran_variant.m4 \
 	$(top_srcdir)/m4/acx_c_package.m4 \
+	$(top_srcdir)/m4/acx_cfortran_flags.m4 \
+	$(top_srcdir)/m4/acx_check_cfortran.m4 \
 	$(top_srcdir)/m4/acx_check_strptr_convert.m4 \
 	$(top_srcdir)/m4/acx_execinfo.m4 \
 	$(top_srcdir)/m4/acx_fortran_package.m4 \
 	$(top_srcdir)/m4/acx_lang_check_include.m4 \
 	$(top_srcdir)/m4/acx_lang_other_suffix_conftest.m4 \
 	$(top_srcdir)/m4/acx_lang_package.m4 \
+	$(top_srcdir)/m4/acx_lt_problems.m4 \
 	$(top_srcdir)/m4/acx_option_search_libs.m4 \
 	$(top_srcdir)/m4/acx_options.m4 \
 	$(top_srcdir)/m4/acx_sl_fc_mod_path_flag.m4 \
 	$(top_srcdir)/m4/acx_sl_mod_suffix.m4 \
 	$(top_srcdir)/m4/asx_tr_arg.m4 $(top_srcdir)/m4/asx_unset.m4 \
-	$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
+	$(top_srcdir)/m4/ax_pthread.m4 \
+	$(top_srcdir)/m4/kpse_libtool.m4 $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/starlink_fpp.m4 \
@@ -228,7 +232,6 @@ ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
-AS = @AS@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
diff --git a/libcdi/NEWS b/libcdi/NEWS
index 2f1232d..148b2e3 100644
--- a/libcdi/NEWS
+++ b/libcdi/NEWS
@@ -1,6 +1,18 @@
 CDI NEWS
 --------
 
+
+Version 1.7.0 (27 October 2015):
+
+   New features:
+     * added support for netCDF Scalar Coordinate Variables
+     * added support for hybrid sigma pressure coordinates following the CF convention
+     * merge changes from branches/cdi-tiles [from Florian Prill]
+   Fixed bugs:
+     * GRIB rotated grids: invert angle of rotation (north to south pole) (bug fix)
+     * bug fix for scanning the WRF time axis
+     * cdiStreamSetupVlist: added call to vlist_unlock(vlistID) (bug fix)
+
 Version 1.6.8 (26 March 2015):
 
    Fixed bugs:
diff --git a/libcdi/acinclude.m4 b/libcdi/acinclude.m4
index b886306..183afb1 100644
--- a/libcdi/acinclude.m4
+++ b/libcdi/acinclude.m4
@@ -1,19 +1,3 @@
-dnl
-dnl AC_CHECK_CFINT
-dnl
-dnl Check C / Fortran interface
-dnl
-AC_DEFUN([ACX_CHECK_CFINT],
-  [AC_CACHE_CHECK([whether the C / Fortran interface works],[acx_cv_check_cfint],
-     [AC_LANG_PUSH([C])
-      AC_COMPILE_IFELSE([AC_LANG_PROGRAM([#include "$1"],[])],
-        [acx_cv_check_cfint=yes],
-        [acx_cv_check_cfint=no])
-      AC_LANG_POP([C])])
-   AS_IF([test x$acx_cv_check_cfint = xyes],
-     [AC_DEFINE(HAVE_CF_INTERFACE, [1],
-        [Define if C / Fortran interface cfortran.h works])])
-  ])
 m4_include([m4/ac_lang_program_fortran.m4])
 m4_include([m4/acx_lang_fortran_check_include.m4])
 m4_include([m4/acx_lang_c_check_include.m4])
diff --git a/libcdi/aclocal.m4 b/libcdi/aclocal.m4
index 3f8b4f3..f7f2c3b 100644
--- a/libcdi/aclocal.m4
+++ b/libcdi/aclocal.m4
@@ -1185,12 +1185,15 @@ AC_SUBST([am__untar])
 
 m4_include([m4/acx_assert_lang_is_fortran_variant.m4])
 m4_include([m4/acx_c_package.m4])
+m4_include([m4/acx_cfortran_flags.m4])
+m4_include([m4/acx_check_cfortran.m4])
 m4_include([m4/acx_check_strptr_convert.m4])
 m4_include([m4/acx_execinfo.m4])
 m4_include([m4/acx_fortran_package.m4])
 m4_include([m4/acx_lang_check_include.m4])
 m4_include([m4/acx_lang_other_suffix_conftest.m4])
 m4_include([m4/acx_lang_package.m4])
+m4_include([m4/acx_lt_problems.m4])
 m4_include([m4/acx_option_search_libs.m4])
 m4_include([m4/acx_options.m4])
 m4_include([m4/acx_sl_fc_mod_path_flag.m4])
@@ -1198,6 +1201,7 @@ m4_include([m4/acx_sl_mod_suffix.m4])
 m4_include([m4/asx_tr_arg.m4])
 m4_include([m4/asx_unset.m4])
 m4_include([m4/ax_pthread.m4])
+m4_include([m4/kpse_libtool.m4])
 m4_include([m4/libtool.m4])
 m4_include([m4/ltoptions.m4])
 m4_include([m4/ltsugar.m4])
diff --git a/libcdi/app/Makefile.in b/libcdi/app/Makefile.in
index b130d30..f7be76b 100644
--- a/libcdi/app/Makefile.in
+++ b/libcdi/app/Makefile.in
@@ -90,18 +90,22 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps =  \
 	$(top_srcdir)/m4/acx_assert_lang_is_fortran_variant.m4 \
 	$(top_srcdir)/m4/acx_c_package.m4 \
+	$(top_srcdir)/m4/acx_cfortran_flags.m4 \
+	$(top_srcdir)/m4/acx_check_cfortran.m4 \
 	$(top_srcdir)/m4/acx_check_strptr_convert.m4 \
 	$(top_srcdir)/m4/acx_execinfo.m4 \
 	$(top_srcdir)/m4/acx_fortran_package.m4 \
 	$(top_srcdir)/m4/acx_lang_check_include.m4 \
 	$(top_srcdir)/m4/acx_lang_other_suffix_conftest.m4 \
 	$(top_srcdir)/m4/acx_lang_package.m4 \
+	$(top_srcdir)/m4/acx_lt_problems.m4 \
 	$(top_srcdir)/m4/acx_option_search_libs.m4 \
 	$(top_srcdir)/m4/acx_options.m4 \
 	$(top_srcdir)/m4/acx_sl_fc_mod_path_flag.m4 \
 	$(top_srcdir)/m4/acx_sl_mod_suffix.m4 \
 	$(top_srcdir)/m4/asx_tr_arg.m4 $(top_srcdir)/m4/asx_unset.m4 \
-	$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
+	$(top_srcdir)/m4/ax_pthread.m4 \
+	$(top_srcdir)/m4/kpse_libtool.m4 $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/starlink_fpp.m4 \
@@ -201,7 +205,6 @@ ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
-AS = @AS@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
diff --git a/libcdi/app/cdi.c b/libcdi/app/cdi.c
index 3174b06..eeee339 100644
--- a/libcdi/app/cdi.c
+++ b/libcdi/app/cdi.c
@@ -2,6 +2,7 @@
 #  include "../src/config.h"
 #endif
 
+#include <inttypes.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <stdarg.h>
@@ -32,6 +33,14 @@ int      vlistInqVarMissvalUsed(int vlistID, int varID);
 #  define IS_EQUAL(x,y)     (!IS_NOT_EQUAL(x,y))
 #endif
 
+#ifndef HOST_ENDIANNESS
+#ifdef __cplusplus
+static const uint32_t HOST_ENDIANNESS_temp[1] = { UINT32_C(0x00030201) };
+#define HOST_ENDIANNESS (((const unsigned char *)HOST_ENDIANNESS_temp)[0])
+#else
+#define HOST_ENDIANNESS (((const unsigned char *)&(const uint32_t[1]){UINT32_C(0x00030201)})[0])
+#endif
+#endif
 
 #include "printinfo.h"
 
@@ -43,21 +52,21 @@ extern char *optarg;
 extern int optind, opterr, optopt;
 
 
-char *Progname;
+static char *Progname;
 
-int DefaultFileType  = CDI_UNDEFID;
-int DefaultDataType  = CDI_UNDEFID;
-int DefaultByteorder = CDI_UNDEFID;
+static int DefaultFileType  = CDI_UNDEFID;
+static int DefaultDataType  = CDI_UNDEFID;
+static int DefaultByteorder = CDI_UNDEFID;
 
-int comptype  = COMPRESS_NONE;  // Compression type
-int complevel = 0;              // Compression level
+static int comptype  = COMPRESS_NONE;  // Compression type
+static int complevel = 0;              // Compression level
 
 
 static
 void version(void)
 {
   int   filetypes[] = {FILETYPE_SRV, FILETYPE_EXT, FILETYPE_IEG, FILETYPE_GRB, FILETYPE_GRB2, FILETYPE_NC, FILETYPE_NC2, FILETYPE_NC4, FILETYPE_NC4C};
-  char *typenames[] = {        "srv",        "ext",        "ieg",        "grb",        "grb2",        "nc",        "nc2",        "nc4",        "nc4c"};
+   const char *typenames[] = {        "srv",        "ext",        "ieg",        "grb",        "grb2",        "nc",        "nc2",        "nc4",        "nc4c"};
 
   fprintf(stderr, "CDI version 1.8\n");
 #if defined (COMPILER)
@@ -261,9 +270,7 @@ void printInfo(int vdate, int vtime, char *varname, double level,
     fprintf(stdout, "Found %d of %d missing values!\n", imiss, nmiss);
 }
 
-#define MAXCHARS 82
-
-const char * tunit2str(int tunits)
+static const char *tunit2str(int tunits)
 {
   if      ( tunits == TUNIT_YEAR )       return ("years");
   else if ( tunits == TUNIT_MONTH )      return ("months");
@@ -280,7 +287,7 @@ const char * tunit2str(int tunits)
 }
 
 
-const char* calendar2str(int calendar)
+static const char *calendar2str(int calendar)
 {
   if      ( calendar == CALENDAR_STANDARD )  return ("standard");
   else if ( calendar == CALENDAR_PROLEPTIC ) return ("proleptic_gregorian");
@@ -314,7 +321,7 @@ void printShortinfo(int streamID, int vlistID, int vardis)
   int gridsize = 0;
   int gridID, zaxisID, param;
   int vdate, vtime;
-  int nvars, ntsteps;
+  int ntsteps;
   int levelsize;
   int tsteptype, taxisID;
   char tmpname[CDI_MAX_NAME];
@@ -329,14 +336,19 @@ void printShortinfo(int streamID, int vlistID, int vardis)
       fprintf(stdout, " : ");
       printFiletype(streamID, vlistID);
 
-      if ( vardis )
-	fprintf(stdout,
-		"   Var : Institut Source   Ttype    Levels Num  Gridsize Num Dtype : Parameter name\n");
+      //vlistPrint(vlistID);
+      int nvars = vlistNvars(vlistID);
+      int nsubtypes = vlistNsubtypes(vlistID);
+
+      if ( nsubtypes > 0 )
+        fprintf(stdout, "   Var : Institut Source   Ttype    Subtypes Num  Levels Num  Gridsize Num Dtype : ");
       else
-	fprintf(stdout,
-		"   Var : Institut Source   Ttype    Levels Num  Gridsize Num Dtype : Parameter ID\n");
+        fprintf(stdout, "   Var : Institut Source   Ttype    Levels Num  Gridsize Num Dtype : ");
 
-      nvars = vlistNvars(vlistID);
+      if ( vardis )
+	fprintf(stdout, "Parameter name\n");
+      else
+	fprintf(stdout, "Parameter ID\n");
 
       for ( varID = 0; varID < nvars; varID++ )
 	{
@@ -374,6 +386,14 @@ void printShortinfo(int streamID, int vlistID, int vardis)
 	  else if ( tsteptype == TSTEP_DIFF     ) fprintf(stdout, "%-8s ", "diff");
 	  else                                    fprintf(stdout, "%-8s ", "unknown");
 
+          if ( nsubtypes > 0 )
+            {
+              int subtypeID = vlistInqVarSubtype(vlistID, varID);
+              int subtypesize = subtypeInqSize(subtypeID);
+              fprintf(stdout, " %6d  ", subtypesize);
+              fprintf(stdout, "%3d ", vlistSubtypeIndex(vlistID, subtypeID) + 1);
+            }
+
 	  /* layer info */
 	  levelsize = zaxisInqSize(zaxisID);
 	  fprintf(stdout, "%6d ", levelsize);
@@ -433,6 +453,14 @@ void printShortinfo(int streamID, int vlistID, int vardis)
 
       printZaxisInfo(vlistID);
 
+      if ( nsubtypes > 0 )
+        {
+          fprintf(stdout, "   Subtypes");
+          fprintf(stdout, " :\n");
+
+          printSubtypeInfo(vlistID);
+        }
+
       taxisID = vlistInqTaxis(vlistID);
       ntsteps = vlistNtsteps(vlistID);
 
@@ -480,14 +508,10 @@ void printShortinfo(int streamID, int vlistID, int vardis)
 }
 
 
-#undef  IsBigendian
-#define IsBigendian()  ( u_byteorder.c[sizeof(long) - 1] )
-
 
 static
 void setDefaultDataType(char *datatypestr)
 {
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
   int nbits = -1;
   enum {D_UINT, D_INT, D_FLT, D_CPX};
   int dtype = -1;
@@ -590,12 +614,12 @@ void setDefaultDataType(char *datatypestr)
     {
       if ( *datatypestr == 'l' || *datatypestr == 'L' )
 	{
-	  if ( IsBigendian() ) DefaultByteorder = CDI_LITTLEENDIAN;
+	  if ( HOST_ENDIANNESS == CDI_BIGENDIAN ) DefaultByteorder = CDI_LITTLEENDIAN;
 	  datatypestr++;
 	}
       else if ( *datatypestr == 'b' || *datatypestr == 'B' )
 	{
-	  if ( ! IsBigendian() ) DefaultByteorder = CDI_BIGENDIAN;
+	  if ( HOST_ENDIANNESS == CDI_LITTLEENDIAN ) DefaultByteorder = CDI_BIGENDIAN;
 	  datatypestr++;
 	}
       else
diff --git a/libcdi/app/createtable.c b/libcdi/app/createtable.c
index d97dd6a..3a32019 100644
--- a/libcdi/app/createtable.c
+++ b/libcdi/app/createtable.c
@@ -9,19 +9,17 @@
 static char *Progname;
 extern int CDI_Debug;
 
-void version(void)
+static void version(void)
 {
-  fprintf(stderr, "createtable version 1.00 (11 Nov 2001)\n");
-  fprintf(stderr, "\n");
+  fputs("createtable version 1.00 (11 Nov 2001)\n\n", stderr);
 }
 
-void usage(void)
+static void usage(void)
 {
-  fprintf(stderr, "usage :  createtable  [-options]  ifile  ofile\n");
-  fprintf(stderr, "with:\n");
-
-  fprintf(stderr, "   -debug        debugging mode\n");
-  fprintf(stderr, "   -version      display version number\n");
+  fputs("usage :  createtable  [-options]  ifile  ofile\n"
+        "with:\n"
+        "   -debug        debugging mode\n"
+        "   -version      display version number\n", stderr);
 }
 
 int main(int argc, char *argv[])
diff --git a/libcdi/app/printinfo.h b/libcdi/app/printinfo.h
index 997f893..c68c2ec 100644
--- a/libcdi/app/printinfo.h
+++ b/libcdi/app/printinfo.h
@@ -1,3 +1,5 @@
+// This file is used in CDI and CDO !!!
+
 #define DATE_FORMAT "%5.4d-%2.2d-%2.2d"
 #define TIME_FORMAT "%2.2d:%2.2d:%2.2d"
 
@@ -6,22 +8,21 @@ void uuid2str(const unsigned char uuid[CDI_UUID_SIZE], char *uuidstr);
 static inline
 int cdiUUIDIsNull(const unsigned char uuid[CDI_UUID_SIZE])
 {
-  static unsigned char uuid_nil[CDI_UUID_SIZE];
-  return !memcmp(uuid, uuid_nil, CDI_UUID_SIZE);
+  int isNull = 1;
+  for (size_t i = 0; i < CDI_UUID_SIZE; ++i)
+    isNull &= (uuid[i] == 0);
+  return isNull;
 }
 
 
 void datetime2str(int date, int time, char *datetimestr, int maxlen)
 {
   int year, month, day;
-  int hour, minute, second;
-  int len;
-
   cdiDecodeDate(date, &year, &month, &day);
+  int hour, minute, second;
   cdiDecodeTime(time, &hour, &minute, &second);
 
-  len = sprintf(datetimestr, DATE_FORMAT "T" TIME_FORMAT, year, month, day, hour, minute, second);
-
+  int len = sprintf(datetimestr, DATE_FORMAT "T" TIME_FORMAT, year, month, day, hour, minute, second);
   if ( len > ( maxlen-1) )
     fprintf(stderr, "Internal problem (%s): sizeof input string is too small!\n", __func__);
 }
@@ -30,12 +31,9 @@ void datetime2str(int date, int time, char *datetimestr, int maxlen)
 void date2str(int date, char *datestr, int maxlen)
 {
   int year, month, day;
-  int len;
-
   cdiDecodeDate(date, &year, &month, &day);
 
-  len = sprintf(datestr, DATE_FORMAT, year, month, day);
-
+  int len = sprintf(datestr, DATE_FORMAT, year, month, day);
   if ( len > ( maxlen-1) )
     fprintf(stderr, "Internal problem (%s): sizeof input string is too small!\n", __func__);
 }
@@ -44,12 +42,9 @@ void date2str(int date, char *datestr, int maxlen)
 void time2str(int time, char *timestr, int maxlen)
 {
   int hour, minute, second;
-  int len;
-
   cdiDecodeTime(time, &hour, &minute, &second);
 
-  len = sprintf(timestr, TIME_FORMAT, hour, minute, second);
-
+  int len = sprintf(timestr, TIME_FORMAT, hour, minute, second);
   if ( len > ( maxlen-1) )
     fprintf(stderr, "Internal problem (%s): sizeof input string is too small!\n", __func__);
 }
@@ -57,9 +52,7 @@ void time2str(int time, char *timestr, int maxlen)
 
 void printFiletype(int streamID, int vlistID)
 {
-  int filetype;
-
-  filetype = streamInqFiletype(streamID);
+  int filetype = streamInqFiletype(streamID);
 
   switch ( filetype )
     {
@@ -132,12 +125,9 @@ void printFiletype(int streamID, int vlistID)
 
   if ( filetype == FILETYPE_GRB2 )
     {
-      int nvars, varID;
       int comptype;
-
-      nvars = vlistNvars(vlistID);
-
-      for ( varID = 0; varID < nvars; varID++ )
+      int nvars = vlistNvars(vlistID);
+      for ( int varID = 0; varID < nvars; varID++ )
 	{
 	  comptype = vlistInqVarCompType(vlistID, varID);
 	  if ( comptype )
@@ -407,14 +397,13 @@ void printGridInfo(int vlistID)
 static
 void printZaxisInfo(int vlistID)
 {
-  int nzaxis, index;
   int zaxisID, zaxistype, levelsize, levelID;
   int ltype;
   double *levels = NULL;
   char zaxisname[CDI_MAX_NAME], zname[CDI_MAX_NAME], zunits[CDI_MAX_NAME];
 
-  nzaxis = vlistNzaxis(vlistID);
-  for ( index = 0; index < nzaxis; index++)
+  int nzaxis = vlistNzaxis(vlistID);
+  for ( int index = 0; index < nzaxis; index++)
     {
       double zfirst = 0, zlast = 0, zinc = 0;
       zaxisID   = vlistZaxis(vlistID, index);
@@ -483,6 +472,21 @@ void printZaxisInfo(int vlistID)
           fprintf(stdout, "\n");
         }
 
+      if ( zaxistype == ZAXIS_HYBRID )
+        {
+          char psname[CDI_MAX_NAME];
+          psname[0] = 0;
+          zaxisInqPsName(zaxisID, psname);
+          int vctsize = zaxisInqVctSize(zaxisID);
+          if ( vctsize || psname[0] )
+            {
+	      fprintf(stdout, "%33s :", "available");
+              if ( vctsize   ) fprintf(stdout, " vct");
+              if ( psname[0] ) fprintf(stdout, "  ps: %s", psname);
+              fprintf(stdout, "\n");
+            }
+        }
+
       if ( zaxistype == ZAXIS_REFERENCE )
         {
           int number   = zaxisInqNumber(zaxisID);
@@ -509,6 +513,20 @@ void printZaxisInfo(int vlistID)
     }
 }
 
+static
+void printSubtypeInfo(int vlistID)
+{
+  int nsubtypes = vlistNsubtypes(vlistID);
+  for ( int index = 0; index < nsubtypes; index++)
+    {
+      int subtypeID = vlistSubtype(vlistID, index);
+      int subtypesize = subtypeInqSize(subtypeID);
+      // subtypePrint(subtypeID);
+      fprintf(stdout, "  %4d : %-24s :", vlistSubtypeIndex(vlistID, subtypeID)+1, "tiles");
+      fprintf(stdout, " ntiles=%d", subtypesize);
+      fprintf(stdout, "\n");
+    }
+}
 
 static
 int printDateTime(int ntimeout, int vdate, int vtime)
@@ -535,7 +553,6 @@ int printDateTime(int ntimeout, int vdate, int vtime)
 static
 int printDot(int ndotout, int *nfact, int *ncout)
 {
-
   //printf("ncout %d %d %d\n",*ncout, (*ncout)%(*nfact), *nfact);
   if ( (*ncout)%(*nfact) == 0 )
     {
@@ -554,7 +571,7 @@ int printDot(int ndotout, int *nfact, int *ncout)
 
   (*ncout)++;
 
-  return (ndotout);
+  return ndotout;
 }
 
 static
@@ -616,10 +633,13 @@ void printTimesteps(int streamID, int taxisID, int verbose)
       fprintf(stdout, "\n");
 
       ntimeout = 0;
-      int toff = tsID%4;
-      if ( toff > 0 ) toff = 4 - toff;
-      for ( int i = 0; i < toff; ++i ) next_vdatetime = next_vdatetime->next;
-
+      int toff = 0;
+      if ( tsID > 2*NUM_TIMESTEP )
+        {
+          toff = tsID%4;
+          if ( toff > 0 ) toff = 4 - toff;
+          for ( int i = 0; i < toff; ++i ) next_vdatetime = next_vdatetime->next;
+        }
       for ( int i = toff; i < nvdatetime; ++i )
 	{
 	  vdate = next_vdatetime->vdate;
diff --git a/libcdi/config/config.guess b/libcdi/config/config.guess
index b79252d..7f53479 100755
--- a/libcdi/config/config.guess
+++ b/libcdi/config/config.guess
@@ -2,7 +2,7 @@
 # Attempt to guess a canonical system name.
 #   Copyright 1992-2013 Free Software Foundation, Inc.
 
-timestamp='2013-06-10'
+timestamp='2014-08-20'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -149,7 +149,8 @@ Linux|GNU|GNU/*)
 	LIBC=gnu
 	#endif
 	EOF
-	eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC'`
+        eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null \
+          | sed -n 's/^LIBC *= */LIBC=/p'`
 	;;
 esac
 
diff --git a/libcdi/config/default b/libcdi/config/default
index 9570e32..2117f4e 100755
--- a/libcdi/config/default
+++ b/libcdi/config/default
@@ -22,7 +22,7 @@ case "${HOSTNAME}" in
                     --with-grib_api=$HOME/local/gribapi-1.12.3 \
                     --with-netcdf=$HOME/local \
                     --with-szlib=$HOME/local \
-	            CC=icc CFLAGS="-g -D_REENTRANT -Wall -O3 -march=native -Df2cFortran -fp-model source"
+	            CC=icc CFLAGS="-g -D_REENTRANT -Wall -Wwrite-strings -O3 -march=native -fp-model source"
 	;;
     bailung*|d133*|d134*)
 	./configure --prefix=$HOME/local \
@@ -30,11 +30,10 @@ case "${HOSTNAME}" in
                     --enable-iso-c-interface \
                     --enable-swig \
                     --enable-python \
-                    --with-jasper=/opt/local \
-                    --with-grib_api=$HOME/local/gribapi-1.12.3 \
-                    --with-netcdf=$HOME/local \
+                    --with-grib_api=$HOME/local/grib_api-1.13.1 \
+                    --with-netcdf=$HOME/local/netcdf-c-4.3.3.1-threadsafe \
                     --with-szlib=$HOME/local \
-	            CC=gcc CFLAGS="-g -pipe -D_REENTRANT -Wall -W -Wfloat-equal -pedantic -O3 -march=native -Df2cFortran"
+	            CC=gcc CFLAGS="-g -pipe -D_REENTRANT -Wall -Wwrite-strings -W -Wfloat-equal -pedantic -O3 -march=native"
 	;;
     cinglung*|feilung*|wanglung*)
 	./configure --prefix=$HOME/local \
@@ -49,7 +48,7 @@ case "${HOSTNAME}" in
                     --with-netcdf=/opt/local \
                     --with-hdf5=/opt/local \
                     --with-szlib=/opt/local \
-	            CC=gcc CFLAGS="-g -pipe -D_REENTRANT -Wall -W -Wfloat-equal -pedantic -O2 -DpgiFortran"
+	            CC=gcc CFLAGS="-g -pipe -D_REENTRANT -Wall -W -Wfloat-equal -pedantic -O2"
 	;;
     hama*)
 	./configure --prefix=$HOME/local \
@@ -59,14 +58,14 @@ case "${HOSTNAME}" in
                     --enable-python \
                     --with-grib_api=$HOME/local/gribapi-1.13.0 \
                     --with-netcdf=$HOME/local \
-	            CC=gcc CFLAGS="-g -pipe -D_REENTRANT -Wall -W -Wfloat-equal -pedantic -O3 -Df2cFortran"
+	            CC=gcc CFLAGS="-g -pipe -D_REENTRANT -Wall -Wwrite-strings -W -Wfloat-equal -pedantic -O3"
 	;;
 # ia64-nec-linux
     ds*)
 	./configure --prefix=$HOME/local \
                     --with-netcdf=/pool/ia64/netcdf/netcdf-3.6.0-p1 \
                     --with-szlib=$HOME/local \
-                    CC=icc CFLAGS="-g -O2 -Wall -fno-alias -DMIN_BUF_SIZE=4194304 -Df2cFortran"
+                    CC=icc CFLAGS="-g -O2 -Wall -fno-alias -DMIN_BUF_SIZE=4194304"
 	;;
 # i686-linux
     etch-ia32 | gata)
@@ -141,7 +140,7 @@ case "${HOSTNAME}" in
                     --with-zlib=/sw/aix61/zlib-1.2.6 \
                     --with-szlib=/sw/aix61/szip-2.1-threadsafe \
                     AR="ar -X 64" LDFLAGS="-brtl" FC=xlf2003_r CC=xlc_r \
-                    CFLAGS="-g -O3 -qhot -q64 -qarch=auto -qtune=auto -qlistfmt=html=transforms -DHAVE_MMAP -Dextname" \
+                    CFLAGS="-g -O3 -qhot -q64 -qarch=auto -qtune=auto -qlistfmt=html=transforms -DHAVE_MMAP" \
                     FCFLAGS="-qsuffix=cpp=f90 -qextname" \
                     SHELL=/bin/bash
         ;;
diff --git a/libcdi/configure b/libcdi/configure
index 0d5b1d6..b56dc78 100755
--- a/libcdi/configure
+++ b/libcdi/configure
@@ -1,6 +1,6 @@
 #! /bin/sh
 # Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.68 for cdi 1.6.9.
+# Generated by GNU Autoconf 2.68 for cdi 1.7.0.
 #
 # Report bugs to <http://mpimet.mpg.de/cdi>.
 #
@@ -570,8 +570,8 @@ MAKEFLAGS=
 # Identity of this package.
 PACKAGE_NAME='cdi'
 PACKAGE_TARNAME='cdi'
-PACKAGE_VERSION='1.6.9'
-PACKAGE_STRING='cdi 1.6.9'
+PACKAGE_VERSION='1.7.0'
+PACKAGE_STRING='cdi 1.7.0'
 PACKAGE_BUGREPORT='http://mpimet.mpg.de/cdi'
 PACKAGE_URL=''
 
@@ -639,7 +639,6 @@ PYTHON
 ENABLE_RUBY
 ENABLE_RUBY_FALSE
 ENABLE_RUBY_TRUE
-RUBY
 ENABLE_SWIG_FALSE
 ENABLE_SWIG_TRUE
 SWIG
@@ -650,8 +649,11 @@ FC_MOD_FLAG
 ENABLE_F2003_ISOC
 CREATE_ISOC_FALSE
 CREATE_ISOC_TRUE
+RUBY
 ENABLE_MPI
 USE_MPI
+HAVE_PARALLEL_NC4_FALSE
+HAVE_PARALLEL_NC4_TRUE
 USE_PPM_CORE_FALSE
 USE_PPM_CORE_TRUE
 USE_MPI_FALSE
@@ -714,25 +716,7 @@ SYSTEM_TYPE
 HOST_NAME
 USER_NAME
 UUID_C_LIB
-AS
 CXXCPP
-am__fastdepCXX_FALSE
-am__fastdepCXX_TRUE
-CXXDEPMODE
-ac_ct_CXX
-CXXFLAGS
-CXX
-ac_ct_F77
-FFLAGS
-F77
-FPP_INCOPT
-FPP_DEFOPT
-FPPFLAGS
-FPP
-FCFLAGS_f90
-ac_ct_FC
-FCFLAGS
-FC
 CPP
 OTOOL64
 OTOOL
@@ -754,6 +738,24 @@ FGREP
 EGREP
 GREP
 SED
+LIBTOOL
+am__fastdepCXX_FALSE
+am__fastdepCXX_TRUE
+CXXDEPMODE
+ac_ct_CXX
+CXXFLAGS
+CXX
+ac_ct_F77
+FFLAGS
+F77
+FPP_INCOPT
+FPP_DEFOPT
+FPPFLAGS
+FPP
+FCFLAGS_f90
+ac_ct_FC
+FCFLAGS
+FC
 am__fastdepCC_FALSE
 am__fastdepCC_TRUE
 CCDEPMODE
@@ -771,7 +773,6 @@ CPPFLAGS
 LDFLAGS
 CFLAGS
 CC
-LIBTOOL
 MAINT
 MAINTAINER_MODE_FALSE
 MAINTAINER_MODE_TRUE
@@ -853,11 +854,11 @@ ac_user_opts='
 enable_option_checking
 enable_silent_rules
 enable_maintainer_mode
+enable_dependency_tracking
 with_pic
 enable_shared
 enable_static
 enable_fast_install
-enable_dependency_tracking
 with_gnu_ld
 with_sysroot
 enable_libtool_lock
@@ -885,6 +886,7 @@ enable_iso_c_interface
 enable_swig
 enable_ruby
 enable_python
+enable_cf_interface
 '
       ac_precious_vars='build_alias
 host_alias
@@ -894,7 +896,6 @@ CFLAGS
 LDFLAGS
 LIBS
 CPPFLAGS
-CPP
 FC
 FCFLAGS
 FPP
@@ -904,6 +905,7 @@ FFLAGS
 CXX
 CXXFLAGS
 CCC
+CPP
 CXXCPP
 MPI_C_INCLUDE
 MPI_C_LIB
@@ -1471,7 +1473,7 @@ if test "$ac_init_help" = "long"; then
   # Omit some internal or obsolete options to make the list less imposing.
   # This message is too long to be a string in the A/UX 3.1 sh.
   cat <<_ACEOF
-\`configure' configures cdi 1.6.9 to adapt to many kinds of systems.
+\`configure' configures cdi 1.7.0 to adapt to many kinds of systems.
 
 Usage: $0 [OPTION]... [VAR=VALUE]...
 
@@ -1541,7 +1543,7 @@ fi
 
 if test -n "$ac_init_help"; then
   case $ac_init_help in
-     short | recursive ) echo "Configuration of cdi 1.6.9:";;
+     short | recursive ) echo "Configuration of cdi 1.7.0:";;
    esac
   cat <<\_ACEOF
 
@@ -1554,14 +1556,14 @@ Optional Features:
   --enable-maintainer-mode
                           enable make rules and dependencies not useful (and
                           sometimes confusing) to the casual installer
-  --enable-shared[=PKGS]  build shared libraries [default=yes]
-  --enable-static[=PKGS]  build static libraries [default=yes]
-  --enable-fast-install[=PKGS]
-                          optimize for fast installation [default=yes]
   --enable-dependency-tracking
                           do not reject slow dependency extractors
   --disable-dependency-tracking
                           speeds up one-time build
+  --enable-shared[=PKGS]  build shared libraries [default=yes]
+  --enable-static[=PKGS]  build static libraries [default=yes]
+  --enable-fast-install[=PKGS]
+                          optimize for fast installation [default=yes]
   --disable-libtool-lock  avoid locking (might break parallel builds)
   --disable-largefile     omit support for large files
   --enable-grib           GRIB support [default=yes]
@@ -1579,6 +1581,7 @@ Optional Features:
                           (EXPERIMENTAL)
   --enable-ruby           ruby language bindings [default=no] (EXPERIMENTAL)
   --enable-python         python language bindings [default=no] (EXPERIMENTAL)
+  --disable-cf-interface  Omit building of cfortran Interface
 
 Optional Packages:
   --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
@@ -1629,7 +1632,6 @@ Some influential environment variables:
   LIBS        libraries to pass to the linker, e.g. -l<library>
   CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
               you have headers in a nonstandard directory <include dir>
-  CPP         C preprocessor
   FC          Fortran compiler command
   FCFLAGS     Fortran compiler flags
   FPP         Command to preprocess Fortran code
@@ -1638,6 +1640,7 @@ Some influential environment variables:
   FFLAGS      Fortran 77 compiler flags
   CXX         C++ compiler command
   CXXFLAGS    C++ compiler flags
+  CPP         C preprocessor
   CXXCPP      C++ preprocessor
   MPI_C_INCLUDE
               specifically set flags to use when compiling sources using MPI
@@ -1749,7 +1752,7 @@ fi
 test -n "$ac_init_help" && exit $ac_status
 if $ac_init_version; then
   cat <<\_ACEOF
-cdi configure 1.6.9
+cdi configure 1.7.0
 generated by GNU Autoconf 2.68
 
 Copyright (C) 2010 Free Software Foundation, Inc.
@@ -1801,6 +1804,120 @@ fi
 
 } # ac_fn_c_try_compile
 
+# ac_fn_fc_try_compile LINENO
+# ---------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_fc_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_fc_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_fc_try_compile
+
+# ac_fn_f77_try_compile LINENO
+# ----------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_f77_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_f77_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_f77_try_compile
+
+# ac_fn_cxx_try_compile LINENO
+# ----------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+	 test -z "$ac_cxx_werror_flag" ||
+	 test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+	ac_retval=1
+fi
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_cxx_try_compile
+
 # ac_fn_c_try_link LINENO
 # -----------------------
 # Try to link conftest.$ac_ext, and return whether this succeeded.
@@ -2024,21 +2141,20 @@ $as_echo "$ac_res" >&6; }
 
 } # ac_fn_c_check_func
 
-# ac_fn_fc_try_compile LINENO
-# ---------------------------
-# Try to compile conftest.$ac_ext, and return whether this succeeded.
-ac_fn_fc_try_compile ()
+# ac_fn_cxx_try_cpp LINENO
+# ------------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_cxx_try_cpp ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
-  if { { ac_try="$ac_compile"
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
 $as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>conftest.err
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
     grep -v '^ *+' conftest.err >conftest.er1
@@ -2046,26 +2162,26 @@ $as_echo "$ac_try_echo"; } >&5
     mv -f conftest.er1 conftest.err
   fi
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_fc_werror_flag" ||
+  test $ac_status = 0; } > conftest.i && {
+	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
 	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then :
+       }; then :
   ac_retval=0
 else
   $as_echo "$as_me: failed program was:" >&5
 sed 's/^/| /' conftest.$ac_ext >&5
 
-	ac_retval=1
+    ac_retval=1
 fi
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
-} # ac_fn_fc_try_compile
+} # ac_fn_cxx_try_cpp
 
-# ac_fn_fc_try_link LINENO
-# ------------------------
+# ac_fn_cxx_try_link LINENO
+# -------------------------
 # Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_fc_try_link ()
+ac_fn_cxx_try_link ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   rm -f conftest.$ac_objext conftest$ac_exeext
@@ -2085,7 +2201,7 @@ $as_echo "$ac_try_echo"; } >&5
   fi
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; } && {
-	 test -z "$ac_fc_werror_flag" ||
+	 test -z "$ac_cxx_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
@@ -2106,23 +2222,23 @@ fi
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
-} # ac_fn_fc_try_link
+} # ac_fn_cxx_try_link
 
-# ac_fn_f77_try_compile LINENO
-# ----------------------------
-# Try to compile conftest.$ac_ext, and return whether this succeeded.
-ac_fn_f77_try_compile ()
+# ac_fn_f77_try_link LINENO
+# -------------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_f77_try_link ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
-  if { { ac_try="$ac_compile"
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
 case "(($ac_try" in
   *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
   *) ac_try_echo=$ac_try;;
 esac
 eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
 $as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>conftest.err
+  (eval "$ac_link") 2>conftest.err
   ac_status=$?
   if test -s conftest.err; then
     grep -v '^ *+' conftest.err >conftest.er1
@@ -2133,7 +2249,10 @@ $as_echo "$ac_try_echo"; } >&5
   test $ac_status = 0; } && {
 	 test -z "$ac_f77_werror_flag" ||
 	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then :
+       } && test -s conftest$ac_exeext && {
+	 test "$cross_compiling" = yes ||
+	 $as_test_x conftest$ac_exeext
+       }; then :
   ac_retval=0
 else
   $as_echo "$as_me: failed program was:" >&5
@@ -2141,15 +2260,20 @@ sed 's/^/| /' conftest.$ac_ext >&5
 
 	ac_retval=1
 fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
-} # ac_fn_f77_try_compile
+} # ac_fn_f77_try_link
 
-# ac_fn_f77_try_link LINENO
-# -------------------------
+# ac_fn_fc_try_link LINENO
+# ------------------------
 # Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_f77_try_link ()
+ac_fn_fc_try_link ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   rm -f conftest.$ac_objext conftest$ac_exeext
@@ -2169,7 +2293,7 @@ $as_echo "$ac_try_echo"; } >&5
   fi
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; } && {
-	 test -z "$ac_f77_werror_flag" ||
+	 test -z "$ac_fc_werror_flag" ||
 	 test ! -s conftest.err
        } && test -s conftest$ac_exeext && {
 	 test "$cross_compiling" = yes ||
@@ -2190,134 +2314,13 @@ fi
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
   as_fn_set_status $ac_retval
 
-} # ac_fn_f77_try_link
+} # ac_fn_fc_try_link
 
-# ac_fn_cxx_try_compile LINENO
-# ----------------------------
-# Try to compile conftest.$ac_ext, and return whether this succeeded.
-ac_fn_cxx_try_compile ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext
-  if { { ac_try="$ac_compile"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compile") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_cxx_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest.$ac_objext; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_cxx_try_compile
-
-# ac_fn_cxx_try_cpp LINENO
-# ------------------------
-# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
-ac_fn_cxx_try_cpp ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  if { { ac_try="$ac_cpp conftest.$ac_ext"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } > conftest.i && {
-	 test -z "$ac_cxx_preproc_warn_flag$ac_cxx_werror_flag" ||
-	 test ! -s conftest.err
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-    ac_retval=1
-fi
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_cxx_try_cpp
-
-# ac_fn_cxx_try_link LINENO
-# -------------------------
-# Try to link conftest.$ac_ext, and return whether this succeeded.
-ac_fn_cxx_try_link ()
-{
-  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
-  rm -f conftest.$ac_objext conftest$ac_exeext
-  if { { ac_try="$ac_link"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_link") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    grep -v '^ *+' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-    mv -f conftest.er1 conftest.err
-  fi
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && {
-	 test -z "$ac_cxx_werror_flag" ||
-	 test ! -s conftest.err
-       } && test -s conftest$ac_exeext && {
-	 test "$cross_compiling" = yes ||
-	 $as_test_x conftest$ac_exeext
-       }; then :
-  ac_retval=0
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-	ac_retval=1
-fi
-  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
-  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
-  # interfere with the next link command; also delete a directory that is
-  # left behind by Apple's compiler.  We do this before executing the actions.
-  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
-  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
-  as_fn_set_status $ac_retval
-
-} # ac_fn_cxx_try_link
-
-# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
-# ----------------------------------------------------
-# Tries to find if the field MEMBER exists in type AGGR, after including
-# INCLUDES, setting cache variable VAR accordingly.
-ac_fn_c_check_member ()
+# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
+# ----------------------------------------------------
+# Tries to find if the field MEMBER exists in type AGGR, after including
+# INCLUDES, setting cache variable VAR accordingly.
+ac_fn_c_check_member ()
 {
   as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
@@ -2506,11 +2509,95 @@ $as_echo "$ac_res" >&6; }
   eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
 
 } # ac_fn_c_check_decl
+
+# ac_fn_fc_try_run LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_fc_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_fc_try_run
+
+# ac_fn_f77_try_run LINENO
+# ------------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_f77_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno
+  as_fn_set_status $ac_retval
+
+} # ac_fn_f77_try_run
 cat >config.log <<_ACEOF
 This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 
-It was created by cdi $as_me 1.6.9, which was
+It was created by cdi $as_me 1.7.0, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   $ $0 $@
@@ -2862,6 +2949,12 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+
+cat >>confdefs.h <<_ACEOF
+#define CDI "$PACKAGE_VERSION"
+_ACEOF
+
+
 echo "configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}"
 
 CONFIG_ABORT=yes
@@ -3456,7 +3549,7 @@ fi
 
 # Define the identity of the package.
  PACKAGE='cdi'
- VERSION='1.6.9'
+ VERSION='1.7.0'
 
 
 cat >>confdefs.h <<_ACEOF
@@ -3574,102 +3667,98 @@ fi
 
 
 
-# Set up libtool.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: setting up libtool" >&5
-$as_echo "$as_me: setting up libtool" >&6;}
-case `pwd` in
-  *\ * | *\	*)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
-$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
-esac
-
-
-
-macro_version='2.4.2'
-macro_revision='1.3337'
-
-
-
-
-
-
-
-
-
-
-
+# Check building environment
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
-ltmain="$ac_aux_dir/ltmain.sh"
 
-# Backslashify metacharacters that are still active within
-# double-quoted strings.
-sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
-
-# Same as above, but do not quote variable references.
-double_quote_subst='s/\(["`\\]\)/\\\1/g'
-
-# Sed substitution to delay expansion of an escaped shell variable in a
-# double_quote_subst'ed string.
-delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
-
-# Sed substitution to delay expansion of an escaped single quote.
-delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
-
-# Sed substitution to avoid accidental globbing in evaled expressions
-no_glob_subst='s/\*/\\\*/g'
-
-ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
-ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
-ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
-$as_echo_n "checking how to print strings... " >&6; }
-# Test print first, because it will be a builtin if present.
-if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
-   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
-  ECHO='print -r --'
-elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
-  ECHO='printf %s\n'
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
 else
-  # Use this function as a fallback that always works.
-  func_fallback_echo ()
-  {
-    eval 'cat <<_LTECHO_EOF
-$1
-_LTECHO_EOF'
-  }
-  ECHO='func_fallback_echo'
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
-# func_echo_all arg...
-# Invoke $ECHO with all args, space-separated.
-func_echo_all ()
-{
-    $ECHO ""
-}
-
-case "$ECHO" in
-  printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
-$as_echo "printf" >&6; } ;;
-  print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
-$as_echo "print -r" >&6; } ;;
-  *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
-$as_echo "cat" >&6; } ;;
+  if test "x$ac_ct_CC" = x; then
+    CC=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
 esac
-
-
-
-
-
-
-
-
-
-
-
-
-
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
 
 DEPDIR="${am__leading_dot}deps"
 
@@ -4711,954 +4800,1227 @@ else
 fi
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
-$as_echo_n "checking for a sed that does not truncate output... " >&6; }
-if ${ac_cv_path_SED+:} false; then :
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5
+$as_echo_n "checking for $CC option to accept ISO C99... " >&6; }
+if ${ac_cv_prog_cc_c99+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
-     for ac_i in 1 2 3 4 5 6 7; do
-       ac_script="$ac_script$as_nl$ac_script"
-     done
-     echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
-     { ac_script=; unset ac_script;}
-     if test -z "$SED"; then
-  ac_path_SED_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in sed gsed; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
-# Check for GNU ac_path_SED and select it if it is found.
-  # Check for GNU $ac_path_SED
-case `"$ac_path_SED" --version 2>&1` in
-*GNU*)
-  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo '' >> "conftest.nl"
-    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_SED_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_SED="$ac_path_SED"
-      ac_path_SED_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_SED_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_SED"; then
-    as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
-  fi
-else
-  ac_cv_path_SED=$SED
-fi
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
-$as_echo "$ac_cv_path_SED" >&6; }
- SED="$ac_cv_path_SED"
-  rm -f conftest.sed
-
-test -z "$SED" && SED=sed
-Xsed="$SED -e 1s/^X//"
-
-
+  ac_cv_prog_cc_c99=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <stdio.h>
 
+// Check varargs macros.  These examples are taken from C99 6.10.3.5.
+#define debug(...) fprintf (stderr, __VA_ARGS__)
+#define showlist(...) puts (#__VA_ARGS__)
+#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
+static void
+test_varargs_macros (void)
+{
+  int x = 1234;
+  int y = 5678;
+  debug ("Flag");
+  debug ("X = %d\n", x);
+  showlist (The first, second, and third items.);
+  report (x>y, "x is %d but y is %d", x, y);
+}
 
+// Check long long types.
+#define BIG64 18446744073709551615ull
+#define BIG32 4294967295ul
+#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
+#if !BIG_OK
+  your preprocessor is broken;
+#endif
+#if BIG_OK
+#else
+  your preprocessor is broken;
+#endif
+static long long int bignum = -9223372036854775807LL;
+static unsigned long long int ubignum = BIG64;
 
+struct incomplete_array
+{
+  int datasize;
+  double data[];
+};
 
+struct named_init {
+  int number;
+  const wchar_t *name;
+  double average;
+};
 
+typedef const char *ccp;
 
+static inline int
+test_restrict (ccp restrict text)
+{
+  // See if C++-style comments work.
+  // Iterate through items via the restricted pointer.
+  // Also check for declarations in for loops.
+  for (unsigned int i = 0; *(text+i) != '\0'; ++i)
+    continue;
+  return 0;
+}
 
+// Check varargs and va_copy.
+static void
+test_varargs (const char *format, ...)
+{
+  va_list args;
+  va_start (args, format);
+  va_list args_copy;
+  va_copy (args_copy, args);
 
+  const char *str;
+  int number;
+  float fnumber;
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
-$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
-if ${ac_cv_path_GREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$GREP"; then
-  ac_path_GREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+  while (*format)
+    {
+      switch (*format++)
+	{
+	case 's': // string
+	  str = va_arg (args_copy, const char *);
+	  break;
+	case 'd': // int
+	  number = va_arg (args_copy, int);
+	  break;
+	case 'f': // float
+	  fnumber = va_arg (args_copy, double);
+	  break;
+	default:
+	  break;
+	}
+    }
+  va_end (args_copy);
+  va_end (args);
+}
+
+int
+main ()
+{
+
+  // Check bool.
+  _Bool success = false;
+
+  // Check restrict.
+  if (test_restrict ("String literal") == 0)
+    success = true;
+  char *restrict newvar = "Another string";
+
+  // Check varargs.
+  test_varargs ("s, d' f .", "string", 65, 34.234);
+  test_varargs_macros ();
+
+  // Check flexible array members.
+  struct incomplete_array *ia =
+    malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
+  ia->datasize = 10;
+  for (int i = 0; i < ia->datasize; ++i)
+    ia->data[i] = i * 1.234;
+
+  // Check named initializers.
+  struct named_init ni = {
+    .number = 34,
+    .name = L"Test wide string",
+    .average = 543.34343,
+  };
+
+  ni.number = 58;
+
+  int dynamic_array[ni.number];
+  dynamic_array[ni.number - 1] = 543;
+
+  // work around unused variable warnings
+  return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
+	  || dynamic_array[ni.number - 1] != 543);
+
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -xc99=all -qlanglvl=extc99
 do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_prog in grep ggrep; do
-    for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
-# Check for GNU ac_path_GREP and select it if it is found.
-  # Check for GNU $ac_path_GREP
-case `"$ac_path_GREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'GREP' >> "conftest.nl"
-    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_GREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_GREP="$ac_path_GREP"
-      ac_path_GREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c99=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c99" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c99" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c99"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
+$as_echo "$ac_cv_prog_cc_c99" >&6; } ;;
 esac
+if test "x$ac_cv_prog_cc_c99" != xno; then :
 
-      $ac_path_GREP_found && break 3
-    done
-  done
-  done
-IFS=$as_save_IFS
-  if test -z "$ac_cv_path_GREP"; then
-    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
+fi
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5
+$as_echo_n "checking for C/C++ restrict keyword... " >&6; }
+if ${ac_cv_c_restrict+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
-  ac_cv_path_GREP=$GREP
+  ac_cv_c_restrict=no
+   # The order here caters to the fact that C++ does not require restrict.
+   for ac_kw in __restrict __restrict__ _Restrict restrict; do
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+typedef int * int_ptr;
+	int foo (int_ptr $ac_kw ip) {
+	return ip[0];
+       }
+int
+main ()
+{
+int s[1];
+	int * $ac_kw t = s;
+	t[0] = 0;
+	return foo(t)
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_restrict=$ac_kw
 fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+     test "$ac_cv_c_restrict" != no && break
+   done
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
-$as_echo "$ac_cv_path_GREP" >&6; }
- GREP="$ac_cv_path_GREP"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5
+$as_echo "$ac_cv_c_restrict" >&6; }
 
+ case $ac_cv_c_restrict in
+   restrict) ;;
+   no) $as_echo "#define restrict /**/" >>confdefs.h
+ ;;
+   *)  cat >>confdefs.h <<_ACEOF
+#define restrict $ac_cv_c_restrict
+_ACEOF
+ ;;
+ esac
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
-$as_echo_n "checking for egrep... " >&6; }
-if ${ac_cv_path_EGREP+:} false; then :
+ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_FC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
-   then ac_cv_path_EGREP="$GREP -E"
-   else
-     if test -z "$EGREP"; then
-  ac_path_EGREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+  if test -n "$FC"; then
+  ac_cv_prog_FC="$FC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_prog in egrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
-# Check for GNU ac_path_EGREP and select it if it is found.
-  # Check for GNU $ac_path_EGREP
-case `"$ac_path_EGREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'EGREP' >> "conftest.nl"
-    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_EGREP="$ac_path_EGREP"
-      ac_path_EGREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_EGREP_found && break 3
-    done
-  done
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_FC="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
   done
 IFS=$as_save_IFS
-  if test -z "$ac_cv_path_EGREP"; then
-    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_EGREP=$EGREP
-fi
 
-   fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
-$as_echo "$ac_cv_path_EGREP" >&6; }
- EGREP="$ac_cv_path_EGREP"
+fi
+FC=$ac_cv_prog_FC
+if test -n "$FC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FC" >&5
+$as_echo "$FC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
-$as_echo_n "checking for fgrep... " >&6; }
-if ${ac_cv_path_FGREP+:} false; then :
+    test -n "$FC" && break
+  done
+fi
+if test -z "$FC"; then
+  ac_ct_FC=$FC
+  for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_FC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
-   then ac_cv_path_FGREP="$GREP -F"
-   else
-     if test -z "$FGREP"; then
-  ac_path_FGREP_found=false
-  # Loop through the user's path and test for each of PROGNAME-LIST
-  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+  if test -n "$ac_ct_FC"; then
+  ac_cv_prog_ac_ct_FC="$ac_ct_FC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
-    for ac_prog in fgrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
-      ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
-      { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue
-# Check for GNU ac_path_FGREP and select it if it is found.
-  # Check for GNU $ac_path_FGREP
-case `"$ac_path_FGREP" --version 2>&1` in
-*GNU*)
-  ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
-*)
-  ac_count=0
-  $as_echo_n 0123456789 >"conftest.in"
-  while :
-  do
-    cat "conftest.in" "conftest.in" >"conftest.tmp"
-    mv "conftest.tmp" "conftest.in"
-    cp "conftest.in" "conftest.nl"
-    $as_echo 'FGREP' >> "conftest.nl"
-    "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
-    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
-    as_fn_arith $ac_count + 1 && ac_count=$as_val
-    if test $ac_count -gt ${ac_path_FGREP_max-0}; then
-      # Best one so far, save it but keep looking for a better one
-      ac_cv_path_FGREP="$ac_path_FGREP"
-      ac_path_FGREP_max=$ac_count
-    fi
-    # 10*(2^10) chars as input seems more than enough
-    test $ac_count -gt 10 && break
-  done
-  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
-esac
-
-      $ac_path_FGREP_found && break 3
-    done
-  done
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_FC="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
   done
 IFS=$as_save_IFS
-  if test -z "$ac_cv_path_FGREP"; then
-    as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
-  fi
-else
-  ac_cv_path_FGREP=$FGREP
-fi
 
-   fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
-$as_echo "$ac_cv_path_FGREP" >&6; }
- FGREP="$ac_cv_path_FGREP"
+fi
+ac_ct_FC=$ac_cv_prog_ac_ct_FC
+if test -n "$ac_ct_FC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_FC" >&5
+$as_echo "$ac_ct_FC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
 
-test -z "$GREP" && GREP=grep
+  test -n "$ac_ct_FC" && break
+done
 
+  if test "x$ac_ct_FC" = x; then
+    FC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    FC=$ac_ct_FC
+  fi
+fi
 
 
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+rm -f a.out
 
+# If we don't use `.F' as extension, the preprocessor is not run on the
+# input file.  (Note that this only needs to work for GNU compilers.)
+ac_save_ext=$ac_ext
+ac_ext=F
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Fortran compiler" >&5
+$as_echo_n "checking whether we are using the GNU Fortran compiler... " >&6; }
+if ${ac_cv_fc_compiler_gnu+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.$ac_ext <<_ACEOF
+      program conftest
+#ifndef __GNUC__
+       choke me
+#endif
 
+      end
+_ACEOF
+if ac_fn_fc_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_fc_compiler_gnu=$ac_compiler_gnu
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fc_compiler_gnu" >&5
+$as_echo "$ac_cv_fc_compiler_gnu" >&6; }
+ac_ext=$ac_save_ext
+ac_test_FCFLAGS=${FCFLAGS+set}
+ac_save_FCFLAGS=$FCFLAGS
+FCFLAGS=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $FC accepts -g" >&5
+$as_echo_n "checking whether $FC accepts -g... " >&6; }
+if ${ac_cv_prog_fc_g+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  FCFLAGS=-g
+cat > conftest.$ac_ext <<_ACEOF
+      program conftest
 
+      end
+_ACEOF
+if ac_fn_fc_try_compile "$LINENO"; then :
+  ac_cv_prog_fc_g=yes
+else
+  ac_cv_prog_fc_g=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_fc_g" >&5
+$as_echo "$ac_cv_prog_fc_g" >&6; }
+if test "$ac_test_FCFLAGS" = set; then
+  FCFLAGS=$ac_save_FCFLAGS
+elif test $ac_cv_prog_fc_g = yes; then
+  if test "x$ac_cv_fc_compiler_gnu" = xyes; then
+    FCFLAGS="-g -O2"
+  else
+    FCFLAGS="-g"
+  fi
+else
+  if test "x$ac_cv_fc_compiler_gnu" = xyes; then
+    FCFLAGS="-O2"
+  else
+    FCFLAGS=
+  fi
+fi
 
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
+if test -n "$FC" && test "X$FC" != Xno; then :
+  ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran flag to compile .f90 files" >&5
+$as_echo_n "checking for Fortran flag to compile .f90 files... " >&6; }
+if ${ac_cv_fc_srcext_f90+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_ext=f90
+ac_fcflags_srcext_save=$ac_fcflags_srcext
+ac_fcflags_srcext=
+ac_cv_fc_srcext_f90=unknown
+for ac_flag in none -qsuffix=f=f90 -Tf; do
+  test "x$ac_flag" != xnone && ac_fcflags_srcext="$ac_flag"
+  cat > conftest.$ac_ext <<_ACEOF
+      program conftest
 
+      end
+_ACEOF
+if ac_fn_fc_try_compile "$LINENO"; then :
+  ac_cv_fc_srcext_f90=$ac_flag; break
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+rm -f conftest.$ac_objext conftest.f90
+ac_fcflags_srcext=$ac_fcflags_srcext_save
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fc_srcext_f90" >&5
+$as_echo "$ac_cv_fc_srcext_f90" >&6; }
+if test "x$ac_cv_fc_srcext_f90" = xunknown; then
+  as_fn_error $? "Fortran could not compile .f90 files" "$LINENO" 5
+else
+  ac_fc_srcext=f90
+  if test "x$ac_cv_fc_srcext_f90" = xnone; then
+    ac_fcflags_srcext=""
+    FCFLAGS_f90=""
+  else
+    ac_fcflags_srcext=$ac_cv_fc_srcext_f90
+    FCFLAGS_f90=$ac_cv_fc_srcext_f90
+  fi
 
 
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+
+
+   # Prefer AC_PROG_FC to AC_PROG_F77
+   export FC FCFLAGS
+   if test "X$F77" != X; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Use AC_PROG_FC with AC_PROG_FPP, instead of AC_PROG_F77" >&5
+$as_echo "$as_me: WARNING: Use AC_PROG_FC with AC_PROG_FPP, instead of AC_PROG_F77" >&2;}
+fi
 
 
 
-# Check whether --with-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then :
-  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+
+
+   acx_sl_fpp_srcext=${ac_fc_srcext-F}
+   as_acx_sl_prog_fpp=`$as_echo "acx_sl_cv_prog_fpp_fc_${ac_fc_srcext-f}" | $as_tr_sh`
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to preprocess Fortran files with suffix $acx_sl_fpp_srcext" >&5
+$as_echo_n "checking how to preprocess Fortran files with suffix $acx_sl_fpp_srcext... " >&6; }
+if eval \${$as_acx_sl_prog_fpp+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
-  with_gnu_ld=no
-fi
+  eval "$as_acx_sl_prog_fpp="
+      # Let the user specify FPP
+      if test -n "$FPP"; then :
+  rm -f conftest*
 
-ac_prog=ld
-if test "$GCC" = yes; then
-  # Check if gcc -print-prog-name=ld gives a path.
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
-$as_echo_n "checking for ld used by $CC... " >&6; }
-  case $host in
-  *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
-    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
-  *)
-    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
-  esac
-  case $ac_prog in
-    # Accept absolute paths.
-    [\\/]* | ?:[\\/]*)
-      re_direlt='/[^/][^/]*/\.\./'
-      # Canonicalize the pathname of ld
-      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
-      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
-	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
-      done
-      test -z "$LD" && LD="$ac_prog"
-      ;;
-  "")
-    # If it fails, then pretend we aren't using GCC.
-    ac_prog=ld
-    ;;
-  *)
-    # If it is relative, then search for the first ld in PATH.
-    with_gnu_ld=unknown
-    ;;
-  esac
-elif test "$with_gnu_ld" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
-$as_echo_n "checking for GNU ld... " >&6; }
+   cat > conftest.$ac_ext <<_ACEOF
+      program conftest
+#define OK
+#ifdef OK
+      REAL A
+#else
+      syntax error
+#endif
+      end
+_ACEOF
+   ac_tmp=conftest.fppout
+   if { {        ac_try="$FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext >$ac_tmp"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  ($FPP conftest.$acx_sl_fpp_srcext >$ac_tmp) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  if test -f $ac_tmp \
+        && ! cmp conftest.$acx_sl_fpp_srcext $ac_tmp >/dev/null 2>&1 \
+        && grep '^      REAL A' $ac_tmp >/dev/null 2>&1 \
+        && ! grep 'syntax error' $ac_tmp >/dev/null 2>&1; then :
+  # we have Fortran!  See if the file can be compiled:
+         mv $ac_tmp conftest.$ac_ext
+         if ac_fn_fc_try_compile "$LINENO"; then :
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+            eval "$as_acx_sl_prog_fpp=\"\$FPP\""
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
-$as_echo_n "checking for non-GNU ld... " >&6; }
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+            { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: user-specified \$FPP ($FPP) does not work" >&5
+$as_echo "$as_me: WARNING: user-specified \$FPP ($FPP) does not work" >&2;}
+            FPP=
 fi
-if ${lt_cv_path_LD+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
-      # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
-      # Break only if it was the GNU/non-GNU ld that we prefer.
-      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
-      *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
-	;;
-      *)
-	test "$with_gnu_ld" != yes && break
-	;;
-      esac
-    fi
-  done
-  IFS="$lt_save_ifs"
+rm -f core conftest.err conftest.$ac_objext
 else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+  mv $ac_tmp conftest.$ac_ext
+         $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+         { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: user-specified \$FPP ($FPP) does not work" >&5
+$as_echo "$as_me: WARNING: user-specified \$FPP ($FPP) does not work" >&2;}
+            FPP=
 fi
 fi
+   rm -f conftest*
 
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
-$as_echo "$LD" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
 fi
-test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
-$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
-if ${lt_cv_prog_gnu_ld+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  # I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
-  lt_cv_prog_gnu_ld=yes
-  ;;
-*)
-  lt_cv_prog_gnu_ld=no
-  ;;
+      if test -z "$FPP"; then :
+  for ac_fpp in `cd $srcdir ; pwd`/util/sxpreproc-wrapper \
+           `cd $srcdir ; pwd`/util/xlfpreproc-wrapper \
+           `cd $srcdir ; pwd`/util/sunf95preproc-wrapper \
+           `cd $srcdir ; pwd`/util/crayftnpreproc-wrapper \
+           "$FC -F" "$FC -F -fpp" "$FC -E" "$FC -E -cpp" \
+           "$FC $FCFLAGS -F" "$FC $FCFLAGS -E" "$FC $FCFLAGS -E" \
+           "$FC $FCFLAGS -E -cpp" "$FC $FCFLAGS -x f95-cpp-input -E -P"
+         do
+           rm -f conftest*
+
+   cat > conftest.$ac_ext <<_ACEOF
+      program conftest
+#define OK
+#ifdef OK
+      REAL A
+#else
+      syntax error
+#endif
+      end
+_ACEOF
+   ac_tmp=conftest.fppout
+   if { {        ac_try="$ac_fpp $FPPFLAGS conftest.$acx_sl_fpp_srcext >$ac_tmp"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
 esac
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
-$as_echo "$lt_cv_prog_gnu_ld" >&6; }
-with_gnu_ld=$lt_cv_prog_gnu_ld
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  ($ac_fpp conftest.$acx_sl_fpp_srcext >$ac_tmp) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  if test -f $ac_tmp \
+        && ! cmp conftest.$acx_sl_fpp_srcext $ac_tmp >/dev/null 2>&1 \
+        && grep '^      REAL A' $ac_tmp >/dev/null 2>&1 \
+        && ! grep 'syntax error' $ac_tmp >/dev/null 2>&1; then :
+  # we have Fortran!  See if the file can be compiled:
+         mv $ac_tmp conftest.$ac_ext
+         if ac_fn_fc_try_compile "$LINENO"; then :
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
+            FPP="$ac_fpp"
+              break
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
 
+fi
+rm -f core conftest.err conftest.$ac_objext
+else
+  mv $ac_tmp conftest.$ac_ext
+         $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
 
+fi
+fi
+   rm -f conftest*
 
+           rm -f conftest*
 
+   cat > conftest.$ac_ext <<_ACEOF
+      program conftest
+#define OK
+#ifdef OK
+      REAL A
+#else
+      syntax error
+#endif
+      end
+_ACEOF
+   ac_tmp=conftest.fppout
+   if { {        ac_try="$ac_fpp -P $FPPFLAGS conftest.$acx_sl_fpp_srcext >$ac_tmp"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  ($ac_fpp -P conftest.$acx_sl_fpp_srcext >$ac_tmp) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  if test -f $ac_tmp \
+        && ! cmp conftest.$acx_sl_fpp_srcext $ac_tmp >/dev/null 2>&1 \
+        && grep '^      REAL A' $ac_tmp >/dev/null 2>&1 \
+        && ! grep 'syntax error' $ac_tmp >/dev/null 2>&1; then :
+  # we have Fortran!  See if the file can be compiled:
+         mv $ac_tmp conftest.$ac_ext
+         if ac_fn_fc_try_compile "$LINENO"; then :
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+            FPP="$ac_fpp -P"
+              break
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
-$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
-if ${lt_cv_path_NM+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$NM"; then
-  # Let the user override the test.
-  lt_cv_path_NM="$NM"
-else
-  lt_nm_to_check="${ac_tool_prefix}nm"
-  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
-    lt_nm_to_check="$lt_nm_to_check nm"
-  fi
-  for lt_tmp_nm in $lt_nm_to_check; do
-    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
-      IFS="$lt_save_ifs"
-      test -z "$ac_dir" && ac_dir=.
-      tmp_nm="$ac_dir/$lt_tmp_nm"
-      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
-	# Check to see if the nm accepts a BSD-compat flag.
-	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
-	#   nm: unknown option "B" ignored
-	# Tru64's nm complains that /dev/null is an invalid object file
-	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
-	*/dev/null* | *'Invalid file or object type'*)
-	  lt_cv_path_NM="$tmp_nm -B"
-	  break
-	  ;;
-	*)
-	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
-	  */dev/null*)
-	    lt_cv_path_NM="$tmp_nm -p"
-	    break
-	    ;;
-	  *)
-	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
-	    continue # so that we can try to find one that supports BSD flags
-	    ;;
-	  esac
-	  ;;
-	esac
-      fi
-    done
-    IFS="$lt_save_ifs"
-  done
-  : ${lt_cv_path_NM=no}
-fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
-$as_echo "$lt_cv_path_NM" >&6; }
-if test "$lt_cv_path_NM" != "no"; then
-  NM="$lt_cv_path_NM"
-else
-  # Didn't find any BSD compatible name lister, look for dumpbin.
-  if test -n "$DUMPBIN"; then :
-    # Let the user override the test.
-  else
-    if test -n "$ac_tool_prefix"; then
-  for ac_prog in dumpbin "link -dump"
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_DUMPBIN+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$DUMPBIN"; then
-  ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
+rm -f core conftest.err conftest.$ac_objext
 else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+  mv $ac_tmp conftest.$ac_ext
+         $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
 
 fi
 fi
-DUMPBIN=$ac_cv_prog_DUMPBIN
-if test -n "$DUMPBIN"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
-$as_echo "$DUMPBIN" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
+   rm -f conftest*
 
-    test -n "$DUMPBIN" && break
-  done
+         done
+                  \rm a.out 2>/dev/null
 fi
-if test -z "$DUMPBIN"; then
-  ac_ct_DUMPBIN=$DUMPBIN
-  for ac_prog in dumpbin "link -dump"
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_DUMPBIN"; then
-  ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
+      if test -z "$FPP"; then :
+
 else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+  eval "$as_acx_sl_prog_fpp=\$FPP"
 
 fi
 fi
-ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
-if test -n "$ac_ct_DUMPBIN"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
-$as_echo "$ac_ct_DUMPBIN" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+eval ac_res=\$$as_acx_sl_prog_fpp
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
 
 
-  test -n "$ac_ct_DUMPBIN" && break
-done
 
-  if test "x$ac_ct_DUMPBIN" = x; then
-    DUMPBIN=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
+   # ACX_SL_PROG_FC_FPP_FEATURES does the actual feature tests,
+   # storing results of the checks in non-cv variables like
+   # ac_prog_fc_cpp_*, which we copy to cv variables afterwards.  This
+   # allows this macro to be reusable for other cv variables (see
+   # below)
+
+   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if preprocessing with $FPP of Fortran source supports required preprocessor features" >&5
+$as_echo_n "checking if preprocessing with $FPP of Fortran source supports required preprocessor features... " >&6; }
+if ${acx_sl_cv_fc_indirect_ok+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  acx_sl_cv_fc_indirect_ok=yes
+      # Set up ac_fpp_need_* flags based on features in
+      acx_sl_fpp_srcext=${ac_fc_srcext-F}
+      # defaults for needed features
+   ac_fpp_need_d=yes
+   ac_fpp_need_i=yes
+   ac_fpp_need_subs=no
+   ac_fpp_need_wrap=no
+   ac_fpp_need_cstyle=no
+   ac_fpp_need_CSTYLE=no
+   ac_fpp_need_cxxstyle=yes
+   ac_fpp_need_CXXSTYLE=no
+         for _t in  nil
+   do
+     case $_t in #(
+  define) :
+    ac_fpp_need_d=yes ;; #(
+  nodefine) :
+    ac_fpp_need_d=no ;; #(
+  include) :
+    ac_fpp_need_i=yes ;; #(
+  noinclude) :
+    ac_fpp_need_i=no ;; #(
+  substitute) :
+    ac_fpp_need_subs=yes ;; #(
+  nosubstitute) :
+    ac_fpp_need_subs=no ;; #(
+  wrap) :
+    ac_fpp_need_wrap=yes ;; #(
+  nowwrap) :
+    ac_fpp_need_wrap=no ;; #(
+  cstyle) :
+    ac_fpp_need_cstyle=yes ;; #(
+  nocstyle) :
+    ac_fpp_need_cstyle=no ;; #(
+  CSTYLE) :
+    ac_fpp_need_CSTYLE=yes ;; #(
+  noCSTYLE) :
+    ac_fpp_need_CSTYLE=no ;; #(
+  cxxstyle) :
+    ac_fpp_need_cxxstyle=yes ;; #(
+  nocxxstyle) :
+    ac_fpp_need_cxxstyle=no ;; #(
+  CXXSTYLE) :
+    ac_fpp_need_CXXSTYLE=yes ;; #(
+  noCXXSTYLE) :
+    ac_fpp_need_CXXSTYLE=no ;; #(
+  nil) :
+     ;; #(
+  *) :
+     ;;
 esac
-    DUMPBIN=$ac_ct_DUMPBIN
-  fi
-fi
+   done
+   # Wrapping requires substitution
+   test $ac_fpp_need_wrap = yes && ac_fpp_need_subs=yes
+   # CSTYLE and cstyle are mutually exclusive.
+   # CSTYLE takes precedence, since if it is not fulfilled,
+   # compile errors may arise
+   test $ac_fpp_need_CSTYLE = yes && ac_fpp_need_cstyle=no
+      test $ac_fpp_need_CXXSTYLE = yes && ac_fpp_need_cxxstyle=no
 
-    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
-    *COFF*)
-      DUMPBIN="$DUMPBIN -symbols"
-      ;;
-    *)
-      DUMPBIN=:
-      ;;
-    esac
-  fi
 
-  if test "$DUMPBIN" != ":"; then
-    NM="$DUMPBIN"
-  fi
-fi
-test -z "$NM" && NM=nm
+      acx_sl_prog_fc_cpp_CSTYLE=no
+      acx_sl_prog_fc_cpp_cxxstyle=no
 
 
+      ac_save_FCFLAGS=$FCFLAGS
 
 
 
+      # We need to skip the following tests if we're trying direct compilation
+      # and FC won't preprocess.
+      if test x$ac_fpp_need_d = xyes; then :
+  acx_sl_prog_fc_cpp_d=no
+         $as_echo "$as_me:${as_lineno-$LINENO}: Trying flag to create preprocessor defines." >&5
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
-$as_echo_n "checking the name lister ($NM) interface... " >&6; }
-if ${lt_cv_nm_interface+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_nm_interface="BSD nm"
-  echo "int some_variable = 0;" > conftest.$ac_ext
-  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5)
-  (eval "$ac_compile" 2>conftest.err)
-  cat conftest.err >&5
-  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
-  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
-  cat conftest.err >&5
-  (eval echo "\"\$as_me:$LINENO: output\"" >&5)
-  cat conftest.out >&5
-  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
-    lt_cv_nm_interface="MS dumpbin"
-  fi
-  rm -f conftest*
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
-$as_echo "$lt_cv_nm_interface" >&6; }
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
-$as_echo_n "checking whether ln -s works... " >&6; }
-LN_S=$as_ln_s
-if test "$LN_S" = "ln -s"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
-$as_echo "no, using $LN_S" >&6; }
-fi
-
-# find the maximum length of command line arguments
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
-$as_echo_n "checking the maximum length of command line arguments... " >&6; }
-if ${lt_cv_sys_max_cmd_len+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-    i=0
-  teststring="ABCD"
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
-  case $build_os in
-  msdosdjgpp*)
-    # On DJGPP, this test can blow up pretty badly due to problems in libc
-    # (any single argument exceeding 2000 bytes causes a buffer overrun
-    # during glob expansion).  Even if it were fixed, the result of this
-    # check would be larger than it should be.
-    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
-    ;;
+   ac_ext="$acx_sl_fpp_srcext"
+   cat > conftest.$ac_ext <<_ACEOF
+      program conftest
+#ifndef OK
+      syntax error
+#endif
+      end
+_ACEOF
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
-  gnu*)
-    # Under GNU Hurd, this test is not required because there is
-    # no limit to the length of command line arguments.
-    # Libtool will interpret -1 as no limit whatsoever
-    lt_cv_sys_max_cmd_len=-1;
-    ;;
 
-  cygwin* | mingw* | cegcc*)
-    # On Win9x/ME, this test blows up -- it succeeds, but takes
-    # about 5 minutes as the teststring grows exponentially.
-    # Worse, since 9x/ME are not pre-emptively multitasking,
-    # you end up with a "frozen" computer, even though with patience
-    # the test eventually succeeds (with a max line length of 256k).
-    # Instead, let's just punt: use the minimum linelength reported by
-    # all of the supported platforms: 8192 (on NT/2K/XP).
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
 
-  mint*)
-    # On MiNT this can take a long time and run out of memory.
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
+         # Normally we expect to be able to define preprocessor macros
+         # with -D, but this might be IBM xlf compiler, which needs
+         # -WF,-D or Fujitsu VPP700 which needs -Wp,-D
+         mv conftest.$acx_sl_fpp_srcext conftest.${acx_sl_fpp_srcext}.bak
+         for FPP_DEFOPT in "$FPP_DEFOPT" '-D' '-WF,-D' '-Wp,-D'
+         do
+           if test x"$FPP_DEFOPT" != x ; then :
+  cp conftest.${acx_sl_fpp_srcext}.bak conftest.$acx_sl_fpp_srcext
+              { { echo Running preprocessor $FPP $FPPFLAGS ${FPP_DEFOPT}OK conftest.$acx_sl_fpp_srcext; } >&5
+  ($FPP $FPPFLAGS ${FPP_DEFOPT}OK conftest.$acx_sl_fpp_srcext \
+        >conftest.${ac_ext}.tmp) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
 
-  amigaos*)
-    # On AmigaOS with pdksh, this test takes hours, literally.
-    # So we just punt and use a minimum line length of 8192.
-    lt_cv_sys_max_cmd_len=8192;
-    ;;
+   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
+   if ac_fn_fc_try_compile "$LINENO"; then :
+  acx_sl_prog_fc_cpp_d=yes; break
+fi
+rm -f core conftest.err conftest.$ac_objext
+fi
+         done
+         FCFLAGS=$ac_save_FCFLAGS
+         if test $acx_sl_prog_fc_cpp_d = no; then :
+  acx_sl_cv_fc_indirect_ok=no
+fi
+         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
+else
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
+fi
 
-  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
-    # This has been around since 386BSD, at least.  Likely further.
-    if test -x /sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
-    elif test -x /usr/sbin/sysctl; then
-      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
-    else
-      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
-    fi
-    # And add a safety zone
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    ;;
+fi
 
-  interix*)
-    # We know the value 262144 and hardcode it with a safety zone (like BSD)
-    lt_cv_sys_max_cmd_len=196608
-    ;;
+      if test $ac_fpp_need_i = yes; then :
+  acx_sl_prog_fc_cpp_i=no
+         $as_echo "$as_me:${as_lineno-$LINENO}: Trying flag to add directories to preprocessor search path." >&5
+         as_dir=conftst; as_fn_mkdir_p
+         cd conftst
 
-  os2*)
-    # The test takes a long time on OS/2.
-    lt_cv_sys_max_cmd_len=8192
-    ;;
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
-  osf*)
-    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
-    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
-    # nice to cause kernel panics so lets avoid the loop below.
-    # First set a reasonable default.
-    lt_cv_sys_max_cmd_len=16384
-    #
-    if test -x /sbin/sysconfig; then
-      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
-        *1*) lt_cv_sys_max_cmd_len=-1 ;;
-      esac
-    fi
-    ;;
-  sco3.2v5*)
-    lt_cv_sys_max_cmd_len=102400
-    ;;
-  sysv5* | sco5v6* | sysv4.2uw2*)
-    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
-    if test -n "$kargmax"; then
-      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[	 ]//'`
-    else
-      lt_cv_sys_max_cmd_len=32768
-    fi
-    ;;
-  *)
-    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
-    if test -n "$lt_cv_sys_max_cmd_len"; then
-      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
-      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
-    else
-      # Make teststring a little bigger before we do anything with it.
-      # a 1K string should be a reasonable start.
-      for i in 1 2 3 4 5 6 7 8 ; do
-        teststring=$teststring$teststring
-      done
-      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
-      # If test is not a shell built-in, we'll probably end up computing a
-      # maximum length that is only half of the actual maximum length, but
-      # we can't tell.
-      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
-	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
-	      test $i != 17 # 1/2 MB should be enough
-      do
-        i=`expr $i + 1`
-        teststring=$teststring$teststring
-      done
-      # Only check the string length outside the loop.
-      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
-      teststring=
-      # Add a significant safety factor because C++ compilers can tack on
-      # massive amounts of additional arguments before passing them to the
-      # linker.  It appears as though 1/2 is a usable value.
-      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
-    fi
-    ;;
-  esac
+   ac_ext="inc"
+   cat > conftest.$ac_ext <<_ACEOF
+       !     This statement overrides the IMPLICIT statement in the program
+      REAL cc
+_ACEOF
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
-fi
 
-if test -n $lt_cv_sys_max_cmd_len ; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
-$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
-$as_echo "none" >&6; }
-fi
-max_cmd_len=$lt_cv_sys_max_cmd_len
 
+         cd ..
 
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
+   ac_ext="$acx_sl_fpp_srcext"
+   cat > conftest.$ac_ext <<_ACEOF
+      program conftest
+      IMPLICIT CHARACTER (c)
+       !     Comments in test programs should be freeform compliant just in case.
+       !     conftest.inc contains the Fortran statement "REAL cc"
+#include "conftest.inc"
+      cc=1.
+      end
+_ACEOF
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
 
 
-: ${CP="cp -f"}
-: ${MV="mv -f"}
-: ${RM="rm -f"}
+         mv conftest.$acx_sl_fpp_srcext conftest.${acx_sl_fpp_srcext}.bak
+         for FPP_INCOPT in "$FPP_INCOPT" '-I' '-WF,-I' '-Wp,-I'
+         do
+           if test x"$FPP_INCOPT" != x ; then :
+  cp conftest.${acx_sl_fpp_srcext}.bak conftest.$acx_sl_fpp_srcext
+              { { echo Running preprocessor $FPP $FPPFLAGS ${FPP_INCOPT}conftst conftest.$acx_sl_fpp_srcext; } >&5
+  ($FPP $FPPFLAGS ${FPP_INCOPT}conftst conftest.$acx_sl_fpp_srcext \
+        >conftest.${ac_ext}.tmp) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
-$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
-# Try some XSI features
-xsi_shell=no
-( _lt_dummy="a/b/c"
-  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
-      = c,a/b,b/c, \
-    && eval 'test $(( 1 + 1 )) -eq 2 \
-    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
-  && xsi_shell=yes
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
-$as_echo "$xsi_shell" >&6; }
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
-$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
-lt_shell_append=no
-( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
-    >/dev/null 2>&1 \
-  && lt_shell_append=yes
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
-$as_echo "$lt_shell_append" >&6; }
-
-
-if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
-  lt_unset=unset
+   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
+   if ac_fn_fc_try_compile "$LINENO"; then :
+  acx_sl_prog_fc_cpp_i=yes
+                 break
+fi
+rm -f core conftest.err conftest.$ac_objext
+fi
+         done
+         FCFLAGS=$ac_save_FCFLAGS
+         rm -rf conftst
+         if test $acx_sl_prog_fc_cpp_i = no; then :
+  acx_sl_cv_fc_indirect_ok=no
+fi
+         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
 else
-  lt_unset=false
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
 fi
+fi
+      if test $ac_fpp_need_subs = yes; then :
+  acx_sl_prog_fc_cpp_subs=no
+         $as_echo "$as_me:${as_lineno-$LINENO}: Testing preprocessor expansion in Fortran code." >&5
 
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
+   ac_ext="$acx_sl_fpp_srcext"
+   cat > conftest.$ac_ext <<_ACEOF
+      program conftest
+#define NM xxxx
+      IMPLICIT CHARACTER (n)
+      REAL xxxx
+      NM=1.
+      end
+_ACEOF
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
 
 
-# test EBCDIC or ASCII
-case `echo X|tr X '\101'` in
- A) # ASCII based system
-    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
-  lt_SP2NL='tr \040 \012'
-  lt_NL2SP='tr \015\012 \040\040'
-  ;;
- *) # EBCDIC based system
-  lt_SP2NL='tr \100 \n'
-  lt_NL2SP='tr \r\n \100\100'
-  ;;
-esac
-
+         { { echo Running preprocessor $FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext; } >&5
+  ($FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext \
+        >conftest.${ac_ext}.tmp) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
 
+   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
+   if ac_fn_fc_try_compile "$LINENO"; then :
+  acx_sl_prog_fc_cpp_subs=yes
+else
+  acx_sl_cv_fc_indirect_ok=no
+fi
+rm -f core conftest.err conftest.$ac_objext
+         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
+else
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
+fi
 
+fi
+      if test $ac_fpp_need_wrap = yes; then :
+  acx_sl_prog_fc_cpp_wrap=no
+         $as_echo "$as_me:${as_lineno-$LINENO}: Testing wether preprocessor wraps long lines." >&5
 
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
+   ac_ext="$acx_sl_fpp_srcext"
+   cat > conftest.$ac_ext <<_ACEOF
+      program conftest
+#define LONG '901234567890123456789012345678901234567890123456789012345678901234567890'
+      CHARACTER(LEN=80) :: A
+      A=LONG
+      end
+_ACEOF
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
 
 
+         { { echo Running preprocessor $FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext; } >&5
+  ($FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext \
+        >conftest.${ac_ext}.tmp) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5
-$as_echo_n "checking how to convert $build file names to $host format... " >&6; }
-if ${lt_cv_to_host_file_cmd+:} false; then :
-  $as_echo_n "(cached) " >&6
+   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
+   if ac_fn_fc_try_compile "$LINENO"; then :
+  acx_sl_prog_fc_cpp_wrap=yes
 else
-  case $host in
-  *-*-mingw* )
-    case $build in
-      *-*-mingw* ) # actually msys
-        lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
-        ;;
-      *-*-cygwin* )
-        lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
-        ;;
-      * ) # otherwise, assume *nix
-        lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
-        ;;
-    esac
-    ;;
-  *-*-cygwin* )
-    case $build in
-      *-*-mingw* ) # actually msys
-        lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
-        ;;
-      *-*-cygwin* )
-        lt_cv_to_host_file_cmd=func_convert_file_noop
-        ;;
-      * ) # otherwise, assume *nix
-        lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
-        ;;
-    esac
-    ;;
-  * ) # unhandled hosts (and "normal" native builds)
-    lt_cv_to_host_file_cmd=func_convert_file_noop
-    ;;
-esac
+  acx_sl_cv_fc_indirect_ok=no
+fi
+rm -f core conftest.err conftest.$ac_objext
+         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
+else
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
+fi
 
 fi
+      if test $ac_fpp_need_CSTYLE = yes; then :
+  $as_echo "$as_me:${as_lineno-$LINENO}: Testing wether preprocessor removes C-style comments." >&5
 
-to_host_file_cmd=$lt_cv_to_host_file_cmd
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5
-$as_echo "$lt_cv_to_host_file_cmd" >&6; }
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
+   ac_ext="$acx_sl_fpp_srcext"
+   cat > conftest.$ac_ext <<_ACEOF
+      program conftest
+      A=1. /* C-style comment */
+      end
+_ACEOF
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
 
 
+         { { echo Running preprocessor $FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext; } >&5
+  ($FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext \
+        >conftest.${ac_ext}.tmp) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5
-$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; }
-if ${lt_cv_to_tool_file_cmd+:} false; then :
-  $as_echo_n "(cached) " >&6
+   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
+   if ac_fn_fc_try_compile "$LINENO"; then :
+  acx_sl_prog_fc_cpp_CSTYLE=yes
 else
-  #assume ordinary cross tools, or native build.
-lt_cv_to_tool_file_cmd=func_convert_file_noop
-case $host in
-  *-*-mingw* )
-    case $build in
-      *-*-mingw* ) # actually msys
-        lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
-        ;;
-    esac
-    ;;
-esac
+  acx_sl_cv_fc_indirect_ok=no
+fi
+rm -f core conftest.err conftest.$ac_objext
+         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
+else
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
+fi
 
 fi
+      if test $ac_fpp_need_cstyle = yes; then :
+  $as_echo "$as_me:${as_lineno-$LINENO}: Testing wether preprocessor leaves C-style comments in place." >&5
 
-to_tool_file_cmd=$lt_cv_to_tool_file_cmd
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5
-$as_echo "$lt_cv_to_tool_file_cmd" >&6; }
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
+   ac_ext="$acx_sl_fpp_srcext"
+   cat > conftest.$ac_ext <<_ACEOF
+      program conftest
+      A=1. /* C-style comment */
+      end
+_ACEOF
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
 
 
+         { { echo Running preprocessor $FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext; } >&5
+  ($FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext \
+        >conftest.${ac_ext}.tmp) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
-$as_echo_n "checking for $LD option to reload object files... " >&6; }
-if ${lt_cv_ld_reload_flag+:} false; then :
-  $as_echo_n "(cached) " >&6
+   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
+   if ac_fn_fc_try_compile "$LINENO"; then :
+  acx_sl_prog_fc_cpp_CSTYLE=yes
 else
-  lt_cv_ld_reload_flag='-r'
+  acx_sl_cv_fc_indirect_ok=no
+fi
+rm -f core conftest.err conftest.$ac_objext
+         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
+else
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
+fi
+
+fi
+      if test $ac_fpp_need_cxxstyle = yes; then :
+  $as_echo "$as_me:${as_lineno-$LINENO}: Testing if preprocessor leaves C++-style comments in place." >&5
+
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+
+   ac_ext="$acx_sl_fpp_srcext"
+   cat > conftest.$ac_ext <<_ACEOF
+      PROGRAM MAIN
+      CHARACTER(LEN=10) :: C
+      C = "abcde" // "fghij"; END PROGRAM
+_ACEOF
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+
+
+
+         { { echo Running preprocessor $FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext; } >&5
+  ($FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext \
+        >conftest.${ac_ext}.tmp) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+
+   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
+   if ac_fn_fc_try_compile "$LINENO"; then :
+  acx_sl_prog_fc_cpp_cxxstyle=yes
+else
+  acx_sl_cv_fc_indirect_ok=no
+fi
+rm -f core conftest.err conftest.$ac_objext
+         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
+else
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
+fi
+
+fi
+      if test $ac_fpp_need_CXXSTYLE = yes; then :
+  $as_echo "$as_me:${as_lineno-$LINENO}: Testing if preprocessor suppresses C++-style comments." >&5
+
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+
+   ac_ext="$acx_sl_fpp_srcext"
+   cat > conftest.$ac_ext <<_ACEOF
+      PROGRAM MAIN
+      CHARACTER(LEN=10) :: C
+      C = "abcde" // "fghij"; END PROGRAM
+_ACEOF
+   ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+
+
+
+         { { echo Running preprocessor $FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext; } >&5
+  ($FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext \
+        >conftest.${ac_ext}.tmp) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+
+   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
+   if ac_fn_fc_try_compile "$LINENO"; then :
+  acx_sl_prog_fc_cpp_cxxstyle=yes
+else
+  acx_sl_cv_fc_indirect_ok=no
+fi
+rm -f core conftest.err conftest.$ac_objext
+         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
+else
+  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
-$as_echo "$lt_cv_ld_reload_flag" >&6; }
-reload_flag=$lt_cv_ld_reload_flag
-case $reload_flag in
-"" | " "*) ;;
-*) reload_flag=" $reload_flag" ;;
-esac
-reload_cmds='$LD$reload_flag -o $output$reload_objs'
-case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
-    if test "$GCC" != yes; then
-      reload_cmds=false
-    fi
-    ;;
-  darwin*)
-    if test "$GCC" = yes; then
-      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
-    else
-      reload_cmds='$LD$reload_flag -o $output$reload_objs'
-    fi
-    ;;
-esac
 
+fi
+      FCFLAGS=$ac_save_FCFLAGS
+      rm -f conftest.*
+      if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
 
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "required Fortran preprocessor not available
+See \`config.log' for more details" "$LINENO" 5; }
+fi
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_sl_cv_fc_indirect_ok" >&5
+$as_echo "$acx_sl_cv_fc_indirect_ok" >&6; }
+   #FIXME we should probably do the AC_SUBST somewhere else.
 
 
 
 
 
+   ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+fi
+ac_ext=f
+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_f77_compiler_gnu
 if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
-set dummy ${ac_tool_prefix}objdump; ac_word=$2
+  for ac_prog in g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 xlf90 f90 pgf90 pghpf epcf90 gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OBJDUMP+:} false; then :
+if ${ac_cv_prog_F77+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$OBJDUMP"; then
-  ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
+  if test -n "$F77"; then
+  ac_cv_prog_F77="$F77" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -5667,7 +6029,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
+    ac_cv_prog_F77="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -5677,28 +6039,32 @@ IFS=$as_save_IFS
 
 fi
 fi
-OBJDUMP=$ac_cv_prog_OBJDUMP
-if test -n "$OBJDUMP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
-$as_echo "$OBJDUMP" >&6; }
+F77=$ac_cv_prog_F77
+if test -n "$F77"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $F77" >&5
+$as_echo "$F77" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
+    test -n "$F77" && break
+  done
 fi
-if test -z "$ac_cv_prog_OBJDUMP"; then
-  ac_ct_OBJDUMP=$OBJDUMP
-  # Extract the first word of "objdump", so it can be a program name with args.
-set dummy objdump; ac_word=$2
+if test -z "$F77"; then
+  ac_ct_F77=$F77
+  for ac_prog in g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 xlf90 f90 pgf90 pghpf epcf90 gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
+if ${ac_cv_prog_ac_ct_F77+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$ac_ct_OBJDUMP"; then
-  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
+  if test -n "$ac_ct_F77"; then
+  ac_cv_prog_ac_ct_F77="$ac_ct_F77" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -5707,7 +6073,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_OBJDUMP="objdump"
+    ac_cv_prog_ac_ct_F77="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -5717,17 +6083,21 @@ IFS=$as_save_IFS
 
 fi
 fi
-ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
-if test -n "$ac_ct_OBJDUMP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
-$as_echo "$ac_ct_OBJDUMP" >&6; }
+ac_ct_F77=$ac_cv_prog_ac_ct_F77
+if test -n "$ac_ct_F77"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_F77" >&5
+$as_echo "$ac_ct_F77" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
-  if test "x$ac_ct_OBJDUMP" = x; then
-    OBJDUMP="false"
+
+  test -n "$ac_ct_F77" && break
+done
+
+  if test "x$ac_ct_F77" = x; then
+    F77=""
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
@@ -5735,572 +6105,690 @@ yes:)
 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
-    OBJDUMP=$ac_ct_OBJDUMP
+    F77=$ac_ct_F77
   fi
-else
-  OBJDUMP="$ac_cv_prog_OBJDUMP"
 fi
 
-test -z "$OBJDUMP" && OBJDUMP=objdump
-
-
-
-
-
 
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran 77 compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+rm -f a.out
 
+# If we don't use `.F' as extension, the preprocessor is not run on the
+# input file.  (Note that this only needs to work for GNU compilers.)
+ac_save_ext=$ac_ext
+ac_ext=F
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Fortran 77 compiler" >&5
+$as_echo_n "checking whether we are using the GNU Fortran 77 compiler... " >&6; }
+if ${ac_cv_f77_compiler_gnu+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.$ac_ext <<_ACEOF
+      program main
+#ifndef __GNUC__
+       choke me
+#endif
 
+      end
+_ACEOF
+if ac_fn_f77_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_f77_compiler_gnu=$ac_compiler_gnu
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
-$as_echo_n "checking how to recognize dependent libraries... " >&6; }
-if ${lt_cv_deplibs_check_method+:} false; then :
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_f77_compiler_gnu" >&5
+$as_echo "$ac_cv_f77_compiler_gnu" >&6; }
+ac_ext=$ac_save_ext
+ac_test_FFLAGS=${FFLAGS+set}
+ac_save_FFLAGS=$FFLAGS
+FFLAGS=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $F77 accepts -g" >&5
+$as_echo_n "checking whether $F77 accepts -g... " >&6; }
+if ${ac_cv_prog_f77_g+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  lt_cv_file_magic_cmd='$MAGIC_CMD'
-lt_cv_file_magic_test_file=
-lt_cv_deplibs_check_method='unknown'
-# Need to set the preceding variable on all platforms that support
-# interlibrary dependencies.
-# 'none' -- dependencies not supported.
-# `unknown' -- same as none, but documents that we really don't know.
-# 'pass_all' -- all dependencies passed with no checks.
-# 'test_compile' -- check by making test program.
-# 'file_magic [[regex]]' -- check by looking for files in library path
-# which responds to the $file_magic_cmd with a given extended regex.
-# If you have `file' or equivalent on your system and you're not sure
-# whether `pass_all' will *always* work, you probably want this one.
-
-case $host_os in
-aix[4-9]*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-beos*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-bsdi[45]*)
-  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
-  lt_cv_file_magic_cmd='/usr/bin/file -L'
-  lt_cv_file_magic_test_file=/shlib/libc.so
-  ;;
+  FFLAGS=-g
+cat > conftest.$ac_ext <<_ACEOF
+      program main
 
-cygwin*)
-  # func_win32_libid is a shell function defined in ltmain.sh
-  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
-  lt_cv_file_magic_cmd='func_win32_libid'
-  ;;
+      end
+_ACEOF
+if ac_fn_f77_try_compile "$LINENO"; then :
+  ac_cv_prog_f77_g=yes
+else
+  ac_cv_prog_f77_g=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-mingw* | pw32*)
-  # Base MSYS/MinGW do not provide the 'file' command needed by
-  # func_win32_libid shell function, so use a weaker test based on 'objdump',
-  # unless we find 'file', for example because we are cross-compiling.
-  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
-  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
-    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
-    lt_cv_file_magic_cmd='func_win32_libid'
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_f77_g" >&5
+$as_echo "$ac_cv_prog_f77_g" >&6; }
+if test "$ac_test_FFLAGS" = set; then
+  FFLAGS=$ac_save_FFLAGS
+elif test $ac_cv_prog_f77_g = yes; then
+  if test "x$ac_cv_f77_compiler_gnu" = xyes; then
+    FFLAGS="-g -O2"
   else
-    # Keep this pattern in sync with the one in func_win32_libid.
-    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
-    lt_cv_file_magic_cmd='$OBJDUMP -f'
+    FFLAGS="-g"
   fi
-  ;;
-
-cegcc*)
-  # use the weaker test based on 'objdump'. See mingw*.
-  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
-  lt_cv_file_magic_cmd='$OBJDUMP -f'
-  ;;
+else
+  if test "x$ac_cv_f77_compiler_gnu" = xyes; then
+    FFLAGS="-O2"
+  else
+    FFLAGS=
+  fi
+fi
 
-darwin* | rhapsody*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+if test $ac_compiler_gnu = yes; then
+  G77=yes
+else
+  G77=
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-freebsd* | dragonfly*)
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
-    case $host_cpu in
-    i*86 )
-      # Not sure whether the presence of OpenBSD here was a mistake.
-      # Let's accept both of them until this is cleared up.
-      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
-      lt_cv_file_magic_cmd=/usr/bin/file
-      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
-      ;;
-    esac
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+if test -z "$CXX"; then
+  if test -n "$CCC"; then
+    CXX=$CCC
   else
-    lt_cv_deplibs_check_method=pass_all
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CXX"; then
+  ac_cv_prog_CXX="$CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
   fi
-  ;;
+done
+  done
+IFS=$as_save_IFS
 
-gnu*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+fi
+fi
+CXX=$ac_cv_prog_CXX
+if test -n "$CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
+$as_echo "$CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
-haiku*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
 
-hpux10.20* | hpux11*)
-  lt_cv_file_magic_cmd=/usr/bin/file
-  case $host_cpu in
-  ia64*)
-    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
-    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
-    ;;
-  hppa*64*)
-    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'
-    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
-    ;;
-  *)
-    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library'
-    lt_cv_file_magic_test_file=/usr/lib/libc.sl
-    ;;
-  esac
-  ;;
+    test -n "$CXX" && break
+  done
+fi
+if test -z "$CXX"; then
+  ac_ct_CXX=$CXX
+  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CXX"; then
+  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CXX="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-interix[3-9]*)
-  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
-  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
-  ;;
+fi
+fi
+ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
+if test -n "$ac_ct_CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
+$as_echo "$ac_ct_CXX" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
-irix5* | irix6* | nonstopux*)
-  case $LD in
-  *-32|*"-32 ") libmagic=32-bit;;
-  *-n32|*"-n32 ") libmagic=N32;;
-  *-64|*"-64 ") libmagic=64-bit;;
-  *) libmagic=never-match;;
-  esac
-  lt_cv_deplibs_check_method=pass_all
-  ;;
 
-# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+  test -n "$ac_ct_CXX" && break
+done
 
-netbsd*)
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  if test "x$ac_ct_CXX" = x; then
+    CXX="g++"
   else
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CXX=$ac_ct_CXX
   fi
-  ;;
-
-newos6*)
-  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
-  lt_cv_file_magic_cmd=/usr/bin/file
-  lt_cv_file_magic_test_file=/usr/lib/libnls.so
-  ;;
-
-*nto* | *qnx*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+fi
 
-openbsd*)
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
-  else
-    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
   fi
-  ;;
-
-osf3* | osf4* | osf5*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-rdos*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-solaris*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
+fi
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
 
-sysv4 | sysv4.3*)
-  case $host_vendor in
-  motorola)
-    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
-    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
-    ;;
-  ncr)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  sequent)
-    lt_cv_file_magic_cmd='/bin/file'
-    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
-    ;;
-  sni)
-    lt_cv_file_magic_cmd='/bin/file'
-    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
-    lt_cv_file_magic_test_file=/lib/libc.so
-    ;;
-  siemens)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  pc)
-    lt_cv_deplibs_check_method=pass_all
-    ;;
-  esac
-  ;;
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
+$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
+if ${ac_cv_cxx_compiler_gnu+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-tpf*)
-  lt_cv_deplibs_check_method=pass_all
-  ;;
-esac
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
-$as_echo "$lt_cv_deplibs_check_method" >&6; }
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
 
-file_magic_glob=
-want_nocaseglob=no
-if test "$build" = "$host"; then
-  case $host_os in
-  mingw* | pw32*)
-    if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
-      want_nocaseglob=yes
-    else
-      file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"`
-    fi
-    ;;
-  esac
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
+$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GXX=yes
+else
+  GXX=
+fi
+ac_test_CXXFLAGS=${CXXFLAGS+set}
+ac_save_CXXFLAGS=$CXXFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
+$as_echo_n "checking whether $CXX accepts -g... " >&6; }
+if ${ac_cv_prog_cxx_g+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
+   ac_cxx_werror_flag=yes
+   ac_cv_prog_cxx_g=no
+   CXXFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-file_magic_cmd=$lt_cv_file_magic_cmd
-deplibs_check_method=$lt_cv_deplibs_check_method
-test -z "$deplibs_check_method" && deplibs_check_method=unknown
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+int
+main ()
+{
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
+else
+  CXXFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+int
+main ()
+{
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
-set dummy ${ac_tool_prefix}dlltool; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_DLLTOOL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$DLLTOOL"; then
-  ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
 else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+  ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+	 CXXFLAGS="-g"
+	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_compile "$LINENO"; then :
+  ac_cv_prog_cxx_g=yes
 fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 fi
-DLLTOOL=$ac_cv_prog_DLLTOOL
-if test -n "$DLLTOOL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
-$as_echo "$DLLTOOL" >&6; }
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
+$as_echo "$ac_cv_prog_cxx_g" >&6; }
+if test "$ac_test_CXXFLAGS" = set; then
+  CXXFLAGS=$ac_save_CXXFLAGS
+elif test $ac_cv_prog_cxx_g = yes; then
+  if test "$GXX" = yes; then
+    CXXFLAGS="-g -O2"
+  else
+    CXXFLAGS="-g"
+  fi
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  if test "$GXX" = yes; then
+    CXXFLAGS="-O2"
+  else
+    CXXFLAGS=
+  fi
 fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+depcc="$CXX"  am_compiler_list=
 
-fi
-if test -z "$ac_cv_prog_DLLTOOL"; then
-  ac_ct_DLLTOOL=$DLLTOOL
-  # Extract the first word of "dlltool", so it can be a program name with args.
-set dummy dlltool; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_DLLTOOL"; then
-  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if ${am_cv_CXX_dependencies_compiler_type+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_DLLTOOL="dlltool"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named 'D' -- because '-MD' means "put the output
+  # in D".
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CXX_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
   fi
-done
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
+      # Solaris 10 /bin/sh.
+      echo '/* dummy */' > sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with '-c' and '-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle '-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs.
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # After this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested.
+      if test "x$enable_dependency_tracking" = xyes; then
+	continue
+      else
+	break
+      fi
+      ;;
+    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
+      # This compiler won't grok '-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CXX_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
   done
-IFS=$as_save_IFS
 
-fi
-fi
-ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
-if test -n "$ac_ct_DLLTOOL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
-$as_echo "$ac_ct_DLLTOOL" >&6; }
+  cd ..
+  rm -rf conftest.dir
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  am_cv_CXX_dependencies_compiler_type=none
 fi
 
-  if test "x$ac_ct_DLLTOOL" = x; then
-    DLLTOOL="false"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    DLLTOOL=$ac_ct_DLLTOOL
-  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
+CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
+  am__fastdepCXX_TRUE=
+  am__fastdepCXX_FALSE='#'
 else
-  DLLTOOL="$ac_cv_prog_DLLTOOL"
+  am__fastdepCXX_TRUE='#'
+  am__fastdepCXX_FALSE=
 fi
 
-test -z "$DLLTOOL" && DLLTOOL=dlltool
 
 
 
+# Set up libtool.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: setting up libtool" >&5
+$as_echo "$as_me: setting up libtool" >&6;}
+if test x"$enable_shared" != xno; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking any compiler has problems building shared objects" >&5
+$as_echo_n "checking any compiler has problems building shared objects... " >&6; }
+if ${acx_cv_disable_shared+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  acx_cv_disable_shared=no
+         ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
 
+   acx_Comp=$FC
+   $as_echo "$as_me:${as_lineno-$LINENO}: testing if $acx_Comp cannot build working shared objects" >&5
+   case $host in #(
+  *-ibm-aix*) :
+    if $acx_Comp -G -v 2>&1 | grep ' -binitfini:poe_remote_main ' >/dev/null; then :
+  acx_cv_disable_shared=yes
+fi ;; #(
+  x86_64-*-linux-*|i*86-*-linux-*|*-apple-darwin*|ia64-*-linux-*|x86_64-*-freebsd*|i*86-*-freebsd*) :
+    if $acx_Comp -V 2>&1 | grep '^Intel(R).*Fortran.*Compiler.*Version 15.0.[123]' >/dev/null; then :
+  acx_cv_disable_shared=yes
+fi ;; #(
+  *) :
+     ;;
+esac
+   $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_disable_shared" >&5
+            ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+         ac_ext=f
+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_f77_compiler_gnu
 
 
+   acx_Comp=$F77
+   $as_echo "$as_me:${as_lineno-$LINENO}: testing if $acx_Comp cannot build working shared objects" >&5
+   case $host in #(
+  *-ibm-aix*) :
+    if $acx_Comp -G -v 2>&1 | grep ' -binitfini:poe_remote_main ' >/dev/null; then :
+  acx_cv_disable_shared=yes
+fi ;; #(
+  x86_64-*-linux-*|i*86-*-linux-*|*-apple-darwin*|ia64-*-linux-*|x86_64-*-freebsd*|i*86-*-freebsd*) :
+    if $acx_Comp -V 2>&1 | grep '^Intel(R).*Fortran.*Compiler.*Version 15.0.[123]' >/dev/null; then :
+  acx_cv_disable_shared=yes
+fi ;; #(
+  *) :
+     ;;
+esac
+   $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_disable_shared" >&5
+            ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+         ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5
-$as_echo_n "checking how to associate runtime and link libraries... " >&6; }
-if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_sharedlib_from_linklib_cmd='unknown'
 
-case $host_os in
-cygwin* | mingw* | pw32* | cegcc*)
-  # two different shell functions defined in ltmain.sh
-  # decide which to use based on capabilities of $DLLTOOL
-  case `$DLLTOOL --help 2>&1` in
-  *--identify-strict*)
-    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
-    ;;
-  *)
-    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
-    ;;
-  esac
-  ;;
-*)
-  # fallback: assume linklib IS sharedlib
-  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
-  ;;
+   acx_Comp=$CC
+   $as_echo "$as_me:${as_lineno-$LINENO}: testing if $acx_Comp cannot build working shared objects" >&5
+   case $host in #(
+  *-ibm-aix*) :
+    if $acx_Comp -G -v 2>&1 | grep ' -binitfini:poe_remote_main ' >/dev/null; then :
+  acx_cv_disable_shared=yes
+fi ;; #(
+  x86_64-*-linux-*|i*86-*-linux-*|*-apple-darwin*|ia64-*-linux-*|x86_64-*-freebsd*|i*86-*-freebsd*) :
+    if $acx_Comp -V 2>&1 | grep '^Intel(R).*Fortran.*Compiler.*Version 15.0.[123]' >/dev/null; then :
+  acx_cv_disable_shared=yes
+fi ;; #(
+  *) :
+     ;;
 esac
+   $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_disable_shared" >&5
+            ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5
-$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; }
-sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
-test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_disable_shared" >&5
+$as_echo "$acx_cv_disable_shared" >&6; }
+       if test x"$acx_cv_disable_shared" = xyes; then :
+  enable_shared=no
+fi
+fi
+case `pwd` in
+  *\ * | *\	*)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5
+$as_echo "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;
+esac
 
 
 
+macro_version='2.4.2'
+macro_revision='1.3337'
 
 
 
 
 
-if test -n "$ac_tool_prefix"; then
-  for ac_prog in ar
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_AR+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$AR"; then
-  ac_cv_prog_AR="$AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-AR=$ac_cv_prog_AR
-if test -n "$AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
-$as_echo "$AR" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
 
 
-    test -n "$AR" && break
-  done
-fi
-if test -z "$AR"; then
-  ac_ct_AR=$AR
-  for ac_prog in ar
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_AR+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_AR"; then
-  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_AR="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-ac_ct_AR=$ac_cv_prog_ac_ct_AR
-if test -n "$ac_ct_AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
-$as_echo "$ac_ct_AR" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
 
 
-  test -n "$ac_ct_AR" && break
-done
 
-  if test "x$ac_ct_AR" = x; then
-    AR="false"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    AR=$ac_ct_AR
-  fi
-fi
 
-: ${AR=ar}
-: ${AR_FLAGS=cru}
+ltmain="$ac_aux_dir/ltmain.sh"
 
+# Backslashify metacharacters that are still active within
+# double-quoted strings.
+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
 
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\(["`\\]\)/\\\1/g'
 
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
 
+# Sed substitution to delay expansion of an escaped single quote.
+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'
 
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
 
+ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO
+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5
+$as_echo_n "checking how to print strings... " >&6; }
+# Test print first, because it will be a builtin if present.
+if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \
+   test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='print -r --'
+elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then
+  ECHO='printf %s\n'
+else
+  # Use this function as a fallback that always works.
+  func_fallback_echo ()
+  {
+    eval 'cat <<_LTECHO_EOF
+$1
+_LTECHO_EOF'
+  }
+  ECHO='func_fallback_echo'
+fi
 
+# func_echo_all arg...
+# Invoke $ECHO with all args, space-separated.
+func_echo_all ()
+{
+    $ECHO ""
+}
 
+case "$ECHO" in
+  printf*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: printf" >&5
+$as_echo "printf" >&6; } ;;
+  print*) { $as_echo "$as_me:${as_lineno-$LINENO}: result: print -r" >&5
+$as_echo "print -r" >&6; } ;;
+  *) { $as_echo "$as_me:${as_lineno-$LINENO}: result: cat" >&5
+$as_echo "cat" >&6; } ;;
+esac
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5
-$as_echo_n "checking for archiver @FILE support... " >&6; }
-if ${lt_cv_ar_at_file+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_ar_at_file=no
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-int
-main ()
-{
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  echo conftest.$ac_objext > conftest.lst
-      lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5'
-      { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
-  (eval $lt_ar_try) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-      if test "$ac_status" -eq 0; then
-	# Ensure the archiver fails upon bogus file names.
-	rm -f conftest.$ac_objext libconftest.a
-	{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
-  (eval $lt_ar_try) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-	if test "$ac_status" -ne 0; then
-          lt_cv_ar_at_file=@
-        fi
-      fi
-      rm -f conftest.* libconftest.a
 
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
-$as_echo "$lt_cv_ar_at_file" >&6; }
 
-if test "x$lt_cv_ar_at_file" = xno; then
-  archiver_list_spec=
-else
-  archiver_list_spec=$lt_cv_ar_at_file
-fi
 
 
 
@@ -6308,250 +6796,286 @@ fi
 
 
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
-set dummy ${ac_tool_prefix}strip; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_STRIP+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+$as_echo_n "checking for a sed that does not truncate output... " >&6; }
+if ${ac_cv_path_SED+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$STRIP"; then
-  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+            ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
+     for ac_i in 1 2 3 4 5 6 7; do
+       ac_script="$ac_script$as_nl$ac_script"
+     done
+     echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed
+     { ac_script=; unset ac_script;}
+     if test -z "$SED"; then
+  ac_path_SED_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
+    for ac_prog in sed gsed; do
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
+      ac_path_SED="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_SED" && $as_test_x "$ac_path_SED"; } || continue
+# Check for GNU ac_path_SED and select it if it is found.
+  # Check for GNU $ac_path_SED
+case `"$ac_path_SED" --version 2>&1` in
+*GNU*)
+  ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo '' >> "conftest.nl"
+    "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_SED_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_SED="$ac_path_SED"
+      ac_path_SED_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
   done
-IFS=$as_save_IFS
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
 
-fi
-fi
-STRIP=$ac_cv_prog_STRIP
-if test -n "$STRIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
-$as_echo "$STRIP" >&6; }
+      $ac_path_SED_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_SED"; then
+    as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5
+  fi
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  ac_cv_path_SED=$SED
 fi
 
-
 fi
-if test -z "$ac_cv_prog_STRIP"; then
-  ac_ct_STRIP=$STRIP
-  # Extract the first word of "strip", so it can be a program name with args.
-set dummy strip; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_STRIP"; then
-  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_STRIP="strip"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5
+$as_echo "$ac_cv_path_SED" >&6; }
+ SED="$ac_cv_path_SED"
+  rm -f conftest.sed
 
-fi
-fi
-ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
-if test -n "$ac_ct_STRIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
-$as_echo "$ac_ct_STRIP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+test -z "$SED" && SED=sed
+Xsed="$SED -e 1s/^X//"
 
-  if test "x$ac_ct_STRIP" = x; then
-    STRIP=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    STRIP=$ac_ct_STRIP
-  fi
-else
-  STRIP="$ac_cv_prog_STRIP"
-fi
 
-test -z "$STRIP" && STRIP=:
 
 
 
 
 
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_RANLIB+:} false; then :
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if ${ac_cv_path_GREP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$RANLIB"; then
-  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
+    for ac_prog in grep ggrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
   done
-IFS=$as_save_IFS
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
 
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
-$as_echo "$RANLIB" >&6; }
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  ac_cv_path_GREP=$GREP
 fi
 
-
 fi
-if test -z "$ac_cv_prog_RANLIB"; then
-  ac_ct_RANLIB=$RANLIB
-  # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if ${ac_cv_path_EGREP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$ac_ct_RANLIB"; then
-  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
 do
   IFS=$as_save_IFS
   test -z "$as_dir" && as_dir=.
+    for ac_prog in egrep; do
     for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_RANLIB="ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
   done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
-$as_echo "$ac_ct_RANLIB" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-  if test "x$ac_ct_RANLIB" = x; then
-    RANLIB=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
 esac
-    RANLIB=$ac_ct_RANLIB
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
   fi
 else
-  RANLIB="$ac_cv_prog_RANLIB"
+  ac_cv_path_EGREP=$EGREP
 fi
 
-test -z "$RANLIB" && RANLIB=:
-
-
-
-
-
-
-# Determine commands to create old-style static archives.
-old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
-old_postinstall_cmds='chmod 644 $oldlib'
-old_postuninstall_cmds=
-
-if test -n "$RANLIB"; then
-  case $host_os in
-  openbsd*)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
-    ;;
-  *)
-    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
-    ;;
-  esac
-  old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
+   fi
 fi
-
-case $host_os in
-  darwin*)
-    lock_old_archive_extraction=yes ;;
-  *)
-    lock_old_archive_extraction=no ;;
-esac
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5
+$as_echo_n "checking for fgrep... " >&6; }
+if ${ac_cv_path_FGREP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1
+   then ac_cv_path_FGREP="$GREP -F"
+   else
+     if test -z "$FGREP"; then
+  ac_path_FGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in fgrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_FGREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_FGREP" && $as_test_x "$ac_path_FGREP"; } || continue
+# Check for GNU ac_path_FGREP and select it if it is found.
+  # Check for GNU $ac_path_FGREP
+case `"$ac_path_FGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'FGREP' >> "conftest.nl"
+    "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_FGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_FGREP="$ac_path_FGREP"
+      ac_path_FGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
 
+      $ac_path_FGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_FGREP"; then
+    as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_FGREP=$FGREP
+fi
 
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5
+$as_echo "$ac_cv_path_FGREP" >&6; }
+ FGREP="$ac_cv_path_FGREP"
 
 
+test -z "$GREP" && GREP=grep
 
 
 
@@ -6568,664 +7092,658 @@ esac
 
 
 
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
 
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
 
-# Allow CC to be a program name with arguments.
-compiler=$CC
 
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
 
-# Check for command to grab the raw symbol name followed by C symbol from nm.
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
-$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
-if ${lt_cv_sys_global_symbol_pipe+:} false; then :
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | ?:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if ${lt_cv_path_LD+:} false; then :
   $as_echo_n "(cached) " >&6
 else
+  if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+	test "$with_gnu_ld" != no && break
+	;;
+      *)
+	test "$with_gnu_ld" != yes && break
+	;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
 
-# These are sane defaults that work on at least a few old systems.
-# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
-
-# Character class describing NM global symbol codes.
-symcode='[BCDEGRST]'
-
-# Regexp to match symbols that can be accessed directly from C.
-sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
-
-# Define system-specific variables.
-case $host_os in
-aix*)
-  symcode='[BCDT]'
-  ;;
-cygwin* | mingw* | pw32* | cegcc*)
-  symcode='[ABCDGISTW]'
-  ;;
-hpux*)
-  if test "$host_cpu" = ia64; then
-    symcode='[ABCDEGRST]'
-  fi
-  ;;
-irix* | nonstopux*)
-  symcode='[BCDEGRST]'
-  ;;
-osf*)
-  symcode='[BCDEGQRST]'
-  ;;
-solaris*)
-  symcode='[BDRT]'
-  ;;
-sco3.2v5*)
-  symcode='[DT]'
-  ;;
-sysv4.2uw2*)
-  symcode='[DT]'
-  ;;
-sysv5* | sco5v6* | unixware* | OpenUNIX*)
-  symcode='[ABDT]'
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if ${lt_cv_prog_gnu_ld+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
   ;;
-sysv4)
-  symcode='[DFNSTU]'
+*)
+  lt_cv_prog_gnu_ld=no
   ;;
 esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
 
-# If we're using GNU nm, then use its standard symbol codes.
-case `$NM -V 2>&1` in
-*GNU* | *'with BFD'*)
-  symcode='[ABCDGIRSTW]' ;;
-esac
 
-# Transform an extracted symbol line into a proper C declaration.
-# Some systems (esp. on ia64) link data and code symbols differently,
-# so use this general approach.
-lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
 
-# Transform an extracted symbol line into symbol name and symbol address
-lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (void *) \&\2},/p'"
-lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
 
-# Handle CRLF in mingw tool chain
-opt_cr=
-case $build_os in
-mingw*)
-  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
-  ;;
-esac
 
-# Try without a prefix underscore, then with it.
-for ac_symprfx in "" "_"; do
 
-  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
-  symxfrm="\\1 $ac_symprfx\\2 \\2"
 
-  # Write the raw and C identifiers.
-  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-    # Fake it for dumpbin and say T for any non-static function
-    # and D for any global variable.
-    # Also find C++ and __fastcall symbols from MSVC++,
-    # which start with @ or ?.
-    lt_cv_sys_global_symbol_pipe="$AWK '"\
-"     {last_section=section; section=\$ 3};"\
-"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
-"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
-"     \$ 0!~/External *\|/{next};"\
-"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
-"     {if(hide[section]) next};"\
-"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
-"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
-"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
-"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
-"     ' prfx=^$ac_symprfx"
-  else
-    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[	 ]\($symcode$symcode*\)[	 ][	 ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
-  fi
-  lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
-
-  # Check to see that the pipe works correctly.
-  pipe_works=no
-
-  rm -f conftest*
-  cat > conftest.$ac_ext <<_LT_EOF
-#ifdef __cplusplus
-extern "C" {
-#endif
-char nm_test_var;
-void nm_test_func(void);
-void nm_test_func(void){}
-#ifdef __cplusplus
-}
-#endif
-int main(){nm_test_var='a';nm_test_func();return(0);}
-_LT_EOF
-
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-    # Now try to grab the symbols.
-    nlist=conftest.nm
-    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
-  (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s "$nlist"; then
-      # Try sorting and uniquifying the output.
-      if sort "$nlist" | uniq > "$nlist"T; then
-	mv -f "$nlist"T "$nlist"
-      else
-	rm -f "$nlist"T
-      fi
-
-      # Make sure that we snagged all the symbols we need.
-      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
-	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
-	  cat <<_LT_EOF > conftest.$ac_ext
-/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
-#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
-/* DATA imports from DLLs on WIN32 con't be const, because runtime
-   relocations are performed -- see ld's documentation on pseudo-relocs.  */
-# define LT_DLSYM_CONST
-#elif defined(__osf__)
-/* This system does not cope well with relocations in const data.  */
-# define LT_DLSYM_CONST
-#else
-# define LT_DLSYM_CONST const
-#endif
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-_LT_EOF
-	  # Now generate the symbol file.
-	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
-
-	  cat <<_LT_EOF >> conftest.$ac_ext
-
-/* The mapping between symbol names and symbols.  */
-LT_DLSYM_CONST struct {
-  const char *name;
-  void       *address;
-}
-lt__PROGRAM__LTX_preloaded_symbols[] =
-{
-  { "@PROGRAM@", (void *) 0 },
-_LT_EOF
-	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
-	  cat <<\_LT_EOF >> conftest.$ac_ext
-  {0, (void *) 0}
-};
 
-/* This works around a problem in FreeBSD linker */
-#ifdef FREEBSD_WORKAROUND
-static const void *lt_preloaded_setup() {
-  return lt__PROGRAM__LTX_preloaded_symbols;
-}
-#endif
 
-#ifdef __cplusplus
-}
-#endif
-_LT_EOF
-	  # Now try linking the two files.
-	  mv conftest.$ac_objext conftstm.$ac_objext
-	  lt_globsym_save_LIBS=$LIBS
-	  lt_globsym_save_CFLAGS=$CFLAGS
-	  LIBS="conftstm.$ac_objext"
-	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
-	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
-	    pipe_works=yes
-	  fi
-	  LIBS=$lt_globsym_save_LIBS
-	  CFLAGS=$lt_globsym_save_CFLAGS
-	else
-	  echo "cannot find nm_test_func in $nlist" >&5
-	fi
-      else
-	echo "cannot find nm_test_var in $nlist" >&5
-      fi
-    else
-      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
-    fi
-  else
-    echo "$progname: failed program was:" >&5
-    cat conftest.$ac_ext >&5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5
+$as_echo_n "checking for BSD- or MS-compatible name lister (nm)... " >&6; }
+if ${lt_cv_path_NM+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_nm_to_check="${ac_tool_prefix}nm"
+  if test -n "$ac_tool_prefix" && test "$build" = "$host"; then
+    lt_nm_to_check="$lt_nm_to_check nm"
   fi
-  rm -rf conftest* conftst*
-
-  # Do not use the global_symbol_pipe unless it works.
-  if test "$pipe_works" = yes; then
-    break
+  for lt_tmp_nm in $lt_nm_to_check; do
+    lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+    for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do
+      IFS="$lt_save_ifs"
+      test -z "$ac_dir" && ac_dir=.
+      tmp_nm="$ac_dir/$lt_tmp_nm"
+      if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+	# Check to see if the nm accepts a BSD-compat flag.
+	# Adding the `sed 1q' prevents false positives on HP-UX, which says:
+	#   nm: unknown option "B" ignored
+	# Tru64's nm complains that /dev/null is an invalid object file
+	case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+	*/dev/null* | *'Invalid file or object type'*)
+	  lt_cv_path_NM="$tmp_nm -B"
+	  break
+	  ;;
+	*)
+	  case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+	  */dev/null*)
+	    lt_cv_path_NM="$tmp_nm -p"
+	    break
+	    ;;
+	  *)
+	    lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+	    continue # so that we can try to find one that supports BSD flags
+	    ;;
+	  esac
+	  ;;
+	esac
+      fi
+    done
+    IFS="$lt_save_ifs"
+  done
+  : ${lt_cv_path_NM=no}
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
+$as_echo "$lt_cv_path_NM" >&6; }
+if test "$lt_cv_path_NM" != "no"; then
+  NM="$lt_cv_path_NM"
+else
+  # Didn't find any BSD compatible name lister, look for dumpbin.
+  if test -n "$DUMPBIN"; then :
+    # Let the user override the test.
   else
-    lt_cv_sys_global_symbol_pipe=
+    if test -n "$ac_tool_prefix"; then
+  for ac_prog in dumpbin "link -dump"
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DUMPBIN+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DUMPBIN"; then
+  ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
   fi
 done
+  done
+IFS=$as_save_IFS
 
 fi
-
-if test -z "$lt_cv_sys_global_symbol_pipe"; then
-  lt_cv_sys_global_symbol_to_cdecl=
 fi
-if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
-$as_echo "failed" >&6; }
+DUMPBIN=$ac_cv_prog_DUMPBIN
+if test -n "$DUMPBIN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5
+$as_echo "$DUMPBIN" >&6; }
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
-$as_echo "ok" >&6; }
-fi
-
-# Response file support.
-if test "$lt_cv_nm_interface" = "MS dumpbin"; then
-  nm_file_list_spec='@'
-elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then
-  nm_file_list_spec='@'
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
 
+    test -n "$DUMPBIN" && break
+  done
+fi
+if test -z "$DUMPBIN"; then
+  ac_ct_DUMPBIN=$DUMPBIN
+  for ac_prog in dumpbin "link -dump"
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DUMPBIN+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_DUMPBIN"; then
+  ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
+fi
+fi
+ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN
+if test -n "$ac_ct_DUMPBIN"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5
+$as_echo "$ac_ct_DUMPBIN" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_DUMPBIN" && break
+done
 
+  if test "x$ac_ct_DUMPBIN" = x; then
+    DUMPBIN=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DUMPBIN=$ac_ct_DUMPBIN
+  fi
+fi
 
+    case `$DUMPBIN -symbols /dev/null 2>&1 | sed '1q'` in
+    *COFF*)
+      DUMPBIN="$DUMPBIN -symbols"
+      ;;
+    *)
+      DUMPBIN=:
+      ;;
+    esac
+  fi
 
+  if test "$DUMPBIN" != ":"; then
+    NM="$DUMPBIN"
+  fi
+fi
+test -z "$NM" && NM=nm
 
 
 
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5
+$as_echo_n "checking the name lister ($NM) interface... " >&6; }
+if ${lt_cv_nm_interface+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_nm_interface="BSD nm"
+  echo "int some_variable = 0;" > conftest.$ac_ext
+  (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5)
+  (eval "$ac_compile" 2>conftest.err)
+  cat conftest.err >&5
+  (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5)
+  (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)
+  cat conftest.err >&5
+  (eval echo "\"\$as_me:$LINENO: output\"" >&5)
+  cat conftest.out >&5
+  if $GREP 'External.*some_variable' conftest.out > /dev/null; then
+    lt_cv_nm_interface="MS dumpbin"
+  fi
+  rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5
+$as_echo "$lt_cv_nm_interface" >&6; }
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
 
+# find the maximum length of command line arguments
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
+$as_echo_n "checking the maximum length of command line arguments... " >&6; }
+if ${lt_cv_sys_max_cmd_len+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+    i=0
+  teststring="ABCD"
 
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
 
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
 
+  cygwin* | mingw* | cegcc*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
 
+  mint*)
+    # On MiNT this can take a long time and run out of memory.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
 
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
 
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536	# usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
 
+  interix*)
+    # We know the value 262144 and hardcode it with a safety zone (like BSD)
+    lt_cv_sys_max_cmd_len=196608
+    ;;
 
+  os2*)
+    # The test takes a long time on OS/2.
+    lt_cv_sys_max_cmd_len=8192
+    ;;
 
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  sco3.2v5*)
+    lt_cv_sys_max_cmd_len=102400
+    ;;
+  sysv5* | sco5v6* | sysv4.2uw2*)
+    kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`
+    if test -n "$kargmax"; then
+      lt_cv_sys_max_cmd_len=`echo $kargmax | sed 's/.*[	 ]//'`
+    else
+      lt_cv_sys_max_cmd_len=32768
+    fi
+    ;;
+  *)
+    lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`
+    if test -n "$lt_cv_sys_max_cmd_len"; then
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    else
+      # Make teststring a little bigger before we do anything with it.
+      # a 1K string should be a reasonable start.
+      for i in 1 2 3 4 5 6 7 8 ; do
+        teststring=$teststring$teststring
+      done
+      SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+      # If test is not a shell built-in, we'll probably end up computing a
+      # maximum length that is only half of the actual maximum length, but
+      # we can't tell.
+      while { test "X"`env echo "$teststring$teststring" 2>/dev/null` \
+	         = "X$teststring$teststring"; } >/dev/null 2>&1 &&
+	      test $i != 17 # 1/2 MB should be enough
+      do
+        i=`expr $i + 1`
+        teststring=$teststring$teststring
+      done
+      # Only check the string length outside the loop.
+      lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`
+      teststring=
+      # Add a significant safety factor because C++ compilers can tack on
+      # massive amounts of additional arguments before passing them to the
+      # linker.  It appears as though 1/2 is a usable value.
+      lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    fi
+    ;;
+  esac
 
+fi
 
-
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
-$as_echo_n "checking for sysroot... " >&6; }
-
-# Check whether --with-sysroot was given.
-if test "${with_sysroot+set}" = set; then :
-  withval=$with_sysroot;
+if test -n $lt_cv_sys_max_cmd_len ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
+$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
 else
-  with_sysroot=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
+$as_echo "none" >&6; }
 fi
+max_cmd_len=$lt_cv_sys_max_cmd_len
 
 
-lt_sysroot=
-case ${with_sysroot} in #(
- yes)
-   if test "$GCC" = yes; then
-     lt_sysroot=`$CC --print-sysroot 2>/dev/null`
-   fi
-   ;; #(
- /*)
-   lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
-   ;; #(
- no|'')
-   ;; #(
- *)
-   { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5
-$as_echo "${with_sysroot}" >&6; }
-   as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
-   ;;
-esac
 
- { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5
-$as_echo "${lt_sysroot:-no}" >&6; }
 
 
 
+: ${CP="cp -f"}
+: ${MV="mv -f"}
+: ${RM="rm -f"}
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands some XSI constructs" >&5
+$as_echo_n "checking whether the shell understands some XSI constructs... " >&6; }
+# Try some XSI features
+xsi_shell=no
+( _lt_dummy="a/b/c"
+  test "${_lt_dummy##*/},${_lt_dummy%/*},${_lt_dummy#??}"${_lt_dummy%"$_lt_dummy"}, \
+      = c,a/b,b/c, \
+    && eval 'test $(( 1 + 1 )) -eq 2 \
+    && test "${#_lt_dummy}" -eq 5' ) >/dev/null 2>&1 \
+  && xsi_shell=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $xsi_shell" >&5
+$as_echo "$xsi_shell" >&6; }
 
-# Check whether --enable-libtool-lock was given.
-if test "${enable_libtool_lock+set}" = set; then :
-  enableval=$enable_libtool_lock;
-fi
 
-test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the shell understands \"+=\"" >&5
+$as_echo_n "checking whether the shell understands \"+=\"... " >&6; }
+lt_shell_append=no
+( foo=bar; set foo baz; eval "$1+=\$2" && test "$foo" = barbaz ) \
+    >/dev/null 2>&1 \
+  && lt_shell_append=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_shell_append" >&5
+$as_echo "$lt_shell_append" >&6; }
 
-# Some flags need to be propagated to the compiler or linker for good
-# libtool support.
-case $host in
-ia64-*-hpux*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-    case `/usr/bin/file conftest.$ac_objext` in
-      *ELF-32*)
-	HPUX_IA64_MODE="32"
-	;;
-      *ELF-64*)
-	HPUX_IA64_MODE="64"
-	;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
-*-*-irix6*)
-  # Find out which ABI we are using.
-  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-    if test "$lt_cv_prog_gnu_ld" = yes; then
-      case `/usr/bin/file conftest.$ac_objext` in
-	*32-bit*)
-	  LD="${LD-ld} -melf32bsmip"
-	  ;;
-	*N32*)
-	  LD="${LD-ld} -melf32bmipn32"
-	  ;;
-	*64-bit*)
-	  LD="${LD-ld} -melf64bmip"
-	;;
-      esac
-    else
-      case `/usr/bin/file conftest.$ac_objext` in
-	*32-bit*)
-	  LD="${LD-ld} -32"
-	  ;;
-	*N32*)
-	  LD="${LD-ld} -n32"
-	  ;;
-	*64-bit*)
-	  LD="${LD-ld} -64"
-	  ;;
-      esac
-    fi
-  fi
-  rm -rf conftest*
-  ;;
-
-x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
-s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-    case `/usr/bin/file conftest.o` in
-      *32-bit*)
-	case $host in
-	  x86_64-*kfreebsd*-gnu)
-	    LD="${LD-ld} -m elf_i386_fbsd"
-	    ;;
-	  x86_64-*linux*)
-	    LD="${LD-ld} -m elf_i386"
-	    ;;
-	  ppc64-*linux*|powerpc64-*linux*)
-	    LD="${LD-ld} -m elf32ppclinux"
-	    ;;
-	  s390x-*linux*)
-	    LD="${LD-ld} -m elf_s390"
-	    ;;
-	  sparc64-*linux*)
-	    LD="${LD-ld} -m elf32_sparc"
-	    ;;
-	esac
-	;;
-      *64-bit*)
-	case $host in
-	  x86_64-*kfreebsd*-gnu)
-	    LD="${LD-ld} -m elf_x86_64_fbsd"
-	    ;;
-	  x86_64-*linux*)
-	    LD="${LD-ld} -m elf_x86_64"
-	    ;;
-	  ppc*-*linux*|powerpc*-*linux*)
-	    LD="${LD-ld} -m elf64ppc"
-	    ;;
-	  s390*-*linux*|s390*-*tpf*)
-	    LD="${LD-ld} -m elf64_s390"
-	    ;;
-	  sparc*-*linux*)
-	    LD="${LD-ld} -m elf64_sparc"
-	    ;;
-	esac
-	;;
-    esac
-  fi
-  rm -rf conftest*
-  ;;
 
-*-*-sco3.2v5*)
-  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
-  SAVE_CFLAGS="$CFLAGS"
-  CFLAGS="$CFLAGS -belf"
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
-$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
-if ${lt_cv_cc_needs_belf+:} false; then :
-  $as_echo_n "(cached) " >&6
+if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then
+  lt_unset=unset
 else
-  ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+  lt_unset=false
+fi
 
-     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-int
-main ()
-{
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  lt_cv_cc_needs_belf=yes
-else
-  lt_cv_cc_needs_belf=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-     ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
-$as_echo "$lt_cv_cc_needs_belf" >&6; }
-  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
-    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
-    CFLAGS="$SAVE_CFLAGS"
-  fi
+
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  lt_SP2NL='tr \040 \012'
+  lt_NL2SP='tr \015\012 \040\040'
   ;;
-*-*solaris*)
-  # Find out which ABI we are using.
-  echo 'int i;' > conftest.$ac_ext
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-    case `/usr/bin/file conftest.o` in
-    *64-bit*)
-      case $lt_cv_prog_gnu_ld in
-      yes*)
-        case $host in
-        i?86-*-solaris*)
-          LD="${LD-ld} -m elf_x86_64"
-          ;;
-        sparc*-*-solaris*)
-          LD="${LD-ld} -m elf64_sparc"
-          ;;
-        esac
-        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
-        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
-          LD="${LD-ld}_sol2"
-        fi
-        ;;
-      *)
-	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
-	  LD="${LD-ld} -64"
-	fi
-	;;
-      esac
-      ;;
-    esac
-  fi
-  rm -rf conftest*
+ *) # EBCDIC based system
+  lt_SP2NL='tr \100 \n'
+  lt_NL2SP='tr \r\n \100\100'
   ;;
 esac
 
-need_locks="$enable_libtool_lock"
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
-set dummy ${ac_tool_prefix}mt; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_MANIFEST_TOOL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$MANIFEST_TOOL"; then
-  ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL
-if test -n "$MANIFEST_TOOL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5
-$as_echo "$MANIFEST_TOOL" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
 
 
-fi
-if test -z "$ac_cv_prog_MANIFEST_TOOL"; then
-  ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL
-  # Extract the first word of "mt", so it can be a program name with args.
-set dummy mt; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then :
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5
+$as_echo_n "checking how to convert $build file names to $host format... " >&6; }
+if ${lt_cv_to_host_file_cmd+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$ac_ct_MANIFEST_TOOL"; then
-  ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+  case $host in
+  *-*-mingw* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32
+        ;;
+      *-*-cygwin* )
+        lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32
+        ;;
+      * ) # otherwise, assume *nix
+        lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32
+        ;;
+    esac
+    ;;
+  *-*-cygwin* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin
+        ;;
+      *-*-cygwin* )
+        lt_cv_to_host_file_cmd=func_convert_file_noop
+        ;;
+      * ) # otherwise, assume *nix
+        lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin
+        ;;
+    esac
+    ;;
+  * ) # unhandled hosts (and "normal" native builds)
+    lt_cv_to_host_file_cmd=func_convert_file_noop
+    ;;
+esac
 
 fi
-fi
-ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL
-if test -n "$ac_ct_MANIFEST_TOOL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5
-$as_echo "$ac_ct_MANIFEST_TOOL" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
 
-  if test "x$ac_ct_MANIFEST_TOOL" = x; then
-    MANIFEST_TOOL=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL
-  fi
+to_host_file_cmd=$lt_cv_to_host_file_cmd
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5
+$as_echo "$lt_cv_to_host_file_cmd" >&6; }
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5
+$as_echo_n "checking how to convert $build file names to toolchain format... " >&6; }
+if ${lt_cv_to_tool_file_cmd+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
-  MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL"
+  #assume ordinary cross tools, or native build.
+lt_cv_to_tool_file_cmd=func_convert_file_noop
+case $host in
+  *-*-mingw* )
+    case $build in
+      *-*-mingw* ) # actually msys
+        lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32
+        ;;
+    esac
+    ;;
+esac
+
 fi
 
-test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5
-$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; }
-if ${lt_cv_path_mainfest_tool+:} false; then :
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5
+$as_echo "$lt_cv_to_tool_file_cmd" >&6; }
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
+$as_echo_n "checking for $LD option to reload object files... " >&6; }
+if ${lt_cv_ld_reload_flag+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  lt_cv_path_mainfest_tool=no
-  echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5
-  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
-  cat conftest.err >&5
-  if $GREP 'Manifest Tool' conftest.out > /dev/null; then
-    lt_cv_path_mainfest_tool=yes
-  fi
-  rm -f conftest*
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
-$as_echo "$lt_cv_path_mainfest_tool" >&6; }
-if test "x$lt_cv_path_mainfest_tool" != xyes; then
-  MANIFEST_TOOL=:
+  lt_cv_ld_reload_flag='-r'
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
+$as_echo "$lt_cv_ld_reload_flag" >&6; }
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    if test "$GCC" != yes; then
+      reload_cmds=false
+    fi
+    ;;
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$LTCC $LTCFLAGS -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
 
 
 
 
 
 
-  case $host_os in
-    rhapsody* | darwin*)
-    if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
-set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
+set dummy ${ac_tool_prefix}objdump; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_DSYMUTIL+:} false; then :
+if ${ac_cv_prog_OBJDUMP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$DSYMUTIL"; then
-  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
+  if test -n "$OBJDUMP"; then
+  ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -7234,7 +7752,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -7244,10 +7762,10 @@ IFS=$as_save_IFS
 
 fi
 fi
-DSYMUTIL=$ac_cv_prog_DSYMUTIL
-if test -n "$DSYMUTIL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
-$as_echo "$DSYMUTIL" >&6; }
+OBJDUMP=$ac_cv_prog_OBJDUMP
+if test -n "$OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
+$as_echo "$OBJDUMP" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
@@ -7255,17 +7773,17 @@ fi
 
 
 fi
-if test -z "$ac_cv_prog_DSYMUTIL"; then
-  ac_ct_DSYMUTIL=$DSYMUTIL
-  # Extract the first word of "dsymutil", so it can be a program name with args.
-set dummy dsymutil; ac_word=$2
+if test -z "$ac_cv_prog_OBJDUMP"; then
+  ac_ct_OBJDUMP=$OBJDUMP
+  # Extract the first word of "objdump", so it can be a program name with args.
+set dummy objdump; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then :
+if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$ac_ct_DSYMUTIL"; then
-  ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
+  if test -n "$ac_ct_OBJDUMP"; then
+  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -7274,7 +7792,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+    ac_cv_prog_ac_ct_OBJDUMP="objdump"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -7284,17 +7802,17 @@ IFS=$as_save_IFS
 
 fi
 fi
-ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
-if test -n "$ac_ct_DSYMUTIL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
-$as_echo "$ac_ct_DSYMUTIL" >&6; }
+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
+if test -n "$ac_ct_OBJDUMP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
+$as_echo "$ac_ct_OBJDUMP" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
-  if test "x$ac_ct_DSYMUTIL" = x; then
-    DSYMUTIL=":"
+  if test "x$ac_ct_OBJDUMP" = x; then
+    OBJDUMP="false"
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
@@ -7302,207 +7820,277 @@ yes:)
 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
-    DSYMUTIL=$ac_ct_DSYMUTIL
+    OBJDUMP=$ac_ct_OBJDUMP
   fi
 else
-  DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+  OBJDUMP="$ac_cv_prog_OBJDUMP"
 fi
 
-    if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
-set dummy ${ac_tool_prefix}nmedit; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_NMEDIT+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$NMEDIT"; then
-  ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+test -z "$OBJDUMP" && OBJDUMP=objdump
 
-fi
-fi
-NMEDIT=$ac_cv_prog_NMEDIT
-if test -n "$NMEDIT"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
-$as_echo "$NMEDIT" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
 
 
-fi
-if test -z "$ac_cv_prog_NMEDIT"; then
-  ac_ct_NMEDIT=$NMEDIT
-  # Extract the first word of "nmedit", so it can be a program name with args.
-set dummy nmedit; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then :
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5
+$as_echo_n "checking how to recognize dependent libraries... " >&6; }
+if ${lt_cv_deplibs_check_method+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$ac_ct_NMEDIT"; then
-  ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_NMEDIT="nmedit"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+  lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
 
-fi
-fi
-ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
-if test -n "$ac_ct_NMEDIT"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
-$as_echo "$ac_ct_NMEDIT" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+case $host_os in
+aix[4-9]*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
-  if test "x$ac_ct_NMEDIT" = x; then
-    NMEDIT=":"
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[45]*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump',
+  # unless we find 'file', for example because we are cross-compiling.
+  # func_win32_libid assumes BSD nm, so disallow it if using MS dumpbin.
+  if ( test "$lt_cv_nm_interface" = "BSD nm" && file / ) >/dev/null 2>&1; then
+    lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+    lt_cv_file_magic_cmd='func_win32_libid'
   else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    NMEDIT=$ac_ct_NMEDIT
+    # Keep this pattern in sync with the one in func_win32_libid.
+    lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'
+    lt_cv_file_magic_cmd='$OBJDUMP -f'
   fi
-else
-  NMEDIT="$ac_cv_prog_NMEDIT"
-fi
+  ;;
 
-    if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
-set dummy ${ac_tool_prefix}lipo; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_LIPO+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$LIPO"; then
-  ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
+cegcc*)
+  # use the weaker test based on 'objdump'. See mingw*.
+  lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | dragonfly*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
   fi
-done
-  done
-IFS=$as_save_IFS
+  ;;
 
-fi
-fi
-LIPO=$ac_cv_prog_LIPO
-if test -n "$LIPO"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
-$as_echo "$LIPO" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
+haiku*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
 
-fi
-if test -z "$ac_cv_prog_LIPO"; then
-  ac_ct_LIPO=$LIPO
-  # Extract the first word of "lipo", so it can be a program name with args.
-set dummy lipo; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_LIPO+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_LIPO"; then
-  ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_LIPO="lipo"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+interix[3-9]*)
+  # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here
+  lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
   fi
-done
-  done
-IFS=$as_save_IFS
+  ;;
 
-fi
-fi
-ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
-if test -n "$ac_ct_LIPO"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
-$as_echo "$ac_ct_LIPO" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
 
-  if test "x$ac_ct_LIPO" = x; then
-    LIPO=":"
+*nto* | *qnx*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
   else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    LIPO=$ac_ct_LIPO
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
   fi
-else
-  LIPO="$ac_cv_prog_LIPO"
-fi
+  ;;
 
-    if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
-set dummy ${ac_tool_prefix}otool; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OTOOL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$OTOOL"; then
-  ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
-else
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+rdos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.3*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  pc)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+tpf*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
+$as_echo "$lt_cv_deplibs_check_method" >&6; }
+
+file_magic_glob=
+want_nocaseglob=no
+if test "$build" = "$host"; then
+  case $host_os in
+  mingw* | pw32*)
+    if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then
+      want_nocaseglob=yes
+    else
+      file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"`
+    fi
+    ;;
+  esac
+fi
+
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dlltool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DLLTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DLLTOOL"; then
+  ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
+else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
 do
@@ -7510,7 +8098,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
+    ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -7520,10 +8108,10 @@ IFS=$as_save_IFS
 
 fi
 fi
-OTOOL=$ac_cv_prog_OTOOL
-if test -n "$OTOOL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
-$as_echo "$OTOOL" >&6; }
+DLLTOOL=$ac_cv_prog_DLLTOOL
+if test -n "$DLLTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
+$as_echo "$DLLTOOL" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
@@ -7531,17 +8119,17 @@ fi
 
 
 fi
-if test -z "$ac_cv_prog_OTOOL"; then
-  ac_ct_OTOOL=$OTOOL
-  # Extract the first word of "otool", so it can be a program name with args.
-set dummy otool; ac_word=$2
+if test -z "$ac_cv_prog_DLLTOOL"; then
+  ac_ct_DLLTOOL=$DLLTOOL
+  # Extract the first word of "dlltool", so it can be a program name with args.
+set dummy dlltool; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OTOOL+:} false; then :
+if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$ac_ct_OTOOL"; then
-  ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
+  if test -n "$ac_ct_DLLTOOL"; then
+  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -7550,7 +8138,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_OTOOL="otool"
+    ac_cv_prog_ac_ct_DLLTOOL="dlltool"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -7560,17 +8148,17 @@ IFS=$as_save_IFS
 
 fi
 fi
-ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
-if test -n "$ac_ct_OTOOL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
-$as_echo "$ac_ct_OTOOL" >&6; }
+ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
+if test -n "$ac_ct_DLLTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
+$as_echo "$ac_ct_DLLTOOL" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
-  if test "x$ac_ct_OTOOL" = x; then
-    OTOOL=":"
+  if test "x$ac_ct_DLLTOOL" = x; then
+    DLLTOOL="false"
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
@@ -7578,22 +8166,73 @@ yes:)
 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
-    OTOOL=$ac_ct_OTOOL
+    DLLTOOL=$ac_ct_DLLTOOL
   fi
 else
-  OTOOL="$ac_cv_prog_OTOOL"
+  DLLTOOL="$ac_cv_prog_DLLTOOL"
 fi
 
-    if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
-set dummy ${ac_tool_prefix}otool64; ac_word=$2
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5
+$as_echo_n "checking how to associate runtime and link libraries... " >&6; }
+if ${lt_cv_sharedlib_from_linklib_cmd+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_sharedlib_from_linklib_cmd='unknown'
+
+case $host_os in
+cygwin* | mingw* | pw32* | cegcc*)
+  # two different shell functions defined in ltmain.sh
+  # decide which to use based on capabilities of $DLLTOOL
+  case `$DLLTOOL --help 2>&1` in
+  *--identify-strict*)
+    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib
+    ;;
+  *)
+    lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback
+    ;;
+  esac
+  ;;
+*)
+  # fallback: assume linklib IS sharedlib
+  lt_cv_sharedlib_from_linklib_cmd="$ECHO"
+  ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5
+$as_echo "$lt_cv_sharedlib_from_linklib_cmd" >&6; }
+sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd
+test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO
+
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  for ac_prog in ar
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OTOOL64+:} false; then :
+if ${ac_cv_prog_AR+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$OTOOL64"; then
-  ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -7602,7 +8241,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
+    ac_cv_prog_AR="$ac_tool_prefix$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -7612,28 +8251,32 @@ IFS=$as_save_IFS
 
 fi
 fi
-OTOOL64=$ac_cv_prog_OTOOL64
-if test -n "$OTOOL64"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
-$as_echo "$OTOOL64" >&6; }
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
 
+    test -n "$AR" && break
+  done
 fi
-if test -z "$ac_cv_prog_OTOOL64"; then
-  ac_ct_OTOOL64=$OTOOL64
-  # Extract the first word of "otool64", so it can be a program name with args.
-set dummy otool64; ac_word=$2
+if test -z "$AR"; then
+  ac_ct_AR=$AR
+  for ac_prog in ar
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
 $as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then :
+if ${ac_cv_prog_ac_ct_AR+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  if test -n "$ac_ct_OTOOL64"; then
-  ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
 else
 as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
 for as_dir in $PATH
@@ -7642,7 +8285,7 @@ do
   test -z "$as_dir" && as_dir=.
     for ac_exec_ext in '' $ac_executable_extensions; do
   if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_OTOOL64="otool64"
+    ac_cv_prog_ac_ct_AR="$ac_prog"
     $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
     break 2
   fi
@@ -7652,17 +8295,21 @@ IFS=$as_save_IFS
 
 fi
 fi
-ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
-if test -n "$ac_ct_OTOOL64"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
-$as_echo "$ac_ct_OTOOL64" >&6; }
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
-  if test "x$ac_ct_OTOOL64" = x; then
-    OTOOL64=":"
+
+  test -n "$ac_ct_AR" && break
+done
+
+  if test "x$ac_ct_AR" = x; then
+    AR="false"
   else
     case $cross_compiling:$ac_tool_warned in
 yes:)
@@ -7670,12 +8317,12 @@ yes:)
 $as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
 ac_tool_warned=yes ;;
 esac
-    OTOOL64=$ac_ct_OTOOL64
+    AR=$ac_ct_AR
   fi
-else
-  OTOOL64="$ac_cv_prog_OTOOL64"
 fi
 
+: ${AR=ar}
+: ${AR_FLAGS=cru}
 
 
 
@@ -7687,11 +8334,57 @@ fi
 
 
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5
+$as_echo_n "checking for archiver @FILE support... " >&6; }
+if ${lt_cv_ar_at_file+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ar_at_file=no
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+int
+main ()
+{
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  echo conftest.$ac_objext > conftest.lst
+      lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5'
+      { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
+  (eval $lt_ar_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+      if test "$ac_status" -eq 0; then
+	# Ensure the archiver fails upon bogus file names.
+	rm -f conftest.$ac_objext libconftest.a
+	{ { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5
+  (eval $lt_ar_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+	if test "$ac_status" -ne 0; then
+          lt_cv_ar_at_file=@
+        fi
+      fi
+      rm -f conftest.* libconftest.a
 
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5
+$as_echo "$lt_cv_ar_at_file" >&6; }
 
+if test "x$lt_cv_ar_at_file" = xno; then
+  archiver_list_spec=
+else
+  archiver_list_spec=$lt_cv_ar_at_file
+fi
 
 
 
@@ -7699,457 +8392,258 @@ fi
 
 
 
-
-
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
-$as_echo_n "checking for -single_module linker flag... " >&6; }
-if ${lt_cv_apple_cc_single_mod+:} false; then :
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_STRIP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  lt_cv_apple_cc_single_mod=no
-      if test -z "${LT_MULTI_MODULE}"; then
-	# By default we will add the -single_module flag. You can override
-	# by either setting the environment variable LT_MULTI_MODULE
-	# non-empty at configure time, or by adding -multi_module to the
-	# link flags.
-	rm -rf libconftest.dylib*
-	echo "int foo(void){return 1;}" > conftest.c
-	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
--dynamiclib -Wl,-single_module conftest.c" >&5
-	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
-	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
-        _lt_result=$?
-	# If there is a non-empty error log, and "single_module"
-	# appears in it, assume the flag caused a linker warning
-        if test -s conftest.err && $GREP single_module conftest.err; then
-	  cat conftest.err >&5
-	# Otherwise, if the output was created with a 0 exit code from
-	# the compiler, it worked.
-	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
-	  lt_cv_apple_cc_single_mod=yes
-	else
-	  cat conftest.err >&5
-	fi
-	rm -rf libconftest.dylib*
-	rm -f conftest.*
-      fi
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
-$as_echo "$lt_cv_apple_cc_single_mod" >&6; }
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
-$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
-if ${lt_cv_ld_exported_symbols_list+:} false; then :
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  lt_cv_ld_exported_symbols_list=no
-      save_LDFLAGS=$LDFLAGS
-      echo "_main" > conftest.sym
-      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  lt_cv_ld_exported_symbols_list=yes
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
 else
-  lt_cv_ld_exported_symbols_list=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-	LDFLAGS="$save_LDFLAGS"
 
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
-$as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
-$as_echo_n "checking for -force_load linker flag... " >&6; }
-if ${lt_cv_ld_force_load+:} false; then :
+test -z "$STRIP" && STRIP=:
+
+
+
+
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_RANLIB+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  lt_cv_ld_force_load=no
-      cat > conftest.c << _LT_EOF
-int forced_loaded() { return 2;}
-_LT_EOF
-      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
-      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
-      echo "$AR cru libconftest.a conftest.o" >&5
-      $AR cru libconftest.a conftest.o 2>&5
-      echo "$RANLIB libconftest.a" >&5
-      $RANLIB libconftest.a 2>&5
-      cat > conftest.c << _LT_EOF
-int main() { return 0;}
-_LT_EOF
-      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
-      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
-      _lt_result=$?
-      if test -s conftest.err && $GREP force_load conftest.err; then
-	cat conftest.err >&5
-      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
-	lt_cv_ld_force_load=yes
-      else
-	cat conftest.err >&5
-      fi
-        rm -f conftest.err libconftest.a conftest conftest.c
-        rm -rf conftest.dSYM
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
-$as_echo "$lt_cv_ld_force_load" >&6; }
-    case $host_os in
-    rhapsody* | darwin1.[012])
-      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
-    darwin1.*)
-      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
-    darwin*) # darwin 5.x on
-      # if running on 10.5 or later, the deployment target defaults
-      # to the OS version, if on x86, and 10.4, the deployment
-      # target defaults to 10.4. Don't you love it?
-      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
-	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-	10.[012]*)
-	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
-	10.*)
-	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
-      esac
-    ;;
-  esac
-    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
-      _lt_dar_single_mod='$single_module'
-    fi
-    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
-      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
-    else
-      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
-    fi
-    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
-      _lt_dsymutil='~$DSYMUTIL $lib || :'
-    else
-      _lt_dsymutil=
-    fi
-    ;;
-  esac
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
-$as_echo_n "checking how to run the C preprocessor... " >&6; }
-# On Suns, sometimes $CPP names a directory.
-if test -n "$CPP" && test -d "$CPP"; then
-  CPP=
 fi
-if test -z "$CPP"; then
-  if ${ac_cv_prog_CPP+:} false; then :
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-      # Double quotes because CPP needs to be expanded
-    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
-    do
-      ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
 do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
 else
-  # Broken: fails on valid input.
-continue
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
 
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # Broken: success on invalid input.
-continue
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
 else
-  # Passes both tests.
-ac_preproc_ok=:
-break
+  RANLIB="$ac_cv_prog_RANLIB"
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
 
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-  break
-fi
+test -z "$RANLIB" && RANLIB=:
 
-    done
-    ac_cv_prog_CPP=$CPP
 
-fi
-  CPP=$ac_cv_prog_CPP
-else
-  ac_cv_prog_CPP=$CPP
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
-$as_echo "$CPP" >&6; }
-ac_preproc_ok=false
-for ac_c_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
 
-else
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
 
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_c_try_cpp "$LINENO"; then :
-  # Broken: success on invalid input.
-continue
-else
-  # Passes both tests.
-ac_preproc_ok=:
-break
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
 
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
 
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5; }
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"
+    ;;
+  *)
+    old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"
 fi
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+case $host_os in
+  darwin*)
+    lock_old_archive_extraction=yes ;;
+  *)
+    lock_old_archive_extraction=no ;;
+esac
 
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
-$as_echo_n "checking for ANSI C header files... " >&6; }
-if ${ac_cv_header_stdc+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-#include <stdarg.h>
-#include <string.h>
-#include <float.h>
 
-int
-main ()
-{
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_header_stdc=yes
-else
-  ac_cv_header_stdc=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-if test $ac_cv_header_stdc = yes; then
-  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <string.h>
 
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "memchr" >/dev/null 2>&1; then :
 
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
 
-fi
 
-if test $ac_cv_header_stdc = yes; then
-  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdlib.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "free" >/dev/null 2>&1; then :
-
-else
-  ac_cv_header_stdc=no
-fi
-rm -f conftest*
 
-fi
 
-if test $ac_cv_header_stdc = yes; then
-  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
-  if test "$cross_compiling" = yes; then :
-  :
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ctype.h>
-#include <stdlib.h>
-#if ((' ' & 0x0FF) == 0x020)
-# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
-# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
-#else
-# define ISLOWER(c) \
-		   (('a' <= (c) && (c) <= 'i') \
-		     || ('j' <= (c) && (c) <= 'r') \
-		     || ('s' <= (c) && (c) <= 'z'))
-# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
-#endif
 
-#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
-int
-main ()
-{
-  int i;
-  for (i = 0; i < 256; i++)
-    if (XOR (islower (i), ISLOWER (i))
-	|| toupper (i) != TOUPPER (i))
-      return 2;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_run "$LINENO"; then :
 
-else
-  ac_cv_header_stdc=no
-fi
-rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
-  conftest.$ac_objext conftest.beam conftest.$ac_ext
-fi
 
-fi
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
-$as_echo "$ac_cv_header_stdc" >&6; }
-if test $ac_cv_header_stdc = yes; then
 
-$as_echo "#define STDC_HEADERS 1" >>confdefs.h
 
-fi
 
-# On IRIX 5.3, sys/types and inttypes.h are conflicting.
-for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
-		  inttypes.h stdint.h unistd.h
-do :
-  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
-ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
-"
-if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
-  cat >>confdefs.h <<_ACEOF
-#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
-_ACEOF
 
-fi
 
-done
 
 
-for ac_header in dlfcn.h
-do :
-  ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
-"
-if test "x$ac_cv_header_dlfcn_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_DLFCN_H 1
-_ACEOF
 
-fi
 
-done
 
 
 
 
 
-# Set options
 
-# Check whether --with-pic was given.
-if test "${with_pic+set}" = set; then :
-  withval=$with_pic; lt_p=${PACKAGE-default}
-    case $withval in
-    yes|no) pic_mode=$withval ;;
-    *)
-      pic_mode=default
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for lt_pkg in $withval; do
-	IFS="$lt_save_ifs"
-	if test "X$lt_pkg" = "X$lt_p"; then
-	  pic_mode=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac
-else
-  pic_mode=default
-fi
 
 
-test -z "$pic_mode" && pic_mode=yes
 
 
 
@@ -8158,130 +8652,264 @@ test -z "$pic_mode" && pic_mode=yes
 
 
 
-        enable_dlopen=no
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
 
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
 
-  enable_win32_dll=no
+# Allow CC to be a program name with arguments.
+compiler=$CC
 
 
-            # Check whether --enable-shared was given.
-if test "${enable_shared+set}" = set; then :
-  enableval=$enable_shared; p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_shared=yes ;;
-    no) enable_shared=no ;;
-    *)
-      enable_shared=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-	IFS="$lt_save_ifs"
-	if test "X$pkg" = "X$p"; then
-	  enable_shared=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
+$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
+if ${lt_cv_sys_global_symbol_pipe+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
-  enable_shared=yes
-fi
-
-
-
-
-
-
 
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
 
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
 
-  # Check whether --enable-static was given.
-if test "${enable_static+set}" = set; then :
-  enableval=$enable_static; p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_static=yes ;;
-    no) enable_static=no ;;
-    *)
-     enable_static=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-	IFS="$lt_save_ifs"
-	if test "X$pkg" = "X$p"; then
-	  enable_static=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac
-else
-  enable_static=yes
-fi
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
 
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[BCDT]'
+  ;;
+cygwin* | mingw* | pw32* | cegcc*)
+  symcode='[ABCDGISTW]'
+  ;;
+hpux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[ABCDEGRST]'
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[BCDEGRST]'
+  ;;
+osf*)
+  symcode='[BCDEGQRST]'
+  ;;
+solaris*)
+  symcode='[BDRT]'
+  ;;
+sco3.2v5*)
+  symcode='[DT]'
+  ;;
+sysv4.2uw2*)
+  symcode='[DT]'
+  ;;
+sysv5* | sco5v6* | unixware* | OpenUNIX*)
+  symcode='[ABDT]'
+  ;;
+sysv4)
+  symcode='[DFNSTU]'
+  ;;
+esac
 
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[ABCDGIRSTW]' ;;
+esac
 
+# Transform an extracted symbol line into a proper C declaration.
+# Some systems (esp. on ia64) link data and code symbols differently,
+# so use this general approach.
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
 
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (void *) \&\2},/p'"
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="sed -n -e 's/^: \([^ ]*\)[ ]*$/  {\\\"\1\\\", (void *) 0},/p' -e 's/^$symcode* \([^ ]*\) \(lib[^ ]*\)$/  {\"\2\", (void *) \&\2},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"lib\2\", (void *) \&\2},/p'"
 
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
 
+# Try without a prefix underscore, then with it.
+for ac_symprfx in "" "_"; do
 
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
 
+  # Write the raw and C identifiers.
+  if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+    # Fake it for dumpbin and say T for any non-static function
+    # and D for any global variable.
+    # Also find C++ and __fastcall symbols from MSVC++,
+    # which start with @ or ?.
+    lt_cv_sys_global_symbol_pipe="$AWK '"\
+"     {last_section=section; section=\$ 3};"\
+"     /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\
+"     /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\
+"     \$ 0!~/External *\|/{next};"\
+"     / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\
+"     {if(hide[section]) next};"\
+"     {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"};"\
+"     {split(\$ 0, a, /\||\r/); split(a[2], s)};"\
+"     s[1]~/^[@?]/{print s[1], s[1]; next};"\
+"     s[1]~prfx {split(s[1],t,\"@\"); print t[1], substr(t[1],length(prfx))}"\
+"     ' prfx=^$ac_symprfx"
+  else
+    lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[	 ]\($symcode$symcode*\)[	 ][	 ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+  fi
+  lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | sed '/ __gnu_lto/d'"
 
+  # Check to see that the pipe works correctly.
+  pipe_works=no
 
-  # Check whether --enable-fast-install was given.
-if test "${enable_fast_install+set}" = set; then :
-  enableval=$enable_fast_install; p=${PACKAGE-default}
-    case $enableval in
-    yes) enable_fast_install=yes ;;
-    no) enable_fast_install=no ;;
-    *)
-      enable_fast_install=no
-      # Look at the argument we got.  We use all the common list separators.
-      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
-      for pkg in $enableval; do
-	IFS="$lt_save_ifs"
-	if test "X$pkg" = "X$p"; then
-	  enable_fast_install=yes
-	fi
-      done
-      IFS="$lt_save_ifs"
-      ;;
-    esac
-else
-  enable_fast_install=yes
-fi
-
-
-
-
-
-
-
-
-
-
-
-# This can be used to rebuild libtool when needed
-LIBTOOL_DEPS="$ltmain"
-
-# Always use our own libtool.
-LIBTOOL='$(SHELL) $(top_builddir)/libtool'
-
-
-
-
-
+  rm -f conftest*
+  cat > conftest.$ac_ext <<_LT_EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(void);
+void nm_test_func(void){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+_LT_EOF
 
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5
+  (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+	mv -f "$nlist"T "$nlist"
+      else
+	rm -f "$nlist"T
+      fi
 
+      # Make sure that we snagged all the symbols we need.
+      if $GREP ' nm_test_var$' "$nlist" >/dev/null; then
+	if $GREP ' nm_test_func$' "$nlist" >/dev/null; then
+	  cat <<_LT_EOF > conftest.$ac_ext
+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests.  */
+#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
+/* DATA imports from DLLs on WIN32 con't be const, because runtime
+   relocations are performed -- see ld's documentation on pseudo-relocs.  */
+# define LT_DLSYM_CONST
+#elif defined(__osf__)
+/* This system does not cope well with relocations in const data.  */
+# define LT_DLSYM_CONST
+#else
+# define LT_DLSYM_CONST const
+#endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
 
+_LT_EOF
+	  # Now generate the symbol file.
+	  eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'
 
+	  cat <<_LT_EOF >> conftest.$ac_ext
 
+/* The mapping between symbol names and symbols.  */
+LT_DLSYM_CONST struct {
+  const char *name;
+  void       *address;
+}
+lt__PROGRAM__LTX_preloaded_symbols[] =
+{
+  { "@PROGRAM@", (void *) 0 },
+_LT_EOF
+	  $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (void *) \&\2},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext
+	  cat <<\_LT_EOF >> conftest.$ac_ext
+  {0, (void *) 0}
+};
 
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt__PROGRAM__LTX_preloaded_symbols;
+}
+#endif
 
+#ifdef __cplusplus
+}
+#endif
+_LT_EOF
+	  # Now try linking the two files.
+	  mv conftest.$ac_objext conftstm.$ac_objext
+	  lt_globsym_save_LIBS=$LIBS
+	  lt_globsym_save_CFLAGS=$CFLAGS
+	  LIBS="conftstm.$ac_objext"
+	  CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
+	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+	    pipe_works=yes
+	  fi
+	  LIBS=$lt_globsym_save_LIBS
+	  CFLAGS=$lt_globsym_save_CFLAGS
+	else
+	  echo "cannot find nm_test_func in $nlist" >&5
+	fi
+      else
+	echo "cannot find nm_test_var in $nlist" >&5
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+    fi
+  else
+    echo "$progname: failed program was:" >&5
+    cat conftest.$ac_ext >&5
+  fi
+  rm -rf conftest* conftst*
 
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
 
+fi
 
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
+$as_echo "failed" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+fi
 
+# Response file support.
+if test "$lt_cv_nm_interface" = "MS dumpbin"; then
+  nm_file_list_spec='@'
+elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then
+  nm_file_list_spec='@'
+fi
 
 
 
@@ -8295,7 +8923,6 @@ LIBTOOL='$(SHELL) $(top_builddir)/libtool'
 
 
 
-test -z "$LN_S" && LN_S="ln -s"
 
 
 
@@ -8310,722 +8937,844 @@ test -z "$LN_S" && LN_S="ln -s"
 
 
 
-if test -n "${ZSH_VERSION+set}" ; then
-   setopt NO_GLOB_SUBST
-fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5
+$as_echo_n "checking for sysroot... " >&6; }
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
-$as_echo_n "checking for objdir... " >&6; }
-if ${lt_cv_objdir+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  rm -f .libs 2>/dev/null
-mkdir .libs 2>/dev/null
-if test -d .libs; then
-  lt_cv_objdir=.libs
+# Check whether --with-sysroot was given.
+if test "${with_sysroot+set}" = set; then :
+  withval=$with_sysroot;
 else
-  # MS-DOS does not allow filenames that begin with a dot.
-  lt_cv_objdir=_libs
-fi
-rmdir .libs 2>/dev/null
+  with_sysroot=no
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
-$as_echo "$lt_cv_objdir" >&6; }
-objdir=$lt_cv_objdir
 
 
+lt_sysroot=
+case ${with_sysroot} in #(
+ yes)
+   if test "$GCC" = yes; then
+     lt_sysroot=`$CC --print-sysroot 2>/dev/null`
+   fi
+   ;; #(
+ /*)
+   lt_sysroot=`echo "$with_sysroot" | sed -e "$sed_quote_subst"`
+   ;; #(
+ no|'')
+   ;; #(
+ *)
+   { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${with_sysroot}" >&5
+$as_echo "${with_sysroot}" >&6; }
+   as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5
+   ;;
+esac
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5
+$as_echo "${lt_sysroot:-no}" >&6; }
 
 
 
-cat >>confdefs.h <<_ACEOF
-#define LT_OBJDIR "$lt_cv_objdir/"
-_ACEOF
 
 
+# Check whether --enable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then :
+  enableval=$enable_libtool_lock;
+fi
 
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
 
-case $host_os in
-aix3*)
-  # AIX sometimes has problems with the GCC collect2 program.  For some
-  # reason, if we set the COLLECT_NAMES environment variable, the problems
-  # vanish in a puff of smoke.
-  if test "X${COLLECT_NAMES+set}" != Xset; then
-    COLLECT_NAMES=
-    export COLLECT_NAMES
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.$ac_objext` in
+      *ELF-32*)
+	HPUX_IA64_MODE="32"
+	;;
+      *ELF-64*)
+	HPUX_IA64_MODE="64"
+	;;
+    esac
   fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '#line '$LINENO' "configure"' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    if test "$lt_cv_prog_gnu_ld" = yes; then
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -melf32bsmip"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -melf32bmipn32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -melf64bmip"
+	;;
+      esac
+    else
+      case `/usr/bin/file conftest.$ac_objext` in
+	*32-bit*)
+	  LD="${LD-ld} -32"
+	  ;;
+	*N32*)
+	  LD="${LD-ld} -n32"
+	  ;;
+	*64-bit*)
+	  LD="${LD-ld} -64"
+	  ;;
+      esac
+    fi
+  fi
+  rm -rf conftest*
   ;;
-esac
-
-# Global variables:
-ofile=libtool
-can_build_shared=yes
-
-# All known linkers require a `.a' archive for static linking (except MSVC,
-# which needs '.lib').
-libext=a
-
-with_gnu_ld="$lt_cv_prog_gnu_ld"
-
-old_CC="$CC"
-old_CFLAGS="$CFLAGS"
-
-# Set sane defaults for various variables
-test -z "$CC" && CC=cc
-test -z "$LTCC" && LTCC=$CC
-test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
-test -z "$LD" && LD=ld
-test -z "$ac_objext" && ac_objext=o
-
-for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
 
+x86_64-*kfreebsd*-gnu|x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*| \
+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.o` in
+      *32-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_i386_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    LD="${LD-ld} -m elf_i386"
+	    ;;
+	  ppc64-*linux*|powerpc64-*linux*)
+	    LD="${LD-ld} -m elf32ppclinux"
+	    ;;
+	  s390x-*linux*)
+	    LD="${LD-ld} -m elf_s390"
+	    ;;
+	  sparc64-*linux*)
+	    LD="${LD-ld} -m elf32_sparc"
+	    ;;
+	esac
+	;;
+      *64-bit*)
+	case $host in
+	  x86_64-*kfreebsd*-gnu)
+	    LD="${LD-ld} -m elf_x86_64_fbsd"
+	    ;;
+	  x86_64-*linux*)
+	    LD="${LD-ld} -m elf_x86_64"
+	    ;;
+	  ppc*-*linux*|powerpc*-*linux*)
+	    LD="${LD-ld} -m elf64ppc"
+	    ;;
+	  s390*-*linux*|s390*-*tpf*)
+	    LD="${LD-ld} -m elf64_s390"
+	    ;;
+	  sparc*-*linux*)
+	    LD="${LD-ld} -m elf64_sparc"
+	    ;;
+	esac
+	;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
 
-# Only perform the check for file, if the check method requires it
-test -z "$MAGIC_CMD" && MAGIC_CMD=file
-case $deplibs_check_method in
-file_magic*)
-  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
-$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
-if ${lt_cv_path_MAGIC_CMD+:} false; then :
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
+$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
+if ${lt_cv_cc_needs_belf+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $MAGIC_CMD in
-[\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
-  ;;
-*)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
-  for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/${ac_tool_prefix}file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
-      if test -n "$file_magic_test_file"; then
-	case $deplibs_check_method in
-	"file_magic "*)
-	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
-	    $EGREP "$file_magic_regex" > /dev/null; then
-	    :
-	  else
-	    cat <<_LT_EOF 1>&2
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such.  This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem.  Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool at gnu.org
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-_LT_EOF
-	  fi ;;
-	esac
-      fi
-      break
-    fi
-  done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
-  ;;
-esac
-fi
+int
+main ()
+{
 
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
-$as_echo "$MAGIC_CMD" >&6; }
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  lt_cv_cc_needs_belf=yes
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
+  lt_cv_cc_needs_belf=no
 fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+     ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
+$as_echo "$lt_cv_cc_needs_belf" >&6; }
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+*-*solaris*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.o` in
+    *64-bit*)
+      case $lt_cv_prog_gnu_ld in
+      yes*)
+        case $host in
+        i?86-*-solaris*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        sparc*-*-solaris*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+        esac
+        # GNU ld 2.21 introduced _sol2 emulations.  Use them if available.
+        if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then
+          LD="${LD-ld}_sol2"
+        fi
+        ;;
+      *)
+	if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then
+	  LD="${LD-ld} -64"
+	fi
+	;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+esac
 
+need_locks="$enable_libtool_lock"
 
-
-
-if test -z "$lt_cv_path_MAGIC_CMD"; then
-  if test -n "$ac_tool_prefix"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
-$as_echo_n "checking for file... " >&6; }
-if ${lt_cv_path_MAGIC_CMD+:} false; then :
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.
+set dummy ${ac_tool_prefix}mt; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_MANIFEST_TOOL+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  case $MAGIC_CMD in
-[\\/*] |  ?:[\\/]*)
-  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
-  ;;
-*)
-  lt_save_MAGIC_CMD="$MAGIC_CMD"
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
-  for ac_dir in $ac_dummy; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    if test -f $ac_dir/file; then
-      lt_cv_path_MAGIC_CMD="$ac_dir/file"
-      if test -n "$file_magic_test_file"; then
-	case $deplibs_check_method in
-	"file_magic "*)
-	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
-	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
-	    $EGREP "$file_magic_regex" > /dev/null; then
-	    :
-	  else
-	    cat <<_LT_EOF 1>&2
+  if test -n "$MANIFEST_TOOL"; then
+  ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL
+if test -n "$MANIFEST_TOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5
+$as_echo "$MANIFEST_TOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
-*** Warning: the command libtool uses to detect shared libraries,
-*** $file_magic_cmd, produces output that libtool cannot recognize.
-*** The result is that libtool may fail to recognize shared libraries
-*** as such.  This will affect the creation of libtool libraries that
-*** depend on shared libraries, but programs linked with such libtool
-*** libraries will work regardless of this problem.  Nevertheless, you
-*** may want to report the problem to your system manager and/or to
-*** bug-libtool at gnu.org
 
-_LT_EOF
-	  fi ;;
-	esac
-      fi
-      break
-    fi
-  done
-  IFS="$lt_save_ifs"
-  MAGIC_CMD="$lt_save_MAGIC_CMD"
-  ;;
-esac
 fi
+if test -z "$ac_cv_prog_MANIFEST_TOOL"; then
+  ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL
+  # Extract the first word of "mt", so it can be a program name with args.
+set dummy mt; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_MANIFEST_TOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_MANIFEST_TOOL"; then
+  ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
-if test -n "$MAGIC_CMD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
-$as_echo "$MAGIC_CMD" >&6; }
+fi
+fi
+ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL
+if test -n "$ac_ct_MANIFEST_TOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5
+$as_echo "$ac_ct_MANIFEST_TOOL" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
 fi
 
-
+  if test "x$ac_ct_MANIFEST_TOOL" = x; then
+    MANIFEST_TOOL=":"
   else
-    MAGIC_CMD=:
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL
   fi
+else
+  MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL"
 fi
 
+test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5
+$as_echo_n "checking if $MANIFEST_TOOL is a manifest tool... " >&6; }
+if ${lt_cv_path_mainfest_tool+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_path_mainfest_tool=no
+  echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5
+  $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out
+  cat conftest.err >&5
+  if $GREP 'Manifest Tool' conftest.out > /dev/null; then
+    lt_cv_path_mainfest_tool=yes
   fi
-  ;;
-esac
-
-# Use C for the default configuration in the libtool script
-
-lt_save_CC="$CC"
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+  rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5
+$as_echo "$lt_cv_path_mainfest_tool" >&6; }
+if test "x$lt_cv_path_mainfest_tool" != xyes; then
+  MANIFEST_TOOL=:
+fi
 
 
-# Source file extension for C test sources.
-ac_ext=c
 
-# Object file extension for compiled C test sources.
-objext=o
-objext=$objext
 
-# Code to be used in simple compile tests
-lt_simple_compile_test_code="int some_variable = 0;"
 
-# Code to be used in simple link tests
-lt_simple_link_test_code='int main(){return(0);}'
 
+  case $host_os in
+    rhapsody* | darwin*)
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.
+set dummy ${ac_tool_prefix}dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_DSYMUTIL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$DSYMUTIL"; then
+  ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
+fi
+fi
+DSYMUTIL=$ac_cv_prog_DSYMUTIL
+if test -n "$DSYMUTIL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5
+$as_echo "$DSYMUTIL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
 
+fi
+if test -z "$ac_cv_prog_DSYMUTIL"; then
+  ac_ct_DSYMUTIL=$DSYMUTIL
+  # Extract the first word of "dsymutil", so it can be a program name with args.
+set dummy dsymutil; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_DSYMUTIL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_DSYMUTIL"; then
+  ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
+fi
+fi
+ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL
+if test -n "$ac_ct_DSYMUTIL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5
+$as_echo "$ac_ct_DSYMUTIL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
+  if test "x$ac_ct_DSYMUTIL" = x; then
+    DSYMUTIL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    DSYMUTIL=$ac_ct_DSYMUTIL
+  fi
+else
+  DSYMUTIL="$ac_cv_prog_DSYMUTIL"
+fi
 
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
-
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
-
-# Allow CC to be a program name with arguments.
-compiler=$CC
-
-# Save the default compiler, since it gets overwritten when the other
-# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
-compiler_DEFAULT=$CC
-
-# save warnings/boilerplate of simple test code
-ac_outfile=conftest.$ac_objext
-echo "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$RM conftest*
-
-ac_outfile=conftest.$ac_objext
-echo "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$RM -r conftest*
-
-
-## CAVEAT EMPTOR:
-## There is no encapsulation within the following macros, do not change
-## the running order or otherwise move them around unless you know exactly
-## what you are doing...
-if test -n "$compiler"; then
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.
+set dummy ${ac_tool_prefix}nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_NMEDIT+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$NMEDIT"; then
+  ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-lt_prog_compiler_no_builtin_flag=
+fi
+fi
+NMEDIT=$ac_cv_prog_NMEDIT
+if test -n "$NMEDIT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5
+$as_echo "$NMEDIT" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
-if test "$GCC" = yes; then
-  case $cc_basename in
-  nvcc*)
-    lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
-  *)
-    lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;;
-  esac
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
-$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
-if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then :
+fi
+if test -z "$ac_cv_prog_NMEDIT"; then
+  ac_ct_NMEDIT=$NMEDIT
+  # Extract the first word of "nmedit", so it can be a program name with args.
+set dummy nmedit; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_NMEDIT+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  lt_cv_prog_compiler_rtti_exceptions=no
-   ac_outfile=conftest.$ac_objext
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="-fno-rtti -fno-exceptions"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_rtti_exceptions=yes
-     fi
-   fi
-   $RM conftest*
+  if test -n "$ac_ct_NMEDIT"; then
+  ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_NMEDIT="nmedit"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
-$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
-
-if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
-    lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+fi
+ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT
+if test -n "$ac_ct_NMEDIT"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5
+$as_echo "$ac_ct_NMEDIT" >&6; }
 else
-    :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
+  if test "x$ac_ct_NMEDIT" = x; then
+    NMEDIT=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    NMEDIT=$ac_ct_NMEDIT
+  fi
+else
+  NMEDIT="$ac_cv_prog_NMEDIT"
 fi
 
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.
+set dummy ${ac_tool_prefix}lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_LIPO+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$LIPO"; then
+  ac_cv_prog_LIPO="$LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_LIPO="${ac_tool_prefix}lipo"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
+fi
+fi
+LIPO=$ac_cv_prog_LIPO
+if test -n "$LIPO"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5
+$as_echo "$LIPO" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
 
+fi
+if test -z "$ac_cv_prog_LIPO"; then
+  ac_ct_LIPO=$LIPO
+  # Extract the first word of "lipo", so it can be a program name with args.
+set dummy lipo; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_LIPO+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_LIPO"; then
+  ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_LIPO="lipo"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
+fi
+fi
+ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO
+if test -n "$ac_ct_LIPO"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5
+$as_echo "$ac_ct_LIPO" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
-  lt_prog_compiler_wl=
-lt_prog_compiler_pic=
-lt_prog_compiler_static=
-
-
-  if test "$GCC" = yes; then
-    lt_prog_compiler_wl='-Wl,'
-    lt_prog_compiler_static='-static'
+  if test "x$ac_ct_LIPO" = x; then
+    LIPO=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    LIPO=$ac_ct_LIPO
+  fi
+else
+  LIPO="$ac_cv_prog_LIPO"
+fi
 
-    case $host_os in
-      aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static='-Bstatic'
-      fi
-      ;;
-
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            lt_prog_compiler_pic='-fPIC'
-        ;;
-      m68k)
-            # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
-            lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
-        ;;
-      esac
-      ;;
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OTOOL"; then
+  ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OTOOL="${ac_tool_prefix}otool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
+fi
+fi
+OTOOL=$ac_cv_prog_OTOOL
+if test -n "$OTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5
+$as_echo "$OTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      # Although the cygwin gcc ignores -fPIC, still need this for old-style
-      # (--disable-auto-import) libraries
-      lt_prog_compiler_pic='-DDLL_EXPORT'
-      ;;
 
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      lt_prog_compiler_pic='-fno-common'
-      ;;
+fi
+if test -z "$ac_cv_prog_OTOOL"; then
+  ac_ct_OTOOL=$OTOOL
+  # Extract the first word of "otool", so it can be a program name with args.
+set dummy otool; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OTOOL+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OTOOL"; then
+  ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_OTOOL="otool"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-    haiku*)
-      # PIC is the default for Haiku.
-      # The "-static" flag exists, but is broken.
-      lt_prog_compiler_static=
-      ;;
+fi
+fi
+ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL
+if test -n "$ac_ct_OTOOL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5
+$as_echo "$ac_ct_OTOOL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
-    hpux*)
-      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
-      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
-      # sets the default TLS model and affects inlining.
-      case $host_cpu in
-      hppa*64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic='-fPIC'
-	;;
-      esac
-      ;;
+  if test "x$ac_ct_OTOOL" = x; then
+    OTOOL=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OTOOL=$ac_ct_OTOOL
+  fi
+else
+  OTOOL="$ac_cv_prog_OTOOL"
+fi
 
-    interix[3-9]*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
+    if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.
+set dummy ${ac_tool_prefix}otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_OTOOL64+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$OTOOL64"; then
+  ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-    msdosdjgpp*)
-      # Just because we use GCC doesn't mean we suddenly get shared libraries
-      # on systems that don't support them.
-      lt_prog_compiler_can_build_shared=no
-      enable_shared=no
-      ;;
+fi
+fi
+OTOOL64=$ac_cv_prog_OTOOL64
+if test -n "$OTOOL64"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5
+$as_echo "$OTOOL64" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
-    *nto* | *qnx*)
-      # QNX uses GNU C++, but need to define -shared option too, otherwise
-      # it will coredump.
-      lt_prog_compiler_pic='-fPIC -shared'
-      ;;
 
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	lt_prog_compiler_pic=-Kconform_pic
-      fi
-      ;;
+fi
+if test -z "$ac_cv_prog_OTOOL64"; then
+  ac_ct_OTOOL64=$OTOOL64
+  # Extract the first word of "otool64", so it can be a program name with args.
+set dummy otool64; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_ac_ct_OTOOL64+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_OTOOL64"; then
+  ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_OTOOL64="otool64"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
 
-    *)
-      lt_prog_compiler_pic='-fPIC'
-      ;;
-    esac
+fi
+fi
+ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64
+if test -n "$ac_ct_OTOOL64"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5
+$as_echo "$ac_ct_OTOOL64" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
-    case $cc_basename in
-    nvcc*) # Cuda Compiler Driver 2.2
-      lt_prog_compiler_wl='-Xlinker '
-      if test -n "$lt_prog_compiler_pic"; then
-        lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic"
-      fi
-      ;;
-    esac
+  if test "x$ac_ct_OTOOL64" = x; then
+    OTOOL64=":"
   else
-    # PORTME Check for flag to pass linker flags through the system compiler.
-    case $host_os in
-    aix*)
-      lt_prog_compiler_wl='-Wl,'
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static='-Bstatic'
-      else
-	lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
-      fi
-      ;;
-
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic='-DDLL_EXPORT'
-      ;;
-
-    hpux9* | hpux10* | hpux11*)
-      lt_prog_compiler_wl='-Wl,'
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic='+Z'
-	;;
-      esac
-      # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static='${wl}-a ${wl}archive'
-      ;;
-
-    irix5* | irix6* | nonstopux*)
-      lt_prog_compiler_wl='-Wl,'
-      # PIC (with -KPIC) is the default.
-      lt_prog_compiler_static='-non_shared'
-      ;;
-
-    linux* | k*bsd*-gnu | kopensolaris*-gnu)
-      case $cc_basename in
-      # old Intel for x86_64 which still supported -KPIC.
-      ecc*)
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='-KPIC'
-	lt_prog_compiler_static='-static'
-        ;;
-      # icc used to be incompatible with GCC.
-      # ICC 10 doesn't accept -KPIC any more.
-      icc* | ifort*)
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='-fPIC'
-	lt_prog_compiler_static='-static'
-        ;;
-      # Lahey Fortran 8.1.
-      lf95*)
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='--shared'
-	lt_prog_compiler_static='--static'
-	;;
-      nagfor*)
-	# NAG Fortran compiler
-	lt_prog_compiler_wl='-Wl,-Wl,,'
-	lt_prog_compiler_pic='-PIC'
-	lt_prog_compiler_static='-Bstatic'
-	;;
-      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='-fpic'
-	lt_prog_compiler_static='-Bstatic'
-        ;;
-      ccc*)
-        lt_prog_compiler_wl='-Wl,'
-        # All Alpha code is PIC.
-        lt_prog_compiler_static='-non_shared'
-        ;;
-      xl* | bgxl* | bgf* | mpixl*)
-	# IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
-	lt_prog_compiler_wl='-Wl,'
-	lt_prog_compiler_pic='-qpic'
-	lt_prog_compiler_static='-qstaticlink'
-	;;
-      *)
-	case `$CC -V 2>&1 | sed 5q` in
-	*Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)
-	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
-	  lt_prog_compiler_pic='-KPIC'
-	  lt_prog_compiler_static='-Bstatic'
-	  lt_prog_compiler_wl=''
-	  ;;
-	*Sun\ F* | *Sun*Fortran*)
-	  lt_prog_compiler_pic='-KPIC'
-	  lt_prog_compiler_static='-Bstatic'
-	  lt_prog_compiler_wl='-Qoption ld '
-	  ;;
-	*Sun\ C*)
-	  # Sun C 5.9
-	  lt_prog_compiler_pic='-KPIC'
-	  lt_prog_compiler_static='-Bstatic'
-	  lt_prog_compiler_wl='-Wl,'
-	  ;;
-        *Intel*\ [CF]*Compiler*)
-	  lt_prog_compiler_wl='-Wl,'
-	  lt_prog_compiler_pic='-fPIC'
-	  lt_prog_compiler_static='-static'
-	  ;;
-	*Portland\ Group*)
-	  lt_prog_compiler_wl='-Wl,'
-	  lt_prog_compiler_pic='-fpic'
-	  lt_prog_compiler_static='-Bstatic'
-	  ;;
-	esac
-	;;
-      esac
-      ;;
-
-    newsos6)
-      lt_prog_compiler_pic='-KPIC'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
-
-    *nto* | *qnx*)
-      # QNX uses GNU C++, but need to define -shared option too, otherwise
-      # it will coredump.
-      lt_prog_compiler_pic='-fPIC -shared'
-      ;;
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    OTOOL64=$ac_ct_OTOOL64
+  fi
+else
+  OTOOL64="$ac_cv_prog_OTOOL64"
+fi
 
-    osf3* | osf4* | osf5*)
-      lt_prog_compiler_wl='-Wl,'
-      # All OSF/1 code is PIC.
-      lt_prog_compiler_static='-non_shared'
-      ;;
 
-    rdos*)
-      lt_prog_compiler_static='-non_shared'
-      ;;
 
-    solaris*)
-      lt_prog_compiler_pic='-KPIC'
-      lt_prog_compiler_static='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
-	lt_prog_compiler_wl='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl='-Wl,';;
-      esac
-      ;;
 
-    sunos4*)
-      lt_prog_compiler_wl='-Qoption ld '
-      lt_prog_compiler_pic='-PIC'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
 
-    sysv4 | sysv4.2uw2* | sysv4.3*)
-      lt_prog_compiler_wl='-Wl,'
-      lt_prog_compiler_pic='-KPIC'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
 
-    sysv4*MP*)
-      if test -d /usr/nec ;then
-	lt_prog_compiler_pic='-Kconform_pic'
-	lt_prog_compiler_static='-Bstatic'
-      fi
-      ;;
 
-    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-      lt_prog_compiler_wl='-Wl,'
-      lt_prog_compiler_pic='-KPIC'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
 
-    unicos*)
-      lt_prog_compiler_wl='-Wl,'
-      lt_prog_compiler_can_build_shared=no
-      ;;
 
-    uts4*)
-      lt_prog_compiler_pic='-pic'
-      lt_prog_compiler_static='-Bstatic'
-      ;;
 
-    *)
-      lt_prog_compiler_can_build_shared=no
-      ;;
-    esac
-  fi
 
-case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
-  *djgpp*)
-    lt_prog_compiler_pic=
-    ;;
-  *)
-    lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
-    ;;
-esac
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
-$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
-if ${lt_cv_prog_compiler_pic+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_pic=$lt_prog_compiler_pic
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5
-$as_echo "$lt_cv_prog_compiler_pic" >&6; }
-lt_prog_compiler_pic=$lt_cv_prog_compiler_pic
 
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
-$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
-if ${lt_cv_prog_compiler_pic_works+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_pic_works=no
-   ac_outfile=conftest.$ac_objext
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_pic_works=yes
-     fi
-   fi
-   $RM conftest*
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
-$as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
 
-if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
-    case $lt_prog_compiler_pic in
-     "" | " "*) ;;
-     *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
-     esac
-else
-    lt_prog_compiler_pic=
-     lt_prog_compiler_can_build_shared=no
-fi
 
-fi
 
 
 
@@ -9037,1450 +9786,866 @@ fi
 
 
 
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
-if ${lt_cv_prog_compiler_static_works+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_static_works=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
-   echo "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_cv_prog_compiler_static_works=yes
-       fi
-     else
-       lt_cv_prog_compiler_static_works=yes
-     fi
-   fi
-   $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
-$as_echo "$lt_cv_prog_compiler_static_works" >&6; }
-
-if test x"$lt_cv_prog_compiler_static_works" = xyes; then
-    :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5
+$as_echo_n "checking for -single_module linker flag... " >&6; }
+if ${lt_cv_apple_cc_single_mod+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
-    lt_prog_compiler_static=
+  lt_cv_apple_cc_single_mod=no
+      if test -z "${LT_MULTI_MODULE}"; then
+	# By default we will add the -single_module flag. You can override
+	# by either setting the environment variable LT_MULTI_MODULE
+	# non-empty at configure time, or by adding -multi_module to the
+	# link flags.
+	rm -rf libconftest.dylib*
+	echo "int foo(void){return 1;}" > conftest.c
+	echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+-dynamiclib -Wl,-single_module conftest.c" >&5
+	$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \
+	  -dynamiclib -Wl,-single_module conftest.c 2>conftest.err
+        _lt_result=$?
+	# If there is a non-empty error log, and "single_module"
+	# appears in it, assume the flag caused a linker warning
+        if test -s conftest.err && $GREP single_module conftest.err; then
+	  cat conftest.err >&5
+	# Otherwise, if the output was created with a 0 exit code from
+	# the compiler, it worked.
+	elif test -f libconftest.dylib && test $_lt_result -eq 0; then
+	  lt_cv_apple_cc_single_mod=yes
+	else
+	  cat conftest.err >&5
+	fi
+	rm -rf libconftest.dylib*
+	rm -f conftest.*
+      fi
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5
+$as_echo "$lt_cv_apple_cc_single_mod" >&6; }
 
-
-
-
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
-$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if ${lt_cv_prog_compiler_c_o+:} false; then :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5
+$as_echo_n "checking for -exported_symbols_list linker flag... " >&6; }
+if ${lt_cv_ld_exported_symbols_list+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  lt_cv_prog_compiler_c_o=no
-   $RM -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+  lt_cv_ld_exported_symbols_list=no
+      save_LDFLAGS=$LDFLAGS
+      echo "_main" > conftest.sym
+      LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $RM conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
-   $RM out/* && rmdir out
-   cd ..
-   $RM -r conftest
-   $RM conftest*
+int
+main ()
+{
 
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  lt_cv_ld_exported_symbols_list=yes
+else
+  lt_cv_ld_exported_symbols_list=no
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
-$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
-
-
-
-
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+	LDFLAGS="$save_LDFLAGS"
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5
+$as_echo "$lt_cv_ld_exported_symbols_list" >&6; }
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
-$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if ${lt_cv_prog_compiler_c_o+:} false; then :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5
+$as_echo_n "checking for -force_load linker flag... " >&6; }
+if ${lt_cv_ld_force_load+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  lt_cv_prog_compiler_c_o=no
-   $RM -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $RM conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
-   $RM out/* && rmdir out
-   cd ..
-   $RM -r conftest
-   $RM conftest*
+  lt_cv_ld_force_load=no
+      cat > conftest.c << _LT_EOF
+int forced_loaded() { return 2;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5
+      $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5
+      echo "$AR cru libconftest.a conftest.o" >&5
+      $AR cru libconftest.a conftest.o 2>&5
+      echo "$RANLIB libconftest.a" >&5
+      $RANLIB libconftest.a 2>&5
+      cat > conftest.c << _LT_EOF
+int main() { return 0;}
+_LT_EOF
+      echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5
+      $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err
+      _lt_result=$?
+      if test -s conftest.err && $GREP force_load conftest.err; then
+	cat conftest.err >&5
+      elif test -f conftest && test $_lt_result -eq 0 && $GREP forced_load conftest >/dev/null 2>&1 ; then
+	lt_cv_ld_force_load=yes
+      else
+	cat conftest.err >&5
+      fi
+        rm -f conftest.err libconftest.a conftest conftest.c
+        rm -rf conftest.dSYM
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
-$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
-
-
-
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5
+$as_echo "$lt_cv_ld_force_load" >&6; }
+    case $host_os in
+    rhapsody* | darwin1.[012])
+      _lt_dar_allow_undefined='${wl}-undefined ${wl}suppress' ;;
+    darwin1.*)
+      _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+    darwin*) # darwin 5.x on
+      # if running on 10.5 or later, the deployment target defaults
+      # to the OS version, if on x86, and 10.4, the deployment
+      # target defaults to 10.4. Don't you love it?
+      case ${MACOSX_DEPLOYMENT_TARGET-10.0},$host in
+	10.0,*86*-darwin8*|10.0,*-darwin[91]*)
+	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+	10.[012]*)
+	  _lt_dar_allow_undefined='${wl}-flat_namespace ${wl}-undefined ${wl}suppress' ;;
+	10.*)
+	  _lt_dar_allow_undefined='${wl}-undefined ${wl}dynamic_lookup' ;;
+      esac
+    ;;
+  esac
+    if test "$lt_cv_apple_cc_single_mod" = "yes"; then
+      _lt_dar_single_mod='$single_module'
+    fi
+    if test "$lt_cv_ld_exported_symbols_list" = "yes"; then
+      _lt_dar_export_syms=' ${wl}-exported_symbols_list,$output_objdir/${libname}-symbols.expsym'
+    else
+      _lt_dar_export_syms='~$NMEDIT -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    fi
+    if test "$DSYMUTIL" != ":" && test "$lt_cv_ld_force_load" = "no"; then
+      _lt_dsymutil='~$DSYMUTIL $lib || :'
+    else
+      _lt_dsymutil=
+    fi
+    ;;
+  esac
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
-$as_echo_n "checking if we can lock with hard links... " >&6; }
-  hard_links=yes
-  $RM conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
-$as_echo "$hard_links" >&6; }
-  if test "$hard_links" = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
-    need_locks=warn
-  fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if ${ac_cv_prog_CPP+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
-  need_locks=no
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
 fi
+rm -f conftest.err conftest.i conftest.$ac_ext
 
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
 
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+  break
+fi
 
+    done
+    ac_cv_prog_CPP=$CPP
 
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
 
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
 
-  runpath_var=
-  allow_undefined_flag=
-  always_export_symbols=no
-  archive_cmds=
-  archive_expsym_cmds=
-  compiler_needs_object=no
-  enable_shared_with_static_runtimes=no
-  export_dynamic_flag_spec=
-  export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  hardcode_automatic=no
-  hardcode_direct=no
-  hardcode_direct_absolute=no
-  hardcode_libdir_flag_spec=
-  hardcode_libdir_separator=
-  hardcode_minus_L=no
-  hardcode_shlibpath_var=unsupported
-  inherit_rpath=no
-  link_all_deplibs=unknown
-  module_cmds=
-  module_expsym_cmds=
-  old_archive_from_new_cmds=
-  old_archive_from_expsyms_cmds=
-  thread_safe_flag_spec=
-  whole_archive_flag_spec=
-  # include_expsyms should be a list of space-separated symbols to be *always*
-  # included in the symbol list
-  include_expsyms=
-  # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
-  exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
-  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
-  # platforms (ab)use it in PIC code, but their linkers get confused if
-  # the symbol is explicitly referenced.  Since portable code cannot
-  # rely on this symbol name, it's probably fine to never include it in
-  # preloaded symbol tables.
-  # Exclude shared library initialization/finalization symbols.
-  extract_expsyms_cmds=
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
 
-  case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
-    # FIXME: the MSVC++ port hasn't been tested in a loooong time
-    # When not using gcc, we currently assume that we are using
-    # Microsoft Visual C++.
-    if test "$GCC" != yes; then
-      with_gnu_ld=no
-    fi
-    ;;
-  interix*)
-    # we just hope/assume this is gcc and not c89 (= MSVC++)
-    with_gnu_ld=yes
-    ;;
-  openbsd*)
-    with_gnu_ld=no
-    ;;
-  esac
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
 
-  ld_shlibs=yes
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-  # On some targets, GNU ld is compatible enough with the native linker
-  # that we're better off using the native interface for both.
-  lt_use_gnu_ld_interface=no
-  if test "$with_gnu_ld" = yes; then
-    case $host_os in
-      aix*)
-	# The AIX port of GNU ld has always aspired to compatibility
-	# with the native linker.  However, as the warning in the GNU ld
-	# block says, versions before 2.19.5* couldn't really create working
-	# shared libraries, regardless of the interface used.
-	case `$LD -v 2>&1` in
-	  *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
-	  *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;;
-	  *\ \(GNU\ Binutils\)\ [3-9]*) ;;
-	  *)
-	    lt_use_gnu_ld_interface=yes
-	    ;;
-	esac
-	;;
-      *)
-	lt_use_gnu_ld_interface=yes
-	;;
-    esac
-  fi
 
-  if test "$lt_use_gnu_ld_interface" = yes; then
-    # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if ${ac_cv_header_stdc+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-    export_dynamic_flag_spec='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-    else
-      whole_archive_flag_spec=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>&1` in
-      *GNU\ gold*) supports_anon_versioning=yes ;;
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
+int
+main ()
+{
 
-    # See if GNU ld supports shared libraries.
-    case $host_os in
-    aix[3-9]*)
-      # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
-	ld_shlibs=no
-	cat <<_LT_EOF 1>&2
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-*** Warning: the GNU linker, at least up to release 2.19, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support.  If you
-*** really care for shared libraries, you may want to install binutils
-*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
-*** You will then need to restart the configuration process.
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
 
-_LT_EOF
-      fi
-      ;;
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
 
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-            archive_expsym_cmds=''
-        ;;
-      m68k)
-            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-            hardcode_libdir_flag_spec='-L$libdir'
-            hardcode_minus_L=yes
-        ;;
-      esac
-      ;;
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
 
-    beos*)
-      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	allow_undefined_flag=unsupported
-	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-      else
-	ld_shlibs=no
-      fi
-      ;;
+fi
 
-    cygwin* | mingw* | pw32* | cegcc*)
-      # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
-      # as there is no search path for DLLs.
-      hardcode_libdir_flag_spec='-L$libdir'
-      export_dynamic_flag_spec='${wl}--export-all-symbols'
-      allow_undefined_flag=unsupported
-      always_export_symbols=no
-      enable_shared_with_static_runtimes=yes
-      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
-      exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
 
-      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-      else
-	ld_shlibs=no
-      fi
-      ;;
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
 
-    haiku*)
-      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-      link_all_deplibs=yes
-      ;;
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
 
-    interix[3-9]*)
-      hardcode_direct=no
-      hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec='${wl}-E'
-      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-      # Instead, shared libraries are loaded at an image base (0x10000000 by
-      # default) and relocated if they conflict, which is a slow very memory
-      # consuming and fragmenting process.  To avoid this, we pick a random,
-      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      ;;
+fi
 
-    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
-      tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
-	case $cc_basename in
-	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
-	esac
-      fi
-      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
-      then
-	tmp_addflag=' $pic_flag'
-	tmp_sharedflag='-shared'
-	case $cc_basename,$host_cpu in
-        pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95* | pgfortran*)
-					# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	lf95*)				# Lahey Fortran 8.1
-	  whole_archive_flag_spec=
-	  tmp_sharedflag='--shared' ;;
-        nagfor*)                        # NAGFOR 5.3
-          tmp_sharedflag='-Wl,-shared' ;;
-	xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
-	  tmp_sharedflag='-qmkshrobj'
-	  tmp_addflag= ;;
-	nvcc*)	# Cuda Compiler Driver 2.2
-	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	  compiler_needs_object=yes
-	  ;;
-	esac
-	case `$CC -V 2>&1 | sed 5q` in
-	*Sun\ C*)			# Sun C 5.9
-	  whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	  compiler_needs_object=yes
-	  tmp_sharedflag='-G' ;;
-	*Sun\ F*)			# Sun Fortran 8.3
-	  tmp_sharedflag='-G' ;;
-	esac
-	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+		   (('a' <= (c) && (c) <= 'i') \
+		     || ('j' <= (c) && (c) <= 'r') \
+		     || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
 
-        if test "x$supports_anon_versioning" = xyes; then
-          archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-        fi
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+	|| toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
 
-	case $cc_basename in
-	xlf* | bgf* | bgxlf* | mpixlf*)
-	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
-	  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
-	  hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-	  archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
-	  if test "x$supports_anon_versioning" = xyes; then
-	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
-	  fi
-	  ;;
-	esac
-      else
-        ld_shlibs=no
-      fi
-      ;;
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
 
-    netbsd*)
-      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
-	wlarc=
-      else
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      fi
-      ;;
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
 
-    solaris*)
-      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
-	ld_shlibs=no
-	cat <<_LT_EOF 1>&2
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
 
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
+fi
 
-_LT_EOF
-      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs=no
-      fi
-      ;;
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+		  inttypes.h stdint.h unistd.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+if eval test \"x\$"$as_ac_Header"\" = x"yes"; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
 
-    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
-      case `$LD -v 2>&1` in
-        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
-	ld_shlibs=no
-	cat <<_LT_EOF 1>&2
+fi
+
+done
+
+
+for ac_header in dlfcn.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default
+"
+if test "x$ac_cv_header_dlfcn_h" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DLFCN_H 1
+_ACEOF
+
+fi
+
+done
+
+
+
+
+func_stripname_cnf ()
+{
+  case ${2} in
+  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
+  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+  esac
+} # func_stripname_cnf
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
 
-_LT_EOF
-	;;
-	*)
-	  # For security reasons, it is highly recommended that you always
-	  # use absolute paths for naming shared libraries, and exclude the
-	  # DT_RUNPATH tag from executables and libraries.  But doing so
-	  # requires that you compile everything twice, which is a pain.
-	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  else
-	    ld_shlibs=no
-	  fi
-	;;
-      esac
-      ;;
 
-    sunos4*)
-      archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      wlarc=
-      hardcode_direct=yes
-      hardcode_shlibpath_var=no
-      ;;
 
+
+
+# Set options
+
+# Check whether --with-pic was given.
+if test "${with_pic+set}" = set; then :
+  withval=$with_pic; lt_p=${PACKAGE-default}
+    case $withval in
+    yes|no) pic_mode=$withval ;;
     *)
-      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs=no
-      fi
+      pic_mode=default
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for lt_pkg in $withval; do
+	IFS="$lt_save_ifs"
+	if test "X$lt_pkg" = "X$lt_p"; then
+	  pic_mode=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
       ;;
     esac
+else
+  pic_mode=default
+fi
 
-    if test "$ld_shlibs" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec=
-      export_dynamic_flag_spec=
-      whole_archive_flag_spec=
-    fi
-  else
-    # PORTME fill in a description of your system's linker (not GNU ld)
-    case $host_os in
-    aix3*)
-      allow_undefined_flag=unsupported
-      always_export_symbols=yes
-      archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
-      # Note: this linker hardcodes the directories in LIBPATH if there
-      # are no directories specified by -L.
-      hardcode_minus_L=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
-	# Neither direct hardcoding nor static linking is supported with a
-	# broken collect2.
-	hardcode_direct=unsupported
-      fi
-      ;;
 
-    aix[4-9]*)
-      if test "$host_cpu" = ia64; then
-	# On IA64, the linker does run time linking by default, so we don't
-	# have to do anything special.
-	aix_use_runtimelinking=no
-	exp_sym_flag='-Bexport'
-	no_entry_flag=""
-      else
-	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	# Also, AIX nm treats weak defined symbols like other global
-	# defined symbols, whereas GNU nm marks them as "W".
-	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
-	else
-	  export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
-	fi
-	aix_use_runtimelinking=no
+test -z "$pic_mode" && pic_mode=yes
 
-	# Test if we are trying to use run time linking or normal
-	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
-	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
-	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
-	    aix_use_runtimelinking=yes
-	    break
-	  fi
-	  done
-	  ;;
-	esac
 
-	exp_sym_flag='-bexport'
-	no_entry_flag='-bnoentry'
-      fi
 
-      # When large executables or shared objects are built, AIX ld can
-      # have problems creating the table of contents.  If linking a library
-      # or program results in "error TOC overflow" add -mminimal-toc to
-      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
 
-      archive_cmds=''
-      hardcode_direct=yes
-      hardcode_direct_absolute=yes
-      hardcode_libdir_separator=':'
-      link_all_deplibs=yes
-      file_list_spec='${wl}-f,'
 
-      if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
-	# We only want to do this on AIX 4.2 and lower, the check
-	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
-	  if test -f "$collect2name" &&
-	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
-	  then
-	  # We have reworked collect2
-	  :
-	  else
-	  # We have old collect2
-	  hardcode_direct=unsupported
-	  # It fails to find uninstalled libraries when the uninstalled
-	  # path is not listed in the libpath.  Setting hardcode_minus_L
-	  # to unsupported forces relinking
-	  hardcode_minus_L=yes
-	  hardcode_libdir_flag_spec='-L$libdir'
-	  hardcode_libdir_separator=
-	  fi
-	  ;;
-	esac
-	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
-      else
-	# not using gcc
-	if test "$host_cpu" = ia64; then
-	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-	# chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
-	  else
-	    shared_flag='${wl}-bM:SRE'
-	  fi
-	fi
-      fi
 
-      export_dynamic_flag_spec='${wl}-bexpall'
-      # It seems that -bexpall does not export symbols beginning with
-      # underscore (_), so it is better to generate a list of symbols to export.
-      always_export_symbols=yes
-      if test "$aix_use_runtimelinking" = yes; then
-	# Warning - without using the other runtime loading flags (-brtl),
-	# -berok will link without error, but may produce a broken library.
-	allow_undefined_flag='-berok'
-        # Determine the default libpath from the value encoded in an
-        # empty executable.
-        if test "${lt_cv_aix_libpath+set}" = set; then
-  aix_libpath=$lt_cv_aix_libpath
-else
-  if ${lt_cv_aix_libpath_+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-int
-main ()
-{
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
+        enable_dlopen=no
 
-  lt_aix_libpath_sed='
-      /Import File Strings/,/^$/ {
-	  /^0/ {
-	      s/^0  *\([^ ]*\) *$/\1/
-	      p
-	  }
-      }'
-  lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  # Check for a 64-bit object if we didn't find anything.
-  if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  fi
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_="/usr/lib:/lib"
-  fi
 
-fi
+  enable_win32_dll=no
 
-  aix_libpath=$lt_cv_aix_libpath_
-fi
 
-        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
-        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-      else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
-	  allow_undefined_flag="-z nodefs"
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-	else
-	 # Determine the default libpath from the value encoded in an
-	 # empty executable.
-	 if test "${lt_cv_aix_libpath+set}" = set; then
-  aix_libpath=$lt_cv_aix_libpath
-else
-  if ${lt_cv_aix_libpath_+:} false; then :
-  $as_echo_n "(cached) " >&6
+            # Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then :
+  enableval=$enable_shared; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_shared=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
 else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+  enable_shared=yes
+fi
 
-int
-main ()
-{
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
 
-  lt_aix_libpath_sed='
-      /Import File Strings/,/^$/ {
-	  /^0/ {
-	      s/^0  *\([^ ]*\) *$/\1/
-	      p
-	  }
-      }'
-  lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  # Check for a 64-bit object if we didn't find anything.
-  if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  fi
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  if test -z "$lt_cv_aix_libpath_"; then
-    lt_cv_aix_libpath_="/usr/lib:/lib"
-  fi
 
-fi
 
-  aix_libpath=$lt_cv_aix_libpath_
-fi
 
-	 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
-	  # Warning - without using the other run time loading flags,
-	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag=' ${wl}-bernotok'
-	  allow_undefined_flag=' ${wl}-berok'
-	  if test "$with_gnu_ld" = yes; then
-	    # We only use this code for GNU lds that support --whole-archive.
-	    whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
-	  else
-	    # Exported symbols can be pulled into shared objects from archives
-	    whole_archive_flag_spec='$convenience'
-	  fi
-	  archive_cmds_need_lc=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-	fi
-      fi
-      ;;
 
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-            archive_expsym_cmds=''
-        ;;
-      m68k)
-            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-            hardcode_libdir_flag_spec='-L$libdir'
-            hardcode_minus_L=yes
-        ;;
-      esac
-      ;;
 
-    bsdi[45]*)
-      export_dynamic_flag_spec=-rdynamic
-      ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
-      # When not using gcc, we currently assume that we are using
-      # Microsoft Visual C++.
-      # hardcode_libdir_flag_spec is actually meaningless, as there is
-      # no search path for DLLs.
-      case $cc_basename in
-      cl*)
-	# Native MSVC
-	hardcode_libdir_flag_spec=' '
-	allow_undefined_flag=unsupported
-	always_export_symbols=yes
-	file_list_spec='@'
-	# Tell ltmain to make .lib files, not .a files.
-	libext=lib
-	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
-	# FIXME: Setting linknames here is a bad hack.
-	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	  else
-	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	  fi~
-	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	  linknames='
-	# The linker will not automatically build a static lib if we build a DLL.
-	# _LT_TAGVAR(old_archive_from_new_cmds, )='true'
-	enable_shared_with_static_runtimes=yes
-	exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
-	export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
-	# Don't use ranlib
-	old_postinstall_cmds='chmod 644 $oldlib'
-	postlink_cmds='lt_outputfile="@OUTPUT@"~
-	  lt_tool_outputfile="@TOOL_OUTPUT@"~
-	  case $lt_outputfile in
-	    *.exe|*.EXE) ;;
-	    *)
-	      lt_outputfile="$lt_outputfile.exe"
-	      lt_tool_outputfile="$lt_tool_outputfile.exe"
-	      ;;
-	  esac~
-	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	    $RM "$lt_outputfile.manifest";
-	  fi'
-	;;
-      *)
-	# Assume MSVC wrapper
-	hardcode_libdir_flag_spec=' '
-	allow_undefined_flag=unsupported
-	# Tell ltmain to make .lib files, not .a files.
-	libext=lib
-	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
-	# FIXME: Setting linknames here is a bad hack.
-	archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
-	# The linker will automatically build a .lib file if we build a DLL.
-	old_archive_from_new_cmds='true'
-	# FIXME: Should let the user specify the lib program.
-	old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
-	enable_shared_with_static_runtimes=yes
-	;;
-      esac
+  # Check whether --enable-static was given.
+if test "${enable_static+set}" = set; then :
+  enableval=$enable_static; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_static=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
       ;;
+    esac
+else
+  enable_static=yes
+fi
 
-    darwin* | rhapsody*)
 
 
-  archive_cmds_need_lc=no
-  hardcode_direct=no
-  hardcode_automatic=yes
-  hardcode_shlibpath_var=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
 
-  else
-    whole_archive_flag_spec=''
-  fi
-  link_all_deplibs=yes
-  allow_undefined_flag="$_lt_dar_allow_undefined"
-  case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
-     *) _lt_dar_can_shared=$GCC ;;
-  esac
-  if test "$_lt_dar_can_shared" = "yes"; then
-    output_verbose_link_cmd=func_echo_all
-    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
 
-  else
-  ld_shlibs=no
-  fi
 
-      ;;
 
-    dgux*)
-      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_shlibpath_var=no
-      ;;
 
-    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
-    # support.  Future versions do this automatically, but an explicit c++rt0.o
-    # does not break anything, and helps significantly (at the cost of a little
-    # extra space).
-    freebsd2.2*)
-      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
-      hardcode_libdir_flag_spec='-R$libdir'
-      hardcode_direct=yes
-      hardcode_shlibpath_var=no
-      ;;
 
-    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2.*)
-      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct=yes
-      hardcode_minus_L=yes
-      hardcode_shlibpath_var=no
-      ;;
 
-    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | dragonfly*)
-      archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-      hardcode_libdir_flag_spec='-R$libdir'
-      hardcode_direct=yes
-      hardcode_shlibpath_var=no
+  # Check whether --enable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then :
+  enableval=$enable_fast_install; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+	IFS="$lt_save_ifs"
+	if test "X$pkg" = "X$p"; then
+	  enable_fast_install=yes
+	fi
+      done
+      IFS="$lt_save_ifs"
       ;;
+    esac
+else
+  enable_fast_install=yes
+fi
 
-    hpux9*)
-      if test "$GCC" = yes; then
-	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      else
-	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      fi
-      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
-      hardcode_libdir_separator=:
-      hardcode_direct=yes
 
-      # hardcode_minus_L: Not really in the search PATH,
-      # but as the default location of the library.
-      hardcode_minus_L=yes
-      export_dynamic_flag_spec='${wl}-E'
-      ;;
 
-    hpux10*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator=:
-	hardcode_direct=yes
-	hardcode_direct_absolute=yes
-	export_dynamic_flag_spec='${wl}-E'
-	# hardcode_minus_L: Not really in the search PATH,
-	# but as the default location of the library.
-	hardcode_minus_L=yes
-      fi
-      ;;
 
-    hpux11*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      else
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
 
-	  # Older versions of the 11.00 compiler do not understand -b yet
-	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
-	  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
-$as_echo_n "checking if $CC understands -b... " >&6; }
-if ${lt_cv_prog_compiler__b+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler__b=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS -b"
-   echo "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_cv_prog_compiler__b=yes
-       fi
-     else
-       lt_cv_prog_compiler__b=yes
-     fi
-   fi
-   $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
-$as_echo "$lt_cv_prog_compiler__b" >&6; }
 
-if test x"$lt_cv_prog_compiler__b" = xyes; then
-    archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-else
-    archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-fi
 
-	  ;;
-	esac
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator=:
 
-	case $host_cpu in
-	hppa*64*|ia64*)
-	  hardcode_direct=no
-	  hardcode_shlibpath_var=no
-	  ;;
-	*)
-	  hardcode_direct=yes
-	  hardcode_direct_absolute=yes
-	  export_dynamic_flag_spec='${wl}-E'
 
-	  # hardcode_minus_L: Not really in the search PATH,
-	  # but as the default location of the library.
-	  hardcode_minus_L=yes
-	  ;;
-	esac
-      fi
-      ;;
 
-    irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	# Try to use the -exported_symbol ld option, if it does not
-	# work, assume that -exports_file does not work either and
-	# implicitly export all symbols.
-	# This should be the same for all languages, so no per-tag cache variable.
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5
-$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; }
-if ${lt_cv_irix_exported_symbol+:} false; then :
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ltmain"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+test -z "$LN_S" && LN_S="ln -s"
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+if test -n "${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
+$as_echo_n "checking for objdir... " >&6; }
+if ${lt_cv_objdir+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  save_LDFLAGS="$LDFLAGS"
-	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
-	   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-int foo (void) { return 0; }
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  lt_cv_irix_exported_symbol=yes
+  rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
 else
-  lt_cv_irix_exported_symbol=no
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-           LDFLAGS="$save_LDFLAGS"
+rmdir .libs 2>/dev/null
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
-$as_echo "$lt_cv_irix_exported_symbol" >&6; }
-	if test "$lt_cv_irix_exported_symbol" = yes; then
-          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
-	fi
-      else
-	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
-      fi
-      archive_cmds_need_lc='no'
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator=:
-      inherit_rpath=yes
-      link_all_deplibs=yes
-      ;;
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
+$as_echo "$lt_cv_objdir" >&6; }
+objdir=$lt_cv_objdir
 
-    netbsd*)
-      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
-      else
-	archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
-      fi
-      hardcode_libdir_flag_spec='-R$libdir'
-      hardcode_direct=yes
-      hardcode_shlibpath_var=no
-      ;;
 
-    newsos6)
-      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct=yes
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator=:
-      hardcode_shlibpath_var=no
-      ;;
 
-    *nto* | *qnx*)
-      ;;
 
-    openbsd*)
-      if test -f /usr/libexec/ld.so; then
-	hardcode_direct=yes
-	hardcode_shlibpath_var=no
-	hardcode_direct_absolute=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	  export_dynamic_flag_spec='${wl}-E'
-	else
-	  case $host_os in
-	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	     archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     hardcode_libdir_flag_spec='-R$libdir'
-	     ;;
-	   *)
-	     archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
-	     ;;
-	  esac
-	fi
-      else
-	ld_shlibs=no
-      fi
-      ;;
-
-    os2*)
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_minus_L=yes
-      allow_undefined_flag=unsupported
-      archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
-      ;;
-
-    osf3*)
-      if test "$GCC" = yes; then
-	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-      fi
-      archive_cmds_need_lc='no'
-      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator=:
-      ;;
-
-    osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
-      else
-	allow_undefined_flag=' -expect_unresolved \*'
-	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
-
-	# Both c and cxx compiler support -rpath directly
-	hardcode_libdir_flag_spec='-rpath $libdir'
-      fi
-      archive_cmds_need_lc='no'
-      hardcode_libdir_separator=:
-      ;;
-
-    solaris*)
-      no_undefined_flag=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
-      else
-	case `$CC -V 2>&1` in
-	*"Compilers 5.0"*)
-	  wlarc=''
-	  archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
-	  ;;
-	*)
-	  wlarc='${wl}'
-	  archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
-	  ;;
-	esac
-      fi
-      hardcode_libdir_flag_spec='-R$libdir'
-      hardcode_shlibpath_var=no
-      case $host_os in
-      solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
-	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
-	# but is careful enough not to reorder.
-	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
-	else
-	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
-	fi
-	;;
-      esac
-      link_all_deplibs=yes
-      ;;
-
-    sunos4*)
-      if test "x$host_vendor" = xsequent; then
-	# Use $CC to link under sequent, because it throws in some extra .o
-	# files that make .init and .fini sections work.
-	archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_direct=yes
-      hardcode_minus_L=yes
-      hardcode_shlibpath_var=no
-      ;;
-
-    sysv4)
-      case $host_vendor in
-	sni)
-	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct=yes # is this really true???
-	;;
-	siemens)
-	  ## LD is ld it makes a PLAMLIB
-	  ## CC just makes a GrossModule.
-	  archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-	  reload_cmds='$CC -r -o $output$reload_objs'
-	  hardcode_direct=no
-        ;;
-	motorola)
-	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct=no #Motorola manual says yes, but my tests say they lie
-	;;
-      esac
-      runpath_var='LD_RUN_PATH'
-      hardcode_shlibpath_var=no
-      ;;
-
-    sysv4.3*)
-      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_shlibpath_var=no
-      export_dynamic_flag_spec='-Bexport'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	hardcode_shlibpath_var=no
-	runpath_var=LD_RUN_PATH
-	hardcode_runpath_var=yes
-	ld_shlibs=yes
-      fi
-      ;;
-
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag='${wl}-z,text'
-      archive_cmds_need_lc=no
-      hardcode_shlibpath_var=no
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
 
-    sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
-      # link with -lc, and that would cause any symbols used from libc to
-      # always be unresolved, which means just about no library would
-      # ever link correctly.  If we're not using GNU ld we use -z text
-      # though, which does catch some bad symbols but isn't as heavy-handed
-      # as -z defs.
-      no_undefined_flag='${wl}-z,text'
-      allow_undefined_flag='${wl}-z,nodefs'
-      archive_cmds_need_lc=no
-      hardcode_shlibpath_var=no
-      hardcode_libdir_flag_spec='${wl}-R,$libdir'
-      hardcode_libdir_separator=':'
-      link_all_deplibs=yes
-      export_dynamic_flag_spec='${wl}-Bexport'
-      runpath_var='LD_RUN_PATH'
+cat >>confdefs.h <<_ACEOF
+#define LT_OBJDIR "$lt_cv_objdir/"
+_ACEOF
 
-      if test "$GCC" = yes; then
-	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
 
-    uts4*)
-      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec='-L$libdir'
-      hardcode_shlibpath_var=no
-      ;;
 
-    *)
-      ld_shlibs=no
-      ;;
-    esac
 
-    if test x$host_vendor = xsni; then
-      case $host in
-      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	export_dynamic_flag_spec='${wl}-Blargedynsym'
-	;;
-      esac
-    fi
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
   fi
+  ;;
+esac
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
-$as_echo "$ld_shlibs" >&6; }
-test "$ld_shlibs" = no && can_build_shared=no
-
-with_gnu_ld=$with_gnu_ld
-
+# Global variables:
+ofile=libtool
+can_build_shared=yes
 
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
 
+with_gnu_ld="$lt_cv_prog_gnu_ld"
 
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
 
+# Set sane defaults for various variables
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS
+test -z "$LD" && LD=ld
+test -z "$ac_objext" && ac_objext=o
 
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
 
 
-
-
-
-
-
-
-
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc" in
-x|xyes)
-  # Assume -lc should be added
-  archive_cmds_need_lc=yes
-
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
-    case $archive_cmds in
-    *'~'*)
-      # FIXME: we may have to deal with multi-command sequences.
-      ;;
-    '$CC '*)
-      # Test whether the compiler implicitly links with -lc since on some
-      # systems, -lgcc has to come before -lc. If gcc already passes -lc
-      # to ld, don't add -lc before -lgcc.
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
-$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
-if ${lt_cv_archive_cmds_need_lc+:} false; then :
+# Only perform the check for file, if the check method requires it
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
+$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
+if ${lt_cv_path_MAGIC_CMD+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  $RM conftest*
-	echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-	if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } 2>conftest.err; then
-	  soname=conftest
-	  lib=conftest
-	  libobjs=conftest.$ac_objext
-	  deplibs=
-	  wl=$lt_prog_compiler_wl
-	  pic_flag=$lt_prog_compiler_pic
-	  compiler_flags=-v
-	  linker_flags=-v
-	  verstring=
-	  output_objdir=.
-	  libname=conftest
-	  lt_save_allow_undefined_flag=$allow_undefined_flag
-	  allow_undefined_flag=
-	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
-  (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-	  then
-	    lt_cv_archive_cmds_need_lc=no
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/${ac_tool_prefix}file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    $EGREP "$file_magic_regex" > /dev/null; then
+	    :
 	  else
-	    lt_cv_archive_cmds_need_lc=yes
-	  fi
-	  allow_undefined_flag=$lt_save_allow_undefined_flag
-	else
-	  cat conftest.err 1>&5
-	fi
-	$RM conftest*
+	    cat <<_LT_EOF 1>&2
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5
-$as_echo "$lt_cv_archive_cmds_need_lc" >&6; }
-      archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc
-      ;;
-    esac
-  fi
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool at gnu.org
+
+_LT_EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
   ;;
 esac
+fi
 
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
 
 
 
 
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
+$as_echo_n "checking for file... " >&6; }
+if ${lt_cv_path_MAGIC_CMD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+      if test -n "$file_magic_test_file"; then
+	case $deplibs_check_method in
+	"file_magic "*)
+	  file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+	  MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+	  if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+	    $EGREP "$file_magic_regex" > /dev/null; then
+	    :
+	  else
+	    cat <<_LT_EOF 1>&2
 
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool at gnu.org
 
+_LT_EOF
+	  fi ;;
+	esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
 
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
 
 
+  else
+    MAGIC_CMD=:
+  fi
+fi
 
+  fi
+  ;;
+esac
 
+# Use C for the default configuration in the libtool script
 
+lt_save_CC="$CC"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
+# Source file extension for C test sources.
+ac_ext=c
 
+# Object file extension for compiled C test sources.
+objext=o
+objext=$objext
 
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;"
 
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}'
 
 
 
@@ -10488,62 +10653,475 @@ esac
 
 
 
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
 
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
 
+# Allow CC to be a program name with arguments.
+compiler=$CC
 
+# Save the default compiler, since it gets overwritten when the other
+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.
+compiler_DEFAULT=$CC
 
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
 
+ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
 
 
+## CAVEAT EMPTOR:
+## There is no encapsulation within the following macros, do not change
+## the running order or otherwise move them around unless you know exactly
+## what you are doing...
+if test -n "$compiler"; then
 
+lt_prog_compiler_no_builtin_flag=
 
+if test "$GCC" = yes; then
+  case $cc_basename in
+  nvcc*)
+    lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;
+  *)
+    lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;;
+  esac
 
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+if ${lt_cv_prog_compiler_rtti_exceptions+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_rtti_exceptions=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_rtti_exceptions=yes
+     fi
+   fi
+   $RM conftest*
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
 
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+    lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+    :
+fi
 
+fi
 
 
 
 
 
 
+  lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
 
 
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl='-Wl,'
+    lt_prog_compiler_static='-static'
 
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
 
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            lt_prog_compiler_pic='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
 
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
 
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
 
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      ;;
 
+    haiku*)
+      # PIC is the default for Haiku.
+      # The "-static" flag exists, but is broken.
+      lt_prog_compiler_static=
+      ;;
 
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic='-fPIC'
+	;;
+      esac
+      ;;
 
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
 
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared=no
+      enable_shared=no
+      ;;
 
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic='-fPIC -shared'
+      ;;
 
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic=-Kconform_pic
+      fi
+      ;;
 
+    *)
+      lt_prog_compiler_pic='-fPIC'
+      ;;
+    esac
 
+    case $cc_basename in
+    nvcc*) # Cuda Compiler Driver 2.2
+      lt_prog_compiler_wl='-Xlinker '
+      if test -n "$lt_prog_compiler_pic"; then
+        lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic"
+      fi
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static='-Bstatic'
+      else
+	lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
 
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
 
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static='${wl}-a ${wl}archive'
+      ;;
 
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static='-non_shared'
+      ;;
 
+    linux* | k*bsd*-gnu | kopensolaris*-gnu)
+      case $cc_basename in
+      # old Intel for x86_64 which still supported -KPIC.
+      ecc*)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-KPIC'
+	lt_prog_compiler_static='-static'
+        ;;
+      # icc used to be incompatible with GCC.
+      # ICC 10 doesn't accept -KPIC any more.
+      icc* | ifort*)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-fPIC'
+	lt_prog_compiler_static='-static'
+        ;;
+      # Lahey Fortran 8.1.
+      lf95*)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='--shared'
+	lt_prog_compiler_static='--static'
+	;;
+      nagfor*)
+	# NAG Fortran compiler
+	lt_prog_compiler_wl='-Wl,-Wl,,'
+	lt_prog_compiler_pic='-PIC'
+	lt_prog_compiler_static='-Bstatic'
+	;;
+      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-fpic'
+	lt_prog_compiler_static='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static='-non_shared'
+        ;;
+      xl* | bgxl* | bgf* | mpixl*)
+	# IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
+	lt_prog_compiler_wl='-Wl,'
+	lt_prog_compiler_pic='-qpic'
+	lt_prog_compiler_static='-qstaticlink'
+	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl=''
+	  ;;
+	*Sun\ F* | *Sun*Fortran*)
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl='-Qoption ld '
+	  ;;
+	*Sun\ C*)
+	  # Sun C 5.9
+	  lt_prog_compiler_pic='-KPIC'
+	  lt_prog_compiler_static='-Bstatic'
+	  lt_prog_compiler_wl='-Wl,'
+	  ;;
+        *Intel*\ [CF]*Compiler*)
+	  lt_prog_compiler_wl='-Wl,'
+	  lt_prog_compiler_pic='-fPIC'
+	  lt_prog_compiler_static='-static'
+	  ;;
+	*Portland\ Group*)
+	  lt_prog_compiler_wl='-Wl,'
+	  lt_prog_compiler_pic='-fpic'
+	  lt_prog_compiler_static='-Bstatic'
+	  ;;
+	esac
+	;;
+      esac
+      ;;
 
+    newsos6)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
 
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic='-fPIC -shared'
+      ;;
 
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static='-non_shared'
+      ;;
 
+    rdos*)
+      lt_prog_compiler_static='-non_shared'
+      ;;
 
+    solaris*)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
+	lt_prog_compiler_wl='-Qoption ld ';;
+      *)
+	lt_prog_compiler_wl='-Wl,';;
+      esac
+      ;;
 
+    sunos4*)
+      lt_prog_compiler_wl='-Qoption ld '
+      lt_prog_compiler_pic='-PIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
 
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
 
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	lt_prog_compiler_pic='-Kconform_pic'
+	lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
 
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
 
+    unicos*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_can_build_shared=no
+      ;;
 
+    uts4*)
+      lt_prog_compiler_pic='-pic'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
 
+    *)
+      lt_prog_compiler_can_build_shared=no
+      ;;
+    esac
+  fi
 
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic=
+    ;;
+  *)
+    lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+    ;;
+esac
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+if ${lt_cv_prog_compiler_pic+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic=$lt_prog_compiler_pic
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5
+$as_echo "$lt_cv_prog_compiler_pic" >&6; }
+lt_prog_compiler_pic=$lt_cv_prog_compiler_pic
 
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
+if ${lt_cv_prog_compiler_pic_works+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic_works=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works=yes
+     fi
+   fi
+   $RM conftest*
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works" >&6; }
 
+if test x"$lt_cv_prog_compiler_pic_works" = xyes; then
+    case $lt_prog_compiler_pic in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+     esac
+else
+    lt_prog_compiler_pic=
+     lt_prog_compiler_can_build_shared=no
+fi
 
+fi
 
 
 
@@ -10555,8 +11133,46 @@ esac
 
 
 
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if ${lt_cv_prog_compiler_static_works+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_static_works=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5
+$as_echo "$lt_cv_prog_compiler_static_works" >&6; }
 
+if test x"$lt_cv_prog_compiler_static_works" = xyes; then
+    :
+else
+    lt_prog_compiler_static=
+fi
 
 
 
@@ -10564,557 +11180,632 @@ esac
 
 
 
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
 
 
 
 
 
 
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
 
 
 
 
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
 
 
 
 
 
 
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
 
+  runpath_var=
+  allow_undefined_flag=
+  always_export_symbols=no
+  archive_cmds=
+  archive_expsym_cmds=
+  compiler_needs_object=no
+  enable_shared_with_static_runtimes=no
+  export_dynamic_flag_spec=
+  export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  hardcode_automatic=no
+  hardcode_direct=no
+  hardcode_direct_absolute=no
+  hardcode_libdir_flag_spec=
+  hardcode_libdir_separator=
+  hardcode_minus_L=no
+  hardcode_shlibpath_var=unsupported
+  inherit_rpath=no
+  link_all_deplibs=unknown
+  module_cmds=
+  module_expsym_cmds=
+  old_archive_from_new_cmds=
+  old_archive_from_expsyms_cmds=
+  thread_safe_flag_spec=
+  whole_archive_flag_spec=
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+  extract_expsyms_cmds=
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
-$as_echo_n "checking dynamic linker characteristics... " >&6; }
-
-if test "$GCC" = yes; then
-  case $host_os in
-    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
-    *) lt_awk_arg="/^libraries:/" ;;
-  esac
   case $host_os in
-    mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;;
-    *) lt_sed_strip_eq="s,=/,/,g" ;;
-  esac
-  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
-  case $lt_search_path_spec in
-  *\;*)
-    # if the path contains ";" then we assume it to be the separator
-    # otherwise default to the standard path separator (i.e. ":") - it is
-    # assumed that no part of a normal pathname contains ";" but that should
-    # okay in the real world where ";" in dirpaths is itself problematic.
-    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
+  cygwin* | mingw* | pw32* | cegcc*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
     ;;
-  *)
-    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
     ;;
   esac
-  # Ok, now we have the path, separated by spaces, we can step through it
-  # and add multilib dir if necessary.
-  lt_tmp_lt_search_path_spec=
-  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
-  for lt_sys_path in $lt_search_path_spec; do
-    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
-      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
-    else
-      test -d "$lt_sys_path" && \
-	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
-    fi
-  done
-  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
-BEGIN {RS=" "; FS="/|\n";} {
-  lt_foo="";
-  lt_count=0;
-  for (lt_i = NF; lt_i > 0; lt_i--) {
-    if ($lt_i != "" && $lt_i != ".") {
-      if ($lt_i == "..") {
-        lt_count++;
-      } else {
-        if (lt_count == 0) {
-          lt_foo="/" $lt_i lt_foo;
-        } else {
-          lt_count--;
-        }
-      }
-    }
-  }
-  if (lt_foo != "") { lt_freq[lt_foo]++; }
-  if (lt_freq[lt_foo] == 1) { print lt_foo; }
-}'`
-  # AWK program above erroneously prepends '/' to C:/dos/paths
-  # for these hosts.
-  case $host_os in
-    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
-      $SED 's,/\([A-Za-z]:\),\1,g'` ;;
-  esac
-  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
-else
-  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
-fi
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-need_lib_prefix=unknown
-hardcode_into_libs=no
-
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
-
-case $host_os in
-aix3*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
-  shlibpath_var=LIBPATH
 
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
-  ;;
+  ld_shlibs=yes
 
-aix[4-9]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
+  # On some targets, GNU ld is compatible enough with the native linker
+  # that we're better off using the native interface for both.
+  lt_use_gnu_ld_interface=no
+  if test "$with_gnu_ld" = yes; then
     case $host_os in
-      aix4 | aix4.[01] | aix4.[01].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
-	:
-      else
-	can_build_shared=no
-      fi
-      ;;
+      aix*)
+	# The AIX port of GNU ld has always aspired to compatibility
+	# with the native linker.  However, as the warning in the GNU ld
+	# block says, versions before 2.19.5* couldn't really create working
+	# shared libraries, regardless of the interface used.
+	case `$LD -v 2>&1` in
+	  *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
+	  *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;;
+	  *\ \(GNU\ Binutils\)\ [3-9]*) ;;
+	  *)
+	    lt_use_gnu_ld_interface=yes
+	    ;;
+	esac
+	;;
+      *)
+	lt_use_gnu_ld_interface=yes
+	;;
     esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
-      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
-      # instead of lib<name>.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
-    shlibpath_var=LIBPATH
   fi
-  ;;
 
-amigaos*)
-  case $host_cpu in
-  powerpc)
-    # Since July 2007 AmigaOS4 officially supports .so libraries.
-    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    ;;
-  m68k)
-    library_names_spec='$libname.ixlibrary $libname.a'
-    # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-    ;;
-  esac
-  ;;
-
-beos*)
-  library_names_spec='${libname}${shared_ext}'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  ;;
-
-bsdi[45]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
-
-cygwin* | mingw* | pw32* | cegcc*)
-  version_type=windows
-  shrext_cmds=".dll"
-  need_version=no
-  need_lib_prefix=no
+  if test "$lt_use_gnu_ld_interface" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
 
-  case $GCC,$cc_basename in
-  yes,*)
-    # gcc
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname~
-      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
-        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
-      fi'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $RM \$dlpath'
-    shlibpath_overrides_runpath=yes
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+    export_dynamic_flag_spec='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+      whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      whole_archive_flag_spec=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>&1` in
+      *GNU\ gold*) supports_anon_versioning=yes ;;
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
 
+    # See if GNU ld supports shared libraries.
     case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-
-      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
-      ;;
-    mingw* | cegcc*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    esac
-    dynamic_linker='Win32 ld.exe'
-    ;;
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	ld_shlibs=no
+	cat <<_LT_EOF 1>&2
 
-  *,cl*)
-    # Native MSVC
-    libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+*** Warning: the GNU linker, at least up to release 2.19, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to install binutils
+*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
+*** You will then need to restart the configuration process.
 
-    case $build_os in
-    mingw*)
-      sys_lib_search_path_spec=
-      lt_save_ifs=$IFS
-      IFS=';'
-      for lt_path in $LIB
-      do
-        IFS=$lt_save_ifs
-        # Let DOS variable expansion print the short 8.3 style file name.
-        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
-        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
-      done
-      IFS=$lt_save_ifs
-      # Convert to MSYS style.
-      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
+_LT_EOF
+      fi
       ;;
-    cygwin*)
-      # Convert to unix form, then to dos form, then back to unix form
-      # but this time dos style (no spaces!) so that the unix form looks
-      # like /cygdrive/c/PROGRA~1:/cygdr...
-      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
-      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
-      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds=''
+        ;;
+      m68k)
+            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec='-L$libdir'
+            hardcode_minus_L=yes
+        ;;
+      esac
       ;;
-    *)
-      sys_lib_search_path_spec="$LIB"
-      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
-        # It is most probably a Windows format PATH.
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+
+    beos*)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	allow_undefined_flag=unsupported
+	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
       else
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+	ld_shlibs=no
       fi
-      # FIXME: find the short name or the path components, as spaces are
-      # common. (e.g. "Program Files" -> "PROGRA~1")
       ;;
-    esac
-
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $RM \$dlpath'
-    shlibpath_overrides_runpath=yes
-    dynamic_linker='Win32 link.exe'
-    ;;
 
-  *)
-    # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
-    dynamic_linker='Win32 ld.exe'
-    ;;
-  esac
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  ;;
+    cygwin* | mingw* | pw32* | cegcc*)
+      # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec='-L$libdir'
+      export_dynamic_flag_spec='${wl}--export-all-symbols'
+      allow_undefined_flag=unsupported
+      always_export_symbols=no
+      enable_shared_with_static_runtimes=yes
+      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
+      exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
 
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
 
-  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
-  ;;
+    haiku*)
+      archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      link_all_deplibs=yes
+      ;;
 
-dgux*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
+    interix[3-9]*)
+      hardcode_direct=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[23].*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-      need_version=no
-      need_lib_prefix=no
+    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+      tmp_diet=no
+      if test "$host_os" = linux-dietlibc; then
+	case $cc_basename in
+	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
+	esac
+      fi
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+	 && test "$tmp_diet" = no
+      then
+	tmp_addflag=' $pic_flag'
+	tmp_sharedflag='-shared'
+	case $cc_basename,$host_cpu in
+        pgcc*)				# Portland Group C compiler
+	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95* | pgfortran*)
+					# Portland Group f77 and f90 compilers
+	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	lf95*)				# Lahey Fortran 8.1
+	  whole_archive_flag_spec=
+	  tmp_sharedflag='--shared' ;;
+        nagfor*)                        # NAGFOR 5.3
+          tmp_sharedflag='-Wl,-shared' ;;
+	xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+	  tmp_sharedflag='-qmkshrobj'
+	  tmp_addflag= ;;
+	nvcc*)	# Cuda Compiler Driver 2.2
+	  whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  compiler_needs_object=yes
+	  ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  whole_archive_flag_spec='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  compiler_needs_object=yes
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	esac
+	archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+        if test "x$supports_anon_versioning" = xyes; then
+          archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	    echo "local: *; };" >> $output_objdir/$libname.ver~
+	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+        fi
+
+	case $cc_basename in
+	xlf* | bgf* | bgxlf* | mpixlf*)
+	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+	  whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'
+	  hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+	  archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
+	  if test "x$supports_anon_versioning" = xyes; then
+	    archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~
+	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	      echo "local: *; };" >> $output_objdir/$libname.ver~
+	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+	  fi
+	  ;;
+	esac
+      else
+        ld_shlibs=no
+      fi
       ;;
-    freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
-      need_version=yes
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
       ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_os in
-  freebsd2.*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
-  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  *) # from 4.6 on, and DragonFly
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  esac
-  ;;
 
-gnu*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
+    solaris*)
+      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+	ld_shlibs=no
+	cat <<_LT_EOF 1>&2
 
-haiku*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
-  hardcode_into_libs=yes
-  ;;
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
 
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
-    fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  hppa*64*)
-    shrext_cmds='.sl'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
-  postinstall_cmds='chmod 555 $lib'
-  # or fails outright, so override atomically:
-  install_override_mode=555
-  ;;
+_LT_EOF
+      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
 
-interix[3-9]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+	ld_shlibs=no
+	cat <<_LT_EOF 1>&2
 
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
-    *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux # correct to gnu/linux during the next big refactor
-	else
-		version_type=irix
-	fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
-  *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  hardcode_into_libs=yes
-  ;;
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
 
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
+_LT_EOF
+	;;
+	*)
+	  # For security reasons, it is highly recommended that you always
+	  # use absolute paths for naming shared libraries, and exclude the
+	  # DT_RUNPATH tag from executables and libraries.  But doing so
+	  # requires that you compile everything twice, which is a pain.
+	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	    hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+	    archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  else
+	    ld_shlibs=no
+	  fi
+	;;
+      esac
+      ;;
 
-# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
+    sunos4*)
+      archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
 
-  # Some binutils ld are patched to set DT_RUNPATH
-  if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
+    *)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs=no
+      fi
+      ;;
+    esac
+
+    if test "$ld_shlibs" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec=
+      export_dynamic_flag_spec=
+      whole_archive_flag_spec=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag=unsupported
+      always_export_symbols=yes
+      archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	hardcode_direct=unsupported
+      fi
+      ;;
+
+    aix[4-9]*)
+      if test "$host_cpu" = ia64; then
+	# On IA64, the linker does run time linking by default, so we don't
+	# have to do anything special.
+	aix_use_runtimelinking=no
+	exp_sym_flag='-Bexport'
+	no_entry_flag=""
+      else
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	# Also, AIX nm treats weak defined symbols like other global
+	# defined symbols, whereas GNU nm marks them as "W".
+	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+	  export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	else
+	  export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	fi
+	aix_use_runtimelinking=no
+
+	# Test if we are trying to use run time linking or normal
+	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
+	# need to do runtime linking.
+	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+	  for ld_flag in $LDFLAGS; do
+	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	    aix_use_runtimelinking=yes
+	    break
+	  fi
+	  done
+	  ;;
+	esac
+
+	exp_sym_flag='-bexport'
+	no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      archive_cmds=''
+      hardcode_direct=yes
+      hardcode_direct_absolute=yes
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+      file_list_spec='${wl}-f,'
+
+      if test "$GCC" = yes; then
+	case $host_os in aix4.[012]|aix4.[012].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	  # We have reworked collect2
+	  :
+	  else
+	  # We have old collect2
+	  hardcode_direct=unsupported
+	  # It fails to find uninstalled libraries when the uninstalled
+	  # path is not listed in the libpath.  Setting hardcode_minus_L
+	  # to unsupported forces relinking
+	  hardcode_minus_L=yes
+	  hardcode_libdir_flag_spec='-L$libdir'
+	  hardcode_libdir_separator=
+	  fi
+	  ;;
+	esac
+	shared_flag='-shared'
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag="$shared_flag "'${wl}-G'
+	fi
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+	else
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag='${wl}-G'
+	  else
+	    shared_flag='${wl}-bM:SRE'
+	  fi
+	fi
+      fi
+
+      export_dynamic_flag_spec='${wl}-bexpall'
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols=yes
+      if test "$aix_use_runtimelinking" = yes; then
+	# Warning - without using the other runtime loading flags (-brtl),
+	# -berok will link without error, but may produce a broken library.
+	allow_undefined_flag='-berok'
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        if test "${lt_cv_aix_libpath+set}" = set; then
+  aix_libpath=$lt_cv_aix_libpath
+else
+  if ${lt_cv_aix_libpath_+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  lt_cv_shlibpath_overrides_runpath=no
-    save_LDFLAGS=$LDFLAGS
-    save_libdir=$libdir
-    eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
-	 LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
 
 int
@@ -11126,294 +11817,664 @@ main ()
 }
 _ACEOF
 if ac_fn_c_try_link "$LINENO"; then :
-  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
-  lt_cv_shlibpath_overrides_runpath=yes
-fi
+
+  lt_aix_libpath_sed='
+      /Import File Strings/,/^$/ {
+	  /^0/ {
+	      s/^0  *\([^ ]*\) *$/\1/
+	      p
+	  }
+      }'
+  lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  # Check for a 64-bit object if we didn't find anything.
+  if test -z "$lt_cv_aix_libpath_"; then
+    lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  fi
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
-    LDFLAGS=$save_LDFLAGS
-    libdir=$save_libdir
+  if test -z "$lt_cv_aix_libpath_"; then
+    lt_cv_aix_libpath_="/usr/lib:/lib"
+  fi
 
 fi
 
-  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+  aix_libpath=$lt_cv_aix_libpath_
+fi
 
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
+        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      else
+	if test "$host_cpu" = ia64; then
+	  hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+	  allow_undefined_flag="-z nodefs"
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an
+	 # empty executable.
+	 if test "${lt_cv_aix_libpath+set}" = set; then
+  aix_libpath=$lt_cv_aix_libpath
+else
+  if ${lt_cv_aix_libpath_+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-  # Append ld.so.conf contents to the search path
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
-  fi
+int
+main ()
+{
 
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
 
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    dynamic_linker='NetBSD ld.elf_so'
+  lt_aix_libpath_sed='
+      /Import File Strings/,/^$/ {
+	  /^0/ {
+	      s/^0  *\([^ ]*\) *$/\1/
+	      p
+	  }
+      }'
+  lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  # Check for a 64-bit object if we didn't find anything.
+  if test -z "$lt_cv_aix_libpath_"; then
+    lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  if test -z "$lt_cv_aix_libpath_"; then
+    lt_cv_aix_libpath_="/usr/lib:/lib"
   fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  ;;
 
-newsos6)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
+fi
 
-*nto* | *qnx*)
-  version_type=qnx
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='ldqnx.so'
-  ;;
+  aix_libpath=$lt_cv_aix_libpath_
+fi
 
-openbsd*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
-  need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
+	 hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  no_undefined_flag=' ${wl}-bernotok'
+	  allow_undefined_flag=' ${wl}-berok'
+	  if test "$with_gnu_ld" = yes; then
+	    # We only use this code for GNU lds that support --whole-archive.
+	    whole_archive_flag_spec='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	  else
+	    # Exported symbols can be pulled into shared objects from archives
+	    whole_archive_flag_spec='$convenience'
+	  fi
+	  archive_cmds_need_lc=yes
+	  # This is similar to how AIX traditionally builds its shared libraries.
+	  archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds=''
+        ;;
+      m68k)
+            archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec='-L$libdir'
+            hardcode_minus_L=yes
+        ;;
+      esac
+      ;;
+
+    bsdi[45]*)
+      export_dynamic_flag_spec=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32* | cegcc*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      case $cc_basename in
+      cl*)
+	# Native MSVC
+	hardcode_libdir_flag_spec=' '
+	allow_undefined_flag=unsupported
+	always_export_symbols=yes
+	file_list_spec='@'
+	# Tell ltmain to make .lib files, not .a files.
+	libext=lib
+	# Tell ltmain to make .dll files, not .so files.
+	shrext_cmds=".dll"
+	# FIXME: Setting linknames here is a bad hack.
+	archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+	archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+	  else
+	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+	  fi~
+	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+	  linknames='
+	# The linker will not automatically build a static lib if we build a DLL.
+	# _LT_TAGVAR(old_archive_from_new_cmds, )='true'
+	enable_shared_with_static_runtimes=yes
+	exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+	export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+	# Don't use ranlib
+	old_postinstall_cmds='chmod 644 $oldlib'
+	postlink_cmds='lt_outputfile="@OUTPUT@"~
+	  lt_tool_outputfile="@TOOL_OUTPUT@"~
+	  case $lt_outputfile in
+	    *.exe|*.EXE) ;;
+	    *)
+	      lt_outputfile="$lt_outputfile.exe"
+	      lt_tool_outputfile="$lt_tool_outputfile.exe"
+	      ;;
+	  esac~
+	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+	    $RM "$lt_outputfile.manifest";
+	  fi'
 	;;
       *)
-	shlibpath_overrides_runpath=yes
+	# Assume MSVC wrapper
+	hardcode_libdir_flag_spec=' '
+	allow_undefined_flag=unsupported
+	# Tell ltmain to make .lib files, not .a files.
+	libext=lib
+	# Tell ltmain to make .dll files, not .so files.
+	shrext_cmds=".dll"
+	# FIXME: Setting linknames here is a bad hack.
+	archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
+	# The linker will automatically build a .lib file if we build a DLL.
+	old_archive_from_new_cmds='true'
+	# FIXME: Should let the user specify the lib program.
+	old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'
+	enable_shared_with_static_runtimes=yes
 	;;
       esac
-  else
-    shlibpath_overrides_runpath=yes
-  fi
-  ;;
+      ;;
 
-os2*)
-  libname_spec='$name'
-  shrext_cmds=".dll"
-  need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
-  ;;
+    darwin* | rhapsody*)
 
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
-  ;;
 
-rdos*)
-  dynamic_linker=no
-  ;;
+  archive_cmds_need_lc=no
+  hardcode_direct=no
+  hardcode_automatic=yes
+  hardcode_shlibpath_var=unsupported
+  if test "$lt_cv_ld_force_load" = "yes"; then
+    whole_archive_flag_spec='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
 
-solaris*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  ;;
+  else
+    whole_archive_flag_spec=''
+  fi
+  link_all_deplibs=yes
+  allow_undefined_flag="$_lt_dar_allow_undefined"
+  case $cc_basename in
+     ifort*) _lt_dar_can_shared=yes ;;
+     *) _lt_dar_can_shared=$GCC ;;
+  esac
+  if test "$_lt_dar_can_shared" = "yes"; then
+    output_verbose_link_cmd=func_echo_all
+    archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    archive_expsym_cmds="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    module_expsym_cmds="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
 
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
+  else
+  ld_shlibs=no
   fi
-  need_version=yes
-  ;;
 
-sysv4 | sysv4.3*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      runpath_var=LD_RUN_PATH
-      ;;
-    siemens)
-      need_lib_prefix=no
       ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+
+    dgux*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
       ;;
-  esac
-  ;;
-
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
-
-tpf*)
-  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
-uts4*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-*)
-  dynamic_linker=no
-  ;;
-esac
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
-$as_echo "$dynamic_linker" >&6; }
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
-fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
-fi
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
 
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
 
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2.*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
 
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
 
+    hpux9*)
+      if test "$GCC" = yes; then
+	archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_direct=yes
 
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L=yes
+      export_dynamic_flag_spec='${wl}-E'
+      ;;
 
+    hpux10*)
+      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+	archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator=:
+	hardcode_direct=yes
+	hardcode_direct_absolute=yes
+	export_dynamic_flag_spec='${wl}-E'
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	hardcode_minus_L=yes
+      fi
+      ;;
 
+    hpux11*)
+      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
 
+	  # Older versions of the 11.00 compiler do not understand -b yet
+	  # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)
+	  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5
+$as_echo_n "checking if $CC understands -b... " >&6; }
+if ${lt_cv_prog_compiler__b+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler__b=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS -b"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler__b=yes
+       fi
+     else
+       lt_cv_prog_compiler__b=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5
+$as_echo "$lt_cv_prog_compiler__b" >&6; }
 
+if test x"$lt_cv_prog_compiler__b" = xyes; then
+    archive_cmds='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+else
+    archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+fi
 
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator=:
 
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  hardcode_direct=no
+	  hardcode_shlibpath_var=no
+	  ;;
+	*)
+	  hardcode_direct=yes
+	  hardcode_direct_absolute=yes
+	  export_dynamic_flag_spec='${wl}-E'
 
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L=yes
+	  ;;
+	esac
+      fi
+      ;;
 
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	# Try to use the -exported_symbol ld option, if it does not
+	# work, assume that -exports_file does not work either and
+	# implicitly export all symbols.
+	# This should be the same for all languages, so no per-tag cache variable.
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5
+$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; }
+if ${lt_cv_irix_exported_symbol+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  save_LDFLAGS="$LDFLAGS"
+	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+	   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+int foo (void) { return 0; }
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  lt_cv_irix_exported_symbol=yes
+else
+  lt_cv_irix_exported_symbol=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+           LDFLAGS="$save_LDFLAGS"
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
+$as_echo "$lt_cv_irix_exported_symbol" >&6; }
+	if test "$lt_cv_irix_exported_symbol" = yes; then
+          archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+	fi
+      else
+	archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      inherit_rpath=yes
+      link_all_deplibs=yes
+      ;;
 
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
 
+    newsos6)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_shlibpath_var=no
+      ;;
 
+    *nto* | *qnx*)
+      ;;
 
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+	hardcode_direct=yes
+	hardcode_shlibpath_var=no
+	hardcode_direct_absolute=yes
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+	  export_dynamic_flag_spec='${wl}-E'
+	else
+	  case $host_os in
+	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+	     archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     hardcode_libdir_flag_spec='-R$libdir'
+	     ;;
+	   *)
+	     archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+	     ;;
+	  esac
+	fi
+      else
+	ld_shlibs=no
+      fi
+      ;;
 
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      allow_undefined_flag=unsupported
+      archive_cmds='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_from_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
 
+    osf3*)
+      if test "$GCC" = yes; then
+	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+	allow_undefined_flag=' -expect_unresolved \*'
+	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      ;;
 
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      else
+	allow_undefined_flag=' -expect_unresolved \*'
+	archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
 
+	# Both c and cxx compiler support -rpath directly
+	hardcode_libdir_flag_spec='-rpath $libdir'
+      fi
+      archive_cmds_need_lc='no'
+      hardcode_libdir_separator=:
+      ;;
 
+    solaris*)
+      no_undefined_flag=' -z defs'
+      if test "$GCC" = yes; then
+	wlarc='${wl}'
+	archive_cmds='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+      else
+	case `$CC -V 2>&1` in
+	*"Compilers 5.0"*)
+	  wlarc=''
+	  archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
+	  ;;
+	*)
+	  wlarc='${wl}'
+	  archive_cmds='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+	  ;;
+	esac
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_shlibpath_var=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
+	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test "$GCC" = yes; then
+	  whole_archive_flag_spec='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  whole_archive_flag_spec='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      esac
+      link_all_deplibs=yes
+      ;;
 
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+	# Use $CC to link under sequent, because it throws in some extra .o
+	# files that make .init and .fini sections work.
+	archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
 
+    sysv4)
+      case $host_vendor in
+	sni)
+	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct=yes # is this really true???
+	;;
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  reload_cmds='$CC -r -o $output$reload_objs'
+	  hardcode_direct=no
+        ;;
+	motorola)
+	  archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var=no
+      ;;
 
+    sysv4.3*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var=no
+      export_dynamic_flag_spec='-Bexport'
+      ;;
 
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hardcode_shlibpath_var=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	ld_shlibs=yes
+      fi
+      ;;
 
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag='${wl}-z,text'
+      archive_cmds_need_lc=no
+      hardcode_shlibpath_var=no
+      runpath_var='LD_RUN_PATH'
 
+      if test "$GCC" = yes; then
+	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
 
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      no_undefined_flag='${wl}-z,text'
+      allow_undefined_flag='${wl}-z,nodefs'
+      archive_cmds_need_lc=no
+      hardcode_shlibpath_var=no
+      hardcode_libdir_flag_spec='${wl}-R,$libdir'
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+      export_dynamic_flag_spec='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
 
+      if test "$GCC" = yes; then
+	archive_cmds='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
 
+    uts4*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
 
+    *)
+      ld_shlibs=no
+      ;;
+    esac
 
+    if test x$host_vendor = xsni; then
+      case $host in
+      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+	export_dynamic_flag_spec='${wl}-Blargedynsym'
+	;;
+      esac
+    fi
+  fi
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
+$as_echo "$ld_shlibs" >&6; }
+test "$ld_shlibs" = no && can_build_shared=no
 
+with_gnu_ld=$with_gnu_ld
 
 
 
@@ -11429,9 +12490,74 @@ fi
 
 
 
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc=yes
 
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+if ${lt_cv_archive_cmds_need_lc+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  $RM conftest*
+	echo "$lt_simple_compile_test_code" > conftest.$ac_ext
 
+	if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } 2>conftest.err; then
+	  soname=conftest
+	  lib=conftest
+	  libobjs=conftest.$ac_objext
+	  deplibs=
+	  wl=$lt_prog_compiler_wl
+	  pic_flag=$lt_prog_compiler_pic
+	  compiler_flags=-v
+	  linker_flags=-v
+	  verstring=
+	  output_objdir=.
+	  libname=conftest
+	  lt_save_allow_undefined_flag=$allow_undefined_flag
+	  allow_undefined_flag=
+	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+  (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+	  then
+	    lt_cv_archive_cmds_need_lc=no
+	  else
+	    lt_cv_archive_cmds_need_lc=yes
+	  fi
+	  allow_undefined_flag=$lt_save_allow_undefined_flag
+	else
+	  cat conftest.err 1>&5
+	fi
+	$RM conftest*
 
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5
+$as_echo "$lt_cv_archive_cmds_need_lc" >&6; }
+      archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc
+      ;;
+    esac
+  fi
+  ;;
+esac
 
 
 
@@ -11454,552 +12580,62 @@ fi
 
 
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
-$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
-hardcode_action=
-if test -n "$hardcode_libdir_flag_spec" ||
-   test -n "$runpath_var" ||
-   test "X$hardcode_automatic" = "Xyes" ; then
 
-  # We can hardcode non-existent directories.
-  if test "$hardcode_direct" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
-     test "$hardcode_minus_L" != no; then
-    # Linking always hardcodes the temporary library directory.
-    hardcode_action=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    hardcode_action=immediate
-  fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  hardcode_action=unsupported
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
-$as_echo "$hardcode_action" >&6; }
 
-if test "$hardcode_action" = relink ||
-   test "$inherit_rpath" = yes; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
 
 
 
 
 
 
-  if test "x$enable_dlopen" != xyes; then
-  enable_dlopen=unknown
-  enable_dlopen_self=unknown
-  enable_dlopen_self_static=unknown
-else
-  lt_cv_dlopen=no
-  lt_cv_dlopen_libs=
 
-  case $host_os in
-  beos*)
-    lt_cv_dlopen="load_add_on"
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=yes
-    ;;
 
-  mingw* | pw32* | cegcc*)
-    lt_cv_dlopen="LoadLibrary"
-    lt_cv_dlopen_libs=
-    ;;
 
-  cygwin*)
-    lt_cv_dlopen="dlopen"
-    lt_cv_dlopen_libs=
-    ;;
 
-  darwin*)
-  # if libdl is installed we need to link against it
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
-$as_echo_n "checking for dlopen in -ldl... " >&6; }
-if ${ac_cv_lib_dl_dlopen+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dlopen ();
-int
-main ()
-{
-return dlopen ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_dl_dlopen=yes
-else
-  ac_cv_lib_dl_dlopen=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
-$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
-if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-else
 
-    lt_cv_dlopen="dyld"
-    lt_cv_dlopen_libs=
-    lt_cv_dlopen_self=yes
 
-fi
 
-    ;;
 
-  *)
-    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
-if test "x$ac_cv_func_shl_load" = xyes; then :
-  lt_cv_dlopen="shl_load"
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
-$as_echo_n "checking for shl_load in -ldld... " >&6; }
-if ${ac_cv_lib_dld_shl_load+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldld  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char shl_load ();
-int
-main ()
-{
-return shl_load ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_dld_shl_load=yes
-else
-  ac_cv_lib_dld_shl_load=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
-$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
-if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
-  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
-else
-  ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
-if test "x$ac_cv_func_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen"
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
-$as_echo_n "checking for dlopen in -ldl... " >&6; }
-if ${ac_cv_lib_dl_dlopen+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldl  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dlopen ();
-int
-main ()
-{
-return dlopen ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_dl_dlopen=yes
-else
-  ac_cv_lib_dl_dlopen=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
-$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
-if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
-$as_echo_n "checking for dlopen in -lsvld... " >&6; }
-if ${ac_cv_lib_svld_dlopen+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-lsvld  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dlopen ();
-int
-main ()
-{
-return dlopen ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_svld_dlopen=yes
-else
-  ac_cv_lib_svld_dlopen=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
-$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
-if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
-  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
-$as_echo_n "checking for dld_link in -ldld... " >&6; }
-if ${ac_cv_lib_dld_dld_link+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_check_lib_save_LIBS=$LIBS
-LIBS="-ldld  $LIBS"
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dld_link ();
-int
-main ()
-{
-return dld_link ();
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_lib_dld_dld_link=yes
-else
-  ac_cv_lib_dld_dld_link=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-LIBS=$ac_check_lib_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
-$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
-if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
-  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
-fi
 
 
-fi
 
 
-fi
 
 
-fi
 
 
-fi
 
 
-fi
 
-    ;;
-  esac
 
-  if test "x$lt_cv_dlopen" != xno; then
-    enable_dlopen=yes
-  else
-    enable_dlopen=no
-  fi
 
-  case $lt_cv_dlopen in
-  dlopen)
-    save_CPPFLAGS="$CPPFLAGS"
-    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-    save_LDFLAGS="$LDFLAGS"
-    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
-    save_LIBS="$LIBS"
-    LIBS="$lt_cv_dlopen_libs $LIBS"
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
-$as_echo_n "checking whether a program can dlopen itself... " >&6; }
-if ${lt_cv_dlopen_self+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  	  if test "$cross_compiling" = yes; then :
-  lt_cv_dlopen_self=cross
-else
-  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-  lt_status=$lt_dlunknown
-  cat > conftest.$ac_ext <<_LT_EOF
-#line $LINENO "configure"
-#include "confdefs.h"
 
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
 
-#include <stdio.h>
 
-#ifdef RTLD_GLOBAL
-#  define LT_DLGLOBAL		RTLD_GLOBAL
-#else
-#  ifdef DL_GLOBAL
-#    define LT_DLGLOBAL		DL_GLOBAL
-#  else
-#    define LT_DLGLOBAL		0
-#  endif
-#endif
 
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-#  ifdef RTLD_LAZY
-#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
-#  else
-#    ifdef DL_LAZY
-#      define LT_DLLAZY_OR_NOW		DL_LAZY
-#    else
-#      ifdef RTLD_NOW
-#        define LT_DLLAZY_OR_NOW	RTLD_NOW
-#      else
-#        ifdef DL_NOW
-#          define LT_DLLAZY_OR_NOW	DL_NOW
-#        else
-#          define LT_DLLAZY_OR_NOW	0
-#        endif
-#      endif
-#    endif
-#  endif
-#endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
-   correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
-int fnord () __attribute__((visibility("default")));
-#endif
 
-int fnord () { return 42; }
-int main ()
-{
-  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
-  int status = $lt_dlunknown;
 
-  if (self)
-    {
-      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
-      else
-        {
-	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
-          else puts (dlerror ());
-	}
-      /* dlclose (self); */
-    }
-  else
-    puts (dlerror ());
 
-  return status;
-}
-_LT_EOF
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
-    lt_status=$?
-    case x$lt_status in
-      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
-      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
-      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
-    esac
-  else :
-    # compilation failed
-    lt_cv_dlopen_self=no
-  fi
-fi
-rm -fr conftest*
 
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
-$as_echo "$lt_cv_dlopen_self" >&6; }
 
-    if test "x$lt_cv_dlopen_self" = xyes; then
-      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
-$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
-if ${lt_cv_dlopen_self_static+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  	  if test "$cross_compiling" = yes; then :
-  lt_cv_dlopen_self_static=cross
-else
-  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
-  lt_status=$lt_dlunknown
-  cat > conftest.$ac_ext <<_LT_EOF
-#line $LINENO "configure"
-#include "confdefs.h"
 
-#if HAVE_DLFCN_H
-#include <dlfcn.h>
-#endif
 
-#include <stdio.h>
 
-#ifdef RTLD_GLOBAL
-#  define LT_DLGLOBAL		RTLD_GLOBAL
-#else
-#  ifdef DL_GLOBAL
-#    define LT_DLGLOBAL		DL_GLOBAL
-#  else
-#    define LT_DLGLOBAL		0
-#  endif
-#endif
 
-/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
-   find out it does not work in some platform. */
-#ifndef LT_DLLAZY_OR_NOW
-#  ifdef RTLD_LAZY
-#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
-#  else
-#    ifdef DL_LAZY
-#      define LT_DLLAZY_OR_NOW		DL_LAZY
-#    else
-#      ifdef RTLD_NOW
-#        define LT_DLLAZY_OR_NOW	RTLD_NOW
-#      else
-#        ifdef DL_NOW
-#          define LT_DLLAZY_OR_NOW	DL_NOW
-#        else
-#          define LT_DLLAZY_OR_NOW	0
-#        endif
-#      endif
-#    endif
-#  endif
-#endif
 
-/* When -fvisbility=hidden is used, assume the code has been annotated
-   correspondingly for the symbols needed.  */
-#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
-int fnord () __attribute__((visibility("default")));
-#endif
 
-int fnord () { return 42; }
-int main ()
-{
-  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
-  int status = $lt_dlunknown;
 
-  if (self)
-    {
-      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
-      else
-        {
-	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
-          else puts (dlerror ());
-	}
-      /* dlclose (self); */
-    }
-  else
-    puts (dlerror ());
 
-  return status;
-}
-_LT_EOF
-  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
-  (eval $ac_link) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
-    (./conftest; exit; ) >&5 2>/dev/null
-    lt_status=$?
-    case x$lt_status in
-      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
-      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
-      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
-    esac
-  else :
-    # compilation failed
-    lt_cv_dlopen_self_static=no
-  fi
-fi
-rm -fr conftest*
-
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
-$as_echo "$lt_cv_dlopen_self_static" >&6; }
-    fi
-
-    CPPFLAGS="$save_CPPFLAGS"
-    LDFLAGS="$save_LDFLAGS"
-    LIBS="$save_LIBS"
-    ;;
-  esac
-
-  case $lt_cv_dlopen_self in
-  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
-  *) enable_dlopen_self=unknown ;;
-  esac
-
-  case $lt_cv_dlopen_self_static in
-  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
-  *) enable_dlopen_self_static=unknown ;;
-  esac
-fi
 
 
 
@@ -12017,35 +12653,6 @@ fi
 
 
 
-striplib=
-old_striplib=
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
-$as_echo_n "checking whether stripping libraries is possible... " >&6; }
-if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
-  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
-  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-else
-# FIXME - insert some real tests, host_os isn't really good enough
-  case $host_os in
-  darwin*)
-    if test -n "$STRIP" ; then
-      striplib="$STRIP -x"
-      old_striplib="$STRIP -S"
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
-$as_echo "yes" >&6; }
-    else
-      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-    fi
-    ;;
-  *)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-    ;;
-  esac
-fi
 
 
 
@@ -12058,54 +12665,15 @@ fi
 
 
 
-  # Report which library types will actually be built
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
-$as_echo_n "checking if libtool supports shared libraries... " >&6; }
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
-$as_echo "$can_build_shared" >&6; }
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
-$as_echo_n "checking whether to build shared libraries... " >&6; }
-  test "$can_build_shared" = "no" && enable_shared=no
 
-  # On AIX, shared libraries and static libraries use the same namespace, and
-  # are all built from PIC.
-  case $host_os in
-  aix3*)
-    test "$enable_shared" = yes && enable_static=no
-    if test -n "$RANLIB"; then
-      archive_cmds="$archive_cmds~\$RANLIB \$lib"
-      postinstall_cmds='$RANLIB $lib'
-    fi
-    ;;
 
-  aix[4-9]*)
-    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-      test "$enable_shared" = yes && enable_static=no
-    fi
-    ;;
-  esac
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
-$as_echo "$enable_shared" >&6; }
 
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
-$as_echo_n "checking whether to build static libraries... " >&6; }
-  # Make sure either enable_shared or enable_static is yes.
-  test "$enable_shared" = yes || enable_static=yes
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
-$as_echo "$enable_static" >&6; }
 
 
 
 
-fi
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-CC="$lt_save_CC"
 
 
 
@@ -12121,832 +12689,809 @@ CC="$lt_save_CC"
 
 
 
-        ac_config_commands="$ac_config_commands libtool"
 
 
 
 
-# Only expand once:
 
 
 
-# Check building environment
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
-set dummy ${ac_tool_prefix}gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CC"; then
-  ac_cv_prog_CC="$CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CC="${ac_tool_prefix}gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-CC=$ac_cv_prog_CC
-if test -n "$CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
-$as_echo "$CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
 
 
-fi
-if test -z "$ac_cv_prog_CC"; then
-  ac_ct_CC=$CC
-  # Extract the first word of "gcc", so it can be a program name with args.
-set dummy gcc; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_CC"; then
-  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_CC="gcc"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-ac_ct_CC=$ac_cv_prog_ac_ct_CC
-if test -n "$ac_ct_CC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
-$as_echo "$ac_ct_CC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
 
-  if test "x$ac_ct_CC" = x; then
-    CC=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CC=$ac_ct_CC
-  fi
-else
-  CC="$ac_cv_prog_CC"
-fi
 
-   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5
-$as_echo_n "checking for $CC option to accept ISO C99... " >&6; }
-if ${ac_cv_prog_cc_c99+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_prog_cc_c99=no
-ac_save_CC=$CC
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <stdarg.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <wchar.h>
-#include <stdio.h>
 
-// Check varargs macros.  These examples are taken from C99 6.10.3.5.
-#define debug(...) fprintf (stderr, __VA_ARGS__)
-#define showlist(...) puts (#__VA_ARGS__)
-#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
-static void
-test_varargs_macros (void)
-{
-  int x = 1234;
-  int y = 5678;
-  debug ("Flag");
-  debug ("X = %d\n", x);
-  showlist (The first, second, and third items.);
-  report (x>y, "x is %d but y is %d", x, y);
-}
 
-// Check long long types.
-#define BIG64 18446744073709551615ull
-#define BIG32 4294967295ul
-#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
-#if !BIG_OK
-  your preprocessor is broken;
-#endif
-#if BIG_OK
-#else
-  your preprocessor is broken;
-#endif
-static long long int bignum = -9223372036854775807LL;
-static unsigned long long int ubignum = BIG64;
 
-struct incomplete_array
-{
-  int datasize;
-  double data[];
-};
 
-struct named_init {
-  int number;
-  const wchar_t *name;
-  double average;
-};
 
-typedef const char *ccp;
 
-static inline int
-test_restrict (ccp restrict text)
-{
-  // See if C++-style comments work.
-  // Iterate through items via the restricted pointer.
-  // Also check for declarations in for loops.
-  for (unsigned int i = 0; *(text+i) != '\0'; ++i)
-    continue;
-  return 0;
-}
 
-// Check varargs and va_copy.
-static void
-test_varargs (const char *format, ...)
-{
-  va_list args;
-  va_start (args, format);
-  va_list args_copy;
-  va_copy (args_copy, args);
 
-  const char *str;
-  int number;
-  float fnumber;
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
 
-  while (*format)
-    {
-      switch (*format++)
-	{
-	case 's': // string
-	  str = va_arg (args_copy, const char *);
-	  break;
-	case 'd': // int
-	  number = va_arg (args_copy, int);
-	  break;
-	case 'f': // float
-	  fnumber = va_arg (args_copy, double);
-	  break;
-	default:
-	  break;
-	}
+if test "$GCC" = yes; then
+  case $host_os in
+    darwin*) lt_awk_arg="/^libraries:/,/LR/" ;;
+    *) lt_awk_arg="/^libraries:/" ;;
+  esac
+  case $host_os in
+    mingw* | cegcc*) lt_sed_strip_eq="s,=\([A-Za-z]:\),\1,g" ;;
+    *) lt_sed_strip_eq="s,=/,/,g" ;;
+  esac
+  lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`
+  case $lt_search_path_spec in
+  *\;*)
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`
+    ;;
+  *)
+    lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`
+    ;;
+  esac
+  # Ok, now we have the path, separated by spaces, we can step through it
+  # and add multilib dir if necessary.
+  lt_tmp_lt_search_path_spec=
+  lt_multi_os_dir=`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`
+  for lt_sys_path in $lt_search_path_spec; do
+    if test -d "$lt_sys_path/$lt_multi_os_dir"; then
+      lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path/$lt_multi_os_dir"
+    else
+      test -d "$lt_sys_path" && \
+	lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"
+    fi
+  done
+  lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '
+BEGIN {RS=" "; FS="/|\n";} {
+  lt_foo="";
+  lt_count=0;
+  for (lt_i = NF; lt_i > 0; lt_i--) {
+    if ($lt_i != "" && $lt_i != ".") {
+      if ($lt_i == "..") {
+        lt_count++;
+      } else {
+        if (lt_count == 0) {
+          lt_foo="/" $lt_i lt_foo;
+        } else {
+          lt_count--;
+        }
+      }
     }
-  va_end (args_copy);
-  va_end (args);
-}
+  }
+  if (lt_foo != "") { lt_freq[lt_foo]++; }
+  if (lt_freq[lt_foo] == 1) { print lt_foo; }
+}'`
+  # AWK program above erroneously prepends '/' to C:/dos/paths
+  # for these hosts.
+  case $host_os in
+    mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\
+      $SED 's,/\([A-Za-z]:\),\1,g'` ;;
+  esac
+  sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
 
-int
-main ()
-{
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
 
-  // Check bool.
-  _Bool success = false;
+case $host_os in
+aix3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
 
-  // Check restrict.
-  if (test_restrict ("String literal") == 0)
-    success = true;
-  char *restrict newvar = "Another string";
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
 
-  // Check varargs.
-  test_varargs ("s, d' f .", "string", 65, 34.234);
-  test_varargs_macros ();
+aix[4-9]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
 
-  // Check flexible array members.
-  struct incomplete_array *ia =
-    malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
-  ia->datasize = 10;
-  for (int i = 0; i < ia->datasize; ++i)
-    ia->data[i] = i * 1.234;
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
 
-  // Check named initializers.
-  struct named_init ni = {
-    .number = 34,
-    .name = L"Test wide string",
-    .average = 543.34343,
-  };
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
 
-  ni.number = 58;
+bsdi[45]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
 
-  int dynamic_array[ni.number];
-  dynamic_array[ni.number - 1] = 543;
+cygwin* | mingw* | pw32* | cegcc*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
 
-  // work around unused variable warnings
-  return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
-	  || dynamic_array[ni.number - 1] != 543);
+  case $GCC,$cc_basename in
+  yes,*)
+    # gcc
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
 
-  ;
-  return 0;
-}
-_ACEOF
-for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -xc99=all -qlanglvl=extc99
-do
-  CC="$ac_save_CC $ac_arg"
-  if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_prog_cc_c99=$ac_arg
-fi
-rm -f core conftest.err conftest.$ac_objext
-  test "x$ac_cv_prog_cc_c99" != "xno" && break
-done
-rm -f conftest.$ac_ext
-CC=$ac_save_CC
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
-fi
-# AC_CACHE_VAL
-case "x$ac_cv_prog_cc_c99" in
-  x)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
-$as_echo "none needed" >&6; } ;;
-  xno)
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
-$as_echo "unsupported" >&6; } ;;
-  *)
-    CC="$CC $ac_cv_prog_cc_c99"
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
-$as_echo "$ac_cv_prog_cc_c99" >&6; } ;;
-esac
-if test "x$ac_cv_prog_cc_c99" != xno; then :
+      sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"
+      ;;
+    mingw* | cegcc*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    dynamic_linker='Win32 ld.exe'
+    ;;
 
-fi
+  *,cl*)
+    # Native MSVC
+    libname_spec='$name'
+    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+    library_names_spec='${libname}.dll.lib'
 
+    case $build_os in
+    mingw*)
+      sys_lib_search_path_spec=
+      lt_save_ifs=$IFS
+      IFS=';'
+      for lt_path in $LIB
+      do
+        IFS=$lt_save_ifs
+        # Let DOS variable expansion print the short 8.3 style file name.
+        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+      done
+      IFS=$lt_save_ifs
+      # Convert to MSYS style.
+      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
+      ;;
+    cygwin*)
+      # Convert to unix form, then to dos form, then back to unix form
+      # but this time dos style (no spaces!) so that the unix form looks
+      # like /cygdrive/c/PROGRA~1:/cygdr...
+      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      ;;
+    *)
+      sys_lib_search_path_spec="$LIB"
+      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      # FIXME: find the short name or the path components, as spaces are
+      # common. (e.g. "Program Files" -> "PROGRA~1")
+      ;;
+    esac
 
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+    dynamic_linker='Win32 link.exe'
+    ;;
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C/C++ restrict keyword" >&5
-$as_echo_n "checking for C/C++ restrict keyword... " >&6; }
-if ${ac_cv_c_restrict+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_cv_c_restrict=no
-   # The order here caters to the fact that C++ does not require restrict.
-   for ac_kw in __restrict __restrict__ _Restrict restrict; do
-     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-typedef int * int_ptr;
-	int foo (int_ptr $ac_kw ip) {
-	return ip[0];
-       }
-int
-main ()
-{
-int s[1];
-	int * $ac_kw t = s;
-	t[0] = 0;
-	return foo(t)
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_c_try_compile "$LINENO"; then :
-  ac_cv_c_restrict=$ac_kw
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-     test "$ac_cv_c_restrict" != no && break
-   done
+  *)
+    # Assume MSVC wrapper
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    dynamic_linker='Win32 ld.exe'
+    ;;
+  esac
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_restrict" >&5
-$as_echo "$ac_cv_c_restrict" >&6; }
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
 
- case $ac_cv_c_restrict in
-   restrict) ;;
-   no) $as_echo "#define restrict /**/" >>confdefs.h
- ;;
-   *)  cat >>confdefs.h <<_ACEOF
-#define restrict $ac_cv_c_restrict
-_ACEOF
- ;;
- esac
+  sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
 
-ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
-if test -n "$ac_tool_prefix"; then
-  for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_FC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$FC"; then
-  ac_cv_prog_FC="$FC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_FC="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
+dgux*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[23].*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
   fi
-done
-  done
-IFS=$as_save_IFS
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2.*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
 
-fi
-fi
-FC=$ac_cv_prog_FC
-if test -n "$FC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $FC" >&5
-$as_echo "$FC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+gnu*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
 
+haiku*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  dynamic_linker="$host_os runtime_loader"
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+  hardcode_into_libs=yes
+  ;;
 
-    test -n "$FC" && break
-  done
-fi
-if test -z "$FC"; then
-  ac_ct_FC=$FC
-  for ac_prog in gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn xlf90 f90 pgf90 pghpf epcf90 g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_FC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_FC"; then
-  ac_cv_prog_ac_ct_FC="$ac_ct_FC" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_FC="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-ac_ct_FC=$ac_cv_prog_ac_ct_FC
-if test -n "$ac_ct_FC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_FC" >&5
-$as_echo "$ac_ct_FC" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+  postinstall_cmds='chmod 555 $lib'
+  # or fails outright, so override atomically:
+  install_override_mode=555
+  ;;
 
-  test -n "$ac_ct_FC" && break
-done
+interix[3-9]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
 
-  if test "x$ac_ct_FC" = x; then
-    FC=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    FC=$ac_ct_FC
-  fi
-fi
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux # correct to gnu/linux during the next big refactor
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
 
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
 
-# Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran compiler version" >&5
-set X $ac_compile
-ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
-  { { ac_try="$ac_compiler $ac_option >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    sed '10a\
-... rest of stderr output deleted ...
-         10q' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-  fi
-  rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-done
-rm -f a.out
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
 
-# If we don't use `.F' as extension, the preprocessor is not run on the
-# input file.  (Note that this only needs to work for GNU compilers.)
-ac_save_ext=$ac_ext
-ac_ext=F
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Fortran compiler" >&5
-$as_echo_n "checking whether we are using the GNU Fortran compiler... " >&6; }
-if ${ac_cv_fc_compiler_gnu+:} false; then :
+  # Some binutils ld are patched to set DT_RUNPATH
+  if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  cat > conftest.$ac_ext <<_ACEOF
-      program conftest
-#ifndef __GNUC__
-       choke me
-#endif
+  lt_cv_shlibpath_overrides_runpath=no
+    save_LDFLAGS=$LDFLAGS
+    save_libdir=$libdir
+    eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \
+	 LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-      end
+int
+main ()
+{
+
+  ;
+  return 0;
+}
 _ACEOF
-if ac_fn_fc_try_compile "$LINENO"; then :
-  ac_compiler_gnu=yes
-else
-  ac_compiler_gnu=no
+if ac_fn_c_try_link "$LINENO"; then :
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+  lt_cv_shlibpath_overrides_runpath=yes
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_fc_compiler_gnu=$ac_compiler_gnu
-
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fc_compiler_gnu" >&5
-$as_echo "$ac_cv_fc_compiler_gnu" >&6; }
-ac_ext=$ac_save_ext
-ac_test_FCFLAGS=${FCFLAGS+set}
-ac_save_FCFLAGS=$FCFLAGS
-FCFLAGS=
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $FC accepts -g" >&5
-$as_echo_n "checking whether $FC accepts -g... " >&6; }
-if ${ac_cv_prog_fc_g+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  FCFLAGS=-g
-cat > conftest.$ac_ext <<_ACEOF
-      program conftest
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    LDFLAGS=$save_LDFLAGS
+    libdir=$save_libdir
 
-      end
-_ACEOF
-if ac_fn_fc_try_compile "$LINENO"; then :
-  ac_cv_prog_fc_g=yes
-else
-  ac_cv_prog_fc_g=no
 fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_fc_g" >&5
-$as_echo "$ac_cv_prog_fc_g" >&6; }
-if test "$ac_test_FCFLAGS" = set; then
-  FCFLAGS=$ac_save_FCFLAGS
-elif test $ac_cv_prog_fc_g = yes; then
-  if test "x$ac_cv_fc_compiler_gnu" = xyes; then
-    FCFLAGS="-g -O2"
-  else
-    FCFLAGS="-g"
+  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
   fi
-else
-  if test "x$ac_cv_fc_compiler_gnu" = xyes; then
-    FCFLAGS="-O2"
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
   else
-    FCFLAGS=
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
   fi
-fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+newsos6)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
 
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
 
-func_stripname_cnf ()
-{
-  case ${2} in
-  .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
-  *)  func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
+    *)				need_version=no  ;;
   esac
-} # func_stripname_cnf
-
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+	shlibpath_overrides_runpath=no
+	;;
+      *)
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
 
-      ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
 
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
 
-if test -z "$FC" || test "X$FC" = "Xno"; then
-  _lt_disable_FC=yes
-fi
+rdos*)
+  dynamic_linker=no
+  ;;
 
-archive_cmds_need_lc_FC=no
-allow_undefined_flag_FC=
-always_export_symbols_FC=no
-archive_expsym_cmds_FC=
-export_dynamic_flag_spec_FC=
-hardcode_direct_FC=no
-hardcode_direct_absolute_FC=no
-hardcode_libdir_flag_spec_FC=
-hardcode_libdir_separator_FC=
-hardcode_minus_L_FC=no
-hardcode_automatic_FC=no
-inherit_rpath_FC=no
-module_cmds_FC=
-module_expsym_cmds_FC=
-link_all_deplibs_FC=unknown
-old_archive_cmds_FC=$old_archive_cmds
-reload_flag_FC=$reload_flag
-reload_cmds_FC=$reload_cmds
-no_undefined_flag_FC=
-whole_archive_flag_spec_FC=
-enable_shared_with_static_runtimes_FC=no
+solaris*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
 
-# Source file extension for fc test sources.
-ac_ext=${ac_fc_srcext-f}
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
 
-# Object file extension for compiled fc test sources.
-objext=o
-objext_FC=$objext
+sysv4 | sysv4.3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
 
-# No sense in running all these tests if we already determined that
-# the FC compiler isn't working.  Some variables (like enable_shared)
-# are currently assumed to apply to all compilers on this platform,
-# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_disable_FC" != yes; then
-  # Code to be used in simple compile tests
-  lt_simple_compile_test_code="\
-      subroutine t
-      return
-      end
-"
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux # correct to gnu/linux during the next big refactor
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
 
-  # Code to be used in simple link tests
-  lt_simple_link_test_code="\
-      program t
-      end
-"
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
 
-  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
 
+uts4*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
 
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
 
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
 
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
 
 
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
 
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
 
-# Allow CC to be a program name with arguments.
-compiler=$CC
 
 
-  # save warnings/boilerplate of simple test code
-  ac_outfile=conftest.$ac_objext
-echo "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$RM conftest*
 
-  ac_outfile=conftest.$ac_objext
-echo "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$RM -r conftest*
 
 
-  # Allow CC to be a program name with arguments.
-  lt_save_CC="$CC"
-  lt_save_GCC=$GCC
-  lt_save_CFLAGS=$CFLAGS
-  CC=${FC-"f95"}
-  CFLAGS=$FCFLAGS
-  compiler=$CC
-  GCC=$ac_cv_fc_compiler_gnu
 
-  compiler_FC=$CC
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
 
 
-  if test -n "$compiler"; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
-$as_echo_n "checking if libtool supports shared libraries... " >&6; }
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
-$as_echo "$can_build_shared" >&6; }
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
-$as_echo_n "checking whether to build shared libraries... " >&6; }
-    test "$can_build_shared" = "no" && enable_shared=no
 
-    # On AIX, shared libraries and static libraries use the same namespace, and
-    # are all built from PIC.
-    case $host_os in
-      aix3*)
-        test "$enable_shared" = yes && enable_static=no
-        if test -n "$RANLIB"; then
-          archive_cmds="$archive_cmds~\$RANLIB \$lib"
-          postinstall_cmds='$RANLIB $lib'
-        fi
-        ;;
-      aix[4-9]*)
-	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
-	  test "$enable_shared" = yes && enable_static=no
-	fi
-        ;;
-    esac
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
-$as_echo "$enable_shared" >&6; }
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
-$as_echo_n "checking whether to build static libraries... " >&6; }
-    # Make sure either enable_shared or enable_static is yes.
-    test "$enable_shared" = yes || enable_static=yes
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
-$as_echo "$enable_static" >&6; }
 
-    GCC_FC="$ac_cv_fc_compiler_gnu"
-    LD_FC="$LD"
 
-    ## CAVEAT EMPTOR:
-    ## There is no encapsulation within the following macros, do not change
-    ## the running order or otherwise move them around unless you know exactly
-    ## what you are doing...
-    # Dependencies to place before and after the object being linked:
-predep_objects_FC=
-postdep_objects_FC=
-predeps_FC=
-postdeps_FC=
-compiler_lib_search_path_FC=
 
-cat > conftest.$ac_ext <<_LT_EOF
-      subroutine foo
-      implicit none
-      integer a
-      a=0
-      return
-      end
-_LT_EOF
 
 
-_lt_libdeps_save_CFLAGS=$CFLAGS
-case "$CC $CFLAGS " in #(
-*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
-*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
-*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
-esac
 
-if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  # Parse the compiler output and extract the necessary
-  # objects, libraries and library flags.
 
-  # Sentinel used to keep track of whether or not we are before
-  # the conftest object file.
-  pre_test_object_deps_done=no
 
-  for p in `eval "$output_verbose_link_cmd"`; do
-    case ${prev}${p} in
 
-    -L* | -R* | -l*)
-       # Some compilers place space between "-{L,R}" and the path.
-       # Remove the space.
-       if test $p = "-L" ||
-          test $p = "-R"; then
-	 prev=$p
-	 continue
-       fi
 
-       # Expand the sysroot to ease extracting the directories later.
-       if test -z "$prev"; then
-         case $p in
-         -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
-         -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
-         -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
-         esac
-       fi
-       case $p in
-       =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
-       esac
-       if test "$pre_test_object_deps_done" = no; then
-	 case ${prev} in
-	 -L | -R)
-	   # Internal compiler library paths should come after those
-	   # provided the user.  The postdeps already come after the
-	   # user supplied libs so there is no need to process them.
-	   if test -z "$compiler_lib_search_path_FC"; then
-	     compiler_lib_search_path_FC="${prev}${p}"
-	   else
-	     compiler_lib_search_path_FC="${compiler_lib_search_path_FC} ${prev}${p}"
-	   fi
-	   ;;
-	 # The "-l" case would never come before the object being
-	 # linked, so don't bother handling this case.
-	 esac
-       else
-	 if test -z "$postdeps_FC"; then
-	   postdeps_FC="${prev}${p}"
-	 else
-	   postdeps_FC="${postdeps_FC} ${prev}${p}"
-	 fi
-       fi
-       prev=
-       ;;
 
-    *.lto.$objext) ;; # Ignore GCC LTO objects
-    *.$objext)
-       # This assumes that the test object file only shows up
-       # once in the compiler output.
-       if test "$p" = "conftest.$objext"; then
-	 pre_test_object_deps_done=yes
-	 continue
-       fi
 
-       if test "$pre_test_object_deps_done" = no; then
-	 if test -z "$predep_objects_FC"; then
-	   predep_objects_FC="$p"
-	 else
-	   predep_objects_FC="$predep_objects_FC $p"
-	 fi
-       else
-	 if test -z "$postdep_objects_FC"; then
-	   postdep_objects_FC="$p"
-	 else
-	   postdep_objects_FC="$postdep_objects_FC $p"
-	 fi
-       fi
-       ;;
 
-    *) ;; # Ignore the rest.
 
-    esac
-  done
 
-  # Clean up.
-  rm -f a.out a.exe
-else
-  echo "libtool.m4: error: problem compiling FC test program"
-fi
 
-$RM -f confest.$objext
-CFLAGS=$_lt_libdeps_save_CFLAGS
 
-# PORTME: override above test on systems where it is broken
 
 
-case " $postdeps_FC " in
-*" -lc "*) archive_cmds_need_lc_FC=no ;;
-esac
- compiler_lib_search_dirs_FC=
-if test -n "${compiler_lib_search_path_FC}"; then
- compiler_lib_search_dirs_FC=`echo " ${compiler_lib_search_path_FC}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
-fi
 
 
 
@@ -12978,1783 +13523,1055 @@ fi
 
 
 
-    lt_prog_compiler_wl_FC=
-lt_prog_compiler_pic_FC=
-lt_prog_compiler_static_FC=
 
 
-  if test "$GCC" = yes; then
-    lt_prog_compiler_wl_FC='-Wl,'
-    lt_prog_compiler_static_FC='-static'
 
-    case $host_os in
-      aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_FC='-Bstatic'
-      fi
-      ;;
 
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            lt_prog_compiler_pic_FC='-fPIC'
-        ;;
-      m68k)
-            # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
-            lt_prog_compiler_pic_FC='-m68020 -resident32 -malways-restore-a4'
-        ;;
-      esac
-      ;;
 
-    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      # Although the cygwin gcc ignores -fPIC, still need this for old-style
-      # (--disable-auto-import) libraries
-      lt_prog_compiler_pic_FC='-DDLL_EXPORT'
-      ;;
 
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      lt_prog_compiler_pic_FC='-fno-common'
-      ;;
 
-    haiku*)
-      # PIC is the default for Haiku.
-      # The "-static" flag exists, but is broken.
-      lt_prog_compiler_static_FC=
-      ;;
 
-    hpux*)
-      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
-      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
-      # sets the default TLS model and affects inlining.
-      case $host_cpu in
-      hppa*64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic_FC='-fPIC'
-	;;
-      esac
-      ;;
 
-    interix[3-9]*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
 
-    msdosdjgpp*)
-      # Just because we use GCC doesn't mean we suddenly get shared libraries
-      # on systems that don't support them.
-      lt_prog_compiler_can_build_shared_FC=no
-      enable_shared=no
-      ;;
 
-    *nto* | *qnx*)
-      # QNX uses GNU C++, but need to define -shared option too, otherwise
-      # it will coredump.
-      lt_prog_compiler_pic_FC='-fPIC -shared'
-      ;;
 
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	lt_prog_compiler_pic_FC=-Kconform_pic
-      fi
-      ;;
 
-    *)
-      lt_prog_compiler_pic_FC='-fPIC'
-      ;;
-    esac
 
-    case $cc_basename in
-    nvcc*) # Cuda Compiler Driver 2.2
-      lt_prog_compiler_wl_FC='-Xlinker '
-      if test -n "$lt_prog_compiler_pic_FC"; then
-        lt_prog_compiler_pic_FC="-Xcompiler $lt_prog_compiler_pic_FC"
-      fi
-      ;;
-    esac
-  else
-    # PORTME Check for flag to pass linker flags through the system compiler.
-    case $host_os in
-    aix*)
-      lt_prog_compiler_wl_FC='-Wl,'
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_FC='-Bstatic'
-      else
-	lt_prog_compiler_static_FC='-bnso -bI:/lib/syscalls.exp'
-      fi
-      ;;
 
-    mingw* | cygwin* | pw32* | os2* | cegcc*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      lt_prog_compiler_pic_FC='-DDLL_EXPORT'
-      ;;
 
-    hpux9* | hpux10* | hpux11*)
-      lt_prog_compiler_wl_FC='-Wl,'
-      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
-      # not for PA HP-UX.
-      case $host_cpu in
-      hppa*64*|ia64*)
-	# +Z the default
-	;;
-      *)
-	lt_prog_compiler_pic_FC='+Z'
-	;;
-      esac
-      # Is there a better lt_prog_compiler_static that works with the bundled CC?
-      lt_prog_compiler_static_FC='${wl}-a ${wl}archive'
-      ;;
 
-    irix5* | irix6* | nonstopux*)
-      lt_prog_compiler_wl_FC='-Wl,'
-      # PIC (with -KPIC) is the default.
-      lt_prog_compiler_static_FC='-non_shared'
-      ;;
 
-    linux* | k*bsd*-gnu | kopensolaris*-gnu)
-      case $cc_basename in
-      # old Intel for x86_64 which still supported -KPIC.
-      ecc*)
-	lt_prog_compiler_wl_FC='-Wl,'
-	lt_prog_compiler_pic_FC='-KPIC'
-	lt_prog_compiler_static_FC='-static'
-        ;;
-      # icc used to be incompatible with GCC.
-      # ICC 10 doesn't accept -KPIC any more.
-      icc* | ifort*)
-	lt_prog_compiler_wl_FC='-Wl,'
-	lt_prog_compiler_pic_FC='-fPIC'
-	lt_prog_compiler_static_FC='-static'
-        ;;
-      # Lahey Fortran 8.1.
-      lf95*)
-	lt_prog_compiler_wl_FC='-Wl,'
-	lt_prog_compiler_pic_FC='--shared'
-	lt_prog_compiler_static_FC='--static'
-	;;
-      nagfor*)
-	# NAG Fortran compiler
-	lt_prog_compiler_wl_FC='-Wl,-Wl,,'
-	lt_prog_compiler_pic_FC='-PIC'
-	lt_prog_compiler_static_FC='-Bstatic'
-	;;
-      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
-        # Portland Group compilers (*not* the Pentium gcc compiler,
-	# which looks to be a dead project)
-	lt_prog_compiler_wl_FC='-Wl,'
-	lt_prog_compiler_pic_FC='-fpic'
-	lt_prog_compiler_static_FC='-Bstatic'
-        ;;
-      ccc*)
-        lt_prog_compiler_wl_FC='-Wl,'
-        # All Alpha code is PIC.
-        lt_prog_compiler_static_FC='-non_shared'
-        ;;
-      xl* | bgxl* | bgf* | mpixl*)
-	# IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
-	lt_prog_compiler_wl_FC='-Wl,'
-	lt_prog_compiler_pic_FC='-qpic'
-	lt_prog_compiler_static_FC='-qstaticlink'
-	;;
-      *)
-	case `$CC -V 2>&1 | sed 5q` in
-	*Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)
-	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
-	  lt_prog_compiler_pic_FC='-KPIC'
-	  lt_prog_compiler_static_FC='-Bstatic'
-	  lt_prog_compiler_wl_FC=''
-	  ;;
-	*Sun\ F* | *Sun*Fortran*)
-	  lt_prog_compiler_pic_FC='-KPIC'
-	  lt_prog_compiler_static_FC='-Bstatic'
-	  lt_prog_compiler_wl_FC='-Qoption ld '
-	  ;;
-	*Sun\ C*)
-	  # Sun C 5.9
-	  lt_prog_compiler_pic_FC='-KPIC'
-	  lt_prog_compiler_static_FC='-Bstatic'
-	  lt_prog_compiler_wl_FC='-Wl,'
-	  ;;
-        *Intel*\ [CF]*Compiler*)
-	  lt_prog_compiler_wl_FC='-Wl,'
-	  lt_prog_compiler_pic_FC='-fPIC'
-	  lt_prog_compiler_static_FC='-static'
-	  ;;
-	*Portland\ Group*)
-	  lt_prog_compiler_wl_FC='-Wl,'
-	  lt_prog_compiler_pic_FC='-fpic'
-	  lt_prog_compiler_static_FC='-Bstatic'
-	  ;;
-	esac
-	;;
-      esac
-      ;;
 
-    newsos6)
-      lt_prog_compiler_pic_FC='-KPIC'
-      lt_prog_compiler_static_FC='-Bstatic'
-      ;;
 
-    *nto* | *qnx*)
-      # QNX uses GNU C++, but need to define -shared option too, otherwise
-      # it will coredump.
-      lt_prog_compiler_pic_FC='-fPIC -shared'
-      ;;
 
-    osf3* | osf4* | osf5*)
-      lt_prog_compiler_wl_FC='-Wl,'
-      # All OSF/1 code is PIC.
-      lt_prog_compiler_static_FC='-non_shared'
-      ;;
 
-    rdos*)
-      lt_prog_compiler_static_FC='-non_shared'
-      ;;
 
-    solaris*)
-      lt_prog_compiler_pic_FC='-KPIC'
-      lt_prog_compiler_static_FC='-Bstatic'
-      case $cc_basename in
-      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
-	lt_prog_compiler_wl_FC='-Qoption ld ';;
-      *)
-	lt_prog_compiler_wl_FC='-Wl,';;
-      esac
-      ;;
 
-    sunos4*)
-      lt_prog_compiler_wl_FC='-Qoption ld '
-      lt_prog_compiler_pic_FC='-PIC'
-      lt_prog_compiler_static_FC='-Bstatic'
-      ;;
 
-    sysv4 | sysv4.2uw2* | sysv4.3*)
-      lt_prog_compiler_wl_FC='-Wl,'
-      lt_prog_compiler_pic_FC='-KPIC'
-      lt_prog_compiler_static_FC='-Bstatic'
-      ;;
 
-    sysv4*MP*)
-      if test -d /usr/nec ;then
-	lt_prog_compiler_pic_FC='-Kconform_pic'
-	lt_prog_compiler_static_FC='-Bstatic'
-      fi
-      ;;
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" ||
+   test -n "$runpath_var" ||
+   test "X$hardcode_automatic" = "Xyes" ; then
 
-    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-      lt_prog_compiler_wl_FC='-Wl,'
-      lt_prog_compiler_pic_FC='-KPIC'
-      lt_prog_compiler_static_FC='-Bstatic'
-      ;;
+  # We can hardcode non-existent directories.
+  if test "$hardcode_direct" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, )" != no &&
+     test "$hardcode_minus_L" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
+$as_echo "$hardcode_action" >&6; }
 
-    unicos*)
-      lt_prog_compiler_wl_FC='-Wl,'
-      lt_prog_compiler_can_build_shared_FC=no
-      ;;
+if test "$hardcode_action" = relink ||
+   test "$inherit_rpath" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
 
-    uts4*)
-      lt_prog_compiler_pic_FC='-pic'
-      lt_prog_compiler_static_FC='-Bstatic'
-      ;;
 
-    *)
-      lt_prog_compiler_can_build_shared_FC=no
-      ;;
-    esac
-  fi
 
-case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
-  *djgpp*)
-    lt_prog_compiler_pic_FC=
+
+
+
+  if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
     ;;
-  *)
-    lt_prog_compiler_pic_FC="$lt_prog_compiler_pic_FC"
+
+  mingw* | pw32* | cegcc*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
     ;;
-esac
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
-$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
-if ${lt_cv_prog_compiler_pic_FC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_pic_FC=$lt_prog_compiler_pic_FC
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_FC" >&5
-$as_echo "$lt_cv_prog_compiler_pic_FC" >&6; }
-lt_prog_compiler_pic_FC=$lt_cv_prog_compiler_pic_FC
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+    ;;
 
-#
-# Check to make sure the PIC flag actually works.
-#
-if test -n "$lt_prog_compiler_pic_FC"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_FC works" >&5
-$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_FC works... " >&6; }
-if ${lt_cv_prog_compiler_pic_works_FC+:} false; then :
+  darwin*)
+  # if libdl is installed we need to link against it
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if ${ac_cv_lib_dl_dlopen+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  lt_cv_prog_compiler_pic_works_FC=no
-   ac_outfile=conftest.$ac_objext
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic_FC"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_pic_works_FC=yes
-     fi
-   fi
-   $RM conftest*
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_FC" >&5
-$as_echo "$lt_cv_prog_compiler_pic_works_FC" >&6; }
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-if test x"$lt_cv_prog_compiler_pic_works_FC" = xyes; then
-    case $lt_prog_compiler_pic_FC in
-     "" | " "*) ;;
-     *) lt_prog_compiler_pic_FC=" $lt_prog_compiler_pic_FC" ;;
-     esac
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
 else
-    lt_prog_compiler_pic_FC=
-     lt_prog_compiler_can_build_shared_FC=no
+  ac_cv_lib_dl_dlopen=no
 fi
-
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
 
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
 
+fi
 
+    ;;
 
-
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_FC eval lt_tmp_static_flag=\"$lt_prog_compiler_static_FC\"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
-if ${lt_cv_prog_compiler_static_works_FC+:} false; then :
+  *)
+    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+if test "x$ac_cv_func_shl_load" = xyes; then :
+  lt_cv_dlopen="shl_load"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+$as_echo_n "checking for shl_load in -ldld... " >&6; }
+if ${ac_cv_lib_dld_shl_load+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  lt_cv_prog_compiler_static_works_FC=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
-   echo "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_cv_prog_compiler_static_works_FC=yes
-       fi
-     else
-       lt_cv_prog_compiler_static_works_FC=yes
-     fi
-   fi
-   $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load ();
+int
+main ()
+{
+return shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_shl_load=yes
+else
+  ac_cv_lib_dld_shl_load=no
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_FC" >&5
-$as_echo "$lt_cv_prog_compiler_static_works_FC" >&6; }
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = xyes; then :
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-ldld"
+else
+  ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
+if test "x$ac_cv_func_dlopen" = xyes; then :
+  lt_cv_dlopen="dlopen"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if ${ac_cv_lib_dl_dlopen+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-if test x"$lt_cv_prog_compiler_static_works_FC" = xyes; then
-    :
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
 else
-    lt_prog_compiler_static_FC=
+  ac_cv_lib_dl_dlopen=no
 fi
-
-
-
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
-$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if ${lt_cv_prog_compiler_c_o_FC+:} false; then :
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = xyes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
+$as_echo_n "checking for dlopen in -lsvld... " >&6; }
+if ${ac_cv_lib_svld_dlopen+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  lt_cv_prog_compiler_c_o_FC=no
-   $RM -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o_FC=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $RM conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
-   $RM out/* && rmdir out
-   cd ..
-   $RM -r conftest
-   $RM conftest*
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_svld_dlopen=yes
+else
+  ac_cv_lib_svld_dlopen=no
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_FC" >&5
-$as_echo "$lt_cv_prog_compiler_c_o_FC" >&6; }
-
-
-
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
-$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if ${lt_cv_prog_compiler_c_o_FC+:} false; then :
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
+$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
+if test "x$ac_cv_lib_svld_dlopen" = xyes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
+$as_echo_n "checking for dld_link in -ldld... " >&6; }
+if ${ac_cv_lib_dld_dld_link+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  lt_cv_prog_compiler_c_o_FC=no
-   $RM -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link ();
+int
+main ()
+{
+return dld_link ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_dld_link=yes
+else
+  ac_cv_lib_dld_dld_link=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
+$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
+if test "x$ac_cv_lib_dld_dld_link" = xyes; then :
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-ldld"
+fi
 
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o_FC=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $RM conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
-   $RM out/* && rmdir out
-   cd ..
-   $RM -r conftest
-   $RM conftest*
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_FC" >&5
-$as_echo "$lt_cv_prog_compiler_c_o_FC" >&6; }
 
 
+fi
 
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_FC" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
-$as_echo_n "checking if we can lock with hard links... " >&6; }
-  hard_links=yes
-  $RM conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
-$as_echo "$hard_links" >&6; }
-  if test "$hard_links" = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
-    need_locks=warn
-  fi
-else
-  need_locks=no
 fi
 
 
+fi
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
 
-  runpath_var=
-  allow_undefined_flag_FC=
-  always_export_symbols_FC=no
-  archive_cmds_FC=
-  archive_expsym_cmds_FC=
-  compiler_needs_object_FC=no
-  enable_shared_with_static_runtimes_FC=no
-  export_dynamic_flag_spec_FC=
-  export_symbols_cmds_FC='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  hardcode_automatic_FC=no
-  hardcode_direct_FC=no
-  hardcode_direct_absolute_FC=no
-  hardcode_libdir_flag_spec_FC=
-  hardcode_libdir_separator_FC=
-  hardcode_minus_L_FC=no
-  hardcode_shlibpath_var_FC=unsupported
-  inherit_rpath_FC=no
-  link_all_deplibs_FC=unknown
-  module_cmds_FC=
-  module_expsym_cmds_FC=
-  old_archive_from_new_cmds_FC=
-  old_archive_from_expsyms_cmds_FC=
-  thread_safe_flag_spec_FC=
-  whole_archive_flag_spec_FC=
-  # include_expsyms should be a list of space-separated symbols to be *always*
-  # included in the symbol list
-  include_expsyms_FC=
-  # exclude_expsyms can be an extended regexp of symbols to exclude
-  # it will be wrapped by ` (' and `)$', so one must not match beginning or
-  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
-  # as well as any symbol that contains `d'.
-  exclude_expsyms_FC='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
-  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
-  # platforms (ab)use it in PIC code, but their linkers get confused if
-  # the symbol is explicitly referenced.  Since portable code cannot
-  # rely on this symbol name, it's probably fine to never include it in
-  # preloaded symbol tables.
-  # Exclude shared library initialization/finalization symbols.
-  extract_expsyms_cmds=
+fi
 
-  case $host_os in
-  cygwin* | mingw* | pw32* | cegcc*)
-    # FIXME: the MSVC++ port hasn't been tested in a loooong time
-    # When not using gcc, we currently assume that we are using
-    # Microsoft Visual C++.
-    if test "$GCC" != yes; then
-      with_gnu_ld=no
-    fi
-    ;;
-  interix*)
-    # we just hope/assume this is gcc and not c89 (= MSVC++)
-    with_gnu_ld=yes
-    ;;
-  openbsd*)
-    with_gnu_ld=no
     ;;
   esac
 
-  ld_shlibs_FC=yes
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
 
-  # On some targets, GNU ld is compatible enough with the native linker
-  # that we're better off using the native interface for both.
-  lt_use_gnu_ld_interface=no
-  if test "$with_gnu_ld" = yes; then
-    case $host_os in
-      aix*)
-	# The AIX port of GNU ld has always aspired to compatibility
-	# with the native linker.  However, as the warning in the GNU ld
-	# block says, versions before 2.19.5* couldn't really create working
-	# shared libraries, regardless of the interface used.
-	case `$LD -v 2>&1` in
-	  *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
-	  *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;;
-	  *\ \(GNU\ Binutils\)\ [3-9]*) ;;
-	  *)
-	    lt_use_gnu_ld_interface=yes
-	    ;;
-	esac
-	;;
-      *)
-	lt_use_gnu_ld_interface=yes
-	;;
-    esac
-  fi
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
 
-  if test "$lt_use_gnu_ld_interface" = yes; then
-    # If archive_cmds runs LD, not CC, wlarc should be empty
-    wlarc='${wl}'
+    save_LDFLAGS="$LDFLAGS"
+    wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
 
-    # Set some defaults for GNU ld with shared library support. These
-    # are reset later if shared libraries are not supported. Putting them
-    # here allows them to be overridden if necessary.
-    runpath_var=LD_RUN_PATH
-    hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
-    export_dynamic_flag_spec_FC='${wl}--export-dynamic'
-    # ancient GNU ld didn't support --whole-archive et. al.
-    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
-      whole_archive_flag_spec_FC="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-    else
-      whole_archive_flag_spec_FC=
-    fi
-    supports_anon_versioning=no
-    case `$LD -v 2>&1` in
-      *GNU\ gold*) supports_anon_versioning=yes ;;
-      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
-      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
-      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
-      *\ 2.11.*) ;; # other 2.11 versions
-      *) supports_anon_versioning=yes ;;
-    esac
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
 
-    # See if GNU ld supports shared libraries.
-    case $host_os in
-    aix[3-9]*)
-      # On AIX/PPC, the GNU linker is very broken
-      if test "$host_cpu" != ia64; then
-	ld_shlibs_FC=no
-	cat <<_LT_EOF 1>&2
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
+$as_echo_n "checking whether a program can dlopen itself... " >&6; }
+if ${lt_cv_dlopen_self+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  	  if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+#line $LINENO "configure"
+#include "confdefs.h"
 
-*** Warning: the GNU linker, at least up to release 2.19, is reported
-*** to be unable to reliably create shared libraries on AIX.
-*** Therefore, libtool is disabling shared libraries support.  If you
-*** really care for shared libraries, you may want to install binutils
-*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
-*** You will then need to restart the configuration process.
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
 
-_LT_EOF
-      fi
-      ;;
+#include <stdio.h>
 
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-            archive_expsym_cmds_FC=''
-        ;;
-      m68k)
-            archive_cmds_FC='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-            hardcode_libdir_flag_spec_FC='-L$libdir'
-            hardcode_minus_L_FC=yes
-        ;;
-      esac
-      ;;
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
 
-    beos*)
-      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	allow_undefined_flag_FC=unsupported
-	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-	# support --undefined.  This deserves some investigation.  FIXME
-	archive_cmds_FC='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-      else
-	ld_shlibs_FC=no
-      fi
-      ;;
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
 
-    cygwin* | mingw* | pw32* | cegcc*)
-      # _LT_TAGVAR(hardcode_libdir_flag_spec, FC) is actually meaningless,
-      # as there is no search path for DLLs.
-      hardcode_libdir_flag_spec_FC='-L$libdir'
-      export_dynamic_flag_spec_FC='${wl}--export-all-symbols'
-      allow_undefined_flag_FC=unsupported
-      always_export_symbols_FC=no
-      enable_shared_with_static_runtimes_FC=yes
-      export_symbols_cmds_FC='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
-      exclude_expsyms_FC='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
+/* When -fvisbility=hidden is used, assume the code has been annotated
+   correspondingly for the symbols needed.  */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
 
-      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-        archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	# If the export-symbols file already is a .def file (1st line
-	# is EXPORTS), use it as is; otherwise, prepend...
-	archive_expsym_cmds_FC='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	  cp $export_symbols $output_objdir/$soname.def;
-	else
-	  echo EXPORTS > $output_objdir/$soname.def;
-	  cat $export_symbols >> $output_objdir/$soname.def;
-	fi~
-	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+int fnord () { return 42; }
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
       else
-	ld_shlibs_FC=no
-      fi
-      ;;
+        {
+	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
+          else puts (dlerror ());
+	}
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
 
-    haiku*)
-      archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-      link_all_deplibs_FC=yes
-      ;;
+  return status;
+}
+_LT_EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self=no
+  fi
+fi
+rm -fr conftest*
 
-    interix[3-9]*)
-      hardcode_direct_FC=no
-      hardcode_shlibpath_var_FC=no
-      hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
-      export_dynamic_flag_spec_FC='${wl}-E'
-      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-      # Instead, shared libraries are loaded at an image base (0x10000000 by
-      # default) and relocated if they conflict, which is a slow very memory
-      # consuming and fragmenting process.  To avoid this, we pick a random,
-      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-      archive_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      archive_expsym_cmds_FC='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-      ;;
 
-    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
-      tmp_diet=no
-      if test "$host_os" = linux-dietlibc; then
-	case $cc_basename in
-	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
-	esac
-      fi
-      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
-	 && test "$tmp_diet" = no
-      then
-	tmp_addflag=' $pic_flag'
-	tmp_sharedflag='-shared'
-	case $cc_basename,$host_cpu in
-        pgcc*)				# Portland Group C compiler
-	  whole_archive_flag_spec_FC='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag'
-	  ;;
-	pgf77* | pgf90* | pgf95* | pgfortran*)
-					# Portland Group f77 and f90 compilers
-	  whole_archive_flag_spec_FC='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	  tmp_addflag=' $pic_flag -Mnomain' ;;
-	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
-	  tmp_addflag=' -i_dynamic' ;;
-	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
-	  tmp_addflag=' -i_dynamic -nofor_main' ;;
-	ifc* | ifort*)			# Intel Fortran compiler
-	  tmp_addflag=' -nofor_main' ;;
-	lf95*)				# Lahey Fortran 8.1
-	  whole_archive_flag_spec_FC=
-	  tmp_sharedflag='--shared' ;;
-        nagfor*)                        # NAGFOR 5.3
-          tmp_sharedflag='-Wl,-shared' ;;
-	xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
-	  tmp_sharedflag='-qmkshrobj'
-	  tmp_addflag= ;;
-	nvcc*)	# Cuda Compiler Driver 2.2
-	  whole_archive_flag_spec_FC='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	  compiler_needs_object_FC=yes
-	  ;;
-	esac
-	case `$CC -V 2>&1 | sed 5q` in
-	*Sun\ C*)			# Sun C 5.9
-	  whole_archive_flag_spec_FC='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	  compiler_needs_object_FC=yes
-	  tmp_sharedflag='-G' ;;
-	*Sun\ F*)			# Sun Fortran 8.3
-	  tmp_sharedflag='-G' ;;
-	esac
-	archive_cmds_FC='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
+$as_echo "$lt_cv_dlopen_self" >&6; }
 
-        if test "x$supports_anon_versioning" = xyes; then
-          archive_expsym_cmds_FC='echo "{ global:" > $output_objdir/$libname.ver~
-	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	    echo "local: *; };" >> $output_objdir/$libname.ver~
-	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-        fi
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
+$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
+if ${lt_cv_dlopen_self_static+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  	  if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self_static=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<_LT_EOF
+#line $LINENO "configure"
+#include "confdefs.h"
 
-	case $cc_basename in
-	xlf* | bgf* | bgxlf* | mpixlf*)
-	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
-	  whole_archive_flag_spec_FC='--whole-archive$convenience --no-whole-archive'
-	  hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
-	  archive_cmds_FC='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
-	  if test "x$supports_anon_versioning" = xyes; then
-	    archive_expsym_cmds_FC='echo "{ global:" > $output_objdir/$libname.ver~
-	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-	      echo "local: *; };" >> $output_objdir/$libname.ver~
-	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
-	  fi
-	  ;;
-	esac
-      else
-        ld_shlibs_FC=no
-      fi
-      ;;
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
 
-    netbsd*)
-      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	archive_cmds_FC='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
-	wlarc=
-      else
-	archive_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      fi
-      ;;
+#include <stdio.h>
 
-    solaris*)
-      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
-	ld_shlibs_FC=no
-	cat <<_LT_EOF 1>&2
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL		RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL		DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL		0
+#  endif
+#endif
 
-*** Warning: The releases 2.8.* of the GNU linker cannot reliably
-*** create shared libraries on Solaris systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.9.1 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW		RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW		DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW	RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW	DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW	0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
 
-_LT_EOF
-      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs_FC=no
-      fi
-      ;;
+/* When -fvisbility=hidden is used, assume the code has been annotated
+   correspondingly for the symbols needed.  */
+#if defined(__GNUC__) && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))
+int fnord () __attribute__((visibility("default")));
+#endif
 
-    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
-      case `$LD -v 2>&1` in
-        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
-	ld_shlibs_FC=no
-	cat <<_LT_EOF 1>&2
+int fnord () { return 42; }
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
 
-*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
-*** reliably create shared libraries on SCO systems.  Therefore, libtool
-*** is disabling shared libraries support.  We urge you to upgrade GNU
-*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
-*** your PATH or compiler configuration so that the native linker is
-*** used, and then restart.
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else
+        {
+	  if (dlsym( self,"_fnord"))  status = $lt_dlneed_uscore;
+          else puts (dlerror ());
+	}
+      /* dlclose (self); */
+    }
+  else
+    puts (dlerror ());
 
+  return status;
+}
 _LT_EOF
-	;;
-	*)
-	  # For security reasons, it is highly recommended that you always
-	  # use absolute paths for naming shared libraries, and exclude the
-	  # DT_RUNPATH tag from executables and libraries.  But doing so
-	  # requires that you compile everything twice, which is a pain.
-	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	    hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
-	    archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-	  else
-	    ld_shlibs_FC=no
-	  fi
-	;;
-      esac
-      ;;
-
-    sunos4*)
-      archive_cmds_FC='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      wlarc=
-      hardcode_direct_FC=yes
-      hardcode_shlibpath_var_FC=no
-      ;;
-
-    *)
-      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	archive_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	archive_expsym_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-      else
-	ld_shlibs_FC=no
-      fi
-      ;;
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;
     esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self_static=no
+  fi
+fi
+rm -fr conftest*
 
-    if test "$ld_shlibs_FC" = no; then
-      runpath_var=
-      hardcode_libdir_flag_spec_FC=
-      export_dynamic_flag_spec_FC=
-      whole_archive_flag_spec_FC=
-    fi
-  else
-    # PORTME fill in a description of your system's linker (not GNU ld)
-    case $host_os in
-    aix3*)
-      allow_undefined_flag_FC=unsupported
-      always_export_symbols_FC=yes
-      archive_expsym_cmds_FC='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
-      # Note: this linker hardcodes the directories in LIBPATH if there
-      # are no directories specified by -L.
-      hardcode_minus_L_FC=yes
-      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
-	# Neither direct hardcoding nor static linking is supported with a
-	# broken collect2.
-	hardcode_direct_FC=unsupported
-      fi
-      ;;
 
-    aix[4-9]*)
-      if test "$host_cpu" = ia64; then
-	# On IA64, the linker does run time linking by default, so we don't
-	# have to do anything special.
-	aix_use_runtimelinking=no
-	exp_sym_flag='-Bexport'
-	no_entry_flag=""
-      else
-	# If we're using GNU nm, then we don't want the "-C" option.
-	# -C means demangle to AIX nm, but means don't demangle with GNU nm
-	# Also, AIX nm treats weak defined symbols like other global
-	# defined symbols, whereas GNU nm marks them as "W".
-	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-	  export_symbols_cmds_FC='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
-	else
-	  export_symbols_cmds_FC='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
-	fi
-	aix_use_runtimelinking=no
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
+$as_echo "$lt_cv_dlopen_self_static" >&6; }
+    fi
 
-	# Test if we are trying to use run time linking or normal
-	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
-	# need to do runtime linking.
-	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
-	  for ld_flag in $LDFLAGS; do
-	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
-	    aix_use_runtimelinking=yes
-	    break
-	  fi
-	  done
-	  ;;
-	esac
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
 
-	exp_sym_flag='-bexport'
-	no_entry_flag='-bnoentry'
-      fi
-
-      # When large executables or shared objects are built, AIX ld can
-      # have problems creating the table of contents.  If linking a library
-      # or program results in "error TOC overflow" add -mminimal-toc to
-      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
-
-      archive_cmds_FC=''
-      hardcode_direct_FC=yes
-      hardcode_direct_absolute_FC=yes
-      hardcode_libdir_separator_FC=':'
-      link_all_deplibs_FC=yes
-      file_list_spec_FC='${wl}-f,'
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
 
-      if test "$GCC" = yes; then
-	case $host_os in aix4.[012]|aix4.[012].*)
-	# We only want to do this on AIX 4.2 and lower, the check
-	# below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
-	  if test -f "$collect2name" &&
-	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
-	  then
-	  # We have reworked collect2
-	  :
-	  else
-	  # We have old collect2
-	  hardcode_direct_FC=unsupported
-	  # It fails to find uninstalled libraries when the uninstalled
-	  # path is not listed in the libpath.  Setting hardcode_minus_L
-	  # to unsupported forces relinking
-	  hardcode_minus_L_FC=yes
-	  hardcode_libdir_flag_spec_FC='-L$libdir'
-	  hardcode_libdir_separator_FC=
-	  fi
-	  ;;
-	esac
-	shared_flag='-shared'
-	if test "$aix_use_runtimelinking" = yes; then
-	  shared_flag="$shared_flag "'${wl}-G'
-	fi
-      else
-	# not using gcc
-	if test "$host_cpu" = ia64; then
-	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-	# chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-	else
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag='${wl}-G'
-	  else
-	    shared_flag='${wl}-bM:SRE'
-	  fi
-	fi
-      fi
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
 
-      export_dynamic_flag_spec_FC='${wl}-bexpall'
-      # It seems that -bexpall does not export symbols beginning with
-      # underscore (_), so it is better to generate a list of symbols to export.
-      always_export_symbols_FC=yes
-      if test "$aix_use_runtimelinking" = yes; then
-	# Warning - without using the other runtime loading flags (-brtl),
-	# -berok will link without error, but may produce a broken library.
-	allow_undefined_flag_FC='-berok'
-        # Determine the default libpath from the value encoded in an
-        # empty executable.
-        if test "${lt_cv_aix_libpath+set}" = set; then
-  aix_libpath=$lt_cv_aix_libpath
-else
-  if ${lt_cv_aix_libpath__FC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat > conftest.$ac_ext <<_ACEOF
-      program conftest
 
-      end
-_ACEOF
-if ac_fn_fc_try_link "$LINENO"; then :
 
-  lt_aix_libpath_sed='
-      /Import File Strings/,/^$/ {
-	  /^0/ {
-	      s/^0  *\([^ ]*\) *$/\1/
-	      p
-	  }
-      }'
-  lt_cv_aix_libpath__FC=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  # Check for a 64-bit object if we didn't find anything.
-  if test -z "$lt_cv_aix_libpath__FC"; then
-    lt_cv_aix_libpath__FC=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  fi
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  if test -z "$lt_cv_aix_libpath__FC"; then
-    lt_cv_aix_libpath__FC="/usr/lib:/lib"
-  fi
 
-fi
 
-  aix_libpath=$lt_cv_aix_libpath__FC
-fi
 
-        hardcode_libdir_flag_spec_FC='${wl}-blibpath:$libdir:'"$aix_libpath"
-        archive_expsym_cmds_FC='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-      else
-	if test "$host_cpu" = ia64; then
-	  hardcode_libdir_flag_spec_FC='${wl}-R $libdir:/usr/lib:/lib'
-	  allow_undefined_flag_FC="-z nodefs"
-	  archive_expsym_cmds_FC="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-	else
-	 # Determine the default libpath from the value encoded in an
-	 # empty executable.
-	 if test "${lt_cv_aix_libpath+set}" = set; then
-  aix_libpath=$lt_cv_aix_libpath
-else
-  if ${lt_cv_aix_libpath__FC+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat > conftest.$ac_ext <<_ACEOF
-      program conftest
 
-      end
-_ACEOF
-if ac_fn_fc_try_link "$LINENO"; then :
 
-  lt_aix_libpath_sed='
-      /Import File Strings/,/^$/ {
-	  /^0/ {
-	      s/^0  *\([^ ]*\) *$/\1/
-	      p
-	  }
-      }'
-  lt_cv_aix_libpath__FC=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  # Check for a 64-bit object if we didn't find anything.
-  if test -z "$lt_cv_aix_libpath__FC"; then
-    lt_cv_aix_libpath__FC=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  fi
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  if test -z "$lt_cv_aix_libpath__FC"; then
-    lt_cv_aix_libpath__FC="/usr/lib:/lib"
-  fi
 
-fi
 
-  aix_libpath=$lt_cv_aix_libpath__FC
-fi
 
-	 hardcode_libdir_flag_spec_FC='${wl}-blibpath:$libdir:'"$aix_libpath"
-	  # Warning - without using the other run time loading flags,
-	  # -berok will link without error, but may produce a broken library.
-	  no_undefined_flag_FC=' ${wl}-bernotok'
-	  allow_undefined_flag_FC=' ${wl}-berok'
-	  if test "$with_gnu_ld" = yes; then
-	    # We only use this code for GNU lds that support --whole-archive.
-	    whole_archive_flag_spec_FC='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
-	  else
-	    # Exported symbols can be pulled into shared objects from archives
-	    whole_archive_flag_spec_FC='$convenience'
-	  fi
-	  archive_cmds_need_lc_FC=yes
-	  # This is similar to how AIX traditionally builds its shared libraries.
-	  archive_expsym_cmds_FC="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-	fi
-      fi
-      ;;
 
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-            archive_expsym_cmds_FC=''
-        ;;
-      m68k)
-            archive_cmds_FC='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
-            hardcode_libdir_flag_spec_FC='-L$libdir'
-            hardcode_minus_L_FC=yes
-        ;;
-      esac
-      ;;
 
-    bsdi[45]*)
-      export_dynamic_flag_spec_FC=-rdynamic
-      ;;
 
-    cygwin* | mingw* | pw32* | cegcc*)
-      # When not using gcc, we currently assume that we are using
-      # Microsoft Visual C++.
-      # hardcode_libdir_flag_spec is actually meaningless, as there is
-      # no search path for DLLs.
-      case $cc_basename in
-      cl*)
-	# Native MSVC
-	hardcode_libdir_flag_spec_FC=' '
-	allow_undefined_flag_FC=unsupported
-	always_export_symbols_FC=yes
-	file_list_spec_FC='@'
-	# Tell ltmain to make .lib files, not .a files.
-	libext=lib
-	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
-	# FIXME: Setting linknames here is a bad hack.
-	archive_cmds_FC='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	archive_expsym_cmds_FC='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	  else
-	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	  fi~
-	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	  linknames='
-	# The linker will not automatically build a static lib if we build a DLL.
-	# _LT_TAGVAR(old_archive_from_new_cmds, FC)='true'
-	enable_shared_with_static_runtimes_FC=yes
-	exclude_expsyms_FC='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
-	export_symbols_cmds_FC='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
-	# Don't use ranlib
-	old_postinstall_cmds_FC='chmod 644 $oldlib'
-	postlink_cmds_FC='lt_outputfile="@OUTPUT@"~
-	  lt_tool_outputfile="@TOOL_OUTPUT@"~
-	  case $lt_outputfile in
-	    *.exe|*.EXE) ;;
-	    *)
-	      lt_outputfile="$lt_outputfile.exe"
-	      lt_tool_outputfile="$lt_tool_outputfile.exe"
-	      ;;
-	  esac~
-	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	    $RM "$lt_outputfile.manifest";
-	  fi'
-	;;
-      *)
-	# Assume MSVC wrapper
-	hardcode_libdir_flag_spec_FC=' '
-	allow_undefined_flag_FC=unsupported
-	# Tell ltmain to make .lib files, not .a files.
-	libext=lib
-	# Tell ltmain to make .dll files, not .so files.
-	shrext_cmds=".dll"
-	# FIXME: Setting linknames here is a bad hack.
-	archive_cmds_FC='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
-	# The linker will automatically build a .lib file if we build a DLL.
-	old_archive_from_new_cmds_FC='true'
-	# FIXME: Should let the user specify the lib program.
-	old_archive_cmds_FC='lib -OUT:$oldlib$oldobjs$old_deplibs'
-	enable_shared_with_static_runtimes_FC=yes
-	;;
-      esac
-      ;;
 
-    darwin* | rhapsody*)
 
 
-  archive_cmds_need_lc_FC=no
-  hardcode_direct_FC=no
-  hardcode_automatic_FC=yes
-  hardcode_shlibpath_var_FC=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    whole_archive_flag_spec_FC='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
-    compiler_needs_object_FC=yes
-  else
-    whole_archive_flag_spec_FC=''
-  fi
-  link_all_deplibs_FC=yes
-  allow_undefined_flag_FC="$_lt_dar_allow_undefined"
-  case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
-     *) _lt_dar_can_shared=$GCC ;;
+striplib=
+old_striplib=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
+$as_echo_n "checking whether stripping libraries is possible... " >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+  darwin*)
+    if test -n "$STRIP" ; then
+      striplib="$STRIP -x"
+      old_striplib="$STRIP -S"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    fi
+    ;;
+  *)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    ;;
   esac
-  if test "$_lt_dar_can_shared" = "yes"; then
-    output_verbose_link_cmd=func_echo_all
-    archive_cmds_FC="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    module_cmds_FC="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds_FC="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    module_expsym_cmds_FC="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+fi
 
-  else
-  ld_shlibs_FC=no
-  fi
 
-      ;;
 
-    dgux*)
-      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec_FC='-L$libdir'
-      hardcode_shlibpath_var_FC=no
-      ;;
 
-    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
-    # support.  Future versions do this automatically, but an explicit c++rt0.o
-    # does not break anything, and helps significantly (at the cost of a little
-    # extra space).
-    freebsd2.2*)
-      archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
-      hardcode_libdir_flag_spec_FC='-R$libdir'
-      hardcode_direct_FC=yes
-      hardcode_shlibpath_var_FC=no
-      ;;
 
-    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
-    freebsd2.*)
-      archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct_FC=yes
-      hardcode_minus_L_FC=yes
-      hardcode_shlibpath_var_FC=no
-      ;;
 
-    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
-    freebsd* | dragonfly*)
-      archive_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-      hardcode_libdir_flag_spec_FC='-R$libdir'
-      hardcode_direct_FC=yes
-      hardcode_shlibpath_var_FC=no
-      ;;
 
-    hpux9*)
-      if test "$GCC" = yes; then
-	archive_cmds_FC='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      else
-	archive_cmds_FC='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-      fi
-      hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
-      hardcode_libdir_separator_FC=:
-      hardcode_direct_FC=yes
 
-      # hardcode_minus_L: Not really in the search PATH,
-      # but as the default location of the library.
-      hardcode_minus_L_FC=yes
-      export_dynamic_flag_spec_FC='${wl}-E'
-      ;;
 
-    hpux10*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	archive_cmds_FC='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_FC='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator_FC=:
-	hardcode_direct_FC=yes
-	hardcode_direct_absolute_FC=yes
-	export_dynamic_flag_spec_FC='${wl}-E'
-	# hardcode_minus_L: Not really in the search PATH,
-	# but as the default location of the library.
-	hardcode_minus_L_FC=yes
-      fi
-      ;;
 
-    hpux11*)
-      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_FC='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_FC='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_FC='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      else
-	case $host_cpu in
-	hppa*64*)
-	  archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	ia64*)
-	  archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	esac
-      fi
-      if test "$with_gnu_ld" = no; then
-	hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
-	hardcode_libdir_separator_FC=:
 
-	case $host_cpu in
-	hppa*64*|ia64*)
-	  hardcode_direct_FC=no
-	  hardcode_shlibpath_var_FC=no
-	  ;;
-	*)
-	  hardcode_direct_FC=yes
-	  hardcode_direct_absolute_FC=yes
-	  export_dynamic_flag_spec_FC='${wl}-E'
 
-	  # hardcode_minus_L: Not really in the search PATH,
-	  # but as the default location of the library.
-	  hardcode_minus_L_FC=yes
-	  ;;
-	esac
-      fi
-      ;;
+  # Report which library types will actually be built
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
 
-    irix5* | irix6* | nonstopux*)
-      if test "$GCC" = yes; then
-	archive_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	# Try to use the -exported_symbol ld option, if it does not
-	# work, assume that -exports_file does not work either and
-	# implicitly export all symbols.
-	# This should be the same for all languages, so no per-tag cache variable.
-	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5
-$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; }
-if ${lt_cv_irix_exported_symbol+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  save_LDFLAGS="$LDFLAGS"
-	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
-	   cat > conftest.$ac_ext <<_ACEOF
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+  test "$can_build_shared" = "no" && enable_shared=no
 
-      subroutine foo
-      end
-_ACEOF
-if ac_fn_fc_try_link "$LINENO"; then :
-  lt_cv_irix_exported_symbol=yes
-else
-  lt_cv_irix_exported_symbol=no
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-           LDFLAGS="$save_LDFLAGS"
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
-$as_echo "$lt_cv_irix_exported_symbol" >&6; }
-	if test "$lt_cv_irix_exported_symbol" = yes; then
-          archive_expsym_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
-	fi
-      else
-	archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
-      fi
-      archive_cmds_need_lc_FC='no'
-      hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_FC=:
-      inherit_rpath_FC=yes
-      link_all_deplibs_FC=yes
-      ;;
+  # On AIX, shared libraries and static libraries use the same namespace, and
+  # are all built from PIC.
+  case $host_os in
+  aix3*)
+    test "$enable_shared" = yes && enable_static=no
+    if test -n "$RANLIB"; then
+      archive_cmds="$archive_cmds~\$RANLIB \$lib"
+      postinstall_cmds='$RANLIB $lib'
+    fi
+    ;;
 
-    netbsd*)
-      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
-      else
-	archive_cmds_FC='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
-      fi
-      hardcode_libdir_flag_spec_FC='-R$libdir'
-      hardcode_direct_FC=yes
-      hardcode_shlibpath_var_FC=no
-      ;;
+  aix[4-9]*)
+    if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+      test "$enable_shared" = yes && enable_static=no
+    fi
+    ;;
+  esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
 
-    newsos6)
-      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_direct_FC=yes
-      hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_FC=:
-      hardcode_shlibpath_var_FC=no
-      ;;
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+  # Make sure either enable_shared or enable_static is yes.
+  test "$enable_shared" = yes || enable_static=yes
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
 
-    *nto* | *qnx*)
-      ;;
 
-    openbsd*)
-      if test -f /usr/libexec/ld.so; then
-	hardcode_direct_FC=yes
-	hardcode_shlibpath_var_FC=no
-	hardcode_direct_absolute_FC=yes
-	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	  archive_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
-	  hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
-	  export_dynamic_flag_spec_FC='${wl}-E'
-	else
-	  case $host_os in
-	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
-	     archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
-	     hardcode_libdir_flag_spec_FC='-R$libdir'
-	     ;;
-	   *)
-	     archive_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
-	     hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
-	     ;;
-	  esac
-	fi
-      else
-	ld_shlibs_FC=no
-      fi
-      ;;
-
-    os2*)
-      hardcode_libdir_flag_spec_FC='-L$libdir'
-      hardcode_minus_L_FC=yes
-      allow_undefined_flag_FC=unsupported
-      archive_cmds_FC='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
-      old_archive_from_new_cmds_FC='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
-      ;;
 
-    osf3*)
-      if test "$GCC" = yes; then
-	allow_undefined_flag_FC=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-      else
-	allow_undefined_flag_FC=' -expect_unresolved \*'
-	archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-      fi
-      archive_cmds_need_lc_FC='no'
-      hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
-      hardcode_libdir_separator_FC=:
-      ;;
 
-    osf4* | osf5*)	# as osf3* with the addition of -msym flag
-      if test "$GCC" = yes; then
-	allow_undefined_flag_FC=' ${wl}-expect_unresolved ${wl}\*'
-	archive_cmds_FC='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
-      else
-	allow_undefined_flag_FC=' -expect_unresolved \*'
-	archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	archive_expsym_cmds_FC='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
-	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+fi
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-	# Both c and cxx compiler support -rpath directly
-	hardcode_libdir_flag_spec_FC='-rpath $libdir'
-      fi
-      archive_cmds_need_lc_FC='no'
-      hardcode_libdir_separator_FC=:
-      ;;
+CC="$lt_save_CC"
 
-    solaris*)
-      no_undefined_flag_FC=' -z defs'
-      if test "$GCC" = yes; then
-	wlarc='${wl}'
-	archive_cmds_FC='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
-      else
-	case `$CC -V 2>&1` in
-	*"Compilers 5.0"*)
-	  wlarc=''
-	  archive_cmds_FC='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
-	  ;;
-	*)
-	  wlarc='${wl}'
-	  archive_cmds_FC='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
-	  ;;
-	esac
-      fi
-      hardcode_libdir_flag_spec_FC='-R$libdir'
-      hardcode_shlibpath_var_FC=no
-      case $host_os in
-      solaris2.[0-5] | solaris2.[0-5].*) ;;
-      *)
-	# The compiler driver will combine and reorder linker options,
-	# but understands `-z linker_flag'.  GCC discards it without `$wl',
-	# but is careful enough not to reorder.
-	# Supported since Solaris 2.6 (maybe 2.5.1?)
-	if test "$GCC" = yes; then
-	  whole_archive_flag_spec_FC='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
-	else
-	  whole_archive_flag_spec_FC='-z allextract$convenience -z defaultextract'
-	fi
-	;;
-      esac
-      link_all_deplibs_FC=yes
-      ;;
+      if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    (test "X$CXX" != "Xg++"))) ; then
+  ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5
+$as_echo_n "checking how to run the C++ preprocessor... " >&6; }
+if test -z "$CXXCPP"; then
+  if ${ac_cv_prog_CXXCPP+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+      # Double quotes because CXXCPP needs to be expanded
+    for CXXCPP in "$CXX -E" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
 
-    sunos4*)
-      if test "x$host_vendor" = xsequent; then
-	# Use $CC to link under sequent, because it throws in some extra .o
-	# files that make .init and .fini sections work.
-	archive_cmds_FC='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_FC='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
-      fi
-      hardcode_libdir_flag_spec_FC='-L$libdir'
-      hardcode_direct_FC=yes
-      hardcode_minus_L_FC=yes
-      hardcode_shlibpath_var_FC=no
-      ;;
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
 
-    sysv4)
-      case $host_vendor in
-	sni)
-	  archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct_FC=yes # is this really true???
-	;;
-	siemens)
-	  ## LD is ld it makes a PLAMLIB
-	  ## CC just makes a GrossModule.
-	  archive_cmds_FC='$LD -G -o $lib $libobjs $deplibs $linker_flags'
-	  reload_cmds_FC='$CC -r -o $output$reload_objs'
-	  hardcode_direct_FC=no
-        ;;
-	motorola)
-	  archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	  hardcode_direct_FC=no #Motorola manual says yes, but my tests say they lie
-	;;
-      esac
-      runpath_var='LD_RUN_PATH'
-      hardcode_shlibpath_var_FC=no
-      ;;
-
-    sysv4.3*)
-      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_shlibpath_var_FC=no
-      export_dynamic_flag_spec_FC='-Bexport'
-      ;;
-
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-	hardcode_shlibpath_var_FC=no
-	runpath_var=LD_RUN_PATH
-	hardcode_runpath_var=yes
-	ld_shlibs_FC=yes
-      fi
-      ;;
-
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag_FC='${wl}-z,text'
-      archive_cmds_need_lc_FC=no
-      hardcode_shlibpath_var_FC=no
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	archive_cmds_FC='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_FC='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_FC='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_FC='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
-
-    sysv5* | sco3.2v5* | sco5v6*)
-      # Note: We can NOT use -z defs as we might desire, because we do not
-      # link with -lc, and that would cause any symbols used from libc to
-      # always be unresolved, which means just about no library would
-      # ever link correctly.  If we're not using GNU ld we use -z text
-      # though, which does catch some bad symbols but isn't as heavy-handed
-      # as -z defs.
-      no_undefined_flag_FC='${wl}-z,text'
-      allow_undefined_flag_FC='${wl}-z,nodefs'
-      archive_cmds_need_lc_FC=no
-      hardcode_shlibpath_var_FC=no
-      hardcode_libdir_flag_spec_FC='${wl}-R,$libdir'
-      hardcode_libdir_separator_FC=':'
-      link_all_deplibs_FC=yes
-      export_dynamic_flag_spec_FC='${wl}-Bexport'
-      runpath_var='LD_RUN_PATH'
-
-      if test "$GCC" = yes; then
-	archive_cmds_FC='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_FC='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      else
-	archive_cmds_FC='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	archive_expsym_cmds_FC='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-      fi
-      ;;
-
-    uts4*)
-      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
-      hardcode_libdir_flag_spec_FC='-L$libdir'
-      hardcode_shlibpath_var_FC=no
-      ;;
-
-    *)
-      ld_shlibs_FC=no
-      ;;
-    esac
-
-    if test x$host_vendor = xsni; then
-      case $host in
-      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
-	export_dynamic_flag_spec_FC='${wl}-Blargedynsym'
-	;;
-      esac
-    fi
-  fi
-
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_FC" >&5
-$as_echo "$ld_shlibs_FC" >&6; }
-test "$ld_shlibs_FC" = no && can_build_shared=no
-
-with_gnu_ld_FC=$with_gnu_ld
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
 
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+  break
+fi
 
+    done
+    ac_cv_prog_CXXCPP=$CXXCPP
 
+fi
+  CXXCPP=$ac_cv_prog_CXXCPP
+else
+  ac_cv_prog_CXXCPP=$CXXCPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5
+$as_echo "$CXXCPP" >&6; }
+ac_preproc_ok=false
+for ac_cxx_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+		     Syntax error
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
 
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
 
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_cxx_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.i conftest.$ac_ext
 
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_FC" in
-x|xyes)
-  # Assume -lc should be added
-  archive_cmds_need_lc_FC=yes
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.i conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
-    case $archive_cmds_FC in
-    *'~'*)
-      # FIXME: we may have to deal with multi-command sequences.
-      ;;
-    '$CC '*)
-      # Test whether the compiler implicitly links with -lc since on some
-      # systems, -lgcc has to come before -lc. If gcc already passes -lc
-      # to ld, don't add -lc before -lgcc.
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
-$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
-if ${lt_cv_archive_cmds_need_lc_FC+:} false; then :
-  $as_echo_n "(cached) " >&6
 else
-  $RM conftest*
-	echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check
+See \`config.log' for more details" "$LINENO" 5; }
+fi
 
-	if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } 2>conftest.err; then
-	  soname=conftest
-	  lib=conftest
-	  libobjs=conftest.$ac_objext
-	  deplibs=
-	  wl=$lt_prog_compiler_wl_FC
-	  pic_flag=$lt_prog_compiler_pic_FC
-	  compiler_flags=-v
-	  linker_flags=-v
-	  verstring=
-	  output_objdir=.
-	  libname=conftest
-	  lt_save_allow_undefined_flag=$allow_undefined_flag_FC
-	  allow_undefined_flag_FC=
-	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_FC 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
-  (eval $archive_cmds_FC 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-	  then
-	    lt_cv_archive_cmds_need_lc_FC=no
-	  else
-	    lt_cv_archive_cmds_need_lc_FC=yes
-	  fi
-	  allow_undefined_flag_FC=$lt_save_allow_undefined_flag
-	else
-	  cat conftest.err 1>&5
-	fi
-	$RM conftest*
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+else
+  _lt_caught_CXX_error=yes
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_FC" >&5
-$as_echo "$lt_cv_archive_cmds_need_lc_FC" >&6; }
-      archive_cmds_need_lc_FC=$lt_cv_archive_cmds_need_lc_FC
-      ;;
-    esac
-  fi
-  ;;
-esac
-
-
-
-
-
-
-
-
-
-
-
-
 
+ac_ext=cpp
+ac_cpp='$CXXCPP $CPPFLAGS'
+ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
 
+archive_cmds_need_lc_CXX=no
+allow_undefined_flag_CXX=
+always_export_symbols_CXX=no
+archive_expsym_cmds_CXX=
+compiler_needs_object_CXX=no
+export_dynamic_flag_spec_CXX=
+hardcode_direct_CXX=no
+hardcode_direct_absolute_CXX=no
+hardcode_libdir_flag_spec_CXX=
+hardcode_libdir_separator_CXX=
+hardcode_minus_L_CXX=no
+hardcode_shlibpath_var_CXX=unsupported
+hardcode_automatic_CXX=no
+inherit_rpath_CXX=no
+module_cmds_CXX=
+module_expsym_cmds_CXX=
+link_all_deplibs_CXX=unknown
+old_archive_cmds_CXX=$old_archive_cmds
+reload_flag_CXX=$reload_flag
+reload_cmds_CXX=$reload_cmds
+no_undefined_flag_CXX=
+whole_archive_flag_spec_CXX=
+enable_shared_with_static_runtimes_CXX=no
 
+# Source file extension for C++ test sources.
+ac_ext=cpp
 
+# Object file extension for compiled C++ test sources.
+objext=o
+objext_CXX=$objext
 
+# No sense in running all these tests if we already determined that
+# the CXX compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_caught_CXX_error" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="int some_variable = 0;"
 
+  # Code to be used in simple link tests
+  lt_simple_link_test_code='int main(int, char *[]) { return(0); }'
 
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
 
 
 
 
 
 
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
 
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
 
+# Allow CC to be a program name with arguments.
+compiler=$CC
 
 
+  # save warnings/boilerplate of simple test code
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
 
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
 
 
+  # Allow CC to be a program name with arguments.
+  lt_save_CC=$CC
+  lt_save_CFLAGS=$CFLAGS
+  lt_save_LD=$LD
+  lt_save_GCC=$GCC
+  GCC=$GXX
+  lt_save_with_gnu_ld=$with_gnu_ld
+  lt_save_path_LD=$lt_cv_path_LD
+  if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+  else
+    $as_unset lt_cv_prog_gnu_ld
+  fi
+  if test -n "${lt_cv_path_LDCXX+set}"; then
+    lt_cv_path_LD=$lt_cv_path_LDCXX
+  else
+    $as_unset lt_cv_path_LD
+  fi
+  test -z "${LDCXX+set}" || LD=$LDCXX
+  CC=${CXX-"c++"}
+  CFLAGS=$CXXFLAGS
+  compiler=$CC
+  compiler_CXX=$CC
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
 
 
+  if test -n "$compiler"; then
+    # We don't want -fno-exception when compiling C++ code, so set the
+    # no_builtin_flag separately
+    if test "$GXX" = yes; then
+      lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
+    else
+      lt_prog_compiler_no_builtin_flag_CXX=
+    fi
 
+    if test "$GXX" = yes; then
+      # Set up default GNU C++ configuration
 
 
 
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
 
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | ?:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
+      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
+	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if ${lt_cv_path_LD+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+	test "$with_gnu_ld" != no && break
+	;;
+      *)
+	test "$with_gnu_ld" != yes && break
+	;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
 
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if ${lt_cv_prog_gnu_ld+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
 
 
 
@@ -14762,1780 +14579,2820 @@ esac
 
 
 
+      # Check if GNU C++ uses GNU ld as the underlying linker, since the
+      # archiving commands below assume that GNU ld is being used.
+      if test "$with_gnu_ld" = yes; then
+        archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
 
+        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+        export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
 
+        # If archive_cmds runs LD, not CC, wlarc should be empty
+        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+        #     investigate it a little bit more. (MM)
+        wlarc='${wl}'
 
+        # ancient GNU ld didn't support --whole-archive et. al.
+        if eval "`$CC -print-prog-name=ld` --help 2>&1" |
+	  $GREP 'no-whole-archive' > /dev/null; then
+          whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+        else
+          whole_archive_flag_spec_CXX=
+        fi
+      else
+        with_gnu_ld=no
+        wlarc=
 
+        # A generic and very simple default shared library creation
+        # command for GNU C++ for the case where it uses the native
+        # linker, instead of GNU ld.  If possible, this setting should
+        # overridden to take advantage of the native linker features on
+        # the platform it is being used on.
+        archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+      fi
 
+      # Commands to make compiler produce verbose output that lists
+      # what "hidden" libraries, object files and flags are used when
+      # linking a shared library.
+      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 
+    else
+      GXX=no
+      with_gnu_ld=no
+      wlarc=
+    fi
 
+    # PORTME: fill in a description of your system's C++ link characteristics
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+    ld_shlibs_CXX=yes
+    case $host_os in
+      aix3*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
+      aix[4-9]*)
+        if test "$host_cpu" = ia64; then
+          # On IA64, the linker does run time linking by default, so we don't
+          # have to do anything special.
+          aix_use_runtimelinking=no
+          exp_sym_flag='-Bexport'
+          no_entry_flag=""
+        else
+          aix_use_runtimelinking=no
 
+          # Test if we are trying to use run time linking or normal
+          # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+          # need to do runtime linking.
+          case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+	    for ld_flag in $LDFLAGS; do
+	      case $ld_flag in
+	      *-brtl*)
+	        aix_use_runtimelinking=yes
+	        break
+	        ;;
+	      esac
+	    done
+	    ;;
+          esac
 
+          exp_sym_flag='-bexport'
+          no_entry_flag='-bnoentry'
+        fi
 
+        # When large executables or shared objects are built, AIX ld can
+        # have problems creating the table of contents.  If linking a library
+        # or program results in "error TOC overflow" add -mminimal-toc to
+        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
 
+        archive_cmds_CXX=''
+        hardcode_direct_CXX=yes
+        hardcode_direct_absolute_CXX=yes
+        hardcode_libdir_separator_CXX=':'
+        link_all_deplibs_CXX=yes
+        file_list_spec_CXX='${wl}-f,'
 
+        if test "$GXX" = yes; then
+          case $host_os in aix4.[012]|aix4.[012].*)
+          # We only want to do this on AIX 4.2 and lower, the check
+          # below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	    # We have reworked collect2
+	    :
+	  else
+	    # We have old collect2
+	    hardcode_direct_CXX=unsupported
+	    # It fails to find uninstalled libraries when the uninstalled
+	    # path is not listed in the libpath.  Setting hardcode_minus_L
+	    # to unsupported forces relinking
+	    hardcode_minus_L_CXX=yes
+	    hardcode_libdir_flag_spec_CXX='-L$libdir'
+	    hardcode_libdir_separator_CXX=
+	  fi
+          esac
+          shared_flag='-shared'
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag="$shared_flag "'${wl}-G'
+	  fi
+        else
+          # not using gcc
+          if test "$host_cpu" = ia64; then
+	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	  # chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+          else
+	    if test "$aix_use_runtimelinking" = yes; then
+	      shared_flag='${wl}-G'
+	    else
+	      shared_flag='${wl}-bM:SRE'
+	    fi
+          fi
+        fi
 
+        export_dynamic_flag_spec_CXX='${wl}-bexpall'
+        # It seems that -bexpall does not export symbols beginning with
+        # underscore (_), so it is better to generate a list of symbols to
+	# export.
+        always_export_symbols_CXX=yes
+        if test "$aix_use_runtimelinking" = yes; then
+          # Warning - without using the other runtime loading flags (-brtl),
+          # -berok will link without error, but may produce a broken library.
+          allow_undefined_flag_CXX='-berok'
+          # Determine the default libpath from the value encoded in an empty
+          # executable.
+          if test "${lt_cv_aix_libpath+set}" = set; then
+  aix_libpath=$lt_cv_aix_libpath
+else
+  if ${lt_cv_aix_libpath__CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
+int
+main ()
+{
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
-$as_echo_n "checking dynamic linker characteristics... " >&6; }
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
 
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-need_lib_prefix=unknown
-hardcode_into_libs=no
+  lt_aix_libpath_sed='
+      /Import File Strings/,/^$/ {
+	  /^0/ {
+	      s/^0  *\([^ ]*\) *$/\1/
+	      p
+	  }
+      }'
+  lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  # Check for a 64-bit object if we didn't find anything.
+  if test -z "$lt_cv_aix_libpath__CXX"; then
+    lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  if test -z "$lt_cv_aix_libpath__CXX"; then
+    lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+  fi
 
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
+fi
 
-case $host_os in
-aix3*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
-  shlibpath_var=LIBPATH
+  aix_libpath=$lt_cv_aix_libpath__CXX
+fi
 
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
-  ;;
+          hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
 
-aix[4-9]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
-    case $host_os in
-      aix4 | aix4.[01] | aix4.[01].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
-	:
-      else
-	can_build_shared=no
-      fi
-      ;;
-    esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
-      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
-      # instead of lib<name>.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
-    shlibpath_var=LIBPATH
-  fi
-  ;;
+          archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+        else
+          if test "$host_cpu" = ia64; then
+	    hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
+	    allow_undefined_flag_CXX="-z nodefs"
+	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+          else
+	    # Determine the default libpath from the value encoded in an
+	    # empty executable.
+	    if test "${lt_cv_aix_libpath+set}" = set; then
+  aix_libpath=$lt_cv_aix_libpath
+else
+  if ${lt_cv_aix_libpath__CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-amigaos*)
-  case $host_cpu in
-  powerpc)
-    # Since July 2007 AmigaOS4 officially supports .so libraries.
-    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    ;;
-  m68k)
-    library_names_spec='$libname.ixlibrary $libname.a'
-    # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-    ;;
-  esac
-  ;;
+int
+main ()
+{
 
-beos*)
-  library_names_spec='${libname}${shared_ext}'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  ;;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_cxx_try_link "$LINENO"; then :
 
-bsdi[45]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
+  lt_aix_libpath_sed='
+      /Import File Strings/,/^$/ {
+	  /^0/ {
+	      s/^0  *\([^ ]*\) *$/\1/
+	      p
+	  }
+      }'
+  lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  # Check for a 64-bit object if we didn't find anything.
+  if test -z "$lt_cv_aix_libpath__CXX"; then
+    lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  if test -z "$lt_cv_aix_libpath__CXX"; then
+    lt_cv_aix_libpath__CXX="/usr/lib:/lib"
+  fi
 
-cygwin* | mingw* | pw32* | cegcc*)
-  version_type=windows
-  shrext_cmds=".dll"
-  need_version=no
-  need_lib_prefix=no
+fi
 
-  case $GCC,$cc_basename in
-  yes,*)
-    # gcc
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname~
-      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
-        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
-      fi'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $RM \$dlpath'
-    shlibpath_overrides_runpath=yes
+  aix_libpath=$lt_cv_aix_libpath__CXX
+fi
 
-    case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+	    hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+	    # Warning - without using the other run time loading flags,
+	    # -berok will link without error, but may produce a broken library.
+	    no_undefined_flag_CXX=' ${wl}-bernotok'
+	    allow_undefined_flag_CXX=' ${wl}-berok'
+	    if test "$with_gnu_ld" = yes; then
+	      # We only use this code for GNU lds that support --whole-archive.
+	      whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    else
+	      # Exported symbols can be pulled into shared objects from archives
+	      whole_archive_flag_spec_CXX='$convenience'
+	    fi
+	    archive_cmds_need_lc_CXX=yes
+	    # This is similar to how AIX traditionally builds its shared
+	    # libraries.
+	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+          fi
+        fi
+        ;;
 
-      ;;
-    mingw* | cegcc*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    esac
-    dynamic_linker='Win32 ld.exe'
-    ;;
+      beos*)
+	if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	  allow_undefined_flag_CXX=unsupported
+	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+	  # support --undefined.  This deserves some investigation.  FIXME
+	  archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	else
+	  ld_shlibs_CXX=no
+	fi
+	;;
 
-  *,cl*)
-    # Native MSVC
-    libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+      chorus*)
+        case $cc_basename in
+          *)
+	  # FIXME: insert proper C++ library support
+	  ld_shlibs_CXX=no
+	  ;;
+        esac
+        ;;
 
-    case $build_os in
-    mingw*)
-      sys_lib_search_path_spec=
-      lt_save_ifs=$IFS
-      IFS=';'
-      for lt_path in $LIB
-      do
-        IFS=$lt_save_ifs
-        # Let DOS variable expansion print the short 8.3 style file name.
-        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
-        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
-      done
-      IFS=$lt_save_ifs
-      # Convert to MSYS style.
-      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
-      ;;
-    cygwin*)
-      # Convert to unix form, then to dos form, then back to unix form
-      # but this time dos style (no spaces!) so that the unix form looks
-      # like /cygdrive/c/PROGRA~1:/cygdr...
-      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
-      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
-      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
-      ;;
-    *)
-      sys_lib_search_path_spec="$LIB"
-      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
-        # It is most probably a Windows format PATH.
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-      else
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
-      fi
-      # FIXME: find the short name or the path components, as spaces are
-      # common. (e.g. "Program Files" -> "PROGRA~1")
-      ;;
-    esac
-
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $RM \$dlpath'
-    shlibpath_overrides_runpath=yes
-    dynamic_linker='Win32 link.exe'
-    ;;
-
-  *)
-    # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
-    dynamic_linker='Win32 ld.exe'
-    ;;
-  esac
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  ;;
+      cygwin* | mingw* | pw32* | cegcc*)
+	case $GXX,$cc_basename in
+	,cl* | no,cl*)
+	  # Native MSVC
+	  # hardcode_libdir_flag_spec is actually meaningless, as there is
+	  # no search path for DLLs.
+	  hardcode_libdir_flag_spec_CXX=' '
+	  allow_undefined_flag_CXX=unsupported
+	  always_export_symbols_CXX=yes
+	  file_list_spec_CXX='@'
+	  # Tell ltmain to make .lib files, not .a files.
+	  libext=lib
+	  # Tell ltmain to make .dll files, not .so files.
+	  shrext_cmds=".dll"
+	  # FIXME: Setting linknames here is a bad hack.
+	  archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+	  archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+	    else
+	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+	    fi~
+	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+	    linknames='
+	  # The linker will not automatically build a static lib if we build a DLL.
+	  # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true'
+	  enable_shared_with_static_runtimes_CXX=yes
+	  # Don't use ranlib
+	  old_postinstall_cmds_CXX='chmod 644 $oldlib'
+	  postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~
+	    lt_tool_outputfile="@TOOL_OUTPUT@"~
+	    case $lt_outputfile in
+	      *.exe|*.EXE) ;;
+	      *)
+		lt_outputfile="$lt_outputfile.exe"
+		lt_tool_outputfile="$lt_tool_outputfile.exe"
+		;;
+	    esac~
+	    func_to_tool_file "$lt_outputfile"~
+	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+	      $RM "$lt_outputfile.manifest";
+	    fi'
+	  ;;
+	*)
+	  # g++
+	  # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
+	  # as there is no search path for DLLs.
+	  hardcode_libdir_flag_spec_CXX='-L$libdir'
+	  export_dynamic_flag_spec_CXX='${wl}--export-all-symbols'
+	  allow_undefined_flag_CXX=unsupported
+	  always_export_symbols_CXX=no
+	  enable_shared_with_static_runtimes_CXX=yes
 
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	    # If the export-symbols file already is a .def file (1st line
+	    # is EXPORTS), use it as is; otherwise, prepend...
+	    archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	      cp $export_symbols $output_objdir/$soname.def;
+	    else
+	      echo EXPORTS > $output_objdir/$soname.def;
+	      cat $export_symbols >> $output_objdir/$soname.def;
+	    fi~
+	    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	  else
+	    ld_shlibs_CXX=no
+	  fi
+	  ;;
+	esac
+	;;
+      darwin* | rhapsody*)
 
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
-  ;;
 
-dgux*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
+  archive_cmds_need_lc_CXX=no
+  hardcode_direct_CXX=no
+  hardcode_automatic_CXX=yes
+  hardcode_shlibpath_var_CXX=unsupported
+  if test "$lt_cv_ld_force_load" = "yes"; then
+    whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
   else
-    case $host_os in
-    freebsd[23].*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
+    whole_archive_flag_spec_CXX=''
   fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-      need_version=no
-      need_lib_prefix=no
-      ;;
-    freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
-      need_version=yes
-      ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_os in
-  freebsd2.*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
-  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  *) # from 4.6 on, and DragonFly
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
+  link_all_deplibs_CXX=yes
+  allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
+  case $cc_basename in
+     ifort*) _lt_dar_can_shared=yes ;;
+     *) _lt_dar_can_shared=$GCC ;;
   esac
-  ;;
+  if test "$_lt_dar_can_shared" = "yes"; then
+    output_verbose_link_cmd=func_echo_all
+    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
+       if test "$lt_cv_apple_cc_single_mod" != "yes"; then
+      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
+      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
+    fi
 
-gnu*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
+  else
+  ld_shlibs_CXX=no
+  fi
 
-haiku*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
-  hardcode_into_libs=yes
-  ;;
+	;;
 
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
-    fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  hppa*64*)
-    shrext_cmds='.sl'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
-  postinstall_cmds='chmod 555 $lib'
-  # or fails outright, so override atomically:
-  install_override_mode=555
-  ;;
-
-interix[3-9]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
-    *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux # correct to gnu/linux during the next big refactor
-	else
-		version_type=irix
-	fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
-  *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  hardcode_into_libs=yes
-  ;;
-
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
-
-# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
+      dgux*)
+        case $cc_basename in
+          ec++*)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          ghcx*)
+	    # Green Hills C++ Compiler
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+        esac
+        ;;
 
-  # Some binutils ld are patched to set DT_RUNPATH
-  if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_shlibpath_overrides_runpath=no
-    save_LDFLAGS=$LDFLAGS
-    save_libdir=$libdir
-    eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_FC\"; \
-	 LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_FC\""
-    cat > conftest.$ac_ext <<_ACEOF
-      program conftest
+      freebsd2.*)
+        # C++ shared libraries reported to be fairly broken before
+	# switch to ELF
+        ld_shlibs_CXX=no
+        ;;
 
-      end
-_ACEOF
-if ac_fn_fc_try_link "$LINENO"; then :
-  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
-  lt_cv_shlibpath_overrides_runpath=yes
-fi
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-    LDFLAGS=$save_LDFLAGS
-    libdir=$save_libdir
+      freebsd-elf*)
+        archive_cmds_need_lc_CXX=no
+        ;;
 
-fi
+      freebsd* | dragonfly*)
+        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+        # conventions
+        ld_shlibs_CXX=yes
+        ;;
 
-  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
+      gnu*)
+        ;;
 
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
+      haiku*)
+        archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+        link_all_deplibs_CXX=yes
+        ;;
 
-  # Append ld.so.conf contents to the search path
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
-  fi
+      hpux9*)
+        hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+        hardcode_libdir_separator_CXX=:
+        export_dynamic_flag_spec_CXX='${wl}-E'
+        hardcode_direct_CXX=yes
+        hardcode_minus_L_CXX=yes # Not in the search PATH,
+				             # but as the default
+				             # location of the library.
 
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
+        case $cc_basename in
+          CC*)
+            # FIXME: insert proper C++ library support
+            ld_shlibs_CXX=no
+            ;;
+          aCC*)
+            archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            # Commands to make compiler produce verbose output that lists
+            # what "hidden" libraries, object files and flags are used when
+            # linking a shared library.
+            #
+            # There doesn't appear to be a way to prevent this compiler from
+            # explicitly linking system object files so we need to strip them
+            # from the output so that they don't get included in the library
+            # dependencies.
+            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+            ;;
+          *)
+            if test "$GXX" = yes; then
+              archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+            else
+              # FIXME: insert proper C++ library support
+              ld_shlibs_CXX=no
+            fi
+            ;;
+        esac
+        ;;
 
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    dynamic_linker='NetBSD ld.elf_so'
-  fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  ;;
+      hpux10*|hpux11*)
+        if test $with_gnu_ld = no; then
+	  hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
+	  hardcode_libdir_separator_CXX=:
 
-newsos6)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
+          case $host_cpu in
+            hppa*64*|ia64*)
+              ;;
+            *)
+	      export_dynamic_flag_spec_CXX='${wl}-E'
+              ;;
+          esac
+        fi
+        case $host_cpu in
+          hppa*64*|ia64*)
+            hardcode_direct_CXX=no
+            hardcode_shlibpath_var_CXX=no
+            ;;
+          *)
+            hardcode_direct_CXX=yes
+            hardcode_direct_absolute_CXX=yes
+            hardcode_minus_L_CXX=yes # Not in the search PATH,
+					         # but as the default
+					         # location of the library.
+            ;;
+        esac
 
-*nto* | *qnx*)
-  version_type=qnx
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='ldqnx.so'
-  ;;
+        case $cc_basename in
+          CC*)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          aCC*)
+	    case $host_cpu in
+	      hppa*64*)
+	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	      ia64*)
+	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	      *)
+	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	        ;;
+	    esac
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    ;;
+          *)
+	    if test "$GXX" = yes; then
+	      if test $with_gnu_ld = no; then
+	        case $host_cpu in
+	          hppa*64*)
+	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	          ia64*)
+	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	          *)
+	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	            ;;
+	        esac
+	      fi
+	    else
+	      # FIXME: insert proper C++ library support
+	      ld_shlibs_CXX=no
+	    fi
+	    ;;
+        esac
+        ;;
 
-openbsd*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
-  need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
+      interix[3-9]*)
+	hardcode_direct_CXX=no
+	hardcode_shlibpath_var_CXX=no
+	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	export_dynamic_flag_spec_CXX='${wl}-E'
+	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+	# Instead, shared libraries are loaded at an image base (0x10000000 by
+	# default) and relocated if they conflict, which is a slow very memory
+	# consuming and fragmenting process.  To avoid this, we pick a random,
+	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+	archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+	archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
 	;;
-      esac
-  else
-    shlibpath_overrides_runpath=yes
-  fi
-  ;;
+      irix5* | irix6*)
+        case $cc_basename in
+          CC*)
+	    # SGI C++
+	    archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
 
-os2*)
-  libname_spec='$name'
-  shrext_cmds=".dll"
-  need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
-  ;;
+	    # Archives containing C++ object files must be created using
+	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
+	    # necessary to make sure instantiated templates are included
+	    # in the archive.
+	    old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
+	    ;;
+          *)
+	    if test "$GXX" = yes; then
+	      if test "$with_gnu_ld" = no; then
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	      else
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
+	      fi
+	    fi
+	    link_all_deplibs_CXX=yes
+	    ;;
+        esac
+        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+        hardcode_libdir_separator_CXX=:
+        inherit_rpath_CXX=yes
+        ;;
 
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
-  ;;
+      linux* | k*bsd*-gnu | kopensolaris*-gnu)
+        case $cc_basename in
+          KCC*)
+	    # Kuck and Associates, Inc. (KAI) C++ Compiler
 
-rdos*)
-  dynamic_linker=no
-  ;;
-
-solaris*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  ;;
-
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
-  fi
-  need_version=yes
-  ;;
-
-sysv4 | sysv4.3*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      runpath_var=LD_RUN_PATH
-      ;;
-    siemens)
-      need_lib_prefix=no
-      ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
-      ;;
-  esac
-  ;;
-
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
-
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
-
-tpf*)
-  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
-
-uts4*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
-
-*)
-  dynamic_linker=no
-  ;;
-esac
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
-$as_echo "$dynamic_linker" >&6; }
-test "$dynamic_linker" = no && can_build_shared=no
-
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
-
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
-fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
-fi
+	    # KCC will only create a shared library if the output file
+	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
+	    # to its proper name (with version) after linking.
+	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+	    archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 
+	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
 
+	    # Archives containing C++ object files must be created using
+	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+	    old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
+	    ;;
+	  icpc* | ecpc* )
+	    # Intel C++
+	    with_gnu_ld=yes
+	    # version 8.0 and above of icpc choke on multiply defined symbols
+	    # if we add $predep_objects and $postdep_objects, however 7.1 and
+	    # earlier do not add the objects themselves.
+	    case `$CC -V 2>&1` in
+	      *"Version 7."*)
+	        archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+		archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+		;;
+	      *)  # Version 8.0 or newer
+	        tmp_idyn=
+	        case $host_cpu in
+		  ia64*) tmp_idyn=' -i_dynamic';;
+		esac
+	        archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+		archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+		;;
+	    esac
+	    archive_cmds_need_lc_CXX=no
+	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	    whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	    ;;
+          pgCC* | pgcpp*)
+            # Portland Group C++ compiler
+	    case `$CC -V` in
+	    *pgCC\ [1-5].* | *pgcpp\ [1-5].*)
+	      prelink_cmds_CXX='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
+		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
+	      old_archive_cmds_CXX='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
+		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
+		$RANLIB $oldlib'
+	      archive_cmds_CXX='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+	      archive_expsym_cmds_CXX='tpldir=Template.dir~
+		rm -rf $tpldir~
+		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
+		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      ;;
+	    *) # Version 6 and above use weak symbols
+	      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+	      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+	      ;;
+	    esac
 
+	    hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
+	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	    whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+            ;;
+	  cxx*)
+	    # Compaq C++
+	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
 
+	    runpath_var=LD_RUN_PATH
+	    hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+	    hardcode_libdir_separator_CXX=:
 
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
+	    ;;
+	  xl* | mpixl* | bgxl*)
+	    # IBM XL 8.0 on PPC, with GNU ld
+	    hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	    archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    if test "x$supports_anon_versioning" = xyes; then
+	      archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~
+		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+		echo "local: *; };" >> $output_objdir/$libname.ver~
+		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+	    fi
+	    ;;
+	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      no_undefined_flag_CXX=' -zdefs'
+	      archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	      archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
+	      hardcode_libdir_flag_spec_CXX='-R$libdir'
+	      whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	      compiler_needs_object_CXX=yes
 
+	      # Not sure whether something based on
+	      # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
+	      # would be better.
+	      output_verbose_link_cmd='func_echo_all'
 
+	      # Archives containing C++ object files must be created using
+	      # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	      # necessary to make sure instantiated templates are included
+	      # in the archive.
+	      old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+	      ;;
+	    esac
+	    ;;
+	esac
+	;;
 
+      lynxos*)
+        # FIXME: insert proper C++ library support
+	ld_shlibs_CXX=no
+	;;
 
+      m88k*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+	;;
 
+      mvs*)
+        case $cc_basename in
+          cxx*)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+	  *)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+	esac
+	;;
 
+      netbsd*)
+        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	  archive_cmds_CXX='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+	  wlarc=
+	  hardcode_libdir_flag_spec_CXX='-R$libdir'
+	  hardcode_direct_CXX=yes
+	  hardcode_shlibpath_var_CXX=no
+	fi
+	# Workaround some broken pre-1.5 toolchains
+	output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+	;;
 
+      *nto* | *qnx*)
+        ld_shlibs_CXX=yes
+	;;
 
+      openbsd2*)
+        # C++ shared libraries are fairly broken
+	ld_shlibs_CXX=no
+	;;
 
+      openbsd*)
+	if test -f /usr/libexec/ld.so; then
+	  hardcode_direct_CXX=yes
+	  hardcode_shlibpath_var_CXX=no
+	  hardcode_direct_absolute_CXX=yes
+	  archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+	  hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	    archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+	    export_dynamic_flag_spec_CXX='${wl}-E'
+	    whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+	  fi
+	  output_verbose_link_cmd=func_echo_all
+	else
+	  ld_shlibs_CXX=no
+	fi
+	;;
 
+      osf3* | osf4* | osf5*)
+        case $cc_basename in
+          KCC*)
+	    # Kuck and Associates, Inc. (KAI) C++ Compiler
 
+	    # KCC will only create a shared library if the output file
+	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
+	    # to its proper name (with version) after linking.
+	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
 
+	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
+	    hardcode_libdir_separator_CXX=:
 
+	    # Archives containing C++ object files must be created using
+	    # the KAI C++ compiler.
+	    case $host in
+	      osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;;
+	      *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;;
+	    esac
+	    ;;
+          RCC*)
+	    # Rational C++ 2.4.1
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          cxx*)
+	    case $host in
+	      osf3*)
+	        allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+		;;
+	      *)
+	        allow_undefined_flag_CXX=' -expect_unresolved \*'
+	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	        archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+	          echo "-hidden">> $lib.exp~
+	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
+	          $RM $lib.exp'
+	        hardcode_libdir_flag_spec_CXX='-rpath $libdir'
+		;;
+	    esac
 
+	    hardcode_libdir_separator_CXX=:
 
+	    # Commands to make compiler produce verbose output that lists
+	    # what "hidden" libraries, object files and flags are used when
+	    # linking a shared library.
+	    #
+	    # There doesn't appear to be a way to prevent this compiler from
+	    # explicitly linking system object files so we need to strip them
+	    # from the output so that they don't get included in the library
+	    # dependencies.
+	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
+	    ;;
+	  *)
+	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	      allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
+	      case $host in
+	        osf3*)
+	          archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+		  ;;
+	        *)
+	          archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+		  ;;
+	      esac
 
+	      hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
+	      hardcode_libdir_separator_CXX=:
 
+	      # Commands to make compiler produce verbose output that lists
+	      # what "hidden" libraries, object files and flags are used when
+	      # linking a shared library.
+	      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 
+	    else
+	      # FIXME: insert proper C++ library support
+	      ld_shlibs_CXX=no
+	    fi
+	    ;;
+        esac
+        ;;
 
+      psos*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
 
+      sunos4*)
+        case $cc_basename in
+          CC*)
+	    # Sun C++ 4.x
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          lcc*)
+	    # Lucid
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+        esac
+        ;;
 
+      solaris*)
+        case $cc_basename in
+          CC* | sunCC*)
+	    # Sun C++ 4.2, 5.x and Centerline C++
+            archive_cmds_need_lc_CXX=yes
+	    no_undefined_flag_CXX=' -zdefs'
+	    archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+	    archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
+	    hardcode_libdir_flag_spec_CXX='-R$libdir'
+	    hardcode_shlibpath_var_CXX=no
+	    case $host_os in
+	      solaris2.[0-5] | solaris2.[0-5].*) ;;
+	      *)
+		# The compiler driver will combine and reorder linker options,
+		# but understands `-z linker_flag'.
+	        # Supported since Solaris 2.6 (maybe 2.5.1?)
+		whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
+	        ;;
+	    esac
+	    link_all_deplibs_CXX=yes
 
+	    output_verbose_link_cmd='func_echo_all'
 
+	    # Archives containing C++ object files must be created using
+	    # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+	    # necessary to make sure instantiated templates are included
+	    # in the archive.
+	    old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
+	    ;;
+          gcx*)
+	    # Green Hills C++ Compiler
+	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
 
+	    # The C++ compiler must be used to create the archive.
+	    old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+	    ;;
+          *)
+	    # GNU C++ compiler with Solaris linker
+	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+	      no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
+	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
+	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
+	        # Commands to make compiler produce verbose output that lists
+	        # what "hidden" libraries, object files and flags are used when
+	        # linking a shared library.
+	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+	      else
+	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
+	        # platform.
+	        archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
+	        # Commands to make compiler produce verbose output that lists
+	        # what "hidden" libraries, object files and flags are used when
+	        # linking a shared library.
+	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+	      fi
 
+	      hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
+	      case $host_os in
+		solaris2.[0-5] | solaris2.[0-5].*) ;;
+		*)
+		  whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+		  ;;
+	      esac
+	    fi
+	    ;;
+        esac
+        ;;
 
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag_CXX='${wl}-z,text'
+      archive_cmds_need_lc_CXX=no
+      hardcode_shlibpath_var_CXX=no
+      runpath_var='LD_RUN_PATH'
 
+      case $cc_basename in
+        CC*)
+	  archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+      esac
+      ;;
 
+      sysv5* | sco3.2v5* | sco5v6*)
+	# Note: We can NOT use -z defs as we might desire, because we do not
+	# link with -lc, and that would cause any symbols used from libc to
+	# always be unresolved, which means just about no library would
+	# ever link correctly.  If we're not using GNU ld we use -z text
+	# though, which does catch some bad symbols but isn't as heavy-handed
+	# as -z defs.
+	no_undefined_flag_CXX='${wl}-z,text'
+	allow_undefined_flag_CXX='${wl}-z,nodefs'
+	archive_cmds_need_lc_CXX=no
+	hardcode_shlibpath_var_CXX=no
+	hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir'
+	hardcode_libdir_separator_CXX=':'
+	link_all_deplibs_CXX=yes
+	export_dynamic_flag_spec_CXX='${wl}-Bexport'
+	runpath_var='LD_RUN_PATH'
 
+	case $cc_basename in
+          CC*)
+	    archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~
+	      '"$old_archive_cmds_CXX"
+	    reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~
+	      '"$reload_cmds_CXX"
+	    ;;
+	  *)
+	    archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	    ;;
+	esac
+      ;;
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
-$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
-hardcode_action_FC=
-if test -n "$hardcode_libdir_flag_spec_FC" ||
-   test -n "$runpath_var_FC" ||
-   test "X$hardcode_automatic_FC" = "Xyes" ; then
+      tandem*)
+        case $cc_basename in
+          NCC*)
+	    # NonStop-UX NCC 3.20
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+          *)
+	    # FIXME: insert proper C++ library support
+	    ld_shlibs_CXX=no
+	    ;;
+        esac
+        ;;
 
-  # We can hardcode non-existent directories.
-  if test "$hardcode_direct_FC" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, FC)" != no &&
-     test "$hardcode_minus_L_FC" != no; then
-    # Linking always hardcodes the temporary library directory.
-    hardcode_action_FC=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    hardcode_action_FC=immediate
-  fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  hardcode_action_FC=unsupported
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_FC" >&5
-$as_echo "$hardcode_action_FC" >&6; }
+      vxworks*)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
 
-if test "$hardcode_action_FC" = relink ||
-   test "$inherit_rpath_FC" = yes; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
+      *)
+        # FIXME: insert proper C++ library support
+        ld_shlibs_CXX=no
+        ;;
+    esac
 
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
+$as_echo "$ld_shlibs_CXX" >&6; }
+    test "$ld_shlibs_CXX" = no && can_build_shared=no
 
+    GCC_CXX="$GXX"
+    LD_CXX="$LD"
 
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    # Dependencies to place before and after the object being linked:
+predep_objects_CXX=
+postdep_objects_CXX=
+predeps_CXX=
+postdeps_CXX=
+compiler_lib_search_path_CXX=
 
+cat > conftest.$ac_ext <<_LT_EOF
+class Foo
+{
+public:
+  Foo (void) { a = 0; }
+private:
+  int a;
+};
+_LT_EOF
 
 
+_lt_libdeps_save_CFLAGS=$CFLAGS
+case "$CC $CFLAGS " in #(
+*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
+*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
+*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
+esac
 
-  fi # test -n "$compiler"
+if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
 
-  GCC=$lt_save_GCC
-  CC=$lt_save_CC
-  CFLAGS=$lt_save_CFLAGS
-fi # test "$_lt_disable_FC" != yes
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+  for p in `eval "$output_verbose_link_cmd"`; do
+    case ${prev}${p} in
 
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" ||
+          test $p = "-R"; then
+	 prev=$p
+	 continue
+       fi
 
-if test -n "$FC" && test "X$FC" != "Xno"; then :
-  ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran flag to compile .f90 files" >&5
-$as_echo_n "checking for Fortran flag to compile .f90 files... " >&6; }
-if ${ac_cv_fc_srcext_f90+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_ext=f90
-ac_fcflags_srcext_save=$ac_fcflags_srcext
-ac_fcflags_srcext=
-ac_cv_fc_srcext_f90=unknown
-for ac_flag in none -qsuffix=f=f90 -Tf; do
-  test "x$ac_flag" != xnone && ac_fcflags_srcext="$ac_flag"
-  cat > conftest.$ac_ext <<_ACEOF
-      program conftest
+       # Expand the sysroot to ease extracting the directories later.
+       if test -z "$prev"; then
+         case $p in
+         -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
+         -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
+         -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
+         esac
+       fi
+       case $p in
+       =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
+       esac
+       if test "$pre_test_object_deps_done" = no; then
+	 case ${prev} in
+	 -L | -R)
+	   # Internal compiler library paths should come after those
+	   # provided the user.  The postdeps already come after the
+	   # user supplied libs so there is no need to process them.
+	   if test -z "$compiler_lib_search_path_CXX"; then
+	     compiler_lib_search_path_CXX="${prev}${p}"
+	   else
+	     compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
+	   fi
+	   ;;
+	 # The "-l" case would never come before the object being
+	 # linked, so don't bother handling this case.
+	 esac
+       else
+	 if test -z "$postdeps_CXX"; then
+	   postdeps_CXX="${prev}${p}"
+	 else
+	   postdeps_CXX="${postdeps_CXX} ${prev}${p}"
+	 fi
+       fi
+       prev=
+       ;;
 
-      end
-_ACEOF
-if ac_fn_fc_try_compile "$LINENO"; then :
-  ac_cv_fc_srcext_f90=$ac_flag; break
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-done
-rm -f conftest.$ac_objext conftest.f90
-ac_fcflags_srcext=$ac_fcflags_srcext_save
+    *.lto.$objext) ;; # Ignore GCC LTO objects
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+	 pre_test_object_deps_done=yes
+	 continue
+       fi
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_fc_srcext_f90" >&5
-$as_echo "$ac_cv_fc_srcext_f90" >&6; }
-if test "x$ac_cv_fc_srcext_f90" = xunknown; then
-  as_fn_error $? "Fortran could not compile .f90 files" "$LINENO" 5
-else
-  ac_fc_srcext=f90
-  if test "x$ac_cv_fc_srcext_f90" = xnone; then
-    ac_fcflags_srcext=""
-    FCFLAGS_f90=""
-  else
-    ac_fcflags_srcext=$ac_cv_fc_srcext_f90
-    FCFLAGS_f90=$ac_cv_fc_srcext_f90
-  fi
+       if test "$pre_test_object_deps_done" = no; then
+	 if test -z "$predep_objects_CXX"; then
+	   predep_objects_CXX="$p"
+	 else
+	   predep_objects_CXX="$predep_objects_CXX $p"
+	 fi
+       else
+	 if test -z "$postdep_objects_CXX"; then
+	   postdep_objects_CXX="$p"
+	 else
+	   postdep_objects_CXX="$postdep_objects_CXX $p"
+	 fi
+       fi
+       ;;
+
+    *) ;; # Ignore the rest.
 
+    esac
+  done
 
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling CXX test program"
 fi
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+$RM -f confest.$objext
+CFLAGS=$_lt_libdeps_save_CFLAGS
 
+# PORTME: override above test on systems where it is broken
+case $host_os in
+interix[3-9]*)
+  # Interix 3.5 installs completely hosed .la files for C++, so rather than
+  # hack all around it, let's just trust "g++" to DTRT.
+  predep_objects_CXX=
+  postdep_objects_CXX=
+  postdeps_CXX=
+  ;;
 
-   # Prefer AC_PROG_FC to AC_PROG_F77
-   export FC FCFLAGS
-   if test "X$F77" != X; then :
-  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Use AC_PROG_FC with AC_PROG_FPP, instead of AC_PROG_F77" >&5
-$as_echo "$as_me: WARNING: Use AC_PROG_FC with AC_PROG_FPP, instead of AC_PROG_F77" >&2;}
+linux*)
+  case `$CC -V 2>&1 | sed 5q` in
+  *Sun\ C*)
+    # Sun C++ 5.9
+
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    if test "$solaris_use_stlport4" != yes; then
+      postdeps_CXX='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+
+solaris*)
+  case $cc_basename in
+  CC* | sunCC*)
+    # The more standards-conforming stlport4 library is
+    # incompatible with the Cstd library. Avoid specifying
+    # it if it's in CXXFLAGS. Ignore libCrun as
+    # -library=stlport4 depends on it.
+    case " $CXX $CXXFLAGS " in
+    *" -library=stlport4 "*)
+      solaris_use_stlport4=yes
+      ;;
+    esac
+
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    if test "$solaris_use_stlport4" != yes; then
+      postdeps_CXX='-library=Cstd -library=Crun'
+    fi
+    ;;
+  esac
+  ;;
+esac
+
+
+case " $postdeps_CXX " in
+*" -lc "*) archive_cmds_need_lc_CXX=no ;;
+esac
+ compiler_lib_search_dirs_CXX=
+if test -n "${compiler_lib_search_path_CXX}"; then
+ compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
 fi
 
 
 
 
 
-   acx_sl_fpp_srcext=${ac_fc_srcext-F}
-   as_acx_sl_prog_fpp=`$as_echo "acx_sl_cv_prog_fpp_fc_${ac_fc_srcext-f}" | $as_tr_sh`
 
-   { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to preprocess Fortran files with suffix $acx_sl_fpp_srcext" >&5
-$as_echo_n "checking how to preprocess Fortran files with suffix $acx_sl_fpp_srcext... " >&6; }
-if eval \${$as_acx_sl_prog_fpp+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  eval "$as_acx_sl_prog_fpp="
-      # Let the user specify FPP
-      if test -n "$FPP"; then :
-  rm -f conftest*
 
-   cat > conftest.$ac_ext <<_ACEOF
-      program conftest
-#define OK
-#ifdef OK
-      REAL A
-#else
-      syntax error
-#endif
-      end
-_ACEOF
-   ac_tmp=conftest.fppout
-   if { {        ac_try="$FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext >$ac_tmp"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  ($FPP conftest.$acx_sl_fpp_srcext >$ac_tmp) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  if test -f $ac_tmp \
-        && ! cmp conftest.$acx_sl_fpp_srcext $ac_tmp >/dev/null 2>&1 \
-        && grep '^      REAL A' $ac_tmp >/dev/null 2>&1 \
-        && ! grep 'syntax error' $ac_tmp >/dev/null 2>&1; then :
-  # we have Fortran!  See if the file can be compiled:
-         mv $ac_tmp conftest.$ac_ext
-         if ac_fn_fc_try_compile "$LINENO"; then :
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
-            eval "$as_acx_sl_prog_fpp=\"\$FPP\""
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
-            { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: user-specified \$FPP ($FPP) does not work" >&5
-$as_echo "$as_me: WARNING: user-specified \$FPP ($FPP) does not work" >&2;}
-            FPP=
-fi
-rm -f core conftest.err conftest.$ac_objext
-else
-  mv $ac_tmp conftest.$ac_ext
-         $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
-         { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: user-specified \$FPP ($FPP) does not work" >&5
-$as_echo "$as_me: WARNING: user-specified \$FPP ($FPP) does not work" >&2;}
-            FPP=
-fi
-fi
-   rm -f conftest*
 
-fi
-      if test -z "$FPP"; then :
-  for ac_fpp in `cd $srcdir ; pwd`/util/sxpreproc-wrapper \
-           `cd $srcdir ; pwd`/util/xlfpreproc-wrapper \
-           `cd $srcdir ; pwd`/util/sunf95preproc-wrapper \
-           `cd $srcdir ; pwd`/util/crayftnpreproc-wrapper \
-           "$FC -F" "$FC -F -fpp" "$FC -E" "$FC -E" "$FC -E -cpp" \
-           "$FC $FCFLAGS -F" "$FC $FCFLAGS -E" "$FC $FCFLAGS -E" \
-           "$FC $FCFLAGS -E -cpp" "$FC $FCFLAGS -x f95-cpp-input -E -P" \
-           "${F77-f77} -F" "${F77-f77} -E" 'fpp' \
-           "$CPP" "$CPP -x c" 'cpp' '/lib/cpp' \
-           '/usr/ccs/lib/cpp' 'g77 -E' '${CC-cc} -E'
-         do
-           rm -f conftest*
 
-   cat > conftest.$ac_ext <<_ACEOF
-      program conftest
-#define OK
-#ifdef OK
-      REAL A
-#else
-      syntax error
-#endif
-      end
-_ACEOF
-   ac_tmp=conftest.fppout
-   if { {        ac_try="$ac_fpp $FPPFLAGS conftest.$acx_sl_fpp_srcext >$ac_tmp"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  ($ac_fpp conftest.$acx_sl_fpp_srcext >$ac_tmp) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  if test -f $ac_tmp \
-        && ! cmp conftest.$acx_sl_fpp_srcext $ac_tmp >/dev/null 2>&1 \
-        && grep '^      REAL A' $ac_tmp >/dev/null 2>&1 \
-        && ! grep 'syntax error' $ac_tmp >/dev/null 2>&1; then :
-  # we have Fortran!  See if the file can be compiled:
-         mv $ac_tmp conftest.$ac_ext
-         if ac_fn_fc_try_compile "$LINENO"; then :
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-            FPP="$ac_fpp"
-              break
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-rm -f core conftest.err conftest.$ac_objext
-else
-  mv $ac_tmp conftest.$ac_ext
-         $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-
-fi
-fi
-   rm -f conftest*
-
-           rm -f conftest*
-
-   cat > conftest.$ac_ext <<_ACEOF
-      program conftest
-#define OK
-#ifdef OK
-      REAL A
-#else
-      syntax error
-#endif
-      end
-_ACEOF
-   ac_tmp=conftest.fppout
-   if { {        ac_try="$ac_fpp -P $FPPFLAGS conftest.$acx_sl_fpp_srcext >$ac_tmp"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  ($ac_fpp -P conftest.$acx_sl_fpp_srcext >$ac_tmp) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then :
-  if test -f $ac_tmp \
-        && ! cmp conftest.$acx_sl_fpp_srcext $ac_tmp >/dev/null 2>&1 \
-        && grep '^      REAL A' $ac_tmp >/dev/null 2>&1 \
-        && ! grep 'syntax error' $ac_tmp >/dev/null 2>&1; then :
-  # we have Fortran!  See if the file can be compiled:
-         mv $ac_tmp conftest.$ac_ext
-         if ac_fn_fc_try_compile "$LINENO"; then :
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
-
-            FPP="$ac_fpp -P"
-              break
-else
-  $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
 
-fi
-rm -f core conftest.err conftest.$ac_objext
-else
-  mv $ac_tmp conftest.$ac_ext
-         $as_echo "$as_me: failed program was:" >&5
-sed 's/^/| /' conftest.$ac_ext >&5
 
 
-fi
-fi
-   rm -f conftest*
 
-         done
-                  \rm a.out 2>/dev/null
-fi
-      if test -z "$FPP"; then :
 
-else
-  eval "$as_acx_sl_prog_fpp=\$FPP"
 
-fi
-fi
-eval ac_res=\$$as_acx_sl_prog_fpp
-	       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
-$as_echo "$ac_res" >&6; }
 
 
 
-   # ACX_SL_PROG_FC_FPP_FEATURES does the actual feature tests,
-   # storing results of the checks in non-cv variables like
-   # ac_prog_fc_cpp_*, which we copy to cv variables afterwards.  This
-   # allows this macro to be reusable for other cv variables (see
-   # below)
 
-   { $as_echo "$as_me:${as_lineno-$LINENO}: checking if preprocessing with $FPP of Fortran source supports required preprocessor features" >&5
-$as_echo_n "checking if preprocessing with $FPP of Fortran source supports required preprocessor features... " >&6; }
-if ${acx_sl_cv_fc_indirect_ok+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  acx_sl_cv_fc_indirect_ok=yes
-      # Set up ac_fpp_need_* flags based on features in
-      acx_sl_fpp_srcext=${ac_fc_srcext-F}
-      # defaults for needed features
-   ac_fpp_need_d=yes
-   ac_fpp_need_i=yes
-   ac_fpp_need_subs=no
-   ac_fpp_need_wrap=no
-   ac_fpp_need_cstyle=no
-   ac_fpp_need_CSTYLE=no
-   ac_fpp_need_cxxstyle=yes
-   ac_fpp_need_CXXSTYLE=no
-         for _t in  nil
-   do
-     case $_t in #(
-  define) :
-    ac_fpp_need_d=yes ;; #(
-  nodefine) :
-    ac_fpp_need_d=no ;; #(
-  include) :
-    ac_fpp_need_i=yes ;; #(
-  noinclude) :
-    ac_fpp_need_i=no ;; #(
-  substitute) :
-    ac_fpp_need_subs=yes ;; #(
-  nosubstitute) :
-    ac_fpp_need_subs=no ;; #(
-  wrap) :
-    ac_fpp_need_wrap=yes ;; #(
-  nowwrap) :
-    ac_fpp_need_wrap=no ;; #(
-  cstyle) :
-    ac_fpp_need_cstyle=yes ;; #(
-  nocstyle) :
-    ac_fpp_need_cstyle=no ;; #(
-  CSTYLE) :
-    ac_fpp_need_CSTYLE=yes ;; #(
-  noCSTYLE) :
-    ac_fpp_need_CSTYLE=no ;; #(
-  cxxstyle) :
-    ac_fpp_need_cxxstyle=yes ;; #(
-  nocxxstyle) :
-    ac_fpp_need_cxxstyle=no ;; #(
-  CXXSTYLE) :
-    ac_fpp_need_CXXSTYLE=yes ;; #(
-  noCXXSTYLE) :
-    ac_fpp_need_CXXSTYLE=no ;; #(
-  nil) :
-     ;; #(
-  *) :
-     ;;
-esac
-   done
-   # Wrapping requires substitution
-   test $ac_fpp_need_wrap = yes && ac_fpp_need_subs=yes
-   # CSTYLE and cstyle are mutually exclusive.
-   # CSTYLE takes precedence, since if it is not fulfilled,
-   # compile errors may arise
-   test $ac_fpp_need_CSTYLE = yes && ac_fpp_need_cstyle=no
-      test $ac_fpp_need_CXXSTYLE = yes && ac_fpp_need_cxxstyle=no
 
 
-      acx_sl_prog_fc_cpp_CSTYLE=no
-      acx_sl_prog_fc_cpp_cxxstyle=no
 
 
-      ac_save_FCFLAGS=$FCFLAGS
 
 
 
-      # We need to skip the following tests if we're trying direct compilation
-      # and FC won't preprocess.
-      if test x$ac_fpp_need_d = xyes; then :
-  acx_sl_prog_fc_cpp_d=no
-         $as_echo "$as_me:${as_lineno-$LINENO}: Trying flag to create preprocessor defines." >&5
 
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+    lt_prog_compiler_wl_CXX=
+lt_prog_compiler_pic_CXX=
+lt_prog_compiler_static_CXX=
 
-   ac_ext="$acx_sl_fpp_srcext"
-   cat > conftest.$ac_ext <<_ACEOF
-      program conftest
-#ifndef OK
-      syntax error
-#endif
-      end
-_ACEOF
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
+  # C++ specific cases for pic, static, wl, etc.
+  if test "$GXX" = yes; then
+    lt_prog_compiler_wl_CXX='-Wl,'
+    lt_prog_compiler_static_CXX='-static'
 
+    case $host_os in
+    aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_CXX='-Bstatic'
+      fi
+      ;;
 
-         # Normally we expect to be able to define preprocessor macros
-         # with -D, but this might be IBM xlf compiler, which needs
-         # -WF,-D or Fujitsu VPP700 which needs -Wp,-D
-         mv conftest.$acx_sl_fpp_srcext conftest.${acx_sl_fpp_srcext}.bak
-         for FPP_DEFOPT in "$FPP_DEFOPT" '-D' '-WF,-D' '-Wp,-D'
-         do
-           if test x"$FPP_DEFOPT" != x ; then :
-  cp conftest.${acx_sl_fpp_srcext}.bak conftest.$acx_sl_fpp_srcext
-              { { echo Running preprocessor $FPP $FPPFLAGS ${FPP_DEFOPT}OK conftest.$acx_sl_fpp_srcext; } >&5
-  ($FPP $FPPFLAGS ${FPP_DEFOPT}OK conftest.$acx_sl_fpp_srcext \
-        >conftest.${ac_ext}.tmp) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            lt_prog_compiler_pic_CXX='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
 
-   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
-   if ac_fn_fc_try_compile "$LINENO"; then :
-  acx_sl_prog_fc_cpp_d=yes; break
-fi
-rm -f core conftest.err conftest.$ac_objext
-fi
-         done
-         FCFLAGS=$ac_save_FCFLAGS
-         if test $acx_sl_prog_fc_cpp_d = no; then :
-  acx_sl_cv_fc_indirect_ok=no
-fi
-         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    mingw* | cygwin* | os2* | pw32* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_CXX='-fno-common'
+      ;;
+    *djgpp*)
+      # DJGPP does not support shared libraries at all
+      lt_prog_compiler_pic_CXX=
+      ;;
+    haiku*)
+      # PIC is the default for Haiku.
+      # The "-static" flag exists, but is broken.
+      lt_prog_compiler_static_CXX=
+      ;;
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic_CXX=-Kconform_pic
+      fi
+      ;;
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+	;;
+      *)
+	lt_prog_compiler_pic_CXX='-fPIC'
+	;;
+      esac
+      ;;
+    *qnx* | *nto*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic_CXX='-fPIC -shared'
+      ;;
+    *)
+      lt_prog_compiler_pic_CXX='-fPIC'
+      ;;
+    esac
+  else
+    case $host_os in
+      aix[4-9]*)
+	# All AIX code is PIC.
+	if test "$host_cpu" = ia64; then
+	  # AIX 5 now supports IA64 processor
+	  lt_prog_compiler_static_CXX='-Bstatic'
+	else
+	  lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
+	fi
+	;;
+      chorus*)
+	case $cc_basename in
+	cxch68*)
+	  # Green Hills C++ Compiler
+	  # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+	  ;;
+	esac
+	;;
+      mingw* | cygwin* | os2* | pw32* | cegcc*)
+	# This hack is so that the source file can tell whether it is being
+	# built for inclusion in a dll (and should export symbols for example).
+	lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
+	;;
+      dgux*)
+	case $cc_basename in
+	  ec++*)
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    ;;
+	  ghcx*)
+	    # Green Hills C++ Compiler
+	    lt_prog_compiler_pic_CXX='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      freebsd* | dragonfly*)
+	# FreeBSD uses GNU C++
+	;;
+      hpux9* | hpux10* | hpux11*)
+	case $cc_basename in
+	  CC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+	    if test "$host_cpu" != ia64; then
+	      lt_prog_compiler_pic_CXX='+Z'
+	    fi
+	    ;;
+	  aCC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
+	    case $host_cpu in
+	    hppa*64*|ia64*)
+	      # +Z the default
+	      ;;
+	    *)
+	      lt_prog_compiler_pic_CXX='+Z'
+	      ;;
+	    esac
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      interix*)
+	# This is c89, which is MS Visual C++ (no shared libs)
+	# Anyone wants to do a port?
+	;;
+      irix5* | irix6* | nonstopux*)
+	case $cc_basename in
+	  CC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_static_CXX='-non_shared'
+	    # CC pic flag -KPIC is the default.
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      linux* | k*bsd*-gnu | kopensolaris*-gnu)
+	case $cc_basename in
+	  KCC*)
+	    # KAI C++ Compiler
+	    lt_prog_compiler_wl_CXX='--backend -Wl,'
+	    lt_prog_compiler_pic_CXX='-fPIC'
+	    ;;
+	  ecpc* )
+	    # old Intel C++ for x86_64 which still supported -KPIC.
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    lt_prog_compiler_static_CXX='-static'
+	    ;;
+	  icpc* )
+	    # Intel C++, used to be incompatible with GCC.
+	    # ICC 10 doesn't accept -KPIC any more.
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-fPIC'
+	    lt_prog_compiler_static_CXX='-static'
+	    ;;
+	  pgCC* | pgcpp*)
+	    # Portland Group C++ compiler
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-fpic'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    ;;
+	  cxx*)
+	    # Compaq C++
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    lt_prog_compiler_pic_CXX=
+	    lt_prog_compiler_static_CXX='-non_shared'
+	    ;;
+	  xlc* | xlC* | bgxl[cC]* | mpixl[cC]*)
+	    # IBM XL 8.0, 9.0 on PPC and BlueGene
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-qpic'
+	    lt_prog_compiler_static_CXX='-qstaticlink'
+	    ;;
+	  *)
+	    case `$CC -V 2>&1 | sed 5q` in
+	    *Sun\ C*)
+	      # Sun C++ 5.9
+	      lt_prog_compiler_pic_CXX='-KPIC'
+	      lt_prog_compiler_static_CXX='-Bstatic'
+	      lt_prog_compiler_wl_CXX='-Qoption ld '
+	      ;;
+	    esac
+	    ;;
+	esac
+	;;
+      lynxos*)
+	;;
+      m88k*)
+	;;
+      mvs*)
+	case $cc_basename in
+	  cxx*)
+	    lt_prog_compiler_pic_CXX='-W c,exportall'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      netbsd*)
+	;;
+      *qnx* | *nto*)
+        # QNX uses GNU C++, but need to define -shared option too, otherwise
+        # it will coredump.
+        lt_prog_compiler_pic_CXX='-fPIC -shared'
+        ;;
+      osf3* | osf4* | osf5*)
+	case $cc_basename in
+	  KCC*)
+	    lt_prog_compiler_wl_CXX='--backend -Wl,'
+	    ;;
+	  RCC*)
+	    # Rational C++ 2.4.1
+	    lt_prog_compiler_pic_CXX='-pic'
+	    ;;
+	  cxx*)
+	    # Digital/Compaq C++
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    # Make sure the PIC flag is empty.  It appears that all Alpha
+	    # Linux and Compaq Tru64 Unix objects are PIC.
+	    lt_prog_compiler_pic_CXX=
+	    lt_prog_compiler_static_CXX='-non_shared'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      psos*)
+	;;
+      solaris*)
+	case $cc_basename in
+	  CC* | sunCC*)
+	    # Sun C++ 4.2, 5.x and Centerline C++
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    lt_prog_compiler_wl_CXX='-Qoption ld '
+	    ;;
+	  gcx*)
+	    # Green Hills C++ Compiler
+	    lt_prog_compiler_pic_CXX='-PIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sunos4*)
+	case $cc_basename in
+	  CC*)
+	    # Sun C++ 4.x
+	    lt_prog_compiler_pic_CXX='-pic'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    ;;
+	  lcc*)
+	    # Lucid
+	    lt_prog_compiler_pic_CXX='-pic'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+	case $cc_basename in
+	  CC*)
+	    lt_prog_compiler_wl_CXX='-Wl,'
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    lt_prog_compiler_static_CXX='-Bstatic'
+	    ;;
+	esac
+	;;
+      tandem*)
+	case $cc_basename in
+	  NCC*)
+	    # NonStop-UX NCC 3.20
+	    lt_prog_compiler_pic_CXX='-KPIC'
+	    ;;
+	  *)
+	    ;;
+	esac
+	;;
+      vxworks*)
+	;;
+      *)
+	lt_prog_compiler_can_build_shared_CXX=no
+	;;
+    esac
+  fi
+
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_CXX=
+    ;;
+  *)
+    lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+if ${lt_cv_prog_compiler_pic_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; }
+lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_CXX"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; }
+if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic_works_CXX=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works_CXX=yes
+     fi
+   fi
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
+    case $lt_prog_compiler_pic_CXX in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
+     esac
+else
+    lt_prog_compiler_pic_CXX=
+     lt_prog_compiler_can_build_shared_CXX=no
+fi
+
+fi
+
+
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if ${lt_cv_prog_compiler_static_works_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_static_works_CXX=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works_CXX=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works_CXX=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; }
+
+if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
+    :
+else
+    lt_prog_compiler_static_CXX=
+fi
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_CXX=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_CXX=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_CXX=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_CXX=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+
+
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+  export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+  case $host_os in
+  aix[4-9]*)
+    # If we're using GNU nm, then we don't want the "-C" option.
+    # -C means demangle to AIX nm, but means don't demangle with GNU nm
+    # Also, AIX nm treats weak defined symbols like other global defined
+    # symbols, whereas GNU nm marks them as "W".
+    if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    else
+      export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+    fi
+    ;;
+  pw32*)
+    export_symbols_cmds_CXX="$ltdll_cmds"
+    ;;
+  cygwin* | mingw* | cegcc*)
+    case $cc_basename in
+    cl*)
+      exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+      ;;
+    *)
+      export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
+      exclude_expsyms_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
+      ;;
+    esac
+    ;;
+  *)
+    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+    ;;
+  esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
+$as_echo "$ld_shlibs_CXX" >&6; }
+test "$ld_shlibs_CXX" = no && can_build_shared=no
+
+with_gnu_ld_CXX=$with_gnu_ld
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_CXX" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_CXX=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_CXX in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+if ${lt_cv_archive_cmds_need_lc_CXX+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
+  $RM conftest*
+	echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+	if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } 2>conftest.err; then
+	  soname=conftest
+	  lib=conftest
+	  libobjs=conftest.$ac_objext
+	  deplibs=
+	  wl=$lt_prog_compiler_wl_CXX
+	  pic_flag=$lt_prog_compiler_pic_CXX
+	  compiler_flags=-v
+	  linker_flags=-v
+	  verstring=
+	  output_objdir=.
+	  libname=conftest
+	  lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
+	  allow_undefined_flag_CXX=
+	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+  (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+	  then
+	    lt_cv_archive_cmds_need_lc_CXX=no
+	  else
+	    lt_cv_archive_cmds_need_lc_CXX=yes
+	  fi
+	  allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
+	else
+	  cat conftest.err 1>&5
+	fi
+	$RM conftest*
+
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5
+$as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; }
+      archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix[4-9]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32* | cegcc*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$cc_basename in
+  yes,*)
+    # gcc
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
 
-fi
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
-      if test $ac_fpp_need_i = yes; then :
-  acx_sl_prog_fc_cpp_i=no
-         $as_echo "$as_me:${as_lineno-$LINENO}: Trying flag to add directories to preprocessor search path." >&5
-         as_dir=conftst; as_fn_mkdir_p
-         cd conftst
+      ;;
+    mingw* | cegcc*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    dynamic_linker='Win32 ld.exe'
+    ;;
 
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+  *,cl*)
+    # Native MSVC
+    libname_spec='$name'
+    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+    library_names_spec='${libname}.dll.lib'
 
-   ac_ext="inc"
-   cat > conftest.$ac_ext <<_ACEOF
-       !     This statement overrides the IMPLICIT statement in the program
-      REAL cc
-_ACEOF
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+    case $build_os in
+    mingw*)
+      sys_lib_search_path_spec=
+      lt_save_ifs=$IFS
+      IFS=';'
+      for lt_path in $LIB
+      do
+        IFS=$lt_save_ifs
+        # Let DOS variable expansion print the short 8.3 style file name.
+        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+      done
+      IFS=$lt_save_ifs
+      # Convert to MSYS style.
+      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
+      ;;
+    cygwin*)
+      # Convert to unix form, then to dos form, then back to unix form
+      # but this time dos style (no spaces!) so that the unix form looks
+      # like /cygdrive/c/PROGRA~1:/cygdr...
+      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      ;;
+    *)
+      sys_lib_search_path_spec="$LIB"
+      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      # FIXME: find the short name or the path components, as spaces are
+      # common. (e.g. "Program Files" -> "PROGRA~1")
+      ;;
+    esac
 
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+    dynamic_linker='Win32 link.exe'
+    ;;
 
+  *)
+    # Assume MSVC wrapper
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    dynamic_linker='Win32 ld.exe'
+    ;;
+  esac
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
 
-         cd ..
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
 
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
 
-   ac_ext="$acx_sl_fpp_srcext"
-   cat > conftest.$ac_ext <<_ACEOF
-      program conftest
-      IMPLICIT CHARACTER (c)
-       !     Comments in test programs should be freeform compliant just in case.
-       !     conftest.inc contains the Fortran statement "REAL cc"
-#include "conftest.inc"
-      cc=1.
-      end
-_ACEOF
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+dgux*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[23].*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2.*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+haiku*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  dynamic_linker="$host_os runtime_loader"
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+  postinstall_cmds='chmod 555 $lib'
+  # or fails outright, so override atomically:
+  install_override_mode=555
+  ;;
+
+interix[3-9]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
 
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux # correct to gnu/linux during the next big refactor
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
 
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
 
-         mv conftest.$acx_sl_fpp_srcext conftest.${acx_sl_fpp_srcext}.bak
-         for FPP_INCOPT in "$FPP_INCOPT" '-I' '-WF,-I' '-Wp,-I'
-         do
-           if test x"$FPP_INCOPT" != x ; then :
-  cp conftest.${acx_sl_fpp_srcext}.bak conftest.$acx_sl_fpp_srcext
-              { { echo Running preprocessor $FPP $FPPFLAGS ${FPP_INCOPT}conftst conftest.$acx_sl_fpp_srcext; } >&5
-  ($FPP $FPPFLAGS ${FPP_INCOPT}conftst conftest.$acx_sl_fpp_srcext \
-        >conftest.${ac_ext}.tmp) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
 
-   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
-   if ac_fn_fc_try_compile "$LINENO"; then :
-  acx_sl_prog_fc_cpp_i=yes
-                 break
-fi
-rm -f core conftest.err conftest.$ac_objext
-fi
-         done
-         FCFLAGS=$ac_save_FCFLAGS
-         rm -rf conftst
-         if test $acx_sl_prog_fc_cpp_i = no; then :
-  acx_sl_cv_fc_indirect_ok=no
-fi
-         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
+  # Some binutils ld are patched to set DT_RUNPATH
+  if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
-fi
-fi
-      if test $ac_fpp_need_subs = yes; then :
-  acx_sl_prog_fc_cpp_subs=no
-         $as_echo "$as_me:${as_lineno-$LINENO}: Testing preprocessor expansion in Fortran code." >&5
+  lt_cv_shlibpath_overrides_runpath=no
+    save_LDFLAGS=$LDFLAGS
+    save_libdir=$libdir
+    eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \
+	 LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\""
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
 
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+int
+main ()
+{
 
-   ac_ext="$acx_sl_fpp_srcext"
-   cat > conftest.$ac_ext <<_ACEOF
-      program conftest
-#define NM xxxx
-      IMPLICIT CHARACTER (n)
-      REAL xxxx
-      NM=1.
-      end
+  ;
+  return 0;
+}
 _ACEOF
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
-
-
-
-         { { echo Running preprocessor $FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext; } >&5
-  ($FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext \
-        >conftest.${ac_ext}.tmp) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-
-   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
-   if ac_fn_fc_try_compile "$LINENO"; then :
-  acx_sl_prog_fc_cpp_subs=yes
-else
-  acx_sl_cv_fc_indirect_ok=no
+if ac_fn_cxx_try_link "$LINENO"; then :
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+  lt_cv_shlibpath_overrides_runpath=yes
 fi
-rm -f core conftest.err conftest.$ac_objext
-         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
-else
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
 fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    LDFLAGS=$save_LDFLAGS
+    libdir=$save_libdir
 
 fi
-      if test $ac_fpp_need_wrap = yes; then :
-  acx_sl_prog_fc_cpp_wrap=no
-         $as_echo "$as_me:${as_lineno-$LINENO}: Testing wether preprocessor wraps long lines." >&5
 
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
 
-   ac_ext="$acx_sl_fpp_srcext"
-   cat > conftest.$ac_ext <<_ACEOF
-      program conftest
-#define LONG '901234567890123456789012345678901234567890123456789012345678901234567890'
-      CHARACTER(LEN=80) :: A
-      A=LONG
-      end
-_ACEOF
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
 
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
 
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
 
-         { { echo Running preprocessor $FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext; } >&5
-  ($FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext \
-        >conftest.${ac_ext}.tmp) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
 
-   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
-   if ac_fn_fc_try_compile "$LINENO"; then :
-  acx_sl_prog_fc_cpp_wrap=yes
-else
-  acx_sl_cv_fc_indirect_ok=no
-fi
-rm -f core conftest.err conftest.$ac_objext
-         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
-else
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
-fi
+newsos6)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
 
-fi
-      if test $ac_fpp_need_CSTYLE = yes; then :
-  $as_echo "$as_me:${as_lineno-$LINENO}: Testing wether preprocessor removes C-style comments." >&5
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
 
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
+    *)				need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+	shlibpath_overrides_runpath=no
+	;;
+      *)
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
 
-   ac_ext="$acx_sl_fpp_srcext"
-   cat > conftest.$ac_ext <<_ACEOF
-      program conftest
-      A=1. /* C-style comment */
-      end
-_ACEOF
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
 
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
 
+rdos*)
+  dynamic_linker=no
+  ;;
 
-         { { echo Running preprocessor $FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext; } >&5
-  ($FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext \
-        >conftest.${ac_ext}.tmp) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
+solaris*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
 
-   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
-   if ac_fn_fc_try_compile "$LINENO"; then :
-  acx_sl_prog_fc_cpp_CSTYLE=yes
-else
-  acx_sl_cv_fc_indirect_ok=no
-fi
-rm -f core conftest.err conftest.$ac_objext
-         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
-else
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
-fi
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
 
-fi
-      if test $ac_fpp_need_cstyle = yes; then :
-  $as_echo "$as_me:${as_lineno-$LINENO}: Testing wether preprocessor leaves C-style comments in place." >&5
+sysv4 | sysv4.3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
 
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux # correct to gnu/linux during the next big refactor
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
 
-   ac_ext="$acx_sl_fpp_srcext"
-   cat > conftest.$ac_ext <<_ACEOF
-      program conftest
-      A=1. /* C-style comment */
-      end
-_ACEOF
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
+	;;
+    esac
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
 
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
 
+uts4*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
 
-         { { echo Running preprocessor $FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext; } >&5
-  ($FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext \
-        >conftest.${ac_ext}.tmp) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
 
-   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
-   if ac_fn_fc_try_compile "$LINENO"; then :
-  acx_sl_prog_fc_cpp_CSTYLE=yes
-else
-  acx_sl_cv_fc_indirect_ok=no
-fi
-rm -f core conftest.err conftest.$ac_objext
-         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
-else
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
 fi
 
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
 fi
-      if test $ac_fpp_need_cxxstyle = yes; then :
-  $as_echo "$as_me:${as_lineno-$LINENO}: Testing if preprocessor leaves C++-style comments in place." >&5
-
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
-
-   ac_ext="$acx_sl_fpp_srcext"
-   cat > conftest.$ac_ext <<_ACEOF
-      PROGRAM MAIN
-      CHARACTER(LEN=10) :: C
-      C = "abcde" // "fghij"; END PROGRAM
-_ACEOF
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
 
 
-         { { echo Running preprocessor $FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext; } >&5
-  ($FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext \
-        >conftest.${ac_ext}.tmp) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
 
-   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
-   if ac_fn_fc_try_compile "$LINENO"; then :
-  acx_sl_prog_fc_cpp_cxxstyle=yes
-else
-  acx_sl_cv_fc_indirect_ok=no
-fi
-rm -f core conftest.err conftest.$ac_objext
-         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
-else
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
-fi
 
-fi
-      if test $ac_fpp_need_CXXSTYLE = yes; then :
-  $as_echo "$as_me:${as_lineno-$LINENO}: Testing if preprocessor suppresses C++-style comments." >&5
 
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
-   ac_ext="$acx_sl_fpp_srcext"
-   cat > conftest.$ac_ext <<_ACEOF
-      PROGRAM MAIN
-      CHARACTER(LEN=10) :: C
-      C = "abcde" // "fghij"; END PROGRAM
-_ACEOF
-   ac_ext=${ac_fc_srcext-f}
-ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
-ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_fc_compiler_gnu
 
 
 
-         { { echo Running preprocessor $FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext; } >&5
-  ($FPP $FPPFLAGS conftest.$acx_sl_fpp_srcext \
-        >conftest.${ac_ext}.tmp) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
 
-   mv conftest.${ac_ext}.tmp conftest.${ac_ext}
-   if ac_fn_fc_try_compile "$LINENO"; then :
-  acx_sl_prog_fc_cpp_cxxstyle=yes
-else
-  acx_sl_cv_fc_indirect_ok=no
-fi
-rm -f core conftest.err conftest.$ac_objext
-         if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test failed." >&5
-else
-  $as_echo "$as_me:${as_lineno-$LINENO}: Test successful." >&5
-fi
 
-fi
-      FCFLAGS=$ac_save_FCFLAGS
-      rm -f conftest.*
-      if test x$acx_sl_cv_fc_indirect_ok = xyes; then :
 
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "required Fortran preprocessor not available
-See \`config.log' for more details" "$LINENO" 5; }
-fi
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_sl_cv_fc_indirect_ok" >&5
-$as_echo "$acx_sl_cv_fc_indirect_ok" >&6; }
-   #FIXME we should probably do the AC_SUBST somewhere else.
 
 
 
 
 
-   ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
-fi
-ac_ext=f
-ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
-ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_f77_compiler_gnu
-if test -n "$ac_tool_prefix"; then
-  for ac_prog in g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 xlf90 f90 pgf90 pghpf epcf90 gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_F77+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$F77"; then
-  ac_cv_prog_F77="$F77" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_F77="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-F77=$ac_cv_prog_F77
-if test -n "$F77"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $F77" >&5
-$as_echo "$F77" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
 
 
-    test -n "$F77" && break
-  done
-fi
-if test -z "$F77"; then
-  ac_ct_F77=$F77
-  for ac_prog in g77 xlf f77 frt pgf77 cf77 fort77 fl32 af77 xlf90 f90 pgf90 pghpf epcf90 gfortran g95 xlf95 f95 fort ifort ifc efc pgfortran pgf95 lf95 ftn
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_F77+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_F77"; then
-  ac_cv_prog_ac_ct_F77="$ac_ct_F77" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_F77="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-ac_ct_F77=$ac_cv_prog_ac_ct_F77
-if test -n "$ac_ct_F77"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_F77" >&5
-$as_echo "$ac_ct_F77" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
 
 
-  test -n "$ac_ct_F77" && break
-done
 
-  if test "x$ac_ct_F77" = x; then
-    F77=""
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    F77=$ac_ct_F77
-  fi
-fi
 
 
-# Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for Fortran 77 compiler version" >&5
-set X $ac_compile
-ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
-  { { ac_try="$ac_compiler $ac_option >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    sed '10a\
-... rest of stderr output deleted ...
-         10q' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-  fi
-  rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-done
-rm -f a.out
 
-# If we don't use `.F' as extension, the preprocessor is not run on the
-# input file.  (Note that this only needs to work for GNU compilers.)
-ac_save_ext=$ac_ext
-ac_ext=F
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU Fortran 77 compiler" >&5
-$as_echo_n "checking whether we are using the GNU Fortran 77 compiler... " >&6; }
-if ${ac_cv_f77_compiler_gnu+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat > conftest.$ac_ext <<_ACEOF
-      program main
-#ifndef __GNUC__
-       choke me
-#endif
 
-      end
-_ACEOF
-if ac_fn_f77_try_compile "$LINENO"; then :
-  ac_compiler_gnu=yes
-else
-  ac_compiler_gnu=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_f77_compiler_gnu=$ac_compiler_gnu
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_f77_compiler_gnu" >&5
-$as_echo "$ac_cv_f77_compiler_gnu" >&6; }
-ac_ext=$ac_save_ext
-ac_test_FFLAGS=${FFLAGS+set}
-ac_save_FFLAGS=$FFLAGS
-FFLAGS=
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $F77 accepts -g" >&5
-$as_echo_n "checking whether $F77 accepts -g... " >&6; }
-if ${ac_cv_prog_f77_g+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  FFLAGS=-g
-cat > conftest.$ac_ext <<_ACEOF
-      program main
 
-      end
-_ACEOF
-if ac_fn_f77_try_compile "$LINENO"; then :
-  ac_cv_prog_f77_g=yes
-else
-  ac_cv_prog_f77_g=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_f77_g" >&5
-$as_echo "$ac_cv_prog_f77_g" >&6; }
-if test "$ac_test_FFLAGS" = set; then
-  FFLAGS=$ac_save_FFLAGS
-elif test $ac_cv_prog_f77_g = yes; then
-  if test "x$ac_cv_f77_compiler_gnu" = xyes; then
-    FFLAGS="-g -O2"
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action_CXX=
+if test -n "$hardcode_libdir_flag_spec_CXX" ||
+   test -n "$runpath_var_CXX" ||
+   test "X$hardcode_automatic_CXX" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$hardcode_direct_CXX" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
+     test "$hardcode_minus_L_CXX" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_CXX=relink
   else
-    FFLAGS="-g"
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_CXX=immediate
   fi
 else
-  if test "x$ac_cv_f77_compiler_gnu" = xyes; then
-    FFLAGS="-O2"
-  else
-    FFLAGS=
-  fi
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_CXX=unsupported
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5
+$as_echo "$hardcode_action_CXX" >&6; }
 
-if test $ac_compiler_gnu = yes; then
-  G77=yes
-else
-  G77=
+if test "$hardcode_action_CXX" = relink ||
+   test "$inherit_rpath_CXX" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
 fi
+
+
+
+
+
+
+
+  fi # test -n "$compiler"
+
+  CC=$lt_save_CC
+  CFLAGS=$lt_save_CFLAGS
+  LDCXX=$LD
+  LD=$lt_save_LD
+  GCC=$lt_save_GCC
+  with_gnu_ld=$lt_save_with_gnu_ld
+  lt_cv_path_LDCXX=$lt_cv_path_LD
+  lt_cv_path_LD=$lt_save_path_LD
+  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+fi # test "$_lt_caught_CXX_error" != yes
+
 ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+
+
       ac_ext=f
 ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
 ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
@@ -19198,43 +20055,352 @@ fi
 
 
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
-$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
-hardcode_action_F77=
-if test -n "$hardcode_libdir_flag_spec_F77" ||
-   test -n "$runpath_var_F77" ||
-   test "X$hardcode_automatic_F77" = "Xyes" ; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action_F77=
+if test -n "$hardcode_libdir_flag_spec_F77" ||
+   test -n "$runpath_var_F77" ||
+   test "X$hardcode_automatic_F77" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$hardcode_direct_F77" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, F77)" != no &&
+     test "$hardcode_minus_L_F77" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_F77=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_F77=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_F77=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_F77" >&5
+$as_echo "$hardcode_action_F77" >&6; }
+
+if test "$hardcode_action_F77" = relink ||
+   test "$inherit_rpath_F77" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+
+
+
+
+
+
+  fi # test -n "$compiler"
+
+  GCC=$lt_save_GCC
+  CC="$lt_save_CC"
+  CFLAGS="$lt_save_CFLAGS"
+fi # test "$_lt_disable_F77" != yes
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+      ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+
+
+if test -z "$FC" || test "X$FC" = "Xno"; then
+  _lt_disable_FC=yes
+fi
+
+archive_cmds_need_lc_FC=no
+allow_undefined_flag_FC=
+always_export_symbols_FC=no
+archive_expsym_cmds_FC=
+export_dynamic_flag_spec_FC=
+hardcode_direct_FC=no
+hardcode_direct_absolute_FC=no
+hardcode_libdir_flag_spec_FC=
+hardcode_libdir_separator_FC=
+hardcode_minus_L_FC=no
+hardcode_automatic_FC=no
+inherit_rpath_FC=no
+module_cmds_FC=
+module_expsym_cmds_FC=
+link_all_deplibs_FC=unknown
+old_archive_cmds_FC=$old_archive_cmds
+reload_flag_FC=$reload_flag
+reload_cmds_FC=$reload_cmds
+no_undefined_flag_FC=
+whole_archive_flag_spec_FC=
+enable_shared_with_static_runtimes_FC=no
+
+# Source file extension for fc test sources.
+ac_ext=${ac_fc_srcext-f}
+
+# Object file extension for compiled fc test sources.
+objext=o
+objext_FC=$objext
+
+# No sense in running all these tests if we already determined that
+# the FC compiler isn't working.  Some variables (like enable_shared)
+# are currently assumed to apply to all compilers on this platform,
+# and will be corrupted by setting them based on a non-working compiler.
+if test "$_lt_disable_FC" != yes; then
+  # Code to be used in simple compile tests
+  lt_simple_compile_test_code="\
+      subroutine t
+      return
+      end
+"
+
+  # Code to be used in simple link tests
+  lt_simple_link_test_code="\
+      program t
+      end
+"
+
+  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# If no C compiler flags were specified, use CFLAGS.
+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+  # save warnings/boilerplate of simple test code
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$RM conftest*
+
+  ac_outfile=conftest.$ac_objext
+echo "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$RM -r conftest*
+
+
+  # Allow CC to be a program name with arguments.
+  lt_save_CC="$CC"
+  lt_save_GCC=$GCC
+  lt_save_CFLAGS=$CFLAGS
+  CC=${FC-"f95"}
+  CFLAGS=$FCFLAGS
+  compiler=$CC
+  GCC=$ac_cv_fc_compiler_gnu
+
+  compiler_FC=$CC
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+
+
+  if test -n "$compiler"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+    test "$can_build_shared" = "no" && enable_shared=no
+
+    # On AIX, shared libraries and static libraries use the same namespace, and
+    # are all built from PIC.
+    case $host_os in
+      aix3*)
+        test "$enable_shared" = yes && enable_static=no
+        if test -n "$RANLIB"; then
+          archive_cmds="$archive_cmds~\$RANLIB \$lib"
+          postinstall_cmds='$RANLIB $lib'
+        fi
+        ;;
+      aix[4-9]*)
+	if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+	  test "$enable_shared" = yes && enable_static=no
+	fi
+        ;;
+    esac
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+    # Make sure either enable_shared or enable_static is yes.
+    test "$enable_shared" = yes || enable_static=yes
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
+
+    GCC_FC="$ac_cv_fc_compiler_gnu"
+    LD_FC="$LD"
+
+    ## CAVEAT EMPTOR:
+    ## There is no encapsulation within the following macros, do not change
+    ## the running order or otherwise move them around unless you know exactly
+    ## what you are doing...
+    # Dependencies to place before and after the object being linked:
+predep_objects_FC=
+postdep_objects_FC=
+predeps_FC=
+postdeps_FC=
+compiler_lib_search_path_FC=
+
+cat > conftest.$ac_ext <<_LT_EOF
+      subroutine foo
+      implicit none
+      integer a
+      a=0
+      return
+      end
+_LT_EOF
+
+
+_lt_libdeps_save_CFLAGS=$CFLAGS
+case "$CC $CFLAGS " in #(
+*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
+*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
+*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
+esac
+
+if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
+
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
+
+  for p in `eval "$output_verbose_link_cmd"`; do
+    case ${prev}${p} in
+
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" ||
+          test $p = "-R"; then
+	 prev=$p
+	 continue
+       fi
+
+       # Expand the sysroot to ease extracting the directories later.
+       if test -z "$prev"; then
+         case $p in
+         -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
+         -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
+         -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
+         esac
+       fi
+       case $p in
+       =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
+       esac
+       if test "$pre_test_object_deps_done" = no; then
+	 case ${prev} in
+	 -L | -R)
+	   # Internal compiler library paths should come after those
+	   # provided the user.  The postdeps already come after the
+	   # user supplied libs so there is no need to process them.
+	   if test -z "$compiler_lib_search_path_FC"; then
+	     compiler_lib_search_path_FC="${prev}${p}"
+	   else
+	     compiler_lib_search_path_FC="${compiler_lib_search_path_FC} ${prev}${p}"
+	   fi
+	   ;;
+	 # The "-l" case would never come before the object being
+	 # linked, so don't bother handling this case.
+	 esac
+       else
+	 if test -z "$postdeps_FC"; then
+	   postdeps_FC="${prev}${p}"
+	 else
+	   postdeps_FC="${postdeps_FC} ${prev}${p}"
+	 fi
+       fi
+       prev=
+       ;;
+
+    *.lto.$objext) ;; # Ignore GCC LTO objects
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+	 pre_test_object_deps_done=yes
+	 continue
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+	 if test -z "$predep_objects_FC"; then
+	   predep_objects_FC="$p"
+	 else
+	   predep_objects_FC="$predep_objects_FC $p"
+	 fi
+       else
+	 if test -z "$postdep_objects_FC"; then
+	   postdep_objects_FC="$p"
+	 else
+	   postdep_objects_FC="$postdep_objects_FC $p"
+	 fi
+       fi
+       ;;
+
+    *) ;; # Ignore the rest.
+
+    esac
+  done
+
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling FC test program"
+fi
+
+$RM -f confest.$objext
+CFLAGS=$_lt_libdeps_save_CFLAGS
+
+# PORTME: override above test on systems where it is broken
+
+
+case " $postdeps_FC " in
+*" -lc "*) archive_cmds_need_lc_FC=no ;;
+esac
+ compiler_lib_search_dirs_FC=
+if test -n "${compiler_lib_search_path_FC}"; then
+ compiler_lib_search_dirs_FC=`echo " ${compiler_lib_search_path_FC}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
+fi
+
 
-  # We can hardcode non-existent directories.
-  if test "$hardcode_direct_F77" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, F77)" != no &&
-     test "$hardcode_minus_L_F77" != no; then
-    # Linking always hardcodes the temporary library directory.
-    hardcode_action_F77=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    hardcode_action_F77=immediate
-  fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  hardcode_action_F77=unsupported
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_F77" >&5
-$as_echo "$hardcode_action_F77" >&6; }
 
-if test "$hardcode_action_F77" = relink ||
-   test "$inherit_rpath_F77" = yes; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
 
 
 
@@ -19242,4480 +20408,4728 @@ fi
 
 
 
-  fi # test -n "$compiler"
 
-  GCC=$lt_save_GCC
-  CC="$lt_save_CC"
-  CFLAGS="$lt_save_CFLAGS"
-fi # test "$_lt_disable_F77" != yes
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
+    lt_prog_compiler_wl_FC=
+lt_prog_compiler_pic_FC=
+lt_prog_compiler_static_FC=
 
-ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-if test -z "$CXX"; then
-  if test -n "$CCC"; then
-    CXX=$CCC
-  else
-    if test -n "$ac_tool_prefix"; then
-  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
-  do
-    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
-set dummy $ac_tool_prefix$ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CXX"; then
-  ac_cv_prog_CXX="$CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CXX="$ac_tool_prefix$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
 
-fi
-fi
-CXX=$ac_cv_prog_CXX
-if test -n "$CXX"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXX" >&5
-$as_echo "$CXX" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl_FC='-Wl,'
+    lt_prog_compiler_static_FC='-static'
 
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_FC='-Bstatic'
+      fi
+      ;;
 
-    test -n "$CXX" && break
-  done
-fi
-if test -z "$CXX"; then
-  ac_ct_CXX=$CXX
-  for ac_prog in g++ c++ gpp aCC CC cxx cc++ cl.exe FCC KCC RCC xlC_r xlC
-do
-  # Extract the first word of "$ac_prog", so it can be a program name with args.
-set dummy $ac_prog; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_CXX"; then
-  ac_cv_prog_ac_ct_CXX="$ac_ct_CXX" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_CXX="$ac_prog"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            lt_prog_compiler_pic_FC='-fPIC'
+        ;;
+      m68k)
+            # FIXME: we need at least 68020 code to build shared libraries, but
+            # adding the `-m68020' flag to GCC prevents building anything better,
+            # like `-m68040'.
+            lt_prog_compiler_pic_FC='-m68020 -resident32 -malways-restore-a4'
+        ;;
+      esac
+      ;;
 
-fi
-fi
-ac_ct_CXX=$ac_cv_prog_ac_ct_CXX
-if test -n "$ac_ct_CXX"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CXX" >&5
-$as_echo "$ac_ct_CXX" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
 
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      # Although the cygwin gcc ignores -fPIC, still need this for old-style
+      # (--disable-auto-import) libraries
+      lt_prog_compiler_pic_FC='-DDLL_EXPORT'
+      ;;
 
-  test -n "$ac_ct_CXX" && break
-done
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_FC='-fno-common'
+      ;;
 
-  if test "x$ac_ct_CXX" = x; then
-    CXX="g++"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CXX=$ac_ct_CXX
-  fi
-fi
+    haiku*)
+      # PIC is the default for Haiku.
+      # The "-static" flag exists, but is broken.
+      lt_prog_compiler_static_FC=
+      ;;
 
-  fi
-fi
-# Provide some information about the compiler.
-$as_echo "$as_me:${as_lineno-$LINENO}: checking for C++ compiler version" >&5
-set X $ac_compile
-ac_compiler=$2
-for ac_option in --version -v -V -qversion; do
-  { { ac_try="$ac_compiler $ac_option >&5"
-case "(($ac_try" in
-  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
-  *) ac_try_echo=$ac_try;;
-esac
-eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
-$as_echo "$ac_try_echo"; } >&5
-  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
-  ac_status=$?
-  if test -s conftest.err; then
-    sed '10a\
-... rest of stderr output deleted ...
-         10q' conftest.err >conftest.er1
-    cat conftest.er1 >&5
-  fi
-  rm -f conftest.er1 conftest.err
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-done
+    hpux*)
+      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
+      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
+      # sets the default TLS model and affects inlining.
+      case $host_cpu in
+      hppa*64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic_FC='-fPIC'
+	;;
+      esac
+      ;;
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C++ compiler" >&5
-$as_echo_n "checking whether we are using the GNU C++ compiler... " >&6; }
-if ${ac_cv_cxx_compiler_gnu+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+    interix[3-9]*)
+      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
+      # Instead, we relocate shared libraries at runtime.
+      ;;
 
-int
-main ()
-{
-#ifndef __GNUC__
-       choke me
-#endif
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared_FC=no
+      enable_shared=no
+      ;;
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  ac_compiler_gnu=yes
-else
-  ac_compiler_gnu=no
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-ac_cv_cxx_compiler_gnu=$ac_compiler_gnu
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic_FC='-fPIC -shared'
+      ;;
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cxx_compiler_gnu" >&5
-$as_echo "$ac_cv_cxx_compiler_gnu" >&6; }
-if test $ac_compiler_gnu = yes; then
-  GXX=yes
-else
-  GXX=
-fi
-ac_test_CXXFLAGS=${CXXFLAGS+set}
-ac_save_CXXFLAGS=$CXXFLAGS
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CXX accepts -g" >&5
-$as_echo_n "checking whether $CXX accepts -g... " >&6; }
-if ${ac_cv_prog_cxx_g+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_save_cxx_werror_flag=$ac_cxx_werror_flag
-   ac_cxx_werror_flag=yes
-   ac_cv_prog_cxx_g=no
-   CXXFLAGS="-g"
-   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	lt_prog_compiler_pic_FC=-Kconform_pic
+      fi
+      ;;
 
-int
-main ()
-{
+    *)
+      lt_prog_compiler_pic_FC='-fPIC'
+      ;;
+    esac
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  ac_cv_prog_cxx_g=yes
-else
-  CXXFLAGS=""
-      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+    case $cc_basename in
+    nvcc*) # Cuda Compiler Driver 2.2
+      lt_prog_compiler_wl_FC='-Xlinker '
+      if test -n "$lt_prog_compiler_pic_FC"; then
+        lt_prog_compiler_pic_FC="-Xcompiler $lt_prog_compiler_pic_FC"
+      fi
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl_FC='-Wl,'
+      if test "$host_cpu" = ia64; then
+	# AIX 5 now supports IA64 processor
+	lt_prog_compiler_static_FC='-Bstatic'
+      else
+	lt_prog_compiler_static_FC='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+
+    mingw* | cygwin* | pw32* | os2* | cegcc*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic_FC='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl_FC='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+	# +Z the default
+	;;
+      *)
+	lt_prog_compiler_pic_FC='+Z'
+	;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static_FC='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl_FC='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static_FC='-non_shared'
+      ;;
+
+    linux* | k*bsd*-gnu | kopensolaris*-gnu)
+      case $cc_basename in
+      # old Intel for x86_64 which still supported -KPIC.
+      ecc*)
+	lt_prog_compiler_wl_FC='-Wl,'
+	lt_prog_compiler_pic_FC='-KPIC'
+	lt_prog_compiler_static_FC='-static'
+        ;;
+      # icc used to be incompatible with GCC.
+      # ICC 10 doesn't accept -KPIC any more.
+      icc* | ifort*)
+	lt_prog_compiler_wl_FC='-Wl,'
+	lt_prog_compiler_pic_FC='-fPIC'
+	lt_prog_compiler_static_FC='-static'
+        ;;
+      # Lahey Fortran 8.1.
+      lf95*)
+	lt_prog_compiler_wl_FC='-Wl,'
+	lt_prog_compiler_pic_FC='--shared'
+	lt_prog_compiler_static_FC='--static'
+	;;
+      nagfor*)
+	# NAG Fortran compiler
+	lt_prog_compiler_wl_FC='-Wl,-Wl,,'
+	lt_prog_compiler_pic_FC='-PIC'
+	lt_prog_compiler_static_FC='-Bstatic'
+	;;
+      pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+	# which looks to be a dead project)
+	lt_prog_compiler_wl_FC='-Wl,'
+	lt_prog_compiler_pic_FC='-fpic'
+	lt_prog_compiler_static_FC='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl_FC='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static_FC='-non_shared'
+        ;;
+      xl* | bgxl* | bgf* | mpixl*)
+	# IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene
+	lt_prog_compiler_wl_FC='-Wl,'
+	lt_prog_compiler_pic_FC='-qpic'
+	lt_prog_compiler_static_FC='-qstaticlink'
+	;;
+      *)
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)
+	  # Sun Fortran 8.3 passes all unrecognized flags to the linker
+	  lt_prog_compiler_pic_FC='-KPIC'
+	  lt_prog_compiler_static_FC='-Bstatic'
+	  lt_prog_compiler_wl_FC=''
+	  ;;
+	*Sun\ F* | *Sun*Fortran*)
+	  lt_prog_compiler_pic_FC='-KPIC'
+	  lt_prog_compiler_static_FC='-Bstatic'
+	  lt_prog_compiler_wl_FC='-Qoption ld '
+	  ;;
+	*Sun\ C*)
+	  # Sun C 5.9
+	  lt_prog_compiler_pic_FC='-KPIC'
+	  lt_prog_compiler_static_FC='-Bstatic'
+	  lt_prog_compiler_wl_FC='-Wl,'
+	  ;;
+        *Intel*\ [CF]*Compiler*)
+	  lt_prog_compiler_wl_FC='-Wl,'
+	  lt_prog_compiler_pic_FC='-fPIC'
+	  lt_prog_compiler_static_FC='-static'
+	  ;;
+	*Portland\ Group*)
+	  lt_prog_compiler_wl_FC='-Wl,'
+	  lt_prog_compiler_pic_FC='-fpic'
+	  lt_prog_compiler_static_FC='-Bstatic'
+	  ;;
+	esac
+	;;
+      esac
+      ;;
 
-int
-main ()
-{
+    newsos6)
+      lt_prog_compiler_pic_FC='-KPIC'
+      lt_prog_compiler_static_FC='-Bstatic'
+      ;;
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
+    *nto* | *qnx*)
+      # QNX uses GNU C++, but need to define -shared option too, otherwise
+      # it will coredump.
+      lt_prog_compiler_pic_FC='-fPIC -shared'
+      ;;
 
-else
-  ac_cxx_werror_flag=$ac_save_cxx_werror_flag
-	 CXXFLAGS="-g"
-	 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl_FC='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static_FC='-non_shared'
+      ;;
 
-int
-main ()
-{
+    rdos*)
+      lt_prog_compiler_static_FC='-non_shared'
+      ;;
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_compile "$LINENO"; then :
-  ac_cv_prog_cxx_g=yes
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-fi
-rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
-   ac_cxx_werror_flag=$ac_save_cxx_werror_flag
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cxx_g" >&5
-$as_echo "$ac_cv_prog_cxx_g" >&6; }
-if test "$ac_test_CXXFLAGS" = set; then
-  CXXFLAGS=$ac_save_CXXFLAGS
-elif test $ac_cv_prog_cxx_g = yes; then
-  if test "$GXX" = yes; then
-    CXXFLAGS="-g -O2"
-  else
-    CXXFLAGS="-g"
-  fi
-else
-  if test "$GXX" = yes; then
-    CXXFLAGS="-O2"
-  else
-    CXXFLAGS=
-  fi
-fi
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+    solaris*)
+      lt_prog_compiler_pic_FC='-KPIC'
+      lt_prog_compiler_static_FC='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
+	lt_prog_compiler_wl_FC='-Qoption ld ';;
+      *)
+	lt_prog_compiler_wl_FC='-Wl,';;
+      esac
+      ;;
 
-depcc="$CXX"  am_compiler_list=
+    sunos4*)
+      lt_prog_compiler_wl_FC='-Qoption ld '
+      lt_prog_compiler_pic_FC='-PIC'
+      lt_prog_compiler_static_FC='-Bstatic'
+      ;;
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
-$as_echo_n "checking dependency style of $depcc... " >&6; }
-if ${am_cv_CXX_dependencies_compiler_type+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
-  # We make a subdir and do the tests there.  Otherwise we can end up
-  # making bogus files that we don't know about and never remove.  For
-  # instance it was reported that on HP-UX the gcc test will end up
-  # making a dummy file named 'D' -- because '-MD' means "put the output
-  # in D".
-  rm -rf conftest.dir
-  mkdir conftest.dir
-  # Copy depcomp to subdir because otherwise we won't find it if we're
-  # using a relative directory.
-  cp "$am_depcomp" conftest.dir
-  cd conftest.dir
-  # We will build objects and dependencies in a subdirectory because
-  # it helps to detect inapplicable dependency modes.  For instance
-  # both Tru64's cc and ICC support -MD to output dependencies as a
-  # side effect of compilation, but ICC will put the dependencies in
-  # the current directory while Tru64 will put them in the object
-  # directory.
-  mkdir sub
+    sysv4 | sysv4.2uw2* | sysv4.3*)
+      lt_prog_compiler_wl_FC='-Wl,'
+      lt_prog_compiler_pic_FC='-KPIC'
+      lt_prog_compiler_static_FC='-Bstatic'
+      ;;
 
-  am_cv_CXX_dependencies_compiler_type=none
-  if test "$am_compiler_list" = ""; then
-     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
-  fi
-  am__universal=false
-  case " $depcc " in #(
-     *\ -arch\ *\ -arch\ *) am__universal=true ;;
-     esac
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+	lt_prog_compiler_pic_FC='-Kconform_pic'
+	lt_prog_compiler_static_FC='-Bstatic'
+      fi
+      ;;
 
-  for depmode in $am_compiler_list; do
-    # Setup a source with many dependencies, because some compilers
-    # like to wrap large dependency lists on column 80 (with \), and
-    # we should not choose a depcomp mode which is confused by this.
-    #
-    # We need to recreate these files for each test, as the compiler may
-    # overwrite some of them when testing with obscure command lines.
-    # This happens at least with the AIX C compiler.
-    : > sub/conftest.c
-    for i in 1 2 3 4 5 6; do
-      echo '#include "conftst'$i'.h"' >> sub/conftest.c
-      # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with
-      # Solaris 10 /bin/sh.
-      echo '/* dummy */' > sub/conftst$i.h
-    done
-    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+    sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
+      lt_prog_compiler_wl_FC='-Wl,'
+      lt_prog_compiler_pic_FC='-KPIC'
+      lt_prog_compiler_static_FC='-Bstatic'
+      ;;
 
-    # We check with '-c' and '-o' for the sake of the "dashmstdout"
-    # mode.  It turns out that the SunPro C++ compiler does not properly
-    # handle '-M -o', and we need to detect this.  Also, some Intel
-    # versions had trouble with output in subdirs.
-    am__obj=sub/conftest.${OBJEXT-o}
-    am__minus_obj="-o $am__obj"
-    case $depmode in
-    gcc)
-      # This depmode causes a compiler race in universal mode.
-      test "$am__universal" = false || continue
+    unicos*)
+      lt_prog_compiler_wl_FC='-Wl,'
+      lt_prog_compiler_can_build_shared_FC=no
       ;;
-    nosideeffect)
-      # After this tag, mechanisms are not by side-effect, so they'll
-      # only be used when explicitly requested.
-      if test "x$enable_dependency_tracking" = xyes; then
-	continue
-      else
-	break
-      fi
+
+    uts4*)
+      lt_prog_compiler_pic_FC='-pic'
+      lt_prog_compiler_static_FC='-Bstatic'
       ;;
-    msvc7 | msvc7msys | msvisualcpp | msvcmsys)
-      # This compiler won't grok '-c -o', but also, the minuso test has
-      # not run yet.  These depmodes are late enough in the game, and
-      # so weak that their functioning should not be impacted.
-      am__obj=conftest.${OBJEXT-o}
-      am__minus_obj=
+
+    *)
+      lt_prog_compiler_can_build_shared_FC=no
       ;;
-    none) break ;;
     esac
-    if depmode=$depmode \
-       source=sub/conftest.c object=$am__obj \
-       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
-       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
-         >/dev/null 2>conftest.err &&
-       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
-       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
-       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
-      # icc doesn't choke on unknown options, it will just issue warnings
-      # or remarks (even with -Werror).  So we grep stderr for any message
-      # that says an option was ignored or not supported.
-      # When given -MP, icc 7.0 and 7.1 complain thusly:
-      #   icc: Command line warning: ignoring option '-M'; no argument required
-      # The diagnosis changed in icc 8.0:
-      #   icc: Command line remark: option '-MP' not supported
-      if (grep 'ignoring option' conftest.err ||
-          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
-        am_cv_CXX_dependencies_compiler_type=$depmode
-        break
-      fi
-    fi
-  done
+  fi
+
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_FC=
+    ;;
+  *)
+    lt_prog_compiler_pic_FC="$lt_prog_compiler_pic_FC"
+    ;;
+esac
 
-  cd ..
-  rm -rf conftest.dir
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+if ${lt_cv_prog_compiler_pic_FC+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
-  am_cv_CXX_dependencies_compiler_type=none
+  lt_cv_prog_compiler_pic_FC=$lt_prog_compiler_pic_FC
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_FC" >&5
+$as_echo "$lt_cv_prog_compiler_pic_FC" >&6; }
+lt_prog_compiler_pic_FC=$lt_cv_prog_compiler_pic_FC
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_FC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_FC works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_FC works... " >&6; }
+if ${lt_cv_prog_compiler_pic_works_FC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_pic_works_FC=no
+   ac_outfile=conftest.$ac_objext
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_FC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
+     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_pic_works_FC=yes
+     fi
+   fi
+   $RM conftest*
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CXX_dependencies_compiler_type" >&5
-$as_echo "$am_cv_CXX_dependencies_compiler_type" >&6; }
-CXXDEPMODE=depmode=$am_cv_CXX_dependencies_compiler_type
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_FC" >&5
+$as_echo "$lt_cv_prog_compiler_pic_works_FC" >&6; }
 
- if
-  test "x$enable_dependency_tracking" != xno \
-  && test "$am_cv_CXX_dependencies_compiler_type" = gcc3; then
-  am__fastdepCXX_TRUE=
-  am__fastdepCXX_FALSE='#'
+if test x"$lt_cv_prog_compiler_pic_works_FC" = xyes; then
+    case $lt_prog_compiler_pic_FC in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_FC=" $lt_prog_compiler_pic_FC" ;;
+     esac
 else
-  am__fastdepCXX_TRUE='#'
-  am__fastdepCXX_FALSE=
+    lt_prog_compiler_pic_FC=
+     lt_prog_compiler_can_build_shared_FC=no
 fi
 
+fi
 
-      if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
-    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
-    (test "X$CXX" != "Xg++"))) ; then
-  ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C++ preprocessor" >&5
-$as_echo_n "checking how to run the C++ preprocessor... " >&6; }
-if test -z "$CXXCPP"; then
-  if ${ac_cv_prog_CXXCPP+:} false; then :
+
+
+
+
+#
+# Check to make sure the static flag actually works.
+#
+wl=$lt_prog_compiler_wl_FC eval lt_tmp_static_flag=\"$lt_prog_compiler_static_FC\"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
+$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
+if ${lt_cv_prog_compiler_static_works_FC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-      # Double quotes because CXXCPP needs to be expanded
-    for CXXCPP in "$CXX -E" "/lib/cpp"
-    do
-      ac_preproc_ok=false
-for ac_cxx_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if ac_fn_cxx_try_cpp "$LINENO"; then :
+  lt_cv_prog_compiler_static_works_FC=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
+   echo "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
+       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_cv_prog_compiler_static_works_FC=yes
+       fi
+     else
+       lt_cv_prog_compiler_static_works_FC=yes
+     fi
+   fi
+   $RM -r conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_FC" >&5
+$as_echo "$lt_cv_prog_compiler_static_works_FC" >&6; }
 
+if test x"$lt_cv_prog_compiler_static_works_FC" = xyes; then
+    :
 else
-  # Broken: fails on valid input.
-continue
+    lt_prog_compiler_static_FC=
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
 
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_cxx_try_cpp "$LINENO"; then :
-  # Broken: success on invalid input.
-continue
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o_FC+:} false; then :
+  $as_echo_n "(cached) " >&6
 else
-  # Passes both tests.
-ac_preproc_ok=:
-break
+  lt_cv_prog_compiler_c_o_FC=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_FC=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
+
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_FC" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_FC" >&6; }
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if ${lt_cv_prog_compiler_c_o_FC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_FC=no
+   $RM -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:$LINENO: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
+     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_FC=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $RM conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
+   $RM out/* && rmdir out
+   cd ..
+   $RM -r conftest
+   $RM conftest*
 
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
-  break
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_FC" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_FC" >&6; }
 
-    done
-    ac_cv_prog_CXXCPP=$CXXCPP
 
-fi
-  CXXCPP=$ac_cv_prog_CXXCPP
-else
-  ac_cv_prog_CXXCPP=$CXXCPP
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CXXCPP" >&5
-$as_echo "$CXXCPP" >&6; }
-ac_preproc_ok=false
-for ac_cxx_preproc_warn_flag in '' yes
-do
-  # Use a header file that comes with gcc, so configuring glibc
-  # with a fresh cross-compiler works.
-  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
-  # <limits.h> exists even on freestanding compilers.
-  # On the NeXT, cc -E runs the code through the compiler's parser,
-  # not just through cpp. "Syntax error" is here to catch this case.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#ifdef __STDC__
-# include <limits.h>
-#else
-# include <assert.h>
-#endif
-		     Syntax error
-_ACEOF
-if ac_fn_cxx_try_cpp "$LINENO"; then :
 
-else
-  # Broken: fails on valid input.
-continue
-fi
-rm -f conftest.err conftest.i conftest.$ac_ext
 
-  # OK, works on sane cases.  Now check whether nonexistent headers
-  # can be detected and how.
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <ac_nonexistent.h>
-_ACEOF
-if ac_fn_cxx_try_cpp "$LINENO"; then :
-  # Broken: success on invalid input.
-continue
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_FC" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $RM conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
 else
-  # Passes both tests.
-ac_preproc_ok=:
-break
+  need_locks=no
 fi
-rm -f conftest.err conftest.i conftest.$ac_ext
 
-done
-# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
-rm -f conftest.i conftest.err conftest.$ac_ext
-if $ac_preproc_ok; then :
 
-else
-  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
-$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
-as_fn_error $? "C++ preprocessor \"$CXXCPP\" fails sanity check
-See \`config.log' for more details" "$LINENO" 5; }
-fi
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
 
-else
-  _lt_caught_CXX_error=yes
-fi
+  runpath_var=
+  allow_undefined_flag_FC=
+  always_export_symbols_FC=no
+  archive_cmds_FC=
+  archive_expsym_cmds_FC=
+  compiler_needs_object_FC=no
+  enable_shared_with_static_runtimes_FC=no
+  export_dynamic_flag_spec_FC=
+  export_symbols_cmds_FC='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  hardcode_automatic_FC=no
+  hardcode_direct_FC=no
+  hardcode_direct_absolute_FC=no
+  hardcode_libdir_flag_spec_FC=
+  hardcode_libdir_separator_FC=
+  hardcode_minus_L_FC=no
+  hardcode_shlibpath_var_FC=unsupported
+  inherit_rpath_FC=no
+  link_all_deplibs_FC=unknown
+  module_cmds_FC=
+  module_expsym_cmds_FC=
+  old_archive_from_new_cmds_FC=
+  old_archive_from_expsyms_cmds_FC=
+  thread_safe_flag_spec_FC=
+  whole_archive_flag_spec_FC=
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms_FC=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms_FC='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  # Exclude shared library initialization/finalization symbols.
+  extract_expsyms_cmds=
 
-ac_ext=cpp
-ac_cpp='$CXXCPP $CPPFLAGS'
-ac_compile='$CXX -c $CXXFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CXX -o conftest$ac_exeext $CXXFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_cxx_compiler_gnu
+  case $host_os in
+  cygwin* | mingw* | pw32* | cegcc*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  interix*)
+    # we just hope/assume this is gcc and not c89 (= MSVC++)
+    with_gnu_ld=yes
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
 
-archive_cmds_need_lc_CXX=no
-allow_undefined_flag_CXX=
-always_export_symbols_CXX=no
-archive_expsym_cmds_CXX=
-compiler_needs_object_CXX=no
-export_dynamic_flag_spec_CXX=
-hardcode_direct_CXX=no
-hardcode_direct_absolute_CXX=no
-hardcode_libdir_flag_spec_CXX=
-hardcode_libdir_separator_CXX=
-hardcode_minus_L_CXX=no
-hardcode_shlibpath_var_CXX=unsupported
-hardcode_automatic_CXX=no
-inherit_rpath_CXX=no
-module_cmds_CXX=
-module_expsym_cmds_CXX=
-link_all_deplibs_CXX=unknown
-old_archive_cmds_CXX=$old_archive_cmds
-reload_flag_CXX=$reload_flag
-reload_cmds_CXX=$reload_cmds
-no_undefined_flag_CXX=
-whole_archive_flag_spec_CXX=
-enable_shared_with_static_runtimes_CXX=no
+  ld_shlibs_FC=yes
 
-# Source file extension for C++ test sources.
-ac_ext=cpp
+  # On some targets, GNU ld is compatible enough with the native linker
+  # that we're better off using the native interface for both.
+  lt_use_gnu_ld_interface=no
+  if test "$with_gnu_ld" = yes; then
+    case $host_os in
+      aix*)
+	# The AIX port of GNU ld has always aspired to compatibility
+	# with the native linker.  However, as the warning in the GNU ld
+	# block says, versions before 2.19.5* couldn't really create working
+	# shared libraries, regardless of the interface used.
+	case `$LD -v 2>&1` in
+	  *\ \(GNU\ Binutils\)\ 2.19.5*) ;;
+	  *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;;
+	  *\ \(GNU\ Binutils\)\ [3-9]*) ;;
+	  *)
+	    lt_use_gnu_ld_interface=yes
+	    ;;
+	esac
+	;;
+      *)
+	lt_use_gnu_ld_interface=yes
+	;;
+    esac
+  fi
 
-# Object file extension for compiled C++ test sources.
-objext=o
-objext_CXX=$objext
+  if test "$lt_use_gnu_ld_interface" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+    export_dynamic_flag_spec_FC='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then
+      whole_archive_flag_spec_FC="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      whole_archive_flag_spec_FC=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>&1` in
+      *GNU\ gold*) supports_anon_versioning=yes ;;
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix[3-9]*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+	ld_shlibs_FC=no
+	cat <<_LT_EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.19, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to install binutils
+*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.
+*** You will then need to restart the configuration process.
+
+_LT_EOF
+      fi
+      ;;
+
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds_FC=''
+        ;;
+      m68k)
+            archive_cmds_FC='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec_FC='-L$libdir'
+            hardcode_minus_L_FC=yes
+        ;;
+      esac
+      ;;
 
-# No sense in running all these tests if we already determined that
-# the CXX compiler isn't working.  Some variables (like enable_shared)
-# are currently assumed to apply to all compilers on this platform,
-# and will be corrupted by setting them based on a non-working compiler.
-if test "$_lt_caught_CXX_error" != yes; then
-  # Code to be used in simple compile tests
-  lt_simple_compile_test_code="int some_variable = 0;"
+    beos*)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	allow_undefined_flag_FC=unsupported
+	# Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
+	# support --undefined.  This deserves some investigation.  FIXME
+	archive_cmds_FC='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+	ld_shlibs_FC=no
+      fi
+      ;;
 
-  # Code to be used in simple link tests
-  lt_simple_link_test_code='int main(int, char *[]) { return(0); }'
+    cygwin* | mingw* | pw32* | cegcc*)
+      # _LT_TAGVAR(hardcode_libdir_flag_spec, FC) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec_FC='-L$libdir'
+      export_dynamic_flag_spec_FC='${wl}--export-all-symbols'
+      allow_undefined_flag_FC=unsupported
+      always_export_symbols_FC=no
+      enable_shared_with_static_runtimes_FC=yes
+      export_symbols_cmds_FC='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
+      exclude_expsyms_FC='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
 
-  # ltmain only uses $CC for tagged configurations so make sure $CC is set.
+      if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
+        archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+	# If the export-symbols file already is a .def file (1st line
+	# is EXPORTS), use it as is; otherwise, prepend...
+	archive_expsym_cmds_FC='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	  cp $export_symbols $output_objdir/$soname.def;
+	else
+	  echo EXPORTS > $output_objdir/$soname.def;
+	  cat $export_symbols >> $output_objdir/$soname.def;
+	fi~
+	$CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
+      else
+	ld_shlibs_FC=no
+      fi
+      ;;
 
+    haiku*)
+      archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      link_all_deplibs_FC=yes
+      ;;
 
+    interix[3-9]*)
+      hardcode_direct_FC=no
+      hardcode_shlibpath_var_FC=no
+      hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
+      export_dynamic_flag_spec_FC='${wl}-E'
+      # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
+      # Instead, shared libraries are loaded at an image base (0x10000000 by
+      # default) and relocated if they conflict, which is a slow very memory
+      # consuming and fragmenting process.  To avoid this, we pick a random,
+      # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
+      # time.  Moving up from 0x10000000 also allows more sbrk(2) space.
+      archive_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      archive_expsym_cmds_FC='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
+      ;;
 
+    gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
+      tmp_diet=no
+      if test "$host_os" = linux-dietlibc; then
+	case $cc_basename in
+	  diet\ *) tmp_diet=yes;;	# linux-dietlibc with static linking (!diet-dyn)
+	esac
+      fi
+      if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \
+	 && test "$tmp_diet" = no
+      then
+	tmp_addflag=' $pic_flag'
+	tmp_sharedflag='-shared'
+	case $cc_basename,$host_cpu in
+        pgcc*)				# Portland Group C compiler
+	  whole_archive_flag_spec_FC='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag'
+	  ;;
+	pgf77* | pgf90* | pgf95* | pgfortran*)
+					# Portland Group f77 and f90 compilers
+	  whole_archive_flag_spec_FC='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  tmp_addflag=' $pic_flag -Mnomain' ;;
+	ecc*,ia64* | icc*,ia64*)	# Intel C compiler on ia64
+	  tmp_addflag=' -i_dynamic' ;;
+	efc*,ia64* | ifort*,ia64*)	# Intel Fortran compiler on ia64
+	  tmp_addflag=' -i_dynamic -nofor_main' ;;
+	ifc* | ifort*)			# Intel Fortran compiler
+	  tmp_addflag=' -nofor_main' ;;
+	lf95*)				# Lahey Fortran 8.1
+	  whole_archive_flag_spec_FC=
+	  tmp_sharedflag='--shared' ;;
+        nagfor*)                        # NAGFOR 5.3
+          tmp_sharedflag='-Wl,-shared' ;;
+	xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)
+	  tmp_sharedflag='-qmkshrobj'
+	  tmp_addflag= ;;
+	nvcc*)	# Cuda Compiler Driver 2.2
+	  whole_archive_flag_spec_FC='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  compiler_needs_object_FC=yes
+	  ;;
+	esac
+	case `$CC -V 2>&1 | sed 5q` in
+	*Sun\ C*)			# Sun C 5.9
+	  whole_archive_flag_spec_FC='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
+	  compiler_needs_object_FC=yes
+	  tmp_sharedflag='-G' ;;
+	*Sun\ F*)			# Sun Fortran 8.3
+	  tmp_sharedflag='-G' ;;
+	esac
+	archive_cmds_FC='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
 
+        if test "x$supports_anon_versioning" = xyes; then
+          archive_expsym_cmds_FC='echo "{ global:" > $output_objdir/$libname.ver~
+	    cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	    echo "local: *; };" >> $output_objdir/$libname.ver~
+	    $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+        fi
 
+	case $cc_basename in
+	xlf* | bgf* | bgxlf* | mpixlf*)
+	  # IBM XL Fortran 10.1 on PPC cannot create shared libs itself
+	  whole_archive_flag_spec_FC='--whole-archive$convenience --no-whole-archive'
+	  hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+	  archive_cmds_FC='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'
+	  if test "x$supports_anon_versioning" = xyes; then
+	    archive_expsym_cmds_FC='echo "{ global:" > $output_objdir/$libname.ver~
+	      cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+	      echo "local: *; };" >> $output_objdir/$libname.ver~
+	      $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'
+	  fi
+	  ;;
+	esac
+      else
+        ld_shlibs_FC=no
+      fi
+      ;;
 
-# If no C compiler was specified, use CC.
-LTCC=${LTCC-"$CC"}
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds_FC='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+	wlarc=
+      else
+	archive_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
 
-# If no C compiler flags were specified, use CFLAGS.
-LTCFLAGS=${LTCFLAGS-"$CFLAGS"}
+    solaris*)
+      if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then
+	ld_shlibs_FC=no
+	cat <<_LT_EOF 1>&2
 
-# Allow CC to be a program name with arguments.
-compiler=$CC
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
 
+_LT_EOF
+      elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_FC=no
+      fi
+      ;;
 
-  # save warnings/boilerplate of simple test code
-  ac_outfile=conftest.$ac_objext
-echo "$lt_simple_compile_test_code" >conftest.$ac_ext
-eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_compiler_boilerplate=`cat conftest.err`
-$RM conftest*
+    sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
+      case `$LD -v 2>&1` in
+        *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
+	ld_shlibs_FC=no
+	cat <<_LT_EOF 1>&2
 
-  ac_outfile=conftest.$ac_objext
-echo "$lt_simple_link_test_code" >conftest.$ac_ext
-eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err
-_lt_linker_boilerplate=`cat conftest.err`
-$RM -r conftest*
+*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 can not
+*** reliably create shared libraries on SCO systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.16.91.0.3 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
 
+_LT_EOF
+	;;
+	*)
+	  # For security reasons, it is highly recommended that you always
+	  # use absolute paths for naming shared libraries, and exclude the
+	  # DT_RUNPATH tag from executables and libraries.  But doing so
+	  # requires that you compile everything twice, which is a pain.
+	  if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	    hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+	    archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	    archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+	  else
+	    ld_shlibs_FC=no
+	  fi
+	;;
+      esac
+      ;;
 
-  # Allow CC to be a program name with arguments.
-  lt_save_CC=$CC
-  lt_save_CFLAGS=$CFLAGS
-  lt_save_LD=$LD
-  lt_save_GCC=$GCC
-  GCC=$GXX
-  lt_save_with_gnu_ld=$with_gnu_ld
-  lt_save_path_LD=$lt_cv_path_LD
-  if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
-    lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
-  else
-    $as_unset lt_cv_prog_gnu_ld
-  fi
-  if test -n "${lt_cv_path_LDCXX+set}"; then
-    lt_cv_path_LD=$lt_cv_path_LDCXX
-  else
-    $as_unset lt_cv_path_LD
-  fi
-  test -z "${LDCXX+set}" || LD=$LDCXX
-  CC=${CXX-"c++"}
-  CFLAGS=$CXXFLAGS
-  compiler=$CC
-  compiler_CXX=$CC
-  for cc_temp in $compiler""; do
-  case $cc_temp in
-    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
-    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
-    \-*) ;;
-    *) break;;
-  esac
-done
-cc_basename=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`
+    sunos4*)
+      archive_cmds_FC='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct_FC=yes
+      hardcode_shlibpath_var_FC=no
+      ;;
 
+    *)
+      if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
+	archive_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+	archive_expsym_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+	ld_shlibs_FC=no
+      fi
+      ;;
+    esac
 
-  if test -n "$compiler"; then
-    # We don't want -fno-exception when compiling C++ code, so set the
-    # no_builtin_flag separately
-    if test "$GXX" = yes; then
-      lt_prog_compiler_no_builtin_flag_CXX=' -fno-builtin'
-    else
-      lt_prog_compiler_no_builtin_flag_CXX=
+    if test "$ld_shlibs_FC" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec_FC=
+      export_dynamic_flag_spec_FC=
+      whole_archive_flag_spec_FC=
     fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag_FC=unsupported
+      always_export_symbols_FC=yes
+      archive_expsym_cmds_FC='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L_FC=yes
+      if test "$GCC" = yes && test -z "$lt_prog_compiler_static"; then
+	# Neither direct hardcoding nor static linking is supported with a
+	# broken collect2.
+	hardcode_direct_FC=unsupported
+      fi
+      ;;
 
-    if test "$GXX" = yes; then
-      # Set up default GNU C++ configuration
+    aix[4-9]*)
+      if test "$host_cpu" = ia64; then
+	# On IA64, the linker does run time linking by default, so we don't
+	# have to do anything special.
+	aix_use_runtimelinking=no
+	exp_sym_flag='-Bexport'
+	no_entry_flag=""
+      else
+	# If we're using GNU nm, then we don't want the "-C" option.
+	# -C means demangle to AIX nm, but means don't demangle with GNU nm
+	# Also, AIX nm treats weak defined symbols like other global
+	# defined symbols, whereas GNU nm marks them as "W".
+	if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
+	  export_symbols_cmds_FC='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	else
+	  export_symbols_cmds_FC='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
+	fi
+	aix_use_runtimelinking=no
 
+	# Test if we are trying to use run time linking or normal
+	# AIX style linking. If -brtl is somewhere in LDFLAGS, we
+	# need to do runtime linking.
+	case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
+	  for ld_flag in $LDFLAGS; do
+	  if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+	    aix_use_runtimelinking=yes
+	    break
+	  fi
+	  done
+	  ;;
+	esac
 
+	exp_sym_flag='-bexport'
+	no_entry_flag='-bnoentry'
+      fi
 
-# Check whether --with-gnu-ld was given.
-if test "${with_gnu_ld+set}" = set; then :
-  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
-else
-  with_gnu_ld=no
-fi
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
 
-ac_prog=ld
-if test "$GCC" = yes; then
-  # Check if gcc -print-prog-name=ld gives a path.
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
-$as_echo_n "checking for ld used by $CC... " >&6; }
-  case $host in
-  *-*-mingw*)
-    # gcc leaves a trailing carriage return which upsets mingw
-    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
-  *)
-    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
-  esac
-  case $ac_prog in
-    # Accept absolute paths.
-    [\\/]* | ?:[\\/]*)
-      re_direlt='/[^/][^/]*/\.\./'
-      # Canonicalize the pathname of ld
-      ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`
-      while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do
-	ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`
-      done
-      test -z "$LD" && LD="$ac_prog"
-      ;;
-  "")
-    # If it fails, then pretend we aren't using GCC.
-    ac_prog=ld
-    ;;
-  *)
-    # If it is relative, then search for the first ld in PATH.
-    with_gnu_ld=unknown
-    ;;
-  esac
-elif test "$with_gnu_ld" = yes; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
-$as_echo_n "checking for GNU ld... " >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
-$as_echo_n "checking for non-GNU ld... " >&6; }
-fi
-if ${lt_cv_path_LD+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -z "$LD"; then
-  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
-  for ac_dir in $PATH; do
-    IFS="$lt_save_ifs"
-    test -z "$ac_dir" && ac_dir=.
-    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
-      lt_cv_path_LD="$ac_dir/$ac_prog"
-      # Check to see if the program is GNU ld.  I'd rather use --version,
-      # but apparently some variants of GNU ld only accept -v.
-      # Break only if it was the GNU/non-GNU ld that we prefer.
-      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
-      *GNU* | *'with BFD'*)
-	test "$with_gnu_ld" != no && break
-	;;
-      *)
-	test "$with_gnu_ld" != yes && break
-	;;
-      esac
-    fi
-  done
-  IFS="$lt_save_ifs"
-else
-  lt_cv_path_LD="$LD" # Let the user override the test with a path.
-fi
-fi
+      archive_cmds_FC=''
+      hardcode_direct_FC=yes
+      hardcode_direct_absolute_FC=yes
+      hardcode_libdir_separator_FC=':'
+      link_all_deplibs_FC=yes
+      file_list_spec_FC='${wl}-f,'
 
-LD="$lt_cv_path_LD"
-if test -n "$LD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
-$as_echo "$LD" >&6; }
+      if test "$GCC" = yes; then
+	case $host_os in aix4.[012]|aix4.[012].*)
+	# We only want to do this on AIX 4.2 and lower, the check
+	# below for broken collect2 doesn't work under 4.3+
+	  collect2name=`${CC} -print-prog-name=collect2`
+	  if test -f "$collect2name" &&
+	   strings "$collect2name" | $GREP resolve_lib_name >/dev/null
+	  then
+	  # We have reworked collect2
+	  :
+	  else
+	  # We have old collect2
+	  hardcode_direct_FC=unsupported
+	  # It fails to find uninstalled libraries when the uninstalled
+	  # path is not listed in the libpath.  Setting hardcode_minus_L
+	  # to unsupported forces relinking
+	  hardcode_minus_L_FC=yes
+	  hardcode_libdir_flag_spec_FC='-L$libdir'
+	  hardcode_libdir_separator_FC=
+	  fi
+	  ;;
+	esac
+	shared_flag='-shared'
+	if test "$aix_use_runtimelinking" = yes; then
+	  shared_flag="$shared_flag "'${wl}-G'
+	fi
+      else
+	# not using gcc
+	if test "$host_cpu" = ia64; then
+	# VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+	# chokes on -Wl,-G. The following line is correct:
+	  shared_flag='-G'
+	else
+	  if test "$aix_use_runtimelinking" = yes; then
+	    shared_flag='${wl}-G'
+	  else
+	    shared_flag='${wl}-bM:SRE'
+	  fi
+	fi
+      fi
+
+      export_dynamic_flag_spec_FC='${wl}-bexpall'
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols_FC=yes
+      if test "$aix_use_runtimelinking" = yes; then
+	# Warning - without using the other runtime loading flags (-brtl),
+	# -berok will link without error, but may produce a broken library.
+	allow_undefined_flag_FC='-berok'
+        # Determine the default libpath from the value encoded in an
+        # empty executable.
+        if test "${lt_cv_aix_libpath+set}" = set; then
+  aix_libpath=$lt_cv_aix_libpath
 else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
-$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
-if ${lt_cv_prog_gnu_ld+:} false; then :
+  if ${lt_cv_aix_libpath__FC+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  # I'd rather use --version here, but apparently some GNU lds only accept -v.
-case `$LD -v 2>&1 </dev/null` in
-*GNU* | *'with BFD'*)
-  lt_cv_prog_gnu_ld=yes
-  ;;
-*)
-  lt_cv_prog_gnu_ld=no
-  ;;
-esac
+  cat > conftest.$ac_ext <<_ACEOF
+      program conftest
+
+      end
+_ACEOF
+if ac_fn_fc_try_link "$LINENO"; then :
+
+  lt_aix_libpath_sed='
+      /Import File Strings/,/^$/ {
+	  /^0/ {
+	      s/^0  *\([^ ]*\) *$/\1/
+	      p
+	  }
+      }'
+  lt_cv_aix_libpath__FC=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  # Check for a 64-bit object if we didn't find anything.
+  if test -z "$lt_cv_aix_libpath__FC"; then
+    lt_cv_aix_libpath__FC=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
-$as_echo "$lt_cv_prog_gnu_ld" >&6; }
-with_gnu_ld=$lt_cv_prog_gnu_ld
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  if test -z "$lt_cv_aix_libpath__FC"; then
+    lt_cv_aix_libpath__FC="/usr/lib:/lib"
+  fi
 
+fi
 
+  aix_libpath=$lt_cv_aix_libpath__FC
+fi
 
+        hardcode_libdir_flag_spec_FC='${wl}-blibpath:$libdir:'"$aix_libpath"
+        archive_expsym_cmds_FC='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+      else
+	if test "$host_cpu" = ia64; then
+	  hardcode_libdir_flag_spec_FC='${wl}-R $libdir:/usr/lib:/lib'
+	  allow_undefined_flag_FC="-z nodefs"
+	  archive_expsym_cmds_FC="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
+	else
+	 # Determine the default libpath from the value encoded in an
+	 # empty executable.
+	 if test "${lt_cv_aix_libpath+set}" = set; then
+  aix_libpath=$lt_cv_aix_libpath
+else
+  if ${lt_cv_aix_libpath__FC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.$ac_ext <<_ACEOF
+      program conftest
 
+      end
+_ACEOF
+if ac_fn_fc_try_link "$LINENO"; then :
 
+  lt_aix_libpath_sed='
+      /Import File Strings/,/^$/ {
+	  /^0/ {
+	      s/^0  *\([^ ]*\) *$/\1/
+	      p
+	  }
+      }'
+  lt_cv_aix_libpath__FC=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  # Check for a 64-bit object if we didn't find anything.
+  if test -z "$lt_cv_aix_libpath__FC"; then
+    lt_cv_aix_libpath__FC=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
+  fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+  if test -z "$lt_cv_aix_libpath__FC"; then
+    lt_cv_aix_libpath__FC="/usr/lib:/lib"
+  fi
 
+fi
 
-      # Check if GNU C++ uses GNU ld as the underlying linker, since the
-      # archiving commands below assume that GNU ld is being used.
-      if test "$with_gnu_ld" = yes; then
-        archive_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        archive_expsym_cmds_CXX='$CC $pic_flag -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+  aix_libpath=$lt_cv_aix_libpath__FC
+fi
 
-        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-        export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
+	 hardcode_libdir_flag_spec_FC='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # Warning - without using the other run time loading flags,
+	  # -berok will link without error, but may produce a broken library.
+	  no_undefined_flag_FC=' ${wl}-bernotok'
+	  allow_undefined_flag_FC=' ${wl}-berok'
+	  if test "$with_gnu_ld" = yes; then
+	    # We only use this code for GNU lds that support --whole-archive.
+	    whole_archive_flag_spec_FC='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+	  else
+	    # Exported symbols can be pulled into shared objects from archives
+	    whole_archive_flag_spec_FC='$convenience'
+	  fi
+	  archive_cmds_need_lc_FC=yes
+	  # This is similar to how AIX traditionally builds its shared libraries.
+	  archive_expsym_cmds_FC="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+	fi
+      fi
+      ;;
 
-        # If archive_cmds runs LD, not CC, wlarc should be empty
-        # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
-        #     investigate it a little bit more. (MM)
-        wlarc='${wl}'
+    amigaos*)
+      case $host_cpu in
+      powerpc)
+            # see comment about AmigaOS4 .so support
+            archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+            archive_expsym_cmds_FC=''
+        ;;
+      m68k)
+            archive_cmds_FC='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+            hardcode_libdir_flag_spec_FC='-L$libdir'
+            hardcode_minus_L_FC=yes
+        ;;
+      esac
+      ;;
 
-        # ancient GNU ld didn't support --whole-archive et. al.
-        if eval "`$CC -print-prog-name=ld` --help 2>&1" |
-	  $GREP 'no-whole-archive' > /dev/null; then
-          whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-        else
-          whole_archive_flag_spec_CXX=
-        fi
-      else
-        with_gnu_ld=no
-        wlarc=
+    bsdi[45]*)
+      export_dynamic_flag_spec_FC=-rdynamic
+      ;;
 
-        # A generic and very simple default shared library creation
-        # command for GNU C++ for the case where it uses the native
-        # linker, instead of GNU ld.  If possible, this setting should
-        # overridden to take advantage of the native linker features on
-        # the platform it is being used on.
-        archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-      fi
+    cygwin* | mingw* | pw32* | cegcc*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      case $cc_basename in
+      cl*)
+	# Native MSVC
+	hardcode_libdir_flag_spec_FC=' '
+	allow_undefined_flag_FC=unsupported
+	always_export_symbols_FC=yes
+	file_list_spec_FC='@'
+	# Tell ltmain to make .lib files, not .a files.
+	libext=lib
+	# Tell ltmain to make .dll files, not .so files.
+	shrext_cmds=".dll"
+	# FIXME: Setting linknames here is a bad hack.
+	archive_cmds_FC='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
+	archive_expsym_cmds_FC='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+	    sed -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
+	  else
+	    sed -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
+	  fi~
+	  $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
+	  linknames='
+	# The linker will not automatically build a static lib if we build a DLL.
+	# _LT_TAGVAR(old_archive_from_new_cmds, FC)='true'
+	enable_shared_with_static_runtimes_FC=yes
+	exclude_expsyms_FC='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
+	export_symbols_cmds_FC='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'
+	# Don't use ranlib
+	old_postinstall_cmds_FC='chmod 644 $oldlib'
+	postlink_cmds_FC='lt_outputfile="@OUTPUT@"~
+	  lt_tool_outputfile="@TOOL_OUTPUT@"~
+	  case $lt_outputfile in
+	    *.exe|*.EXE) ;;
+	    *)
+	      lt_outputfile="$lt_outputfile.exe"
+	      lt_tool_outputfile="$lt_tool_outputfile.exe"
+	      ;;
+	  esac~
+	  if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
+	    $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
+	    $RM "$lt_outputfile.manifest";
+	  fi'
+	;;
+      *)
+	# Assume MSVC wrapper
+	hardcode_libdir_flag_spec_FC=' '
+	allow_undefined_flag_FC=unsupported
+	# Tell ltmain to make .lib files, not .a files.
+	libext=lib
+	# Tell ltmain to make .dll files, not .so files.
+	shrext_cmds=".dll"
+	# FIXME: Setting linknames here is a bad hack.
+	archive_cmds_FC='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='
+	# The linker will automatically build a .lib file if we build a DLL.
+	old_archive_from_new_cmds_FC='true'
+	# FIXME: Should let the user specify the lib program.
+	old_archive_cmds_FC='lib -OUT:$oldlib$oldobjs$old_deplibs'
+	enable_shared_with_static_runtimes_FC=yes
+	;;
+      esac
+      ;;
 
-      # Commands to make compiler produce verbose output that lists
-      # what "hidden" libraries, object files and flags are used when
-      # linking a shared library.
-      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
+    darwin* | rhapsody*)
 
-    else
-      GXX=no
-      with_gnu_ld=no
-      wlarc=
-    fi
 
-    # PORTME: fill in a description of your system's C++ link characteristics
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
-    ld_shlibs_CXX=yes
-    case $host_os in
-      aix3*)
-        # FIXME: insert proper C++ library support
-        ld_shlibs_CXX=no
-        ;;
-      aix[4-9]*)
-        if test "$host_cpu" = ia64; then
-          # On IA64, the linker does run time linking by default, so we don't
-          # have to do anything special.
-          aix_use_runtimelinking=no
-          exp_sym_flag='-Bexport'
-          no_entry_flag=""
-        else
-          aix_use_runtimelinking=no
+  archive_cmds_need_lc_FC=no
+  hardcode_direct_FC=no
+  hardcode_automatic_FC=yes
+  hardcode_shlibpath_var_FC=unsupported
+  if test "$lt_cv_ld_force_load" = "yes"; then
+    whole_archive_flag_spec_FC='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+    compiler_needs_object_FC=yes
+  else
+    whole_archive_flag_spec_FC=''
+  fi
+  link_all_deplibs_FC=yes
+  allow_undefined_flag_FC="$_lt_dar_allow_undefined"
+  case $cc_basename in
+     ifort*) _lt_dar_can_shared=yes ;;
+     *) _lt_dar_can_shared=$GCC ;;
+  esac
+  if test "$_lt_dar_can_shared" = "yes"; then
+    output_verbose_link_cmd=func_echo_all
+    archive_cmds_FC="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
+    module_cmds_FC="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
+    archive_expsym_cmds_FC="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
+    module_expsym_cmds_FC="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
 
-          # Test if we are trying to use run time linking or normal
-          # AIX style linking. If -brtl is somewhere in LDFLAGS, we
-          # need to do runtime linking.
-          case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
-	    for ld_flag in $LDFLAGS; do
-	      case $ld_flag in
-	      *-brtl*)
-	        aix_use_runtimelinking=yes
-	        break
-	        ;;
-	      esac
-	    done
-	    ;;
-          esac
+  else
+  ld_shlibs_FC=no
+  fi
 
-          exp_sym_flag='-bexport'
-          no_entry_flag='-bnoentry'
-        fi
+      ;;
 
-        # When large executables or shared objects are built, AIX ld can
-        # have problems creating the table of contents.  If linking a library
-        # or program results in "error TOC overflow" add -mminimal-toc to
-        # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
-        # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+    dgux*)
+      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_FC='-L$libdir'
+      hardcode_shlibpath_var_FC=no
+      ;;
 
-        archive_cmds_CXX=''
-        hardcode_direct_CXX=yes
-        hardcode_direct_absolute_CXX=yes
-        hardcode_libdir_separator_CXX=':'
-        link_all_deplibs_CXX=yes
-        file_list_spec_CXX='${wl}-f,'
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec_FC='-R$libdir'
+      hardcode_direct_FC=yes
+      hardcode_shlibpath_var_FC=no
+      ;;
 
-        if test "$GXX" = yes; then
-          case $host_os in aix4.[012]|aix4.[012].*)
-          # We only want to do this on AIX 4.2 and lower, the check
-          # below for broken collect2 doesn't work under 4.3+
-	  collect2name=`${CC} -print-prog-name=collect2`
-	  if test -f "$collect2name" &&
-	     strings "$collect2name" | $GREP resolve_lib_name >/dev/null
-	  then
-	    # We have reworked collect2
-	    :
-	  else
-	    # We have old collect2
-	    hardcode_direct_CXX=unsupported
-	    # It fails to find uninstalled libraries when the uninstalled
-	    # path is not listed in the libpath.  Setting hardcode_minus_L
-	    # to unsupported forces relinking
-	    hardcode_minus_L_CXX=yes
-	    hardcode_libdir_flag_spec_CXX='-L$libdir'
-	    hardcode_libdir_separator_CXX=
-	  fi
-          esac
-          shared_flag='-shared'
-	  if test "$aix_use_runtimelinking" = yes; then
-	    shared_flag="$shared_flag "'${wl}-G'
-	  fi
-        else
-          # not using gcc
-          if test "$host_cpu" = ia64; then
-	  # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
-	  # chokes on -Wl,-G. The following line is correct:
-	  shared_flag='-G'
-          else
-	    if test "$aix_use_runtimelinking" = yes; then
-	      shared_flag='${wl}-G'
-	    else
-	      shared_flag='${wl}-bM:SRE'
-	    fi
-          fi
-        fi
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2.*)
+      archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_FC=yes
+      hardcode_minus_L_FC=yes
+      hardcode_shlibpath_var_FC=no
+      ;;
 
-        export_dynamic_flag_spec_CXX='${wl}-bexpall'
-        # It seems that -bexpall does not export symbols beginning with
-        # underscore (_), so it is better to generate a list of symbols to
-	# export.
-        always_export_symbols_CXX=yes
-        if test "$aix_use_runtimelinking" = yes; then
-          # Warning - without using the other runtime loading flags (-brtl),
-          # -berok will link without error, but may produce a broken library.
-          allow_undefined_flag_CXX='-berok'
-          # Determine the default libpath from the value encoded in an empty
-          # executable.
-          if test "${lt_cv_aix_libpath+set}" = set; then
-  aix_libpath=$lt_cv_aix_libpath
-else
-  if ${lt_cv_aix_libpath__CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | dragonfly*)
+      archive_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec_FC='-R$libdir'
+      hardcode_direct_FC=yes
+      hardcode_shlibpath_var_FC=no
+      ;;
 
-int
-main ()
-{
+    hpux9*)
+      if test "$GCC" = yes; then
+	archive_cmds_FC='$RM $output_objdir/$soname~$CC -shared $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+	archive_cmds_FC='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator_FC=:
+      hardcode_direct_FC=yes
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L_FC=yes
+      export_dynamic_flag_spec_FC='${wl}-E'
+      ;;
 
-  lt_aix_libpath_sed='
-      /Import File Strings/,/^$/ {
-	  /^0/ {
-	      s/^0  *\([^ ]*\) *$/\1/
-	      p
-	  }
-      }'
-  lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  # Check for a 64-bit object if we didn't find anything.
-  if test -z "$lt_cv_aix_libpath__CXX"; then
-    lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  fi
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-  if test -z "$lt_cv_aix_libpath__CXX"; then
-    lt_cv_aix_libpath__CXX="/usr/lib:/lib"
-  fi
+    hpux10*)
+      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+	archive_cmds_FC='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_FC='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator_FC=:
+	hardcode_direct_FC=yes
+	hardcode_direct_absolute_FC=yes
+	export_dynamic_flag_spec_FC='${wl}-E'
+	# hardcode_minus_L: Not really in the search PATH,
+	# but as the default location of the library.
+	hardcode_minus_L_FC=yes
+      fi
+      ;;
 
-fi
+    hpux11*)
+      if test "$GCC" = yes && test "$with_gnu_ld" = no; then
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds_FC='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds_FC='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	  archive_cmds_FC='$CC -shared $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      else
+	case $host_cpu in
+	hppa*64*)
+	  archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	ia64*)
+	  archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	*)
+	archive_cmds_FC='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+	  ;;
+	esac
+      fi
+      if test "$with_gnu_ld" = no; then
+	hardcode_libdir_flag_spec_FC='${wl}+b ${wl}$libdir'
+	hardcode_libdir_separator_FC=:
 
-  aix_libpath=$lt_cv_aix_libpath__CXX
-fi
+	case $host_cpu in
+	hppa*64*|ia64*)
+	  hardcode_direct_FC=no
+	  hardcode_shlibpath_var_FC=no
+	  ;;
+	*)
+	  hardcode_direct_FC=yes
+	  hardcode_direct_absolute_FC=yes
+	  export_dynamic_flag_spec_FC='${wl}-E'
 
-          hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
+	  # hardcode_minus_L: Not really in the search PATH,
+	  # but as the default location of the library.
+	  hardcode_minus_L_FC=yes
+	  ;;
+	esac
+      fi
+      ;;
 
-          archive_expsym_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then func_echo_all "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$exp_sym_flag:\$export_symbols $shared_flag"
-        else
-          if test "$host_cpu" = ia64; then
-	    hardcode_libdir_flag_spec_CXX='${wl}-R $libdir:/usr/lib:/lib'
-	    allow_undefined_flag_CXX="-z nodefs"
-	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\${wl}$no_entry_flag"' $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$exp_sym_flag:\$export_symbols"
-          else
-	    # Determine the default libpath from the value encoded in an
-	    # empty executable.
-	    if test "${lt_cv_aix_libpath+set}" = set; then
-  aix_libpath=$lt_cv_aix_libpath
-else
-  if ${lt_cv_aix_libpath__CXX+:} false; then :
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+	archive_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	# Try to use the -exported_symbol ld option, if it does not
+	# work, assume that -exports_file does not work either and
+	# implicitly export all symbols.
+	# This should be the same for all languages, so no per-tag cache variable.
+	{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5
+$as_echo_n "checking whether the $host_os linker accepts -exported_symbol... " >&6; }
+if ${lt_cv_irix_exported_symbol+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-int
-main ()
-{
+  save_LDFLAGS="$LDFLAGS"
+	   LDFLAGS="$LDFLAGS -shared ${wl}-exported_symbol ${wl}foo ${wl}-update_registry ${wl}/dev/null"
+	   cat > conftest.$ac_ext <<_ACEOF
 
-  ;
-  return 0;
-}
+      subroutine foo
+      end
 _ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
-
-  lt_aix_libpath_sed='
-      /Import File Strings/,/^$/ {
-	  /^0/ {
-	      s/^0  *\([^ ]*\) *$/\1/
-	      p
-	  }
-      }'
-  lt_cv_aix_libpath__CXX=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  # Check for a 64-bit object if we didn't find anything.
-  if test -z "$lt_cv_aix_libpath__CXX"; then
-    lt_cv_aix_libpath__CXX=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`
-  fi
+if ac_fn_fc_try_link "$LINENO"; then :
+  lt_cv_irix_exported_symbol=yes
+else
+  lt_cv_irix_exported_symbol=no
 fi
 rm -f core conftest.err conftest.$ac_objext \
     conftest$ac_exeext conftest.$ac_ext
-  if test -z "$lt_cv_aix_libpath__CXX"; then
-    lt_cv_aix_libpath__CXX="/usr/lib:/lib"
-  fi
-
+           LDFLAGS="$save_LDFLAGS"
 fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5
+$as_echo "$lt_cv_irix_exported_symbol" >&6; }
+	if test "$lt_cv_irix_exported_symbol" = yes; then
+          archive_expsym_cmds_FC='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations ${wl}-exports_file ${wl}$export_symbols -o $lib'
+	fi
+      else
+	archive_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds_FC='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -exports_file $export_symbols -o $lib'
+      fi
+      archive_cmds_need_lc_FC='no'
+      hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_FC=:
+      inherit_rpath_FC=yes
+      link_all_deplibs_FC=yes
+      ;;
 
-  aix_libpath=$lt_cv_aix_libpath__CXX
-fi
+    netbsd*)
+      if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+	archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+	archive_cmds_FC='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec_FC='-R$libdir'
+      hardcode_direct_FC=yes
+      hardcode_shlibpath_var_FC=no
+      ;;
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-blibpath:$libdir:'"$aix_libpath"
-	    # Warning - without using the other run time loading flags,
-	    # -berok will link without error, but may produce a broken library.
-	    no_undefined_flag_CXX=' ${wl}-bernotok'
-	    allow_undefined_flag_CXX=' ${wl}-berok'
-	    if test "$with_gnu_ld" = yes; then
-	      # We only use this code for GNU lds that support --whole-archive.
-	      whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
-	    else
-	      # Exported symbols can be pulled into shared objects from archives
-	      whole_archive_flag_spec_CXX='$convenience'
-	    fi
-	    archive_cmds_need_lc_CXX=yes
-	    # This is similar to how AIX traditionally builds its shared
-	    # libraries.
-	    archive_expsym_cmds_CXX="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs ${wl}-bnoentry $compiler_flags ${wl}-bE:$export_symbols${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
-          fi
-        fi
-        ;;
+    newsos6)
+      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_FC=yes
+      hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_FC=:
+      hardcode_shlibpath_var_FC=no
+      ;;
 
-      beos*)
-	if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then
-	  allow_undefined_flag_CXX=unsupported
-	  # Joseph Beckenbach <jrb3 at best.com> says some releases of gcc
-	  # support --undefined.  This deserves some investigation.  FIXME
-	  archive_cmds_CXX='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    *nto* | *qnx*)
+      ;;
+
+    openbsd*)
+      if test -f /usr/libexec/ld.so; then
+	hardcode_direct_FC=yes
+	hardcode_shlibpath_var_FC=no
+	hardcode_direct_absolute_FC=yes
+	if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+	  archive_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+	  hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
+	  export_dynamic_flag_spec_FC='${wl}-E'
 	else
-	  ld_shlibs_CXX=no
+	  case $host_os in
+	   openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+	     archive_cmds_FC='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+	     hardcode_libdir_flag_spec_FC='-R$libdir'
+	     ;;
+	   *)
+	     archive_cmds_FC='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+	     hardcode_libdir_flag_spec_FC='${wl}-rpath,$libdir'
+	     ;;
+	  esac
 	fi
-	;;
+      else
+	ld_shlibs_FC=no
+      fi
+      ;;
 
-      chorus*)
-        case $cc_basename in
-          *)
-	  # FIXME: insert proper C++ library support
-	  ld_shlibs_CXX=no
-	  ;;
-        esac
-        ;;
+    os2*)
+      hardcode_libdir_flag_spec_FC='-L$libdir'
+      hardcode_minus_L_FC=yes
+      allow_undefined_flag_FC=unsupported
+      archive_cmds_FC='$ECHO "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~echo DATA >> $output_objdir/$libname.def~echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_from_new_cmds_FC='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
 
-      cygwin* | mingw* | pw32* | cegcc*)
-	case $GXX,$cc_basename in
-	,cl* | no,cl*)
-	  # Native MSVC
-	  # hardcode_libdir_flag_spec is actually meaningless, as there is
-	  # no search path for DLLs.
-	  hardcode_libdir_flag_spec_CXX=' '
-	  allow_undefined_flag_CXX=unsupported
-	  always_export_symbols_CXX=yes
-	  file_list_spec_CXX='@'
-	  # Tell ltmain to make .lib files, not .a files.
-	  libext=lib
-	  # Tell ltmain to make .dll files, not .so files.
-	  shrext_cmds=".dll"
-	  # FIXME: Setting linknames here is a bad hack.
-	  archive_cmds_CXX='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-dll~linknames='
-	  archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      $SED -n -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' -e '1\\\!p' < $export_symbols > $output_objdir/$soname.exp;
-	    else
-	      $SED -e 's/\\\\\\\(.*\\\\\\\)/-link\\\ -EXPORT:\\\\\\\1/' < $export_symbols > $output_objdir/$soname.exp;
-	    fi~
-	    $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~
-	    linknames='
-	  # The linker will not automatically build a static lib if we build a DLL.
-	  # _LT_TAGVAR(old_archive_from_new_cmds, CXX)='true'
-	  enable_shared_with_static_runtimes_CXX=yes
-	  # Don't use ranlib
-	  old_postinstall_cmds_CXX='chmod 644 $oldlib'
-	  postlink_cmds_CXX='lt_outputfile="@OUTPUT@"~
-	    lt_tool_outputfile="@TOOL_OUTPUT@"~
-	    case $lt_outputfile in
-	      *.exe|*.EXE) ;;
-	      *)
-		lt_outputfile="$lt_outputfile.exe"
-		lt_tool_outputfile="$lt_tool_outputfile.exe"
-		;;
-	    esac~
-	    func_to_tool_file "$lt_outputfile"~
-	    if test "$MANIFEST_TOOL" != ":" && test -f "$lt_outputfile.manifest"; then
-	      $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;
-	      $RM "$lt_outputfile.manifest";
-	    fi'
+    osf3*)
+      if test "$GCC" = yes; then
+	allow_undefined_flag_FC=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+	allow_undefined_flag_FC=' -expect_unresolved \*'
+	archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      archive_cmds_need_lc_FC='no'
+      hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_FC=:
+      ;;
+
+    osf4* | osf5*)	# as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+	allow_undefined_flag_FC=' ${wl}-expect_unresolved ${wl}\*'
+	archive_cmds_FC='$CC -shared${allow_undefined_flag} $pic_flag $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+	hardcode_libdir_flag_spec_FC='${wl}-rpath ${wl}$libdir'
+      else
+	allow_undefined_flag_FC=' -expect_unresolved \*'
+	archive_cmds_FC='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
+	archive_expsym_cmds_FC='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~
+	$CC -shared${allow_undefined_flag} ${wl}-input ${wl}$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~$RM $lib.exp'
+
+	# Both c and cxx compiler support -rpath directly
+	hardcode_libdir_flag_spec_FC='-rpath $libdir'
+      fi
+      archive_cmds_need_lc_FC='no'
+      hardcode_libdir_separator_FC=:
+      ;;
+
+    solaris*)
+      no_undefined_flag_FC=' -z defs'
+      if test "$GCC" = yes; then
+	wlarc='${wl}'
+	archive_cmds_FC='$CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -shared $pic_flag ${wl}-z ${wl}text ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
+      else
+	case `$CC -V 2>&1` in
+	*"Compilers 5.0"*)
+	  wlarc=''
+	  archive_cmds_FC='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'
 	  ;;
 	*)
-	  # g++
-	  # _LT_TAGVAR(hardcode_libdir_flag_spec, CXX) is actually meaningless,
-	  # as there is no search path for DLLs.
-	  hardcode_libdir_flag_spec_CXX='-L$libdir'
-	  export_dynamic_flag_spec_CXX='${wl}--export-all-symbols'
-	  allow_undefined_flag_CXX=unsupported
-	  always_export_symbols_CXX=no
-	  enable_shared_with_static_runtimes_CXX=yes
-
-	  if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then
-	    archive_cmds_CXX='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	    # If the export-symbols file already is a .def file (1st line
-	    # is EXPORTS), use it as is; otherwise, prepend...
-	    archive_expsym_cmds_CXX='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
-	      cp $export_symbols $output_objdir/$soname.def;
-	    else
-	      echo EXPORTS > $output_objdir/$soname.def;
-	      cat $export_symbols >> $output_objdir/$soname.def;
-	    fi~
-	    $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'
-	  else
-	    ld_shlibs_CXX=no
-	  fi
+	  wlarc='${wl}'
+	  archive_cmds_FC='$CC -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $compiler_flags'
+	  archive_expsym_cmds_FC='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
+	  $CC -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'
 	  ;;
 	esac
+      fi
+      hardcode_libdir_flag_spec_FC='-R$libdir'
+      hardcode_shlibpath_var_FC=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+	# The compiler driver will combine and reorder linker options,
+	# but understands `-z linker_flag'.  GCC discards it without `$wl',
+	# but is careful enough not to reorder.
+	# Supported since Solaris 2.6 (maybe 2.5.1?)
+	if test "$GCC" = yes; then
+	  whole_archive_flag_spec_FC='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
+	else
+	  whole_archive_flag_spec_FC='-z allextract$convenience -z defaultextract'
+	fi
+	;;
+      esac
+      link_all_deplibs_FC=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+	# Use $CC to link under sequent, because it throws in some extra .o
+	# files that make .init and .fini sections work.
+	archive_cmds_FC='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_FC='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec_FC='-L$libdir'
+      hardcode_direct_FC=yes
+      hardcode_minus_L_FC=yes
+      hardcode_shlibpath_var_FC=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+	sni)
+	  archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_FC=yes # is this really true???
 	;;
-      darwin* | rhapsody*)
+	siemens)
+	  ## LD is ld it makes a PLAMLIB
+	  ## CC just makes a GrossModule.
+	  archive_cmds_FC='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+	  reload_cmds_FC='$CC -r -o $output$reload_objs'
+	  hardcode_direct_FC=no
+        ;;
+	motorola)
+	  archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	  hardcode_direct_FC=no #Motorola manual says yes, but my tests say they lie
+	;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var_FC=no
+      ;;
 
+    sysv4.3*)
+      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var_FC=no
+      export_dynamic_flag_spec_FC='-Bexport'
+      ;;
 
-  archive_cmds_need_lc_CXX=no
-  hardcode_direct_CXX=no
-  hardcode_automatic_CXX=yes
-  hardcode_shlibpath_var_CXX=unsupported
-  if test "$lt_cv_ld_force_load" = "yes"; then
-    whole_archive_flag_spec_CXX='`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience ${wl}-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'
+    sysv4*MP*)
+      if test -d /usr/nec; then
+	archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+	hardcode_shlibpath_var_FC=no
+	runpath_var=LD_RUN_PATH
+	hardcode_runpath_var=yes
+	ld_shlibs_FC=yes
+      fi
+      ;;
 
-  else
-    whole_archive_flag_spec_CXX=''
-  fi
-  link_all_deplibs_CXX=yes
-  allow_undefined_flag_CXX="$_lt_dar_allow_undefined"
-  case $cc_basename in
-     ifort*) _lt_dar_can_shared=yes ;;
-     *) _lt_dar_can_shared=$GCC ;;
-  esac
-  if test "$_lt_dar_can_shared" = "yes"; then
-    output_verbose_link_cmd=func_echo_all
-    archive_cmds_CXX="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod${_lt_dsymutil}"
-    module_cmds_CXX="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dsymutil}"
-    archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring ${_lt_dar_single_mod}${_lt_dar_export_syms}${_lt_dsymutil}"
-    module_expsym_cmds_CXX="sed -e 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags${_lt_dar_export_syms}${_lt_dsymutil}"
-       if test "$lt_cv_apple_cc_single_mod" != "yes"; then
-      archive_cmds_CXX="\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dsymutil}"
-      archive_expsym_cmds_CXX="sed 's,^,_,' < \$export_symbols > \$output_objdir/\${libname}-symbols.expsym~\$CC -r -keep_private_externs -nostdlib -o \${lib}-master.o \$libobjs~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \${lib}-master.o \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring${_lt_dar_export_syms}${_lt_dsymutil}"
-    fi
+    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
+      no_undefined_flag_FC='${wl}-z,text'
+      archive_cmds_need_lc_FC=no
+      hardcode_shlibpath_var_FC=no
+      runpath_var='LD_RUN_PATH'
 
-  else
-  ld_shlibs_CXX=no
-  fi
+      if test "$GCC" = yes; then
+	archive_cmds_FC='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_FC='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_FC='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_FC='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    sysv5* | sco3.2v5* | sco5v6*)
+      # Note: We can NOT use -z defs as we might desire, because we do not
+      # link with -lc, and that would cause any symbols used from libc to
+      # always be unresolved, which means just about no library would
+      # ever link correctly.  If we're not using GNU ld we use -z text
+      # though, which does catch some bad symbols but isn't as heavy-handed
+      # as -z defs.
+      no_undefined_flag_FC='${wl}-z,text'
+      allow_undefined_flag_FC='${wl}-z,nodefs'
+      archive_cmds_need_lc_FC=no
+      hardcode_shlibpath_var_FC=no
+      hardcode_libdir_flag_spec_FC='${wl}-R,$libdir'
+      hardcode_libdir_separator_FC=':'
+      link_all_deplibs_FC=yes
+      export_dynamic_flag_spec_FC='${wl}-Bexport'
+      runpath_var='LD_RUN_PATH'
+
+      if test "$GCC" = yes; then
+	archive_cmds_FC='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_FC='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+	archive_cmds_FC='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+	archive_expsym_cmds_FC='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      ;;
+
+    uts4*)
+      archive_cmds_FC='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_FC='-L$libdir'
+      hardcode_shlibpath_var_FC=no
+      ;;
+
+    *)
+      ld_shlibs_FC=no
+      ;;
+    esac
 
+    if test x$host_vendor = xsni; then
+      case $host in
+      sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+	export_dynamic_flag_spec_FC='${wl}-Blargedynsym'
 	;;
+      esac
+    fi
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_FC" >&5
+$as_echo "$ld_shlibs_FC" >&6; }
+test "$ld_shlibs_FC" = no && can_build_shared=no
+
+with_gnu_ld_FC=$with_gnu_ld
+
+
+
+
+
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_FC" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_FC=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_FC in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+if ${lt_cv_archive_cmds_need_lc_FC+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  $RM conftest*
+	echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+	if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } 2>conftest.err; then
+	  soname=conftest
+	  lib=conftest
+	  libobjs=conftest.$ac_objext
+	  deplibs=
+	  wl=$lt_prog_compiler_wl_FC
+	  pic_flag=$lt_prog_compiler_pic_FC
+	  compiler_flags=-v
+	  linker_flags=-v
+	  verstring=
+	  output_objdir=.
+	  libname=conftest
+	  lt_save_allow_undefined_flag=$allow_undefined_flag_FC
+	  allow_undefined_flag_FC=
+	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_FC 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+  (eval $archive_cmds_FC 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+	  then
+	    lt_cv_archive_cmds_need_lc_FC=no
+	  else
+	    lt_cv_archive_cmds_need_lc_FC=yes
+	  fi
+	  allow_undefined_flag_FC=$lt_save_allow_undefined_flag
+	else
+	  cat conftest.err 1>&5
+	fi
+	$RM conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_FC" >&5
+$as_echo "$lt_cv_archive_cmds_need_lc_FC" >&6; }
+      archive_cmds_need_lc_FC=$lt_cv_archive_cmds_need_lc_FC
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+
+
+
 
-      dgux*)
-        case $cc_basename in
-          ec++*)
-	    # FIXME: insert proper C++ library support
-	    ld_shlibs_CXX=no
-	    ;;
-          ghcx*)
-	    # Green Hills C++ Compiler
-	    # FIXME: insert proper C++ library support
-	    ld_shlibs_CXX=no
-	    ;;
-          *)
-	    # FIXME: insert proper C++ library support
-	    ld_shlibs_CXX=no
-	    ;;
-        esac
-        ;;
 
-      freebsd2.*)
-        # C++ shared libraries reported to be fairly broken before
-	# switch to ELF
-        ld_shlibs_CXX=no
-        ;;
 
-      freebsd-elf*)
-        archive_cmds_need_lc_CXX=no
-        ;;
 
-      freebsd* | dragonfly*)
-        # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
-        # conventions
-        ld_shlibs_CXX=yes
-        ;;
 
-      gnu*)
-        ;;
 
-      haiku*)
-        archive_cmds_CXX='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-        link_all_deplibs_CXX=yes
-        ;;
 
-      hpux9*)
-        hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
-        hardcode_libdir_separator_CXX=:
-        export_dynamic_flag_spec_CXX='${wl}-E'
-        hardcode_direct_CXX=yes
-        hardcode_minus_L_CXX=yes # Not in the search PATH,
-				             # but as the default
-				             # location of the library.
 
-        case $cc_basename in
-          CC*)
-            # FIXME: insert proper C++ library support
-            ld_shlibs_CXX=no
-            ;;
-          aCC*)
-            archive_cmds_CXX='$RM $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-            # Commands to make compiler produce verbose output that lists
-            # what "hidden" libraries, object files and flags are used when
-            # linking a shared library.
-            #
-            # There doesn't appear to be a way to prevent this compiler from
-            # explicitly linking system object files so we need to strip them
-            # from the output so that they don't get included in the library
-            # dependencies.
-            output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $EGREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
-            ;;
-          *)
-            if test "$GXX" = yes; then
-              archive_cmds_CXX='$RM $output_objdir/$soname~$CC -shared -nostdlib $pic_flag ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
-            else
-              # FIXME: insert proper C++ library support
-              ld_shlibs_CXX=no
-            fi
-            ;;
-        esac
-        ;;
 
-      hpux10*|hpux11*)
-        if test $with_gnu_ld = no; then
-	  hardcode_libdir_flag_spec_CXX='${wl}+b ${wl}$libdir'
-	  hardcode_libdir_separator_CXX=:
 
-          case $host_cpu in
-            hppa*64*|ia64*)
-              ;;
-            *)
-	      export_dynamic_flag_spec_CXX='${wl}-E'
-              ;;
-          esac
-        fi
-        case $host_cpu in
-          hppa*64*|ia64*)
-            hardcode_direct_CXX=no
-            hardcode_shlibpath_var_CXX=no
-            ;;
-          *)
-            hardcode_direct_CXX=yes
-            hardcode_direct_absolute_CXX=yes
-            hardcode_minus_L_CXX=yes # Not in the search PATH,
-					         # but as the default
-					         # location of the library.
-            ;;
-        esac
 
-        case $cc_basename in
-          CC*)
-	    # FIXME: insert proper C++ library support
-	    ld_shlibs_CXX=no
-	    ;;
-          aCC*)
-	    case $host_cpu in
-	      hppa*64*)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	        ;;
-	      ia64*)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	        ;;
-	      *)
-	        archive_cmds_CXX='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	        ;;
-	    esac
-	    # Commands to make compiler produce verbose output that lists
-	    # what "hidden" libraries, object files and flags are used when
-	    # linking a shared library.
-	    #
-	    # There doesn't appear to be a way to prevent this compiler from
-	    # explicitly linking system object files so we need to strip them
-	    # from the output so that they don't get included in the library
-	    # dependencies.
-	    output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | $GREP "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
-	    ;;
-          *)
-	    if test "$GXX" = yes; then
-	      if test $with_gnu_ld = no; then
-	        case $host_cpu in
-	          hppa*64*)
-	            archive_cmds_CXX='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	            ;;
-	          ia64*)
-	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+nodefaultrpath -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	            ;;
-	          *)
-	            archive_cmds_CXX='$CC -shared -nostdlib $pic_flag ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	            ;;
-	        esac
-	      fi
-	    else
-	      # FIXME: insert proper C++ library support
-	      ld_shlibs_CXX=no
-	    fi
-	    ;;
-        esac
-        ;;
 
-      interix[3-9]*)
-	hardcode_direct_CXX=no
-	hardcode_shlibpath_var_CXX=no
-	hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	export_dynamic_flag_spec_CXX='${wl}-E'
-	# Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.
-	# Instead, shared libraries are loaded at an image base (0x10000000 by
-	# default) and relocated if they conflict, which is a slow very memory
-	# consuming and fragmenting process.  To avoid this, we pick a random,
-	# 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link
-	# time.  Moving up from 0x10000000 also allows more sbrk(2) space.
-	archive_cmds_CXX='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	archive_expsym_cmds_CXX='sed "s,^,_," $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags ${wl}-h,$soname ${wl}--retain-symbols-file,$output_objdir/$soname.expsym ${wl}--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'
-	;;
-      irix5* | irix6*)
-        case $cc_basename in
-          CC*)
-	    # SGI C++
-	    archive_cmds_CXX='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
 
-	    # Archives containing C++ object files must be created using
-	    # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
-	    # necessary to make sure instantiated templates are included
-	    # in the archive.
-	    old_archive_cmds_CXX='$CC -ar -WR,-u -o $oldlib $oldobjs'
-	    ;;
-          *)
-	    if test "$GXX" = yes; then
-	      if test "$with_gnu_ld" = no; then
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-	      else
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` -o $lib'
-	      fi
-	    fi
-	    link_all_deplibs_CXX=yes
-	    ;;
-        esac
-        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-        hardcode_libdir_separator_CXX=:
-        inherit_rpath_CXX=yes
-        ;;
 
-      linux* | k*bsd*-gnu | kopensolaris*-gnu)
-        case $cc_basename in
-          KCC*)
-	    # Kuck and Associates, Inc. (KAI) C++ Compiler
 
-	    # KCC will only create a shared library if the output file
-	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
-	    # to its proper name (with version) after linking.
-	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
-	    archive_expsym_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
-	    # Commands to make compiler produce verbose output that lists
-	    # what "hidden" libraries, object files and flags are used when
-	    # linking a shared library.
-	    #
-	    # There doesn't appear to be a way to prevent this compiler from
-	    # explicitly linking system object files so we need to strip them
-	    # from the output so that they don't get included in the library
-	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | $GREP "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
 
-	    # Archives containing C++ object files must be created using
-	    # "CC -Bstatic", where "CC" is the KAI C++ compiler.
-	    old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs'
-	    ;;
-	  icpc* | ecpc* )
-	    # Intel C++
-	    with_gnu_ld=yes
-	    # version 8.0 and above of icpc choke on multiply defined symbols
-	    # if we add $predep_objects and $postdep_objects, however 7.1 and
-	    # earlier do not add the objects themselves.
-	    case `$CC -V 2>&1` in
-	      *"Version 7."*)
-	        archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-		;;
-	      *)  # Version 8.0 or newer
-	        tmp_idyn=
-	        case $host_cpu in
-		  ia64*) tmp_idyn=' -i_dynamic';;
-		esac
-	        archive_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-		archive_expsym_cmds_CXX='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
-		;;
-	    esac
-	    archive_cmds_need_lc_CXX=no
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    whole_archive_flag_spec_CXX='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
-	    ;;
-          pgCC* | pgcpp*)
-            # Portland Group C++ compiler
-	    case `$CC -V` in
-	    *pgCC\ [1-5].* | *pgcpp\ [1-5].*)
-	      prelink_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $objs $libobjs $compile_deplibs~
-		compile_command="$compile_command `find $tpldir -name \*.o | sort | $NL2SP`"'
-	      old_archive_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $oldobjs$old_deplibs~
-		$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs `find $tpldir -name \*.o | sort | $NL2SP`~
-		$RANLIB $oldlib'
-	      archive_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      archive_expsym_cmds_CXX='tpldir=Template.dir~
-		rm -rf $tpldir~
-		$CC --prelink_objects --instantiation_dir $tpldir $predep_objects $libobjs $deplibs $convenience $postdep_objects~
-		$CC -shared $pic_flag $predep_objects $libobjs $deplibs `find $tpldir -name \*.o | sort | $NL2SP` $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-	      ;;
-	    *) # Version 6 and above use weak symbols
-	      archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
-	      archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
-	      ;;
-	    esac
 
-	    hardcode_libdir_flag_spec_CXX='${wl}--rpath ${wl}$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    whole_archive_flag_spec_CXX='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-            ;;
-	  cxx*)
-	    # Compaq C++
-	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    archive_expsym_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
 
-	    runpath_var=LD_RUN_PATH
-	    hardcode_libdir_flag_spec_CXX='-rpath $libdir'
-	    hardcode_libdir_separator_CXX=:
 
-	    # Commands to make compiler produce verbose output that lists
-	    # what "hidden" libraries, object files and flags are used when
-	    # linking a shared library.
-	    #
-	    # There doesn't appear to be a way to prevent this compiler from
-	    # explicitly linking system object files so we need to strip them
-	    # from the output so that they don't get included in the library
-	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "X$list" | $Xsed'
-	    ;;
-	  xl* | mpixl* | bgxl*)
-	    # IBM XL 8.0 on PPC, with GNU ld
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-	    export_dynamic_flag_spec_CXX='${wl}--export-dynamic'
-	    archive_cmds_CXX='$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
-	    if test "x$supports_anon_versioning" = xyes; then
-	      archive_expsym_cmds_CXX='echo "{ global:" > $output_objdir/$libname.ver~
-		cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
-		echo "local: *; };" >> $output_objdir/$libname.ver~
-		$CC -qmkshrobj $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
-	    fi
-	    ;;
-	  *)
-	    case `$CC -V 2>&1 | sed 5q` in
-	    *Sun\ C*)
-	      # Sun C++ 5.9
-	      no_undefined_flag_CXX=' -zdefs'
-	      archive_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	      archive_expsym_cmds_CXX='$CC -G${allow_undefined_flag} -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file ${wl}$export_symbols'
-	      hardcode_libdir_flag_spec_CXX='-R$libdir'
-	      whole_archive_flag_spec_CXX='${wl}--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` ${wl}--no-whole-archive'
-	      compiler_needs_object_CXX=yes
 
-	      # Not sure whether something based on
-	      # $CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1
-	      # would be better.
-	      output_verbose_link_cmd='func_echo_all'
 
-	      # Archives containing C++ object files must be created using
-	      # "CC -xar", where "CC" is the Sun C++ compiler.  This is
-	      # necessary to make sure instantiated templates are included
-	      # in the archive.
-	      old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
-	      ;;
-	    esac
-	    ;;
-	esac
-	;;
 
-      lynxos*)
-        # FIXME: insert proper C++ library support
-	ld_shlibs_CXX=no
-	;;
 
-      m88k*)
-        # FIXME: insert proper C++ library support
-        ld_shlibs_CXX=no
-	;;
 
-      mvs*)
-        case $cc_basename in
-          cxx*)
-	    # FIXME: insert proper C++ library support
-	    ld_shlibs_CXX=no
-	    ;;
-	  *)
-	    # FIXME: insert proper C++ library support
-	    ld_shlibs_CXX=no
-	    ;;
-	esac
-	;;
 
-      netbsd*)
-        if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-	  archive_cmds_CXX='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
-	  wlarc=
-	  hardcode_libdir_flag_spec_CXX='-R$libdir'
-	  hardcode_direct_CXX=yes
-	  hardcode_shlibpath_var_CXX=no
-	fi
-	# Workaround some broken pre-1.5 toolchains
-	output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
-	;;
 
-      *nto* | *qnx*)
-        ld_shlibs_CXX=yes
-	;;
 
-      openbsd2*)
-        # C++ shared libraries are fairly broken
-	ld_shlibs_CXX=no
-	;;
 
-      openbsd*)
-	if test -f /usr/libexec/ld.so; then
-	  hardcode_direct_CXX=yes
-	  hardcode_shlibpath_var_CXX=no
-	  hardcode_direct_absolute_CXX=yes
-	  archive_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
-	  hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-	    archive_expsym_cmds_CXX='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
-	    export_dynamic_flag_spec_CXX='${wl}-E'
-	    whole_archive_flag_spec_CXX="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
-	  fi
-	  output_verbose_link_cmd=func_echo_all
-	else
-	  ld_shlibs_CXX=no
-	fi
-	;;
 
-      osf3* | osf4* | osf5*)
-        case $cc_basename in
-          KCC*)
-	    # Kuck and Associates, Inc. (KAI) C++ Compiler
 
-	    # KCC will only create a shared library if the output file
-	    # ends with ".so" (or ".sl" for HP-UX), so rename the library
-	    # to its proper name (with version) after linking.
-	    archive_cmds_CXX='tempext=`echo $shared_ext | $SED -e '\''s/\([^()0-9A-Za-z{}]\)/\\\\\1/g'\''`; templib=`echo "$lib" | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
 
-	    hardcode_libdir_flag_spec_CXX='${wl}-rpath,$libdir'
-	    hardcode_libdir_separator_CXX=:
 
-	    # Archives containing C++ object files must be created using
-	    # the KAI C++ compiler.
-	    case $host in
-	      osf3*) old_archive_cmds_CXX='$CC -Bstatic -o $oldlib $oldobjs' ;;
-	      *) old_archive_cmds_CXX='$CC -o $oldlib $oldobjs' ;;
-	    esac
-	    ;;
-          RCC*)
-	    # Rational C++ 2.4.1
-	    # FIXME: insert proper C++ library support
-	    ld_shlibs_CXX=no
-	    ;;
-          cxx*)
-	    case $host in
-	      osf3*)
-	        allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && func_echo_all "${wl}-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-		;;
-	      *)
-	        allow_undefined_flag_CXX=' -expect_unresolved \*'
-	        archive_cmds_CXX='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib'
-	        archive_expsym_cmds_CXX='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
-	          echo "-hidden">> $lib.exp~
-	          $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname ${wl}-input ${wl}$lib.exp  `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry ${output_objdir}/so_locations -o $lib~
-	          $RM $lib.exp'
-	        hardcode_libdir_flag_spec_CXX='-rpath $libdir'
-		;;
-	    esac
 
-	    hardcode_libdir_separator_CXX=:
 
-	    # Commands to make compiler produce verbose output that lists
-	    # what "hidden" libraries, object files and flags are used when
-	    # linking a shared library.
-	    #
-	    # There doesn't appear to be a way to prevent this compiler from
-	    # explicitly linking system object files so we need to strip them
-	    # from the output so that they don't get included in the library
-	    # dependencies.
-	    output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP "ld" | $GREP -v "ld:"`; templist=`func_echo_all "$templist" | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; func_echo_all "$list"'
-	    ;;
-	  *)
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      allow_undefined_flag_CXX=' ${wl}-expect_unresolved ${wl}\*'
-	      case $host in
-	        osf3*)
-	          archive_cmds_CXX='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-		  ;;
-	        *)
-	          archive_cmds_CXX='$CC -shared $pic_flag -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && func_echo_all "${wl}-set_version ${wl}$verstring"` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
-		  ;;
-	      esac
 
-	      hardcode_libdir_flag_spec_CXX='${wl}-rpath ${wl}$libdir'
-	      hardcode_libdir_separator_CXX=:
 
-	      # Commands to make compiler produce verbose output that lists
-	      # what "hidden" libraries, object files and flags are used when
-	      # linking a shared library.
-	      output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
 
-	    else
-	      # FIXME: insert proper C++ library support
-	      ld_shlibs_CXX=no
-	    fi
-	    ;;
-        esac
-        ;;
 
-      psos*)
-        # FIXME: insert proper C++ library support
-        ld_shlibs_CXX=no
-        ;;
 
-      sunos4*)
-        case $cc_basename in
-          CC*)
-	    # Sun C++ 4.x
-	    # FIXME: insert proper C++ library support
-	    ld_shlibs_CXX=no
-	    ;;
-          lcc*)
-	    # Lucid
-	    # FIXME: insert proper C++ library support
-	    ld_shlibs_CXX=no
-	    ;;
-          *)
-	    # FIXME: insert proper C++ library support
-	    ld_shlibs_CXX=no
-	    ;;
-        esac
-        ;;
 
-      solaris*)
-        case $cc_basename in
-          CC* | sunCC*)
-	    # Sun C++ 4.2, 5.x and Centerline C++
-            archive_cmds_need_lc_CXX=yes
-	    no_undefined_flag_CXX=' -zdefs'
-	    archive_cmds_CXX='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
-	    archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-	      $CC -G${allow_undefined_flag} ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
-	    hardcode_libdir_flag_spec_CXX='-R$libdir'
-	    hardcode_shlibpath_var_CXX=no
-	    case $host_os in
-	      solaris2.[0-5] | solaris2.[0-5].*) ;;
-	      *)
-		# The compiler driver will combine and reorder linker options,
-		# but understands `-z linker_flag'.
-	        # Supported since Solaris 2.6 (maybe 2.5.1?)
-		whole_archive_flag_spec_CXX='-z allextract$convenience -z defaultextract'
-	        ;;
-	    esac
-	    link_all_deplibs_CXX=yes
 
-	    output_verbose_link_cmd='func_echo_all'
 
-	    # Archives containing C++ object files must be created using
-	    # "CC -xar", where "CC" is the Sun C++ compiler.  This is
-	    # necessary to make sure instantiated templates are included
-	    # in the archive.
-	    old_archive_cmds_CXX='$CC -xar -o $oldlib $oldobjs'
-	    ;;
-          gcx*)
-	    # Green Hills C++ Compiler
-	    archive_cmds_CXX='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
 
-	    # The C++ compiler must be used to create the archive.
-	    old_archive_cmds_CXX='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
-	    ;;
-          *)
-	    # GNU C++ compiler with Solaris linker
-	    if test "$GXX" = yes && test "$with_gnu_ld" = no; then
-	      no_undefined_flag_CXX=' ${wl}-z ${wl}defs'
-	      if $CC --version | $GREP -v '^2\.7' > /dev/null; then
-	        archive_cmds_CXX='$CC -shared $pic_flag -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -shared $pic_flag -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
-	        # Commands to make compiler produce verbose output that lists
-	        # what "hidden" libraries, object files and flags are used when
-	        # linking a shared library.
-	        output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
-	      else
-	        # g++ 2.7 appears to require `-G' NOT `-shared' on this
-	        # platform.
-	        archive_cmds_CXX='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
-	        archive_expsym_cmds_CXX='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~
-		  $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$RM $lib.exp'
 
-	        # Commands to make compiler produce verbose output that lists
-	        # what "hidden" libraries, object files and flags are used when
-	        # linking a shared library.
-	        output_verbose_link_cmd='$CC -G $CFLAGS -v conftest.$objext 2>&1 | $GREP -v "^Configured with:" | $GREP "\-L"'
-	      fi
 
-	      hardcode_libdir_flag_spec_CXX='${wl}-R $wl$libdir'
-	      case $host_os in
-		solaris2.[0-5] | solaris2.[0-5].*) ;;
-		*)
-		  whole_archive_flag_spec_CXX='${wl}-z ${wl}allextract$convenience ${wl}-z ${wl}defaultextract'
-		  ;;
-	      esac
-	    fi
-	    ;;
-        esac
-        ;;
 
-    sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
-      no_undefined_flag_CXX='${wl}-z,text'
-      archive_cmds_need_lc_CXX=no
-      hardcode_shlibpath_var_CXX=no
-      runpath_var='LD_RUN_PATH'
 
-      case $cc_basename in
-        CC*)
-	  archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-	*)
-	  archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	  ;;
-      esac
-      ;;
 
-      sysv5* | sco3.2v5* | sco5v6*)
-	# Note: We can NOT use -z defs as we might desire, because we do not
-	# link with -lc, and that would cause any symbols used from libc to
-	# always be unresolved, which means just about no library would
-	# ever link correctly.  If we're not using GNU ld we use -z text
-	# though, which does catch some bad symbols but isn't as heavy-handed
-	# as -z defs.
-	no_undefined_flag_CXX='${wl}-z,text'
-	allow_undefined_flag_CXX='${wl}-z,nodefs'
-	archive_cmds_need_lc_CXX=no
-	hardcode_shlibpath_var_CXX=no
-	hardcode_libdir_flag_spec_CXX='${wl}-R,$libdir'
-	hardcode_libdir_separator_CXX=':'
-	link_all_deplibs_CXX=yes
-	export_dynamic_flag_spec_CXX='${wl}-Bexport'
-	runpath_var='LD_RUN_PATH'
 
-	case $cc_basename in
-          CC*)
-	    archive_cmds_CXX='$CC -G ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    archive_expsym_cmds_CXX='$CC -G ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    old_archive_cmds_CXX='$CC -Tprelink_objects $oldobjs~
-	      '"$old_archive_cmds_CXX"
-	    reload_cmds_CXX='$CC -Tprelink_objects $reload_objs~
-	      '"$reload_cmds_CXX"
-	    ;;
-	  *)
-	    archive_cmds_CXX='$CC -shared ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    archive_expsym_cmds_CXX='$CC -shared ${wl}-Bexport:$export_symbols ${wl}-h,$soname -o $lib $libobjs $deplibs $compiler_flags'
-	    ;;
-	esac
-      ;;
 
-      tandem*)
-        case $cc_basename in
-          NCC*)
-	    # NonStop-UX NCC 3.20
-	    # FIXME: insert proper C++ library support
-	    ld_shlibs_CXX=no
-	    ;;
-          *)
-	    # FIXME: insert proper C++ library support
-	    ld_shlibs_CXX=no
-	    ;;
-        esac
-        ;;
 
-      vxworks*)
-        # FIXME: insert proper C++ library support
-        ld_shlibs_CXX=no
-        ;;
 
-      *)
-        # FIXME: insert proper C++ library support
-        ld_shlibs_CXX=no
-        ;;
-    esac
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
-$as_echo "$ld_shlibs_CXX" >&6; }
-    test "$ld_shlibs_CXX" = no && can_build_shared=no
 
-    GCC_CXX="$GXX"
-    LD_CXX="$LD"
 
-    ## CAVEAT EMPTOR:
-    ## There is no encapsulation within the following macros, do not change
-    ## the running order or otherwise move them around unless you know exactly
-    ## what you are doing...
-    # Dependencies to place before and after the object being linked:
-predep_objects_CXX=
-postdep_objects_CXX=
-predeps_CXX=
-postdeps_CXX=
-compiler_lib_search_path_CXX=
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
 
-cat > conftest.$ac_ext <<_LT_EOF
-class Foo
-{
-public:
-  Foo (void) { a = 0; }
-private:
-  int a;
-};
-_LT_EOF
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+need_lib_prefix=unknown
+hardcode_into_libs=no
 
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
 
-_lt_libdeps_save_CFLAGS=$CFLAGS
-case "$CC $CFLAGS " in #(
-*\ -flto*\ *) CFLAGS="$CFLAGS -fno-lto" ;;
-*\ -fwhopr*\ *) CFLAGS="$CFLAGS -fno-whopr" ;;
-*\ -fuse-linker-plugin*\ *) CFLAGS="$CFLAGS -fno-use-linker-plugin" ;;
-esac
+case $host_os in
+aix3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
 
-if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }; then
-  # Parse the compiler output and extract the necessary
-  # objects, libraries and library flags.
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
 
-  # Sentinel used to keep track of whether or not we are before
-  # the conftest object file.
-  pre_test_object_deps_done=no
+aix[4-9]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+	   echo ' yes '
+	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
+	:
+      else
+	can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
 
-  for p in `eval "$output_verbose_link_cmd"`; do
-    case ${prev}${p} in
+amigaos*)
+  case $host_cpu in
+  powerpc)
+    # Since July 2007 AmigaOS4 officially supports .so libraries.
+    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    ;;
+  m68k)
+    library_names_spec='$libname.ixlibrary $libname.a'
+    # Create ${libname}_ixlibrary.a entries in /sys/libs.
+    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+    ;;
+  esac
+  ;;
 
-    -L* | -R* | -l*)
-       # Some compilers place space between "-{L,R}" and the path.
-       # Remove the space.
-       if test $p = "-L" ||
-          test $p = "-R"; then
-	 prev=$p
-	 continue
-       fi
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
 
-       # Expand the sysroot to ease extracting the directories later.
-       if test -z "$prev"; then
-         case $p in
-         -L*) func_stripname_cnf '-L' '' "$p"; prev=-L; p=$func_stripname_result ;;
-         -R*) func_stripname_cnf '-R' '' "$p"; prev=-R; p=$func_stripname_result ;;
-         -l*) func_stripname_cnf '-l' '' "$p"; prev=-l; p=$func_stripname_result ;;
-         esac
-       fi
-       case $p in
-       =*) func_stripname_cnf '=' '' "$p"; p=$lt_sysroot$func_stripname_result ;;
-       esac
-       if test "$pre_test_object_deps_done" = no; then
-	 case ${prev} in
-	 -L | -R)
-	   # Internal compiler library paths should come after those
-	   # provided the user.  The postdeps already come after the
-	   # user supplied libs so there is no need to process them.
-	   if test -z "$compiler_lib_search_path_CXX"; then
-	     compiler_lib_search_path_CXX="${prev}${p}"
-	   else
-	     compiler_lib_search_path_CXX="${compiler_lib_search_path_CXX} ${prev}${p}"
-	   fi
-	   ;;
-	 # The "-l" case would never come before the object being
-	 # linked, so don't bother handling this case.
-	 esac
-       else
-	 if test -z "$postdeps_CXX"; then
-	   postdeps_CXX="${prev}${p}"
-	 else
-	   postdeps_CXX="${postdeps_CXX} ${prev}${p}"
-	 fi
-       fi
-       prev=
-       ;;
+bsdi[45]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
 
-    *.lto.$objext) ;; # Ignore GCC LTO objects
-    *.$objext)
-       # This assumes that the test object file only shows up
-       # once in the compiler output.
-       if test "$p" = "conftest.$objext"; then
-	 pre_test_object_deps_done=yes
-	 continue
-       fi
+cygwin* | mingw* | pw32* | cegcc*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$cc_basename in
+  yes,*)
+    # gcc
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname~
+      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
+        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
+      fi'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
 
-       if test "$pre_test_object_deps_done" = no; then
-	 if test -z "$predep_objects_CXX"; then
-	   predep_objects_CXX="$p"
-	 else
-	   predep_objects_CXX="$predep_objects_CXX $p"
-	 fi
-       else
-	 if test -z "$postdep_objects_CXX"; then
-	   postdep_objects_CXX="$p"
-	 else
-	   postdep_objects_CXX="$postdep_objects_CXX $p"
-	 fi
-       fi
-       ;;
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
 
-    *) ;; # Ignore the rest.
+      ;;
+    mingw* | cegcc*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    dynamic_linker='Win32 ld.exe'
+    ;;
 
+  *,cl*)
+    # Native MSVC
+    libname_spec='$name'
+    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+    library_names_spec='${libname}.dll.lib'
+
+    case $build_os in
+    mingw*)
+      sys_lib_search_path_spec=
+      lt_save_ifs=$IFS
+      IFS=';'
+      for lt_path in $LIB
+      do
+        IFS=$lt_save_ifs
+        # Let DOS variable expansion print the short 8.3 style file name.
+        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
+        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
+      done
+      IFS=$lt_save_ifs
+      # Convert to MSYS style.
+      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
+      ;;
+    cygwin*)
+      # Convert to unix form, then to dos form, then back to unix form
+      # but this time dos style (no spaces!) so that the unix form looks
+      # like /cygdrive/c/PROGRA~1:/cygdr...
+      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
+      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
+      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      ;;
+    *)
+      sys_lib_search_path_spec="$LIB"
+      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH.
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      # FIXME: find the short name or the path components, as spaces are
+      # common. (e.g. "Program Files" -> "PROGRA~1")
+      ;;
     esac
-  done
 
-  # Clean up.
-  rm -f a.out a.exe
-else
-  echo "libtool.m4: error: problem compiling CXX test program"
-fi
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $RM \$dlpath'
+    shlibpath_overrides_runpath=yes
+    dynamic_linker='Win32 link.exe'
+    ;;
 
-$RM -f confest.$objext
-CFLAGS=$_lt_libdeps_save_CFLAGS
+  *)
+    # Assume MSVC wrapper
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    dynamic_linker='Win32 ld.exe'
+    ;;
+  esac
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
 
-# PORTME: override above test on systems where it is broken
-case $host_os in
-interix[3-9]*)
-  # Interix 3.5 installs completely hosed .la files for C++, so rather than
-  # hack all around it, let's just trust "g++" to DTRT.
-  predep_objects_CXX=
-  postdep_objects_CXX=
-  postdeps_CXX=
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
   ;;
 
-linux*)
-  case `$CC -V 2>&1 | sed 5q` in
-  *Sun\ C*)
-    # Sun C++ 5.9
+dgux*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
 
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[23].*) objformat=aout ;;
+    *) objformat=elf ;;
     esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2.*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
+  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  *) # from 4.6 on, and DragonFly
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
 
-    if test "$solaris_use_stlport4" != yes; then
-      postdeps_CXX='-library=Cstd -library=Crun'
+gnu*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+haiku*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  dynamic_linker="$host_os runtime_loader"
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
     fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  hppa*64*)
+    shrext_cmds='.sl'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+  *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
     ;;
   esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
+  postinstall_cmds='chmod 555 $lib'
+  # or fails outright, so override atomically:
+  install_override_mode=555
+  ;;
+
+interix[3-9]*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
   ;;
 
-solaris*)
-  case $cc_basename in
-  CC* | sunCC*)
-    # The more standards-conforming stlport4 library is
-    # incompatible with the Cstd library. Avoid specifying
-    # it if it's in CXXFLAGS. Ignore libCrun as
-    # -library=stlport4 depends on it.
-    case " $CXX $CXXFLAGS " in
-    *" -library=stlport4 "*)
-      solaris_use_stlport4=yes
-      ;;
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+	if test "$lt_cv_prog_gnu_ld" = yes; then
+		version_type=linux # correct to gnu/linux during the next big refactor
+	else
+		version_type=irix
+	fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
     esac
-
-    # Adding this requires a known-good setup of shared libraries for
-    # Sun compiler versions before 5.6, else PIC objects from an old
-    # archive will be linked into the output, leading to subtle bugs.
-    if test "$solaris_use_stlport4" != yes; then
-      postdeps_CXX='-library=Cstd -library=Crun'
-    fi
     ;;
   esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
   ;;
-esac
-
-
-case " $postdeps_CXX " in
-*" -lc "*) archive_cmds_need_lc_CXX=no ;;
-esac
- compiler_lib_search_dirs_CXX=
-if test -n "${compiler_lib_search_path_CXX}"; then
- compiler_lib_search_dirs_CXX=`echo " ${compiler_lib_search_path_CXX}" | ${SED} -e 's! -L! !g' -e 's!^ !!'`
-fi
-
-
-
-
-
 
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
 
+# This must be glibc/ELF.
+linux* | k*bsd*-gnu | kopensolaris*-gnu)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
 
+  # Some binutils ld are patched to set DT_RUNPATH
+  if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_shlibpath_overrides_runpath=no
+    save_LDFLAGS=$LDFLAGS
+    save_libdir=$libdir
+    eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_FC\"; \
+	 LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_FC\""
+    cat > conftest.$ac_ext <<_ACEOF
+      program conftest
 
+      end
+_ACEOF
+if ac_fn_fc_try_link "$LINENO"; then :
+  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
+  lt_cv_shlibpath_overrides_runpath=yes
+fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    LDFLAGS=$save_LDFLAGS
+    libdir=$save_libdir
 
+fi
 
+  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
 
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
 
-    lt_prog_compiler_wl_CXX=
-lt_prog_compiler_pic_CXX=
-lt_prog_compiler_static_CXX=
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
 
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
 
-  # C++ specific cases for pic, static, wl, etc.
-  if test "$GXX" = yes; then
-    lt_prog_compiler_wl_CXX='-Wl,'
-    lt_prog_compiler_static_CXX='-static'
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
 
-    case $host_os in
-    aix*)
-      # All AIX code is PIC.
-      if test "$host_cpu" = ia64; then
-	# AIX 5 now supports IA64 processor
-	lt_prog_compiler_static_CXX='-Bstatic'
-      fi
-      ;;
+newsos6)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
 
-    amigaos*)
-      case $host_cpu in
-      powerpc)
-            # see comment about AmigaOS4 .so support
-            lt_prog_compiler_pic_CXX='-fPIC'
-        ;;
-      m68k)
-            # FIXME: we need at least 68020 code to build shared libraries, but
-            # adding the `-m68020' flag to GCC prevents building anything better,
-            # like `-m68040'.
-            lt_prog_compiler_pic_CXX='-m68020 -resident32 -malways-restore-a4'
-        ;;
-      esac
-      ;;
+*nto* | *qnx*)
+  version_type=qnx
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='ldqnx.so'
+  ;;
 
-    beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
-      # PIC is the default for these OSes.
-      ;;
-    mingw* | cygwin* | os2* | pw32* | cegcc*)
-      # This hack is so that the source file can tell whether it is being
-      # built for inclusion in a dll (and should export symbols for example).
-      # Although the cygwin gcc ignores -fPIC, still need this for old-style
-      # (--disable-auto-import) libraries
-      lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
-      ;;
-    darwin* | rhapsody*)
-      # PIC is the default on this platform
-      # Common symbols not allowed in MH_DYLIB files
-      lt_prog_compiler_pic_CXX='-fno-common'
-      ;;
-    *djgpp*)
-      # DJGPP does not support shared libraries at all
-      lt_prog_compiler_pic_CXX=
-      ;;
-    haiku*)
-      # PIC is the default for Haiku.
-      # The "-static" flag exists, but is broken.
-      lt_prog_compiler_static_CXX=
-      ;;
-    interix[3-9]*)
-      # Interix 3.x gcc -fpic/-fPIC options generate broken code.
-      # Instead, we relocate shared libraries at runtime.
-      ;;
-    sysv4*MP*)
-      if test -d /usr/nec; then
-	lt_prog_compiler_pic_CXX=-Kconform_pic
-      fi
-      ;;
-    hpux*)
-      # PIC is the default for 64-bit PA HP-UX, but not for 32-bit
-      # PA HP-UX.  On IA64 HP-UX, PIC is the default but the pic flag
-      # sets the default TLS model and affects inlining.
-      case $host_cpu in
-      hppa*64*)
-	;;
-      *)
-	lt_prog_compiler_pic_CXX='-fPIC'
-	;;
-      esac
-      ;;
-    *qnx* | *nto*)
-      # QNX uses GNU C++, but need to define -shared option too, otherwise
-      # it will coredump.
-      lt_prog_compiler_pic_CXX='-fPIC -shared'
-      ;;
-    *)
-      lt_prog_compiler_pic_CXX='-fPIC'
-      ;;
-    esac
-  else
+openbsd*)
+  version_type=sunos
+  sys_lib_dlsearch_path_spec="/usr/lib"
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
+    *)				need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
     case $host_os in
-      aix[4-9]*)
-	# All AIX code is PIC.
-	if test "$host_cpu" = ia64; then
-	  # AIX 5 now supports IA64 processor
-	  lt_prog_compiler_static_CXX='-Bstatic'
-	else
-	  lt_prog_compiler_static_CXX='-bnso -bI:/lib/syscalls.exp'
-	fi
-	;;
-      chorus*)
-	case $cc_basename in
-	cxch68*)
-	  # Green Hills C++ Compiler
-	  # _LT_TAGVAR(lt_prog_compiler_static, CXX)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
-	  ;;
-	esac
-	;;
-      mingw* | cygwin* | os2* | pw32* | cegcc*)
-	# This hack is so that the source file can tell whether it is being
-	# built for inclusion in a dll (and should export symbols for example).
-	lt_prog_compiler_pic_CXX='-DDLL_EXPORT'
-	;;
-      dgux*)
-	case $cc_basename in
-	  ec++*)
-	    lt_prog_compiler_pic_CXX='-KPIC'
-	    ;;
-	  ghcx*)
-	    # Green Hills C++ Compiler
-	    lt_prog_compiler_pic_CXX='-pic'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      freebsd* | dragonfly*)
-	# FreeBSD uses GNU C++
-	;;
-      hpux9* | hpux10* | hpux11*)
-	case $cc_basename in
-	  CC*)
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
-	    if test "$host_cpu" != ia64; then
-	      lt_prog_compiler_pic_CXX='+Z'
-	    fi
-	    ;;
-	  aCC*)
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='${wl}-a ${wl}archive'
-	    case $host_cpu in
-	    hppa*64*|ia64*)
-	      # +Z the default
-	      ;;
-	    *)
-	      lt_prog_compiler_pic_CXX='+Z'
-	      ;;
-	    esac
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      interix*)
-	# This is c89, which is MS Visual C++ (no shared libs)
-	# Anyone wants to do a port?
-	;;
-      irix5* | irix6* | nonstopux*)
-	case $cc_basename in
-	  CC*)
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_static_CXX='-non_shared'
-	    # CC pic flag -KPIC is the default.
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      linux* | k*bsd*-gnu | kopensolaris*-gnu)
-	case $cc_basename in
-	  KCC*)
-	    # KAI C++ Compiler
-	    lt_prog_compiler_wl_CXX='--backend -Wl,'
-	    lt_prog_compiler_pic_CXX='-fPIC'
-	    ;;
-	  ecpc* )
-	    # old Intel C++ for x86_64 which still supported -KPIC.
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_pic_CXX='-KPIC'
-	    lt_prog_compiler_static_CXX='-static'
-	    ;;
-	  icpc* )
-	    # Intel C++, used to be incompatible with GCC.
-	    # ICC 10 doesn't accept -KPIC any more.
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_pic_CXX='-fPIC'
-	    lt_prog_compiler_static_CXX='-static'
-	    ;;
-	  pgCC* | pgcpp*)
-	    # Portland Group C++ compiler
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_pic_CXX='-fpic'
-	    lt_prog_compiler_static_CXX='-Bstatic'
-	    ;;
-	  cxx*)
-	    # Compaq C++
-	    # Make sure the PIC flag is empty.  It appears that all Alpha
-	    # Linux and Compaq Tru64 Unix objects are PIC.
-	    lt_prog_compiler_pic_CXX=
-	    lt_prog_compiler_static_CXX='-non_shared'
-	    ;;
-	  xlc* | xlC* | bgxl[cC]* | mpixl[cC]*)
-	    # IBM XL 8.0, 9.0 on PPC and BlueGene
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_pic_CXX='-qpic'
-	    lt_prog_compiler_static_CXX='-qstaticlink'
-	    ;;
-	  *)
-	    case `$CC -V 2>&1 | sed 5q` in
-	    *Sun\ C*)
-	      # Sun C++ 5.9
-	      lt_prog_compiler_pic_CXX='-KPIC'
-	      lt_prog_compiler_static_CXX='-Bstatic'
-	      lt_prog_compiler_wl_CXX='-Qoption ld '
-	      ;;
-	    esac
-	    ;;
-	esac
-	;;
-      lynxos*)
-	;;
-      m88k*)
-	;;
-      mvs*)
-	case $cc_basename in
-	  cxx*)
-	    lt_prog_compiler_pic_CXX='-W c,exportall'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      netbsd*)
-	;;
-      *qnx* | *nto*)
-        # QNX uses GNU C++, but need to define -shared option too, otherwise
-        # it will coredump.
-        lt_prog_compiler_pic_CXX='-fPIC -shared'
-        ;;
-      osf3* | osf4* | osf5*)
-	case $cc_basename in
-	  KCC*)
-	    lt_prog_compiler_wl_CXX='--backend -Wl,'
-	    ;;
-	  RCC*)
-	    # Rational C++ 2.4.1
-	    lt_prog_compiler_pic_CXX='-pic'
-	    ;;
-	  cxx*)
-	    # Digital/Compaq C++
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    # Make sure the PIC flag is empty.  It appears that all Alpha
-	    # Linux and Compaq Tru64 Unix objects are PIC.
-	    lt_prog_compiler_pic_CXX=
-	    lt_prog_compiler_static_CXX='-non_shared'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      psos*)
-	;;
-      solaris*)
-	case $cc_basename in
-	  CC* | sunCC*)
-	    # Sun C++ 4.2, 5.x and Centerline C++
-	    lt_prog_compiler_pic_CXX='-KPIC'
-	    lt_prog_compiler_static_CXX='-Bstatic'
-	    lt_prog_compiler_wl_CXX='-Qoption ld '
-	    ;;
-	  gcx*)
-	    # Green Hills C++ Compiler
-	    lt_prog_compiler_pic_CXX='-PIC'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      sunos4*)
-	case $cc_basename in
-	  CC*)
-	    # Sun C++ 4.x
-	    lt_prog_compiler_pic_CXX='-pic'
-	    lt_prog_compiler_static_CXX='-Bstatic'
-	    ;;
-	  lcc*)
-	    # Lucid
-	    lt_prog_compiler_pic_CXX='-pic'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
-	case $cc_basename in
-	  CC*)
-	    lt_prog_compiler_wl_CXX='-Wl,'
-	    lt_prog_compiler_pic_CXX='-KPIC'
-	    lt_prog_compiler_static_CXX='-Bstatic'
-	    ;;
-	esac
-	;;
-      tandem*)
-	case $cc_basename in
-	  NCC*)
-	    # NonStop-UX NCC 3.20
-	    lt_prog_compiler_pic_CXX='-KPIC'
-	    ;;
-	  *)
-	    ;;
-	esac
-	;;
-      vxworks*)
+      openbsd2.[89] | openbsd2.[89].*)
+	shlibpath_overrides_runpath=no
 	;;
       *)
-	lt_prog_compiler_can_build_shared_CXX=no
+	shlibpath_overrides_runpath=yes
+	;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+rdos*)
+  dynamic_linker=no
+  ;;
+
+solaris*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.3*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux # correct to gnu/linux during the next big refactor
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
+  version_type=freebsd-elf
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  if test "$with_gnu_ld" = yes; then
+    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
+  else
+    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
+    case $host_os in
+      sco3.2v5*)
+        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
 	;;
     esac
-  fi
+  fi
+  sys_lib_dlsearch_path_spec='/usr/lib'
+  ;;
+
+tpf*)
+  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
+  version_type=linux # correct to gnu/linux during the next big refactor
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  ;;
+
+uts4*)
+  version_type=linux # correct to gnu/linux during the next big refactor
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
+  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
+fi
+if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
+  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
+fi
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action_FC=
+if test -n "$hardcode_libdir_flag_spec_FC" ||
+   test -n "$runpath_var_FC" ||
+   test "X$hardcode_automatic_FC" = "Xyes" ; then
+
+  # We can hardcode non-existent directories.
+  if test "$hardcode_direct_FC" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, FC)" != no &&
+     test "$hardcode_minus_L_FC" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_FC=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_FC=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_FC=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_FC" >&5
+$as_echo "$hardcode_action_FC" >&6; }
+
+if test "$hardcode_action_FC" = relink ||
+   test "$inherit_rpath_FC" = yes; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+
+
+
+
+
+
+  fi # test -n "$compiler"
+
+  GCC=$lt_save_GCC
+  CC=$lt_save_CC
+  CFLAGS=$lt_save_CFLAGS
+fi # test "$_lt_disable_FC" != yes
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+
+
+
+
+
+
+
+
+
+        ac_config_commands="$ac_config_commands libtool"
+
+
+
+
+# Only expand once:
+
+
+## _KPSE_USE_LIBTOOL: Generate a libtool script for use in configure tests
+: ${CONFIG_LT=./config.lt}
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_LT" >&5
+$as_echo "$as_me: creating $CONFIG_LT" >&6;}
+as_write_fail=0
+cat >"$CONFIG_LT" <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate a libtool stub with the current configuration.
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>"$CONFIG_LT" <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+	expr "X$arg" : "X\\(.*\\)$as_nl";
+	arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""	$as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+as_myself=
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error STATUS ERROR [LINENO LOG_FD]
+# ----------------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with STATUS, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$1; test $as_status -eq 0 && as_status=1
+  if test "$4"; then
+    as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4
+  fi
+  $as_echo "$as_me: error: $2" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+	 X"$0" : 'X\(//\)$' \| \
+	 X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\/\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='	';;	# ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='	';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+	 X"$as_dir" : 'X\(//\)[^/]' \| \
+	 X"$as_dir" : 'X\(//\)$' \| \
+	 X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)[^/].*/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\/\)$/{
+	    s//\1/
+	    q
+	  }
+	  /^X\(\/\).*/{
+	    s//\1/
+	    q
+	  }
+	  s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+	test -d "$1/.";
+      else
+	case $1 in #(
+	-*)set "./$1";;
+	esac;
+	case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+	???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## --------------------------------- ##
+## Main body of "$CONFIG_LT" script. ##
+## --------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x "$CONFIG_LT"
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+lt_cl_silent=false
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+} >&5
+
+lt_cl_help="\
+\`$as_me' creates a local libtool stub from the current configuration,
+for use in further configure time tests before the real libtool is
+generated.
+
+Usage: $0 [OPTIONS]
+
+  -h, --help      print this help, then exit
+  -V, --version   print version number, then exit
+  -q, --quiet     do not print progress messages
+  -d, --debug     don't remove temporary files
+
+Report bugs to <bug-libtool at gnu.org>."
+
+lt_cl_version="\
+cdi config.lt 1.7.0
+configured by $0, generated by GNU Autoconf 2.68.
+
+Copyright (C) 2011 Free Software Foundation, Inc.
+This config.lt script is free software; the Free Software Foundation
+gives unlimited permision to copy, distribute and modify it."
+
+while test $# != 0
+do
+  case $1 in
+    --version | --v* | -V )
+      echo "$lt_cl_version"; exit 0 ;;
+    --help | --h* | -h )
+      echo "$lt_cl_help"; exit 0 ;;
+    --debug | --d* | -d )
+      debug=: ;;
+    --quiet | --q* | --silent | --s* | -q )
+      lt_cl_silent=: ;;
+
+    -*) as_fn_error $? "unrecognized option: $1
+Try \`$0 --help' for more information." "$LINENO" 5 ;;
+
+    *) as_fn_error $? "unrecognized argument: $1
+Try \`$0 --help' for more information." "$LINENO" 5 ;;
+  esac
+  shift
+done
+
+if $lt_cl_silent; then
+  exec 6>/dev/null
+fi
+_LTEOF
+
+cat >>"$CONFIG_LT" <<_LTEOF
+
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+sed_quote_subst='$sed_quote_subst'
+double_quote_subst='$double_quote_subst'
+delay_variable_subst='$delay_variable_subst'
+macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`'
+macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`'
+pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'
+enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'
+enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'
+enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'
+SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'
+ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'
+PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`'
+host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`'
+host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`'
+host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`'
+build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`'
+build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`'
+build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`'
+SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`'
+Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`'
+GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`'
+EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`'
+FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`'
+LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`'
+NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`'
+LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`'
+max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`'
+ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`'
+exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`'
+lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`'
+lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`'
+lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`'
+lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`'
+lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`'
+reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`'
+reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`'
+OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`'
+deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`'
+file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`'
+file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`'
+want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`'
+DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`'
+sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`'
+AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`'
+AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`'
+archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`'
+STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`'
+RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`'
+old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`'
+old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
+old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`'
+lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`'
+CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`'
+CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`'
+compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'
+GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'
+nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`'
+lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`'
+objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'
+MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`'
+need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`'
+MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`'
+DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`'
+NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`'
+LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`'
+OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`'
+OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`'
+libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`'
+shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`'
+extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
+archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`'
+export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`'
+whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`'
+compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`'
+old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`'
+archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`'
+archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`'
+module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`'
+module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`'
+with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`'
+allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`'
+no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`'
+hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`'
+hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`'
+hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`'
+hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`'
+inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`'
+link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`'
+always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`'
+export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`'
+exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`'
+include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`'
+prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`'
+postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`'
+file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`'
+variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`'
+need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`'
+need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`'
+version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`'
+runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`'
+shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`'
+shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`'
+libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`'
+library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`'
+soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`'
+install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`'
+postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`'
+postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`'
+finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'
+finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'
+hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'
+sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'
+sys_lib_dlsearch_path_spec='`$ECHO "$sys_lib_dlsearch_path_spec" | $SED "$delay_single_quote_subst"`'
+hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'
+enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'
+enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'
+enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`'
+old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`'
+striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_dirs='`$ECHO "$compiler_lib_search_dirs" | $SED "$delay_single_quote_subst"`'
+predep_objects='`$ECHO "$predep_objects" | $SED "$delay_single_quote_subst"`'
+postdep_objects='`$ECHO "$postdep_objects" | $SED "$delay_single_quote_subst"`'
+predeps='`$ECHO "$predeps" | $SED "$delay_single_quote_subst"`'
+postdeps='`$ECHO "$postdeps" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_path='`$ECHO "$compiler_lib_search_path" | $SED "$delay_single_quote_subst"`'
+LD_CXX='`$ECHO "$LD_CXX" | $SED "$delay_single_quote_subst"`'
+LD_F77='`$ECHO "$LD_F77" | $SED "$delay_single_quote_subst"`'
+LD_FC='`$ECHO "$LD_FC" | $SED "$delay_single_quote_subst"`'
+reload_flag_CXX='`$ECHO "$reload_flag_CXX" | $SED "$delay_single_quote_subst"`'
+reload_flag_F77='`$ECHO "$reload_flag_F77" | $SED "$delay_single_quote_subst"`'
+reload_flag_FC='`$ECHO "$reload_flag_FC" | $SED "$delay_single_quote_subst"`'
+reload_cmds_CXX='`$ECHO "$reload_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+reload_cmds_F77='`$ECHO "$reload_cmds_F77" | $SED "$delay_single_quote_subst"`'
+reload_cmds_FC='`$ECHO "$reload_cmds_FC" | $SED "$delay_single_quote_subst"`'
+old_archive_cmds_CXX='`$ECHO "$old_archive_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+old_archive_cmds_F77='`$ECHO "$old_archive_cmds_F77" | $SED "$delay_single_quote_subst"`'
+old_archive_cmds_FC='`$ECHO "$old_archive_cmds_FC" | $SED "$delay_single_quote_subst"`'
+compiler_CXX='`$ECHO "$compiler_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_F77='`$ECHO "$compiler_F77" | $SED "$delay_single_quote_subst"`'
+compiler_FC='`$ECHO "$compiler_FC" | $SED "$delay_single_quote_subst"`'
+GCC_CXX='`$ECHO "$GCC_CXX" | $SED "$delay_single_quote_subst"`'
+GCC_F77='`$ECHO "$GCC_F77" | $SED "$delay_single_quote_subst"`'
+GCC_FC='`$ECHO "$GCC_FC" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "$lt_prog_compiler_no_builtin_flag_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_F77='`$ECHO "$lt_prog_compiler_no_builtin_flag_F77" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_FC='`$ECHO "$lt_prog_compiler_no_builtin_flag_FC" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_CXX='`$ECHO "$lt_prog_compiler_pic_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_F77='`$ECHO "$lt_prog_compiler_pic_F77" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_FC='`$ECHO "$lt_prog_compiler_pic_FC" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_CXX='`$ECHO "$lt_prog_compiler_wl_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_F77='`$ECHO "$lt_prog_compiler_wl_F77" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_FC='`$ECHO "$lt_prog_compiler_wl_FC" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_static_CXX='`$ECHO "$lt_prog_compiler_static_CXX" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_static_F77='`$ECHO "$lt_prog_compiler_static_F77" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_static_FC='`$ECHO "$lt_prog_compiler_static_FC" | $SED "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_CXX='`$ECHO "$lt_cv_prog_compiler_c_o_CXX" | $SED "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_F77='`$ECHO "$lt_cv_prog_compiler_c_o_F77" | $SED "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_FC='`$ECHO "$lt_cv_prog_compiler_c_o_FC" | $SED "$delay_single_quote_subst"`'
+archive_cmds_need_lc_CXX='`$ECHO "$archive_cmds_need_lc_CXX" | $SED "$delay_single_quote_subst"`'
+archive_cmds_need_lc_F77='`$ECHO "$archive_cmds_need_lc_F77" | $SED "$delay_single_quote_subst"`'
+archive_cmds_need_lc_FC='`$ECHO "$archive_cmds_need_lc_FC" | $SED "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_CXX='`$ECHO "$enable_shared_with_static_runtimes_CXX" | $SED "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_F77='`$ECHO "$enable_shared_with_static_runtimes_F77" | $SED "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_FC='`$ECHO "$enable_shared_with_static_runtimes_FC" | $SED "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_CXX='`$ECHO "$export_dynamic_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_F77='`$ECHO "$export_dynamic_flag_spec_F77" | $SED "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_FC='`$ECHO "$export_dynamic_flag_spec_FC" | $SED "$delay_single_quote_subst"`'
+whole_archive_flag_spec_CXX='`$ECHO "$whole_archive_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
+whole_archive_flag_spec_F77='`$ECHO "$whole_archive_flag_spec_F77" | $SED "$delay_single_quote_subst"`'
+whole_archive_flag_spec_FC='`$ECHO "$whole_archive_flag_spec_FC" | $SED "$delay_single_quote_subst"`'
+compiler_needs_object_CXX='`$ECHO "$compiler_needs_object_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_needs_object_F77='`$ECHO "$compiler_needs_object_F77" | $SED "$delay_single_quote_subst"`'
+compiler_needs_object_FC='`$ECHO "$compiler_needs_object_FC" | $SED "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_CXX='`$ECHO "$old_archive_from_new_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_F77='`$ECHO "$old_archive_from_new_cmds_F77" | $SED "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_FC='`$ECHO "$old_archive_from_new_cmds_FC" | $SED "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_CXX='`$ECHO "$old_archive_from_expsyms_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_F77='`$ECHO "$old_archive_from_expsyms_cmds_F77" | $SED "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_FC='`$ECHO "$old_archive_from_expsyms_cmds_FC" | $SED "$delay_single_quote_subst"`'
+archive_cmds_CXX='`$ECHO "$archive_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+archive_cmds_F77='`$ECHO "$archive_cmds_F77" | $SED "$delay_single_quote_subst"`'
+archive_cmds_FC='`$ECHO "$archive_cmds_FC" | $SED "$delay_single_quote_subst"`'
+archive_expsym_cmds_CXX='`$ECHO "$archive_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+archive_expsym_cmds_F77='`$ECHO "$archive_expsym_cmds_F77" | $SED "$delay_single_quote_subst"`'
+archive_expsym_cmds_FC='`$ECHO "$archive_expsym_cmds_FC" | $SED "$delay_single_quote_subst"`'
+module_cmds_CXX='`$ECHO "$module_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+module_cmds_F77='`$ECHO "$module_cmds_F77" | $SED "$delay_single_quote_subst"`'
+module_cmds_FC='`$ECHO "$module_cmds_FC" | $SED "$delay_single_quote_subst"`'
+module_expsym_cmds_CXX='`$ECHO "$module_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+module_expsym_cmds_F77='`$ECHO "$module_expsym_cmds_F77" | $SED "$delay_single_quote_subst"`'
+module_expsym_cmds_FC='`$ECHO "$module_expsym_cmds_FC" | $SED "$delay_single_quote_subst"`'
+with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`'
+with_gnu_ld_F77='`$ECHO "$with_gnu_ld_F77" | $SED "$delay_single_quote_subst"`'
+with_gnu_ld_FC='`$ECHO "$with_gnu_ld_FC" | $SED "$delay_single_quote_subst"`'
+allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`'
+allow_undefined_flag_F77='`$ECHO "$allow_undefined_flag_F77" | $SED "$delay_single_quote_subst"`'
+allow_undefined_flag_FC='`$ECHO "$allow_undefined_flag_FC" | $SED "$delay_single_quote_subst"`'
+no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`'
+no_undefined_flag_F77='`$ECHO "$no_undefined_flag_F77" | $SED "$delay_single_quote_subst"`'
+no_undefined_flag_FC='`$ECHO "$no_undefined_flag_FC" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_F77='`$ECHO "$hardcode_libdir_flag_spec_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_FC='`$ECHO "$hardcode_libdir_flag_spec_FC" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_separator_F77='`$ECHO "$hardcode_libdir_separator_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_separator_FC='`$ECHO "$hardcode_libdir_separator_FC" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_F77='`$ECHO "$hardcode_direct_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_FC='`$ECHO "$hardcode_direct_FC" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_absolute_F77='`$ECHO "$hardcode_direct_absolute_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_absolute_FC='`$ECHO "$hardcode_direct_absolute_FC" | $SED "$delay_single_quote_subst"`'
+hardcode_minus_L_CXX='`$ECHO "$hardcode_minus_L_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_minus_L_F77='`$ECHO "$hardcode_minus_L_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_minus_L_FC='`$ECHO "$hardcode_minus_L_FC" | $SED "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_CXX='`$ECHO "$hardcode_shlibpath_var_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_F77='`$ECHO "$hardcode_shlibpath_var_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_FC='`$ECHO "$hardcode_shlibpath_var_FC" | $SED "$delay_single_quote_subst"`'
+hardcode_automatic_CXX='`$ECHO "$hardcode_automatic_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_automatic_F77='`$ECHO "$hardcode_automatic_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_automatic_FC='`$ECHO "$hardcode_automatic_FC" | $SED "$delay_single_quote_subst"`'
+inherit_rpath_CXX='`$ECHO "$inherit_rpath_CXX" | $SED "$delay_single_quote_subst"`'
+inherit_rpath_F77='`$ECHO "$inherit_rpath_F77" | $SED "$delay_single_quote_subst"`'
+inherit_rpath_FC='`$ECHO "$inherit_rpath_FC" | $SED "$delay_single_quote_subst"`'
+link_all_deplibs_CXX='`$ECHO "$link_all_deplibs_CXX" | $SED "$delay_single_quote_subst"`'
+link_all_deplibs_F77='`$ECHO "$link_all_deplibs_F77" | $SED "$delay_single_quote_subst"`'
+link_all_deplibs_FC='`$ECHO "$link_all_deplibs_FC" | $SED "$delay_single_quote_subst"`'
+always_export_symbols_CXX='`$ECHO "$always_export_symbols_CXX" | $SED "$delay_single_quote_subst"`'
+always_export_symbols_F77='`$ECHO "$always_export_symbols_F77" | $SED "$delay_single_quote_subst"`'
+always_export_symbols_FC='`$ECHO "$always_export_symbols_FC" | $SED "$delay_single_quote_subst"`'
+export_symbols_cmds_CXX='`$ECHO "$export_symbols_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+export_symbols_cmds_F77='`$ECHO "$export_symbols_cmds_F77" | $SED "$delay_single_quote_subst"`'
+export_symbols_cmds_FC='`$ECHO "$export_symbols_cmds_FC" | $SED "$delay_single_quote_subst"`'
+exclude_expsyms_CXX='`$ECHO "$exclude_expsyms_CXX" | $SED "$delay_single_quote_subst"`'
+exclude_expsyms_F77='`$ECHO "$exclude_expsyms_F77" | $SED "$delay_single_quote_subst"`'
+exclude_expsyms_FC='`$ECHO "$exclude_expsyms_FC" | $SED "$delay_single_quote_subst"`'
+include_expsyms_CXX='`$ECHO "$include_expsyms_CXX" | $SED "$delay_single_quote_subst"`'
+include_expsyms_F77='`$ECHO "$include_expsyms_F77" | $SED "$delay_single_quote_subst"`'
+include_expsyms_FC='`$ECHO "$include_expsyms_FC" | $SED "$delay_single_quote_subst"`'
+prelink_cmds_CXX='`$ECHO "$prelink_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+prelink_cmds_F77='`$ECHO "$prelink_cmds_F77" | $SED "$delay_single_quote_subst"`'
+prelink_cmds_FC='`$ECHO "$prelink_cmds_FC" | $SED "$delay_single_quote_subst"`'
+postlink_cmds_CXX='`$ECHO "$postlink_cmds_CXX" | $SED "$delay_single_quote_subst"`'
+postlink_cmds_F77='`$ECHO "$postlink_cmds_F77" | $SED "$delay_single_quote_subst"`'
+postlink_cmds_FC='`$ECHO "$postlink_cmds_FC" | $SED "$delay_single_quote_subst"`'
+file_list_spec_CXX='`$ECHO "$file_list_spec_CXX" | $SED "$delay_single_quote_subst"`'
+file_list_spec_F77='`$ECHO "$file_list_spec_F77" | $SED "$delay_single_quote_subst"`'
+file_list_spec_FC='`$ECHO "$file_list_spec_FC" | $SED "$delay_single_quote_subst"`'
+hardcode_action_CXX='`$ECHO "$hardcode_action_CXX" | $SED "$delay_single_quote_subst"`'
+hardcode_action_F77='`$ECHO "$hardcode_action_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_action_FC='`$ECHO "$hardcode_action_FC" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_dirs_CXX='`$ECHO "$compiler_lib_search_dirs_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_dirs_F77='`$ECHO "$compiler_lib_search_dirs_F77" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_dirs_FC='`$ECHO "$compiler_lib_search_dirs_FC" | $SED "$delay_single_quote_subst"`'
+predep_objects_CXX='`$ECHO "$predep_objects_CXX" | $SED "$delay_single_quote_subst"`'
+predep_objects_F77='`$ECHO "$predep_objects_F77" | $SED "$delay_single_quote_subst"`'
+predep_objects_FC='`$ECHO "$predep_objects_FC" | $SED "$delay_single_quote_subst"`'
+postdep_objects_CXX='`$ECHO "$postdep_objects_CXX" | $SED "$delay_single_quote_subst"`'
+postdep_objects_F77='`$ECHO "$postdep_objects_F77" | $SED "$delay_single_quote_subst"`'
+postdep_objects_FC='`$ECHO "$postdep_objects_FC" | $SED "$delay_single_quote_subst"`'
+predeps_CXX='`$ECHO "$predeps_CXX" | $SED "$delay_single_quote_subst"`'
+predeps_F77='`$ECHO "$predeps_F77" | $SED "$delay_single_quote_subst"`'
+predeps_FC='`$ECHO "$predeps_FC" | $SED "$delay_single_quote_subst"`'
+postdeps_CXX='`$ECHO "$postdeps_CXX" | $SED "$delay_single_quote_subst"`'
+postdeps_F77='`$ECHO "$postdeps_F77" | $SED "$delay_single_quote_subst"`'
+postdeps_FC='`$ECHO "$postdeps_FC" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_path_CXX='`$ECHO "$compiler_lib_search_path_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_path_F77='`$ECHO "$compiler_lib_search_path_F77" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_path_FC='`$ECHO "$compiler_lib_search_path_FC" | $SED "$delay_single_quote_subst"`'
+
+LTCC='$LTCC'
+LTCFLAGS='$LTCFLAGS'
+compiler='$compiler_DEFAULT'
+
+# A function that is used when there is no print builtin or printf.
+func_fallback_echo ()
+{
+  eval 'cat <<_LTECHO_EOF
+\$1
+_LTECHO_EOF'
+}
+
+# Quote evaled strings.
+for var in SHELL \
+ECHO \
+PATH_SEPARATOR \
+SED \
+GREP \
+EGREP \
+FGREP \
+LD \
+NM \
+LN_S \
+lt_SP2NL \
+lt_NL2SP \
+reload_flag \
+OBJDUMP \
+deplibs_check_method \
+file_magic_cmd \
+file_magic_glob \
+want_nocaseglob \
+DLLTOOL \
+sharedlib_from_linklib_cmd \
+AR \
+AR_FLAGS \
+archiver_list_spec \
+STRIP \
+RANLIB \
+CC \
+CFLAGS \
+compiler \
+lt_cv_sys_global_symbol_pipe \
+lt_cv_sys_global_symbol_to_cdecl \
+lt_cv_sys_global_symbol_to_c_name_address \
+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \
+nm_file_list_spec \
+lt_prog_compiler_no_builtin_flag \
+lt_prog_compiler_pic \
+lt_prog_compiler_wl \
+lt_prog_compiler_static \
+lt_cv_prog_compiler_c_o \
+need_locks \
+MANIFEST_TOOL \
+DSYMUTIL \
+NMEDIT \
+LIPO \
+OTOOL \
+OTOOL64 \
+shrext_cmds \
+export_dynamic_flag_spec \
+whole_archive_flag_spec \
+compiler_needs_object \
+with_gnu_ld \
+allow_undefined_flag \
+no_undefined_flag \
+hardcode_libdir_flag_spec \
+hardcode_libdir_separator \
+exclude_expsyms \
+include_expsyms \
+file_list_spec \
+variables_saved_for_relink \
+libname_spec \
+library_names_spec \
+soname_spec \
+install_override_mode \
+finish_eval \
+old_striplib \
+striplib \
+compiler_lib_search_dirs \
+predep_objects \
+postdep_objects \
+predeps \
+postdeps \
+compiler_lib_search_path \
+LD_CXX \
+LD_F77 \
+LD_FC \
+reload_flag_CXX \
+reload_flag_F77 \
+reload_flag_FC \
+compiler_CXX \
+compiler_F77 \
+compiler_FC \
+lt_prog_compiler_no_builtin_flag_CXX \
+lt_prog_compiler_no_builtin_flag_F77 \
+lt_prog_compiler_no_builtin_flag_FC \
+lt_prog_compiler_pic_CXX \
+lt_prog_compiler_pic_F77 \
+lt_prog_compiler_pic_FC \
+lt_prog_compiler_wl_CXX \
+lt_prog_compiler_wl_F77 \
+lt_prog_compiler_wl_FC \
+lt_prog_compiler_static_CXX \
+lt_prog_compiler_static_F77 \
+lt_prog_compiler_static_FC \
+lt_cv_prog_compiler_c_o_CXX \
+lt_cv_prog_compiler_c_o_F77 \
+lt_cv_prog_compiler_c_o_FC \
+export_dynamic_flag_spec_CXX \
+export_dynamic_flag_spec_F77 \
+export_dynamic_flag_spec_FC \
+whole_archive_flag_spec_CXX \
+whole_archive_flag_spec_F77 \
+whole_archive_flag_spec_FC \
+compiler_needs_object_CXX \
+compiler_needs_object_F77 \
+compiler_needs_object_FC \
+with_gnu_ld_CXX \
+with_gnu_ld_F77 \
+with_gnu_ld_FC \
+allow_undefined_flag_CXX \
+allow_undefined_flag_F77 \
+allow_undefined_flag_FC \
+no_undefined_flag_CXX \
+no_undefined_flag_F77 \
+no_undefined_flag_FC \
+hardcode_libdir_flag_spec_CXX \
+hardcode_libdir_flag_spec_F77 \
+hardcode_libdir_flag_spec_FC \
+hardcode_libdir_separator_CXX \
+hardcode_libdir_separator_F77 \
+hardcode_libdir_separator_FC \
+exclude_expsyms_CXX \
+exclude_expsyms_F77 \
+exclude_expsyms_FC \
+include_expsyms_CXX \
+include_expsyms_F77 \
+include_expsyms_FC \
+file_list_spec_CXX \
+file_list_spec_F77 \
+file_list_spec_FC \
+compiler_lib_search_dirs_CXX \
+compiler_lib_search_dirs_F77 \
+compiler_lib_search_dirs_FC \
+predep_objects_CXX \
+predep_objects_F77 \
+predep_objects_FC \
+postdep_objects_CXX \
+postdep_objects_F77 \
+postdep_objects_FC \
+predeps_CXX \
+predeps_F77 \
+predeps_FC \
+postdeps_CXX \
+postdeps_F77 \
+postdeps_FC \
+compiler_lib_search_path_CXX \
+compiler_lib_search_path_F77 \
+compiler_lib_search_path_FC; do
+    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+    *[\\\\\\\`\\"\\\$]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
 
-case $host_os in
-  # For platforms which do not support PIC, -DPIC is meaningless:
-  *djgpp*)
-    lt_prog_compiler_pic_CXX=
-    ;;
-  *)
-    lt_prog_compiler_pic_CXX="$lt_prog_compiler_pic_CXX -DPIC"
-    ;;
-esac
+# Double-quote double-evaled strings.
+for var in reload_cmds \
+old_postinstall_cmds \
+old_postuninstall_cmds \
+old_archive_cmds \
+extract_expsyms_cmds \
+old_archive_from_new_cmds \
+old_archive_from_expsyms_cmds \
+archive_cmds \
+archive_expsym_cmds \
+module_cmds \
+module_expsym_cmds \
+export_symbols_cmds \
+prelink_cmds \
+postlink_cmds \
+postinstall_cmds \
+postuninstall_cmds \
+finish_cmds \
+sys_lib_search_path_spec \
+sys_lib_dlsearch_path_spec \
+reload_cmds_CXX \
+reload_cmds_F77 \
+reload_cmds_FC \
+old_archive_cmds_CXX \
+old_archive_cmds_F77 \
+old_archive_cmds_FC \
+old_archive_from_new_cmds_CXX \
+old_archive_from_new_cmds_F77 \
+old_archive_from_new_cmds_FC \
+old_archive_from_expsyms_cmds_CXX \
+old_archive_from_expsyms_cmds_F77 \
+old_archive_from_expsyms_cmds_FC \
+archive_cmds_CXX \
+archive_cmds_F77 \
+archive_cmds_FC \
+archive_expsym_cmds_CXX \
+archive_expsym_cmds_F77 \
+archive_expsym_cmds_FC \
+module_cmds_CXX \
+module_cmds_F77 \
+module_cmds_FC \
+module_expsym_cmds_CXX \
+module_expsym_cmds_F77 \
+module_expsym_cmds_FC \
+export_symbols_cmds_CXX \
+export_symbols_cmds_F77 \
+export_symbols_cmds_FC \
+prelink_cmds_CXX \
+prelink_cmds_F77 \
+prelink_cmds_FC \
+postlink_cmds_CXX \
+postlink_cmds_F77 \
+postlink_cmds_FC; do
+    case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
+    *[\\\\\\\`\\"\\\$]*)
+      eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
+      ;;
+    *)
+      eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""
+      ;;
+    esac
+done
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
-$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
-if ${lt_cv_prog_compiler_pic_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_pic_CXX=$lt_prog_compiler_pic_CXX
+ac_aux_dir='$ac_aux_dir'
+xsi_shell='$xsi_shell'
+lt_shell_append='$lt_shell_append'
+
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes INIT.
+if test -n "\${ZSH_VERSION+set}" ; then
+   setopt NO_GLOB_SUBST
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_CXX" >&5
-$as_echo "$lt_cv_prog_compiler_pic_CXX" >&6; }
-lt_prog_compiler_pic_CXX=$lt_cv_prog_compiler_pic_CXX
 
+
+    PACKAGE='$PACKAGE'
+    VERSION='$VERSION'
+    TIMESTAMP='$TIMESTAMP'
+    RM='$RM'
+    ofile='$ofile'
+
+
+
+
+
+
+
+
+
+_LTEOF
+
+cat >>"$CONFIG_LT" <<\_LTEOF
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $ofile" >&5
+$as_echo "$as_me: creating $ofile" >&6;}
+
+
+    # See if we are running on zsh, and set the options which allow our
+    # commands through without removal of \ escapes.
+    if test -n "${ZSH_VERSION+set}" ; then
+      setopt NO_GLOB_SUBST
+    fi
+
+    cfgfile="${ofile}T"
+    trap "$RM \"$cfgfile\"; exit 1" 1 2 15
+    $RM "$cfgfile"
+
+    cat <<_LT_EOF >> "$cfgfile"
+#! $SHELL
+
+# `$ECHO "$ofile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $as_me ($PACKAGE$TIMESTAMP) $VERSION
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
 #
-# Check to make sure the PIC flag actually works.
+#   Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005,
+#                 2006, 2007, 2008, 2009, 2010, 2011 Free Software
+#                 Foundation, Inc.
+#   Written by Gordon Matzigkeit, 1996
 #
-if test -n "$lt_prog_compiler_pic_CXX"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works" >&5
-$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_CXX works... " >&6; }
-if ${lt_cv_prog_compiler_pic_works_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_pic_works_CXX=no
-   ac_outfile=conftest.$ac_objext
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
-   lt_compiler_flag="$lt_prog_compiler_pic_CXX -DPIC"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   # The option is referenced via a variable to avoid confusing sed.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>conftest.err)
-   ac_status=$?
-   cat conftest.err >&5
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s "$ac_outfile"; then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings other than the usual output.
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp
-     $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-     if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_pic_works_CXX=yes
-     fi
-   fi
-   $RM conftest*
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works_CXX" >&5
-$as_echo "$lt_cv_prog_compiler_pic_works_CXX" >&6; }
+#   This file is part of GNU Libtool.
+#
+# GNU Libtool is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# As a special exception to the GNU General Public License,
+# if you distribute this file as part of a program or library that
+# is built using GNU Libtool, you may include this file under the
+# same distribution terms that you use for the rest of that program.
+#
+# GNU Libtool is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with GNU Libtool; see the file COPYING.  If not, a copy
+# can be downloaded from http://www.gnu.org/licenses/gpl.html, or
+# obtained by writing to the Free Software Foundation, Inc.,
+# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 
-if test x"$lt_cv_prog_compiler_pic_works_CXX" = xyes; then
-    case $lt_prog_compiler_pic_CXX in
-     "" | " "*) ;;
-     *) lt_prog_compiler_pic_CXX=" $lt_prog_compiler_pic_CXX" ;;
-     esac
-else
-    lt_prog_compiler_pic_CXX=
-     lt_prog_compiler_can_build_shared_CXX=no
-fi
 
-fi
+# The names of the tagged configurations supported by this script.
+available_tags="CXX F77 FC "
 
+# ### BEGIN LIBTOOL CONFIG
 
+# Which release of libtool.m4 was used?
+macro_version=$macro_version
+macro_revision=$macro_revision
 
+# What type of objects to build.
+pic_mode=$pic_mode
 
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
 
-#
-# Check to make sure the static flag actually works.
-#
-wl=$lt_prog_compiler_wl_CXX eval lt_tmp_static_flag=\"$lt_prog_compiler_static_CXX\"
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5
-$as_echo_n "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }
-if ${lt_cv_prog_compiler_static_works_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_static_works_CXX=no
-   save_LDFLAGS="$LDFLAGS"
-   LDFLAGS="$LDFLAGS $lt_tmp_static_flag"
-   echo "$lt_simple_link_test_code" > conftest.$ac_ext
-   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
-     # The linker can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     if test -s conftest.err; then
-       # Append any errors to the config.log.
-       cat conftest.err 1>&5
-       $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp
-       $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2
-       if diff conftest.exp conftest.er2 >/dev/null; then
-         lt_cv_prog_compiler_static_works_CXX=yes
-       fi
-     else
-       lt_cv_prog_compiler_static_works_CXX=yes
-     fi
-   fi
-   $RM -r conftest*
-   LDFLAGS="$save_LDFLAGS"
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works_CXX" >&5
-$as_echo "$lt_cv_prog_compiler_static_works_CXX" >&6; }
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
 
-if test x"$lt_cv_prog_compiler_static_works_CXX" = xyes; then
-    :
-else
-    lt_prog_compiler_static_CXX=
-fi
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
 
+# An echo program that protects backslashes.
+ECHO=$lt_ECHO
 
+# The PATH separator for the build system.
+PATH_SEPARATOR=$lt_PATH_SEPARATOR
 
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
-$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if ${lt_cv_prog_compiler_c_o_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_c_o_CXX=no
-   $RM -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
 
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o_CXX=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $RM conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
-   $RM out/* && rmdir out
-   cd ..
-   $RM -r conftest
-   $RM conftest*
+# A sed program that does not truncate output.
+SED=$lt_SED
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
-$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="\$SED -e 1s/^X//"
 
+# A grep program that handles long lines.
+GREP=$lt_GREP
 
+# An ERE matcher.
+EGREP=$lt_EGREP
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
-$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
-if ${lt_cv_prog_compiler_c_o_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_prog_compiler_c_o_CXX=no
-   $RM -r conftest 2>/dev/null
-   mkdir conftest
-   cd conftest
-   mkdir out
-   echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+# A literal string matcher.
+FGREP=$lt_FGREP
 
-   lt_compiler_flag="-o out/conftest2.$ac_objext"
-   # Insert the option either (1) after the last *FLAGS variable, or
-   # (2) before a word containing "conftest.", or (3) at the end.
-   # Note that $ac_compile itself does not contain backslashes and begins
-   # with a dollar sign (not a hyphen), so the echo should work correctly.
-   lt_compile=`echo "$ac_compile" | $SED \
-   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
-   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
-   -e 's:$: $lt_compiler_flag:'`
-   (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)
-   (eval "$lt_compile" 2>out/conftest.err)
-   ac_status=$?
-   cat out/conftest.err >&5
-   echo "$as_me:$LINENO: \$? = $ac_status" >&5
-   if (exit $ac_status) && test -s out/conftest2.$ac_objext
-   then
-     # The compiler can only warn and ignore the option if not recognized
-     # So say no if there are warnings
-     $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp
-     $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2
-     if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then
-       lt_cv_prog_compiler_c_o_CXX=yes
-     fi
-   fi
-   chmod u+w . 2>&5
-   $RM conftest*
-   # SGI C++ compiler will create directory out/ii_files/ for
-   # template instantiation
-   test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files
-   $RM out/* && rmdir out
-   cd ..
-   $RM -r conftest
-   $RM conftest*
+# A BSD- or MS-compatible name lister.
+NM=$lt_NM
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_CXX" >&5
-$as_echo "$lt_cv_prog_compiler_c_o_CXX" >&6; }
+# Whether we need soft or hard links.
+LN_S=$lt_LN_S
 
+# What is the maximum length of a command?
+max_cmd_len=$max_cmd_len
 
+# Object file suffix (normally "o").
+objext=$ac_objext
 
+# Executable file suffix (normally "").
+exeext=$exeext
 
-hard_links="nottested"
-if test "$lt_cv_prog_compiler_c_o_CXX" = no && test "$need_locks" != no; then
-  # do not overwrite the value of need_locks provided by the user
-  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
-$as_echo_n "checking if we can lock with hard links... " >&6; }
-  hard_links=yes
-  $RM conftest*
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  touch conftest.a
-  ln conftest.a conftest.b 2>&5 || hard_links=no
-  ln conftest.a conftest.b 2>/dev/null && hard_links=no
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
-$as_echo "$hard_links" >&6; }
-  if test "$hard_links" = no; then
-    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
-$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
-    need_locks=warn
-  fi
-else
-  need_locks=no
-fi
+# whether the shell understands "unset".
+lt_unset=$lt_unset
 
+# turn spaces into newlines.
+SP2NL=$lt_lt_SP2NL
 
+# turn newlines into spaces.
+NL2SP=$lt_lt_NL2SP
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
-$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+# convert \$build file names to \$host format.
+to_host_file_cmd=$lt_cv_to_host_file_cmd
 
-  export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-  exclude_expsyms_CXX='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'
-  case $host_os in
-  aix[4-9]*)
-    # If we're using GNU nm, then we don't want the "-C" option.
-    # -C means demangle to AIX nm, but means don't demangle with GNU nm
-    # Also, AIX nm treats weak defined symbols like other global defined
-    # symbols, whereas GNU nm marks them as "W".
-    if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then
-      export_symbols_cmds_CXX='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
-    else
-      export_symbols_cmds_CXX='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B")) && (substr(\$ 3,1,1) != ".")) { print \$ 3 } }'\'' | sort -u > $export_symbols'
-    fi
-    ;;
-  pw32*)
-    export_symbols_cmds_CXX="$ltdll_cmds"
-    ;;
-  cygwin* | mingw* | cegcc*)
-    case $cc_basename in
-    cl*)
-      exclude_expsyms_CXX='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'
-      ;;
-    *)
-      export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'
-      exclude_expsyms_CXX='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'
-      ;;
-    esac
-    ;;
-  *)
-    export_symbols_cmds_CXX='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
-    ;;
-  esac
+# convert \$build files to toolchain format.
+to_tool_file_cmd=$lt_cv_to_tool_file_cmd
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_CXX" >&5
-$as_echo "$ld_shlibs_CXX" >&6; }
-test "$ld_shlibs_CXX" = no && can_build_shared=no
+# An object symbol dumper.
+OBJDUMP=$lt_OBJDUMP
 
-with_gnu_ld_CXX=$with_gnu_ld
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
 
+# Command to use when deplibs_check_method = "file_magic".
+file_magic_cmd=$lt_file_magic_cmd
 
+# How to find potential files when deplibs_check_method = "file_magic".
+file_magic_glob=$lt_file_magic_glob
 
+# Find potential files using nocaseglob when deplibs_check_method = "file_magic".
+want_nocaseglob=$lt_want_nocaseglob
 
+# DLL creation program.
+DLLTOOL=$lt_DLLTOOL
 
+# Command to associate shared and link libraries.
+sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd
 
-#
-# Do we need to explicitly link libc?
-#
-case "x$archive_cmds_need_lc_CXX" in
-x|xyes)
-  # Assume -lc should be added
-  archive_cmds_need_lc_CXX=yes
+# The archiver.
+AR=$lt_AR
 
-  if test "$enable_shared" = yes && test "$GCC" = yes; then
-    case $archive_cmds_CXX in
-    *'~'*)
-      # FIXME: we may have to deal with multi-command sequences.
-      ;;
-    '$CC '*)
-      # Test whether the compiler implicitly links with -lc since on some
-      # systems, -lgcc has to come before -lc. If gcc already passes -lc
-      # to ld, don't add -lc before -lgcc.
-      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
-$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
-if ${lt_cv_archive_cmds_need_lc_CXX+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  $RM conftest*
-	echo "$lt_simple_compile_test_code" > conftest.$ac_ext
+# Flags to create an archive.
+AR_FLAGS=$lt_AR_FLAGS
 
-	if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
-  (eval $ac_compile) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; } 2>conftest.err; then
-	  soname=conftest
-	  lib=conftest
-	  libobjs=conftest.$ac_objext
-	  deplibs=
-	  wl=$lt_prog_compiler_wl_CXX
-	  pic_flag=$lt_prog_compiler_pic_CXX
-	  compiler_flags=-v
-	  linker_flags=-v
-	  verstring=
-	  output_objdir=.
-	  libname=conftest
-	  lt_save_allow_undefined_flag=$allow_undefined_flag_CXX
-	  allow_undefined_flag_CXX=
-	  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5
-  (eval $archive_cmds_CXX 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5
-  ac_status=$?
-  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
-  test $ac_status = 0; }
-	  then
-	    lt_cv_archive_cmds_need_lc_CXX=no
-	  else
-	    lt_cv_archive_cmds_need_lc_CXX=yes
-	  fi
-	  allow_undefined_flag_CXX=$lt_save_allow_undefined_flag
-	else
-	  cat conftest.err 1>&5
-	fi
-	$RM conftest*
+# How to feed a file listing to the archiver.
+archiver_list_spec=$lt_archiver_list_spec
 
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc_CXX" >&5
-$as_echo "$lt_cv_archive_cmds_need_lc_CXX" >&6; }
-      archive_cmds_need_lc_CXX=$lt_cv_archive_cmds_need_lc_CXX
-      ;;
-    esac
-  fi
-  ;;
-esac
+# A symbol stripping program.
+STRIP=$lt_STRIP
+
+# Commands used to install an old-style archive.
+RANLIB=$lt_RANLIB
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Whether to use a lock for old archive extraction.
+lock_old_archive_extraction=$lock_old_archive_extraction
+
+# A C compiler.
+LTCC=$lt_CC
+
+# LTCC compiler flags.
+LTCFLAGS=$lt_CFLAGS
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
 
+# Transform the output of nm in a proper C declaration.
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
 
+# Transform the output of nm in a C name address pair.
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
 
+# Transform the output of nm in a C name address pair when lib prefix is needed.
+global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix
 
+# Specify filename containing input files for \$NM.
+nm_file_list_spec=$lt_nm_file_list_spec
 
+# The root where to search for dependent libraries,and in which our libraries should be installed.
+lt_sysroot=$lt_sysroot
 
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
 
+# Used to examine libraries when file_magic_cmd begins with "file".
+MAGIC_CMD=$MAGIC_CMD
 
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
 
+# Manifest tool.
+MANIFEST_TOOL=$lt_MANIFEST_TOOL
 
+# Tool to manipulate archived DWARF debug symbol files on Mac OS X.
+DSYMUTIL=$lt_DSYMUTIL
 
+# Tool to change global to local symbols on Mac OS X.
+NMEDIT=$lt_NMEDIT
 
+# Tool to manipulate fat objects and archives on Mac OS X.
+LIPO=$lt_LIPO
 
+# ldd/readelf like tool for Mach-O binaries on Mac OS X.
+OTOOL=$lt_OTOOL
 
+# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.
+OTOOL64=$lt_OTOOL64
 
+# Old archive suffix (normally "a").
+libext=$libext
 
+# Shared library suffix (normally ".so").
+shrext_cmds=$lt_shrext_cmds
 
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
 
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at link time.
+variables_saved_for_relink=$lt_variables_saved_for_relink
 
+# Do we need the "lib" prefix for modules?
+need_lib_prefix=$need_lib_prefix
 
+# Do we need a version for libraries?
+need_version=$need_version
 
+# Library versioning type.
+version_type=$version_type
 
+# Shared library runtime path variable.
+runpath_var=$runpath_var
 
+# Shared library path variable.
+shlibpath_var=$shlibpath_var
 
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
 
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
 
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME
+library_names_spec=$lt_library_names_spec
 
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
 
+# Permission mode override for installation of shared libraries.
+install_override_mode=$lt_install_override_mode
 
+# Command to use after installation of a shared archive.
+postinstall_cmds=$lt_postinstall_cmds
 
+# Command to use after uninstallation of a shared archive.
+postuninstall_cmds=$lt_postuninstall_cmds
 
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
 
+# As "finish_cmds", except a single script fragment to be evaled but
+# not shown.
+finish_eval=$lt_finish_eval
 
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
 
+# Compile-time system search path for libraries.
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
 
+# Run-time system search path for libraries.
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
 
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
 
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
 
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
 
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
 
 
+# The linker used to build libraries.
+LD=$lt_LD
 
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
 
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds
 
+# A language specific compiler.
+CC=$lt_compiler
 
+# Is the compiler the GNU compiler?
+with_gcc=$GCC
 
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
 
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic
 
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl
 
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static
 
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o
 
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc
 
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
 
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
 
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
 
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object
 
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
 
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
 
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
 
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds
+module_expsym_cmds=$lt_module_expsym_cmds
 
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld
 
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
-$as_echo_n "checking dynamic linker characteristics... " >&6; }
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
 
-library_names_spec=
-libname_spec='lib$name'
-soname_spec=
-shrext_cmds=".so"
-postinstall_cmds=
-postuninstall_cmds=
-finish_cmds=
-finish_eval=
-shlibpath_var=
-shlibpath_overrides_runpath=unknown
-version_type=none
-dynamic_linker="$host_os ld.so"
-sys_lib_dlsearch_path_spec="/lib /usr/lib"
-need_lib_prefix=unknown
-hardcode_into_libs=no
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
 
-# when you set need_version to no, make sure it does not cause -set_version
-# flags to be left without arguments
-need_version=unknown
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
 
-case $host_os in
-aix3*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
-  shlibpath_var=LIBPATH
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct
 
-  # AIX 3 has no versioning support, so we append a major version to the name.
-  soname_spec='${libname}${release}${shared_ext}$major'
-  ;;
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute
 
-aix[4-9]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  hardcode_into_libs=yes
-  if test "$host_cpu" = ia64; then
-    # AIX 5 supports IA64
-    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
-    shlibpath_var=LD_LIBRARY_PATH
-  else
-    # With GCC up to 2.95.x, collect2 would create an import file
-    # for dependence libraries.  The import file would start with
-    # the line `#! .'.  This would cause the generated library to
-    # depend on `.', always an invalid library.  This was fixed in
-    # development snapshots of GCC prior to 3.0.
-    case $host_os in
-      aix4 | aix4.[01] | aix4.[01].*)
-      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
-	   echo ' yes '
-	   echo '#endif'; } | ${CC} -E - | $GREP yes > /dev/null; then
-	:
-      else
-	can_build_shared=no
-      fi
-      ;;
-    esac
-    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
-    # soname into executable. Probably we can add versioning support to
-    # collect2, so additional links can be useful in future.
-    if test "$aix_use_runtimelinking" = yes; then
-      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
-      # instead of lib<name>.a to let people know that these are not
-      # typical AIX shared libraries.
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    else
-      # We preserve .a as extension for shared libraries through AIX4.2
-      # and later when we are not doing run time linking.
-      library_names_spec='${libname}${release}.a $libname.a'
-      soname_spec='${libname}${release}${shared_ext}$major'
-    fi
-    shlibpath_var=LIBPATH
-  fi
-  ;;
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L
 
-amigaos*)
-  case $host_cpu in
-  powerpc)
-    # Since July 2007 AmigaOS4 officially supports .so libraries.
-    # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    ;;
-  m68k)
-    library_names_spec='$libname.ixlibrary $libname.a'
-    # Create ${libname}_ixlibrary.a entries in /sys/libs.
-    finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
-    ;;
-  esac
-  ;;
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
 
-beos*)
-  library_names_spec='${libname}${shared_ext}'
-  dynamic_linker="$host_os ld.so"
-  shlibpath_var=LIBRARY_PATH
-  ;;
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic
 
-bsdi[45]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
-  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
-  # the default ld.so.conf also contains /usr/contrib/lib and
-  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
-  # libtool to hard-code these into programs
-  ;;
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath
 
-cygwin* | mingw* | pw32* | cegcc*)
-  version_type=windows
-  shrext_cmds=".dll"
-  need_version=no
-  need_lib_prefix=no
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
 
-  case $GCC,$cc_basename in
-  yes,*)
-    # gcc
-    library_names_spec='$libname.dll.a'
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname~
-      chmod a+x \$dldir/$dlname~
-      if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then
-        eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;
-      fi'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $RM \$dlpath'
-    shlibpath_overrides_runpath=yes
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols
 
-    case $host_os in
-    cygwin*)
-      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
-      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
 
-      ;;
-    mingw* | cegcc*)
-      # MinGW DLLs use traditional 'lib' prefix
-      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    pw32*)
-      # pw32 DLLs use 'pw' prefix rather than 'lib'
-      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-      ;;
-    esac
-    dynamic_linker='Win32 ld.exe'
-    ;;
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
 
-  *,cl*)
-    # Native MSVC
-    libname_spec='$name'
-    soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
-    library_names_spec='${libname}.dll.lib'
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
 
-    case $build_os in
-    mingw*)
-      sys_lib_search_path_spec=
-      lt_save_ifs=$IFS
-      IFS=';'
-      for lt_path in $LIB
-      do
-        IFS=$lt_save_ifs
-        # Let DOS variable expansion print the short 8.3 style file name.
-        lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`
-        sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"
-      done
-      IFS=$lt_save_ifs
-      # Convert to MSYS style.
-      sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | sed -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`
-      ;;
-    cygwin*)
-      # Convert to unix form, then to dos form, then back to unix form
-      # but this time dos style (no spaces!) so that the unix form looks
-      # like /cygdrive/c/PROGRA~1:/cygdr...
-      sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`
-      sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`
-      sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
-      ;;
-    *)
-      sys_lib_search_path_spec="$LIB"
-      if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then
-        # It is most probably a Windows format PATH.
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
-      else
-        sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`
-      fi
-      # FIXME: find the short name or the path components, as spaces are
-      # common. (e.g. "Program Files" -> "PROGRA~1")
-      ;;
-    esac
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds
 
-    # DLL is installed to $(libdir)/../bin by postinstall_cmds
-    postinstall_cmds='base_file=`basename \${file}`~
-      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i; echo \$dlname'\''`~
-      dldir=$destdir/`dirname \$dlpath`~
-      test -d \$dldir || mkdir -p \$dldir~
-      $install_prog $dir/$dlname \$dldir/$dlname'
-    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
-      dlpath=$dir/\$dldll~
-       $RM \$dlpath'
-    shlibpath_overrides_runpath=yes
-    dynamic_linker='Win32 link.exe'
-    ;;
+# Commands necessary for finishing linking programs.
+postlink_cmds=$lt_postlink_cmds
 
-  *)
-    # Assume MSVC wrapper
-    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
-    dynamic_linker='Win32 ld.exe'
-    ;;
-  esac
-  # FIXME: first we should search . and the directory the executable is in
-  shlibpath_var=PATH
-  ;;
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec
 
-darwin* | rhapsody*)
-  dynamic_linker="$host_os dyld"
-  version_type=darwin
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${major}$shared_ext ${libname}$shared_ext'
-  soname_spec='${libname}${release}${major}$shared_ext'
-  shlibpath_overrides_runpath=yes
-  shlibpath_var=DYLD_LIBRARY_PATH
-  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
 
-  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
-  ;;
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs
+
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects
+postdep_objects=$lt_postdep_objects
+predeps=$lt_predeps
+postdeps=$lt_postdeps
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path
 
-dgux*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
+# ### END LIBTOOL CONFIG
+
+_LT_EOF
 
-freebsd* | dragonfly*)
-  # DragonFly does not have aout.  When/if they implement a new
-  # versioning mechanism, adjust this.
-  if test -x /usr/bin/objformat; then
-    objformat=`/usr/bin/objformat`
-  else
-    case $host_os in
-    freebsd[23].*) objformat=aout ;;
-    *) objformat=elf ;;
-    esac
-  fi
-  version_type=freebsd-$objformat
-  case $version_type in
-    freebsd-elf*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-      need_version=no
-      need_lib_prefix=no
-      ;;
-    freebsd-*)
-      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
-      need_version=yes
-      ;;
-  esac
-  shlibpath_var=LD_LIBRARY_PATH
   case $host_os in
-  freebsd2.*)
-    shlibpath_overrides_runpath=yes
-    ;;
-  freebsd3.[01]* | freebsdelf3.[01]*)
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
-    ;;
-  freebsd3.[2-9]* | freebsdelf3.[2-9]* | \
-  freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)
-    shlibpath_overrides_runpath=no
-    hardcode_into_libs=yes
-    ;;
-  *) # from 4.6 on, and DragonFly
-    shlibpath_overrides_runpath=yes
-    hardcode_into_libs=yes
+  aix3*)
+    cat <<\_LT_EOF >> "$cfgfile"
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+_LT_EOF
     ;;
   esac
-  ;;
 
-gnu*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
 
-haiku*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  dynamic_linker="$host_os runtime_loader"
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'
-  hardcode_into_libs=yes
-  ;;
+ltmain="$ac_aux_dir/ltmain.sh"
 
-hpux9* | hpux10* | hpux11*)
-  # Give a soname corresponding to the major version so that dld.sl refuses to
-  # link against other versions.
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  case $host_cpu in
-  ia64*)
-    shrext_cmds='.so'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.so"
-    shlibpath_var=LD_LIBRARY_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    if test "X$HPUX_IA64_MODE" = X32; then
-      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
-    else
-      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
-    fi
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  hppa*64*)
-    shrext_cmds='.sl'
-    hardcode_into_libs=yes
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
-    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
-    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
-    ;;
-  *)
-    shrext_cmds='.sl'
-    dynamic_linker="$host_os dld.sl"
-    shlibpath_var=SHLIB_PATH
-    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    ;;
-  esac
-  # HP-UX runs *really* slowly unless shared libraries are mode 555, ...
-  postinstall_cmds='chmod 555 $lib'
-  # or fails outright, so override atomically:
-  install_override_mode=555
-  ;;
 
-interix[3-9]*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '$q' "$ltmain" >> "$cfgfile" \
+     || (rm -f "$cfgfile"; exit 1)
 
-irix5* | irix6* | nonstopux*)
-  case $host_os in
-    nonstopux*) version_type=nonstopux ;;
-    *)
-	if test "$lt_cv_prog_gnu_ld" = yes; then
-		version_type=linux # correct to gnu/linux during the next big refactor
-	else
-		version_type=irix
-	fi ;;
-  esac
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
-  case $host_os in
-  irix5* | nonstopux*)
-    libsuff= shlibsuff=
-    ;;
-  *)
-    case $LD in # libtool.m4 will add one of these switches to LD
-    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
-      libsuff= shlibsuff= libmagic=32-bit;;
-    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
-      libsuff=32 shlibsuff=N32 libmagic=N32;;
-    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
-      libsuff=64 shlibsuff=64 libmagic=64-bit;;
-    *) libsuff= shlibsuff= libmagic=never-match;;
-    esac
-    ;;
-  esac
-  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
-  shlibpath_overrides_runpath=no
-  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
-  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
-  hardcode_into_libs=yes
-  ;;
+  if test x"$xsi_shell" = xyes; then
+  sed -e '/^func_dirname ()$/,/^} # func_dirname /c\
+func_dirname ()\
+{\
+\    case ${1} in\
+\      */*) func_dirname_result="${1%/*}${2}" ;;\
+\      *  ) func_dirname_result="${3}" ;;\
+\    esac\
+} # Extended-shell func_dirname implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_basename ()$/,/^} # func_basename /c\
+func_basename ()\
+{\
+\    func_basename_result="${1##*/}"\
+} # Extended-shell func_basename implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_dirname_and_basename ()$/,/^} # func_dirname_and_basename /c\
+func_dirname_and_basename ()\
+{\
+\    case ${1} in\
+\      */*) func_dirname_result="${1%/*}${2}" ;;\
+\      *  ) func_dirname_result="${3}" ;;\
+\    esac\
+\    func_basename_result="${1##*/}"\
+} # Extended-shell func_dirname_and_basename implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_stripname ()$/,/^} # func_stripname /c\
+func_stripname ()\
+{\
+\    # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are\
+\    # positional parameters, so assign one to ordinary parameter first.\
+\    func_stripname_result=${3}\
+\    func_stripname_result=${func_stripname_result#"${1}"}\
+\    func_stripname_result=${func_stripname_result%"${2}"}\
+} # Extended-shell func_stripname implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_split_long_opt ()$/,/^} # func_split_long_opt /c\
+func_split_long_opt ()\
+{\
+\    func_split_long_opt_name=${1%%=*}\
+\    func_split_long_opt_arg=${1#*=}\
+} # Extended-shell func_split_long_opt implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_split_short_opt ()$/,/^} # func_split_short_opt /c\
+func_split_short_opt ()\
+{\
+\    func_split_short_opt_arg=${1#??}\
+\    func_split_short_opt_name=${1%"$func_split_short_opt_arg"}\
+} # Extended-shell func_split_short_opt implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
 
-# No shared lib support for Linux oldld, aout, or coff.
-linux*oldld* | linux*aout* | linux*coff*)
-  dynamic_linker=no
-  ;;
 
-# This must be glibc/ELF.
-linux* | k*bsd*-gnu | kopensolaris*-gnu)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
+  sed -e '/^func_lo2o ()$/,/^} # func_lo2o /c\
+func_lo2o ()\
+{\
+\    case ${1} in\
+\      *.lo) func_lo2o_result=${1%.lo}.${objext} ;;\
+\      *)    func_lo2o_result=${1} ;;\
+\    esac\
+} # Extended-shell func_lo2o implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
 
-  # Some binutils ld are patched to set DT_RUNPATH
-  if ${lt_cv_shlibpath_overrides_runpath+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  lt_cv_shlibpath_overrides_runpath=no
-    save_LDFLAGS=$LDFLAGS
-    save_libdir=$libdir
-    eval "libdir=/foo; wl=\"$lt_prog_compiler_wl_CXX\"; \
-	 LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec_CXX\""
-    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
 
-int
-main ()
-{
+  sed -e '/^func_xform ()$/,/^} # func_xform /c\
+func_xform ()\
+{\
+    func_xform_result=${1%.*}.lo\
+} # Extended-shell func_xform implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_arith ()$/,/^} # func_arith /c\
+func_arith ()\
+{\
+    func_arith_result=$(( $* ))\
+} # Extended-shell func_arith implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_len ()$/,/^} # func_len /c\
+func_len ()\
+{\
+    func_len_result=${#1}\
+} # Extended-shell func_len implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
 
-  ;
-  return 0;
-}
-_ACEOF
-if ac_fn_cxx_try_link "$LINENO"; then :
-  if  ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null; then :
-  lt_cv_shlibpath_overrides_runpath=yes
 fi
+
+if test x"$lt_shell_append" = xyes; then
+  sed -e '/^func_append ()$/,/^} # func_append /c\
+func_append ()\
+{\
+    eval "${1}+=\\${2}"\
+} # Extended-shell func_append implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  sed -e '/^func_append_quoted ()$/,/^} # func_append_quoted /c\
+func_append_quoted ()\
+{\
+\    func_quote_for_eval "${2}"\
+\    eval "${1}+=\\\\ \\$func_quote_for_eval_result"\
+} # Extended-shell func_append_quoted implementation' "$cfgfile" > $cfgfile.tmp \
+  && mv -f "$cfgfile.tmp" "$cfgfile" \
+    || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+test 0 -eq $? || _lt_function_replace_fail=:
+
+
+  # Save a `func_append' function call where possible by direct use of '+='
+  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1+="%g' $cfgfile > $cfgfile.tmp \
+    && mv -f "$cfgfile.tmp" "$cfgfile" \
+      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+  test 0 -eq $? || _lt_function_replace_fail=:
+else
+  # Save a `func_append' function call even when '+=' is not available
+  sed -e 's%func_append \([a-zA-Z_]\{1,\}\) "%\1="$\1%g' $cfgfile > $cfgfile.tmp \
+    && mv -f "$cfgfile.tmp" "$cfgfile" \
+      || (rm -f "$cfgfile" && cp "$cfgfile.tmp" "$cfgfile" && rm -f "$cfgfile.tmp")
+  test 0 -eq $? || _lt_function_replace_fail=:
 fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext conftest.$ac_ext
-    LDFLAGS=$save_LDFLAGS
-    libdir=$save_libdir
 
+if test x"$_lt_function_replace_fail" = x":"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Unable to substitute extended shell functions in $ofile" >&5
+$as_echo "$as_me: WARNING: Unable to substitute extended shell functions in $ofile" >&2;}
 fi
 
-  shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath
 
-  # This implies no fast_install, which is unacceptable.
-  # Some rework will be needed to allow for fast_install
-  # before this can be enabled.
-  hardcode_into_libs=yes
+   mv -f "$cfgfile" "$ofile" ||
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
 
-  # Append ld.so.conf contents to the search path
-  if test -f /etc/ld.so.conf; then
-    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[	 ]*hwcap[	 ]/d;s/[:,	]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`
-    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
-  fi
 
-  # We used to test for /lib/ld.so.1 and disable shared libraries on
-  # powerpc, because MkLinux only supported shared libraries with the
-  # GNU dynamic linker.  Since this was broken with cross compilers,
-  # most powerpc-linux boxes support dynamic linking these days and
-  # people can always --disable-shared, the test was removed, and we
-  # assume the GNU/Linux dynamic linker is in use.
-  dynamic_linker='GNU/Linux ld.so'
-  ;;
+    cat <<_LT_EOF >> "$ofile"
 
-netbsd*)
-  version_type=sunos
-  need_lib_prefix=no
-  need_version=no
-  if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-    dynamic_linker='NetBSD (a.out) ld.so'
-  else
-    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
-    soname_spec='${libname}${release}${shared_ext}$major'
-    dynamic_linker='NetBSD ld.elf_so'
-  fi
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  ;;
+# ### BEGIN LIBTOOL TAG CONFIG: CXX
 
-newsos6)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  ;;
+# The linker used to build libraries.
+LD=$lt_LD_CXX
 
-*nto* | *qnx*)
-  version_type=qnx
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  dynamic_linker='ldqnx.so'
-  ;;
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag_CXX
+reload_cmds=$lt_reload_cmds_CXX
 
-openbsd*)
-  version_type=sunos
-  sys_lib_dlsearch_path_spec="/usr/lib"
-  need_lib_prefix=no
-  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
-  case $host_os in
-    openbsd3.3 | openbsd3.3.*)	need_version=yes ;;
-    *)				need_version=no  ;;
-  esac
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
-    case $host_os in
-      openbsd2.[89] | openbsd2.[89].*)
-	shlibpath_overrides_runpath=no
-	;;
-      *)
-	shlibpath_overrides_runpath=yes
-	;;
-      esac
-  else
-    shlibpath_overrides_runpath=yes
-  fi
-  ;;
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds_CXX
 
-os2*)
-  libname_spec='$name'
-  shrext_cmds=".dll"
-  need_lib_prefix=no
-  library_names_spec='$libname${shared_ext} $libname.a'
-  dynamic_linker='OS/2 ld.exe'
-  shlibpath_var=LIBPATH
-  ;;
+# A language specific compiler.
+CC=$lt_compiler_CXX
 
-osf3* | osf4* | osf5*)
-  version_type=osf
-  need_lib_prefix=no
-  need_version=no
-  soname_spec='${libname}${release}${shared_ext}$major'
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
-  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
-  ;;
+# Is the compiler the GNU compiler?
+with_gcc=$GCC_CXX
 
-rdos*)
-  dynamic_linker=no
-  ;;
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
 
-solaris*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  # ldd complains unless libraries are executable
-  postinstall_cmds='chmod +x $lib'
-  ;;
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_CXX
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_CXX
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_CXX
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_CXX
 
-sunos4*)
-  version_type=sunos
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
-  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  if test "$with_gnu_ld" = yes; then
-    need_lib_prefix=no
-  fi
-  need_version=yes
-  ;;
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
 
-sysv4 | sysv4.3*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  case $host_vendor in
-    sni)
-      shlibpath_overrides_runpath=no
-      need_lib_prefix=no
-      runpath_var=LD_RUN_PATH
-      ;;
-    siemens)
-      need_lib_prefix=no
-      ;;
-    motorola)
-      need_lib_prefix=no
-      need_version=no
-      shlibpath_overrides_runpath=no
-      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
-      ;;
-  esac
-  ;;
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
 
-sysv4*MP*)
-  if test -d /usr/nec ;then
-    version_type=linux # correct to gnu/linux during the next big refactor
-    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
-    soname_spec='$libname${shared_ext}.$major'
-    shlibpath_var=LD_LIBRARY_PATH
-  fi
-  ;;
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
 
-sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
-  version_type=freebsd-elf
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=yes
-  hardcode_into_libs=yes
-  if test "$with_gnu_ld" = yes; then
-    sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'
-  else
-    sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'
-    case $host_os in
-      sco3.2v5*)
-        sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"
-	;;
-    esac
-  fi
-  sys_lib_dlsearch_path_spec='/usr/lib'
-  ;;
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object_CXX
 
-tpf*)
-  # TPF is a cross-target only.  Preferred cross-host = GNU/Linux.
-  version_type=linux # correct to gnu/linux during the next big refactor
-  need_lib_prefix=no
-  need_version=no
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  shlibpath_var=LD_LIBRARY_PATH
-  shlibpath_overrides_runpath=no
-  hardcode_into_libs=yes
-  ;;
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
 
-uts4*)
-  version_type=linux # correct to gnu/linux during the next big refactor
-  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
-  soname_spec='${libname}${release}${shared_ext}$major'
-  shlibpath_var=LD_LIBRARY_PATH
-  ;;
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
 
-*)
-  dynamic_linker=no
-  ;;
-esac
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
-$as_echo "$dynamic_linker" >&6; }
-test "$dynamic_linker" = no && can_build_shared=no
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds_CXX
+archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
 
-variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
-if test "$GCC" = yes; then
-  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
-fi
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds_CXX
+module_expsym_cmds=$lt_module_expsym_cmds_CXX
 
-if test "${lt_cv_sys_lib_search_path_spec+set}" = set; then
-  sys_lib_search_path_spec="$lt_cv_sys_lib_search_path_spec"
-fi
-if test "${lt_cv_sys_lib_dlsearch_path_spec+set}" = set; then
-  sys_lib_dlsearch_path_spec="$lt_cv_sys_lib_dlsearch_path_spec"
-fi
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld_CXX
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_CXX
 
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_CXX
 
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
 
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
 
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct_CXX
 
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute_CXX
 
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L_CXX
 
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
 
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic_CXX
 
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath_CXX
 
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_CXX
 
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols_CXX
 
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_CXX
 
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_CXX
 
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_CXX
 
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds_CXX
 
+# Commands necessary for finishing linking programs.
+postlink_cmds=$lt_postlink_cmds_CXX
 
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec_CXX
 
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_CXX
 
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX
 
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects_CXX
+postdep_objects=$lt_postdep_objects_CXX
+predeps=$lt_predeps_CXX
+postdeps=$lt_postdeps_CXX
 
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
 
+# ### END LIBTOOL TAG CONFIG: CXX
+_LT_EOF
 
 
+    cat <<_LT_EOF >> "$ofile"
 
+# ### BEGIN LIBTOOL TAG CONFIG: F77
 
+# The linker used to build libraries.
+LD=$lt_LD_F77
 
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag_F77
+reload_cmds=$lt_reload_cmds_F77
 
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds_F77
 
+# A language specific compiler.
+CC=$lt_compiler_F77
 
+# Is the compiler the GNU compiler?
+with_gcc=$GCC_F77
 
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_F77
 
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_F77
 
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_F77
 
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_F77
 
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_F77
 
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_F77
 
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_F77
 
-    { $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
-$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
-hardcode_action_CXX=
-if test -n "$hardcode_libdir_flag_spec_CXX" ||
-   test -n "$runpath_var_CXX" ||
-   test "X$hardcode_automatic_CXX" = "Xyes" ; then
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_F77
 
-  # We can hardcode non-existent directories.
-  if test "$hardcode_direct_CXX" != no &&
-     # If the only mechanism to avoid hardcoding is shlibpath_var, we
-     # have to relink, otherwise we might link with an installed library
-     # when we should be linking with a yet-to-be-installed one
-     ## test "$_LT_TAGVAR(hardcode_shlibpath_var, CXX)" != no &&
-     test "$hardcode_minus_L_CXX" != no; then
-    # Linking always hardcodes the temporary library directory.
-    hardcode_action_CXX=relink
-  else
-    # We can link without hardcoding, and we can hardcode nonexisting dirs.
-    hardcode_action_CXX=immediate
-  fi
-else
-  # We cannot hardcode anything, or else we can only hardcode existing
-  # directories.
-  hardcode_action_CXX=unsupported
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_CXX" >&5
-$as_echo "$hardcode_action_CXX" >&6; }
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_F77
 
-if test "$hardcode_action_CXX" = relink ||
-   test "$inherit_rpath_CXX" = yes; then
-  # Fast installation is not supported
-  enable_fast_install=no
-elif test "$shlibpath_overrides_runpath" = yes ||
-     test "$enable_shared" = no; then
-  # Fast installation is not necessary
-  enable_fast_install=needless
-fi
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object_F77
 
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_F77
 
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_F77
 
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds_F77
+archive_expsym_cmds=$lt_archive_expsym_cmds_F77
 
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds_F77
+module_expsym_cmds=$lt_module_expsym_cmds_F77
 
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld_F77
 
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_F77
 
-  fi # test -n "$compiler"
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_F77
 
-  CC=$lt_save_CC
-  CFLAGS=$lt_save_CFLAGS
-  LDCXX=$LD
-  LD=$lt_save_LD
-  GCC=$lt_save_GCC
-  with_gnu_ld=$lt_save_with_gnu_ld
-  lt_cv_path_LDCXX=$lt_cv_path_LD
-  lt_cv_path_LD=$lt_save_path_LD
-  lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
-  lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
-fi # test "$_lt_caught_CXX_error" != yes
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_F77
 
-ac_ext=c
-ac_cpp='$CPP $CPPFLAGS'
-ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
-ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
-ac_compiler_gnu=$ac_cv_c_compiler_gnu
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_F77
 
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct_F77
 
-# Extract the first word of "sed", so it can be a program name with args.
-set dummy sed; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_SED+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$SED"; then
-  ac_cv_prog_SED="$SED" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_SED="sed"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute_F77
 
-  test -z "$ac_cv_prog_SED" && ac_cv_prog_SED="false"
-fi
-fi
-SED=$ac_cv_prog_SED
-if test -n "$SED"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $SED" >&5
-$as_echo "$SED" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L_F77
 
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_F77
 
-# Extract the first word of "grep", so it can be a program name with args.
-set dummy grep; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_GREP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$GREP"; then
-  ac_cv_prog_GREP="$GREP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_GREP="grep"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic_F77
 
-  test -z "$ac_cv_prog_GREP" && ac_cv_prog_GREP="false"
-fi
-fi
-GREP=$ac_cv_prog_GREP
-if test -n "$GREP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $GREP" >&5
-$as_echo "$GREP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath_F77
 
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_F77
 
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols_F77
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ar; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_AR+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$AR"; then
-  ac_cv_prog_AR="$AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_AR="${ac_tool_prefix}ar"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_F77
 
-fi
-fi
-AR=$ac_cv_prog_AR
-if test -n "$AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
-$as_echo "$AR" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_F77
 
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_F77
 
-fi
-if test -z "$ac_cv_prog_AR"; then
-  ac_ct_AR=$AR
-  # Extract the first word of "ar", so it can be a program name with args.
-set dummy ar; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_AR+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_AR"; then
-  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_AR="ar"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds_F77
 
-fi
-fi
-ac_ct_AR=$ac_cv_prog_ac_ct_AR
-if test -n "$ac_ct_AR"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
-$as_echo "$ac_ct_AR" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Commands necessary for finishing linking programs.
+postlink_cmds=$lt_postlink_cmds_F77
 
-  if test "x$ac_ct_AR" = x; then
-    AR=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    AR=$ac_ct_AR
-  fi
-else
-  AR="$ac_cv_prog_AR"
-fi
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec_F77
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}cpp", so it can be a program name with args.
-set dummy ${ac_tool_prefix}cpp; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_CPP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$CPP"; then
-  ac_cv_prog_CPP="$CPP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_CPP="${ac_tool_prefix}cpp"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_F77
 
-fi
-fi
-CPP=$ac_cv_prog_CPP
-if test -n "$CPP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
-$as_echo "$CPP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_F77
 
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects_F77
+postdep_objects=$lt_postdep_objects_F77
+predeps=$lt_predeps_F77
+postdeps=$lt_postdeps_F77
 
-fi
-if test -z "$ac_cv_prog_CPP"; then
-  ac_ct_CPP=$CPP
-  # Extract the first word of "cpp", so it can be a program name with args.
-set dummy cpp; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_CPP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_CPP"; then
-  ac_cv_prog_ac_ct_CPP="$ac_ct_CPP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_CPP="cpp"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_F77
 
-fi
-fi
-ac_ct_CPP=$ac_cv_prog_ac_ct_CPP
-if test -n "$ac_ct_CPP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CPP" >&5
-$as_echo "$ac_ct_CPP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# ### END LIBTOOL TAG CONFIG: F77
+_LT_EOF
 
-  if test "x$ac_ct_CPP" = x; then
-    CPP=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    CPP=$ac_ct_CPP
-  fi
-else
-  CPP="$ac_cv_prog_CPP"
-fi
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ld", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ld; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_LD+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$LD"; then
-  ac_cv_prog_LD="$LD" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_LD="${ac_tool_prefix}ld"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+    cat <<_LT_EOF >> "$ofile"
 
-fi
-fi
-LD=$ac_cv_prog_LD
-if test -n "$LD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
-$as_echo "$LD" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# ### BEGIN LIBTOOL TAG CONFIG: FC
 
+# The linker used to build libraries.
+LD=$lt_LD_FC
 
-fi
-if test -z "$ac_cv_prog_LD"; then
-  ac_ct_LD=$LD
-  # Extract the first word of "ld", so it can be a program name with args.
-set dummy ld; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_LD+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_LD"; then
-  ac_cv_prog_ac_ct_LD="$ac_ct_LD" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_LD="ld"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag_FC
+reload_cmds=$lt_reload_cmds_FC
 
-fi
-fi
-ac_ct_LD=$ac_cv_prog_ac_ct_LD
-if test -n "$ac_ct_LD"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LD" >&5
-$as_echo "$ac_ct_LD" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Commands used to build an old-style archive.
+old_archive_cmds=$lt_old_archive_cmds_FC
 
-  if test "x$ac_ct_LD" = x; then
-    LD=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    LD=$ac_ct_LD
-  fi
-else
-  LD="$ac_cv_prog_LD"
-fi
+# A language specific compiler.
+CC=$lt_compiler_FC
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}nm", so it can be a program name with args.
-set dummy ${ac_tool_prefix}nm; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_NM+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$NM"; then
-  ac_cv_prog_NM="$NM" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_NM="${ac_tool_prefix}nm"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# Is the compiler the GNU compiler?
+with_gcc=$GCC_FC
 
-fi
-fi
-NM=$ac_cv_prog_NM
-if test -n "$NM"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NM" >&5
-$as_echo "$NM" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_FC
 
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_FC
 
-fi
-if test -z "$ac_cv_prog_NM"; then
-  ac_ct_NM=$NM
-  # Extract the first word of "nm", so it can be a program name with args.
-set dummy nm; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_NM+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_NM"; then
-  ac_cv_prog_ac_ct_NM="$ac_ct_NM" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_NM="nm"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_FC
 
-fi
-fi
-ac_ct_NM=$ac_cv_prog_ac_ct_NM
-if test -n "$ac_ct_NM"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NM" >&5
-$as_echo "$ac_ct_NM" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_FC
 
-  if test "x$ac_ct_NM" = x; then
-    NM=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    NM=$ac_ct_NM
-  fi
-else
-  NM="$ac_cv_prog_NM"
-fi
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_FC
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.
-set dummy ${ac_tool_prefix}as; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_AS+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$AS"; then
-  ac_cv_prog_AS="$AS" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_AS="${ac_tool_prefix}as"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_FC
 
-fi
-fi
-AS=$ac_cv_prog_AS
-if test -n "$AS"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AS" >&5
-$as_echo "$AS" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Whether or not to disallow shared libs when runtime libs are static.
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_FC
 
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_FC
 
-fi
-if test -z "$ac_cv_prog_AS"; then
-  ac_ct_AS=$AS
-  # Extract the first word of "as", so it can be a program name with args.
-set dummy as; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_AS+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_AS"; then
-  ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_AS="as"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_FC
 
-fi
-fi
-ac_ct_AS=$ac_cv_prog_ac_ct_AS
-if test -n "$ac_ct_AS"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5
-$as_echo "$ac_ct_AS" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Whether the compiler copes with passing no objects directly.
+compiler_needs_object=$lt_compiler_needs_object_FC
 
-  if test "x$ac_ct_AS" = x; then
-    AS=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    AS=$ac_ct_AS
-  fi
-else
-  AS="$ac_cv_prog_AS"
-fi
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_FC
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.
-set dummy ${ac_tool_prefix}dlltool; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_DLLTOOL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$DLLTOOL"; then
-  ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_FC
 
-fi
-fi
-DLLTOOL=$ac_cv_prog_DLLTOOL
-if test -n "$DLLTOOL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5
-$as_echo "$DLLTOOL" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Commands used to build a shared archive.
+archive_cmds=$lt_archive_cmds_FC
+archive_expsym_cmds=$lt_archive_expsym_cmds_FC
 
+# Commands used to build a loadable module if different from building
+# a shared archive.
+module_cmds=$lt_module_cmds_FC
+module_expsym_cmds=$lt_module_expsym_cmds_FC
 
-fi
-if test -z "$ac_cv_prog_DLLTOOL"; then
-  ac_ct_DLLTOOL=$DLLTOOL
-  # Extract the first word of "dlltool", so it can be a program name with args.
-set dummy dlltool; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_DLLTOOL+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_DLLTOOL"; then
-  ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_DLLTOOL="dlltool"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# Whether we are building with GNU ld or not.
+with_gnu_ld=$lt_with_gnu_ld_FC
 
-fi
-fi
-ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL
-if test -n "$ac_ct_DLLTOOL"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5
-$as_echo "$ac_ct_DLLTOOL" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_FC
 
-  if test "x$ac_ct_DLLTOOL" = x; then
-    DLLTOOL=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    DLLTOOL=$ac_ct_DLLTOOL
-  fi
-else
-  DLLTOOL="$ac_cv_prog_DLLTOOL"
-fi
+# Flag that enforces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_FC
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.
-set dummy ${ac_tool_prefix}objdump; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_OBJDUMP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$OBJDUMP"; then
-  ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_FC
 
-fi
-fi
-OBJDUMP=$ac_cv_prog_OBJDUMP
-if test -n "$OBJDUMP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5
-$as_echo "$OBJDUMP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Whether we need a single "-rpath" flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_FC
 
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary.
+hardcode_direct=$hardcode_direct_FC
 
-fi
-if test -z "$ac_cv_prog_OBJDUMP"; then
-  ac_ct_OBJDUMP=$OBJDUMP
-  # Extract the first word of "objdump", so it can be a program name with args.
-set dummy objdump; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_OBJDUMP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_OBJDUMP"; then
-  ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_OBJDUMP="objdump"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
+# DIR into the resulting binary and the resulting library dependency is
+# "absolute",i.e impossible to change by setting \${shlibpath_var} if the
+# library is relocated.
+hardcode_direct_absolute=$hardcode_direct_absolute_FC
 
-fi
-fi
-ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP
-if test -n "$ac_ct_OBJDUMP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5
-$as_echo "$ac_ct_OBJDUMP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Set to "yes" if using the -LDIR flag during linking hardcodes DIR
+# into the resulting binary.
+hardcode_minus_L=$hardcode_minus_L_FC
 
-  if test "x$ac_ct_OBJDUMP" = x; then
-    OBJDUMP=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    OBJDUMP=$ac_ct_OBJDUMP
-  fi
-else
-  OBJDUMP="$ac_cv_prog_OBJDUMP"
-fi
+# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
+# into the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_FC
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
-set dummy ${ac_tool_prefix}strip; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_STRIP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$STRIP"; then
-  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# Set to "yes" if building a shared library automatically hardcodes DIR
+# into the library and all subsequent libraries and executables linked
+# against it.
+hardcode_automatic=$hardcode_automatic_FC
 
-fi
-fi
-STRIP=$ac_cv_prog_STRIP
-if test -n "$STRIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
-$as_echo "$STRIP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Set to yes if linker adds runtime paths of dependent libraries
+# to runtime path list.
+inherit_rpath=$inherit_rpath_FC
 
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_FC
 
-fi
-if test -z "$ac_cv_prog_STRIP"; then
-  ac_ct_STRIP=$STRIP
-  # Extract the first word of "strip", so it can be a program name with args.
-set dummy strip; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_STRIP+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_STRIP"; then
-  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_STRIP="strip"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# Set to "yes" if exported symbols are required.
+always_export_symbols=$always_export_symbols_FC
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_FC
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_FC
 
-fi
-fi
-ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
-if test -n "$ac_ct_STRIP"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
-$as_echo "$ac_ct_STRIP" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_FC
 
-  if test "x$ac_ct_STRIP" = x; then
-    STRIP=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    STRIP=$ac_ct_STRIP
-  fi
-else
-  STRIP="$ac_cv_prog_STRIP"
-fi
+# Commands necessary for linking programs (against libraries) with templates.
+prelink_cmds=$lt_prelink_cmds_FC
 
-if test -n "$ac_tool_prefix"; then
-  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
-set dummy ${ac_tool_prefix}ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_RANLIB+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$RANLIB"; then
-  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# Commands necessary for finishing linking programs.
+postlink_cmds=$lt_postlink_cmds_FC
 
-fi
-fi
-RANLIB=$ac_cv_prog_RANLIB
-if test -n "$RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
-$as_echo "$RANLIB" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Specify filename containing input files.
+file_list_spec=$lt_file_list_spec_FC
 
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_FC
 
-fi
-if test -z "$ac_cv_prog_RANLIB"; then
-  ac_ct_RANLIB=$RANLIB
-  # Extract the first word of "ranlib", so it can be a program name with args.
-set dummy ranlib; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_ac_ct_RANLIB+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$ac_ct_RANLIB"; then
-  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_ac_ct_RANLIB="ranlib"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
+# The directories searched by this compiler when creating a shared library.
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_FC
 
-fi
-fi
-ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
-if test -n "$ac_ct_RANLIB"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
-$as_echo "$ac_ct_RANLIB" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
+# Dependencies to place before and after the objects being linked to
+# create a shared library.
+predep_objects=$lt_predep_objects_FC
+postdep_objects=$lt_postdep_objects_FC
+predeps=$lt_predeps_FC
+postdeps=$lt_postdeps_FC
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_FC
+
+# ### END LIBTOOL TAG CONFIG: FC
+_LT_EOF
+
+
+as_fn_exit 0
+_LTEOF
+chmod +x "$CONFIG_LT"
+
+# configure is writing to config.log, but config.lt does its own redirection,
+# appending to config.log, which fails on DOS, as config.log is still kept
+# open by configure.  Here we exec the FD to /dev/null, effectively closing
+# config.log, so it can be properly (re)opened and appended to by config.lt.
+lt_cl_success=:
+test "$silent" = yes &&
+  lt_config_lt_args="$lt_config_lt_args --quiet"
+exec 5>/dev/null
+$SHELL "$CONFIG_LT" $lt_config_lt_args || lt_cl_success=false
+exec 5>>config.log
+$lt_cl_success || as_fn_exit 1
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
 
-  if test "x$ac_ct_RANLIB" = x; then
-    RANLIB=":"
-  else
-    case $cross_compiling:$ac_tool_warned in
-yes:)
-{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
-$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
-ac_tool_warned=yes ;;
-esac
-    RANLIB=$ac_ct_RANLIB
-  fi
-else
-  RANLIB="$ac_cv_prog_RANLIB"
-fi
 
 # -----------------------------------------------------------------------
 # Check endianess of system
@@ -24443,6 +25857,7 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
 
 	 for ax_cv_proto_backtrace_type in size_t int none; do
 	   if test "${ax_cv_proto_backtrace_type}" = none; then :
@@ -24474,6 +25889,7 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
 
 fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ax_cv_proto_backtrace_type" >&5
@@ -24816,6 +26232,7 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
 
 ax_pthread_ok=no
 
@@ -25249,6 +26666,7 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
 
 
                LIBS="$PTHREAD_LIBS $LIBS"
@@ -27270,6 +28688,17 @@ else
   ENABLE_NETCDF_FALSE=
 fi
 
+for ac_func in grib_get_length
+do :
+  ac_fn_c_check_func "$LINENO" "grib_get_length" "ac_cv_func_grib_get_length"
+if test "x$ac_cv_func_grib_get_length" = xyes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_GRIB_GET_LENGTH 1
+_ACEOF
+
+fi
+done
+
 #  ----------------------------------------------------------------------
 # Compile with MPI support
 # Sed expression to map a string onto a valid argument string part.
@@ -27283,6 +28712,7 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
 
 
 
@@ -27494,12 +28924,14 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
 
      if test -n "$FC" && test "X$FC" != "Xno"; then :
   ac_ext=${ac_fc_srcext-f}
 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+ac_link="./libtool --mode=link --tag=FC $ac_link"
 
 
 
@@ -27763,6 +29195,7 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
 
 fi
 else
@@ -28007,6 +29440,98 @@ fi
   { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: MPI launch command unavailable" >&5
 $as_echo "$as_me: WARNING: MPI launch command unavailable" >&2;}
 fi
+   ac_fn_c_check_decl "$LINENO" "_SC_LARGE_PAGESIZE" "ac_cv_have_decl__SC_LARGE_PAGESIZE" "$ac_includes_default
+#include <limits.h>
+#include <unistd.h>
+"
+if test "x$ac_cv_have_decl__SC_LARGE_PAGESIZE" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL__SC_LARGE_PAGESIZE $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "PAGESIZE" "ac_cv_have_decl_PAGESIZE" "$ac_includes_default
+#include <limits.h>
+#include <unistd.h>
+"
+if test "x$ac_cv_have_decl_PAGESIZE" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_PAGESIZE $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "PAGE_SIZE" "ac_cv_have_decl_PAGE_SIZE" "$ac_includes_default
+#include <limits.h>
+#include <unistd.h>
+"
+if test "x$ac_cv_have_decl_PAGE_SIZE" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_PAGE_SIZE $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "_SC_PAGE_SIZE" "ac_cv_have_decl__SC_PAGE_SIZE" "$ac_includes_default
+#include <limits.h>
+#include <unistd.h>
+"
+if test "x$ac_cv_have_decl__SC_PAGE_SIZE" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL__SC_PAGE_SIZE $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "_SC_PAGESIZE" "ac_cv_have_decl__SC_PAGESIZE" "$ac_includes_default
+#include <limits.h>
+#include <unistd.h>
+"
+if test "x$ac_cv_have_decl__SC_PAGESIZE" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL__SC_PAGESIZE $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "_PC_REC_XFER_ALIGN" "ac_cv_have_decl__PC_REC_XFER_ALIGN" "$ac_includes_default
+#include <limits.h>
+#include <unistd.h>
+"
+if test "x$ac_cv_have_decl__PC_REC_XFER_ALIGN" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL__PC_REC_XFER_ALIGN $ac_have_decl
+_ACEOF
+ac_fn_c_check_decl "$LINENO" "POSIX_REC_XFER_ALIGN" "ac_cv_have_decl_POSIX_REC_XFER_ALIGN" "$ac_includes_default
+#include <limits.h>
+#include <unistd.h>
+"
+if test "x$ac_cv_have_decl_POSIX_REC_XFER_ALIGN" = xyes; then :
+  ac_have_decl=1
+else
+  ac_have_decl=0
+fi
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_DECL_POSIX_REC_XFER_ALIGN $ac_have_decl
+_ACEOF
+
 
 
 pkg_failed=no
@@ -28220,19 +29745,67 @@ else
   USE_MPI_FALSE=
 fi
 
- if test $enable_ppm = yes; then
-  USE_PPM_CORE_TRUE=
-  USE_PPM_CORE_FALSE='#'
+ if test $enable_ppm = yes; then
+  USE_PPM_CORE_TRUE=
+  USE_PPM_CORE_FALSE='#'
+else
+  USE_PPM_CORE_TRUE='#'
+  USE_PPM_CORE_FALSE=
+fi
+
+ if test $HAVE_PARALLEL_NC4 -gt 0; then
+  HAVE_PARALLEL_NC4_TRUE=
+  HAVE_PARALLEL_NC4_FALSE='#'
+else
+  HAVE_PARALLEL_NC4_TRUE='#'
+  HAVE_PARALLEL_NC4_FALSE=
+fi
+
+
+ENABLE_MPI=`test x"$enable_mpi" = xyes && echo true || echo false`
+
+#  ----------------------------------------------------------------------
+#  Create the Fortran Interface via iso_c_binding module (Fortran 2003 Standard)
+#
+# the test for ruby itself is unconditional because ruby is also used in
+# the Fortran 2003 ISO C generator
+# Extract the first word of "ruby", so it can be a program name with args.
+set dummy ruby; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if ${ac_cv_prog_RUBY+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$RUBY"; then
+  ac_cv_prog_RUBY="$RUBY" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_RUBY="ruby"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+RUBY=$ac_cv_prog_RUBY
+if test -n "$RUBY"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBY" >&5
+$as_echo "$RUBY" >&6; }
 else
-  USE_PPM_CORE_TRUE='#'
-  USE_PPM_CORE_FALSE=
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
 fi
 
 
-ENABLE_MPI=`test x"$enable_mpi" = xyes && echo true || echo false`
-
-#  ----------------------------------------------------------------------
-#  Create the Fortran Interface via iso_c_binding module (Fortran 2003 Standard)
 # Check whether --enable-iso-c-interface was given.
 if test "${enable_iso_c_interface+set}" = set; then :
   enableval=$enable_iso_c_interface; enable_isoc=${enableval}
@@ -28245,6 +29818,7 @@ if test x"$enable_isoc" = xyes; then :
 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+ac_link="./libtool --mode=link --tag=FC $ac_link"
 
    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if Fortran compiler can handle complex CHARACTER interoperability" >&5
 $as_echo_n "checking if Fortran compiler can handle complex CHARACTER interoperability... " >&6; }
@@ -28301,7 +29875,7 @@ $as_echo "yes" >&6; }
 else
   { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
 $as_echo "no" >&6; }
-
+enable_isoc=no
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
    ac_ext=c
@@ -28309,6 +29883,7 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
 
 else
   enable_isoc=no
@@ -28333,6 +29908,7 @@ if test "x${enable_isoc}" = "xyes"; then :
 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+ac_link="./libtool --mode=link --tag=FC $ac_link"
 
 
 
@@ -28393,6 +29969,7 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
 
    CDI_F90_INTERFACE_FCFLAGS="${FC_MOD_FLAG}${includedir}"
 fi
@@ -28407,6 +29984,7 @@ $as_echo_n "checking for suffix of module files... " >&6; }
 ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
 ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+ac_link="./libtool --mode=link --tag=FC $ac_link"
 
    cat > conftest.$ac_ext <<_ACEOF
       module conftest
@@ -28444,6 +30022,7 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
 
    case "$acx_fc_mod_name" in #(
        conftest.$FCMODEXT) :
@@ -28531,46 +30110,10 @@ fi
 
 #  ----------------------------------------------------------------------
 #  Create the Ruby Interface via swig
+#
 # Check whether --enable-ruby was given.
 if test "${enable_ruby+set}" = set; then :
-  enableval=$enable_ruby; # Extract the first word of "ruby", so it can be a program name with args.
-set dummy ruby; ac_word=$2
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
-$as_echo_n "checking for $ac_word... " >&6; }
-if ${ac_cv_prog_RUBY+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  if test -n "$RUBY"; then
-  ac_cv_prog_RUBY="$RUBY" # Let the user override the test.
-else
-as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
-for as_dir in $PATH
-do
-  IFS=$as_save_IFS
-  test -z "$as_dir" && as_dir=.
-    for ac_exec_ext in '' $ac_executable_extensions; do
-  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
-    ac_cv_prog_RUBY="ruby"
-    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
-    break 2
-  fi
-done
-  done
-IFS=$as_save_IFS
-
-fi
-fi
-RUBY=$ac_cv_prog_RUBY
-if test -n "$RUBY"; then
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RUBY" >&5
-$as_echo "$RUBY" >&6; }
-else
-  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
-$as_echo "no" >&6; }
-fi
-
-
-   RUBY_INCLUDES="$($RUBY $srcdir/config/interface.rb)"
+  enableval=$enable_ruby; RUBY_INCLUDES="$($RUBY $srcdir/config/interface.rb)"
    save_CPPFLAGS=$CPPFLAGS
    CPPFLAGS="$CPPFLAGS $RUBY_INCLUDES"
    ac_fn_c_check_header_mongrel "$LINENO" "ruby.h" "ac_cv_header_ruby_h" "$ac_includes_default"
@@ -28717,33 +30260,497 @@ else
 fi
 
 #  ----------------------------------------------------------------------
-#  Check C / Fortran interface
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C / Fortran interface works" >&5
-$as_echo_n "checking whether the C / Fortran interface works... " >&6; }
-if ${acx_cv_check_cfint+:} false; then :
+#  Create the CDI Fortran77 Interface via cfortran.h
+# Check whether --enable-cf-interface was given.
+if test "${enable_cf_interface+set}" = set; then :
+  enableval=$enable_cf_interface; enable_cfinterface=${enableval}
+else
+  enable_cfinterface=yes
+fi
+
+if test "x${enable_cfinterface}" = "xyes"; then :
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking C preprocessor flags for Fortran calling convention cfortran.h" >&5
+$as_echo_n "checking C preprocessor flags for Fortran calling convention cfortran.h... " >&6; }
+if ${acx_cv_cf_flag+:} false; then :
   $as_echo_n "(cached) " >&6
 else
-  ac_ext=c
+  acx_cv_cf_flag=''
+      for macro in pgiFortran NAGf90Fortran f2cFortran hpuxFortran apolloFortran sunFortran IBMR2Fortran CRAYFortran PATHSCALE_COMPILER gFortran mipsFortran DECFortran vmsFortran CONVEXFortran PowerStationFortran AbsoftUNIXFortran AbsoftProFortran SXFortran
+do :
+  acx_temp=`echo "$CPPFLAGS $CFLAGS" | sed -n 's/^\(.* \)*-D\('"$macro"'\)\( .*\)*$/\2/;t print
+b
+: print
+p'`
+         if test x"$acx_temp" != x; then :
+  if test x"$acx_cv_cf_flag" = x; then :
+  acx_cv_cf_flag="$acx_temp (user-specified)"
+else
+  echo ; echo '"'"$acx_cv_cf_flag $acx_temp"'"'
+               as_fn_error $? "Multiple specification of cfortran.h flags" "$LINENO" 5
+fi
+fi
+done
+      if test x"$acx_cv_cf_flag" = x; then :
+  if test -n "$FC" -a X"$FC" != Xno; then :
+  ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+ac_link="./libtool --mode=link --tag=FC $ac_link"
+
+
+
+
+   save_FC=$FC ; acx_FC=$FC
+   case $host in #(
+  x86_64-*-linux-*|i*86-*-linux-*|*-apple-darwin*|ia64-*-linux-*|x86_64-*-freebsd*|i*86-*-freebsd*) :
+    acx_temp=`$acx_FC -V 2>&1`
+      if echo "$acx_temp" | grep '^Copyright.*\(The Portland Group\|NVIDIA CORPORATION\)' >/dev/null; then :
+  acx_cv_fc_cf_flag=-DgFortran
+elif echo "$acx_temp" | grep '^NAG Fortran Compiler Release' >/dev/null; then :
+  acx_cv_fc_cf_flag=-DNAGf90Fortran
+elif echo "$acx_temp" | grep '^Intel(R) Fortran.*Compiler' >/dev/null; then :
+  acx_cv_fc_cf_flag=-DgFortran
+elif echo "$acx_temp" | grep '^Cray Fortran' >/dev/null; then :
+  acx_cv_fc_cf_flag=-DgFortran
+elif acx_temp=`$acx_FC --version 2>&1` \
+         && echo $acx_temp | grep '^GNU Fortran' >/dev/null; then :
+  if echo $acx_temp | grep g77 >/dev/null; then :
+  acx_cv_fc_cf_flag=-Dg77Fortran
+else
+              if echo "$FCFLAGS" | grep '^\(.* \)*-ff2c\( .*\)*$' >/dev/null; then :
+  acx_cv_fc_cf_flag=-Df2cFortran
+else
+  acx_cv_fc_cf_flag=-DgFortran
+fi
+fi
+elif acx_temp=`$acx_FC -v 2>&1` \
+         && echo $acx_temp | grep '^f2c'; then :
+  acx_cv_fc_cf_flag=-Df2cFortran
+fi ;; #(
+  *-ibm-aix*) :
+          if $CC -qversion 2>&1 | grep '^IBM XL C' >/dev/null; then :
+
+else
+           acx_cv_fc_cf_flag=-DIBMR2Fortran
+fi
+      ;; #(
+  *-*-hpux*) :
+    acx_cv_fc_cf_flag=-DhpuxFortran ;; #(
+  sx*-*-*|es*-*-*) :
+          acx_cv_fc_cf_flag=-DSXFortran ;; #(
+  *) :
+     ;;
+esac
+
+               ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
+
+fi
+         if test -n "$F77" -a X"$F77" != Xno; then :
+  ac_ext=f
+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_f77_compiler_gnu
+ac_link="./libtool --mode=link --tag=F77 $ac_link"
+
+
+
+
+   save_F77=$F77 ; acx_FC=$F77
+   case $host in #(
+  x86_64-*-linux-*|i*86-*-linux-*|*-apple-darwin*|ia64-*-linux-*|x86_64-*-freebsd*|i*86-*-freebsd*) :
+    acx_temp=`$acx_FC -V 2>&1`
+      if echo "$acx_temp" | grep '^Copyright.*\(The Portland Group\|NVIDIA CORPORATION\)' >/dev/null; then :
+  acx_cv_f77_cf_flag=-DgFortran
+elif echo "$acx_temp" | grep '^NAG Fortran Compiler Release' >/dev/null; then :
+  acx_cv_f77_cf_flag=-DNAGf90Fortran
+elif echo "$acx_temp" | grep '^Intel(R) Fortran.*Compiler' >/dev/null; then :
+  acx_cv_f77_cf_flag=-DgFortran
+elif echo "$acx_temp" | grep '^Cray Fortran' >/dev/null; then :
+  acx_cv_f77_cf_flag=-DgFortran
+elif acx_temp=`$acx_FC --version 2>&1` \
+         && echo $acx_temp | grep '^GNU Fortran' >/dev/null; then :
+  if echo $acx_temp | grep g77 >/dev/null; then :
+  acx_cv_f77_cf_flag=-Dg77Fortran
+else
+              if echo "$FFLAGS" | grep '^\(.* \)*-ff2c\( .*\)*$' >/dev/null; then :
+  acx_cv_f77_cf_flag=-Df2cFortran
+else
+  acx_cv_f77_cf_flag=-DgFortran
+fi
+fi
+elif acx_temp=`$acx_FC -v 2>&1` \
+         && echo $acx_temp | grep '^f2c'; then :
+  acx_cv_f77_cf_flag=-Df2cFortran
+fi ;; #(
+  *-ibm-aix*) :
+          if $CC -qversion 2>&1 | grep '^IBM XL C' >/dev/null; then :
+
+else
+           acx_cv_f77_cf_flag=-DIBMR2Fortran
+fi
+      ;; #(
+  *-*-hpux*) :
+    acx_cv_f77_cf_flag=-DhpuxFortran ;; #(
+  sx*-*-*|es*-*-*) :
+          acx_cv_f77_cf_flag=-DSXFortran ;; #(
+  *) :
+     ;;
+esac
+
+               ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
+
+fi
+                        if test -z "$F77" -o X"$F77" = Xno; then :
+  acx_cv_cf_flag="$acx_cv_fc_cf_flag (probed)"
+elif test -z "$FC" -o X"$FC" = Xno; then :
+  acx_cv_cf_flag="$acx_cv_f77_cf_flag (probed)"
+else
+  if test x"$acx_cv_f77_cf_flag" = x"$acx_cv_fc_cf_flag"; then :
+  acx_cv_cf_flag="$acx_cv_f77_cf_flag (probed)"
+else
+  as_fn_error $? "cfortran.h flag for $F77 does not match the flag for $FC.
+Have you configured compatible compilers?" "$LINENO" 5
+fi
+fi
+
+
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_cf_flag" >&5
+$as_echo "$acx_cv_cf_flag" >&6; }
+   if echo "$acx_cv_cf_flag" | grep ' (probed)$' >/dev/null; then :
+  CPPFLAGS="${CPPFLAGS+$CPPFLAGS }`echo "$acx_cv_cf_flag" | sed 's/ (probed)$//'`"
+fi
+
+case $host in #(
+  *-ibm-aix*) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if -Dappendus needs to be added to CPPFLAGS for cfortran.h" >&5
+$as_echo_n "checking if -Dappendus needs to be added to CPPFLAGS for cfortran.h... " >&6; }
+      if $CC -qversion 2>&1 | grep '^IBM XL C' >/dev/null; then :
+  acx_temp_qextname_f77flags=`echo "$FFLAGS" | sed -n '/-qextname/{ s/^\(.* \)*-qextname\( .*\)*$/-qextname/;p;}'`
+         acx_temp_qextname_fcflags=`echo "$FCFLAGS" | sed -n '/-qextname/{ s/^\(.* \)*-qextname\( .*\)*$/-qextname/;p;}'`
+
+               if $FC -qversion 2>&1 | grep '^IBM XL Fortran' >/dev/null; then :
+
+else
+  acx_temp_qextname_fcflags=-qextname
+fi
+         case x"$acx_temp_qextname_fcflags$acx_temp_qextname_f77flags" in #(
+  x-qextname) :
+    as_fn_error $? "Option -qextname must be provided consistently to F77 and FC" "$LINENO" 5 ;; #(
+  x-qextname-qextname) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+            CPPFLAGS="${CPPFLAGS+$CPPFLAGS }-Dappendus" ;; #(
+  *) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; } ;;
+esac
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi ;; #(
+  *) :
+     ;;
+esac
+if test -n "$FC" -a X"$FC" != Xno -o -n "$F77" -a X"$F77" != Xno; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if C externals constructed with cfortran.h work" >&5
+$as_echo_n "checking if C externals constructed with cfortran.h work... " >&6; }
+if ${acx_cv_cfortran_works+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  acx_cv_cfortran_works=no
+      save_CPPFLAGS=$CPPFLAGS
+      CPPFLAGS="-I$srcdir/src $CPPFLAGS"
+      ac_ext=c
 ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
 
       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-#include "$srcdir/src/cfortran.h"
-int
-main ()
+#include "cfortran.h"
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+
+PROTOCCALLSFFUN1(FLOAT,CFTSTF,cftstf,FLOAT)
+#define conftest_F(v) \
+  CCALLSFFUN1(CFTSTF,cftstf,FLOAT,(v));
+
+static float
+cftstC(int i, float v, int *p, float *q)
+{
+  float f;
+  *p = (int)roundf(v * i);
+  *q = f = conftest_F(v * i);
+  return f;
+}
+
+FCALLSCFUN4(FLOAT,cftstC,CFTSTC,cftstc,INT,FLOAT,PINT,PFLOAT)
+
+/* test string returns */
+static const char *
+conftest_str_C(void)
 {
+  static const char msg[100] = "AAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
+  return msg;
+}
 
-  ;
-  return 0;
+FCALLSCFUN0(STRING,conftest_str_C,CHTST,chtst)
+
+/* This function is required simply because some Fortran compilers
+ * won't stop with exit code n when encountering STOP n */
+static void
+errExit(void)
+{
+  exit(1);
 }
+
+FCALLSCSUB0(errExit,ERR_EXIT,err_exit)
+
+
 _ACEOF
 if ac_fn_c_try_compile "$LINENO"; then :
-  acx_cv_check_cfint=yes
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: Renaming C object file." >&5; } >&5
+  (mv "conftest.$ac_objext" "conftest_c.$ac_objext") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+         ac_ext=${ac_fc_srcext-f}
+ac_compile='$FC -c $FCFLAGS $ac_fcflags_srcext conftest.$ac_ext >&5'
+ac_link='$FC -o conftest$ac_exeext $FCFLAGS $LDFLAGS $ac_fcflags_srcext conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_fc_compiler_gnu
+ac_link="./libtool --mode=link --tag=FC $ac_link"
+
+         cat > conftest.$ac_ext <<_ACEOF
+      MODULE conftest_data
+      IMPLICIT NONE
+      PRIVATE
+      REAL :: ri
+      PUBLIC :: ri
+      END MODULE conftest_data
+
+      FUNCTION cftstf(v) RESULT(r)
+      USE conftest_data, ONLY: ri
+      REAL, INTENT(in) :: v
+      REAL :: r
+      r = v * 100.0
+      ri = 1.0 / v
+      END FUNCTION cftstf
+_ACEOF
+if ac_fn_fc_try_compile "$LINENO"; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: Renaming Fortran object file." >&5; } >&5
+  (mv "conftest.$ac_objext" "conftest_f.$ac_objext") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+            save_LIBS=$LIBS
+            LIBS="conftest_c.$ac_objext conftest_f.$ac_objext $LIBS"
+            if test "$cross_compiling" = yes; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: Skipping run test for cfortran.h in cross-compilation mode," >&5
+$as_echo "$as_me: Skipping run test for cfortran.h in cross-compilation mode," >&6;}
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: link test succeeded." >&5
+$as_echo "$as_me: link test succeeded." >&6;}
+               acx_cv_cfortran_works=yes
+else
+  cat > conftest.$ac_ext <<_ACEOF
+      program conftest
+      USE conftest_data, ONLY: ri
+      IMPLICIT NONE
+      INTERFACE
+       FUNCTION cftstc(i, v, p, q) RESULT(f)
+         INTEGER, INTENT(in) :: i
+         REAL, INTENT(in) :: v
+         INTEGER, INTENT(out) :: p
+         REAL, INTENT(out) :: q
+         REAL :: f
+       END FUNCTION cftstc
+       FUNCTION chtst() result(s)
+         CHARACTER(99) :: s
+       END FUNCTION chtst
+      END INTERFACE
+      REAL, PARAMETER :: eps = 10e-6
+      REAL :: foo, boo, too
+      INTEGER :: bar, baz, i
+      CHARACTER(99) :: aaaaaa
+      bar = 5
+      foo = 0.3
+      too = cftstc(bar, foo, baz, boo)
+      IF (ABS(baz - NINT(bar * foo)) /= 0) THEN
+        WRITE (0, '(2(a,i0))') "error checking, when baz, baz=", baz, &
+             ", NINT(bar * foo) =", NINT(bar * foo)
+        FLUSH(0)
+        CALL err_exit
+      END IF
+      IF (ABS((ri - 1.0 / (bar * foo)) / ABS(ri)) > eps)  THEN
+        WRITE (0, '(2(a,g24.15))') "error checking ri, ri=", ri, ", 1.0 / &
+             &(bar * foo) = ", 1.0 / (bar * foo)
+        FLUSH(0)
+        CALL err_exit
+      END IF
+      IF (ABS((boo - (bar * foo * 100.0))/ABS(boo)) > eps)  THEN
+        WRITE (0, '(2(a,g24.15))') "error checking boo, boo=", boo, &
+             ", bar * foo * 100.0 = ", bar * foo * 100.0
+        FLUSH(0)
+        CALL err_exit
+      END IF
+      IF (too /= boo) THEN
+        WRITE (0, '(2(a,g24.15))') "error checking too vs. boo, too=", too, &
+             ", boo = ", boo
+        FLUSH(0)
+        CALL err_exit
+      END IF
+      aaaaaa = chtst()
+      DO i = 1, 99
+        IF (aaaaaa(i:i) /= 'A') THEN
+          WRITE (0, '(a,i0,a)') "error checking aaaaaa(", i, ")=", &
+              aaaaaa(i:i)
+          FLUSH(0)
+          CALL err_exit
+        END IF
+      END DO
+      end
+_ACEOF
+if ac_fn_fc_try_run "$LINENO"; then :
+  acx_cv_cfortran_works=yes
+else
+  acx_cv_cfortran_works="error"
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+	    LIBS=$save_LIBS
+else
+  acx_cv_cfortran_works="error compiling Fortran subroutine"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+         ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
+
+         ac_ext=f
+ac_compile='$F77 -c $FFLAGS conftest.$ac_ext >&5'
+ac_link='$F77 -o conftest$ac_exeext $FFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_f77_compiler_gnu
+ac_link="./libtool --mode=link --tag=F77 $ac_link"
+
+         cat > conftest.$ac_ext <<_ACEOF
+      REAL FUNCTION CFTSTF(v)
+      REAL RI
+      COMMON /CFTSTD/ RI
+      REAL V
+      REAL R
+      CFTSTF = V * 100.0
+      RI = 1.0 / V
+      END FUNCTION CFTSTF
+_ACEOF
+if ac_fn_f77_try_compile "$LINENO"; then :
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: Renaming Fortran object file." >&5; } >&5
+  (mv "conftest.$ac_objext" "conftest_f.$ac_objext") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+            save_LIBS=$LIBS
+            LIBS="conftest_c.$ac_objext conftest_f.$ac_objext $LIBS"
+            if test "$cross_compiling" = yes; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: Skipping run test for cfortran.h in cross-compilation mode," >&5
+$as_echo "$as_me: Skipping run test for cfortran.h in cross-compilation mode," >&6;}
+	       { $as_echo "$as_me:${as_lineno-$LINENO}: link test succeeded." >&5
+$as_echo "$as_me: link test succeeded." >&6;}
+               acx_cv_cfortran_works=yes
+else
+  cat > conftest.$ac_ext <<_ACEOF
+      program main
+      REAL RI
+      COMMON /CFTSTD/ RI
+      REAL EPS
+      PARAMETER(EPS=10E-6)
+      REAL FOO, BOO, TOO
+      INTEGER BAR, BAZ, I
+      CHARACTER(99) AAAAAA
+      EXTERNAL CFTSTC, CFTSTF, CHTST, ERR_EXIT
+      REAL CFTSTC, CFTSTF
+      CHARACTER(99) CHTST
+      BAR = 5
+      FOO = 0.3
+      TOO = CFTSTC(BAR, FOO, BAZ, BOO)
+      IF (ABS(BAZ - NINT(BAR * FOO)) /= 0) THEN
+        WRITE (0, '(2(A,I0))') "ERROR CHECKING, WHEN BAZ, BAZ=", BAZ,
+     &       ", NINT(BAR * FOO) =", NINT(BAR * FOO)
+        CALL ERR_EXIT
+      END IF
+      IF (ABS((RI - 1.0 / (BAR * FOO)) / ABS(RI)) > EPS)  THEN
+        WRITE (0, '(2(A,F24.15))') "ERROR CHECKING RI, RI=", RI, ",
+     &       1.0 / (BAR * FOO) = ", 1.0 / (BAR * FOO)
+        CALL err_exit
+      END IF
+      IF (ABS((BOO - (BAR * FOO * 100.0))/ABS(BOO)) > EPS)  THEN
+        WRITE (0, '(2(A,F24.15))') "ERROR CHECKING BOO, BOO=", BOO,
+     &       ", BAR * FOO * 100.0 = ", BAR * FOO * 100.0
+        CALL ERR_EXIT
+      END IF
+      IF (TOO /= BOO) THEN
+        WRITE (0, '(2(A,F24.15))') "ERROR CHECKING TOO VS. BOO, TOO=",
+     &       TOO, ", BOO = ", BOO
+        CALL ERR_EXIT
+      END IF
+      AAAAAA = CHTST()
+      DO i = 1, 99
+        IF (AAAAAA(I:I) /= 'A') THEN
+          WRITE (0, '(A,I0,2A)') "ERROR CHECKING AAAAAA(", I, ")=",
+     &        AAAAAA(I:I)
+          CALL ERR_EXIT
+        END IF
+      END DO
+      end
+_ACEOF
+if ac_fn_f77_try_run "$LINENO"; then :
+  acx_cv_cfortran_works=yes
+else
+  acx_cv_cfortran_works="error"
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+	    LIBS=$save_LIBS
+else
+  acx_cv_cfortran_works="error compiling Fortran subroutine"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+         ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
+
+
 else
-  acx_cv_check_cfint=no
+  acx_cv_cfortran_works="compiling with cfortran.h failed"
 fi
 rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
       ac_ext=c
@@ -28751,17 +30758,41 @@ ac_cpp='$CPP $CPPFLAGS'
 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
 ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
 ac_compiler_gnu=$ac_cv_c_compiler_gnu
+ac_link="./libtool --mode=link --tag=CC $ac_link"
+
+      CPPFLAGS=$save_CPPFLAGS
 
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_check_cfint" >&5
-$as_echo "$acx_cv_check_cfint" >&6; }
-   if test x$acx_cv_check_cfint = xyes; then :
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $acx_cv_cfortran_works" >&5
+$as_echo "$acx_cv_cfortran_works" >&6; }
+   if test x"$acx_cv_cfortran_works" = xyes; then :
 
 $as_echo "#define HAVE_CF_INTERFACE 1" >>confdefs.h
 
+else
+  case x"$acx_cv_cfortran_works" in #(
+  x"error") :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Linking/Running with C EXTERNAL built with cfortran.h does not work!" >&5
+$as_echo "$as_me: Linking/Running with C EXTERNAL built with cfortran.h does not work!" >&6;} ;; #(
+  x"compiling with cfortran.h failed") :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Compilation with cfortran.h is not working!" >&5
+$as_echo "$as_me: Compilation with cfortran.h is not working!" >&6;} ;; #(
+  x"error compiling Fortran subroutine") :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: compilation of simple Fortran source failed!" >&5
+$as_echo "$as_me: compilation of simple Fortran source failed!" >&6;} ;; #(
+  *) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: Unexpected error when linking C and Fortran via cfortran.h!" >&5
+$as_echo "$as_me: Unexpected error when linking C and Fortran via cfortran.h!" >&6;} ;;
+esac
+     { $as_echo "$as_me:${as_lineno-$LINENO}: Disabling cfortran.h bindings generation" >&5
+$as_echo "$as_me: Disabling cfortran.h bindings generation" >&6;}
+     acx_cv_cfortran_works=no
+fi
+
 fi
 
- if test -n "$FC" && test "X$FC" != "Xno" && test x$acx_cv_check_cfint = "xyes"; then
+fi
+ if test -n "$FC" -a X"$FC" != Xno -a x"$acx_cv_cfortran_works" = xyes; then
   USE_FC_TRUE=
   USE_FC_FALSE='#'
 else
@@ -28777,7 +30808,7 @@ cat >>confdefs.h <<_ACEOF
 _ACEOF
 
 
-ac_config_files="$ac_config_files tests/test_cksum_grib tests/test_cksum_nc tests/test_cksum_nc2 tests/test_cksum_nc4 tests/test_cksum_extra tests/test_cksum_service tests/test_cksum_ieg tests/test_chunk_cksum tests/test_f2003 tests/pio_write_run tests/pio_write_deco2d_run tests/pio_cksum_mpinonb tests/pio_cksum_fpguard tests/pio_cksum_asynch tests/pio_cksum_writer tests/pio_cksum_cdf tests/test_resource_copy_mpi_run tests/test_cdf_transformation tables/gen_tableheaderfile util/serialrun"
+ac_config_files="$ac_config_files tests/test_cksum_grib tests/test_cksum_nc tests/test_cksum_nc2 tests/test_cksum_nc4 tests/test_cksum_extra tests/test_cksum_service tests/test_cksum_ieg tests/test_chunk_cksum tests/test_f2003 tests/pio_write_run tests/pio_write_deco2d_run tests/pio_cksum_mpinonb tests/pio_cksum_mpi_fw_ordered tests/pio_cksum_mpi_fw_at_all tests/pio_cksum_mpi_fw_at_reblock tests/pio_cksum_fpguard tests/pio_cksum_asynch tests/pio_cksum_writer tests/pio_cksum_cdf tests/tes [...]
 
 
 ac_config_files="$ac_config_files Makefile src/Makefile interfaces/Makefile app/Makefile tests/Makefile examples/Makefile cdi.settings examples/pio/Makefile src/pkgconfig/cdi.pc src/pkgconfig/cdipio.pc"
@@ -28948,6 +30979,10 @@ if test -z "${USE_PPM_CORE_TRUE}" && test -z "${USE_PPM_CORE_FALSE}"; then
   as_fn_error $? "conditional \"USE_PPM_CORE\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
 fi
+if test -z "${HAVE_PARALLEL_NC4_TRUE}" && test -z "${HAVE_PARALLEL_NC4_FALSE}"; then
+  as_fn_error $? "conditional \"HAVE_PARALLEL_NC4\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
 if test -z "${CREATE_ISOC_TRUE}" && test -z "${CREATE_ISOC_FALSE}"; then
   as_fn_error $? "conditional \"CREATE_ISOC\" was never defined.
 Usually this means the macro was only invoked conditionally." "$LINENO" 5
@@ -29393,7 +31428,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
 # report actual input values of CONFIG_FILES etc. instead of their
 # values after options handling.
 ac_log="
-This file was extended by cdi $as_me 1.6.9, which was
+This file was extended by cdi $as_me 1.7.0, which was
 generated by GNU Autoconf 2.68.  Invocation command line was
 
   CONFIG_FILES    = $CONFIG_FILES
@@ -29459,7 +31494,7 @@ _ACEOF
 cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
 ac_cs_version="\\
-cdi config.status 1.6.9
+cdi config.status 1.7.0
 configured by $0, generated by GNU Autoconf 2.68,
   with options \\"\$ac_cs_config\\"
 
@@ -29724,150 +31759,150 @@ postdep_objects='`$ECHO "$postdep_objects" | $SED "$delay_single_quote_subst"`'
 predeps='`$ECHO "$predeps" | $SED "$delay_single_quote_subst"`'
 postdeps='`$ECHO "$postdeps" | $SED "$delay_single_quote_subst"`'
 compiler_lib_search_path='`$ECHO "$compiler_lib_search_path" | $SED "$delay_single_quote_subst"`'
-LD_FC='`$ECHO "$LD_FC" | $SED "$delay_single_quote_subst"`'
-LD_F77='`$ECHO "$LD_F77" | $SED "$delay_single_quote_subst"`'
 LD_CXX='`$ECHO "$LD_CXX" | $SED "$delay_single_quote_subst"`'
-reload_flag_FC='`$ECHO "$reload_flag_FC" | $SED "$delay_single_quote_subst"`'
-reload_flag_F77='`$ECHO "$reload_flag_F77" | $SED "$delay_single_quote_subst"`'
+LD_F77='`$ECHO "$LD_F77" | $SED "$delay_single_quote_subst"`'
+LD_FC='`$ECHO "$LD_FC" | $SED "$delay_single_quote_subst"`'
 reload_flag_CXX='`$ECHO "$reload_flag_CXX" | $SED "$delay_single_quote_subst"`'
-reload_cmds_FC='`$ECHO "$reload_cmds_FC" | $SED "$delay_single_quote_subst"`'
-reload_cmds_F77='`$ECHO "$reload_cmds_F77" | $SED "$delay_single_quote_subst"`'
+reload_flag_F77='`$ECHO "$reload_flag_F77" | $SED "$delay_single_quote_subst"`'
+reload_flag_FC='`$ECHO "$reload_flag_FC" | $SED "$delay_single_quote_subst"`'
 reload_cmds_CXX='`$ECHO "$reload_cmds_CXX" | $SED "$delay_single_quote_subst"`'
-old_archive_cmds_FC='`$ECHO "$old_archive_cmds_FC" | $SED "$delay_single_quote_subst"`'
-old_archive_cmds_F77='`$ECHO "$old_archive_cmds_F77" | $SED "$delay_single_quote_subst"`'
+reload_cmds_F77='`$ECHO "$reload_cmds_F77" | $SED "$delay_single_quote_subst"`'
+reload_cmds_FC='`$ECHO "$reload_cmds_FC" | $SED "$delay_single_quote_subst"`'
 old_archive_cmds_CXX='`$ECHO "$old_archive_cmds_CXX" | $SED "$delay_single_quote_subst"`'
-compiler_FC='`$ECHO "$compiler_FC" | $SED "$delay_single_quote_subst"`'
-compiler_F77='`$ECHO "$compiler_F77" | $SED "$delay_single_quote_subst"`'
+old_archive_cmds_F77='`$ECHO "$old_archive_cmds_F77" | $SED "$delay_single_quote_subst"`'
+old_archive_cmds_FC='`$ECHO "$old_archive_cmds_FC" | $SED "$delay_single_quote_subst"`'
 compiler_CXX='`$ECHO "$compiler_CXX" | $SED "$delay_single_quote_subst"`'
-GCC_FC='`$ECHO "$GCC_FC" | $SED "$delay_single_quote_subst"`'
-GCC_F77='`$ECHO "$GCC_F77" | $SED "$delay_single_quote_subst"`'
+compiler_F77='`$ECHO "$compiler_F77" | $SED "$delay_single_quote_subst"`'
+compiler_FC='`$ECHO "$compiler_FC" | $SED "$delay_single_quote_subst"`'
 GCC_CXX='`$ECHO "$GCC_CXX" | $SED "$delay_single_quote_subst"`'
-lt_prog_compiler_no_builtin_flag_FC='`$ECHO "$lt_prog_compiler_no_builtin_flag_FC" | $SED "$delay_single_quote_subst"`'
-lt_prog_compiler_no_builtin_flag_F77='`$ECHO "$lt_prog_compiler_no_builtin_flag_F77" | $SED "$delay_single_quote_subst"`'
+GCC_F77='`$ECHO "$GCC_F77" | $SED "$delay_single_quote_subst"`'
+GCC_FC='`$ECHO "$GCC_FC" | $SED "$delay_single_quote_subst"`'
 lt_prog_compiler_no_builtin_flag_CXX='`$ECHO "$lt_prog_compiler_no_builtin_flag_CXX" | $SED "$delay_single_quote_subst"`'
-lt_prog_compiler_pic_FC='`$ECHO "$lt_prog_compiler_pic_FC" | $SED "$delay_single_quote_subst"`'
-lt_prog_compiler_pic_F77='`$ECHO "$lt_prog_compiler_pic_F77" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_F77='`$ECHO "$lt_prog_compiler_no_builtin_flag_F77" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_no_builtin_flag_FC='`$ECHO "$lt_prog_compiler_no_builtin_flag_FC" | $SED "$delay_single_quote_subst"`'
 lt_prog_compiler_pic_CXX='`$ECHO "$lt_prog_compiler_pic_CXX" | $SED "$delay_single_quote_subst"`'
-lt_prog_compiler_wl_FC='`$ECHO "$lt_prog_compiler_wl_FC" | $SED "$delay_single_quote_subst"`'
-lt_prog_compiler_wl_F77='`$ECHO "$lt_prog_compiler_wl_F77" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_F77='`$ECHO "$lt_prog_compiler_pic_F77" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_pic_FC='`$ECHO "$lt_prog_compiler_pic_FC" | $SED "$delay_single_quote_subst"`'
 lt_prog_compiler_wl_CXX='`$ECHO "$lt_prog_compiler_wl_CXX" | $SED "$delay_single_quote_subst"`'
-lt_prog_compiler_static_FC='`$ECHO "$lt_prog_compiler_static_FC" | $SED "$delay_single_quote_subst"`'
-lt_prog_compiler_static_F77='`$ECHO "$lt_prog_compiler_static_F77" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_F77='`$ECHO "$lt_prog_compiler_wl_F77" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_wl_FC='`$ECHO "$lt_prog_compiler_wl_FC" | $SED "$delay_single_quote_subst"`'
 lt_prog_compiler_static_CXX='`$ECHO "$lt_prog_compiler_static_CXX" | $SED "$delay_single_quote_subst"`'
-lt_cv_prog_compiler_c_o_FC='`$ECHO "$lt_cv_prog_compiler_c_o_FC" | $SED "$delay_single_quote_subst"`'
-lt_cv_prog_compiler_c_o_F77='`$ECHO "$lt_cv_prog_compiler_c_o_F77" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_static_F77='`$ECHO "$lt_prog_compiler_static_F77" | $SED "$delay_single_quote_subst"`'
+lt_prog_compiler_static_FC='`$ECHO "$lt_prog_compiler_static_FC" | $SED "$delay_single_quote_subst"`'
 lt_cv_prog_compiler_c_o_CXX='`$ECHO "$lt_cv_prog_compiler_c_o_CXX" | $SED "$delay_single_quote_subst"`'
-archive_cmds_need_lc_FC='`$ECHO "$archive_cmds_need_lc_FC" | $SED "$delay_single_quote_subst"`'
-archive_cmds_need_lc_F77='`$ECHO "$archive_cmds_need_lc_F77" | $SED "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_F77='`$ECHO "$lt_cv_prog_compiler_c_o_F77" | $SED "$delay_single_quote_subst"`'
+lt_cv_prog_compiler_c_o_FC='`$ECHO "$lt_cv_prog_compiler_c_o_FC" | $SED "$delay_single_quote_subst"`'
 archive_cmds_need_lc_CXX='`$ECHO "$archive_cmds_need_lc_CXX" | $SED "$delay_single_quote_subst"`'
-enable_shared_with_static_runtimes_FC='`$ECHO "$enable_shared_with_static_runtimes_FC" | $SED "$delay_single_quote_subst"`'
-enable_shared_with_static_runtimes_F77='`$ECHO "$enable_shared_with_static_runtimes_F77" | $SED "$delay_single_quote_subst"`'
+archive_cmds_need_lc_F77='`$ECHO "$archive_cmds_need_lc_F77" | $SED "$delay_single_quote_subst"`'
+archive_cmds_need_lc_FC='`$ECHO "$archive_cmds_need_lc_FC" | $SED "$delay_single_quote_subst"`'
 enable_shared_with_static_runtimes_CXX='`$ECHO "$enable_shared_with_static_runtimes_CXX" | $SED "$delay_single_quote_subst"`'
-export_dynamic_flag_spec_FC='`$ECHO "$export_dynamic_flag_spec_FC" | $SED "$delay_single_quote_subst"`'
-export_dynamic_flag_spec_F77='`$ECHO "$export_dynamic_flag_spec_F77" | $SED "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_F77='`$ECHO "$enable_shared_with_static_runtimes_F77" | $SED "$delay_single_quote_subst"`'
+enable_shared_with_static_runtimes_FC='`$ECHO "$enable_shared_with_static_runtimes_FC" | $SED "$delay_single_quote_subst"`'
 export_dynamic_flag_spec_CXX='`$ECHO "$export_dynamic_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
-whole_archive_flag_spec_FC='`$ECHO "$whole_archive_flag_spec_FC" | $SED "$delay_single_quote_subst"`'
-whole_archive_flag_spec_F77='`$ECHO "$whole_archive_flag_spec_F77" | $SED "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_F77='`$ECHO "$export_dynamic_flag_spec_F77" | $SED "$delay_single_quote_subst"`'
+export_dynamic_flag_spec_FC='`$ECHO "$export_dynamic_flag_spec_FC" | $SED "$delay_single_quote_subst"`'
 whole_archive_flag_spec_CXX='`$ECHO "$whole_archive_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
-compiler_needs_object_FC='`$ECHO "$compiler_needs_object_FC" | $SED "$delay_single_quote_subst"`'
-compiler_needs_object_F77='`$ECHO "$compiler_needs_object_F77" | $SED "$delay_single_quote_subst"`'
+whole_archive_flag_spec_F77='`$ECHO "$whole_archive_flag_spec_F77" | $SED "$delay_single_quote_subst"`'
+whole_archive_flag_spec_FC='`$ECHO "$whole_archive_flag_spec_FC" | $SED "$delay_single_quote_subst"`'
 compiler_needs_object_CXX='`$ECHO "$compiler_needs_object_CXX" | $SED "$delay_single_quote_subst"`'
-old_archive_from_new_cmds_FC='`$ECHO "$old_archive_from_new_cmds_FC" | $SED "$delay_single_quote_subst"`'
-old_archive_from_new_cmds_F77='`$ECHO "$old_archive_from_new_cmds_F77" | $SED "$delay_single_quote_subst"`'
+compiler_needs_object_F77='`$ECHO "$compiler_needs_object_F77" | $SED "$delay_single_quote_subst"`'
+compiler_needs_object_FC='`$ECHO "$compiler_needs_object_FC" | $SED "$delay_single_quote_subst"`'
 old_archive_from_new_cmds_CXX='`$ECHO "$old_archive_from_new_cmds_CXX" | $SED "$delay_single_quote_subst"`'
-old_archive_from_expsyms_cmds_FC='`$ECHO "$old_archive_from_expsyms_cmds_FC" | $SED "$delay_single_quote_subst"`'
-old_archive_from_expsyms_cmds_F77='`$ECHO "$old_archive_from_expsyms_cmds_F77" | $SED "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_F77='`$ECHO "$old_archive_from_new_cmds_F77" | $SED "$delay_single_quote_subst"`'
+old_archive_from_new_cmds_FC='`$ECHO "$old_archive_from_new_cmds_FC" | $SED "$delay_single_quote_subst"`'
 old_archive_from_expsyms_cmds_CXX='`$ECHO "$old_archive_from_expsyms_cmds_CXX" | $SED "$delay_single_quote_subst"`'
-archive_cmds_FC='`$ECHO "$archive_cmds_FC" | $SED "$delay_single_quote_subst"`'
-archive_cmds_F77='`$ECHO "$archive_cmds_F77" | $SED "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_F77='`$ECHO "$old_archive_from_expsyms_cmds_F77" | $SED "$delay_single_quote_subst"`'
+old_archive_from_expsyms_cmds_FC='`$ECHO "$old_archive_from_expsyms_cmds_FC" | $SED "$delay_single_quote_subst"`'
 archive_cmds_CXX='`$ECHO "$archive_cmds_CXX" | $SED "$delay_single_quote_subst"`'
-archive_expsym_cmds_FC='`$ECHO "$archive_expsym_cmds_FC" | $SED "$delay_single_quote_subst"`'
-archive_expsym_cmds_F77='`$ECHO "$archive_expsym_cmds_F77" | $SED "$delay_single_quote_subst"`'
+archive_cmds_F77='`$ECHO "$archive_cmds_F77" | $SED "$delay_single_quote_subst"`'
+archive_cmds_FC='`$ECHO "$archive_cmds_FC" | $SED "$delay_single_quote_subst"`'
 archive_expsym_cmds_CXX='`$ECHO "$archive_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`'
-module_cmds_FC='`$ECHO "$module_cmds_FC" | $SED "$delay_single_quote_subst"`'
-module_cmds_F77='`$ECHO "$module_cmds_F77" | $SED "$delay_single_quote_subst"`'
+archive_expsym_cmds_F77='`$ECHO "$archive_expsym_cmds_F77" | $SED "$delay_single_quote_subst"`'
+archive_expsym_cmds_FC='`$ECHO "$archive_expsym_cmds_FC" | $SED "$delay_single_quote_subst"`'
 module_cmds_CXX='`$ECHO "$module_cmds_CXX" | $SED "$delay_single_quote_subst"`'
-module_expsym_cmds_FC='`$ECHO "$module_expsym_cmds_FC" | $SED "$delay_single_quote_subst"`'
-module_expsym_cmds_F77='`$ECHO "$module_expsym_cmds_F77" | $SED "$delay_single_quote_subst"`'
+module_cmds_F77='`$ECHO "$module_cmds_F77" | $SED "$delay_single_quote_subst"`'
+module_cmds_FC='`$ECHO "$module_cmds_FC" | $SED "$delay_single_quote_subst"`'
 module_expsym_cmds_CXX='`$ECHO "$module_expsym_cmds_CXX" | $SED "$delay_single_quote_subst"`'
-with_gnu_ld_FC='`$ECHO "$with_gnu_ld_FC" | $SED "$delay_single_quote_subst"`'
-with_gnu_ld_F77='`$ECHO "$with_gnu_ld_F77" | $SED "$delay_single_quote_subst"`'
+module_expsym_cmds_F77='`$ECHO "$module_expsym_cmds_F77" | $SED "$delay_single_quote_subst"`'
+module_expsym_cmds_FC='`$ECHO "$module_expsym_cmds_FC" | $SED "$delay_single_quote_subst"`'
 with_gnu_ld_CXX='`$ECHO "$with_gnu_ld_CXX" | $SED "$delay_single_quote_subst"`'
-allow_undefined_flag_FC='`$ECHO "$allow_undefined_flag_FC" | $SED "$delay_single_quote_subst"`'
-allow_undefined_flag_F77='`$ECHO "$allow_undefined_flag_F77" | $SED "$delay_single_quote_subst"`'
+with_gnu_ld_F77='`$ECHO "$with_gnu_ld_F77" | $SED "$delay_single_quote_subst"`'
+with_gnu_ld_FC='`$ECHO "$with_gnu_ld_FC" | $SED "$delay_single_quote_subst"`'
 allow_undefined_flag_CXX='`$ECHO "$allow_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`'
-no_undefined_flag_FC='`$ECHO "$no_undefined_flag_FC" | $SED "$delay_single_quote_subst"`'
-no_undefined_flag_F77='`$ECHO "$no_undefined_flag_F77" | $SED "$delay_single_quote_subst"`'
+allow_undefined_flag_F77='`$ECHO "$allow_undefined_flag_F77" | $SED "$delay_single_quote_subst"`'
+allow_undefined_flag_FC='`$ECHO "$allow_undefined_flag_FC" | $SED "$delay_single_quote_subst"`'
 no_undefined_flag_CXX='`$ECHO "$no_undefined_flag_CXX" | $SED "$delay_single_quote_subst"`'
-hardcode_libdir_flag_spec_FC='`$ECHO "$hardcode_libdir_flag_spec_FC" | $SED "$delay_single_quote_subst"`'
-hardcode_libdir_flag_spec_F77='`$ECHO "$hardcode_libdir_flag_spec_F77" | $SED "$delay_single_quote_subst"`'
+no_undefined_flag_F77='`$ECHO "$no_undefined_flag_F77" | $SED "$delay_single_quote_subst"`'
+no_undefined_flag_FC='`$ECHO "$no_undefined_flag_FC" | $SED "$delay_single_quote_subst"`'
 hardcode_libdir_flag_spec_CXX='`$ECHO "$hardcode_libdir_flag_spec_CXX" | $SED "$delay_single_quote_subst"`'
-hardcode_libdir_separator_FC='`$ECHO "$hardcode_libdir_separator_FC" | $SED "$delay_single_quote_subst"`'
-hardcode_libdir_separator_F77='`$ECHO "$hardcode_libdir_separator_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_F77='`$ECHO "$hardcode_libdir_flag_spec_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_flag_spec_FC='`$ECHO "$hardcode_libdir_flag_spec_FC" | $SED "$delay_single_quote_subst"`'
 hardcode_libdir_separator_CXX='`$ECHO "$hardcode_libdir_separator_CXX" | $SED "$delay_single_quote_subst"`'
-hardcode_direct_FC='`$ECHO "$hardcode_direct_FC" | $SED "$delay_single_quote_subst"`'
-hardcode_direct_F77='`$ECHO "$hardcode_direct_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_separator_F77='`$ECHO "$hardcode_libdir_separator_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_libdir_separator_FC='`$ECHO "$hardcode_libdir_separator_FC" | $SED "$delay_single_quote_subst"`'
 hardcode_direct_CXX='`$ECHO "$hardcode_direct_CXX" | $SED "$delay_single_quote_subst"`'
-hardcode_direct_absolute_FC='`$ECHO "$hardcode_direct_absolute_FC" | $SED "$delay_single_quote_subst"`'
-hardcode_direct_absolute_F77='`$ECHO "$hardcode_direct_absolute_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_F77='`$ECHO "$hardcode_direct_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_FC='`$ECHO "$hardcode_direct_FC" | $SED "$delay_single_quote_subst"`'
 hardcode_direct_absolute_CXX='`$ECHO "$hardcode_direct_absolute_CXX" | $SED "$delay_single_quote_subst"`'
-hardcode_minus_L_FC='`$ECHO "$hardcode_minus_L_FC" | $SED "$delay_single_quote_subst"`'
-hardcode_minus_L_F77='`$ECHO "$hardcode_minus_L_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_absolute_F77='`$ECHO "$hardcode_direct_absolute_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_direct_absolute_FC='`$ECHO "$hardcode_direct_absolute_FC" | $SED "$delay_single_quote_subst"`'
 hardcode_minus_L_CXX='`$ECHO "$hardcode_minus_L_CXX" | $SED "$delay_single_quote_subst"`'
-hardcode_shlibpath_var_FC='`$ECHO "$hardcode_shlibpath_var_FC" | $SED "$delay_single_quote_subst"`'
-hardcode_shlibpath_var_F77='`$ECHO "$hardcode_shlibpath_var_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_minus_L_F77='`$ECHO "$hardcode_minus_L_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_minus_L_FC='`$ECHO "$hardcode_minus_L_FC" | $SED "$delay_single_quote_subst"`'
 hardcode_shlibpath_var_CXX='`$ECHO "$hardcode_shlibpath_var_CXX" | $SED "$delay_single_quote_subst"`'
-hardcode_automatic_FC='`$ECHO "$hardcode_automatic_FC" | $SED "$delay_single_quote_subst"`'
-hardcode_automatic_F77='`$ECHO "$hardcode_automatic_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_F77='`$ECHO "$hardcode_shlibpath_var_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_shlibpath_var_FC='`$ECHO "$hardcode_shlibpath_var_FC" | $SED "$delay_single_quote_subst"`'
 hardcode_automatic_CXX='`$ECHO "$hardcode_automatic_CXX" | $SED "$delay_single_quote_subst"`'
-inherit_rpath_FC='`$ECHO "$inherit_rpath_FC" | $SED "$delay_single_quote_subst"`'
-inherit_rpath_F77='`$ECHO "$inherit_rpath_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_automatic_F77='`$ECHO "$hardcode_automatic_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_automatic_FC='`$ECHO "$hardcode_automatic_FC" | $SED "$delay_single_quote_subst"`'
 inherit_rpath_CXX='`$ECHO "$inherit_rpath_CXX" | $SED "$delay_single_quote_subst"`'
-link_all_deplibs_FC='`$ECHO "$link_all_deplibs_FC" | $SED "$delay_single_quote_subst"`'
-link_all_deplibs_F77='`$ECHO "$link_all_deplibs_F77" | $SED "$delay_single_quote_subst"`'
+inherit_rpath_F77='`$ECHO "$inherit_rpath_F77" | $SED "$delay_single_quote_subst"`'
+inherit_rpath_FC='`$ECHO "$inherit_rpath_FC" | $SED "$delay_single_quote_subst"`'
 link_all_deplibs_CXX='`$ECHO "$link_all_deplibs_CXX" | $SED "$delay_single_quote_subst"`'
-always_export_symbols_FC='`$ECHO "$always_export_symbols_FC" | $SED "$delay_single_quote_subst"`'
-always_export_symbols_F77='`$ECHO "$always_export_symbols_F77" | $SED "$delay_single_quote_subst"`'
+link_all_deplibs_F77='`$ECHO "$link_all_deplibs_F77" | $SED "$delay_single_quote_subst"`'
+link_all_deplibs_FC='`$ECHO "$link_all_deplibs_FC" | $SED "$delay_single_quote_subst"`'
 always_export_symbols_CXX='`$ECHO "$always_export_symbols_CXX" | $SED "$delay_single_quote_subst"`'
-export_symbols_cmds_FC='`$ECHO "$export_symbols_cmds_FC" | $SED "$delay_single_quote_subst"`'
-export_symbols_cmds_F77='`$ECHO "$export_symbols_cmds_F77" | $SED "$delay_single_quote_subst"`'
+always_export_symbols_F77='`$ECHO "$always_export_symbols_F77" | $SED "$delay_single_quote_subst"`'
+always_export_symbols_FC='`$ECHO "$always_export_symbols_FC" | $SED "$delay_single_quote_subst"`'
 export_symbols_cmds_CXX='`$ECHO "$export_symbols_cmds_CXX" | $SED "$delay_single_quote_subst"`'
-exclude_expsyms_FC='`$ECHO "$exclude_expsyms_FC" | $SED "$delay_single_quote_subst"`'
-exclude_expsyms_F77='`$ECHO "$exclude_expsyms_F77" | $SED "$delay_single_quote_subst"`'
+export_symbols_cmds_F77='`$ECHO "$export_symbols_cmds_F77" | $SED "$delay_single_quote_subst"`'
+export_symbols_cmds_FC='`$ECHO "$export_symbols_cmds_FC" | $SED "$delay_single_quote_subst"`'
 exclude_expsyms_CXX='`$ECHO "$exclude_expsyms_CXX" | $SED "$delay_single_quote_subst"`'
-include_expsyms_FC='`$ECHO "$include_expsyms_FC" | $SED "$delay_single_quote_subst"`'
-include_expsyms_F77='`$ECHO "$include_expsyms_F77" | $SED "$delay_single_quote_subst"`'
+exclude_expsyms_F77='`$ECHO "$exclude_expsyms_F77" | $SED "$delay_single_quote_subst"`'
+exclude_expsyms_FC='`$ECHO "$exclude_expsyms_FC" | $SED "$delay_single_quote_subst"`'
 include_expsyms_CXX='`$ECHO "$include_expsyms_CXX" | $SED "$delay_single_quote_subst"`'
-prelink_cmds_FC='`$ECHO "$prelink_cmds_FC" | $SED "$delay_single_quote_subst"`'
-prelink_cmds_F77='`$ECHO "$prelink_cmds_F77" | $SED "$delay_single_quote_subst"`'
+include_expsyms_F77='`$ECHO "$include_expsyms_F77" | $SED "$delay_single_quote_subst"`'
+include_expsyms_FC='`$ECHO "$include_expsyms_FC" | $SED "$delay_single_quote_subst"`'
 prelink_cmds_CXX='`$ECHO "$prelink_cmds_CXX" | $SED "$delay_single_quote_subst"`'
-postlink_cmds_FC='`$ECHO "$postlink_cmds_FC" | $SED "$delay_single_quote_subst"`'
-postlink_cmds_F77='`$ECHO "$postlink_cmds_F77" | $SED "$delay_single_quote_subst"`'
+prelink_cmds_F77='`$ECHO "$prelink_cmds_F77" | $SED "$delay_single_quote_subst"`'
+prelink_cmds_FC='`$ECHO "$prelink_cmds_FC" | $SED "$delay_single_quote_subst"`'
 postlink_cmds_CXX='`$ECHO "$postlink_cmds_CXX" | $SED "$delay_single_quote_subst"`'
-file_list_spec_FC='`$ECHO "$file_list_spec_FC" | $SED "$delay_single_quote_subst"`'
-file_list_spec_F77='`$ECHO "$file_list_spec_F77" | $SED "$delay_single_quote_subst"`'
+postlink_cmds_F77='`$ECHO "$postlink_cmds_F77" | $SED "$delay_single_quote_subst"`'
+postlink_cmds_FC='`$ECHO "$postlink_cmds_FC" | $SED "$delay_single_quote_subst"`'
 file_list_spec_CXX='`$ECHO "$file_list_spec_CXX" | $SED "$delay_single_quote_subst"`'
-hardcode_action_FC='`$ECHO "$hardcode_action_FC" | $SED "$delay_single_quote_subst"`'
-hardcode_action_F77='`$ECHO "$hardcode_action_F77" | $SED "$delay_single_quote_subst"`'
+file_list_spec_F77='`$ECHO "$file_list_spec_F77" | $SED "$delay_single_quote_subst"`'
+file_list_spec_FC='`$ECHO "$file_list_spec_FC" | $SED "$delay_single_quote_subst"`'
 hardcode_action_CXX='`$ECHO "$hardcode_action_CXX" | $SED "$delay_single_quote_subst"`'
-compiler_lib_search_dirs_FC='`$ECHO "$compiler_lib_search_dirs_FC" | $SED "$delay_single_quote_subst"`'
-compiler_lib_search_dirs_F77='`$ECHO "$compiler_lib_search_dirs_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_action_F77='`$ECHO "$hardcode_action_F77" | $SED "$delay_single_quote_subst"`'
+hardcode_action_FC='`$ECHO "$hardcode_action_FC" | $SED "$delay_single_quote_subst"`'
 compiler_lib_search_dirs_CXX='`$ECHO "$compiler_lib_search_dirs_CXX" | $SED "$delay_single_quote_subst"`'
-predep_objects_FC='`$ECHO "$predep_objects_FC" | $SED "$delay_single_quote_subst"`'
-predep_objects_F77='`$ECHO "$predep_objects_F77" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_dirs_F77='`$ECHO "$compiler_lib_search_dirs_F77" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_dirs_FC='`$ECHO "$compiler_lib_search_dirs_FC" | $SED "$delay_single_quote_subst"`'
 predep_objects_CXX='`$ECHO "$predep_objects_CXX" | $SED "$delay_single_quote_subst"`'
-postdep_objects_FC='`$ECHO "$postdep_objects_FC" | $SED "$delay_single_quote_subst"`'
-postdep_objects_F77='`$ECHO "$postdep_objects_F77" | $SED "$delay_single_quote_subst"`'
+predep_objects_F77='`$ECHO "$predep_objects_F77" | $SED "$delay_single_quote_subst"`'
+predep_objects_FC='`$ECHO "$predep_objects_FC" | $SED "$delay_single_quote_subst"`'
 postdep_objects_CXX='`$ECHO "$postdep_objects_CXX" | $SED "$delay_single_quote_subst"`'
-predeps_FC='`$ECHO "$predeps_FC" | $SED "$delay_single_quote_subst"`'
-predeps_F77='`$ECHO "$predeps_F77" | $SED "$delay_single_quote_subst"`'
+postdep_objects_F77='`$ECHO "$postdep_objects_F77" | $SED "$delay_single_quote_subst"`'
+postdep_objects_FC='`$ECHO "$postdep_objects_FC" | $SED "$delay_single_quote_subst"`'
 predeps_CXX='`$ECHO "$predeps_CXX" | $SED "$delay_single_quote_subst"`'
-postdeps_FC='`$ECHO "$postdeps_FC" | $SED "$delay_single_quote_subst"`'
-postdeps_F77='`$ECHO "$postdeps_F77" | $SED "$delay_single_quote_subst"`'
+predeps_F77='`$ECHO "$predeps_F77" | $SED "$delay_single_quote_subst"`'
+predeps_FC='`$ECHO "$predeps_FC" | $SED "$delay_single_quote_subst"`'
 postdeps_CXX='`$ECHO "$postdeps_CXX" | $SED "$delay_single_quote_subst"`'
-compiler_lib_search_path_FC='`$ECHO "$compiler_lib_search_path_FC" | $SED "$delay_single_quote_subst"`'
-compiler_lib_search_path_F77='`$ECHO "$compiler_lib_search_path_F77" | $SED "$delay_single_quote_subst"`'
+postdeps_F77='`$ECHO "$postdeps_F77" | $SED "$delay_single_quote_subst"`'
+postdeps_FC='`$ECHO "$postdeps_FC" | $SED "$delay_single_quote_subst"`'
 compiler_lib_search_path_CXX='`$ECHO "$compiler_lib_search_path_CXX" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_path_F77='`$ECHO "$compiler_lib_search_path_F77" | $SED "$delay_single_quote_subst"`'
+compiler_lib_search_path_FC='`$ECHO "$compiler_lib_search_path_FC" | $SED "$delay_single_quote_subst"`'
 
 LTCC='$LTCC'
 LTCFLAGS='$LTCFLAGS'
@@ -29953,81 +31988,81 @@ postdep_objects \
 predeps \
 postdeps \
 compiler_lib_search_path \
-LD_FC \
-LD_F77 \
 LD_CXX \
-reload_flag_FC \
-reload_flag_F77 \
+LD_F77 \
+LD_FC \
 reload_flag_CXX \
-compiler_FC \
-compiler_F77 \
+reload_flag_F77 \
+reload_flag_FC \
 compiler_CXX \
-lt_prog_compiler_no_builtin_flag_FC \
-lt_prog_compiler_no_builtin_flag_F77 \
+compiler_F77 \
+compiler_FC \
 lt_prog_compiler_no_builtin_flag_CXX \
-lt_prog_compiler_pic_FC \
-lt_prog_compiler_pic_F77 \
+lt_prog_compiler_no_builtin_flag_F77 \
+lt_prog_compiler_no_builtin_flag_FC \
 lt_prog_compiler_pic_CXX \
-lt_prog_compiler_wl_FC \
-lt_prog_compiler_wl_F77 \
+lt_prog_compiler_pic_F77 \
+lt_prog_compiler_pic_FC \
 lt_prog_compiler_wl_CXX \
-lt_prog_compiler_static_FC \
-lt_prog_compiler_static_F77 \
+lt_prog_compiler_wl_F77 \
+lt_prog_compiler_wl_FC \
 lt_prog_compiler_static_CXX \
-lt_cv_prog_compiler_c_o_FC \
-lt_cv_prog_compiler_c_o_F77 \
+lt_prog_compiler_static_F77 \
+lt_prog_compiler_static_FC \
 lt_cv_prog_compiler_c_o_CXX \
-export_dynamic_flag_spec_FC \
-export_dynamic_flag_spec_F77 \
+lt_cv_prog_compiler_c_o_F77 \
+lt_cv_prog_compiler_c_o_FC \
 export_dynamic_flag_spec_CXX \
-whole_archive_flag_spec_FC \
-whole_archive_flag_spec_F77 \
+export_dynamic_flag_spec_F77 \
+export_dynamic_flag_spec_FC \
 whole_archive_flag_spec_CXX \
-compiler_needs_object_FC \
-compiler_needs_object_F77 \
+whole_archive_flag_spec_F77 \
+whole_archive_flag_spec_FC \
 compiler_needs_object_CXX \
-with_gnu_ld_FC \
-with_gnu_ld_F77 \
+compiler_needs_object_F77 \
+compiler_needs_object_FC \
 with_gnu_ld_CXX \
-allow_undefined_flag_FC \
-allow_undefined_flag_F77 \
+with_gnu_ld_F77 \
+with_gnu_ld_FC \
 allow_undefined_flag_CXX \
-no_undefined_flag_FC \
-no_undefined_flag_F77 \
+allow_undefined_flag_F77 \
+allow_undefined_flag_FC \
 no_undefined_flag_CXX \
-hardcode_libdir_flag_spec_FC \
-hardcode_libdir_flag_spec_F77 \
+no_undefined_flag_F77 \
+no_undefined_flag_FC \
 hardcode_libdir_flag_spec_CXX \
-hardcode_libdir_separator_FC \
-hardcode_libdir_separator_F77 \
+hardcode_libdir_flag_spec_F77 \
+hardcode_libdir_flag_spec_FC \
 hardcode_libdir_separator_CXX \
-exclude_expsyms_FC \
-exclude_expsyms_F77 \
+hardcode_libdir_separator_F77 \
+hardcode_libdir_separator_FC \
 exclude_expsyms_CXX \
-include_expsyms_FC \
-include_expsyms_F77 \
+exclude_expsyms_F77 \
+exclude_expsyms_FC \
 include_expsyms_CXX \
-file_list_spec_FC \
-file_list_spec_F77 \
+include_expsyms_F77 \
+include_expsyms_FC \
 file_list_spec_CXX \
-compiler_lib_search_dirs_FC \
-compiler_lib_search_dirs_F77 \
+file_list_spec_F77 \
+file_list_spec_FC \
 compiler_lib_search_dirs_CXX \
-predep_objects_FC \
-predep_objects_F77 \
+compiler_lib_search_dirs_F77 \
+compiler_lib_search_dirs_FC \
 predep_objects_CXX \
-postdep_objects_FC \
-postdep_objects_F77 \
+predep_objects_F77 \
+predep_objects_FC \
 postdep_objects_CXX \
-predeps_FC \
-predeps_F77 \
+postdep_objects_F77 \
+postdep_objects_FC \
 predeps_CXX \
-postdeps_FC \
-postdeps_F77 \
+predeps_F77 \
+predeps_FC \
 postdeps_CXX \
-compiler_lib_search_path_FC \
+postdeps_F77 \
+postdeps_FC \
+compiler_lib_search_path_CXX \
 compiler_lib_search_path_F77 \
-compiler_lib_search_path_CXX; do
+compiler_lib_search_path_FC; do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[\\\\\\\`\\"\\\$]*)
       eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\""
@@ -30058,39 +32093,39 @@ postuninstall_cmds \
 finish_cmds \
 sys_lib_search_path_spec \
 sys_lib_dlsearch_path_spec \
-reload_cmds_FC \
-reload_cmds_F77 \
 reload_cmds_CXX \
-old_archive_cmds_FC \
-old_archive_cmds_F77 \
+reload_cmds_F77 \
+reload_cmds_FC \
 old_archive_cmds_CXX \
-old_archive_from_new_cmds_FC \
-old_archive_from_new_cmds_F77 \
+old_archive_cmds_F77 \
+old_archive_cmds_FC \
 old_archive_from_new_cmds_CXX \
-old_archive_from_expsyms_cmds_FC \
-old_archive_from_expsyms_cmds_F77 \
+old_archive_from_new_cmds_F77 \
+old_archive_from_new_cmds_FC \
 old_archive_from_expsyms_cmds_CXX \
-archive_cmds_FC \
-archive_cmds_F77 \
+old_archive_from_expsyms_cmds_F77 \
+old_archive_from_expsyms_cmds_FC \
 archive_cmds_CXX \
-archive_expsym_cmds_FC \
-archive_expsym_cmds_F77 \
+archive_cmds_F77 \
+archive_cmds_FC \
 archive_expsym_cmds_CXX \
-module_cmds_FC \
-module_cmds_F77 \
+archive_expsym_cmds_F77 \
+archive_expsym_cmds_FC \
 module_cmds_CXX \
-module_expsym_cmds_FC \
-module_expsym_cmds_F77 \
+module_cmds_F77 \
+module_cmds_FC \
 module_expsym_cmds_CXX \
-export_symbols_cmds_FC \
-export_symbols_cmds_F77 \
+module_expsym_cmds_F77 \
+module_expsym_cmds_FC \
 export_symbols_cmds_CXX \
-prelink_cmds_FC \
-prelink_cmds_F77 \
+export_symbols_cmds_F77 \
+export_symbols_cmds_FC \
 prelink_cmds_CXX \
-postlink_cmds_FC \
+prelink_cmds_F77 \
+prelink_cmds_FC \
+postlink_cmds_CXX \
 postlink_cmds_F77 \
-postlink_cmds_CXX; do
+postlink_cmds_FC; do
     case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in
     *[\\\\\\\`\\"\\\$]*)
       eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\""
@@ -30124,6 +32159,7 @@ fi
 
 
 
+ac_aux_dir='$ac_aux_dir'
 
 
 
@@ -30150,6 +32186,9 @@ do
     "tests/pio_write_run") CONFIG_FILES="$CONFIG_FILES tests/pio_write_run" ;;
     "tests/pio_write_deco2d_run") CONFIG_FILES="$CONFIG_FILES tests/pio_write_deco2d_run" ;;
     "tests/pio_cksum_mpinonb") CONFIG_FILES="$CONFIG_FILES tests/pio_cksum_mpinonb" ;;
+    "tests/pio_cksum_mpi_fw_ordered") CONFIG_FILES="$CONFIG_FILES tests/pio_cksum_mpi_fw_ordered" ;;
+    "tests/pio_cksum_mpi_fw_at_all") CONFIG_FILES="$CONFIG_FILES tests/pio_cksum_mpi_fw_at_all" ;;
+    "tests/pio_cksum_mpi_fw_at_reblock") CONFIG_FILES="$CONFIG_FILES tests/pio_cksum_mpi_fw_at_reblock" ;;
     "tests/pio_cksum_fpguard") CONFIG_FILES="$CONFIG_FILES tests/pio_cksum_fpguard" ;;
     "tests/pio_cksum_asynch") CONFIG_FILES="$CONFIG_FILES tests/pio_cksum_asynch" ;;
     "tests/pio_cksum_writer") CONFIG_FILES="$CONFIG_FILES tests/pio_cksum_writer" ;;
@@ -30906,7 +32945,7 @@ $as_echo X"$file" |
 
 
 # The names of the tagged configurations supported by this script.
-available_tags="FC F77 CXX "
+available_tags="CXX F77 FC "
 
 # ### BEGIN LIBTOOL CONFIG
 
@@ -31502,154 +33541,154 @@ fi
 
     cat <<_LT_EOF >> "$ofile"
 
-# ### BEGIN LIBTOOL TAG CONFIG: FC
+# ### BEGIN LIBTOOL TAG CONFIG: CXX
 
 # The linker used to build libraries.
-LD=$lt_LD_FC
+LD=$lt_LD_CXX
 
 # How to create reloadable object files.
-reload_flag=$lt_reload_flag_FC
-reload_cmds=$lt_reload_cmds_FC
+reload_flag=$lt_reload_flag_CXX
+reload_cmds=$lt_reload_cmds_CXX
 
 # Commands used to build an old-style archive.
-old_archive_cmds=$lt_old_archive_cmds_FC
+old_archive_cmds=$lt_old_archive_cmds_CXX
 
 # A language specific compiler.
-CC=$lt_compiler_FC
+CC=$lt_compiler_CXX
 
 # Is the compiler the GNU compiler?
-with_gcc=$GCC_FC
+with_gcc=$GCC_CXX
 
 # Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_FC
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
 
 # Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_FC
+pic_flag=$lt_lt_prog_compiler_pic_CXX
 
 # How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_FC
+wl=$lt_lt_prog_compiler_wl_CXX
 
 # Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_FC
+link_static_flag=$lt_lt_prog_compiler_static_CXX
 
 # Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_FC
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
 
 # Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_FC
+build_libtool_need_lc=$archive_cmds_need_lc_CXX
 
 # Whether or not to disallow shared libs when runtime libs are static.
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_FC
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
 
 # Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_FC
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
 
 # Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_FC
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
 
 # Whether the compiler copes with passing no objects directly.
-compiler_needs_object=$lt_compiler_needs_object_FC
+compiler_needs_object=$lt_compiler_needs_object_CXX
 
 # Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_FC
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
 
 # Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_FC
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
 
 # Commands used to build a shared archive.
-archive_cmds=$lt_archive_cmds_FC
-archive_expsym_cmds=$lt_archive_expsym_cmds_FC
+archive_cmds=$lt_archive_cmds_CXX
+archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
 
 # Commands used to build a loadable module if different from building
 # a shared archive.
-module_cmds=$lt_module_cmds_FC
-module_expsym_cmds=$lt_module_expsym_cmds_FC
+module_cmds=$lt_module_cmds_CXX
+module_expsym_cmds=$lt_module_expsym_cmds_CXX
 
 # Whether we are building with GNU ld or not.
-with_gnu_ld=$lt_with_gnu_ld_FC
+with_gnu_ld=$lt_with_gnu_ld_CXX
 
 # Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_FC
+allow_undefined_flag=$lt_allow_undefined_flag_CXX
 
 # Flag that enforces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_FC
+no_undefined_flag=$lt_no_undefined_flag_CXX
 
 # Flag to hardcode \$libdir into a binary during linking.
 # This must work even if \$libdir does not exist
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_FC
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
 
 # Whether we need a single "-rpath" flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_FC
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
 
 # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
 # DIR into the resulting binary.
-hardcode_direct=$hardcode_direct_FC
+hardcode_direct=$hardcode_direct_CXX
 
 # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
 # DIR into the resulting binary and the resulting library dependency is
 # "absolute",i.e impossible to change by setting \${shlibpath_var} if the
 # library is relocated.
-hardcode_direct_absolute=$hardcode_direct_absolute_FC
+hardcode_direct_absolute=$hardcode_direct_absolute_CXX
 
 # Set to "yes" if using the -LDIR flag during linking hardcodes DIR
 # into the resulting binary.
-hardcode_minus_L=$hardcode_minus_L_FC
+hardcode_minus_L=$hardcode_minus_L_CXX
 
 # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
 # into the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_FC
+hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
 
 # Set to "yes" if building a shared library automatically hardcodes DIR
 # into the library and all subsequent libraries and executables linked
 # against it.
-hardcode_automatic=$hardcode_automatic_FC
+hardcode_automatic=$hardcode_automatic_CXX
 
 # Set to yes if linker adds runtime paths of dependent libraries
 # to runtime path list.
-inherit_rpath=$inherit_rpath_FC
+inherit_rpath=$inherit_rpath_CXX
 
 # Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_FC
+link_all_deplibs=$link_all_deplibs_CXX
 
 # Set to "yes" if exported symbols are required.
-always_export_symbols=$always_export_symbols_FC
+always_export_symbols=$always_export_symbols_CXX
 
 # The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_FC
+export_symbols_cmds=$lt_export_symbols_cmds_CXX
 
 # Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_FC
+exclude_expsyms=$lt_exclude_expsyms_CXX
 
 # Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_FC
+include_expsyms=$lt_include_expsyms_CXX
 
 # Commands necessary for linking programs (against libraries) with templates.
-prelink_cmds=$lt_prelink_cmds_FC
+prelink_cmds=$lt_prelink_cmds_CXX
 
 # Commands necessary for finishing linking programs.
-postlink_cmds=$lt_postlink_cmds_FC
+postlink_cmds=$lt_postlink_cmds_CXX
 
 # Specify filename containing input files.
-file_list_spec=$lt_file_list_spec_FC
+file_list_spec=$lt_file_list_spec_CXX
 
 # How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_FC
+hardcode_action=$hardcode_action_CXX
 
 # The directories searched by this compiler when creating a shared library.
-compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_FC
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX
 
 # Dependencies to place before and after the objects being linked to
 # create a shared library.
-predep_objects=$lt_predep_objects_FC
-postdep_objects=$lt_postdep_objects_FC
-predeps=$lt_predeps_FC
-postdeps=$lt_postdeps_FC
+predep_objects=$lt_predep_objects_CXX
+postdep_objects=$lt_postdep_objects_CXX
+predeps=$lt_predeps_CXX
+postdeps=$lt_postdeps_CXX
 
 # The library search path used internally by the compiler when linking
 # a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_FC
+compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
 
-# ### END LIBTOOL TAG CONFIG: FC
+# ### END LIBTOOL TAG CONFIG: CXX
 _LT_EOF
 
 
@@ -31808,154 +33847,154 @@ _LT_EOF
 
     cat <<_LT_EOF >> "$ofile"
 
-# ### BEGIN LIBTOOL TAG CONFIG: CXX
+# ### BEGIN LIBTOOL TAG CONFIG: FC
 
 # The linker used to build libraries.
-LD=$lt_LD_CXX
+LD=$lt_LD_FC
 
 # How to create reloadable object files.
-reload_flag=$lt_reload_flag_CXX
-reload_cmds=$lt_reload_cmds_CXX
+reload_flag=$lt_reload_flag_FC
+reload_cmds=$lt_reload_cmds_FC
 
 # Commands used to build an old-style archive.
-old_archive_cmds=$lt_old_archive_cmds_CXX
+old_archive_cmds=$lt_old_archive_cmds_FC
 
 # A language specific compiler.
-CC=$lt_compiler_CXX
+CC=$lt_compiler_FC
 
 # Is the compiler the GNU compiler?
-with_gcc=$GCC_CXX
+with_gcc=$GCC_FC
 
 # Compiler flag to turn off builtin functions.
-no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_CXX
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_FC
 
 # Additional compiler flags for building library objects.
-pic_flag=$lt_lt_prog_compiler_pic_CXX
+pic_flag=$lt_lt_prog_compiler_pic_FC
 
 # How to pass a linker flag through the compiler.
-wl=$lt_lt_prog_compiler_wl_CXX
+wl=$lt_lt_prog_compiler_wl_FC
 
 # Compiler flag to prevent dynamic linking.
-link_static_flag=$lt_lt_prog_compiler_static_CXX
+link_static_flag=$lt_lt_prog_compiler_static_FC
 
 # Does compiler simultaneously support -c and -o options?
-compiler_c_o=$lt_lt_cv_prog_compiler_c_o_CXX
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_FC
 
 # Whether or not to add -lc for building shared libraries.
-build_libtool_need_lc=$archive_cmds_need_lc_CXX
+build_libtool_need_lc=$archive_cmds_need_lc_FC
 
 # Whether or not to disallow shared libs when runtime libs are static.
-allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_CXX
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_FC
 
 # Compiler flag to allow reflexive dlopens.
-export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_CXX
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_FC
 
 # Compiler flag to generate shared objects directly from archives.
-whole_archive_flag_spec=$lt_whole_archive_flag_spec_CXX
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_FC
 
 # Whether the compiler copes with passing no objects directly.
-compiler_needs_object=$lt_compiler_needs_object_CXX
+compiler_needs_object=$lt_compiler_needs_object_FC
 
 # Create an old-style archive from a shared archive.
-old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_CXX
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_FC
 
 # Create a temporary old-style archive to link instead of a shared archive.
-old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_CXX
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_FC
 
 # Commands used to build a shared archive.
-archive_cmds=$lt_archive_cmds_CXX
-archive_expsym_cmds=$lt_archive_expsym_cmds_CXX
+archive_cmds=$lt_archive_cmds_FC
+archive_expsym_cmds=$lt_archive_expsym_cmds_FC
 
 # Commands used to build a loadable module if different from building
 # a shared archive.
-module_cmds=$lt_module_cmds_CXX
-module_expsym_cmds=$lt_module_expsym_cmds_CXX
+module_cmds=$lt_module_cmds_FC
+module_expsym_cmds=$lt_module_expsym_cmds_FC
 
 # Whether we are building with GNU ld or not.
-with_gnu_ld=$lt_with_gnu_ld_CXX
+with_gnu_ld=$lt_with_gnu_ld_FC
 
 # Flag that allows shared libraries with undefined symbols to be built.
-allow_undefined_flag=$lt_allow_undefined_flag_CXX
+allow_undefined_flag=$lt_allow_undefined_flag_FC
 
 # Flag that enforces no undefined symbols.
-no_undefined_flag=$lt_no_undefined_flag_CXX
+no_undefined_flag=$lt_no_undefined_flag_FC
 
 # Flag to hardcode \$libdir into a binary during linking.
 # This must work even if \$libdir does not exist
-hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_CXX
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_FC
 
 # Whether we need a single "-rpath" flag with a separated argument.
-hardcode_libdir_separator=$lt_hardcode_libdir_separator_CXX
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_FC
 
 # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
 # DIR into the resulting binary.
-hardcode_direct=$hardcode_direct_CXX
+hardcode_direct=$hardcode_direct_FC
 
 # Set to "yes" if using DIR/libNAME\${shared_ext} during linking hardcodes
 # DIR into the resulting binary and the resulting library dependency is
 # "absolute",i.e impossible to change by setting \${shlibpath_var} if the
 # library is relocated.
-hardcode_direct_absolute=$hardcode_direct_absolute_CXX
+hardcode_direct_absolute=$hardcode_direct_absolute_FC
 
 # Set to "yes" if using the -LDIR flag during linking hardcodes DIR
 # into the resulting binary.
-hardcode_minus_L=$hardcode_minus_L_CXX
+hardcode_minus_L=$hardcode_minus_L_FC
 
 # Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR
 # into the resulting binary.
-hardcode_shlibpath_var=$hardcode_shlibpath_var_CXX
+hardcode_shlibpath_var=$hardcode_shlibpath_var_FC
 
 # Set to "yes" if building a shared library automatically hardcodes DIR
 # into the library and all subsequent libraries and executables linked
 # against it.
-hardcode_automatic=$hardcode_automatic_CXX
+hardcode_automatic=$hardcode_automatic_FC
 
 # Set to yes if linker adds runtime paths of dependent libraries
 # to runtime path list.
-inherit_rpath=$inherit_rpath_CXX
+inherit_rpath=$inherit_rpath_FC
 
 # Whether libtool must link a program against all its dependency libraries.
-link_all_deplibs=$link_all_deplibs_CXX
+link_all_deplibs=$link_all_deplibs_FC
 
 # Set to "yes" if exported symbols are required.
-always_export_symbols=$always_export_symbols_CXX
+always_export_symbols=$always_export_symbols_FC
 
 # The commands to list exported symbols.
-export_symbols_cmds=$lt_export_symbols_cmds_CXX
+export_symbols_cmds=$lt_export_symbols_cmds_FC
 
 # Symbols that should not be listed in the preloaded symbols.
-exclude_expsyms=$lt_exclude_expsyms_CXX
+exclude_expsyms=$lt_exclude_expsyms_FC
 
 # Symbols that must always be exported.
-include_expsyms=$lt_include_expsyms_CXX
+include_expsyms=$lt_include_expsyms_FC
 
 # Commands necessary for linking programs (against libraries) with templates.
-prelink_cmds=$lt_prelink_cmds_CXX
+prelink_cmds=$lt_prelink_cmds_FC
 
 # Commands necessary for finishing linking programs.
-postlink_cmds=$lt_postlink_cmds_CXX
+postlink_cmds=$lt_postlink_cmds_FC
 
 # Specify filename containing input files.
-file_list_spec=$lt_file_list_spec_CXX
+file_list_spec=$lt_file_list_spec_FC
 
 # How to hardcode a shared library path into an executable.
-hardcode_action=$hardcode_action_CXX
+hardcode_action=$hardcode_action_FC
 
 # The directories searched by this compiler when creating a shared library.
-compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_CXX
+compiler_lib_search_dirs=$lt_compiler_lib_search_dirs_FC
 
 # Dependencies to place before and after the objects being linked to
 # create a shared library.
-predep_objects=$lt_predep_objects_CXX
-postdep_objects=$lt_postdep_objects_CXX
-predeps=$lt_predeps_CXX
-postdeps=$lt_postdeps_CXX
+predep_objects=$lt_predep_objects_FC
+postdep_objects=$lt_postdep_objects_FC
+predeps=$lt_predeps_FC
+postdeps=$lt_postdeps_FC
 
 # The library search path used internally by the compiler when linking
 # a shared library.
-compiler_lib_search_path=$lt_compiler_lib_search_path_CXX
+compiler_lib_search_path=$lt_compiler_lib_search_path_FC
 
-# ### END LIBTOOL TAG CONFIG: CXX
+# ### END LIBTOOL TAG CONFIG: FC
 _LT_EOF
 
  ;;
@@ -31971,6 +34010,9 @@ _LT_EOF
     "tests/pio_write_run":F) chmod a+x "$ac_file" ;;
     "tests/pio_write_deco2d_run":F) chmod a+x "$ac_file" ;;
     "tests/pio_cksum_mpinonb":F) chmod a+x "$ac_file" ;;
+    "tests/pio_cksum_mpi_fw_ordered":F) chmod a+x "$ac_file" ;;
+    "tests/pio_cksum_mpi_fw_at_all":F) chmod a+x "$ac_file" ;;
+    "tests/pio_cksum_mpi_fw_at_reblock":F) chmod a+x "$ac_file" ;;
     "tests/pio_cksum_fpguard":F) chmod a+x "$ac_file" ;;
     "tests/pio_cksum_asynch":F) chmod a+x "$ac_file" ;;
     "tests/pio_cksum_writer":F) chmod a+x "$ac_file" ;;
diff --git a/libcdi/configure.ac b/libcdi/configure.ac
index 0dee0b8..d95aa34 100644
--- a/libcdi/configure.ac
+++ b/libcdi/configure.ac
@@ -4,7 +4,9 @@
 #  autoconf 2.68
 #  libtool  2.4.2
 
-AC_INIT([cdi], [1.6.9], [http://mpimet.mpg.de/cdi])
+AC_INIT([cdi], [1.7.0], [http://mpimet.mpg.de/cdi])
+
+AC_DEFINE_UNQUOTED(CDI, ["$PACKAGE_VERSION"], [CDI version])
 
 echo "configuring ${PACKAGE_NAME} ${PACKAGE_VERSION}"
 
@@ -21,35 +23,31 @@ AM_INIT_AUTOMAKE([foreign serial-tests])
 AC_CONFIG_HEADERS([src/config.h])
 AM_MAINTAINER_MODE([disable])
 
-# Set up libtool.
-AC_MSG_NOTICE([setting up libtool])
-LT_INIT([pic-only])
-
 # Check building environment
 AC_CHECK_TOOL([CC],[gcc],[:])
 AC_PROG_CC_C99
 AM_PROG_CC_C_O
 AC_C_RESTRICT
 AC_PROG_FC
-AS_IF([test -n "$FC" && test "X$FC" != "Xno"],
+AS_IF([test -n "$FC" && test "X$FC" != Xno],
   [AC_FC_SRCEXT([f90])
    AC_LANG_PUSH([Fortran])
    AC_PROG_FPP
    AC_LANG_POP([Fortran])])
 AC_PROG_F77
 AC_PROG_CXX
-AC_CHECK_PROG(SED,sed,sed,false)
-AC_CHECK_PROG(GREP,grep,grep,false)
 AC_PROG_INSTALL
-AC_CHECK_TOOL([AR],[ar],[:])
-AC_CHECK_TOOL([CPP],[cpp],[:])
-AC_CHECK_TOOL([LD],[ld],[:])
-AC_CHECK_TOOL([NM],[nm],[:])
-AC_CHECK_TOOL([AS],[as],[:])
-AC_CHECK_TOOL([DLLTOOL],[dlltool],[:])
-AC_CHECK_TOOL([OBJDUMP],[objdump],[:])
-AC_CHECK_TOOL([STRIP],[strip],[:])
-AC_CHECK_TOOL([RANLIB],[ranlib],[:])
+
+# Set up libtool.
+AC_MSG_NOTICE([setting up libtool])
+dnl before switching on libtool, identify compilers that prevent us from
+dnl certain build configurations
+ACX_LT_PROBLEMS
+LT_INIT([pic-only])
+dnl _KPSE_USE_LIBTOOL ensures libtool is also used for configure-time tests,
+dnl which deduces dependent libraries automatically
+_KPSE_USE_LIBTOOL
+
 # -----------------------------------------------------------------------
 # Check endianess of system
 AC_C_BIGENDIAN
@@ -129,6 +127,7 @@ AC_CHECK_LIB(m, floor)
 # Add basic configure options
 ACX_OPTIONS
 AM_CONDITIONAL([ENABLE_NETCDF],[test x$ENABLE_NETCDF = xyes])
+AC_CHECK_FUNCS([grib_get_length])
 #  ----------------------------------------------------------------------
 # Compile with MPI support
 AC_ARG_ENABLE([mpi],
@@ -196,6 +195,10 @@ main(int argc, char **argv)
      ])
    AS_IF([test "x$MPI_LAUNCH" = xtrue],
      [AC_MSG_WARN([MPI launch command unavailable])])
+   AC_CHECK_DECLS([_SC_LARGE_PAGESIZE, PAGESIZE, PAGE_SIZE, _SC_PAGE_SIZE, dnl
+_SC_PAGESIZE, _PC_REC_XFER_ALIGN, POSIX_REC_XFER_ALIGN],,,[AC_INCLUDES_DEFAULT
+@%:@include <limits.h>
+@%:@include <unistd.h>])
 
    PKG_CHECK_MODULES([YAXT],[yaxt],
      [AC_DEFINE([HAVE_YAXT],,[yaxt library is available])],
@@ -235,16 +238,21 @@ AS_IF([test $HAVE_PARALLEL_NC4 -gt 0],
 AC_SUBST([HAVE_PARALLEL_NC4])
 AM_CONDITIONAL([USE_MPI],[test x"$USE_MPI" = xyes])
 AM_CONDITIONAL([USE_PPM_CORE],[test $enable_ppm = yes])
+AM_CONDITIONAL([HAVE_PARALLEL_NC4],[test $HAVE_PARALLEL_NC4 -gt 0])
 AC_SUBST([USE_MPI])
 AC_SUBST([ENABLE_MPI],[`test x"$enable_mpi" = xyes && echo true || echo false`])
 #  ----------------------------------------------------------------------
 #  Create the Fortran Interface via iso_c_binding module (Fortran 2003 Standard)
+#
+# the test for ruby itself is unconditional because ruby is also used in
+# the Fortran 2003 ISO C generator
+AC_CHECK_PROG([RUBY],[ruby],[ruby])
 AC_ARG_ENABLE([iso-c-interface],
               [AS_HELP_STRING([--enable-iso-c-interface],
                  [Create Fortran Interface via iso_c_bindings facility of F2003 [default=no].])],
               [enable_isoc=${enableval}],[enable_isoc=no])
 AS_IF([test x"$enable_isoc" = xyes],
-  [ACX_FC_CHECK_STRPTR_CONVERT],[enable_isoc=no])
+  [ACX_FC_CHECK_STRPTR_CONVERT(,[enable_isoc=no])],[enable_isoc=no])
 AM_CONDITIONAL([CREATE_ISOC],[test $enable_isoc = 'yes'])
 AC_SUBST([ENABLE_F2003_ISOC],[$enable_isoc])
 AM_SUBST_NOTMAKE([ENABLE_F2003_ISOC])
@@ -270,10 +278,10 @@ AC_ARG_ENABLE(swig,
 AM_CONDITIONAL(ENABLE_SWIG,[test "x$SWIG" != "x"])
 #  ----------------------------------------------------------------------
 #  Create the Ruby Interface via swig
-AC_ARG_ENABLE(ruby,
+#
+AC_ARG_ENABLE([ruby],
   [AS_HELP_STRING([--enable-ruby],[ruby language bindings [default=no] (EXPERIMENTAL)])],
-  [AC_CHECK_PROG(RUBY,ruby,ruby)
-   RUBY_INCLUDES="$($RUBY $srcdir/config/interface.rb)"
+  [RUBY_INCLUDES="$($RUBY $srcdir/config/interface.rb)"
    save_CPPFLAGS=$CPPFLAGS
    CPPFLAGS="$CPPFLAGS $RUBY_INCLUDES"
    AC_CHECK_HEADER([ruby.h],,[enable_ruby=no
@@ -320,9 +328,33 @@ AS_IF([test "x$enable_python" != "xno"],[AC_SUBST([ENABLE_PYTHON],[true])],[AC_S
 #  ----------------------------------------------------------------------
 AM_CONDITIONAL(CREATE_INTERFACES, [test  "x$enable_ruby" = "xyes" -o "x$enable_python" = "xyes"])
 #  ----------------------------------------------------------------------
-#  Check C / Fortran interface
-ACX_CHECK_CFINT([$srcdir/src/cfortran.h])
-AM_CONDITIONAL([USE_FC],[test -n "$FC" && test "X$FC" != "Xno" && test x$acx_cv_check_cfint = "xyes"])dnl
+#  Create the CDI Fortran77 Interface via cfortran.h
+AC_ARG_ENABLE([cf-interface],
+              [AS_HELP_STRING([--disable-cf-interface],
+                              [Omit building of cfortran Interface])],
+              [enable_cfinterface=${enableval}],[enable_cfinterface=yes])
+AS_IF([test "x${enable_cfinterface}" = "xyes"], [
+dnl ######################################################################
+dnl Test whether cfortran.h works correctly
+dnl ######################################################################
+ACX_FIND_CFORTRAN_DEF
+ACX_XLF_QEXTNAME_ADD_APPENDUS
+AS_IF([test -n "$FC" -a X"$FC" != Xno -o -n "$F77" -a X"$F77" != Xno],
+  [ACX_CHECK_CFORTRAN([$srcdir/src],
+    [AC_DEFINE([HAVE_CF_INTERFACE],[1],
+       [Defined to 1 if C / Fortran interface cfortran.h works])],
+    [AS_CASE([x"$acx_cv_cfortran_works"],
+       [x"error"],
+       [AC_MSG_NOTICE([Linking/Running with C EXTERNAL built with cfortran.h does not work!])],
+       [x"compiling with cfortran.h failed"],
+       [AC_MSG_NOTICE([Compilation with cfortran.h is not working!])],
+       [x"error compiling Fortran subroutine"],
+       [AC_MSG_NOTICE([compilation of simple Fortran source failed!])],
+       [AC_MSG_NOTICE([Unexpected error when linking C and Fortran via cfortran.h!])])
+     AC_MSG_NOTICE([Disabling cfortran.h bindings generation])
+     acx_cv_cfortran_works=no])])
+])
+AM_CONDITIONAL([USE_FC],[test -n "$FC" -a X"$FC" != Xno -a x"$acx_cv_cfortran_works" = xyes])dnl
 dnl
 AC_SUBST([CPPFLAGS])dnl
 dnl
@@ -356,6 +388,9 @@ AC_CONFIG_FILES([tests/test_cksum_grib \
                  tests/pio_write_run \
                  tests/pio_write_deco2d_run \
                  tests/pio_cksum_mpinonb \
+                 tests/pio_cksum_mpi_fw_ordered \
+                 tests/pio_cksum_mpi_fw_at_all \
+                 tests/pio_cksum_mpi_fw_at_reblock \
                  tests/pio_cksum_fpguard \
                  tests/pio_cksum_asynch \
                  tests/pio_cksum_writer \
diff --git a/libcdi/doc/cdi_cman.pdf b/libcdi/doc/cdi_cman.pdf
index 5ff9873..20571a0 100644
Binary files a/libcdi/doc/cdi_cman.pdf and b/libcdi/doc/cdi_cman.pdf differ
diff --git a/libcdi/doc/cdi_fman.pdf b/libcdi/doc/cdi_fman.pdf
index 8b936e7..0e2f0af 100644
Binary files a/libcdi/doc/cdi_fman.pdf and b/libcdi/doc/cdi_fman.pdf differ
diff --git a/libcdi/examples/Makefile.in b/libcdi/examples/Makefile.in
index e7ec26b..ad376e2 100644
--- a/libcdi/examples/Makefile.in
+++ b/libcdi/examples/Makefile.in
@@ -90,18 +90,22 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps =  \
 	$(top_srcdir)/m4/acx_assert_lang_is_fortran_variant.m4 \
 	$(top_srcdir)/m4/acx_c_package.m4 \
+	$(top_srcdir)/m4/acx_cfortran_flags.m4 \
+	$(top_srcdir)/m4/acx_check_cfortran.m4 \
 	$(top_srcdir)/m4/acx_check_strptr_convert.m4 \
 	$(top_srcdir)/m4/acx_execinfo.m4 \
 	$(top_srcdir)/m4/acx_fortran_package.m4 \
 	$(top_srcdir)/m4/acx_lang_check_include.m4 \
 	$(top_srcdir)/m4/acx_lang_other_suffix_conftest.m4 \
 	$(top_srcdir)/m4/acx_lang_package.m4 \
+	$(top_srcdir)/m4/acx_lt_problems.m4 \
 	$(top_srcdir)/m4/acx_option_search_libs.m4 \
 	$(top_srcdir)/m4/acx_options.m4 \
 	$(top_srcdir)/m4/acx_sl_fc_mod_path_flag.m4 \
 	$(top_srcdir)/m4/acx_sl_mod_suffix.m4 \
 	$(top_srcdir)/m4/asx_tr_arg.m4 $(top_srcdir)/m4/asx_unset.m4 \
-	$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
+	$(top_srcdir)/m4/ax_pthread.m4 \
+	$(top_srcdir)/m4/kpse_libtool.m4 $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/starlink_fpp.m4 \
@@ -249,7 +253,6 @@ ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
-AS = @AS@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
diff --git a/libcdi/examples/pio/Makefile.in b/libcdi/examples/pio/Makefile.in
index dee19ea..5354f78 100644
--- a/libcdi/examples/pio/Makefile.in
+++ b/libcdi/examples/pio/Makefile.in
@@ -91,18 +91,22 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps =  \
 	$(top_srcdir)/m4/acx_assert_lang_is_fortran_variant.m4 \
 	$(top_srcdir)/m4/acx_c_package.m4 \
+	$(top_srcdir)/m4/acx_cfortran_flags.m4 \
+	$(top_srcdir)/m4/acx_check_cfortran.m4 \
 	$(top_srcdir)/m4/acx_check_strptr_convert.m4 \
 	$(top_srcdir)/m4/acx_execinfo.m4 \
 	$(top_srcdir)/m4/acx_fortran_package.m4 \
 	$(top_srcdir)/m4/acx_lang_check_include.m4 \
 	$(top_srcdir)/m4/acx_lang_other_suffix_conftest.m4 \
 	$(top_srcdir)/m4/acx_lang_package.m4 \
+	$(top_srcdir)/m4/acx_lt_problems.m4 \
 	$(top_srcdir)/m4/acx_option_search_libs.m4 \
 	$(top_srcdir)/m4/acx_options.m4 \
 	$(top_srcdir)/m4/acx_sl_fc_mod_path_flag.m4 \
 	$(top_srcdir)/m4/acx_sl_mod_suffix.m4 \
 	$(top_srcdir)/m4/asx_tr_arg.m4 $(top_srcdir)/m4/asx_unset.m4 \
-	$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
+	$(top_srcdir)/m4/ax_pthread.m4 \
+	$(top_srcdir)/m4/kpse_libtool.m4 $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/starlink_fpp.m4 \
@@ -243,7 +247,6 @@ ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
-AS = @AS@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
diff --git a/libcdi/examples/pio/collectData.c b/libcdi/examples/pio/collectData.c
index f532a9d..7ee2ba1 100644
--- a/libcdi/examples/pio/collectData.c
+++ b/libcdi/examples/pio/collectData.c
@@ -38,8 +38,8 @@ static void modelRun(MPI_Comm commModel)
     nlat        = 6,
     maxlev      = 5 };
 
-  static int nlev[nVars]    = {1,1,5,5,2};
-  static char * name        = "example";
+  static int nlev[nVars]  = {1,1,5,5,2};
+  static const char *name = "example";
 
   int gridID, zaxisID[nVars], taxisID;
   int vlistID, varID[nVars], streamID, tsID, tfID = 0;
@@ -59,6 +59,9 @@ static void modelRun(MPI_Comm commModel)
   } varDeco[nVars];
 #endif
 
+#ifndef USE_MPI
+  (void)commModel;
+#endif
   gridID = gridCreate ( GRID_LONLAT, nlon*nlat );
   gridDefXsize ( gridID, nlon );
   gridDefYsize ( gridID, nlat );
@@ -79,7 +82,7 @@ static void modelRun(MPI_Comm commModel)
 #endif
   for ( i = 0; i < nVars; i++ )
     {
-      varID[i] = vlistDefVar ( vlistID, gridID, zaxisID[i], TIME_VARIABLE );
+      varID[i] = vlistDefVar ( vlistID, gridID, zaxisID[i], TIME_VARIABLE);
 #ifdef USE_MPI
       {
         int start = uniform_partition_start((int [2]){ 0, (int)varSize[i] - 1 },
@@ -155,41 +158,12 @@ static void modelRun(MPI_Comm commModel)
     zaxisDestroy ( zaxisID[i] );
   gridDestroy ( gridID );
 #ifdef USE_MPI
-  for (int varID = 0; varID < nVars; ++varID)
-    xt_idxlist_delete(varDeco[varID].partDesc);
+  for (int varIdx = 0; varIdx < nVars; ++varIdx)
+    xt_idxlist_delete(varDeco[varIdx].partDesc);
   MPI_Barrier(commModel);
 #endif
 }
 
-#ifdef USE_MPI
-static struct {
-  char *text;
-  int mode;
-} mode_map[] = {
-  { "PIO_MPI", PIO_MPI },
-  { "PIO_FPGUARD", PIO_FPGUARD },
-  { "PIO_ASYNCH", PIO_ASYNCH },
-  { "PIO_WRITER", PIO_WRITER },
-  { "PIO_FPGUARD", PIO_FPGUARD},
-};
-
-static inline int
-search_iomode_str(const char *modestr)
-{
-  int retval = -1;
-  for (size_t i = 0;
-       i < sizeof (mode_map) / sizeof (mode_map[0]);
-       ++i)
-    if (!strcmp(modestr, mode_map[i].text))
-      {
-        retval = (int)i;
-        break;
-      }
-  return retval;
-}
-#endif
-
-
 int main (int argc, char *argv[])
 {
   MPI_Comm commModel = MPI_COMM_NULL;
@@ -211,15 +185,12 @@ int main (int argc, char *argv[])
     while ((opt = getopt(argc, argv, "p:w:")) != -1)
       switch (opt) {
       case 'p':
-        {
-          int entry = search_iomode_str(optarg);
-          if (entry < 0)
-            {
-              fprintf(stderr, "Unsupported PIO mode requested: %s\n", optarg);
-              exit(EXIT_FAILURE);
-            }
-          IOMode = mode_map[entry].mode;
-        }
+        IOMode = cdiPioStr2IOMode(optarg);
+        if (IOMode < 0)
+          {
+            fprintf(stderr, "Unsupported PIO mode requested: %s\n", optarg);
+            exit(EXIT_FAILURE);
+          }
         break;
       case 'w':
         {
@@ -240,6 +211,9 @@ int main (int argc, char *argv[])
   if (commModel != MPI_COMM_NULL)
     {
       namespaceSetActive(pioNamespace);
+#else
+      (void)argc;
+      (void)argv;
 #endif
 
       modelRun(commModel);
diff --git a/libcdi/examples/pio/collectDataNStreams.c b/libcdi/examples/pio/collectDataNStreams.c
index 8f8b048..98e4098 100644
--- a/libcdi/examples/pio/collectDataNStreams.c
+++ b/libcdi/examples/pio/collectDataNStreams.c
@@ -75,6 +75,10 @@ static void modelRun(MPI_Comm commModel)
     Xt_idxlist partDesc;
   } varDeco[nStreams][nVars];
 #endif
+
+#ifndef USE_MPI
+  (void)commModel;
+#endif
   xassert ( nStreams < MAXNSTREAMS );
 
   gridID = gridCreate ( GRID_LONLAT, nlon*nlat );
@@ -99,12 +103,12 @@ static void modelRun(MPI_Comm commModel)
   xmpi ( MPI_Comm_size ( commModel, &comm_size ));
 #endif
   {
-    int maxChunkSize = 0;
+    size_t maxChunkSize = 0;
     for ( i = 0; i < nStreams; i++ )
       for ( j = 0; j < nVars; j++ )
       {
         varID[i][j] = vlistDefVar(vlistID[i], gridID, zaxisID[i][j],
-                                  TIME_VARIABLE );
+                                  TIME_VARIABLE);
         varSize[i][j] = nlon * nlat * (size_t)nlev[i][j];
 #ifdef USE_MPI
         {
@@ -112,8 +116,8 @@ static void modelRun(MPI_Comm commModel)
                                               comm_size, rank),
             chunkSize = uniform_partition_start((int [2]){ 0, (int)varSize[i][j] - 1 },
                                                 comm_size, rank + 1) - start;
-          if (maxChunkSize < chunkSize)
-            maxChunkSize = chunkSize;
+          if (maxChunkSize < (size_t)chunkSize)
+            maxChunkSize = (size_t)chunkSize;
           fprintf(stderr, "%d: start=%d, chunkSize = %d\n", rank,
                   start, chunkSize);
           Xt_idxlist idxlist
@@ -127,10 +131,10 @@ static void modelRun(MPI_Comm commModel)
         }
 #else
         if (maxChunkSize < varSize[i][j])
-          maxChunkSize = (int)varSize[i][j];
+          maxChunkSize = varSize[i][j];
 #endif
       }
-    var = (double *)malloc((size_t)maxChunkSize * sizeof (var[0]));
+    var = (double *)malloc(maxChunkSize * sizeof (var[0]));
   }
   taxisID = taxisCreate ( TAXIS_ABSOLUTE );
   for ( i = 0; i < nStreams; i++ )
@@ -205,9 +209,9 @@ static void modelRun(MPI_Comm commModel)
 
 #ifdef USE_MPI
   pioEndTimestepping ();
-  for (int streamID = 0; streamID < nStreams; ++streamID)
-    for (int varID = 0; varID < nVars; ++varID)
-      xt_idxlist_delete(varDeco[streamID][varID].partDesc);
+  for (size_t streamIdx = 0; streamIdx < (size_t)nStreams; ++streamIdx)
+    for (size_t varIdx = 0; varIdx < (size_t)nVars; ++varIdx)
+      xt_idxlist_delete(varDeco[streamIdx][varIdx].partDesc);
 #endif
 
   for ( i = 0; i < nStreams; i++ )
@@ -271,6 +275,8 @@ int main (int argc, char *argv[])
   if (commModel != MPI_COMM_NULL)
     {
       namespaceSetActive(pioNamespace);
+#else
+      (void)argc; (void)argv;
 #endif
 
       modelRun(commModel);
diff --git a/libcdi/examples/pio/compareResourcesArray.c b/libcdi/examples/pio/compareResourcesArray.c
index 1cd4459..2a3d5ad 100644
--- a/libcdi/examples/pio/compareResourcesArray.c
+++ b/libcdi/examples/pio/compareResourcesArray.c
@@ -24,9 +24,9 @@ enum {
   nlev             = 5,
   ntsteps          = 3 };
 
-double lons[nlon] = {0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330};
-double lats[nlat] = {-75, -45, -15, 15, 45, 75};
-double levs[nlev] = {101300, 92500, 85000, 50000, 20000};
+static double lons[nlon] = {0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330};
+static double lats[nlat] = {-75, -45, -15, 15, 45, 75};
+static double levs[nlev] = {101300, 92500, 85000, 50000, 20000};
 
 static int defineGrid()
 {
@@ -126,7 +126,7 @@ static int defineTaxis ()
   return taxisID;
 }
 
-void defineStream ( int streamID, int vlistID )
+static void defineStream ( int streamID, int vlistID )
 {
   streamDefByteorder ( streamID, 1 );
   streamDefCompType  ( streamID, 2 );
@@ -134,7 +134,7 @@ void defineStream ( int streamID, int vlistID )
   streamDefVlist(streamID, vlistID);
 }
 
-int defineVlist ( int gridID, int zaxisID, int taxisID )
+static int defineVlist ( int gridID, int zaxisID, int taxisID )
 {
   int vlistID = CDI_UNDEFID;
   int zaxisID2 = zaxisCreate(ZAXIS_SURFACE, 1);
@@ -204,13 +204,13 @@ static void modelRun ( MPI_Comm comm )
 
   reshPackBufferCreate(&sendBuffer, &bufferSize, &comm);
   xmpi ( MPI_Send ( sendBuffer, bufferSize, MPI_PACKED, 0, 0, comm ));
-  recvBuffer = xmalloc((size_t)bufferSize);
+  recvBuffer = Malloc((size_t)bufferSize);
   xmpi ( MPI_Recv ( recvBuffer, bufferSize, MPI_PACKED, 0,
 		    0, comm, &status ));
 
   namespaceSetActive ( 1 );
   reshUnpackResources(recvBuffer, bufferSize, &comm);
-  free ( recvBuffer );
+  Free ( recvBuffer );
   reshPackBufferDestroy ( &sendBuffer );
 
   differ = reshListCompare ( 0, 1 );
diff --git a/libcdi/interfaces/Makefile.in b/libcdi/interfaces/Makefile.in
index 646a909..0bf972d 100644
--- a/libcdi/interfaces/Makefile.in
+++ b/libcdi/interfaces/Makefile.in
@@ -97,18 +97,22 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps =  \
 	$(top_srcdir)/m4/acx_assert_lang_is_fortran_variant.m4 \
 	$(top_srcdir)/m4/acx_c_package.m4 \
+	$(top_srcdir)/m4/acx_cfortran_flags.m4 \
+	$(top_srcdir)/m4/acx_check_cfortran.m4 \
 	$(top_srcdir)/m4/acx_check_strptr_convert.m4 \
 	$(top_srcdir)/m4/acx_execinfo.m4 \
 	$(top_srcdir)/m4/acx_fortran_package.m4 \
 	$(top_srcdir)/m4/acx_lang_check_include.m4 \
 	$(top_srcdir)/m4/acx_lang_other_suffix_conftest.m4 \
 	$(top_srcdir)/m4/acx_lang_package.m4 \
+	$(top_srcdir)/m4/acx_lt_problems.m4 \
 	$(top_srcdir)/m4/acx_option_search_libs.m4 \
 	$(top_srcdir)/m4/acx_options.m4 \
 	$(top_srcdir)/m4/acx_sl_fc_mod_path_flag.m4 \
 	$(top_srcdir)/m4/acx_sl_mod_suffix.m4 \
 	$(top_srcdir)/m4/asx_tr_arg.m4 $(top_srcdir)/m4/asx_unset.m4 \
-	$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
+	$(top_srcdir)/m4/ax_pthread.m4 \
+	$(top_srcdir)/m4/kpse_libtool.m4 $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/starlink_fpp.m4 \
@@ -227,7 +231,6 @@ ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
-AS = @AS@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
diff --git a/libcdi/interfaces/f2003/bindGen.rb b/libcdi/interfaces/f2003/bindGen.rb
index b643f47..deecd4e 100755
--- a/libcdi/interfaces/f2003/bindGen.rb
+++ b/libcdi/interfaces/f2003/bindGen.rb
@@ -55,7 +55,7 @@
 #	:returnAs	The type of the fortran wrapper function.
 #	:helperVars	Declarations of additional variables needed to provide the desired functionality in the wrapper function.
 #	:precallStatements	Code that needs to be executed before the C function is called.
-#	:recieveAs	The type of the `bind(c)` interface function.
+#	:receiveAs	The type of the `bind(c)` interface function.
 #	:assignVariable	The expression that the result of the C function is assigned to.
 #	:postcallStatements	Code that needs to be executed after the C function returns.
 #
@@ -77,7 +77,7 @@
 #		:acceptAs...
 #		:helperVars...
 #		interface
-#			:recieveAs function lib_fname(:dummyName...) bind(c, name = 'fname')
+#			:receiveAs function lib_fname(:dummyName...) bind(c, name = 'fname')
 #				import <importConstants>
 #				:passAs...
 #			end function lib_fname
@@ -105,226 +105,354 @@
 #		:postcallStatements
 #	end subroutine fname
 
+$debug = 0
+$wrapperResultVarName = 'f_result'
+
 ####################################################################################################
 # Template definitions #############################################################################
 ####################################################################################################
 
-$argumentTemplates = [
-	{	#Dummy for declarations using foo(void).
-		:regex => '^\s*void\s*$',
-		:placeholders => %w[],
-		:dummyName => '',
-		:acceptAs => '',
-		:helperVars => '',
-		:precallStatements => '',
-		:callExpression => '',
-		:passAs => '',
-		:postcallStatements => ''
-	}, {	#<integerTypes>
-		:regex => '^\s*(?<type><integerTypes>)\s+(?<name>\w+)\s*$',
-		:placeholders => %w[name type],
-		:dummyName => '<name>_dummy',
-		:acceptAs => 'integer(c_<type>), value :: <name>_dummy',
-		:helperVars => '',
-		:precallStatements => '',
-		:callExpression => '<name>_dummy',
-		:passAs => 'integer(c_<type>), value :: <name>_dummy',
-		:postcallStatements => ''
-	}, {	#<floatTypes>
-		:regex => '^\s*(?<type><floatTypes>)\s+(?<name>\w+)\s*$',
-		:placeholders => %w[name type],
-		:dummyName => '<name>_dummy',
-		:acceptAs => 'real(c_<type>), value :: <name>_dummy',
-		:helperVars => '',
-		:precallStatements => '',
-		:callExpression => '<name>_dummy',
-		:passAs => 'real(c_<type>), value :: <name>_dummy',
-		:postcallStatements => ''
-	},
-	#Array arguments. These are marked by a `_vec` suffix by convention.
-	#Since it's near impossible to write regexs that only match names that do *not* end in a given suffix,
-	#these templates must precede the more general templates for pointer arguments.
-	#That way, we can override the more general template with the more special one if both match.
-	{	#<integerTypes>* <name>_vec
-		:regex => '^\s*(?<type><integerTypes>)\s*\*\s*(?<name>\w+_vec)\s*$',
-		:placeholders => %w[name type],
-		:dummyName => '<name>_dummy',
-		:acceptAs => 'integer(c_<type>), intent(inout) :: <name>_dummy(*)',
-		:helperVars => "",
-		:precallStatements => "",
-		:callExpression => '<name>_dummy',
-		:passAs => 'integer(c_<type>), intent(inout) :: <name>_dummy(*)',
-		:postcallStatements => ""
-	}, {	#<floatTypes>* <name>_vec
-		:regex => '^\s*(?<type><floatTypes>)\s*\*\s*(?<name>\w+_vec)\s*$',
-		:placeholders => %w[name type],
-		:dummyName => '<name>_dummy',
-		:acceptAs => 'real(c_<type>), intent(inout) :: <name>_dummy(*)',
-		:helperVars => "",
-		:precallStatements => "",
-		:callExpression => '<name>_dummy',
-		:passAs => 'real(c_<type>), intent(inout) :: <name>_dummy(*)',
-		:postcallStatements => ""
-	}, {	#unsigned char <name>[<size>]
-		:regex => '^\s*unsigned\s+char\s+(?<name>\w+)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$',
-		:placeholders => %w[name size],
-		:dummyName => '<name>_dummy',
-		:acceptAs => 'character(kind = c_char), intent(inout) :: <name>_dummy(<size>)',
-		:helperVars => "",
-		:precallStatements => "",
-		:callExpression => '<name>_dummy',
-		:passAs => 'character(kind = c_char), intent(inout) :: <name>_dummy(*)',
-		:postcallStatements => ""
-	}, {	#const <integerTypes>* <name>_vec
-		:regex => '^\s*const\s+(?<type><integerTypes>)\s*\*\s*(?<name>\w+_vec)\s*$',
-		:placeholders => %w[name type],
-		:dummyName => '<name>_dummy',
-		:acceptAs => 'integer(c_<type>), intent(in) :: <name>_dummy(*)',
-		:helperVars => "",
-		:precallStatements => "",
-		:callExpression => '<name>_dummy',
-		:passAs => 'integer(c_<type>), intent(in) :: <name>_dummy(*)',
-		:postcallStatements => ""
-	}, {	#const <floatTypes>* <name>_vec
-		:regex => '^\s*const\s+(?<type><floatTypes>)\s*\*\s*(?<name>\w+_vec)\s*$',
-		:placeholders => %w[name type],
-		:dummyName => '<name>_dummy',
-		:acceptAs => 'real(c_<type>), intent(in) :: <name>_dummy(*)',
-		:helperVars => "",
-		:precallStatements => "",
-		:callExpression => '<name>_dummy',
-		:passAs => 'real(c_<type>), intent(in) :: <name>_dummy(*)',
-		:postcallStatements => ""
-	}, {	#const unsigned char <name>[<size>]
-		:regex => '^\s*(const\s+unsigned\s+char|unsigned\s+char\s+const)\s+(?<name>\w+)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$',
-		:placeholders => %w[name size],
-		:dummyName => '<name>_dummy',
-		:acceptAs => 'character(kind = c_char), intent(in) :: <name>_dummy(<size>)',
-		:helperVars => "",
-		:precallStatements => "",
-		:callExpression => '<name>_dummy',
-		:passAs => 'character(kind = c_char), intent(in) :: <name>_dummy(*)',
-		:postcallStatements => ""
-	}, {	#const <integerTypes> <name>[<lineCount>][<lineSize>]
-		:regex => '^\s*const\s+(?<type><integerTypes>)\s+(?<name>\w+)\s*\[\s*(?<lineCount>[^\]]+)\s*\]\s*\[\s*(?<lineSize>[^\]]+)\s*\]\s*$',
-		:placeholders => %w[name type lineCount lineSize],
-		:dummyName => '<name>_dummy',
-		:acceptAs => 'integer(c_<type>), intent(in) :: <name>_dummy(<lineSize>, <lineCount>)',
-		:helperVars => "",
-		:precallStatements => "",
-		:callExpression => '<name>_dummy',
-		:passAs => 'integer(c_<type>), intent(in) :: <name>_dummy(*)',
-		:postcallStatements => ""
-	},
-	#Pointer arguments. These match both pointers and arrays, so they must appear after the more special array templates.
-	#Most of these are wrapped by optional arguments which have to be named in calling code, which is why we don't use the _dummy suffix for them.
-	{	#<integerTypes>*
-		:regex => '^\s*(?<type><integerTypes>)\s*\*\s*(?<name>\w+)\s*$',
-		:placeholders => %w[name type],
-		:dummyName => '<name>',
-		:acceptAs => 'integer(c_<type>), optional, intent(inout) :: <name>',
-		:helperVars => "integer(c_<type>), target :: <name>_temp\ntype(c_ptr) :: <name>_ptr",
-		:precallStatements => "<name>_ptr = c_null_ptr\nif(present(<name>)) <name>_ptr = c_loc(<name>_temp)",
-		:callExpression => '<name>_ptr',
-		:passAs => 'type(c_ptr), value :: <name>',
-		:postcallStatements => "if(present(<name>)) <name> = <name>_temp"
-	}, {	#<floatTypes>*
-		:regex => '^\s*(?<type><floatTypes>)\s*\*\s*(?<name>\w+)\s*$',
-		:placeholders => %w[name type],
-		:dummyName => '<name>',
-		:acceptAs => 'real(c_<type>), optional, intent(inout) :: <name>',
-		:helperVars => "real(c_<type>), target :: <name>_temp\ntype(c_ptr) :: <name>_ptr",
-		:precallStatements => "<name>_ptr = c_null_ptr\nif(present(<name>)) <name>_ptr = c_loc(<name>_temp)",
-		:callExpression => '<name>_ptr',
-		:passAs => 'type(c_ptr), value :: <name>',
-		:postcallStatements => "if(present(<name>)) <name> = <name>_temp"
-	}, {	#unsigned char (*<name>)[<size>]
-		:regex => '^\s*unsigned\s+char\s*\(\s*\*\s*(?<name>\w+)\s*\)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$',
-		:placeholders => %w[name size],
-		:dummyName => '<name>',
-		:acceptAs => 'character(kind = c_char), optional, intent(inout) :: <name>(<size>)',
-		:helperVars => "character(kind = c_char), target :: <name>_temp(<size>)\ntype(c_ptr) :: <name>_ptr",
-		:precallStatements => "<name>_ptr = c_null_ptr\nif(present(<name>)) <name>_ptr = c_loc(<name>_temp)",
-		:callExpression => '<name>_ptr',
-		:passAs => 'type(c_ptr), value :: <name>',
-		:postcallStatements => "if(present(<name>)) <name> = <name>_temp"
-	},
-	#String arguments.
-	{	#char*	Unsafe buffer passing
-		:regex => '^\s*char\s*\*\s*(?<name>\w+)\s*$',
-		:placeholders => %w[name],
-		:dummyName => '<name>_dummy',
-		:acceptAs => 'character(kind = c_char, len = *), intent(inout) :: <name>_dummy',
-		:helperVars => "character(kind = c_char) :: <name>_temp(len(<name>_dummy))\n" +
-		               "integer :: <name>_i\n" +
-		               "logical :: <name>_padding = .true.",
-		:precallStatements => "do <name>_i = len(<name>_dummy), 1, -1\n" +
-		                      "\tif(<name>_dummy(<name>_i:<name>_i) /= ' ') <name>_padding = .false.\n" +
-		                      "\tif(<name>_padding) then\n" +
-		                      "\t\t<name>_temp(<name>_i) = c_null_char\n" +
-		                      "\telse\n" +
-		                      "\t\t<name>_temp(<name>_i) = <name>_dummy(<name>_i:<name>_i)\n" +
-		                      "\tend if\n" +
-		                      "end do",
-		:callExpression => '<name>_temp',
-		:passAs => 'character(kind = c_char) :: <name>_dummy(*)',
-		:postcallStatements => "<name>_padding = .false.\n" +
-		                       "do <name>_i = 1, len(<name>_dummy)\n" +
-		                       "\tif(<name>_temp(<name>_i) == c_null_char) <name>_padding = .true.\n" +
-		                       "\tif(<name>_padding) then\n" +
-		                       "\t\t<name>_dummy(<name>_i:<name>_i) = ' '\n" +
-		                       "\telse\n" +
-		                       "\t\t<name>_dummy(<name>_i:<name>_i) = <name>_temp(<name>_i)\n" +
-		                       "\tend if\n" +
-		                       "end do"
-	}, {	#const char*	Safe passing of an input string.
-		:regex => '^\s*(const\s+char|char\sconst)\s*\*\s*(?<name>\w+)\s*$',
-		:placeholders => %w[name],
-		:dummyName => '<name>_dummy',
-		:acceptAs => 'character(kind = c_char, len = *), intent(in) :: <name>_dummy',
-		:helperVars => "character(kind = c_char) :: <name>_temp(len(<name>_dummy) + 1)\ninteger :: <name>_i",
-		:precallStatements => "do <name>_i = 1, len(<name>_dummy)\n<name>_temp(<name>_i) = <name>_dummy(<name>_i:<name>_i)\nend do\n<name>_temp(len(<name>_dummy) + 1) = c_null_char",
-		:callExpression => '<name>_temp',
-		:passAs => 'character(kind = c_char) :: <name>_dummy(*)',
-		:postcallStatements => ''
-	}, {	#char**	Safe returning of an output string.
-		:regex => '^\s*char\s*\*\s*\*\s*(?<name>\w+)\s*$',
-		:placeholders => %w[name],
-		:dummyName => '<name>',
-		:acceptAs => 'character(kind = c_char), pointer, optional, intent(inout) :: <name>(:)',
-		:helperVars => "type(c_ptr), target :: <name>_ptr\n" +
-		               "type(c_ptr) :: <name>_handle\n" +
-		               "integer :: <name>_shape(1)\n" +
-		               "character(kind = c_char), pointer :: <name>_fptr(:)",
-		:precallStatements => "<name>_handle = c_null_ptr\n" +
-		                      "if(present(<name>)) <name>_handle = c_loc(<name>_ptr)",
-		:callExpression => '<name>_handle',
-		:passAs => 'type(c_ptr), value :: <name>',
-		:postcallStatements => "if(present(<name>)) then\n" +
-		                       "\tif(c_associated(<name>_ptr)) then\n" +
-		                       "\t\t<name>_shape(1) = int(lib_strlen(<name>_ptr))\n" +
-		                       "\t\tcall c_f_pointer(<name>_ptr, <name>_fptr, <name>_shape)\n" +
-		                       "\t\tallocate(<name>(<name>_shape(1)))\n" +
-		                       "\t\t<name> = <name>_fptr\n" +
-		                       "\t\tcall lib_free(<name>_ptr)\n" +
-		                       "\telse\n" +
-		                       "\t\t<name> => null()\n" +
-		                       "\tend if\n" +
-		                       "end if"
-	},
-	#Public and opaque types
-	{	#[const] <opaqueTypes>*
-		:regex => '^\s*(const\s+|)(?<type><opaqueTypes>)(\s+const|)\s*\*\s*(?<name>\w+)\s*$',
-		:placeholders => %w[name type],
-		:dummyName => '<name>_dummy',
-		:acceptAs => 'type(t_<type>), intent(in) :: <name>_dummy',
-		:helperVars => '',
-		:precallStatements => '',
-		:callExpression => '<name>_dummy%ptr',
-		:passAs => 'type(c_ptr), value :: <name>_dummy',
-		:postcallStatements => ''
-	}
-]
+$argumentTemplates =
+	[
+	 {	#Dummy for declarations using foo(void).
+		 :regex => '^\s*void\s*$',
+		 :placeholders => %w[],
+		 :dummyName => '',
+		 :acceptAs => '',
+		 :helperVars => '',
+		 :precallStatements => '',
+		 :callExpression => '',
+		 :passAs => '',
+		 :postcallStatements => ''
+	 }, {	#<integerTypes>
+		 :regex => '^\s*(?<type><integerTypes>)\s+(?<name>\w+)\s*$',
+		 :placeholders => %w[name type],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'integer(c_<type>), value :: <name>_dummy',
+		 :helperVars => '',
+		 :precallStatements => '',
+		 :callExpression => '<name>_dummy',
+		 :passAs => 'integer(c_<type>), value :: <name>_dummy',
+		 :postcallStatements => ''
+	 }, {	#<floatTypes>
+		 :regex => '^\s*(?<type><floatTypes>)\s+(?<name>\w+)\s*$',
+		 :placeholders => %w[name type],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'real(c_<type>), value :: <name>_dummy',
+		 :helperVars => '',
+		 :precallStatements => '',
+		 :callExpression => '<name>_dummy',
+		 :passAs => 'real(c_<type>), value :: <name>_dummy',
+		 :postcallStatements => ''
+	 },
+	 #Optional pointer arguments. These are wrapped by optional
+	 #arguments which have to be named in calling code, which is why we
+	 #don't use the _dummy suffix for them.
+	 {	#<integerTypes>*
+		 :regex => '^\s*(?<type><integerTypes>)\s*\*\s*(?<name>\w+)_optional\s*$',
+		 :placeholders => %w[name type],
+		 :dummyName => '<name>',
+		 :acceptAs => 'integer(c_<type>), optional, target, intent(inout) :: <name>',
+		 :helperVars => "type(c_ptr) :: <name>_cptr",
+		 :precallStatements => "<name>_cptr = c_null_ptr\nif(present(<name>)) <name>_cptr = c_loc(<name>)",
+		 :callExpression => '<name>_cptr',
+		 :passAs => 'type(c_ptr), value :: <name>',
+		 :postcallStatements => ""
+	 },
+	 {	#<floatTypes>*
+		 :regex => '^\s*(?<type><floatTypes>)\s*\*\s*(?<name>\w+)_optional\s*$',
+		 :placeholders => %w[name type],
+		 :dummyName => '<name>',
+		 :acceptAs => 'real(c_<type>), target, optional, intent(inout) :: <name>',
+		 :helperVars => "type(c_ptr) :: <name>_cptr",
+		 :precallStatements => "<name>_cptr = c_null_ptr\nif(present(<name>)) <name>_cptr = c_loc(<name>)",
+		 :callExpression => '<name>_cptr',
+		 :passAs => 'type(c_ptr), value :: <name>',
+		 :postcallStatements => ""
+	 },
+	 {	#unsigned char (*<name>)[<size>]
+		 :regex => '^\s*unsigned\s+char\s*\(\s*\*\s*(?<name>\w+)_optional\s*\)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$',
+		 :placeholders => %w[name size],
+		 :dummyName => '<name>',
+		 :acceptAs => 'integer(kind = c_signed_char), target, optional, intent(inout) :: <name>(<size>)',
+		 :helperVars => "type(c_ptr) :: <name>_cptr",
+		 :precallStatements => "<name>_cptr = c_null_ptr\nif(present(<name>)) <name>_cptr = c_loc(<name>)",
+		 :callExpression => '<name>_cptr',
+		 :passAs => 'type(c_ptr), value :: <name>',
+		 :postcallStatements => ""
+	 },
+	 {	#<integerTypes> []
+		 :regex => '^\s*(?<type><integerTypes>)\s*(?<name>\w+)_optional\[\]\s*$',
+		 :placeholders => %w[name type],
+		 :dummyName => '<name>',
+		 :acceptAs => 'integer(c_<type>), target, optional, intent(inout) :: <name>(*)',
+		 :helperVars => "type(c_ptr) :: <name>_cptr",
+		 :precallStatements => "<name>_cptr = c_null_ptr\nif(present(<name>)) <name>_cptr = c_loc(<name>)",
+		 :callExpression => '<name>_cptr',
+		 :passAs => 'type(c_ptr), value :: <name>',
+		 :postcallStatements => ""
+	 }, {	#<floatTypes> []
+		 :regex => '^\s*(?<type><floatTypes>)\s*(?<name>\w+)_optional\[\]\s*$',
+		 :placeholders => %w[name type],
+		 :dummyName => '<name>',
+		 :acceptAs => 'real(c_<type>), target, optional, intent(inout) :: <name>(*)',
+		 :helperVars => "type(c_ptr) :: <name>_cptr",
+		 :precallStatements => "<name>_cptr = c_null_ptr\nif(present(<name>)) <name>_cptr = c_loc(<name>)",
+		 :callExpression => '<name>_cptr',
+		 :passAs => 'type(c_ptr), value :: <name>',
+		 :postcallStatements => ""
+	 }, {	#unsigned char <name>[<size>]
+		 :regex => '^\s*unsigned\s+char\s*(?<name>\w+)_optional\s*\[\s*(?<size>[^\]]+)\s*\]\s*$',
+		 :placeholders => %w[name size],
+		 :dummyName => '<name>',
+		 :acceptAs => 'integer(kind = c_signed_char), target, optional, intent(inout) :: <name>(<size>)',
+		 :helperVars => "type(c_ptr) :: <name>_cptr",
+		 :precallStatements => "<name>_cptr = c_null_ptr\nif(present(<name>)) <name>_cptr = c_loc(<name>)",
+		 :callExpression => '<name>_cptr',
+		 :passAs => 'type(c_ptr), value :: <name>',
+		 :postcallStatements => ""
+	 },
+	 {	#optional char *
+		 :regex => '^\s*char\s*(?:\*\s*(?<name>\w+)_optional|(?<name>\w+)_optional\[\])\s*$',
+		 :placeholders => %w[name],
+		 :dummyName => '<name>',
+		 :acceptAs => 'character(kind = c_char, len = *), optional, intent(inout) :: <name>',
+		 :helperVars => "character(kind = c_char), allocatable, target :: <name>_temp(:)\n" +
+		 "integer :: <name>_i\n" +
+		 "type(c_ptr) :: <name>_cptr",
+		 :precallStatements => "if (present(<name>)) then\n" +
+		 "\tallocate(<name>_temp(len(<name>) + 1))\n" +
+		 "\t<name>_temp(len(<name>) + 1) = c_null_char\n" +
+		 "\tdo <name>_i = len(<name>), 1, -1\n" +
+		 "\t\tif(<name>(<name>_i:<name>_i) /= ' ') exit\n" +
+		 "\t\t<name>_temp(<name>_i) = c_null_char\n" +
+		 "\tend do\n" +
+		 "\tdo <name>_i = <name>_i, 1, -1\n" +
+		 "\t\t\t<name>_temp(<name>_i) = <name>(<name>_i:<name>_i)\n" +
+		 "\tend do\n" +
+		 "\t<name>_cptr = c_loc(<name>_temp)\n" +
+		 "else\n" +
+		 "\t<name>_cptr = c_null_ptr\n" +
+		 "end if",
+		 :callExpression => '<name>_cptr',
+		 :passAs => 'type(c_ptr), value :: <name>',
+		 :postcallStatements => "if (present(<name>)) then\n" +
+		 "\tdo <name>_i = 1, len(<name>)\n" +
+		 "\t\tif(<name>_temp(<name>_i) == c_null_char) exit\n" +
+		 "\t\t<name>(<name>_i:<name>_i) = <name>_temp(<name>_i)\n" +
+		 "\tend do\n" +
+		 "\tdo <name>_i = <name>_i, len(<name>)\n" +
+		 "\t\t<name>(<name>_i:<name>_i) = ' '\n" +
+		 "\tend do\n" +
+		 "end if"
+	 },
+	 {	#optional const char *
+		 :regex => '^\s*const\s+char\s*(?:\*\s*(?<name>\w+)_optional|(?<name>\w+)_optional\[\])\s*$',
+		 :placeholders => %w[name],
+		 :dummyName => '<name>',
+		 :acceptAs => 'character(kind = c_char, len = *), optional, intent(in) :: <name>',
+		 :helperVars => "character(kind = c_char), allocatable, target :: <name>_temp(:)\n" +
+		 "integer :: <name>_i\n" +
+		 "type(c_ptr) :: <name>_cptr",
+		 :precallStatements => "if (present(<name>)) then\n" +
+		 "\tallocate(<name>_temp(len(<name>) + 1))\n" +
+		 "\t<name>_temp(len(<name>) + 1) = c_null_char\n" +
+		 "\tdo <name>_i = len(<name>), 1, -1\n" +
+		 "\t\tif(<name>(<name>_i:<name>_i) /= ' ') exit\n" +
+		 "\t\t<name>_temp(<name>_i) = c_null_char\n" +
+		 "\tend do\n" +
+		 "\tdo <name>_i = <name>_i, 1, -1\n" +
+		 "\t\t\t<name>_temp(<name>_i) = <name>(<name>_i:<name>_i)\n" +
+		 "\tend do\n" +
+		 "\t<name>_cptr = c_loc(<name>_temp)\n" +
+		 "else\n" +
+		 "\t<name>_cptr = c_null_ptr\n" +
+		 "end if",
+		 :callExpression => '<name>_cptr',
+		 :passAs => 'type(c_ptr), value :: <name>',
+		 :postcallStatements => ""
+	 },
+	 #Array arguments. These are marked by a `_vec` suffix by convention.
+	 #Since it's near impossible to write regexs that only match names that do *not* end in a given suffix,
+	 #these templates must precede the more general templates for pointer arguments.
+	 #That way, we can override the more general template with the more special one if both match.
+	 {	#<integerTypes>* <name>_vec
+		 :regex => '^\s*(?<type><integerTypes>)\s*(?:\*\s*(?<name>\w+_vec)|(?<name>\w+)\[\])\s*$',
+		 :placeholders => %w[name type],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'integer(c_<type>), intent(inout) :: <name>_dummy(*)',
+		 :helperVars => "",
+		 :precallStatements => "",
+		 :callExpression => '<name>_dummy',
+		 :passAs => 'integer(c_<type>), intent(inout) :: <name>_dummy(*)',
+		 :postcallStatements => ""
+	 }, {	#<floatTypes>* <name>_vec
+		 :regex => '^\s*(?<type><floatTypes>)\s*(?:\*\s*(?<name>\w+_vec)|(?<name>\w+)\[\])\s*$',
+		 :placeholders => %w[name type],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'real(c_<type>), intent(inout) :: <name>_dummy(*)',
+		 :helperVars => "",
+		 :precallStatements => "",
+		 :callExpression => '<name>_dummy',
+		 :passAs => 'real(c_<type>), intent(inout) :: <name>_dummy(*)',
+		 :postcallStatements => ""
+	 }, {	#unsigned char <name>[<size>]
+		 :regex => '^\s*unsigned\s+char\s+(?<name>\w+)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$',
+		 :placeholders => %w[name size],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'integer(kind = c_signed_char), intent(inout) :: <name>_dummy(<size>)',
+		 :helperVars => "",
+		 :precallStatements => "",
+		 :callExpression => '<name>_dummy',
+		 :passAs => 'integer(kind = c_signed_char), intent(inout) :: <name>_dummy(<size>)',
+		 :postcallStatements => ""
+	 }, {	#const <integerTypes>* <name>_vec
+		 :regex => '^\s*const\s+(?<type><integerTypes>)\s*(?:\*\s*(?<name>\w+_vec)|(?<name>\w+)\[\])\s*$',
+		 :placeholders => %w[name type],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'integer(c_<type>), intent(in) :: <name>_dummy(*)',
+		 :helperVars => "",
+		 :precallStatements => "",
+		 :callExpression => '<name>_dummy',
+		 :passAs => 'integer(c_<type>), intent(in) :: <name>_dummy(*)',
+		 :postcallStatements => ""
+	 }, {	#const <floatTypes>* <name>_vec
+		 :regex => '^\s*const\s+(?<type><floatTypes>)\s*(?:\*\s*(?<name>\w+_vec)|(?<name>\w+)\[\])\s*$',
+		 :placeholders => %w[name type],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'real(c_<type>), intent(in) :: <name>_dummy(*)',
+		 :helperVars => "",
+		 :precallStatements => "",
+		 :callExpression => '<name>_dummy',
+		 :passAs => 'real(c_<type>), intent(in) :: <name>_dummy(*)',
+		 :postcallStatements => ""
+	 }, {	#const unsigned char <name>[<size>]
+		 :regex => '^\s*(const\s+unsigned\s+char|unsigned\s+char\s+const)\s+(?<name>\w+)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$',
+		 :placeholders => %w[name size],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'integer(kind = c_signed_char), intent(in) :: <name>_dummy(<size>)',
+		 :helperVars => "",
+		 :precallStatements => "",
+		 :callExpression => '<name>_dummy',
+		 :passAs => 'integer(kind = c_signed_char), intent(in) :: <name>_dummy(<size>)',
+		 :postcallStatements => ""
+	 }, {	#const <integerTypes> <name>[<lineCount>][<lineSize>]
+		 :regex => '^\s*const\s+(?<type><integerTypes>)\s+(?<name>\w+)\s*\[\s*(?<lineCount>[^\]]+)\s*\]\s*\[\s*(?<lineSize>[^\]]+)\s*\]\s*$',
+		 :placeholders => %w[name type lineCount lineSize],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'integer(c_<type>), intent(in) :: <name>_dummy(<lineSize>, <lineCount>)',
+		 :helperVars => "",
+		 :precallStatements => "",
+		 :callExpression => '<name>_dummy',
+		 :passAs => 'integer(c_<type>), intent(in) :: <name>_dummy(<lineSize>, <lineCount>)',
+		 :postcallStatements => ""
+	 },
+	 #Non-optional pointer arguments. These match both pointers and
+	 #arrays, so they must appear after the more special array templates.
+	 {	#<integerTypes>*
+		 :regex => '^\s*(?<type><integerTypes>)\s*\*\s*(?<name>\w+)\s*$',
+		 :placeholders => %w[name type],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'integer(c_<type>), intent(inout) :: <name>_dummy',
+		 :helperVars => "",
+		 :precallStatements => "",
+		 :callExpression => '<name>_dummy',
+		 :passAs => 'integer(c_<type>), intent(inout) :: <name>_dummy',
+		 :postcallStatements => ""
+	 }, {	#<floatTypes>*
+		 :regex => '^\s*(?<type><floatTypes>)\s*\*\s*(?<name>\w+)\s*$',
+		 :placeholders => %w[name type],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'real(c_<type>), intent(inout) :: <name>_dummy',
+		 :helperVars => "",
+		 :precallStatements => "",
+		 :callExpression => '<name>_dummy',
+		 :passAs => 'real(c_<type>), intent(inout) :: <name>_dummy',
+		 :postcallStatements => ""
+	 }, {	#unsigned char (*<name>)[<size>]
+		 :regex => '^\s*unsigned\s+char\s*\(\s*\*\s*(?<name>\w+)\s*\)\s*\[\s*(?<size>[^\]]+)\s*\]\s*$',
+		 :placeholders => %w[name size],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'integer(kind = c_signed_char), intent(inout) :: <name>(<size>)',
+		 :helperVars => "",
+		 :precallStatements => "",
+		 :callExpression => '<name>_dummy',
+		 :passAs => 'integer(kind = c_signed_char), intent(inout) :: <name>(<size>)',
+		 :postcallStatements => ""
+	 },
+	 #String arguments.
+	 {	#char*	Unsafe buffer passing
+		 :regex => '^\s*char\s*\*\s*(?<name>\w+)\s*$',
+		 :placeholders => %w[name],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'character(kind = c_char, len = *), intent(inout) :: <name>_dummy',
+		 :helperVars => "character(kind = c_char) :: <name>_temp(len(<name>_dummy) + 1)\n" +
+		 "integer :: <name>_i",
+		 :precallStatements => "<name>_temp(len(<name>_dummy) + 1) = c_null_char\n" +
+		 "do <name>_i = len(<name>_dummy), 1, -1\n" +
+		 "\tif(<name>_dummy(<name>_i:<name>_i) /= ' ') exit\n" +
+		 "\t<name>_temp(<name>_i) = c_null_char\n" +
+		 "end do\n" +
+		 "do <name>_i = <name>_i, 1, -1\n" +
+		 "\t\t<name>_temp(<name>_i) = <name>_dummy(<name>_i:<name>_i)\n" +
+		 "end do",
+		 :callExpression => '<name>_temp',
+		 :passAs => 'character(kind = c_char) :: <name>_dummy(*)',
+		 :postcallStatements => "do <name>_i = 1, len(<name>_dummy)\n" +
+		 "\tif(<name>_temp(<name>_i) == c_null_char) exit\n" +
+		 "\t<name>_dummy(<name>_i:<name>_i) = <name>_temp(<name>_i)\n" +
+		 "end do\n" +
+		 "do <name>_i = <name>_i, len(<name>_dummy)\n" +
+		 "\t<name>_dummy(<name>_i:<name>_i) = ' '\n" +
+		 "end do"
+	 }, {	#const char*	Safe passing of an input string.
+		 :regex => '^\s*(const\s+char|char\s+const)\s*\*\s*(?<name>\w+)\s*$',
+		 :placeholders => %w[name],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'character(kind = c_char, len = *), intent(in) :: <name>_dummy',
+		 :helperVars => "character(kind = c_char) :: <name>_temp(len(<name>_dummy) + 1)\ninteger :: <name>_i",
+		 :precallStatements => "do <name>_i = 1, len(<name>_dummy)\n\t<name>_temp(<name>_i) = <name>_dummy(<name>_i:<name>_i)\nend do\n<name>_temp(len(<name>_dummy) + 1) = c_null_char",
+		 :callExpression => '<name>_temp',
+		 :passAs => 'character(kind = c_char) :: <name>_dummy(*)',
+		 :postcallStatements => ''
+	 }, {	#char**	Safe returning of an output string.
+		 :regex => '^\s*char\s*\*\s*\*\s*(?<name>\w+)_optional\s*$',
+		 :placeholders => %w[name],
+		 :dummyName => '<name>',
+		 :acceptAs => 'character(kind = c_char), pointer, optional, intent(inout) :: <name>(:)',
+		 :helperVars => "type(c_ptr), target :: <name>_cptr\n" +
+		 "type(c_ptr) :: <name>_handle\n" +
+		 "integer :: <name>_shape(1)\n" +
+		 "character(kind = c_char), pointer :: <name>_fptr(:)",
+		 :precallStatements => "<name>_handle = c_null_ptr\n" +
+		 "if(present(<name>)) <name>_handle = c_loc(<name>_cptr)",
+		 :callExpression => '<name>_handle',
+		 :passAs => 'type(c_ptr), value :: <name>',
+		 :postcallStatements => "if(present(<name>)) then\n" +
+		 "\tif(c_associated(<name>_cptr)) then\n" +
+		 "\t\t<name>_shape(1) = int(lib_strlen(<name>_cptr))\n" +
+		 "\t\tcall c_f_pointer(<name>_cptr, <name>_fptr, <name>_shape)\n" +
+		 "\t\tallocate(<name>(<name>_shape(1)))\n" +
+		 "\t\t<name> = <name>_fptr\n" +
+		 "\t\tcall lib_free(<name>_cptr)\n" +
+		 "\telse\n" +
+		 "\t\t<name> => null()\n" +
+		 "\tend if\n" +
+		 "end if"
+	 },
+	 #Public and opaque types
+	 {	#[const] <opaqueTypes>*
+		 :regex => '^\s*(const\s+|)(?<type><opaqueTypes>)(\s+const|)\s*\*\s*(?<name>\w+)\s*$',
+		 :placeholders => %w[name type],
+		 :dummyName => '<name>_dummy',
+		 :acceptAs => 'type(t_<type>), intent(in) :: <name>_dummy',
+		 :helperVars => '',
+		 :precallStatements => '',
+		 :callExpression => '<name>_dummy%ptr',
+		 :passAs => 'type(c_ptr), value :: <name>_dummy',
+		 :postcallStatements => ''
+	 }
+	]
 
 $returnTypeTemplates = [
 	{	#void
@@ -338,8 +466,8 @@ $returnTypeTemplates = [
 		:returnAs => 'integer(c_<type>)',
 		:helperVars => '',
 		:precallStatements => '',
-		:recieveAs => 'integer(c_<type>)',
-		:assignVariable => 'result',
+		:receiveAs => 'integer(c_<type>)',
+		:assignVariable => $wrapperResultVarName,
 		:postcallStatements => ''
 	}, {	#<floatTypes>
 		:regex => '^\s*(?<type><floatTypes>)\s*$',
@@ -348,8 +476,8 @@ $returnTypeTemplates = [
 		:returnAs => 'real(c_<type>)',
 		:helperVars => '',
 		:precallStatements => '',
-		:recieveAs => 'real(c_<type>)',
-		:assignVariable => 'result',
+		:receiveAs => 'real(c_<type>)',
+		:assignVariable => $wrapperResultVarName,
 		:postcallStatements => ''
 	}, {	#char*
 		:regex => '^\s*char\s*\*\s*$',
@@ -357,32 +485,32 @@ $returnTypeTemplates = [
 		:isVoid => false,
 		:returnAs => 'character(kind = c_char), dimension(:), pointer',
 		:helperVars => "type(c_ptr) :: cString\n" +
-		               "integer :: shape(1)\n" +
+		               "integer :: rv_shape(1)\n" +
 		               "character(kind = c_char), dimension(:), pointer :: temp",
 		:precallStatements => '',
-		:recieveAs => 'type(c_ptr)',
+		:receiveAs => 'type(c_ptr)',
 		:assignVariable => 'cString',
 		:postcallStatements => "if(c_associated(cString)) then\n" +
-		                       "\tshape(1) = int(lib_strlen(cString))\n" +
-		                       "\tcall c_f_pointer(cString, temp, shape)\n" +
-		                       "\tallocate(result(shape(1)))\n" +
-		                       "\tresult = temp\n" +
+		                       "\trv_shape(1) = int(lib_strlen(cString))\n" +
+		                       "\tcall c_f_pointer(cString, temp, rv_shape)\n" +
+		                       "\tallocate(#{$wrapperResultVarName}(rv_shape(1)))\n" +
+		                       "\t#{$wrapperResultVarName} = temp\n" +
 		                       "\tcall lib_free(cString)\n" +
 		                       "else\n" +
-		                       "\tresult => null()\n" +
+		                       "\t#{$wrapperResultVarName} => null()\n" +
 		                       "end if"
 	}, {	#const char*
 		:regex => '^\s*const\s+char\s*\*\s*$',
 		:placeholders => %w[],
 		:isVoid => false,
 		:returnAs => 'character(kind = c_char), dimension(:), pointer',
-		:helperVars => "type(c_ptr) :: ptr\ninteger :: shape(1)",
-		:precallStatements => 'result => null()',
-		:recieveAs => 'type(c_ptr)',
+		:helperVars => "type(c_ptr) :: ptr\ninteger :: rv_shape(1)",
+		:precallStatements => $wrapperResultVarName + ' => null()',
+		:receiveAs => 'type(c_ptr)',
 		:assignVariable => 'ptr',
 		:postcallStatements => "if(c_associated(ptr)) then\n" +
-		                       "\tshape(1) = int(lib_strlen(ptr))\n" +
-		                       "\tcall c_f_pointer(ptr, result, shape)\n" +
+		                       "\trv_shape(1) = int(lib_strlen(ptr))\n" +
+		                       "\tcall c_f_pointer(ptr, #{$wrapperResultVarName}, rv_shape)\n" +
 		                       "end if"
 	}, {	#const int*	This returns the naked pointer because we can't know the length of the returned array within the wrapper. The user has to call c_f_pointer() himself.
 		:regex => '^\s*const\s+(?<type><integerTypes>)\s*\*\s*$',
@@ -391,8 +519,8 @@ $returnTypeTemplates = [
 		:returnAs => 'type(c_ptr)',
 		:helperVars => '',
 		:precallStatements => '',
-		:recieveAs => 'type(c_ptr)',
-		:assignVariable => 'result',
+		:receiveAs => 'type(c_ptr)',
+		:assignVariable => $wrapperResultVarName,
 		:postcallStatements => ''
 	}, {	#const double*	This returns the naked pointer because we can't know the length of the returned array within the wrapper. The user has to call c_f_pointer() himself.
 		:regex => '^\s*const\s+(?<type><floatTypes>)\s*\*\s*$',
@@ -401,8 +529,8 @@ $returnTypeTemplates = [
 		:returnAs => 'type(c_ptr)',
 		:helperVars => '',
 		:precallStatements => '',
-		:recieveAs => 'type(c_ptr)',
-		:assignVariable => 'result',
+		:receiveAs => 'type(c_ptr)',
+		:assignVariable => $wrapperResultVarName,
 		:postcallStatements => ''
 	},
 	#Public and opaque types.
@@ -413,8 +541,8 @@ $returnTypeTemplates = [
 		:returnAs => 'type(t_<type>)',
 		:helperVars => '',
 		:precallStatements => '',
-		:recieveAs => 'type(t_<type>)',
-		:assignVariable => 'result',
+		:receiveAs => 'type(t_<type>)',
+		:assignVariable => $wrapperResultVarName,
 		:postcallStatements => ''
 	}, {	#<opaqueTypes>*
 		:regex => '^\s*(?<type><opaqueTypes>)\s*\*\s*$',
@@ -423,8 +551,8 @@ $returnTypeTemplates = [
 		:returnAs => 'type(t_<type>)',
 		:helperVars => '',
 		:precallStatements => '',
-		:recieveAs => 'type(c_ptr)',
-		:assignVariable => 'result%ptr',
+		:receiveAs => 'type(c_ptr)',
+		:assignVariable => $wrapperResultVarName + '%ptr',
 		:postcallStatements => ''
 	}
 ]
@@ -492,17 +620,29 @@ $verbatimDefinitions = "
 
 $declarationLines = []
 $definitionLines = []
+$interfaceLines = []
 $opaqueTypes = []
 $publicTypes = []
 
+def rubyVersionOk()
+       version = RUBY_VERSION.split(".")
+       if version[0].to_i > 1
+               return true
+       elsif version[0].to_i == 1
+               return version[1].to_i >= 9
+       else
+               return false
+       end
+end
+
 #This substitutes the placeholders <opaqueTypes> and <publicTypes> in the regexString prior to constructing a Regexp out of it.
 def matchTemplate(regexString, matchString)
-	opaqueTypesString = "(#{ $opaqueTypes.collect{ |type| type }.join('|') })"
+	opaqueTypesString = '(' + $opaqueTypes.collect{ |type| type	}.join('|') + ')'
 	regexString = regexString.gsub("<opaqueTypes>", opaqueTypesString)
-	publicTypesString = "(#{ $publicTypes.collect{ |type| type }.join('|') })"
-	regexString = regexString.gsub("<publicTypes>", publicTypesString)
-	regexString = regexString.gsub("<integerTypes>", '(short|int|long|size_t|intmax_t|int_(least|fast)(8|16|32|64)_t)')
-	regexString = regexString.gsub("<floatTypes>",  '(float|double)')
+	publicTypesString = '(' + $publicTypes.collect{ |type| type }.join('|') + ')'
+	regexString = regexString.gsub('<publicTypes>', publicTypesString)
+	regexString = regexString.gsub('<integerTypes>', '(short|int|long|size_t|intmax_t|int_(least|fast)(8|16|32|64)_t)')
+	regexString = regexString.gsub('<floatTypes>',  '(float|double)')
 	return Regexp.new(regexString).match(matchString)
 end
 
@@ -524,35 +664,58 @@ class TemplateInstanciation
 		}
 		return result
 	end
+	def nonEmptyKey?(templateKey)
+		result = @template[templateKey] != ''
+		return result
+	end
+	attr_reader :template
 end
 
 def formatLines(lineArray, indentation, string)
+	$stderr.puts("Formatting '" + string + "'") if $debug > 3
 	if string == "" && indentation == 0
 		lineArray.push("")	#split() does not return anything if the string is empty, killing our empty lines
 	end
 	string.split("\n").each { |line|
 		lineArray.push("\t"*indentation + line)
 	}
+	tail = ''
+	if lineArray.length > 1
+		tail = lineArray[-2..-1].join("\n")
+	else
+		tail = lineArray[-1]
+	end
+	$stderr.puts("Tail '" + tail + "'") if $debug > 3
 end
 
-def dumpStatements(indentation, argumentArray, templateKey)
+def haveTemplateKey(templates, templateKey)
+	result = false
+	templates.count{ |template|
+		result ||= template.nonEmptyKey?(templateKey)
+		break if result
+	}
+	return result
+end
+
+
+def dumpStatements(indentation, argumentArray, templateKey, outputArray)
 	argumentArray.each{ |argument|
-		formatLines($definitionLines, indentation, argument.expandTemplate(templateKey))
+		formatLines(outputArray, indentation, argument.expandTemplate(templateKey))
 	}
 end
 
 def defineConstant(name, value)
 	if /^(\+|-|)\d+$/.match(value)
-		formatLines($declarationLines, 1, "integer(c_int), public, parameter :: #{name} = #{value}")
+		formatLines($declarationLines, 1, "integer(c_int), public, parameter :: #{name} = " + value)
 	else
-		puts("Error: value '#{value}' of constant '#{name}' is not an integer literal")
+		$stderr.puts("Error: value '#{value}' of constant '#{name}' is not an integer literal")
 	end
 end
 
 def defineOpaqueType(name)
 	formatLines($declarationLines, 0, "")
-	formatLines($declarationLines, 1, "public t_#{name}")
-	formatLines($declarationLines, 1, "type t_#{name}")
+	formatLines($declarationLines, 1, "public :: t_#{name}")
+	formatLines($declarationLines, 1, "type :: t_#{name}")
 	formatLines($declarationLines, 2, "type(c_ptr) :: ptr")
 	formatLines($declarationLines, 1, "end type t_#{name}")
 	$opaqueTypes.push(name)
@@ -574,29 +737,52 @@ def definePublicType(name, body)
 	body.gsub(/[^;]+;/) do |variableDeclaration|
 		if template = findTemplate(variableDeclaration, $typeTemplates)
 			variable = TemplateInstanciation.new(variableDeclaration, template)
-			formatLines($declarationLines, 2, "#{variable.expandTemplate(:declareAs)}")
+			formatLines($declarationLines, 2, variable.expandTemplate(:declareAs))
 		else
-			puts("Error: Can't translate the declaration '#{variableDeclaration}'")
+			$stderr.puts("Error: Can't translate the declaration '" + variableDeclaration + "'")
 		end
 	end
-	formatLines($declarationLines, 1, "end type t_#{name}")
+	formatLines($declarationLines, 1, 'end type t_' + name)
 	$publicTypes.push(name)
 end
 
 def collectImportConstants(importConstantsArray, typeString)
+	$stderr.puts('Considering \'' + typeString + "' for import\n") if $debug > 2
 	if importConstant = typeString[/\b[ct]_\w+\b/]
 		importConstantsArray.push(importConstant)
 	end
 end
 
+def collectArrayBoundImports(importConstantsArray, argPassString)
+	if array_bounds_match =
+			/(?<=\()\s*(?:[a-zA-Z_]\w*|:|\d+)\s*(?:,\s*(?:[a-zA-Z_]\w*|:|\d+)\s*?)*(?=\s*\)$)/.match(argPassString)
+		$stderr.puts('Found array bounds: \'' +
+								 array_bounds_match.to_a.join('\', \'') + "'",
+								 'for \'' + argPassString + "'") if $debug > 3
+		array_bounds_match = array_bounds_match[0]
+		array_bounds_match.lstrip!
+		array_bounds_match = array_bounds_match.split(/\s*,\s*/)
+		array_bounds_match.select! do |bound|
+			bound != ':' && bound !~ /^\d+$/
+		end
+		$stderr.puts('Possible import symbols in array bounds: \'' +
+								 array_bounds_match.join('\', \'') + "'") if $debug > 3
+		importConstantsArray.push(*array_bounds_match)
+	end
+end
+
 #Collect the c_* and t_* constants/types from the arguments and the return type and build the corresponding `import` statement from them.
 def importStatement(returnType, argumentArray)
 	importConstants = []
 	collectImportConstants(importConstants, returnType)
 	argumentArray.each { |arg|
-		collectImportConstants(importConstants, arg.expandTemplate(:passAs))
+		argStr = arg.expandTemplate(:passAs)
+		collectArrayBoundImports(importConstants, argStr)
+		collectImportConstants(importConstants, argStr)
 	}
-	return (importConstants.length != 0) ? "import #{importConstants.sort.uniq.join(", ")}" : ""
+	$stderr.puts('Returning \'' + importConstants.sort.uniq.join(', ') +
+							 "' for import\n") if $debug > 2
+	return (importConstants.length != 0) ? ('import ' + importConstants.sort.uniq.join(', ')) : ''
 end
 
 def defineFunction(name, arguments, returnType)
@@ -608,65 +794,127 @@ def defineFunction(name, arguments, returnType)
 			if template = findTemplate(argument, $argumentTemplates)
 				argArray.push(TemplateInstanciation.new(argument, template))
 			else
-				puts("Error: type of argument '#{argument}' to function #{name}() is not supported")
+				$stderr.puts("Error: type of argument '#{argument}' to function #{name}() is not supported")
 				return
 			end
 		end
 	else
-		puts("Error: Can't translate return type '#{returnType}' of function #{name}()")
+		$stderr.puts("Error: Can't translate return type '#{returnType}' of function #{name}()")
 		return
 	end
 
-	#Generate the wrapper function.
+	needArgPrologue = haveTemplateKey(argArray, :precallStatements)
+	needRetValPrologue = !returnTemplate[:isVoid] &&
+		returnData.nonEmptyKey?(:precallStatements)
+	needArgEpilogue = haveTemplateKey(argArray, :postcallStatements)
+	needRetValEpilogue = !returnTemplate[:isVoid] &&
+		returnData.nonEmptyKey?(:postcallStatements)
+	needRetValConversion = !returnTemplate[:isVoid] &&
+		returnTemplate[:returnAs] != returnTemplate[:receiveAs]
+	needArgConversion = false
+	argArray.each do |arg|
+		needArgConversion = (arg.template[:passAs] != arg.template[:acceptAs])
+		break if needArgConversion
+	end
+
+	needWrapper = needArgPrologue || needRetValPrologue ||
+		needArgEpilogue || needRetValEpilogue ||
+		needRetValConversion || needArgConversion
+	baseIndent = 0
+	formatLines($declarationLines, 1, 'public :: ' + name)
+	$stderr.puts(name + "\n" +
+							 [ "\t"+'needArgPrologue => ' + needArgPrologue.to_s,
+								 "\t"+'needRetValPrologue => ' + needRetValPrologue.to_s,
+								 "\t"+'needArgEpilogue => ' + needArgEpilogue.to_s,
+								 "\t"+'needRetValEpilogue => ' + needRetValEpilogue.to_s,
+								 "\t"+'needRetValConversion => ' + needRetValConversion.to_s,
+								 "\t"+'needArgConversion => ' + needArgConversion.to_s,
+								 "\t"+'needWrapper => ' +
+		needWrapper.to_s].join("\n")) if $debug > 1
+	subprogramtype = returnTemplate[:isVoid] ? 'subroutine' : 'function'
 	dummyArguments = argArray.collect{ |arg|
 		arg.expandTemplate(:dummyName)
 	}.join(", ")
-	if returnTemplate[:isVoid]
-		formatLines($definitionLines, 1, "subroutine #{name}(#{dummyArguments})")
-		dumpStatements(               2, argArray, :acceptAs)
-		dumpStatements(               2, argArray, :helperVars)
-		formatLines($definitionLines, 2, "interface")
-		formatLines($definitionLines, 3, "subroutine lib_#{name}(#{dummyArguments}) bind(c, name = '#{name}')")
-		formatLines($definitionLines, 4, "#{importStatement("", argArray)}")
-		dumpStatements(               4, argArray, :passAs)
-		formatLines($definitionLines, 3, "end subroutine lib_#{name}")
-		formatLines($definitionLines, 2, "end interface")
-		dumpStatements(               2, argArray, :precallStatements)
-		formatLines($definitionLines, 2, "call lib_#{name}(#{argArray.collect{ |arg|
-			arg.expandTemplate(:callExpression)
-		}.join(", ")})")
-		dumpStatements(               2, argArray, :postcallStatements)
-		formatLines($definitionLines, 1, "end subroutine #{name}")
+	if needWrapper
+		#Generate the wrapper function.
+		line = subprogramtype + ' ' + name + '(' + dummyArguments + ')' +
+			(returnTemplate[:isVoid] ? '' : " result(#{$wrapperResultVarName})")
+		formatLines($definitionLines, 1, line)
+		if !returnTemplate[:isVoid]
+			formatLines($definitionLines, 2,
+									returnData.expandTemplate(:returnAs) + ' :: ' +
+									$wrapperResultVarName)
+		end
+		dumpStatements(               2, argArray, :acceptAs, $definitionLines)
+		dumpStatements(               2, argArray, :helperVars, $definitionLines)
+		if !returnTemplate[:isVoid]
+			formatLines($definitionLines, 2, returnData.expandTemplate(:helperVars))
+		end
+		formatLines($definitionLines, 2, 'interface')
+		line=subprogramtype + ' lib_' + name + '(' + dummyArguments + ') ' +
+			'bind(c, name = \'' + name + '\')' +
+			(returnTemplate[:isVoid] ? '' : ' result(c_result)')
+		formatLines($definitionLines, 3, line)
+		formatLines($definitionLines, 4,
+								importStatement(returnTemplate[:isVoid] ? '' :
+																returnData.expandTemplate(:receiveAs), argArray))
+		if !returnTemplate[:isVoid]
+			formatLines($definitionLines, 4,
+									returnData.expandTemplate(:receiveAs) + ' :: c_result')
+		end
+		dumpStatements(               4, argArray, :passAs, $definitionLines)
+		formatLines($definitionLines, 3, 'end ' + subprogramtype + ' lib_' + name)
+		formatLines($definitionLines, 2, 'end interface')
+		if needArgPrologue
+			dumpStatements(               2, argArray, :precallStatements, $definitionLines)
+		end
+		if !returnTemplate[:isVoid]
+			formatLines($definitionLines, 2,
+									returnData.expandTemplate(:precallStatements))
+		end
+		formatLines($definitionLines, 2,
+								(returnTemplate[:isVoid] ? 'call' :
+								 (returnData.expandTemplate(:assignVariable) + ' =')) +
+								' lib_' + name + '(' + argArray.collect{ |arg|
+									arg.expandTemplate(:callExpression)
+								}.join(', ') + ')')
+		if (needArgEpilogue)
+			dumpStatements(               2, argArray, :postcallStatements, $definitionLines)
+		end
+		if needRetValEpilogue
+			formatLines($definitionLines, 2,
+									returnData.expandTemplate(:postcallStatements))
+		end
+		formatLines($definitionLines, 1, 'end ' + subprogramtype + ' ' + name)
+		formatLines($definitionLines, 0, '')
 	else
-		formatLines($definitionLines, 1, "function #{name}(#{dummyArguments}) result(result)")
-		formatLines($definitionLines, 2, "#{returnData.expandTemplate(:returnAs)} :: result")
-		dumpStatements(               2, argArray, :acceptAs)
-		dumpStatements(               2, argArray, :helperVars)
-		formatLines($definitionLines, 2, "#{returnData.expandTemplate(:helperVars)}")
-		formatLines($definitionLines, 2, "interface")
-		formatLines($definitionLines, 3, "#{returnData.expandTemplate(:recieveAs)} function lib_#{name}(#{dummyArguments}) bind(c, name = '#{name}')")
-		formatLines($definitionLines, 4, "#{importStatement(returnData.expandTemplate(:recieveAs), argArray)}")
-		dumpStatements(               4, argArray, :passAs)
-		formatLines($definitionLines, 3, "end function lib_#{name}")
-		formatLines($definitionLines, 2, "end interface")
-		dumpStatements(               2, argArray, :precallStatements)
-		formatLines($definitionLines, 2, "#{returnData.expandTemplate(:precallStatements)}")
-		formatLines($definitionLines, 2, "#{returnData.expandTemplate(:assignVariable)} = lib_#{name}(#{argArray.collect{ |arg|
-			arg.expandTemplate(:callExpression)
-		}.join(", ")})")
-		dumpStatements(               2, argArray, :postcallStatements)
-		formatLines($definitionLines, 2, "#{returnData.expandTemplate(:postcallStatements)}")
-		formatLines($definitionLines, 1, "end function #{name}")
-	end
-	formatLines($definitionLines, 0, "")
-	formatLines($declarationLines, 1, "public #{name}")
+		#Generate interface block only
+		baseIndent = 1
+		line = subprogramtype + ' ' + name + '(' + dummyArguments +
+			') bind(c, name = \'' + name + '\')' +
+			(returnTemplate[:isVoid] ? '' : " result(#{$wrapperResultVarName})")
+		formatLines($interfaceLines, baseIndent + 1, line)
+		line = importStatement(returnTemplate[:isVoid] ? '' :
+													 returnData.expandTemplate(:returnAs),
+													 argArray)
+		$stderr.puts('Emitting \'' + line + "'") if $debug > 2
+		formatLines($interfaceLines, baseIndent + 2, line)
 
+		dumpStatements(baseIndent + 2, argArray, :passAs, $interfaceLines)
+		if !returnTemplate[:isVoid]
+			formatLines($interfaceLines, baseIndent + 2,
+									returnData.expandTemplate(:returnAs) + ' :: ' +
+									$wrapperResultVarName)
+		end
+		formatLines($interfaceLines, baseIndent + 1, 'end ' + subprogramtype + ' ' + name)
+		formatLines($interfaceLines, 0, '')
+	end
 end
 
 #Scan the given header and collect the interface information in the global variables.
 def scanHeader(headerPath)
 	#Scan the given header.
-	headerLines = IO.popen("cpp -fpreprocessed -dD #{headerPath}").readlines	#The options cause the preprocessor to strip all comments, but retain all #defines, and ignore #includes.
+	headerLines = IO.popen('cpp -fpreprocessed -dD ' + headerPath).readlines	#The options cause the preprocessor to strip all comments, but retain all #defines, and ignore #includes.
 	headerLines.each do |line|
 		line.chomp!
 
@@ -698,12 +946,20 @@ end
 #Prints the line if it does not consist only of indentation, adding continuation lines as necessary.
 def fortranLine(file, line)
 	unless /^\t+$/.match(line)	#Intentionally empty lines don't contain indentation, so we preserve totally empty lines while throwing away the ones with leading tabs.
-		indentation = /^\t*/.match(line)[0]
-		while line.length > 131
-			file.puts(line[0...131] + "&")
-			line = indentation + "&" + line[131...line.length]
+		# replace tabs with spaces first
+		spacesPerTab = 2
+		mline = line.gsub("\t", ' '*spacesPerTab)
+		charsPerLine=79
+		indentation = /^ */.match(mline)[0]
+		if not /^ *!/.match(mline)
+			while mline.length > charsPerLine
+				# last position of space preceding line break
+				tspos = mline[0..charsPerLine].rindex(' ') || charsPerLine
+				file.puts(mline[0...tspos] + "&")
+				mline = indentation + "&" + mline[tspos...mline.length]
+			end
 		end
-		file.puts(line)
+		file.puts(mline)
 	end
 end
 
@@ -715,26 +971,37 @@ def writeFortranModule(scriptPath, headerPath, modulePath, moduleName)
 	fortranLine(file, "! Generated by \"#{scriptPath}\" from input file \"#{headerPath}\".")
 	fortranLine(file, "");
 
-	fortranLine(file, "module #{moduleName}")
+	fortranLine(file, 'module ' + moduleName)
 	fortranLine(file, "\tuse iso_c_binding")
 	fortranLine(file, "\timplicit none")
 	fortranLine(file, "\tprivate")
 
-	file.puts($verbatimDeclarations)
-	fortranLine(file, "")
+	$verbatimDeclarations.each_line do |line|
+		fortranLine(file, line)
+	end
+	fortranLine(file, '')
 	$declarationLines.each do |line|
 		fortranLine(file, line)
 	end
-	fortranLine(file, "")
-
+	fortranLine(file, '')
+	unless $interfaceLines.empty?
+		fortranLine(file, "\tinterface")
+		$interfaceLines.each do |line|
+			fortranLine(file, line)
+		end
+		fortranLine(file, "\tend interface")
+		fortranLine(file, '')
+	end
 	fortranLine(file, "contains")
-	file.puts($verbatimDefinitions)
-	fortranLine(file, "")
+	$verbatimDefinitions.each_line do |line|
+		fortranLine(file, line)
+	end
+	fortranLine(file, '')
 	$definitionLines.each do |line|
 		fortranLine(file, line)
 	end
 
-	fortranLine(file, "end module #{moduleName}")
+	fortranLine(file, 'end module ' + moduleName)
 end
 
 def main
@@ -747,17 +1014,17 @@ def main
 	unless printUsage
 		case ARGV.length
 			when 0
-				puts("Error: no input file given")
+				$stderr.puts("Error: no input file given")
 				printUsage = true
 			when 1
-				puts("Error: no output file given")
+				$stderr.puts("Error: no output file given")
 				printUsage = true
 			when 2
 				moduleName = /(?<basename>[^.\/]+)\.[^\/]+/.match(ARGV[1])['basename']
 			when 3
 				moduleName = ARGV[2]
 			else
-				puts("Error: too many arguments")
+				$stderr.puts("Error: too many arguments")
 				printUsage = true
 		end
 	end
@@ -768,8 +1035,8 @@ def main
 		writeFortranModule($0, headerPath, outputPath, moduleName)
 	else
 		puts("Usage:")
-		puts("#{$0} cHeader outputPath [ moduleName ]")
-		puts("#{$0} ( -h | --help )")
+		puts($0 + ' cHeader outputPath [ moduleName ]')
+		puts($0 + ' ( -h | --help )')
 		puts("")
 		puts("\tcHeader:    input C header file")
 		puts("\toutputPath: output fortran file name")
@@ -777,4 +1044,17 @@ def main
 	end
 end
 
-main()
+if rubyVersionOk()
+	main()
+else
+	$stderr.puts("Error: Ruby version #{RUBY_VERSION} is too old (version 1.9 is required). Skipping fortran interface generation.")
+end
+#
+# Local Variables:
+# mode: ruby
+# tab-always-indent: nil
+# tab-width: 2
+# ruby-indent-tabs-mode: t
+# indent-tabs-mode: t
+# End:
+#
diff --git a/libcdi/interfaces/python/CdiObj.py b/libcdi/interfaces/python/CdiObj.py
index 35d483a..6f1c3bd 100644
--- a/libcdi/interfaces/python/CdiObj.py
+++ b/libcdi/interfaces/python/CdiObj.py
@@ -1,35 +1,12 @@
 # This file was automatically generated by SWIG (http://www.swig.org).
-# Version 3.0.2
+# Version 1.3.31
 #
-# Do not make changes to this file unless you know what you are doing--modify
-# the SWIG interface file instead.
-
-
-
-
+# Don't modify this file, modify the SWIG interface instead.
+# This file is compatible with both classic and new-style classes.
 
-from sys import version_info
-if version_info >= (2,6,0):
-    def swig_import_helper():
-        from os.path import dirname
-        import imp
-        fp = None
-        try:
-            fp, pathname, description = imp.find_module('_CdiObj', [dirname(__file__)])
-        except ImportError:
-            import _CdiObj
-            return _CdiObj
-        if fp is not None:
-            try:
-                _mod = imp.load_module('_CdiObj', fp, pathname, description)
-            finally:
-                fp.close()
-            return _mod
-    _CdiObj = swig_import_helper()
-    del swig_import_helper
-else:
-    import _CdiObj
-del version_info
+import _CdiObj
+import new
+new_instancemethod = new.instancemethod
 try:
     _swig_property = property
 except NameError:
@@ -37,12 +14,12 @@ except NameError:
 def _swig_setattr_nondynamic(self,class_type,name,value,static=1):
     if (name == "thisown"): return self.this.own(value)
     if (name == "this"):
-        if type(value).__name__ == 'SwigPyObject':
+        if type(value).__name__ == 'PySwigObject':
             self.__dict__[name] = value
             return
     method = class_type.__swig_setmethods__.get(name,None)
     if method: return method(self,value)
-    if (not static):
+    if (not static) or hasattr(self,name):
         self.__dict__[name] = value
     else:
         raise AttributeError("You cannot add attributes to %s" % self)
@@ -54,49 +31,50 @@ def _swig_getattr(self,class_type,name):
     if (name == "thisown"): return self.this.own()
     method = class_type.__swig_getmethods__.get(name,None)
     if method: return method(self)
-    raise AttributeError(name)
+    raise AttributeError,name
 
 def _swig_repr(self):
     try: strthis = "proxy of " + self.this.__repr__()
     except: strthis = ""
     return "<%s.%s; %s >" % (self.__class__.__module__, self.__class__.__name__, strthis,)
 
+import types
 try:
-    _object = object
+    _object = types.ObjectType
     _newclass = 1
 except AttributeError:
     class _object : pass
     _newclass = 0
+del types
 
 
-class SwigPyIterator(_object):
+class PySwigIterator(_object):
     __swig_setmethods__ = {}
-    __setattr__ = lambda self, name, value: _swig_setattr(self, SwigPyIterator, name, value)
+    __setattr__ = lambda self, name, value: _swig_setattr(self, PySwigIterator, name, value)
     __swig_getmethods__ = {}
-    __getattr__ = lambda self, name: _swig_getattr(self, SwigPyIterator, name)
-    def __init__(self, *args, **kwargs): raise AttributeError("No constructor defined - class is abstract")
+    __getattr__ = lambda self, name: _swig_getattr(self, PySwigIterator, name)
+    def __init__(self): raise AttributeError, "No constructor defined"
     __repr__ = _swig_repr
-    __swig_destroy__ = _CdiObj.delete_SwigPyIterator
+    __swig_destroy__ = _CdiObj.delete_PySwigIterator
     __del__ = lambda self : None;
-    def value(self): return _CdiObj.SwigPyIterator_value(self)
-    def incr(self, n=1): return _CdiObj.SwigPyIterator_incr(self, n)
-    def decr(self, n=1): return _CdiObj.SwigPyIterator_decr(self, n)
-    def distance(self, *args): return _CdiObj.SwigPyIterator_distance(self, *args)
-    def equal(self, *args): return _CdiObj.SwigPyIterator_equal(self, *args)
-    def copy(self): return _CdiObj.SwigPyIterator_copy(self)
-    def next(self): return _CdiObj.SwigPyIterator_next(self)
-    def __next__(self): return _CdiObj.SwigPyIterator___next__(self)
-    def previous(self): return _CdiObj.SwigPyIterator_previous(self)
-    def advance(self, *args): return _CdiObj.SwigPyIterator_advance(self, *args)
-    def __eq__(self, *args): return _CdiObj.SwigPyIterator___eq__(self, *args)
-    def __ne__(self, *args): return _CdiObj.SwigPyIterator___ne__(self, *args)
-    def __iadd__(self, *args): return _CdiObj.SwigPyIterator___iadd__(self, *args)
-    def __isub__(self, *args): return _CdiObj.SwigPyIterator___isub__(self, *args)
-    def __add__(self, *args): return _CdiObj.SwigPyIterator___add__(self, *args)
-    def __sub__(self, *args): return _CdiObj.SwigPyIterator___sub__(self, *args)
+    def value(*args): return _CdiObj.PySwigIterator_value(*args)
+    def incr(*args): return _CdiObj.PySwigIterator_incr(*args)
+    def decr(*args): return _CdiObj.PySwigIterator_decr(*args)
+    def distance(*args): return _CdiObj.PySwigIterator_distance(*args)
+    def equal(*args): return _CdiObj.PySwigIterator_equal(*args)
+    def copy(*args): return _CdiObj.PySwigIterator_copy(*args)
+    def next(*args): return _CdiObj.PySwigIterator_next(*args)
+    def previous(*args): return _CdiObj.PySwigIterator_previous(*args)
+    def advance(*args): return _CdiObj.PySwigIterator_advance(*args)
+    def __eq__(*args): return _CdiObj.PySwigIterator___eq__(*args)
+    def __ne__(*args): return _CdiObj.PySwigIterator___ne__(*args)
+    def __iadd__(*args): return _CdiObj.PySwigIterator___iadd__(*args)
+    def __isub__(*args): return _CdiObj.PySwigIterator___isub__(*args)
+    def __add__(*args): return _CdiObj.PySwigIterator___add__(*args)
+    def __sub__(*args): return _CdiObj.PySwigIterator___sub__(*args)
     def __iter__(self): return self
-SwigPyIterator_swigregister = _CdiObj.SwigPyIterator_swigregister
-SwigPyIterator_swigregister(SwigPyIterator)
+PySwigIterator_swigregister = _CdiObj.PySwigIterator_swigregister
+PySwigIterator_swigregister(PySwigIterator)
 
 class IntVector(_object):
     __swig_setmethods__ = {}
@@ -104,42 +82,41 @@ class IntVector(_object):
     __swig_getmethods__ = {}
     __getattr__ = lambda self, name: _swig_getattr(self, IntVector, name)
     __repr__ = _swig_repr
-    def iterator(self): return _CdiObj.IntVector_iterator(self)
+    def iterator(*args): return _CdiObj.IntVector_iterator(*args)
     def __iter__(self): return self.iterator()
-    def __nonzero__(self): return _CdiObj.IntVector___nonzero__(self)
-    def __bool__(self): return _CdiObj.IntVector___bool__(self)
-    def __len__(self): return _CdiObj.IntVector___len__(self)
-    def pop(self): return _CdiObj.IntVector_pop(self)
-    def __getslice__(self, *args): return _CdiObj.IntVector___getslice__(self, *args)
-    def __setslice__(self, *args): return _CdiObj.IntVector___setslice__(self, *args)
-    def __delslice__(self, *args): return _CdiObj.IntVector___delslice__(self, *args)
-    def __delitem__(self, *args): return _CdiObj.IntVector___delitem__(self, *args)
-    def __getitem__(self, *args): return _CdiObj.IntVector___getitem__(self, *args)
-    def __setitem__(self, *args): return _CdiObj.IntVector___setitem__(self, *args)
-    def append(self, *args): return _CdiObj.IntVector_append(self, *args)
-    def empty(self): return _CdiObj.IntVector_empty(self)
-    def size(self): return _CdiObj.IntVector_size(self)
-    def clear(self): return _CdiObj.IntVector_clear(self)
-    def swap(self, *args): return _CdiObj.IntVector_swap(self, *args)
-    def get_allocator(self): return _CdiObj.IntVector_get_allocator(self)
-    def begin(self): return _CdiObj.IntVector_begin(self)
-    def end(self): return _CdiObj.IntVector_end(self)
-    def rbegin(self): return _CdiObj.IntVector_rbegin(self)
-    def rend(self): return _CdiObj.IntVector_rend(self)
-    def pop_back(self): return _CdiObj.IntVector_pop_back(self)
-    def erase(self, *args): return _CdiObj.IntVector_erase(self, *args)
+    def __nonzero__(*args): return _CdiObj.IntVector___nonzero__(*args)
+    def __len__(*args): return _CdiObj.IntVector___len__(*args)
+    def pop(*args): return _CdiObj.IntVector_pop(*args)
+    def __getslice__(*args): return _CdiObj.IntVector___getslice__(*args)
+    def __setslice__(*args): return _CdiObj.IntVector___setslice__(*args)
+    def __delslice__(*args): return _CdiObj.IntVector___delslice__(*args)
+    def __delitem__(*args): return _CdiObj.IntVector___delitem__(*args)
+    def __getitem__(*args): return _CdiObj.IntVector___getitem__(*args)
+    def __setitem__(*args): return _CdiObj.IntVector___setitem__(*args)
+    def append(*args): return _CdiObj.IntVector_append(*args)
+    def empty(*args): return _CdiObj.IntVector_empty(*args)
+    def size(*args): return _CdiObj.IntVector_size(*args)
+    def clear(*args): return _CdiObj.IntVector_clear(*args)
+    def swap(*args): return _CdiObj.IntVector_swap(*args)
+    def get_allocator(*args): return _CdiObj.IntVector_get_allocator(*args)
+    def begin(*args): return _CdiObj.IntVector_begin(*args)
+    def end(*args): return _CdiObj.IntVector_end(*args)
+    def rbegin(*args): return _CdiObj.IntVector_rbegin(*args)
+    def rend(*args): return _CdiObj.IntVector_rend(*args)
+    def pop_back(*args): return _CdiObj.IntVector_pop_back(*args)
+    def erase(*args): return _CdiObj.IntVector_erase(*args)
     def __init__(self, *args): 
         this = _CdiObj.new_IntVector(*args)
         try: self.this.append(this)
         except: self.this = this
-    def push_back(self, *args): return _CdiObj.IntVector_push_back(self, *args)
-    def front(self): return _CdiObj.IntVector_front(self)
-    def back(self): return _CdiObj.IntVector_back(self)
-    def assign(self, *args): return _CdiObj.IntVector_assign(self, *args)
-    def resize(self, *args): return _CdiObj.IntVector_resize(self, *args)
-    def insert(self, *args): return _CdiObj.IntVector_insert(self, *args)
-    def reserve(self, *args): return _CdiObj.IntVector_reserve(self, *args)
-    def capacity(self): return _CdiObj.IntVector_capacity(self)
+    def push_back(*args): return _CdiObj.IntVector_push_back(*args)
+    def front(*args): return _CdiObj.IntVector_front(*args)
+    def back(*args): return _CdiObj.IntVector_back(*args)
+    def assign(*args): return _CdiObj.IntVector_assign(*args)
+    def resize(*args): return _CdiObj.IntVector_resize(*args)
+    def insert(*args): return _CdiObj.IntVector_insert(*args)
+    def reserve(*args): return _CdiObj.IntVector_reserve(*args)
+    def capacity(*args): return _CdiObj.IntVector_capacity(*args)
     __swig_destroy__ = _CdiObj.delete_IntVector
     __del__ = lambda self : None;
 IntVector_swigregister = _CdiObj.IntVector_swigregister
@@ -151,42 +128,41 @@ class DoubleVector(_object):
     __swig_getmethods__ = {}
     __getattr__ = lambda self, name: _swig_getattr(self, DoubleVector, name)
     __repr__ = _swig_repr
-    def iterator(self): return _CdiObj.DoubleVector_iterator(self)
+    def iterator(*args): return _CdiObj.DoubleVector_iterator(*args)
     def __iter__(self): return self.iterator()
-    def __nonzero__(self): return _CdiObj.DoubleVector___nonzero__(self)
-    def __bool__(self): return _CdiObj.DoubleVector___bool__(self)
-    def __len__(self): return _CdiObj.DoubleVector___len__(self)
-    def pop(self): return _CdiObj.DoubleVector_pop(self)
-    def __getslice__(self, *args): return _CdiObj.DoubleVector___getslice__(self, *args)
-    def __setslice__(self, *args): return _CdiObj.DoubleVector___setslice__(self, *args)
-    def __delslice__(self, *args): return _CdiObj.DoubleVector___delslice__(self, *args)
-    def __delitem__(self, *args): return _CdiObj.DoubleVector___delitem__(self, *args)
-    def __getitem__(self, *args): return _CdiObj.DoubleVector___getitem__(self, *args)
-    def __setitem__(self, *args): return _CdiObj.DoubleVector___setitem__(self, *args)
-    def append(self, *args): return _CdiObj.DoubleVector_append(self, *args)
-    def empty(self): return _CdiObj.DoubleVector_empty(self)
-    def size(self): return _CdiObj.DoubleVector_size(self)
-    def clear(self): return _CdiObj.DoubleVector_clear(self)
-    def swap(self, *args): return _CdiObj.DoubleVector_swap(self, *args)
-    def get_allocator(self): return _CdiObj.DoubleVector_get_allocator(self)
-    def begin(self): return _CdiObj.DoubleVector_begin(self)
-    def end(self): return _CdiObj.DoubleVector_end(self)
-    def rbegin(self): return _CdiObj.DoubleVector_rbegin(self)
-    def rend(self): return _CdiObj.DoubleVector_rend(self)
-    def pop_back(self): return _CdiObj.DoubleVector_pop_back(self)
-    def erase(self, *args): return _CdiObj.DoubleVector_erase(self, *args)
+    def __nonzero__(*args): return _CdiObj.DoubleVector___nonzero__(*args)
+    def __len__(*args): return _CdiObj.DoubleVector___len__(*args)
+    def pop(*args): return _CdiObj.DoubleVector_pop(*args)
+    def __getslice__(*args): return _CdiObj.DoubleVector___getslice__(*args)
+    def __setslice__(*args): return _CdiObj.DoubleVector___setslice__(*args)
+    def __delslice__(*args): return _CdiObj.DoubleVector___delslice__(*args)
+    def __delitem__(*args): return _CdiObj.DoubleVector___delitem__(*args)
+    def __getitem__(*args): return _CdiObj.DoubleVector___getitem__(*args)
+    def __setitem__(*args): return _CdiObj.DoubleVector___setitem__(*args)
+    def append(*args): return _CdiObj.DoubleVector_append(*args)
+    def empty(*args): return _CdiObj.DoubleVector_empty(*args)
+    def size(*args): return _CdiObj.DoubleVector_size(*args)
+    def clear(*args): return _CdiObj.DoubleVector_clear(*args)
+    def swap(*args): return _CdiObj.DoubleVector_swap(*args)
+    def get_allocator(*args): return _CdiObj.DoubleVector_get_allocator(*args)
+    def begin(*args): return _CdiObj.DoubleVector_begin(*args)
+    def end(*args): return _CdiObj.DoubleVector_end(*args)
+    def rbegin(*args): return _CdiObj.DoubleVector_rbegin(*args)
+    def rend(*args): return _CdiObj.DoubleVector_rend(*args)
+    def pop_back(*args): return _CdiObj.DoubleVector_pop_back(*args)
+    def erase(*args): return _CdiObj.DoubleVector_erase(*args)
     def __init__(self, *args): 
         this = _CdiObj.new_DoubleVector(*args)
         try: self.this.append(this)
         except: self.this = this
-    def push_back(self, *args): return _CdiObj.DoubleVector_push_back(self, *args)
-    def front(self): return _CdiObj.DoubleVector_front(self)
-    def back(self): return _CdiObj.DoubleVector_back(self)
-    def assign(self, *args): return _CdiObj.DoubleVector_assign(self, *args)
-    def resize(self, *args): return _CdiObj.DoubleVector_resize(self, *args)
-    def insert(self, *args): return _CdiObj.DoubleVector_insert(self, *args)
-    def reserve(self, *args): return _CdiObj.DoubleVector_reserve(self, *args)
-    def capacity(self): return _CdiObj.DoubleVector_capacity(self)
+    def push_back(*args): return _CdiObj.DoubleVector_push_back(*args)
+    def front(*args): return _CdiObj.DoubleVector_front(*args)
+    def back(*args): return _CdiObj.DoubleVector_back(*args)
+    def assign(*args): return _CdiObj.DoubleVector_assign(*args)
+    def resize(*args): return _CdiObj.DoubleVector_resize(*args)
+    def insert(*args): return _CdiObj.DoubleVector_insert(*args)
+    def reserve(*args): return _CdiObj.DoubleVector_reserve(*args)
+    def capacity(*args): return _CdiObj.DoubleVector_capacity(*args)
     __swig_destroy__ = _CdiObj.delete_DoubleVector
     __del__ = lambda self : None;
 DoubleVector_swigregister = _CdiObj.DoubleVector_swigregister
@@ -198,42 +174,41 @@ class DoubleDoubleVector(_object):
     __swig_getmethods__ = {}
     __getattr__ = lambda self, name: _swig_getattr(self, DoubleDoubleVector, name)
     __repr__ = _swig_repr
-    def iterator(self): return _CdiObj.DoubleDoubleVector_iterator(self)
+    def iterator(*args): return _CdiObj.DoubleDoubleVector_iterator(*args)
     def __iter__(self): return self.iterator()
-    def __nonzero__(self): return _CdiObj.DoubleDoubleVector___nonzero__(self)
-    def __bool__(self): return _CdiObj.DoubleDoubleVector___bool__(self)
-    def __len__(self): return _CdiObj.DoubleDoubleVector___len__(self)
-    def pop(self): return _CdiObj.DoubleDoubleVector_pop(self)
-    def __getslice__(self, *args): return _CdiObj.DoubleDoubleVector___getslice__(self, *args)
-    def __setslice__(self, *args): return _CdiObj.DoubleDoubleVector___setslice__(self, *args)
-    def __delslice__(self, *args): return _CdiObj.DoubleDoubleVector___delslice__(self, *args)
-    def __delitem__(self, *args): return _CdiObj.DoubleDoubleVector___delitem__(self, *args)
-    def __getitem__(self, *args): return _CdiObj.DoubleDoubleVector___getitem__(self, *args)
-    def __setitem__(self, *args): return _CdiObj.DoubleDoubleVector___setitem__(self, *args)
-    def append(self, *args): return _CdiObj.DoubleDoubleVector_append(self, *args)
-    def empty(self): return _CdiObj.DoubleDoubleVector_empty(self)
-    def size(self): return _CdiObj.DoubleDoubleVector_size(self)
-    def clear(self): return _CdiObj.DoubleDoubleVector_clear(self)
-    def swap(self, *args): return _CdiObj.DoubleDoubleVector_swap(self, *args)
-    def get_allocator(self): return _CdiObj.DoubleDoubleVector_get_allocator(self)
-    def begin(self): return _CdiObj.DoubleDoubleVector_begin(self)
-    def end(self): return _CdiObj.DoubleDoubleVector_end(self)
-    def rbegin(self): return _CdiObj.DoubleDoubleVector_rbegin(self)
-    def rend(self): return _CdiObj.DoubleDoubleVector_rend(self)
-    def pop_back(self): return _CdiObj.DoubleDoubleVector_pop_back(self)
-    def erase(self, *args): return _CdiObj.DoubleDoubleVector_erase(self, *args)
+    def __nonzero__(*args): return _CdiObj.DoubleDoubleVector___nonzero__(*args)
+    def __len__(*args): return _CdiObj.DoubleDoubleVector___len__(*args)
+    def pop(*args): return _CdiObj.DoubleDoubleVector_pop(*args)
+    def __getslice__(*args): return _CdiObj.DoubleDoubleVector___getslice__(*args)
+    def __setslice__(*args): return _CdiObj.DoubleDoubleVector___setslice__(*args)
+    def __delslice__(*args): return _CdiObj.DoubleDoubleVector___delslice__(*args)
+    def __delitem__(*args): return _CdiObj.DoubleDoubleVector___delitem__(*args)
+    def __getitem__(*args): return _CdiObj.DoubleDoubleVector___getitem__(*args)
+    def __setitem__(*args): return _CdiObj.DoubleDoubleVector___setitem__(*args)
+    def append(*args): return _CdiObj.DoubleDoubleVector_append(*args)
+    def empty(*args): return _CdiObj.DoubleDoubleVector_empty(*args)
+    def size(*args): return _CdiObj.DoubleDoubleVector_size(*args)
+    def clear(*args): return _CdiObj.DoubleDoubleVector_clear(*args)
+    def swap(*args): return _CdiObj.DoubleDoubleVector_swap(*args)
+    def get_allocator(*args): return _CdiObj.DoubleDoubleVector_get_allocator(*args)
+    def begin(*args): return _CdiObj.DoubleDoubleVector_begin(*args)
+    def end(*args): return _CdiObj.DoubleDoubleVector_end(*args)
+    def rbegin(*args): return _CdiObj.DoubleDoubleVector_rbegin(*args)
+    def rend(*args): return _CdiObj.DoubleDoubleVector_rend(*args)
+    def pop_back(*args): return _CdiObj.DoubleDoubleVector_pop_back(*args)
+    def erase(*args): return _CdiObj.DoubleDoubleVector_erase(*args)
     def __init__(self, *args): 
         this = _CdiObj.new_DoubleDoubleVector(*args)
         try: self.this.append(this)
         except: self.this = this
-    def push_back(self, *args): return _CdiObj.DoubleDoubleVector_push_back(self, *args)
-    def front(self): return _CdiObj.DoubleDoubleVector_front(self)
-    def back(self): return _CdiObj.DoubleDoubleVector_back(self)
-    def assign(self, *args): return _CdiObj.DoubleDoubleVector_assign(self, *args)
-    def resize(self, *args): return _CdiObj.DoubleDoubleVector_resize(self, *args)
-    def insert(self, *args): return _CdiObj.DoubleDoubleVector_insert(self, *args)
-    def reserve(self, *args): return _CdiObj.DoubleDoubleVector_reserve(self, *args)
-    def capacity(self): return _CdiObj.DoubleDoubleVector_capacity(self)
+    def push_back(*args): return _CdiObj.DoubleDoubleVector_push_back(*args)
+    def front(*args): return _CdiObj.DoubleDoubleVector_front(*args)
+    def back(*args): return _CdiObj.DoubleDoubleVector_back(*args)
+    def assign(*args): return _CdiObj.DoubleDoubleVector_assign(*args)
+    def resize(*args): return _CdiObj.DoubleDoubleVector_resize(*args)
+    def insert(*args): return _CdiObj.DoubleDoubleVector_insert(*args)
+    def reserve(*args): return _CdiObj.DoubleDoubleVector_reserve(*args)
+    def capacity(*args): return _CdiObj.DoubleDoubleVector_capacity(*args)
     __swig_destroy__ = _CdiObj.delete_DoubleDoubleVector
     __del__ = lambda self : None;
 DoubleDoubleVector_swigregister = _CdiObj.DoubleDoubleVector_swigregister
@@ -245,42 +220,41 @@ class StringVector(_object):
     __swig_getmethods__ = {}
     __getattr__ = lambda self, name: _swig_getattr(self, StringVector, name)
     __repr__ = _swig_repr
-    def iterator(self): return _CdiObj.StringVector_iterator(self)
+    def iterator(*args): return _CdiObj.StringVector_iterator(*args)
     def __iter__(self): return self.iterator()
-    def __nonzero__(self): return _CdiObj.StringVector___nonzero__(self)
-    def __bool__(self): return _CdiObj.StringVector___bool__(self)
-    def __len__(self): return _CdiObj.StringVector___len__(self)
-    def pop(self): return _CdiObj.StringVector_pop(self)
-    def __getslice__(self, *args): return _CdiObj.StringVector___getslice__(self, *args)
-    def __setslice__(self, *args): return _CdiObj.StringVector___setslice__(self, *args)
-    def __delslice__(self, *args): return _CdiObj.StringVector___delslice__(self, *args)
-    def __delitem__(self, *args): return _CdiObj.StringVector___delitem__(self, *args)
-    def __getitem__(self, *args): return _CdiObj.StringVector___getitem__(self, *args)
-    def __setitem__(self, *args): return _CdiObj.StringVector___setitem__(self, *args)
-    def append(self, *args): return _CdiObj.StringVector_append(self, *args)
-    def empty(self): return _CdiObj.StringVector_empty(self)
-    def size(self): return _CdiObj.StringVector_size(self)
-    def clear(self): return _CdiObj.StringVector_clear(self)
-    def swap(self, *args): return _CdiObj.StringVector_swap(self, *args)
-    def get_allocator(self): return _CdiObj.StringVector_get_allocator(self)
-    def begin(self): return _CdiObj.StringVector_begin(self)
-    def end(self): return _CdiObj.StringVector_end(self)
-    def rbegin(self): return _CdiObj.StringVector_rbegin(self)
-    def rend(self): return _CdiObj.StringVector_rend(self)
-    def pop_back(self): return _CdiObj.StringVector_pop_back(self)
-    def erase(self, *args): return _CdiObj.StringVector_erase(self, *args)
+    def __nonzero__(*args): return _CdiObj.StringVector___nonzero__(*args)
+    def __len__(*args): return _CdiObj.StringVector___len__(*args)
+    def pop(*args): return _CdiObj.StringVector_pop(*args)
+    def __getslice__(*args): return _CdiObj.StringVector___getslice__(*args)
+    def __setslice__(*args): return _CdiObj.StringVector___setslice__(*args)
+    def __delslice__(*args): return _CdiObj.StringVector___delslice__(*args)
+    def __delitem__(*args): return _CdiObj.StringVector___delitem__(*args)
+    def __getitem__(*args): return _CdiObj.StringVector___getitem__(*args)
+    def __setitem__(*args): return _CdiObj.StringVector___setitem__(*args)
+    def append(*args): return _CdiObj.StringVector_append(*args)
+    def empty(*args): return _CdiObj.StringVector_empty(*args)
+    def size(*args): return _CdiObj.StringVector_size(*args)
+    def clear(*args): return _CdiObj.StringVector_clear(*args)
+    def swap(*args): return _CdiObj.StringVector_swap(*args)
+    def get_allocator(*args): return _CdiObj.StringVector_get_allocator(*args)
+    def begin(*args): return _CdiObj.StringVector_begin(*args)
+    def end(*args): return _CdiObj.StringVector_end(*args)
+    def rbegin(*args): return _CdiObj.StringVector_rbegin(*args)
+    def rend(*args): return _CdiObj.StringVector_rend(*args)
+    def pop_back(*args): return _CdiObj.StringVector_pop_back(*args)
+    def erase(*args): return _CdiObj.StringVector_erase(*args)
     def __init__(self, *args): 
         this = _CdiObj.new_StringVector(*args)
         try: self.this.append(this)
         except: self.this = this
-    def push_back(self, *args): return _CdiObj.StringVector_push_back(self, *args)
-    def front(self): return _CdiObj.StringVector_front(self)
-    def back(self): return _CdiObj.StringVector_back(self)
-    def assign(self, *args): return _CdiObj.StringVector_assign(self, *args)
-    def resize(self, *args): return _CdiObj.StringVector_resize(self, *args)
-    def insert(self, *args): return _CdiObj.StringVector_insert(self, *args)
-    def reserve(self, *args): return _CdiObj.StringVector_reserve(self, *args)
-    def capacity(self): return _CdiObj.StringVector_capacity(self)
+    def push_back(*args): return _CdiObj.StringVector_push_back(*args)
+    def front(*args): return _CdiObj.StringVector_front(*args)
+    def back(*args): return _CdiObj.StringVector_back(*args)
+    def assign(*args): return _CdiObj.StringVector_assign(*args)
+    def resize(*args): return _CdiObj.StringVector_resize(*args)
+    def insert(*args): return _CdiObj.StringVector_insert(*args)
+    def reserve(*args): return _CdiObj.StringVector_reserve(*args)
+    def capacity(*args): return _CdiObj.StringVector_capacity(*args)
     __swig_destroy__ = _CdiObj.delete_StringVector
     __del__ = lambda self : None;
 StringVector_swigregister = _CdiObj.StringVector_swigregister
@@ -292,42 +266,41 @@ class VarsVector(_object):
     __swig_getmethods__ = {}
     __getattr__ = lambda self, name: _swig_getattr(self, VarsVector, name)
     __repr__ = _swig_repr
-    def iterator(self): return _CdiObj.VarsVector_iterator(self)
+    def iterator(*args): return _CdiObj.VarsVector_iterator(*args)
     def __iter__(self): return self.iterator()
-    def __nonzero__(self): return _CdiObj.VarsVector___nonzero__(self)
-    def __bool__(self): return _CdiObj.VarsVector___bool__(self)
-    def __len__(self): return _CdiObj.VarsVector___len__(self)
-    def pop(self): return _CdiObj.VarsVector_pop(self)
-    def __getslice__(self, *args): return _CdiObj.VarsVector___getslice__(self, *args)
-    def __setslice__(self, *args): return _CdiObj.VarsVector___setslice__(self, *args)
-    def __delslice__(self, *args): return _CdiObj.VarsVector___delslice__(self, *args)
-    def __delitem__(self, *args): return _CdiObj.VarsVector___delitem__(self, *args)
-    def __getitem__(self, *args): return _CdiObj.VarsVector___getitem__(self, *args)
-    def __setitem__(self, *args): return _CdiObj.VarsVector___setitem__(self, *args)
-    def append(self, *args): return _CdiObj.VarsVector_append(self, *args)
-    def empty(self): return _CdiObj.VarsVector_empty(self)
-    def size(self): return _CdiObj.VarsVector_size(self)
-    def clear(self): return _CdiObj.VarsVector_clear(self)
-    def swap(self, *args): return _CdiObj.VarsVector_swap(self, *args)
-    def get_allocator(self): return _CdiObj.VarsVector_get_allocator(self)
-    def begin(self): return _CdiObj.VarsVector_begin(self)
-    def end(self): return _CdiObj.VarsVector_end(self)
-    def rbegin(self): return _CdiObj.VarsVector_rbegin(self)
-    def rend(self): return _CdiObj.VarsVector_rend(self)
-    def pop_back(self): return _CdiObj.VarsVector_pop_back(self)
-    def erase(self, *args): return _CdiObj.VarsVector_erase(self, *args)
+    def __nonzero__(*args): return _CdiObj.VarsVector___nonzero__(*args)
+    def __len__(*args): return _CdiObj.VarsVector___len__(*args)
+    def pop(*args): return _CdiObj.VarsVector_pop(*args)
+    def __getslice__(*args): return _CdiObj.VarsVector___getslice__(*args)
+    def __setslice__(*args): return _CdiObj.VarsVector___setslice__(*args)
+    def __delslice__(*args): return _CdiObj.VarsVector___delslice__(*args)
+    def __delitem__(*args): return _CdiObj.VarsVector___delitem__(*args)
+    def __getitem__(*args): return _CdiObj.VarsVector___getitem__(*args)
+    def __setitem__(*args): return _CdiObj.VarsVector___setitem__(*args)
+    def append(*args): return _CdiObj.VarsVector_append(*args)
+    def empty(*args): return _CdiObj.VarsVector_empty(*args)
+    def size(*args): return _CdiObj.VarsVector_size(*args)
+    def clear(*args): return _CdiObj.VarsVector_clear(*args)
+    def swap(*args): return _CdiObj.VarsVector_swap(*args)
+    def get_allocator(*args): return _CdiObj.VarsVector_get_allocator(*args)
+    def begin(*args): return _CdiObj.VarsVector_begin(*args)
+    def end(*args): return _CdiObj.VarsVector_end(*args)
+    def rbegin(*args): return _CdiObj.VarsVector_rbegin(*args)
+    def rend(*args): return _CdiObj.VarsVector_rend(*args)
+    def pop_back(*args): return _CdiObj.VarsVector_pop_back(*args)
+    def erase(*args): return _CdiObj.VarsVector_erase(*args)
     def __init__(self, *args): 
         this = _CdiObj.new_VarsVector(*args)
         try: self.this.append(this)
         except: self.this = this
-    def push_back(self, *args): return _CdiObj.VarsVector_push_back(self, *args)
-    def front(self): return _CdiObj.VarsVector_front(self)
-    def back(self): return _CdiObj.VarsVector_back(self)
-    def assign(self, *args): return _CdiObj.VarsVector_assign(self, *args)
-    def resize(self, *args): return _CdiObj.VarsVector_resize(self, *args)
-    def insert(self, *args): return _CdiObj.VarsVector_insert(self, *args)
-    def reserve(self, *args): return _CdiObj.VarsVector_reserve(self, *args)
-    def capacity(self): return _CdiObj.VarsVector_capacity(self)
+    def push_back(*args): return _CdiObj.VarsVector_push_back(*args)
+    def front(*args): return _CdiObj.VarsVector_front(*args)
+    def back(*args): return _CdiObj.VarsVector_back(*args)
+    def assign(*args): return _CdiObj.VarsVector_assign(*args)
+    def resize(*args): return _CdiObj.VarsVector_resize(*args)
+    def insert(*args): return _CdiObj.VarsVector_insert(*args)
+    def reserve(*args): return _CdiObj.VarsVector_reserve(*args)
+    def capacity(*args): return _CdiObj.VarsVector_capacity(*args)
     __swig_destroy__ = _CdiObj.delete_VarsVector
     __del__ = lambda self : None;
 VarsVector_swigregister = _CdiObj.VarsVector_swigregister
@@ -339,44 +312,42 @@ class VarsMap(_object):
     __swig_getmethods__ = {}
     __getattr__ = lambda self, name: _swig_getattr(self, VarsMap, name)
     __repr__ = _swig_repr
-    def iterator(self): return _CdiObj.VarsMap_iterator(self)
+    def iterator(*args): return _CdiObj.VarsMap_iterator(*args)
     def __iter__(self): return self.iterator()
-    def __nonzero__(self): return _CdiObj.VarsMap___nonzero__(self)
-    def __bool__(self): return _CdiObj.VarsMap___bool__(self)
-    def __len__(self): return _CdiObj.VarsMap___len__(self)
+    def __nonzero__(*args): return _CdiObj.VarsMap___nonzero__(*args)
+    def __len__(*args): return _CdiObj.VarsMap___len__(*args)
+    def __getitem__(*args): return _CdiObj.VarsMap___getitem__(*args)
+    def __delitem__(*args): return _CdiObj.VarsMap___delitem__(*args)
+    def has_key(*args): return _CdiObj.VarsMap_has_key(*args)
+    def keys(*args): return _CdiObj.VarsMap_keys(*args)
+    def values(*args): return _CdiObj.VarsMap_values(*args)
+    def items(*args): return _CdiObj.VarsMap_items(*args)
+    def __contains__(*args): return _CdiObj.VarsMap___contains__(*args)
+    def key_iterator(*args): return _CdiObj.VarsMap_key_iterator(*args)
+    def value_iterator(*args): return _CdiObj.VarsMap_value_iterator(*args)
     def __iter__(self): return self.key_iterator()
     def iterkeys(self): return self.key_iterator()
     def itervalues(self): return self.value_iterator()
     def iteritems(self): return self.iterator()
-    def __getitem__(self, *args): return _CdiObj.VarsMap___getitem__(self, *args)
-    def __delitem__(self, *args): return _CdiObj.VarsMap___delitem__(self, *args)
-    def has_key(self, *args): return _CdiObj.VarsMap_has_key(self, *args)
-    def keys(self): return _CdiObj.VarsMap_keys(self)
-    def values(self): return _CdiObj.VarsMap_values(self)
-    def items(self): return _CdiObj.VarsMap_items(self)
-    def __contains__(self, *args): return _CdiObj.VarsMap___contains__(self, *args)
-    def key_iterator(self): return _CdiObj.VarsMap_key_iterator(self)
-    def value_iterator(self): return _CdiObj.VarsMap_value_iterator(self)
-    def __setitem__(self, *args): return _CdiObj.VarsMap___setitem__(self, *args)
-    def asdict(self): return _CdiObj.VarsMap_asdict(self)
+    def __setitem__(*args): return _CdiObj.VarsMap___setitem__(*args)
     def __init__(self, *args): 
         this = _CdiObj.new_VarsMap(*args)
         try: self.this.append(this)
         except: self.this = this
-    def empty(self): return _CdiObj.VarsMap_empty(self)
-    def size(self): return _CdiObj.VarsMap_size(self)
-    def clear(self): return _CdiObj.VarsMap_clear(self)
-    def swap(self, *args): return _CdiObj.VarsMap_swap(self, *args)
-    def get_allocator(self): return _CdiObj.VarsMap_get_allocator(self)
-    def begin(self): return _CdiObj.VarsMap_begin(self)
-    def end(self): return _CdiObj.VarsMap_end(self)
-    def rbegin(self): return _CdiObj.VarsMap_rbegin(self)
-    def rend(self): return _CdiObj.VarsMap_rend(self)
-    def count(self, *args): return _CdiObj.VarsMap_count(self, *args)
-    def erase(self, *args): return _CdiObj.VarsMap_erase(self, *args)
-    def find(self, *args): return _CdiObj.VarsMap_find(self, *args)
-    def lower_bound(self, *args): return _CdiObj.VarsMap_lower_bound(self, *args)
-    def upper_bound(self, *args): return _CdiObj.VarsMap_upper_bound(self, *args)
+    def empty(*args): return _CdiObj.VarsMap_empty(*args)
+    def size(*args): return _CdiObj.VarsMap_size(*args)
+    def clear(*args): return _CdiObj.VarsMap_clear(*args)
+    def swap(*args): return _CdiObj.VarsMap_swap(*args)
+    def get_allocator(*args): return _CdiObj.VarsMap_get_allocator(*args)
+    def begin(*args): return _CdiObj.VarsMap_begin(*args)
+    def end(*args): return _CdiObj.VarsMap_end(*args)
+    def rbegin(*args): return _CdiObj.VarsMap_rbegin(*args)
+    def rend(*args): return _CdiObj.VarsMap_rend(*args)
+    def count(*args): return _CdiObj.VarsMap_count(*args)
+    def erase(*args): return _CdiObj.VarsMap_erase(*args)
+    def find(*args): return _CdiObj.VarsMap_find(*args)
+    def lower_bound(*args): return _CdiObj.VarsMap_lower_bound(*args)
+    def upper_bound(*args): return _CdiObj.VarsMap_upper_bound(*args)
     __swig_destroy__ = _CdiObj.delete_VarsMap
     __del__ = lambda self : None;
 VarsMap_swigregister = _CdiObj.VarsMap_swigregister
@@ -388,44 +359,42 @@ class VarsByCode(_object):
     __swig_getmethods__ = {}
     __getattr__ = lambda self, name: _swig_getattr(self, VarsByCode, name)
     __repr__ = _swig_repr
-    def iterator(self): return _CdiObj.VarsByCode_iterator(self)
+    def iterator(*args): return _CdiObj.VarsByCode_iterator(*args)
     def __iter__(self): return self.iterator()
-    def __nonzero__(self): return _CdiObj.VarsByCode___nonzero__(self)
-    def __bool__(self): return _CdiObj.VarsByCode___bool__(self)
-    def __len__(self): return _CdiObj.VarsByCode___len__(self)
+    def __nonzero__(*args): return _CdiObj.VarsByCode___nonzero__(*args)
+    def __len__(*args): return _CdiObj.VarsByCode___len__(*args)
+    def __getitem__(*args): return _CdiObj.VarsByCode___getitem__(*args)
+    def __delitem__(*args): return _CdiObj.VarsByCode___delitem__(*args)
+    def has_key(*args): return _CdiObj.VarsByCode_has_key(*args)
+    def keys(*args): return _CdiObj.VarsByCode_keys(*args)
+    def values(*args): return _CdiObj.VarsByCode_values(*args)
+    def items(*args): return _CdiObj.VarsByCode_items(*args)
+    def __contains__(*args): return _CdiObj.VarsByCode___contains__(*args)
+    def key_iterator(*args): return _CdiObj.VarsByCode_key_iterator(*args)
+    def value_iterator(*args): return _CdiObj.VarsByCode_value_iterator(*args)
     def __iter__(self): return self.key_iterator()
     def iterkeys(self): return self.key_iterator()
     def itervalues(self): return self.value_iterator()
     def iteritems(self): return self.iterator()
-    def __getitem__(self, *args): return _CdiObj.VarsByCode___getitem__(self, *args)
-    def __delitem__(self, *args): return _CdiObj.VarsByCode___delitem__(self, *args)
-    def has_key(self, *args): return _CdiObj.VarsByCode_has_key(self, *args)
-    def keys(self): return _CdiObj.VarsByCode_keys(self)
-    def values(self): return _CdiObj.VarsByCode_values(self)
-    def items(self): return _CdiObj.VarsByCode_items(self)
-    def __contains__(self, *args): return _CdiObj.VarsByCode___contains__(self, *args)
-    def key_iterator(self): return _CdiObj.VarsByCode_key_iterator(self)
-    def value_iterator(self): return _CdiObj.VarsByCode_value_iterator(self)
-    def __setitem__(self, *args): return _CdiObj.VarsByCode___setitem__(self, *args)
-    def asdict(self): return _CdiObj.VarsByCode_asdict(self)
+    def __setitem__(*args): return _CdiObj.VarsByCode___setitem__(*args)
     def __init__(self, *args): 
         this = _CdiObj.new_VarsByCode(*args)
         try: self.this.append(this)
         except: self.this = this
-    def empty(self): return _CdiObj.VarsByCode_empty(self)
-    def size(self): return _CdiObj.VarsByCode_size(self)
-    def clear(self): return _CdiObj.VarsByCode_clear(self)
-    def swap(self, *args): return _CdiObj.VarsByCode_swap(self, *args)
-    def get_allocator(self): return _CdiObj.VarsByCode_get_allocator(self)
-    def begin(self): return _CdiObj.VarsByCode_begin(self)
-    def end(self): return _CdiObj.VarsByCode_end(self)
-    def rbegin(self): return _CdiObj.VarsByCode_rbegin(self)
-    def rend(self): return _CdiObj.VarsByCode_rend(self)
-    def count(self, *args): return _CdiObj.VarsByCode_count(self, *args)
-    def erase(self, *args): return _CdiObj.VarsByCode_erase(self, *args)
-    def find(self, *args): return _CdiObj.VarsByCode_find(self, *args)
-    def lower_bound(self, *args): return _CdiObj.VarsByCode_lower_bound(self, *args)
-    def upper_bound(self, *args): return _CdiObj.VarsByCode_upper_bound(self, *args)
+    def empty(*args): return _CdiObj.VarsByCode_empty(*args)
+    def size(*args): return _CdiObj.VarsByCode_size(*args)
+    def clear(*args): return _CdiObj.VarsByCode_clear(*args)
+    def swap(*args): return _CdiObj.VarsByCode_swap(*args)
+    def get_allocator(*args): return _CdiObj.VarsByCode_get_allocator(*args)
+    def begin(*args): return _CdiObj.VarsByCode_begin(*args)
+    def end(*args): return _CdiObj.VarsByCode_end(*args)
+    def rbegin(*args): return _CdiObj.VarsByCode_rbegin(*args)
+    def rend(*args): return _CdiObj.VarsByCode_rend(*args)
+    def count(*args): return _CdiObj.VarsByCode_count(*args)
+    def erase(*args): return _CdiObj.VarsByCode_erase(*args)
+    def find(*args): return _CdiObj.VarsByCode_find(*args)
+    def lower_bound(*args): return _CdiObj.VarsByCode_lower_bound(*args)
+    def upper_bound(*args): return _CdiObj.VarsByCode_upper_bound(*args)
     __swig_destroy__ = _CdiObj.delete_VarsByCode
     __del__ = lambda self : None;
 VarsByCode_swigregister = _CdiObj.VarsByCode_swigregister
@@ -437,44 +406,42 @@ class TaxesMap(_object):
     __swig_getmethods__ = {}
     __getattr__ = lambda self, name: _swig_getattr(self, TaxesMap, name)
     __repr__ = _swig_repr
-    def iterator(self): return _CdiObj.TaxesMap_iterator(self)
+    def iterator(*args): return _CdiObj.TaxesMap_iterator(*args)
     def __iter__(self): return self.iterator()
-    def __nonzero__(self): return _CdiObj.TaxesMap___nonzero__(self)
-    def __bool__(self): return _CdiObj.TaxesMap___bool__(self)
-    def __len__(self): return _CdiObj.TaxesMap___len__(self)
+    def __nonzero__(*args): return _CdiObj.TaxesMap___nonzero__(*args)
+    def __len__(*args): return _CdiObj.TaxesMap___len__(*args)
+    def __getitem__(*args): return _CdiObj.TaxesMap___getitem__(*args)
+    def __delitem__(*args): return _CdiObj.TaxesMap___delitem__(*args)
+    def has_key(*args): return _CdiObj.TaxesMap_has_key(*args)
+    def keys(*args): return _CdiObj.TaxesMap_keys(*args)
+    def values(*args): return _CdiObj.TaxesMap_values(*args)
+    def items(*args): return _CdiObj.TaxesMap_items(*args)
+    def __contains__(*args): return _CdiObj.TaxesMap___contains__(*args)
+    def key_iterator(*args): return _CdiObj.TaxesMap_key_iterator(*args)
+    def value_iterator(*args): return _CdiObj.TaxesMap_value_iterator(*args)
     def __iter__(self): return self.key_iterator()
     def iterkeys(self): return self.key_iterator()
     def itervalues(self): return self.value_iterator()
     def iteritems(self): return self.iterator()
-    def __getitem__(self, *args): return _CdiObj.TaxesMap___getitem__(self, *args)
-    def __delitem__(self, *args): return _CdiObj.TaxesMap___delitem__(self, *args)
-    def has_key(self, *args): return _CdiObj.TaxesMap_has_key(self, *args)
-    def keys(self): return _CdiObj.TaxesMap_keys(self)
-    def values(self): return _CdiObj.TaxesMap_values(self)
-    def items(self): return _CdiObj.TaxesMap_items(self)
-    def __contains__(self, *args): return _CdiObj.TaxesMap___contains__(self, *args)
-    def key_iterator(self): return _CdiObj.TaxesMap_key_iterator(self)
-    def value_iterator(self): return _CdiObj.TaxesMap_value_iterator(self)
-    def __setitem__(self, *args): return _CdiObj.TaxesMap___setitem__(self, *args)
-    def asdict(self): return _CdiObj.TaxesMap_asdict(self)
+    def __setitem__(*args): return _CdiObj.TaxesMap___setitem__(*args)
     def __init__(self, *args): 
         this = _CdiObj.new_TaxesMap(*args)
         try: self.this.append(this)
         except: self.this = this
-    def empty(self): return _CdiObj.TaxesMap_empty(self)
-    def size(self): return _CdiObj.TaxesMap_size(self)
-    def clear(self): return _CdiObj.TaxesMap_clear(self)
-    def swap(self, *args): return _CdiObj.TaxesMap_swap(self, *args)
-    def get_allocator(self): return _CdiObj.TaxesMap_get_allocator(self)
-    def begin(self): return _CdiObj.TaxesMap_begin(self)
-    def end(self): return _CdiObj.TaxesMap_end(self)
-    def rbegin(self): return _CdiObj.TaxesMap_rbegin(self)
-    def rend(self): return _CdiObj.TaxesMap_rend(self)
-    def count(self, *args): return _CdiObj.TaxesMap_count(self, *args)
-    def erase(self, *args): return _CdiObj.TaxesMap_erase(self, *args)
-    def find(self, *args): return _CdiObj.TaxesMap_find(self, *args)
-    def lower_bound(self, *args): return _CdiObj.TaxesMap_lower_bound(self, *args)
-    def upper_bound(self, *args): return _CdiObj.TaxesMap_upper_bound(self, *args)
+    def empty(*args): return _CdiObj.TaxesMap_empty(*args)
+    def size(*args): return _CdiObj.TaxesMap_size(*args)
+    def clear(*args): return _CdiObj.TaxesMap_clear(*args)
+    def swap(*args): return _CdiObj.TaxesMap_swap(*args)
+    def get_allocator(*args): return _CdiObj.TaxesMap_get_allocator(*args)
+    def begin(*args): return _CdiObj.TaxesMap_begin(*args)
+    def end(*args): return _CdiObj.TaxesMap_end(*args)
+    def rbegin(*args): return _CdiObj.TaxesMap_rbegin(*args)
+    def rend(*args): return _CdiObj.TaxesMap_rend(*args)
+    def count(*args): return _CdiObj.TaxesMap_count(*args)
+    def erase(*args): return _CdiObj.TaxesMap_erase(*args)
+    def find(*args): return _CdiObj.TaxesMap_find(*args)
+    def lower_bound(*args): return _CdiObj.TaxesMap_lower_bound(*args)
+    def upper_bound(*args): return _CdiObj.TaxesMap_upper_bound(*args)
     __swig_destroy__ = _CdiObj.delete_TaxesMap
     __del__ = lambda self : None;
 TaxesMap_swigregister = _CdiObj.TaxesMap_swigregister
@@ -486,44 +453,42 @@ class ZaxesMap(_object):
     __swig_getmethods__ = {}
     __getattr__ = lambda self, name: _swig_getattr(self, ZaxesMap, name)
     __repr__ = _swig_repr
-    def iterator(self): return _CdiObj.ZaxesMap_iterator(self)
+    def iterator(*args): return _CdiObj.ZaxesMap_iterator(*args)
     def __iter__(self): return self.iterator()
-    def __nonzero__(self): return _CdiObj.ZaxesMap___nonzero__(self)
-    def __bool__(self): return _CdiObj.ZaxesMap___bool__(self)
-    def __len__(self): return _CdiObj.ZaxesMap___len__(self)
+    def __nonzero__(*args): return _CdiObj.ZaxesMap___nonzero__(*args)
+    def __len__(*args): return _CdiObj.ZaxesMap___len__(*args)
+    def __getitem__(*args): return _CdiObj.ZaxesMap___getitem__(*args)
+    def __delitem__(*args): return _CdiObj.ZaxesMap___delitem__(*args)
+    def has_key(*args): return _CdiObj.ZaxesMap_has_key(*args)
+    def keys(*args): return _CdiObj.ZaxesMap_keys(*args)
+    def values(*args): return _CdiObj.ZaxesMap_values(*args)
+    def items(*args): return _CdiObj.ZaxesMap_items(*args)
+    def __contains__(*args): return _CdiObj.ZaxesMap___contains__(*args)
+    def key_iterator(*args): return _CdiObj.ZaxesMap_key_iterator(*args)
+    def value_iterator(*args): return _CdiObj.ZaxesMap_value_iterator(*args)
     def __iter__(self): return self.key_iterator()
     def iterkeys(self): return self.key_iterator()
     def itervalues(self): return self.value_iterator()
     def iteritems(self): return self.iterator()
-    def __getitem__(self, *args): return _CdiObj.ZaxesMap___getitem__(self, *args)
-    def __delitem__(self, *args): return _CdiObj.ZaxesMap___delitem__(self, *args)
-    def has_key(self, *args): return _CdiObj.ZaxesMap_has_key(self, *args)
-    def keys(self): return _CdiObj.ZaxesMap_keys(self)
-    def values(self): return _CdiObj.ZaxesMap_values(self)
-    def items(self): return _CdiObj.ZaxesMap_items(self)
-    def __contains__(self, *args): return _CdiObj.ZaxesMap___contains__(self, *args)
-    def key_iterator(self): return _CdiObj.ZaxesMap_key_iterator(self)
-    def value_iterator(self): return _CdiObj.ZaxesMap_value_iterator(self)
-    def __setitem__(self, *args): return _CdiObj.ZaxesMap___setitem__(self, *args)
-    def asdict(self): return _CdiObj.ZaxesMap_asdict(self)
+    def __setitem__(*args): return _CdiObj.ZaxesMap___setitem__(*args)
     def __init__(self, *args): 
         this = _CdiObj.new_ZaxesMap(*args)
         try: self.this.append(this)
         except: self.this = this
-    def empty(self): return _CdiObj.ZaxesMap_empty(self)
-    def size(self): return _CdiObj.ZaxesMap_size(self)
-    def clear(self): return _CdiObj.ZaxesMap_clear(self)
-    def swap(self, *args): return _CdiObj.ZaxesMap_swap(self, *args)
-    def get_allocator(self): return _CdiObj.ZaxesMap_get_allocator(self)
-    def begin(self): return _CdiObj.ZaxesMap_begin(self)
-    def end(self): return _CdiObj.ZaxesMap_end(self)
-    def rbegin(self): return _CdiObj.ZaxesMap_rbegin(self)
-    def rend(self): return _CdiObj.ZaxesMap_rend(self)
-    def count(self, *args): return _CdiObj.ZaxesMap_count(self, *args)
-    def erase(self, *args): return _CdiObj.ZaxesMap_erase(self, *args)
-    def find(self, *args): return _CdiObj.ZaxesMap_find(self, *args)
-    def lower_bound(self, *args): return _CdiObj.ZaxesMap_lower_bound(self, *args)
-    def upper_bound(self, *args): return _CdiObj.ZaxesMap_upper_bound(self, *args)
+    def empty(*args): return _CdiObj.ZaxesMap_empty(*args)
+    def size(*args): return _CdiObj.ZaxesMap_size(*args)
+    def clear(*args): return _CdiObj.ZaxesMap_clear(*args)
+    def swap(*args): return _CdiObj.ZaxesMap_swap(*args)
+    def get_allocator(*args): return _CdiObj.ZaxesMap_get_allocator(*args)
+    def begin(*args): return _CdiObj.ZaxesMap_begin(*args)
+    def end(*args): return _CdiObj.ZaxesMap_end(*args)
+    def rbegin(*args): return _CdiObj.ZaxesMap_rbegin(*args)
+    def rend(*args): return _CdiObj.ZaxesMap_rend(*args)
+    def count(*args): return _CdiObj.ZaxesMap_count(*args)
+    def erase(*args): return _CdiObj.ZaxesMap_erase(*args)
+    def find(*args): return _CdiObj.ZaxesMap_find(*args)
+    def lower_bound(*args): return _CdiObj.ZaxesMap_lower_bound(*args)
+    def upper_bound(*args): return _CdiObj.ZaxesMap_upper_bound(*args)
     __swig_destroy__ = _CdiObj.delete_ZaxesMap
     __del__ = lambda self : None;
 ZaxesMap_swigregister = _CdiObj.ZaxesMap_swigregister
@@ -535,44 +500,42 @@ class GridsMap(_object):
     __swig_getmethods__ = {}
     __getattr__ = lambda self, name: _swig_getattr(self, GridsMap, name)
     __repr__ = _swig_repr
-    def iterator(self): return _CdiObj.GridsMap_iterator(self)
+    def iterator(*args): return _CdiObj.GridsMap_iterator(*args)
     def __iter__(self): return self.iterator()
-    def __nonzero__(self): return _CdiObj.GridsMap___nonzero__(self)
-    def __bool__(self): return _CdiObj.GridsMap___bool__(self)
-    def __len__(self): return _CdiObj.GridsMap___len__(self)
+    def __nonzero__(*args): return _CdiObj.GridsMap___nonzero__(*args)
+    def __len__(*args): return _CdiObj.GridsMap___len__(*args)
+    def __getitem__(*args): return _CdiObj.GridsMap___getitem__(*args)
+    def __delitem__(*args): return _CdiObj.GridsMap___delitem__(*args)
+    def has_key(*args): return _CdiObj.GridsMap_has_key(*args)
+    def keys(*args): return _CdiObj.GridsMap_keys(*args)
+    def values(*args): return _CdiObj.GridsMap_values(*args)
+    def items(*args): return _CdiObj.GridsMap_items(*args)
+    def __contains__(*args): return _CdiObj.GridsMap___contains__(*args)
+    def key_iterator(*args): return _CdiObj.GridsMap_key_iterator(*args)
+    def value_iterator(*args): return _CdiObj.GridsMap_value_iterator(*args)
     def __iter__(self): return self.key_iterator()
     def iterkeys(self): return self.key_iterator()
     def itervalues(self): return self.value_iterator()
     def iteritems(self): return self.iterator()
-    def __getitem__(self, *args): return _CdiObj.GridsMap___getitem__(self, *args)
-    def __delitem__(self, *args): return _CdiObj.GridsMap___delitem__(self, *args)
-    def has_key(self, *args): return _CdiObj.GridsMap_has_key(self, *args)
-    def keys(self): return _CdiObj.GridsMap_keys(self)
-    def values(self): return _CdiObj.GridsMap_values(self)
-    def items(self): return _CdiObj.GridsMap_items(self)
-    def __contains__(self, *args): return _CdiObj.GridsMap___contains__(self, *args)
-    def key_iterator(self): return _CdiObj.GridsMap_key_iterator(self)
-    def value_iterator(self): return _CdiObj.GridsMap_value_iterator(self)
-    def __setitem__(self, *args): return _CdiObj.GridsMap___setitem__(self, *args)
-    def asdict(self): return _CdiObj.GridsMap_asdict(self)
+    def __setitem__(*args): return _CdiObj.GridsMap___setitem__(*args)
     def __init__(self, *args): 
         this = _CdiObj.new_GridsMap(*args)
         try: self.this.append(this)
         except: self.this = this
-    def empty(self): return _CdiObj.GridsMap_empty(self)
-    def size(self): return _CdiObj.GridsMap_size(self)
-    def clear(self): return _CdiObj.GridsMap_clear(self)
-    def swap(self, *args): return _CdiObj.GridsMap_swap(self, *args)
-    def get_allocator(self): return _CdiObj.GridsMap_get_allocator(self)
-    def begin(self): return _CdiObj.GridsMap_begin(self)
-    def end(self): return _CdiObj.GridsMap_end(self)
-    def rbegin(self): return _CdiObj.GridsMap_rbegin(self)
-    def rend(self): return _CdiObj.GridsMap_rend(self)
-    def count(self, *args): return _CdiObj.GridsMap_count(self, *args)
-    def erase(self, *args): return _CdiObj.GridsMap_erase(self, *args)
-    def find(self, *args): return _CdiObj.GridsMap_find(self, *args)
-    def lower_bound(self, *args): return _CdiObj.GridsMap_lower_bound(self, *args)
-    def upper_bound(self, *args): return _CdiObj.GridsMap_upper_bound(self, *args)
+    def empty(*args): return _CdiObj.GridsMap_empty(*args)
+    def size(*args): return _CdiObj.GridsMap_size(*args)
+    def clear(*args): return _CdiObj.GridsMap_clear(*args)
+    def swap(*args): return _CdiObj.GridsMap_swap(*args)
+    def get_allocator(*args): return _CdiObj.GridsMap_get_allocator(*args)
+    def begin(*args): return _CdiObj.GridsMap_begin(*args)
+    def end(*args): return _CdiObj.GridsMap_end(*args)
+    def rbegin(*args): return _CdiObj.GridsMap_rbegin(*args)
+    def rend(*args): return _CdiObj.GridsMap_rend(*args)
+    def count(*args): return _CdiObj.GridsMap_count(*args)
+    def erase(*args): return _CdiObj.GridsMap_erase(*args)
+    def find(*args): return _CdiObj.GridsMap_find(*args)
+    def lower_bound(*args): return _CdiObj.GridsMap_lower_bound(*args)
+    def upper_bound(*args): return _CdiObj.GridsMap_upper_bound(*args)
     __swig_destroy__ = _CdiObj.delete_GridsMap
     __del__ = lambda self : None;
 GridsMap_swigregister = _CdiObj.GridsMap_swigregister
@@ -660,12 +623,12 @@ class CdiGrid(_object):
     __swig_setmethods__["name"] = _CdiObj.CdiGrid_name_set
     __swig_getmethods__["name"] = _CdiObj.CdiGrid_name_get
     if _newclass:name = _swig_property(_CdiObj.CdiGrid_name_get, _CdiObj.CdiGrid_name_set)
-    def getValues(self): return _CdiObj.CdiGrid_getValues(self)
-    def getBounds(self): return _CdiObj.CdiGrid_getBounds(self)
-    def getValuesAsPointer(self, *args): return _CdiObj.CdiGrid_getValuesAsPointer(self, *args)
-    def getBoundsAsPointer(self, *args): return _CdiObj.CdiGrid_getBoundsAsPointer(self, *args)
-    def getFloatVals(self, *args): return _CdiObj.CdiGrid_getFloatVals(self, *args)
-    def getFloatBounds(self, *args): return _CdiObj.CdiGrid_getFloatBounds(self, *args)
+    def getValues(*args): return _CdiObj.CdiGrid_getValues(*args)
+    def getBounds(*args): return _CdiObj.CdiGrid_getBounds(*args)
+    def getValuesAsPointer(*args): return _CdiObj.CdiGrid_getValuesAsPointer(*args)
+    def getBoundsAsPointer(*args): return _CdiObj.CdiGrid_getBoundsAsPointer(*args)
+    def getFloatVals(*args): return _CdiObj.CdiGrid_getFloatVals(*args)
+    def getFloatBounds(*args): return _CdiObj.CdiGrid_getFloatBounds(*args)
 CdiGrid_swigregister = _CdiObj.CdiGrid_swigregister
 CdiGrid_swigregister(CdiGrid)
 
@@ -855,13 +818,13 @@ class CdiVariable(_object):
     __swig_setmethods__["taxis"] = _CdiObj.CdiVariable_taxis_set
     __swig_getmethods__["taxis"] = _CdiObj.CdiVariable_taxis_get
     if _newclass:taxis = _swig_property(_CdiObj.CdiVariable_taxis_get, _CdiObj.CdiVariable_taxis_set)
-    def sinfo(self): return _CdiObj.CdiVariable_sinfo(self)
-    def getValues(self): return _CdiObj.CdiVariable_getValues(self)
-    def getValuesWithLevel(self, tsID=0): return _CdiObj.CdiVariable_getValuesWithLevel(self, tsID)
-    def getFValues(self): return _CdiObj.CdiVariable_getFValues(self)
-    def getFValuesWithLevel(self, tsID=0): return _CdiObj.CdiVariable_getFValuesWithLevel(self, tsID)
-    def getValuesAsPointer(self): return _CdiObj.CdiVariable_getValuesAsPointer(self)
-    def getValuesWithLevelAsPointer(self, tsID=0): return _CdiObj.CdiVariable_getValuesWithLevelAsPointer(self, tsID)
+    def sinfo(*args): return _CdiObj.CdiVariable_sinfo(*args)
+    def getValues(*args): return _CdiObj.CdiVariable_getValues(*args)
+    def getValuesWithLevel(*args): return _CdiObj.CdiVariable_getValuesWithLevel(*args)
+    def getFValues(*args): return _CdiObj.CdiVariable_getFValues(*args)
+    def getFValuesWithLevel(*args): return _CdiObj.CdiVariable_getFValuesWithLevel(*args)
+    def getValuesAsPointer(*args): return _CdiObj.CdiVariable_getValuesAsPointer(*args)
+    def getValuesWithLevelAsPointer(*args): return _CdiObj.CdiVariable_getValuesWithLevelAsPointer(*args)
 CdiVariable_swigregister = _CdiObj.CdiVariable_swigregister
 CdiVariable_swigregister(CdiVariable)
 
@@ -922,10 +885,9 @@ class Cdi(_object):
     __swig_setmethods__["grids"] = _CdiObj.Cdi_grids_set
     __swig_getmethods__["grids"] = _CdiObj.Cdi_grids_get
     if _newclass:grids = _swig_property(_CdiObj.Cdi_grids_get, _CdiObj.Cdi_grids_set)
-    def griddes(self): return _CdiObj.Cdi_griddes(self)
+    def griddes(*args): return _CdiObj.Cdi_griddes(*args)
 Cdi_swigregister = _CdiObj.Cdi_swigregister
 Cdi_swigregister(Cdi)
 
-# This file is compatible with both classic and new-style classes.
 
 
diff --git a/libcdi/interfaces/python/cdiobj_wrap.cpp b/libcdi/interfaces/python/cdiobj_wrap.cpp
index cf41afa..c199f62 100644
--- a/libcdi/interfaces/python/cdiobj_wrap.cpp
+++ b/libcdi/interfaces/python/cdiobj_wrap.cpp
@@ -1,38 +1,30 @@
 /* ----------------------------------------------------------------------------
  * This file was automatically generated by SWIG (http://www.swig.org).
- * Version 3.0.2
- *
- * This file is not intended to be easily readable and contains a number of
+ * Version 1.3.31
+ * 
+ * This file is not intended to be easily readable and contains a number of 
  * coding conventions designed to improve portability and efficiency. Do not make
- * changes to this file unless you know what you are doing--modify the SWIG
- * interface file instead.
+ * changes to this file unless you know what you are doing--modify the SWIG 
+ * interface file instead. 
  * ----------------------------------------------------------------------------- */
 
 #define SWIGPYTHON
 #define SWIG_PYTHON_DIRECTOR_NO_VTABLE
 
-
 #ifdef __cplusplus
-/* SwigValueWrapper is described in swig.swg */
-template<typename T> class SwigValueWrapper {
-  struct SwigMovePointer {
-    T *ptr;
-    SwigMovePointer(T *p) : ptr(p) { }
-    ~SwigMovePointer() { delete ptr; }
-    SwigMovePointer& operator=(SwigMovePointer& rhs) { T* oldptr = ptr; ptr = 0; delete oldptr; ptr = rhs.ptr; rhs.ptr = 0; return *this; }
-  } pointer;
-  SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
-  SwigValueWrapper(const SwigValueWrapper<T>& rhs);
+template<class T> class SwigValueWrapper {
+    T *tt;
 public:
-  SwigValueWrapper() : pointer(0) { }
-  SwigValueWrapper& operator=(const T& t) { SwigMovePointer tmp(new T(t)); pointer = tmp; return *this; }
-  operator T&() const { return *pointer.ptr; }
-  T *operator&() { return pointer.ptr; }
+    SwigValueWrapper() : tt(0) { }
+    SwigValueWrapper(const SwigValueWrapper<T>& rhs) : tt(new T(*rhs.tt)) { }
+    SwigValueWrapper(const T& t) : tt(new T(t)) { }
+    ~SwigValueWrapper() { delete tt; } 
+    SwigValueWrapper& operator=(const T& t) { delete tt; tt = new T(t); return *this; }
+    operator T&() const { return *tt; }
+    T *operator&() { return tt; }
+private:
+    SwigValueWrapper& operator=(const SwigValueWrapper<T>& rhs);
 };
-
-template <typename T> T SwigValueInit() {
-  return T();
-}
 #endif
 
 /* -----------------------------------------------------------------------------
@@ -42,14 +34,14 @@ template <typename T> T SwigValueInit() {
 
 /* template workaround for compilers that cannot correctly implement the C++ standard */
 #ifndef SWIGTEMPLATEDISAMBIGUATOR
-# if defined(__SUNPRO_CC) && (__SUNPRO_CC <= 0x560)
-#  define SWIGTEMPLATEDISAMBIGUATOR template
-# elif defined(__HP_aCC)
-/* Needed even with `aCC -AA' when `aCC -V' reports HP ANSI C++ B3910B A.03.55 */
-/* If we find a maximum version that requires this, the test would be __HP_aCC <= 35500 for A.03.55 */
-#  define SWIGTEMPLATEDISAMBIGUATOR template
+# if defined(__SUNPRO_CC)
+#   if (__SUNPRO_CC <= 0x560)
+#     define SWIGTEMPLATEDISAMBIGUATOR template
+#   else
+#     define SWIGTEMPLATEDISAMBIGUATOR 
+#   endif
 # else
-#  define SWIGTEMPLATEDISAMBIGUATOR
+#   define SWIGTEMPLATEDISAMBIGUATOR 
 # endif
 #endif
 
@@ -66,20 +58,14 @@ template <typename T> T SwigValueInit() {
 #ifndef SWIGUNUSED
 # if defined(__GNUC__)
 #   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
-#     define SWIGUNUSED __attribute__ ((__unused__))
+#     define SWIGUNUSED __attribute__ ((__unused__)) 
 #   else
 #     define SWIGUNUSED
 #   endif
 # elif defined(__ICC)
-#   define SWIGUNUSED __attribute__ ((__unused__))
+#   define SWIGUNUSED __attribute__ ((__unused__)) 
 # else
-#   define SWIGUNUSED
-# endif
-#endif
-
-#ifndef SWIG_MSC_UNSUPPRESS_4505
-# if defined(_MSC_VER)
-#   pragma warning(disable : 4505) /* unreferenced local function has been removed */
+#   define SWIGUNUSED 
 # endif
 #endif
 
@@ -87,7 +73,7 @@ template <typename T> T SwigValueInit() {
 # ifdef __cplusplus
 #   define SWIGUNUSEDPARM(p)
 # else
-#   define SWIGUNUSEDPARM(p) p SWIGUNUSED
+#   define SWIGUNUSEDPARM(p) p SWIGUNUSED 
 # endif
 #endif
 
@@ -130,7 +116,7 @@ template <typename T> T SwigValueInit() {
 #   define SWIGSTDCALL __stdcall
 # else
 #   define SWIGSTDCALL
-# endif
+# endif 
 #endif
 
 /* Deal with Microsoft's attempt at deprecating C standard runtime functions */
@@ -138,32 +124,20 @@ template <typename T> T SwigValueInit() {
 # define _CRT_SECURE_NO_DEPRECATE
 #endif
 
-/* Deal with Microsoft's attempt at deprecating methods in the standard C++ library */
-#if !defined(SWIG_NO_SCL_SECURE_NO_DEPRECATE) && defined(_MSC_VER) && !defined(_SCL_SECURE_NO_DEPRECATE)
-# define _SCL_SECURE_NO_DEPRECATE
-#endif
-
 
-
-#if defined(_DEBUG) && defined(SWIG_PYTHON_INTERPRETER_NO_DEBUG)
-/* Use debug wrappers with the Python release dll */
-# undef _DEBUG
-# include <Python.h>
-# define _DEBUG
-#else
-# include <Python.h>
-#endif
+/* Python.h has to appear first */
+#include <Python.h>
 
 /* -----------------------------------------------------------------------------
  * swigrun.swg
  *
- * This file contains generic C API SWIG runtime support for pointer
+ * This file contains generic CAPI SWIG runtime support for pointer
  * type checking.
  * ----------------------------------------------------------------------------- */
 
 /* This should only be incremented when either the layout of swig_type_info changes,
    or for whatever reason, the runtime changes incompatibly */
-#define SWIG_RUNTIME_VERSION "4"
+#define SWIG_RUNTIME_VERSION "3"
 
 /* define SWIG_TYPE_TABLE_NAME as "SWIG_TYPE_TABLE" */
 #ifdef SWIG_TYPE_TABLE
@@ -176,11 +150,11 @@ template <typename T> T SwigValueInit() {
 
 /*
   You can use the SWIGRUNTIME and SWIGRUNTIMEINLINE macros for
-  creating a static or dynamic library from the SWIG runtime code.
-  In 99.9% of the cases, SWIG just needs to declare them as 'static'.
-
-  But only do this if strictly necessary, ie, if you have problems
-  with your compiler or suchlike.
+  creating a static or dynamic library from the swig runtime code.
+  In 99.9% of the cases, swig just needs to declare them as 'static'.
+  
+  But only do this if is strictly necessary, ie, if you have problems
+  with your compiler or so.
 */
 
 #ifndef SWIGRUNTIME
@@ -198,23 +172,22 @@ template <typename T> T SwigValueInit() {
 
 /* Flags for pointer conversions */
 #define SWIG_POINTER_DISOWN        0x1
-#define SWIG_CAST_NEW_MEMORY       0x2
 
 /* Flags for new pointer objects */
 #define SWIG_POINTER_OWN           0x1
 
 
-/*
+/* 
    Flags/methods for returning states.
-
-   The SWIG conversion methods, as ConvertPtr, return an integer
+   
+   The swig conversion methods, as ConvertPtr, return and integer 
    that tells if the conversion was successful or not. And if not,
    an error code can be returned (see swigerrors.swg for the codes).
-
+   
    Use the following macros/flags to set or process the returning
    states.
-
-   In old versions of SWIG, code such as the following was usually written:
+   
+   In old swig versions, you usually write code as:
 
      if (SWIG_ConvertPtr(obj,vptr,ty.flags) != -1) {
        // success code
@@ -222,7 +195,7 @@ template <typename T> T SwigValueInit() {
        //fail code
      }
 
-   Now you can be more explicit:
+   Now you can be more explicit as:
 
     int res = SWIG_ConvertPtr(obj,vptr,ty.flags);
     if (SWIG_IsOK(res)) {
@@ -231,7 +204,7 @@ template <typename T> T SwigValueInit() {
       // fail code
     }
 
-   which is the same really, but now you can also do
+   that seems to be the same, but now you can also do
 
     Type *ptr;
     int res = SWIG_ConvertPtr(obj,(void **)(&ptr),ty.flags);
@@ -246,28 +219,28 @@ template <typename T> T SwigValueInit() {
     } else {
       // fail code
     }
-
+    
    I.e., now SWIG_ConvertPtr can return new objects and you can
    identify the case and take care of the deallocation. Of course that
-   also requires SWIG_ConvertPtr to return new result values, such as
-
-      int SWIG_ConvertPtr(obj, ptr,...) {
-        if (<obj is ok>) {
-          if (<need new object>) {
-            *ptr = <ptr to new allocated object>;
-            return SWIG_NEWOBJ;
-          } else {
-            *ptr = <ptr to old object>;
-            return SWIG_OLDOBJ;
-          }
-        } else {
-          return SWIG_BADOBJ;
-        }
+   requires also to SWIG_ConvertPtr to return new result values, as
+
+      int SWIG_ConvertPtr(obj, ptr,...) {         
+        if (<obj is ok>) {			       
+          if (<need new object>) {		       
+            *ptr = <ptr to new allocated object>; 
+            return SWIG_NEWOBJ;		       
+          } else {				       
+            *ptr = <ptr to old object>;	       
+            return SWIG_OLDOBJ;		       
+          } 				       
+        } else {				       
+          return SWIG_BADOBJ;		       
+        }					       
       }
 
    Of course, returning the plain '0(success)/-1(fail)' still works, but you can be
    more explicit by returning SWIG_BADOBJ, SWIG_ERROR or any of the
-   SWIG errors code.
+   swig errors code.
 
    Finally, if the SWIG_CASTRANK_MODE is enabled, the result code
    allows to return the 'cast rank', for example, if you have this
@@ -276,17 +249,18 @@ template <typename T> T SwigValueInit() {
        int fooi(int);
 
    and you call
-
+ 
       food(1)   // cast rank '1'  (1 -> 1.0)
       fooi(1)   // cast rank '0'
 
    just use the SWIG_AddCast()/SWIG_CheckState()
-*/
 
-#define SWIG_OK                    (0)
+
+ */
+#define SWIG_OK                    (0) 
 #define SWIG_ERROR                 (-1)
 #define SWIG_IsOK(r)               (r >= 0)
-#define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)
+#define SWIG_ArgError(r)           ((r != SWIG_ERROR) ? r : SWIG_TypeError)  
 
 /* The CastRankLimit says how many bits are used for the cast rank */
 #define SWIG_CASTRANKLIMIT         (1 << 8)
@@ -307,6 +281,7 @@ template <typename T> T SwigValueInit() {
 #define SWIG_DelTmpMask(r)         (SWIG_IsOK(r) ? (r & ~SWIG_TMPOBJMASK) : r)
 #define SWIG_IsTmpObj(r)           (SWIG_IsOK(r) && (r & SWIG_TMPOBJMASK))
 
+
 /* Cast-Rank Mode */
 #if defined(SWIG_CASTRANK_MODE)
 #  ifndef SWIG_TypeRank
@@ -317,28 +292,30 @@ template <typename T> T SwigValueInit() {
 #  endif
 #  define SWIG_CASTRANKMASK          ((SWIG_CASTRANKLIMIT) -1)
 #  define SWIG_CastRank(r)           (r & SWIG_CASTRANKMASK)
-SWIGINTERNINLINE int SWIG_AddCast(int r) {
+SWIGINTERNINLINE int SWIG_AddCast(int r) { 
   return SWIG_IsOK(r) ? ((SWIG_CastRank(r) < SWIG_MAXCASTRANK) ? (r + 1) : SWIG_ERROR) : r;
 }
-SWIGINTERNINLINE int SWIG_CheckState(int r) {
-  return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0;
+SWIGINTERNINLINE int SWIG_CheckState(int r) { 
+  return SWIG_IsOK(r) ? SWIG_CastRank(r) + 1 : 0; 
 }
 #else /* no cast-rank mode */
-#  define SWIG_AddCast(r) (r)
+#  define SWIG_AddCast
 #  define SWIG_CheckState(r) (SWIG_IsOK(r) ? 1 : 0)
 #endif
 
 
+
+
 #include <string.h>
 
 #ifdef __cplusplus
 extern "C" {
 #endif
 
-typedef void *(*swig_converter_func)(void *, int *);
+typedef void *(*swig_converter_func)(void *);
 typedef struct swig_type_info *(*swig_dycast_func)(void **);
 
-/* Structure to store information on one type */
+/* Structure to store inforomation on one type */
 typedef struct swig_type_info {
   const char             *name;			/* mangled name of this type */
   const char             *str;			/* human readable name of this type */
@@ -368,7 +345,7 @@ typedef struct swig_module_info {
   void                    *clientdata;		/* Language specific module data */
 } swig_module_info;
 
-/*
+/* 
   Compare two type names skipping the space characters, therefore
   "char*" == "char *" and "Class<int>" == "Class<int >", etc.
 
@@ -383,23 +360,23 @@ SWIG_TypeNameComp(const char *f1, const char *l1,
     while ((*f2 == ' ') && (f2 != l2)) ++f2;
     if (*f1 != *f2) return (*f1 > *f2) ? 1 : -1;
   }
-  return (int)((l1 - f1) - (l2 - f2));
+  return (l1 - f1) - (l2 - f2);
 }
 
 /*
   Check type equivalence in a name list like <name1>|<name2>|...
-  Return 0 if equal, -1 if nb < tb, 1 if nb > tb
+  Return 0 if not equal, 1 if equal
 */
 SWIGRUNTIME int
-SWIG_TypeCmp(const char *nb, const char *tb) {
-  int equiv = 1;
+SWIG_TypeEquiv(const char *nb, const char *tb) {
+  int equiv = 0;
   const char* te = tb + strlen(tb);
   const char* ne = nb;
-  while (equiv != 0 && *ne) {
+  while (!equiv && *ne) {
     for (nb = ne; *ne; ++ne) {
       if (*ne == '|') break;
     }
-    equiv = SWIG_TypeNameComp(nb, ne, tb, te);
+    equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
     if (*ne) ++ne;
   }
   return equiv;
@@ -407,76 +384,69 @@ SWIG_TypeCmp(const char *nb, const char *tb) {
 
 /*
   Check type equivalence in a name list like <name1>|<name2>|...
-  Return 0 if not equal, 1 if equal
+  Return 0 if equal, -1 if nb < tb, 1 if nb > tb
 */
 SWIGRUNTIME int
-SWIG_TypeEquiv(const char *nb, const char *tb) {
-  return SWIG_TypeCmp(nb, tb) == 0 ? 1 : 0;
+SWIG_TypeCompare(const char *nb, const char *tb) {
+  int equiv = 0;
+  const char* te = tb + strlen(tb);
+  const char* ne = nb;
+  while (!equiv && *ne) {
+    for (nb = ne; *ne; ++ne) {
+      if (*ne == '|') break;
+    }
+    equiv = (SWIG_TypeNameComp(nb, ne, tb, te) == 0) ? 1 : 0;
+    if (*ne) ++ne;
+  }
+  return equiv;
 }
 
+
+/* think of this as a c++ template<> or a scheme macro */
+#define SWIG_TypeCheck_Template(comparison, ty)         \
+  if (ty) {                                             \
+    swig_cast_info *iter = ty->cast;                    \
+    while (iter) {                                      \
+      if (comparison) {                                 \
+        if (iter == ty->cast) return iter;              \
+        /* Move iter to the top of the linked list */   \
+        iter->prev->next = iter->next;                  \
+        if (iter->next)                                 \
+          iter->next->prev = iter->prev;                \
+        iter->next = ty->cast;                          \
+        iter->prev = 0;                                 \
+        if (ty->cast) ty->cast->prev = iter;            \
+        ty->cast = iter;                                \
+        return iter;                                    \
+      }                                                 \
+      iter = iter->next;                                \
+    }                                                   \
+  }                                                     \
+  return 0
+
 /*
   Check the typename
 */
 SWIGRUNTIME swig_cast_info *
 SWIG_TypeCheck(const char *c, swig_type_info *ty) {
-  if (ty) {
-    swig_cast_info *iter = ty->cast;
-    while (iter) {
-      if (strcmp(iter->type->name, c) == 0) {
-        if (iter == ty->cast)
-          return iter;
-        /* Move iter to the top of the linked list */
-        iter->prev->next = iter->next;
-        if (iter->next)
-          iter->next->prev = iter->prev;
-        iter->next = ty->cast;
-        iter->prev = 0;
-        if (ty->cast) ty->cast->prev = iter;
-        ty->cast = iter;
-        return iter;
-      }
-      iter = iter->next;
-    }
-  }
-  return 0;
+  SWIG_TypeCheck_Template(strcmp(iter->type->name, c) == 0, ty);
 }
 
-/*
-  Identical to SWIG_TypeCheck, except strcmp is replaced with a pointer comparison
-*/
+/* Same as previous function, except strcmp is replaced with a pointer comparison */
 SWIGRUNTIME swig_cast_info *
-SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *ty) {
-  if (ty) {
-    swig_cast_info *iter = ty->cast;
-    while (iter) {
-      if (iter->type == from) {
-        if (iter == ty->cast)
-          return iter;
-        /* Move iter to the top of the linked list */
-        iter->prev->next = iter->next;
-        if (iter->next)
-          iter->next->prev = iter->prev;
-        iter->next = ty->cast;
-        iter->prev = 0;
-        if (ty->cast) ty->cast->prev = iter;
-        ty->cast = iter;
-        return iter;
-      }
-      iter = iter->next;
-    }
-  }
-  return 0;
+SWIG_TypeCheckStruct(swig_type_info *from, swig_type_info *into) {
+  SWIG_TypeCheck_Template(iter->type == from, into);
 }
 
 /*
   Cast a pointer up an inheritance hierarchy
 */
 SWIGRUNTIMEINLINE void *
-SWIG_TypeCast(swig_cast_info *ty, void *ptr, int *newmemory) {
-  return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr, newmemory);
+SWIG_TypeCast(swig_cast_info *ty, void *ptr) {
+  return ((!ty) || (!ty->converter)) ? ptr : (*ty->converter)(ptr);
 }
 
-/*
+/* 
    Dynamic pointer casting. Down an inheritance hierarchy
 */
 SWIGRUNTIME swig_type_info *
@@ -520,7 +490,7 @@ SWIG_TypePrettyName(const swig_type_info *type) {
     return type->name;
 }
 
-/*
+/* 
    Set the clientdata field for a type
 */
 SWIGRUNTIME void
@@ -528,14 +498,14 @@ SWIG_TypeClientData(swig_type_info *ti, void *clientdata) {
   swig_cast_info *cast = ti->cast;
   /* if (ti->clientdata == clientdata) return; */
   ti->clientdata = clientdata;
-
+  
   while (cast) {
     if (!cast->converter) {
       swig_type_info *tc = cast->type;
       if (!tc->clientdata) {
 	SWIG_TypeClientData(tc, clientdata);
       }
-    }
+    }    
     cast = cast->next;
   }
 }
@@ -544,31 +514,31 @@ SWIG_TypeNewClientData(swig_type_info *ti, void *clientdata) {
   SWIG_TypeClientData(ti, clientdata);
   ti->owndata = 1;
 }
-
+  
 /*
   Search for a swig_type_info structure only by mangled name
   Search is a O(log #types)
-
-  We start searching at module start, and finish searching when start == end.
+  
+  We start searching at module start, and finish searching when start == end.  
   Note: if start == end at the beginning of the function, we go all the way around
   the circular list.
 */
 SWIGRUNTIME swig_type_info *
-SWIG_MangledTypeQueryModule(swig_module_info *start,
-                            swig_module_info *end,
+SWIG_MangledTypeQueryModule(swig_module_info *start, 
+                            swig_module_info *end, 
 		            const char *name) {
   swig_module_info *iter = start;
   do {
     if (iter->size) {
-      size_t l = 0;
-      size_t r = iter->size - 1;
+      register size_t l = 0;
+      register size_t r = iter->size - 1;
       do {
 	/* since l+r >= 0, we can (>> 1) instead (/ 2) */
-	size_t i = (l + r) >> 1;
+	register size_t i = (l + r) >> 1; 
 	const char *iname = iter->types[i]->name;
 	if (iname) {
-	  int compare = strcmp(name, iname);
-	  if (compare == 0) {
+	  register int compare = strcmp(name, iname);
+	  if (compare == 0) {	    
 	    return iter->types[i];
 	  } else if (compare < 0) {
 	    if (i) {
@@ -593,14 +563,14 @@ SWIG_MangledTypeQueryModule(swig_module_info *start,
   Search for a swig_type_info structure for either a mangled name or a human readable name.
   It first searches the mangled names of the types, which is a O(log #types)
   If a type is not found it then searches the human readable names, which is O(#types).
-
-  We start searching at module start, and finish searching when start == end.
+  
+  We start searching at module start, and finish searching when start == end.  
   Note: if start == end at the beginning of the function, we go all the way around
   the circular list.
 */
 SWIGRUNTIME swig_type_info *
-SWIG_TypeQueryModule(swig_module_info *start,
-                     swig_module_info *end,
+SWIG_TypeQueryModule(swig_module_info *start, 
+                     swig_module_info *end, 
 		     const char *name) {
   /* STEP 1: Search the name field using binary search */
   swig_type_info *ret = SWIG_MangledTypeQueryModule(start, end, name);
@@ -611,7 +581,7 @@ SWIG_TypeQueryModule(swig_module_info *start,
        of the str field (the human readable name) */
     swig_module_info *iter = start;
     do {
-      size_t i = 0;
+      register size_t i = 0;
       for (; i < iter->size; ++i) {
 	if (iter->types[i]->str && (SWIG_TypeEquiv(iter->types[i]->str, name)))
 	  return iter->types[i];
@@ -619,56 +589,56 @@ SWIG_TypeQueryModule(swig_module_info *start,
       iter = iter->next;
     } while (iter != end);
   }
-
+  
   /* neither found a match */
   return 0;
 }
 
-/*
+/* 
    Pack binary data into a string
 */
 SWIGRUNTIME char *
 SWIG_PackData(char *c, void *ptr, size_t sz) {
   static const char hex[17] = "0123456789abcdef";
-  const unsigned char *u = (unsigned char *) ptr;
-  const unsigned char *eu =  u + sz;
+  register const unsigned char *u = (unsigned char *) ptr;
+  register const unsigned char *eu =  u + sz;
   for (; u != eu; ++u) {
-    unsigned char uu = *u;
+    register unsigned char uu = *u;
     *(c++) = hex[(uu & 0xf0) >> 4];
     *(c++) = hex[uu & 0xf];
   }
   return c;
 }
 
-/*
+/* 
    Unpack binary data from a string
 */
 SWIGRUNTIME const char *
 SWIG_UnpackData(const char *c, void *ptr, size_t sz) {
-  unsigned char *u = (unsigned char *) ptr;
-  const unsigned char *eu = u + sz;
+  register unsigned char *u = (unsigned char *) ptr;
+  register const unsigned char *eu = u + sz;
   for (; u != eu; ++u) {
-    char d = *(c++);
-    unsigned char uu;
+    register char d = *(c++);
+    register unsigned char uu;
     if ((d >= '0') && (d <= '9'))
       uu = ((d - '0') << 4);
     else if ((d >= 'a') && (d <= 'f'))
       uu = ((d - ('a'-10)) << 4);
-    else
+    else 
       return (char *) 0;
     d = *(c++);
     if ((d >= '0') && (d <= '9'))
       uu |= (d - '0');
     else if ((d >= 'a') && (d <= 'f'))
       uu |= (d - ('a'-10));
-    else
+    else 
       return (char *) 0;
     *u = uu;
   }
   return c;
 }
 
-/*
+/* 
    Pack 'void *' into a string buffer.
 */
 SWIGRUNTIME char *
@@ -728,92 +698,22 @@ SWIG_UnpackDataName(const char *c, void *ptr, size_t sz, const char *name) {
 #endif
 
 /*  Errors in SWIG */
-#define  SWIG_UnknownError    	   -1
-#define  SWIG_IOError        	   -2
-#define  SWIG_RuntimeError   	   -3
-#define  SWIG_IndexError     	   -4
-#define  SWIG_TypeError      	   -5
-#define  SWIG_DivisionByZero 	   -6
-#define  SWIG_OverflowError  	   -7
-#define  SWIG_SyntaxError    	   -8
-#define  SWIG_ValueError     	   -9
+#define  SWIG_UnknownError    	   -1 
+#define  SWIG_IOError        	   -2 
+#define  SWIG_RuntimeError   	   -3 
+#define  SWIG_IndexError     	   -4 
+#define  SWIG_TypeError      	   -5 
+#define  SWIG_DivisionByZero 	   -6 
+#define  SWIG_OverflowError  	   -7 
+#define  SWIG_SyntaxError    	   -8 
+#define  SWIG_ValueError     	   -9 
 #define  SWIG_SystemError    	   -10
 #define  SWIG_AttributeError 	   -11
-#define  SWIG_MemoryError    	   -12
+#define  SWIG_MemoryError    	   -12 
 #define  SWIG_NullReferenceError   -13
 
 
 
-/* Compatibility macros for Python 3 */
-#if PY_VERSION_HEX >= 0x03000000
-
-#define PyClass_Check(obj) PyObject_IsInstance(obj, (PyObject *)&PyType_Type)
-#define PyInt_Check(x) PyLong_Check(x)
-#define PyInt_AsLong(x) PyLong_AsLong(x)
-#define PyInt_FromLong(x) PyLong_FromLong(x)
-#define PyInt_FromSize_t(x) PyLong_FromSize_t(x)
-#define PyString_Check(name) PyBytes_Check(name)
-#define PyString_FromString(x) PyUnicode_FromString(x)
-#define PyString_Format(fmt, args)  PyUnicode_Format(fmt, args)
-#define PyString_AsString(str) PyBytes_AsString(str)
-#define PyString_Size(str) PyBytes_Size(str)	
-#define PyString_InternFromString(key) PyUnicode_InternFromString(key)
-#define Py_TPFLAGS_HAVE_CLASS Py_TPFLAGS_BASETYPE
-#define PyString_AS_STRING(x) PyUnicode_AS_STRING(x)
-#define _PyLong_FromSsize_t(x) PyLong_FromSsize_t(x)
-
-#endif
-
-#ifndef Py_TYPE
-#  define Py_TYPE(op) ((op)->ob_type)
-#endif
-
-/* SWIG APIs for compatibility of both Python 2 & 3 */
-
-#if PY_VERSION_HEX >= 0x03000000
-#  define SWIG_Python_str_FromFormat PyUnicode_FromFormat
-#else
-#  define SWIG_Python_str_FromFormat PyString_FromFormat
-#endif
-
-
-/* Warning: This function will allocate a new string in Python 3,
- * so please call SWIG_Python_str_DelForPy3(x) to free the space.
- */
-SWIGINTERN char*
-SWIG_Python_str_AsChar(PyObject *str)
-{
-#if PY_VERSION_HEX >= 0x03000000
-  char *cstr;
-  char *newstr;
-  Py_ssize_t len;
-  str = PyUnicode_AsUTF8String(str);
-  PyBytes_AsStringAndSize(str, &cstr, &len);
-  newstr = (char *) malloc(len+1);
-  memcpy(newstr, cstr, len+1);
-  Py_XDECREF(str);
-  return newstr;
-#else
-  return PyString_AsString(str);
-#endif
-}
-
-#if PY_VERSION_HEX >= 0x03000000
-#  define SWIG_Python_str_DelForPy3(x) free( (void*) (x) )
-#else
-#  define SWIG_Python_str_DelForPy3(x) 
-#endif
-
-
-SWIGINTERN PyObject*
-SWIG_Python_str_FromChar(const char *c)
-{
-#if PY_VERSION_HEX >= 0x03000000
-  return PyUnicode_FromString(c); 
-#else
-  return PyString_FromString(c);
-#endif
-}
 
 /* Add PyOS_snprintf for old Pythons */
 #if PY_VERSION_HEX < 0x02020000
@@ -860,7 +760,6 @@ PyString_FromFormat(const char *fmt, ...) {
 #  define PyObject_GenericGetAttr 0
 # endif
 #endif
-
 /* Py_NotImplemented is defined in 2.1 and up. */
 #if PY_VERSION_HEX < 0x02010000
 # ifndef Py_NotImplemented
@@ -868,6 +767,7 @@ PyString_FromFormat(const char *fmt, ...) {
 # endif
 #endif
 
+
 /* A crude PyString_AsStringAndSize implementation for old Pythons */
 #if PY_VERSION_HEX < 0x02010000
 # ifndef PyString_AsStringAndSize
@@ -882,6 +782,7 @@ PyString_FromFormat(const char *fmt, ...) {
 # endif
 #endif
 
+
 /* PyBool_FromLong for old Pythons */
 #if PY_VERSION_HEX < 0x02030000
 static
@@ -900,67 +801,6 @@ PyObject *PyBool_FromLong(long ok)
 typedef int Py_ssize_t;
 # define PY_SSIZE_T_MAX INT_MAX
 # define PY_SSIZE_T_MIN INT_MIN
-typedef inquiry lenfunc;
-typedef intargfunc ssizeargfunc;
-typedef intintargfunc ssizessizeargfunc;
-typedef intobjargproc ssizeobjargproc;
-typedef intintobjargproc ssizessizeobjargproc;
-typedef getreadbufferproc readbufferproc;
-typedef getwritebufferproc writebufferproc;
-typedef getsegcountproc segcountproc;
-typedef getcharbufferproc charbufferproc;
-static long PyNumber_AsSsize_t (PyObject *x, void *SWIGUNUSEDPARM(exc))
-{
-  long result = 0;
-  PyObject *i = PyNumber_Int(x);
-  if (i) {
-    result = PyInt_AsLong(i);
-    Py_DECREF(i);
-  }
-  return result;
-}
-#endif
-
-#if PY_VERSION_HEX < 0x02050000
-#define PyInt_FromSize_t(x) PyInt_FromLong((long)x)
-#endif
-
-#if PY_VERSION_HEX < 0x02040000
-#define Py_VISIT(op)				\
-  do { 						\
-    if (op) {					\
-      int vret = visit((op), arg);		\
-      if (vret)					\
-        return vret;				\
-    }						\
-  } while (0)
-#endif
-
-#if PY_VERSION_HEX < 0x02030000
-typedef struct {
-  PyTypeObject type;
-  PyNumberMethods as_number;
-  PyMappingMethods as_mapping;
-  PySequenceMethods as_sequence;
-  PyBufferProcs as_buffer;
-  PyObject *name, *slots;
-} PyHeapTypeObject;
-#endif
-
-#if PY_VERSION_HEX < 0x02030000
-typedef destructor freefunc;
-#endif
-
-#if ((PY_MAJOR_VERSION == 2 && PY_MINOR_VERSION > 6) || \
-     (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION > 0) || \
-     (PY_MAJOR_VERSION > 3))
-# define SWIGPY_USE_CAPSULE
-# define SWIGPY_CAPSULE_NAME ((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION ".type_pointer_capsule" SWIG_TYPE_TABLE_NAME)
-#endif
-
-#if PY_VERSION_HEX < 0x03020000
-#define PyDescr_TYPE(x) (((PyDescrObject *)(x))->d_type)
-#define PyDescr_NAME(x) (((PyDescrObject *)(x))->d_name)
 #endif
 
 /* -----------------------------------------------------------------------------
@@ -1020,20 +860,19 @@ SWIG_Python_AddErrorMsg(const char* mesg)
 
   if (PyErr_Occurred()) PyErr_Fetch(&type, &value, &traceback);
   if (value) {
-    char *tmp;
     PyObject *old_str = PyObject_Str(value);
     PyErr_Clear();
     Py_XINCREF(type);
-
-    PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
-    SWIG_Python_str_DelForPy3(tmp);
+    PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
     Py_DECREF(old_str);
     Py_DECREF(value);
   } else {
-    PyErr_SetString(PyExc_RuntimeError, mesg);
+    PyErr_Format(PyExc_RuntimeError, mesg);
   }
 }
 
+
+
 #if defined(SWIG_PYTHON_NO_THREADS)
 #  if defined(SWIG_PYTHON_THREADS)
 #    undef SWIG_PYTHON_THREADS
@@ -1107,6 +946,9 @@ SWIG_Python_AddErrorMsg(const char* mesg)
 
 #ifdef __cplusplus
 extern "C" {
+#if 0
+} /* cc-mode */
+#endif
 #endif
 
 /* -----------------------------------------------------------------------------
@@ -1127,29 +969,18 @@ typedef struct swig_const_info {
   swig_type_info **ptype;
 } swig_const_info;
 
-
-/* -----------------------------------------------------------------------------
- * Wrapper of PyInstanceMethod_New() used in Python 3
- * It is exported to the generated module, used for -fastproxy
- * ----------------------------------------------------------------------------- */
-#if PY_VERSION_HEX >= 0x03000000
-SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *func)
-{
-  return PyInstanceMethod_New(func);
-}
-#else
-SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self), PyObject *SWIGUNUSEDPARM(func))
-{
-  return NULL;
-}
-#endif
-
 #ifdef __cplusplus
+#if 0
+{ /* cc-mode */
+#endif
 }
 #endif
 
 
 /* -----------------------------------------------------------------------------
+ * See the LICENSE file for information on copyright, usage and redistribution
+ * of SWIG, and the README file for authors - http://www.swig.org/release.html.
+ *
  * pyrun.swg
  *
  * This file contains the runtime support for Python modules
@@ -1164,15 +995,7 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self),
 #define SWIG_Python_ConvertPtr(obj, pptr, type, flags)  SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, 0)
 #define SWIG_ConvertPtr(obj, pptr, type, flags)         SWIG_Python_ConvertPtr(obj, pptr, type, flags)
 #define SWIG_ConvertPtrAndOwn(obj,pptr,type,flags,own)  SWIG_Python_ConvertPtrAndOwn(obj, pptr, type, flags, own)
-
-#ifdef SWIGPYTHON_BUILTIN
-#define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(self, ptr, type, flags)
-#else
-#define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
-#endif
-
-#define SWIG_InternalNewPointerObj(ptr, type, flags)	SWIG_Python_NewPointerObj(NULL, ptr, type, flags)
-
+#define SWIG_NewPointerObj(ptr, type, flags)            SWIG_Python_NewPointerObj(ptr, type, flags)
 #define SWIG_CheckImplicit(ty)                          SWIG_Python_CheckImplicit(ty) 
 #define SWIG_AcquirePtr(ptr, src)                       SWIG_Python_AcquirePtr(ptr, src)
 #define swig_owntype                                    int
@@ -1187,7 +1010,7 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self),
 
 /* for C or C++ function pointers */
 #define SWIG_ConvertFunctionPtr(obj, pptr, type)        SWIG_Python_ConvertFunctionPtr(obj, pptr, type)
-#define SWIG_NewFunctionPtrObj(ptr, type)               SWIG_Python_NewPointerObj(NULL, ptr, type, 0)
+#define SWIG_NewFunctionPtrObj(ptr, type)               SWIG_Python_NewPointerObj(ptr, type, 0)
 
 /* for C++ member pointers, ie, member methods */
 #define SWIG_ConvertMember(obj, ptr, sz, ty)            SWIG_Python_ConvertPacked(obj, ptr, sz, ty)
@@ -1196,9 +1019,9 @@ SWIGRUNTIME PyObject* SWIG_PyInstanceMethod_New(PyObject *SWIGUNUSEDPARM(self),
 
 /* Runtime API */
 
-#define SWIG_GetModule(clientdata)                      SWIG_Python_GetModule(clientdata)
+#define SWIG_GetModule(clientdata)                      SWIG_Python_GetModule()
 #define SWIG_SetModule(clientdata, pointer)             SWIG_Python_SetModule(pointer)
-#define SWIG_NewClientData(obj)                         SwigPyClientData_New(obj)
+#define SWIG_NewClientData(obj)                         PySwigClientData_New(obj)
 
 #define SWIG_SetErrorObj                                SWIG_Python_SetErrorObj                            
 #define SWIG_SetErrorMsg                        	SWIG_Python_SetErrorMsg				   
@@ -1222,7 +1045,7 @@ SWIG_Python_SetErrorObj(PyObject *errtype, PyObject *obj) {
 SWIGINTERN void 
 SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
   SWIG_PYTHON_THREAD_BEGIN_BLOCK;
-  PyErr_SetString(errtype, msg);
+  PyErr_SetString(errtype, (char *) msg);
   SWIG_PYTHON_THREAD_END_BLOCK;
 }
 
@@ -1230,41 +1053,12 @@ SWIG_Python_SetErrorMsg(PyObject *errtype, const char *msg) {
 
 /* Set a constant value */
 
-#if defined(SWIGPYTHON_BUILTIN)
-
-SWIGINTERN void
-SwigPyBuiltin_AddPublicSymbol(PyObject *seq, const char *key) {
-  PyObject *s = PyString_InternFromString(key);
-  PyList_Append(seq, s);
-  Py_DECREF(s);
-}
-
-SWIGINTERN void
-SWIG_Python_SetConstant(PyObject *d, PyObject *public_interface, const char *name, PyObject *obj) {   
-#if PY_VERSION_HEX < 0x02030000
-  PyDict_SetItemString(d, (char *)name, obj);
-#else
-  PyDict_SetItemString(d, name, obj);
-#endif
-  Py_DECREF(obj);
-  if (public_interface)
-    SwigPyBuiltin_AddPublicSymbol(public_interface, name);
-}
-
-#else
-
 SWIGINTERN void
 SWIG_Python_SetConstant(PyObject *d, const char *name, PyObject *obj) {   
-#if PY_VERSION_HEX < 0x02030000
-  PyDict_SetItemString(d, (char *)name, obj);
-#else
-  PyDict_SetItemString(d, name, obj);
-#endif
+  PyDict_SetItemString(d, (char*) name, obj);
   Py_DECREF(obj);                            
 }
 
-#endif
-
 /* Append a value to the result obj */
 
 SWIGINTERN PyObject*
@@ -1313,40 +1107,32 @@ SWIG_Python_AppendOutput(PyObject* result, PyObject* obj) {
 /* Unpack the argument tuple */
 
 SWIGINTERN int
-SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssize_t max, PyObject **objs)
+SWIG_Python_UnpackTuple(PyObject *args, const char *name, int min, int max, PyObject **objs)
 {
   if (!args) {
     if (!min && !max) {
       return 1;
     } else {
       PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got none", 
-		   name, (min == max ? "" : "at least "), (int)min);
+		   name, (min == max ? "" : "at least "), min);
       return 0;
     }
   }  
   if (!PyTuple_Check(args)) {
-    if (min <= 1 && max >= 1) {
-      int i;
-      objs[0] = args;
-      for (i = 1; i < max; ++i) {
-	objs[i] = 0;
-      }
-      return 2;
-    }
     PyErr_SetString(PyExc_SystemError, "UnpackTuple() argument list is not a tuple");
     return 0;
   } else {
-    Py_ssize_t l = PyTuple_GET_SIZE(args);
+    register int l = PyTuple_GET_SIZE(args);
     if (l < min) {
       PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 
-		   name, (min == max ? "" : "at least "), (int)min, (int)l);
+		   name, (min == max ? "" : "at least "), min, l);
       return 0;
     } else if (l > max) {
       PyErr_Format(PyExc_TypeError, "%s expected %s%d arguments, got %d", 
-		   name, (min == max ? "" : "at most "), (int)max, (int)l);
+		   name, (min == max ? "" : "at most "), max, l);
       return 0;
     } else {
-      int i;
+      register int i;
       for (i = 0; i < l; ++i) {
 	objs[i] = PyTuple_GET_ITEM(args, i);
       }
@@ -1385,11 +1171,11 @@ SWIG_Python_UnpackTuple(PyObject *args, const char *name, Py_ssize_t min, Py_ssi
 
 #define SWIG_POINTER_IMPLICIT_CONV  (SWIG_POINTER_DISOWN   << 1)
 
-#define SWIG_BUILTIN_TP_INIT	    (SWIG_POINTER_OWN << 2)
-#define SWIG_BUILTIN_INIT	    (SWIG_BUILTIN_TP_INIT | SWIG_POINTER_OWN)
-
 #ifdef __cplusplus
 extern "C" {
+#if 0
+} /* cc-mode */
+#endif
 #endif
 
 /*  How to access Py_None */
@@ -1431,7 +1217,7 @@ SWIG_Py_Void(void)
   return none;
 }
 
-/* SwigPyClientData */
+/* PySwigClientData */
 
 typedef struct {
   PyObject *klass;
@@ -1440,31 +1226,30 @@ typedef struct {
   PyObject *destroy;
   int delargs;
   int implicitconv;
-  PyTypeObject *pytype;
-} SwigPyClientData;
+} PySwigClientData;
 
 SWIGRUNTIMEINLINE int 
 SWIG_Python_CheckImplicit(swig_type_info *ty)
 {
-  SwigPyClientData *data = (SwigPyClientData *)ty->clientdata;
+  PySwigClientData *data = (PySwigClientData *)ty->clientdata;
   return data ? data->implicitconv : 0;
 }
 
 SWIGRUNTIMEINLINE PyObject *
 SWIG_Python_ExceptionType(swig_type_info *desc) {
-  SwigPyClientData *data = desc ? (SwigPyClientData *) desc->clientdata : 0;
+  PySwigClientData *data = desc ? (PySwigClientData *) desc->clientdata : 0;
   PyObject *klass = data ? data->klass : 0;
   return (klass ? klass : PyExc_RuntimeError);
 }
 
 
-SWIGRUNTIME SwigPyClientData * 
-SwigPyClientData_New(PyObject* obj)
+SWIGRUNTIME PySwigClientData * 
+PySwigClientData_New(PyObject* obj)
 {
   if (!obj) {
     return 0;
   } else {
-    SwigPyClientData *data = (SwigPyClientData *)malloc(sizeof(SwigPyClientData));
+    PySwigClientData *data = (PySwigClientData *)malloc(sizeof(PySwigClientData));
     /* the klass element */
     data->klass = obj;
     Py_INCREF(data->klass);
@@ -1507,19 +1292,19 @@ SwigPyClientData_New(PyObject* obj)
       data->delargs = 0;
     }
     data->implicitconv = 0;
-    data->pytype = 0;
     return data;
   }
 }
 
 SWIGRUNTIME void 
-SwigPyClientData_Del(SwigPyClientData *data) {
+PySwigClientData_Del(PySwigClientData* data)
+{
   Py_XDECREF(data->newraw);
   Py_XDECREF(data->newargs);
   Py_XDECREF(data->destroy);
 }
 
-/* =============== SwigPyObject =====================*/
+/* =============== PySwigObject =====================*/
 
 typedef struct {
   PyObject_HEAD
@@ -1527,31 +1312,24 @@ typedef struct {
   swig_type_info *ty;
   int own;
   PyObject *next;
-#ifdef SWIGPYTHON_BUILTIN
-  PyObject *dict;
-#endif
-} SwigPyObject;
+} PySwigObject;
 
 SWIGRUNTIME PyObject *
-SwigPyObject_long(SwigPyObject *v)
+PySwigObject_long(PySwigObject *v)
 {
   return PyLong_FromVoidPtr(v->ptr);
 }
 
 SWIGRUNTIME PyObject *
-SwigPyObject_format(const char* fmt, SwigPyObject *v)
+PySwigObject_format(const char* fmt, PySwigObject *v)
 {
   PyObject *res = NULL;
   PyObject *args = PyTuple_New(1);
   if (args) {
-    if (PyTuple_SetItem(args, 0, SwigPyObject_long(v)) == 0) {
-      PyObject *ofmt = SWIG_Python_str_FromChar(fmt);
+    if (PyTuple_SetItem(args, 0, PySwigObject_long(v)) == 0) {
+      PyObject *ofmt = PyString_FromString(fmt);
       if (ofmt) {
-#if PY_VERSION_HEX >= 0x03000000
-	res = PyUnicode_Format(ofmt,args);
-#else
 	res = PyString_Format(ofmt,args);
-#endif
 	Py_DECREF(ofmt);
       }
       Py_DECREF(args);
@@ -1561,118 +1339,104 @@ SwigPyObject_format(const char* fmt, SwigPyObject *v)
 }
 
 SWIGRUNTIME PyObject *
-SwigPyObject_oct(SwigPyObject *v)
+PySwigObject_oct(PySwigObject *v)
 {
-  return SwigPyObject_format("%o",v);
+  return PySwigObject_format("%o",v);
 }
 
 SWIGRUNTIME PyObject *
-SwigPyObject_hex(SwigPyObject *v)
+PySwigObject_hex(PySwigObject *v)
 {
-  return SwigPyObject_format("%x",v);
+  return PySwigObject_format("%x",v);
 }
 
 SWIGRUNTIME PyObject *
 #ifdef METH_NOARGS
-SwigPyObject_repr(SwigPyObject *v)
+PySwigObject_repr(PySwigObject *v)
 #else
-SwigPyObject_repr(SwigPyObject *v, PyObject *args)
+PySwigObject_repr(PySwigObject *v, PyObject *args)
 #endif
 {
   const char *name = SWIG_TypePrettyName(v->ty);
-  PyObject *repr = SWIG_Python_str_FromFormat("<Swig Object of type '%s' at %p>", (name ? name : "unknown"), (void *)v);
+  PyObject *hex = PySwigObject_hex(v);    
+  PyObject *repr = PyString_FromFormat("<Swig Object of type '%s' at 0x%s>", name, PyString_AsString(hex));
+  Py_DECREF(hex);
   if (v->next) {
-# ifdef METH_NOARGS
-    PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next);
-# else
-    PyObject *nrep = SwigPyObject_repr((SwigPyObject *)v->next, args);
-# endif
-# if PY_VERSION_HEX >= 0x03000000
-    PyObject *joined = PyUnicode_Concat(repr, nrep);
-    Py_DecRef(repr);
-    Py_DecRef(nrep);
-    repr = joined;
-# else
+#ifdef METH_NOARGS
+    PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next);
+#else
+    PyObject *nrep = PySwigObject_repr((PySwigObject *)v->next, args);
+#endif
     PyString_ConcatAndDel(&repr,nrep);
-# endif
   }
   return repr;  
 }
 
 SWIGRUNTIME int
-SwigPyObject_compare(SwigPyObject *v, SwigPyObject *w)
+PySwigObject_print(PySwigObject *v, FILE *fp, int SWIGUNUSEDPARM(flags))
 {
-  void *i = v->ptr;
-  void *j = w->ptr;
-  return (i < j) ? -1 : ((i > j) ? 1 : 0);
+#ifdef METH_NOARGS
+  PyObject *repr = PySwigObject_repr(v);
+#else
+  PyObject *repr = PySwigObject_repr(v, NULL);
+#endif
+  if (repr) {
+    fputs(PyString_AsString(repr), fp);
+    Py_DECREF(repr);
+    return 0; 
+  } else {
+    return 1; 
+  }
 }
 
-/* Added for Python 3.x, would it also be useful for Python 2.x? */
-SWIGRUNTIME PyObject*
-SwigPyObject_richcompare(SwigPyObject *v, SwigPyObject *w, int op)
+SWIGRUNTIME PyObject *
+PySwigObject_str(PySwigObject *v)
 {
-  PyObject* res;
-  if( op != Py_EQ && op != Py_NE ) {
-    Py_INCREF(Py_NotImplemented);
-    return Py_NotImplemented;
-  }
-  res = PyBool_FromLong( (SwigPyObject_compare(v, w)==0) == (op == Py_EQ) ? 1 : 0);
-  return res;  
+  char result[SWIG_BUFFER_SIZE];
+  return SWIG_PackVoidPtr(result, v->ptr, v->ty->name, sizeof(result)) ?
+    PyString_FromString(result) : 0;
 }
 
+SWIGRUNTIME int
+PySwigObject_compare(PySwigObject *v, PySwigObject *w)
+{
+  void *i = v->ptr;
+  void *j = w->ptr;
+  return (i < j) ? -1 : ((i > j) ? 1 : 0);
+}
 
-SWIGRUNTIME PyTypeObject* SwigPyObject_TypeOnce(void);
+SWIGRUNTIME PyTypeObject* _PySwigObject_type(void);
 
-#ifdef SWIGPYTHON_BUILTIN
-static swig_type_info *SwigPyObject_stype = 0;
-SWIGRUNTIME PyTypeObject*
-SwigPyObject_type(void) {
-    SwigPyClientData *cd;
-    assert(SwigPyObject_stype);
-    cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
-    assert(cd);
-    assert(cd->pytype);
-    return cd->pytype;
-}
-#else
 SWIGRUNTIME PyTypeObject*
-SwigPyObject_type(void) {
-  static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyObject_TypeOnce();
+PySwigObject_type(void) {
+  static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigObject_type();
   return type;
 }
-#endif
 
 SWIGRUNTIMEINLINE int
-SwigPyObject_Check(PyObject *op) {
-#ifdef SWIGPYTHON_BUILTIN
-  PyTypeObject *target_tp = SwigPyObject_type();
-  if (PyType_IsSubtype(op->ob_type, target_tp))
-    return 1;
-  return (strcmp(op->ob_type->tp_name, "SwigPyObject") == 0);
-#else
-  return (Py_TYPE(op) == SwigPyObject_type())
-    || (strcmp(Py_TYPE(op)->tp_name,"SwigPyObject") == 0);
-#endif
+PySwigObject_Check(PyObject *op) {
+  return ((op)->ob_type == PySwigObject_type())
+    || (strcmp((op)->ob_type->tp_name,"PySwigObject") == 0);
 }
 
 SWIGRUNTIME PyObject *
-SwigPyObject_New(void *ptr, swig_type_info *ty, int own);
+PySwigObject_New(void *ptr, swig_type_info *ty, int own);
 
 SWIGRUNTIME void
-SwigPyObject_dealloc(PyObject *v)
+PySwigObject_dealloc(PyObject *v)
 {
-  SwigPyObject *sobj = (SwigPyObject *) v;
+  PySwigObject *sobj = (PySwigObject *) v;
   PyObject *next = sobj->next;
-  if (sobj->own == SWIG_POINTER_OWN) {
+  if (sobj->own) {
     swig_type_info *ty = sobj->ty;
-    SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
+    PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
     PyObject *destroy = data ? data->destroy : 0;
     if (destroy) {
       /* destroy is always a VARARGS method */
       PyObject *res;
       if (data->delargs) {
-	/* we need to create a temporary object to carry the destroy operation */
-	PyObject *tmp = SwigPyObject_New(sobj->ptr, ty, 0);
+	/* we need to create a temporal object to carry the destroy operation */
+	PyObject *tmp = PySwigObject_New(sobj->ptr, ty, 0);
 	res = SWIG_Python_CallFunctor(destroy, tmp);
 	Py_DECREF(tmp);
       } else {
@@ -1681,28 +1445,27 @@ SwigPyObject_dealloc(PyObject *v)
 	res = ((*meth)(mself, v));
       }
       Py_XDECREF(res);
-    } 
-#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
-    else {
+    } else {
       const char *name = SWIG_TypePrettyName(ty);
-      printf("swig/python detected a memory leak of type '%s', no destructor found.\n", (name ? name : "unknown"));
-    }
+#if !defined(SWIG_PYTHON_SILENT_MEMLEAK)
+      printf("swig/python detected a memory leak of type '%s', no destructor found.\n", name);
 #endif
+    }
   } 
   Py_XDECREF(next);
   PyObject_DEL(v);
 }
 
 SWIGRUNTIME PyObject* 
-SwigPyObject_append(PyObject* v, PyObject* next)
+PySwigObject_append(PyObject* v, PyObject* next)
 {
-  SwigPyObject *sobj = (SwigPyObject *) v;
+  PySwigObject *sobj = (PySwigObject *) v;
 #ifndef METH_O
   PyObject *tmp = 0;
   if (!PyArg_ParseTuple(next,(char *)"O:append", &tmp)) return NULL;
   next = tmp;
 #endif
-  if (!SwigPyObject_Check(next)) {
+  if (!PySwigObject_Check(next)) {
     return NULL;
   }
   sobj->next = next;
@@ -1712,12 +1475,12 @@ SwigPyObject_append(PyObject* v, PyObject* next)
 
 SWIGRUNTIME PyObject* 
 #ifdef METH_NOARGS
-SwigPyObject_next(PyObject* v)
+PySwigObject_next(PyObject* v)
 #else
-SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+PySwigObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
 #endif
 {
-  SwigPyObject *sobj = (SwigPyObject *) v;
+  PySwigObject *sobj = (PySwigObject *) v;
   if (sobj->next) {    
     Py_INCREF(sobj->next);
     return sobj->next;
@@ -1728,58 +1491,56 @@ SwigPyObject_next(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
 
 SWIGINTERN PyObject*
 #ifdef METH_NOARGS
-SwigPyObject_disown(PyObject *v)
+PySwigObject_disown(PyObject *v)
 #else
-SwigPyObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+PySwigObject_disown(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
 #endif
 {
-  SwigPyObject *sobj = (SwigPyObject *)v;
+  PySwigObject *sobj = (PySwigObject *)v;
   sobj->own = 0;
   return SWIG_Py_Void();
 }
 
 SWIGINTERN PyObject*
 #ifdef METH_NOARGS
-SwigPyObject_acquire(PyObject *v)
+PySwigObject_acquire(PyObject *v)
 #else
-SwigPyObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
+PySwigObject_acquire(PyObject* v, PyObject *SWIGUNUSEDPARM(args))
 #endif
 {
-  SwigPyObject *sobj = (SwigPyObject *)v;
+  PySwigObject *sobj = (PySwigObject *)v;
   sobj->own = SWIG_POINTER_OWN;
   return SWIG_Py_Void();
 }
 
 SWIGINTERN PyObject*
-SwigPyObject_own(PyObject *v, PyObject *args)
+PySwigObject_own(PyObject *v, PyObject *args)
 {
   PyObject *val = 0;
 #if (PY_VERSION_HEX < 0x02020000)
   if (!PyArg_ParseTuple(args,(char *)"|O:own",&val))
-#elif (PY_VERSION_HEX < 0x02050000)
-  if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) 
 #else
-  if (!PyArg_UnpackTuple(args, "own", 0, 1, &val)) 
+  if (!PyArg_UnpackTuple(args, (char *)"own", 0, 1, &val)) 
 #endif
     {
       return NULL;
     } 
   else
     {
-      SwigPyObject *sobj = (SwigPyObject *)v;
+      PySwigObject *sobj = (PySwigObject *)v;
       PyObject *obj = PyBool_FromLong(sobj->own);
       if (val) {
 #ifdef METH_NOARGS
 	if (PyObject_IsTrue(val)) {
-	  SwigPyObject_acquire(v);
+	  PySwigObject_acquire(v);
 	} else {
-	  SwigPyObject_disown(v);
+	  PySwigObject_disown(v);
 	}
 #else
 	if (PyObject_IsTrue(val)) {
-	  SwigPyObject_acquire(v,args);
+	  PySwigObject_acquire(v,args);
 	} else {
-	  SwigPyObject_disown(v,args);
+	  PySwigObject_disown(v,args);
 	}
 #endif
       } 
@@ -1790,47 +1551,44 @@ SwigPyObject_own(PyObject *v, PyObject *args)
 #ifdef METH_O
 static PyMethodDef
 swigobject_methods[] = {
-  {(char *)"disown",  (PyCFunction)SwigPyObject_disown,  METH_NOARGS,  (char *)"releases ownership of the pointer"},
-  {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_NOARGS,  (char *)"acquires ownership of the pointer"},
-  {(char *)"own",     (PyCFunction)SwigPyObject_own,     METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
-  {(char *)"append",  (PyCFunction)SwigPyObject_append,  METH_O,       (char *)"appends another 'this' object"},
-  {(char *)"next",    (PyCFunction)SwigPyObject_next,    METH_NOARGS,  (char *)"returns the next 'this' object"},
-  {(char *)"__repr__",(PyCFunction)SwigPyObject_repr,    METH_NOARGS,  (char *)"returns object representation"},
+  {(char *)"disown",  (PyCFunction)PySwigObject_disown,  METH_NOARGS,  (char *)"releases ownership of the pointer"},
+  {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_NOARGS,  (char *)"aquires ownership of the pointer"},
+  {(char *)"own",     (PyCFunction)PySwigObject_own,     METH_VARARGS, (char *)"returns/sets ownership of the pointer"},
+  {(char *)"append",  (PyCFunction)PySwigObject_append,  METH_O,       (char *)"appends another 'this' object"},
+  {(char *)"next",    (PyCFunction)PySwigObject_next,    METH_NOARGS,  (char *)"returns the next 'this' object"},
+  {(char *)"__repr__",(PyCFunction)PySwigObject_repr,    METH_NOARGS,  (char *)"returns object representation"},
   {0, 0, 0, 0}  
 };
 #else
 static PyMethodDef
 swigobject_methods[] = {
-  {(char *)"disown",  (PyCFunction)SwigPyObject_disown,  METH_VARARGS,  (char *)"releases ownership of the pointer"},
-  {(char *)"acquire", (PyCFunction)SwigPyObject_acquire, METH_VARARGS,  (char *)"aquires ownership of the pointer"},
-  {(char *)"own",     (PyCFunction)SwigPyObject_own,     METH_VARARGS,  (char *)"returns/sets ownership of the pointer"},
-  {(char *)"append",  (PyCFunction)SwigPyObject_append,  METH_VARARGS,  (char *)"appends another 'this' object"},
-  {(char *)"next",    (PyCFunction)SwigPyObject_next,    METH_VARARGS,  (char *)"returns the next 'this' object"},
-  {(char *)"__repr__",(PyCFunction)SwigPyObject_repr,   METH_VARARGS,  (char *)"returns object representation"},
+  {(char *)"disown",  (PyCFunction)PySwigObject_disown,  METH_VARARGS,  (char *)"releases ownership of the pointer"},
+  {(char *)"acquire", (PyCFunction)PySwigObject_acquire, METH_VARARGS,  (char *)"aquires ownership of the pointer"},
+  {(char *)"own",     (PyCFunction)PySwigObject_own,     METH_VARARGS,  (char *)"returns/sets ownership of the pointer"},
+  {(char *)"append",  (PyCFunction)PySwigObject_append,  METH_VARARGS,  (char *)"appends another 'this' object"},
+  {(char *)"next",    (PyCFunction)PySwigObject_next,    METH_VARARGS,  (char *)"returns the next 'this' object"},
+  {(char *)"__repr__",(PyCFunction)PySwigObject_repr,   METH_VARARGS,  (char *)"returns object representation"},
   {0, 0, 0, 0}  
 };
 #endif
 
 #if PY_VERSION_HEX < 0x02020000
 SWIGINTERN PyObject *
-SwigPyObject_getattr(SwigPyObject *sobj,char *name)
+PySwigObject_getattr(PySwigObject *sobj,char *name)
 {
   return Py_FindMethod(swigobject_methods, (PyObject *)sobj, name);
 }
 #endif
 
 SWIGRUNTIME PyTypeObject*
-SwigPyObject_TypeOnce(void) {
+_PySwigObject_type(void) {
   static char swigobject_doc[] = "Swig object carries a C/C++ instance pointer";
-
-  static PyNumberMethods SwigPyObject_as_number = {
+  
+  static PyNumberMethods PySwigObject_as_number = {
     (binaryfunc)0, /*nb_add*/
     (binaryfunc)0, /*nb_subtract*/
     (binaryfunc)0, /*nb_multiply*/
-    /* nb_divide removed in Python 3 */
-#if PY_VERSION_HEX < 0x03000000
     (binaryfunc)0, /*nb_divide*/
-#endif
     (binaryfunc)0, /*nb_remainder*/
     (binaryfunc)0, /*nb_divmod*/
     (ternaryfunc)0,/*nb_power*/
@@ -1844,122 +1602,94 @@ SwigPyObject_TypeOnce(void) {
     0,		   /*nb_and*/
     0,		   /*nb_xor*/
     0,		   /*nb_or*/
-#if PY_VERSION_HEX < 0x03000000
-    0,   /*nb_coerce*/
-#endif
-    (unaryfunc)SwigPyObject_long, /*nb_int*/
-#if PY_VERSION_HEX < 0x03000000
-    (unaryfunc)SwigPyObject_long, /*nb_long*/
-#else
-    0, /*nb_reserved*/
-#endif
+    (coercion)0,   /*nb_coerce*/
+    (unaryfunc)PySwigObject_long, /*nb_int*/
+    (unaryfunc)PySwigObject_long, /*nb_long*/
     (unaryfunc)0,                 /*nb_float*/
-#if PY_VERSION_HEX < 0x03000000
-    (unaryfunc)SwigPyObject_oct,  /*nb_oct*/
-    (unaryfunc)SwigPyObject_hex,  /*nb_hex*/
-#endif
-#if PY_VERSION_HEX >= 0x03000000 /* 3.0 */
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index, nb_inplace_divide removed */
-#elif PY_VERSION_HEX >= 0x02050000 /* 2.5.0 */
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_index */
-#elif PY_VERSION_HEX >= 0x02020000 /* 2.2.0 */
-    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */
-#elif PY_VERSION_HEX >= 0x02000000 /* 2.0.0 */
+    (unaryfunc)PySwigObject_oct,  /*nb_oct*/
+    (unaryfunc)PySwigObject_hex,  /*nb_hex*/
+#if PY_VERSION_HEX >= 0x02020000
+    0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_true_divide */ 
+#elif PY_VERSION_HEX >= 0x02000000
     0,0,0,0,0,0,0,0,0,0,0 /* nb_inplace_add -> nb_inplace_or */
 #endif
   };
 
-  static PyTypeObject swigpyobject_type;
+  static PyTypeObject pyswigobject_type;  
   static int type_init = 0;
   if (!type_init) {
-    const PyTypeObject tmp = {
-      /* PyObject header changed in Python 3 */
-#if PY_VERSION_HEX >= 0x03000000
-      PyVarObject_HEAD_INIT(NULL, 0)
-#else
-      PyObject_HEAD_INIT(NULL)
-      0,                                    /* ob_size */
-#endif
-      (char *)"SwigPyObject",               /* tp_name */
-      sizeof(SwigPyObject),                 /* tp_basicsize */
-      0,                                    /* tp_itemsize */
-      (destructor)SwigPyObject_dealloc,     /* tp_dealloc */
-      0,				    /* tp_print */
+    const PyTypeObject tmp
+      = {
+	PyObject_HEAD_INIT(NULL)
+	0,				    /* ob_size */
+	(char *)"PySwigObject",		    /* tp_name */
+	sizeof(PySwigObject),		    /* tp_basicsize */
+	0,			            /* tp_itemsize */
+	(destructor)PySwigObject_dealloc,   /* tp_dealloc */
+	(printfunc)PySwigObject_print,	    /* tp_print */
 #if PY_VERSION_HEX < 0x02020000
-      (getattrfunc)SwigPyObject_getattr,    /* tp_getattr */
-#else
-      (getattrfunc)0,                       /* tp_getattr */
-#endif
-      (setattrfunc)0,                       /* tp_setattr */
-#if PY_VERSION_HEX >= 0x03000000
-    0, /* tp_reserved in 3.0.1, tp_compare in 3.0.0 but not used */
+	(getattrfunc)PySwigObject_getattr,  /* tp_getattr */ 
 #else
-      (cmpfunc)SwigPyObject_compare,        /* tp_compare */
+	(getattrfunc)0,			    /* tp_getattr */ 
 #endif
-      (reprfunc)SwigPyObject_repr,          /* tp_repr */
-      &SwigPyObject_as_number,              /* tp_as_number */
-      0,                                    /* tp_as_sequence */
-      0,                                    /* tp_as_mapping */
-      (hashfunc)0,                          /* tp_hash */
-      (ternaryfunc)0,                       /* tp_call */
-      0,				    /* tp_str */
-      PyObject_GenericGetAttr,              /* tp_getattro */
-      0,                                    /* tp_setattro */
-      0,                                    /* tp_as_buffer */
-      Py_TPFLAGS_DEFAULT,                   /* tp_flags */
-      swigobject_doc,                       /* tp_doc */
-      0,                                    /* tp_traverse */
-      0,                                    /* tp_clear */
-      (richcmpfunc)SwigPyObject_richcompare,/* tp_richcompare */
-      0,                                    /* tp_weaklistoffset */
+	(setattrfunc)0,			    /* tp_setattr */ 
+	(cmpfunc)PySwigObject_compare,	    /* tp_compare */ 
+	(reprfunc)PySwigObject_repr,	    /* tp_repr */    
+	&PySwigObject_as_number,	    /* tp_as_number */
+	0,				    /* tp_as_sequence */
+	0,				    /* tp_as_mapping */
+	(hashfunc)0,			    /* tp_hash */
+	(ternaryfunc)0,			    /* tp_call */
+	(reprfunc)PySwigObject_str,	    /* tp_str */
+	PyObject_GenericGetAttr,            /* tp_getattro */
+	0,				    /* tp_setattro */
+	0,		                    /* tp_as_buffer */
+	Py_TPFLAGS_DEFAULT,	            /* tp_flags */
+	swigobject_doc, 	            /* tp_doc */        
+	0,                                  /* tp_traverse */
+	0,                                  /* tp_clear */
+	0,                                  /* tp_richcompare */
+	0,                                  /* tp_weaklistoffset */
 #if PY_VERSION_HEX >= 0x02020000
-      0,                                    /* tp_iter */
-      0,                                    /* tp_iternext */
-      swigobject_methods,                   /* tp_methods */
-      0,                                    /* tp_members */
-      0,                                    /* tp_getset */
-      0,                                    /* tp_base */
-      0,                                    /* tp_dict */
-      0,                                    /* tp_descr_get */
-      0,                                    /* tp_descr_set */
-      0,                                    /* tp_dictoffset */
-      0,                                    /* tp_init */
-      0,                                    /* tp_alloc */
-      0,                                    /* tp_new */
-      0,                                    /* tp_free */
-      0,                                    /* tp_is_gc */
-      0,                                    /* tp_bases */
-      0,                                    /* tp_mro */
-      0,                                    /* tp_cache */
-      0,                                    /* tp_subclasses */
-      0,                                    /* tp_weaklist */
+	0,                                  /* tp_iter */
+	0,                                  /* tp_iternext */
+	swigobject_methods,		    /* tp_methods */ 
+	0,			            /* tp_members */
+	0,				    /* tp_getset */	    	
+	0,			            /* tp_base */	        
+	0,				    /* tp_dict */	    	
+	0,				    /* tp_descr_get */  	
+	0,				    /* tp_descr_set */  	
+	0,				    /* tp_dictoffset */ 	
+	0,				    /* tp_init */	    	
+	0,				    /* tp_alloc */	    	
+	0,			            /* tp_new */	    	
+	0,	                            /* tp_free */	   
+        0,                                  /* tp_is_gc */  
+	0,				    /* tp_bases */   
+	0,				    /* tp_mro */
+	0,				    /* tp_cache */   
+ 	0,				    /* tp_subclasses */
+	0,				    /* tp_weaklist */
 #endif
 #if PY_VERSION_HEX >= 0x02030000
-      0,                                    /* tp_del */
-#endif
-#if PY_VERSION_HEX >= 0x02060000
-      0,                                    /* tp_version */
+	0,                                  /* tp_del */
 #endif
 #ifdef COUNT_ALLOCS
-      0,0,0,0                               /* tp_alloc -> tp_next */
+	0,0,0,0                             /* tp_alloc -> tp_next */
 #endif
-    };
-    swigpyobject_type = tmp;
+      };
+    pyswigobject_type = tmp;
+    pyswigobject_type.ob_type = &PyType_Type;
     type_init = 1;
-#if PY_VERSION_HEX < 0x02020000
-    swigpyobject_type.ob_type = &PyType_Type;
-#else
-    if (PyType_Ready(&swigpyobject_type) < 0)
-      return NULL;
-#endif
   }
-  return &swigpyobject_type;
+  return &pyswigobject_type;
 }
 
 SWIGRUNTIME PyObject *
-SwigPyObject_New(void *ptr, swig_type_info *ty, int own)
+PySwigObject_New(void *ptr, swig_type_info *ty, int own)
 {
-  SwigPyObject *sobj = PyObject_NEW(SwigPyObject, SwigPyObject_type());
+  PySwigObject *sobj = PyObject_NEW(PySwigObject, PySwigObject_type());
   if (sobj) {
     sobj->ptr  = ptr;
     sobj->ty   = ty;
@@ -1978,10 +1708,10 @@ typedef struct {
   void *pack;
   swig_type_info *ty;
   size_t size;
-} SwigPyPacked;
+} PySwigPacked;
 
 SWIGRUNTIME int
-SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
+PySwigPacked_print(PySwigPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
 {
   char result[SWIG_BUFFER_SIZE];
   fputs("<Swig Packed ", fp); 
@@ -1995,29 +1725,29 @@ SwigPyPacked_print(SwigPyPacked *v, FILE *fp, int SWIGUNUSEDPARM(flags))
 }
   
 SWIGRUNTIME PyObject *
-SwigPyPacked_repr(SwigPyPacked *v)
+PySwigPacked_repr(PySwigPacked *v)
 {
   char result[SWIG_BUFFER_SIZE];
   if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))) {
-    return SWIG_Python_str_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
+    return PyString_FromFormat("<Swig Packed at %s%s>", result, v->ty->name);
   } else {
-    return SWIG_Python_str_FromFormat("<Swig Packed %s>", v->ty->name);
+    return PyString_FromFormat("<Swig Packed %s>", v->ty->name);
   }  
 }
 
 SWIGRUNTIME PyObject *
-SwigPyPacked_str(SwigPyPacked *v)
+PySwigPacked_str(PySwigPacked *v)
 {
   char result[SWIG_BUFFER_SIZE];
   if (SWIG_PackDataName(result, v->pack, v->size, 0, sizeof(result))){
-    return SWIG_Python_str_FromFormat("%s%s", result, v->ty->name);
+    return PyString_FromFormat("%s%s", result, v->ty->name);
   } else {
-    return SWIG_Python_str_FromChar(v->ty->name);
+    return PyString_FromString(v->ty->name);
   }  
 }
 
 SWIGRUNTIME int
-SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)
+PySwigPacked_compare(PySwigPacked *v, PySwigPacked *w)
 {
   size_t i = v->size;
   size_t j = w->size;
@@ -2025,120 +1755,104 @@ SwigPyPacked_compare(SwigPyPacked *v, SwigPyPacked *w)
   return s ? s : strncmp((char *)v->pack, (char *)w->pack, 2*v->size);
 }
 
-SWIGRUNTIME PyTypeObject* SwigPyPacked_TypeOnce(void);
+SWIGRUNTIME PyTypeObject* _PySwigPacked_type(void);
 
 SWIGRUNTIME PyTypeObject*
-SwigPyPacked_type(void) {
-  static PyTypeObject *SWIG_STATIC_POINTER(type) = SwigPyPacked_TypeOnce();
+PySwigPacked_type(void) {
+  static PyTypeObject *SWIG_STATIC_POINTER(type) = _PySwigPacked_type();
   return type;
 }
 
 SWIGRUNTIMEINLINE int
-SwigPyPacked_Check(PyObject *op) {
-  return ((op)->ob_type == SwigPyPacked_TypeOnce()) 
-    || (strcmp((op)->ob_type->tp_name,"SwigPyPacked") == 0);
+PySwigPacked_Check(PyObject *op) {
+  return ((op)->ob_type == _PySwigPacked_type()) 
+    || (strcmp((op)->ob_type->tp_name,"PySwigPacked") == 0);
 }
 
 SWIGRUNTIME void
-SwigPyPacked_dealloc(PyObject *v)
+PySwigPacked_dealloc(PyObject *v)
 {
-  if (SwigPyPacked_Check(v)) {
-    SwigPyPacked *sobj = (SwigPyPacked *) v;
+  if (PySwigPacked_Check(v)) {
+    PySwigPacked *sobj = (PySwigPacked *) v;
     free(sobj->pack);
   }
   PyObject_DEL(v);
 }
 
 SWIGRUNTIME PyTypeObject*
-SwigPyPacked_TypeOnce(void) {
+_PySwigPacked_type(void) {
   static char swigpacked_doc[] = "Swig object carries a C/C++ instance pointer";
-  static PyTypeObject swigpypacked_type;
-  static int type_init = 0;
+  static PyTypeObject pyswigpacked_type;
+  static int type_init = 0;  
   if (!type_init) {
-    const PyTypeObject tmp = {
-      /* PyObject header changed in Python 3 */
-#if PY_VERSION_HEX>=0x03000000
-      PyVarObject_HEAD_INIT(NULL, 0)
-#else
-      PyObject_HEAD_INIT(NULL)
-      0,                                    /* ob_size */
-#endif
-      (char *)"SwigPyPacked",               /* tp_name */
-      sizeof(SwigPyPacked),                 /* tp_basicsize */
-      0,                                    /* tp_itemsize */
-      (destructor)SwigPyPacked_dealloc,     /* tp_dealloc */
-      (printfunc)SwigPyPacked_print,        /* tp_print */
-      (getattrfunc)0,                       /* tp_getattr */
-      (setattrfunc)0,                       /* tp_setattr */
-#if PY_VERSION_HEX>=0x03000000
-      0, /* tp_reserved in 3.0.1 */
-#else
-      (cmpfunc)SwigPyPacked_compare,        /* tp_compare */
-#endif
-      (reprfunc)SwigPyPacked_repr,          /* tp_repr */
-      0,                                    /* tp_as_number */
-      0,                                    /* tp_as_sequence */
-      0,                                    /* tp_as_mapping */
-      (hashfunc)0,                          /* tp_hash */
-      (ternaryfunc)0,                       /* tp_call */
-      (reprfunc)SwigPyPacked_str,           /* tp_str */
-      PyObject_GenericGetAttr,              /* tp_getattro */
-      0,                                    /* tp_setattro */
-      0,                                    /* tp_as_buffer */
-      Py_TPFLAGS_DEFAULT,                   /* tp_flags */
-      swigpacked_doc,                       /* tp_doc */
-      0,                                    /* tp_traverse */
-      0,                                    /* tp_clear */
-      0,                                    /* tp_richcompare */
-      0,                                    /* tp_weaklistoffset */
+    const PyTypeObject tmp
+      = {
+	PyObject_HEAD_INIT(NULL)
+	0,				    /* ob_size */	
+	(char *)"PySwigPacked",		    /* tp_name */	
+	sizeof(PySwigPacked),		    /* tp_basicsize */	
+	0,				    /* tp_itemsize */	
+	(destructor)PySwigPacked_dealloc,   /* tp_dealloc */	
+	(printfunc)PySwigPacked_print,	    /* tp_print */   	
+	(getattrfunc)0,			    /* tp_getattr */ 	
+	(setattrfunc)0,			    /* tp_setattr */ 	
+	(cmpfunc)PySwigPacked_compare,	    /* tp_compare */ 	
+	(reprfunc)PySwigPacked_repr,	    /* tp_repr */    	
+	0,	                            /* tp_as_number */	
+	0,				    /* tp_as_sequence */
+	0,				    /* tp_as_mapping */	
+	(hashfunc)0,			    /* tp_hash */	
+	(ternaryfunc)0,			    /* tp_call */	
+	(reprfunc)PySwigPacked_str,	    /* tp_str */	
+	PyObject_GenericGetAttr,            /* tp_getattro */
+	0,				    /* tp_setattro */
+	0,		                    /* tp_as_buffer */
+	Py_TPFLAGS_DEFAULT,	            /* tp_flags */
+	swigpacked_doc, 	            /* tp_doc */
+	0,                                  /* tp_traverse */
+	0,                                  /* tp_clear */
+	0,                                  /* tp_richcompare */
+	0,                                  /* tp_weaklistoffset */
 #if PY_VERSION_HEX >= 0x02020000
-      0,                                    /* tp_iter */
-      0,                                    /* tp_iternext */
-      0,                                    /* tp_methods */
-      0,                                    /* tp_members */
-      0,                                    /* tp_getset */
-      0,                                    /* tp_base */
-      0,                                    /* tp_dict */
-      0,                                    /* tp_descr_get */
-      0,                                    /* tp_descr_set */
-      0,                                    /* tp_dictoffset */
-      0,                                    /* tp_init */
-      0,                                    /* tp_alloc */
-      0,                                    /* tp_new */
-      0,                                    /* tp_free */
-      0,                                    /* tp_is_gc */
-      0,                                    /* tp_bases */
-      0,                                    /* tp_mro */
-      0,                                    /* tp_cache */
-      0,                                    /* tp_subclasses */
-      0,                                    /* tp_weaklist */
+	0,                                  /* tp_iter */
+	0,                                  /* tp_iternext */
+	0,		                    /* tp_methods */ 
+	0,			            /* tp_members */
+	0,				    /* tp_getset */	    	
+	0,			            /* tp_base */	        
+	0,				    /* tp_dict */	    	
+	0,				    /* tp_descr_get */  	
+	0,				    /* tp_descr_set */  	
+	0,				    /* tp_dictoffset */ 	
+	0,				    /* tp_init */	    	
+	0,				    /* tp_alloc */	    	
+	0,			            /* tp_new */	    	
+	0, 	                            /* tp_free */	   
+        0,                                  /* tp_is_gc */  
+	0,				    /* tp_bases */   
+	0,				    /* tp_mro */
+	0,				    /* tp_cache */   
+ 	0,				    /* tp_subclasses */
+	0,				    /* tp_weaklist */
 #endif
 #if PY_VERSION_HEX >= 0x02030000
-      0,                                    /* tp_del */
-#endif
-#if PY_VERSION_HEX >= 0x02060000
-      0,                                    /* tp_version */
+	0,                                  /* tp_del */
 #endif
 #ifdef COUNT_ALLOCS
-      0,0,0,0                               /* tp_alloc -> tp_next */
+	0,0,0,0                             /* tp_alloc -> tp_next */
 #endif
-    };
-    swigpypacked_type = tmp;
+      };
+    pyswigpacked_type = tmp;
+    pyswigpacked_type.ob_type = &PyType_Type;
     type_init = 1;
-#if PY_VERSION_HEX < 0x02020000
-    swigpypacked_type.ob_type = &PyType_Type;
-#else
-    if (PyType_Ready(&swigpypacked_type) < 0)
-      return NULL;
-#endif
   }
-  return &swigpypacked_type;
+  return &pyswigpacked_type;
 }
 
 SWIGRUNTIME PyObject *
-SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty)
+PySwigPacked_New(void *ptr, size_t size, swig_type_info *ty)
 {
-  SwigPyPacked *sobj = PyObject_NEW(SwigPyPacked, SwigPyPacked_type());
+  PySwigPacked *sobj = PyObject_NEW(PySwigPacked, PySwigPacked_type());
   if (sobj) {
     void *pack = malloc(size);
     if (pack) {
@@ -2155,10 +1869,10 @@ SwigPyPacked_New(void *ptr, size_t size, swig_type_info *ty)
 }
 
 SWIGRUNTIME swig_type_info *
-SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
+PySwigPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
 {
-  if (SwigPyPacked_Check(obj)) {
-    SwigPyPacked *sobj = (SwigPyPacked *)obj;
+  if (PySwigPacked_Check(obj)) {
+    PySwigPacked *sobj = (PySwigPacked *)obj;
     if (sobj->size != size) return 0;
     memcpy(ptr, sobj->pack, size);
     return sobj->ty;
@@ -2174,96 +1888,73 @@ SwigPyPacked_UnpackData(PyObject *obj, void *ptr, size_t size)
 SWIGRUNTIMEINLINE PyObject *
 _SWIG_This(void)
 {
-    return SWIG_Python_str_FromChar("this");
+  return PyString_FromString("this");
 }
 
-static PyObject *swig_this = NULL;
-
 SWIGRUNTIME PyObject *
 SWIG_This(void)
 {
-  if (swig_this == NULL)
-    swig_this = _SWIG_This();
+  static PyObject *SWIG_STATIC_POINTER(swig_this) = _SWIG_This();
   return swig_this;
 }
 
 /* #define SWIG_PYTHON_SLOW_GETSET_THIS */
 
-/* TODO: I don't know how to implement the fast getset in Python 3 right now */
-#if PY_VERSION_HEX>=0x03000000
-#define SWIG_PYTHON_SLOW_GETSET_THIS 
-#endif
-
-SWIGRUNTIME SwigPyObject *
+SWIGRUNTIME PySwigObject *
 SWIG_Python_GetSwigThis(PyObject *pyobj) 
 {
-  PyObject *obj;
-
-  if (SwigPyObject_Check(pyobj))
-    return (SwigPyObject *) pyobj;
-
-#ifdef SWIGPYTHON_BUILTIN
-  (void)obj;
-# ifdef PyWeakref_CheckProxy
-  if (PyWeakref_CheckProxy(pyobj)) {
-    pyobj = PyWeakref_GET_OBJECT(pyobj);
-    if (pyobj && SwigPyObject_Check(pyobj))
-      return (SwigPyObject*) pyobj;
-  }
-# endif
-  return NULL;
-#else
-
-  obj = 0;
-
-#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
-  if (PyInstance_Check(pyobj)) {
-    obj = _PyInstance_Lookup(pyobj, SWIG_This());      
+  if (PySwigObject_Check(pyobj)) {
+    return (PySwigObject *) pyobj;
   } else {
-    PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
-    if (dictptr != NULL) {
-      PyObject *dict = *dictptr;
-      obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
+    PyObject *obj = 0;
+#if (!defined(SWIG_PYTHON_SLOW_GETSET_THIS) && (PY_VERSION_HEX >= 0x02030000))
+    if (PyInstance_Check(pyobj)) {
+      obj = _PyInstance_Lookup(pyobj, SWIG_This());      
     } else {
+      PyObject **dictptr = _PyObject_GetDictPtr(pyobj);
+      if (dictptr != NULL) {
+	PyObject *dict = *dictptr;
+	obj = dict ? PyDict_GetItem(dict, SWIG_This()) : 0;
+      } else {
 #ifdef PyWeakref_CheckProxy
-      if (PyWeakref_CheckProxy(pyobj)) {
-	PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
-	return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
-      }
+	if (PyWeakref_CheckProxy(pyobj)) {
+	  PyObject *wobj = PyWeakref_GET_OBJECT(pyobj);
+	  return wobj ? SWIG_Python_GetSwigThis(wobj) : 0;
+	}
 #endif
-      obj = PyObject_GetAttr(pyobj,SWIG_This());
-      if (obj) {
-	Py_DECREF(obj);
-      } else {
-	if (PyErr_Occurred()) PyErr_Clear();
-	return 0;
+	obj = PyObject_GetAttr(pyobj,SWIG_This());
+	if (obj) {
+	  Py_DECREF(obj);
+	} else {
+	  if (PyErr_Occurred()) PyErr_Clear();
+	  return 0;
+	}
       }
     }
-  }
 #else
-  obj = PyObject_GetAttr(pyobj,SWIG_This());
-  if (obj) {
-    Py_DECREF(obj);
-  } else {
-    if (PyErr_Occurred()) PyErr_Clear();
-    return 0;
-  }
+    obj = PyObject_GetAttr(pyobj,SWIG_This());
+    if (obj) {
+      Py_DECREF(obj);
+    } else {
+      if (PyErr_Occurred()) PyErr_Clear();
+      return 0;
+    }
 #endif
-  if (obj && !SwigPyObject_Check(obj)) {
-    /* a PyObject is called 'this', try to get the 'real this'
-       SwigPyObject from it */ 
-    return SWIG_Python_GetSwigThis(obj);
+    if (obj && !PySwigObject_Check(obj)) {
+      /* a PyObject is called 'this', try to get the 'real this'
+	 PySwigObject from it */ 
+      return SWIG_Python_GetSwigThis(obj);
+    }
+    return (PySwigObject *)obj;
   }
-  return (SwigPyObject *)obj;
-#endif
 }
 
 /* Acquire a pointer value */
 
 SWIGRUNTIME int
 SWIG_Python_AcquirePtr(PyObject *obj, int own) {
-  if (own == SWIG_POINTER_OWN) {
-    SwigPyObject *sobj = SWIG_Python_GetSwigThis(obj);
+  if (own) {
+    PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
     if (sobj) {
       int oldown = sobj->own;
       sobj->own = own;
@@ -2277,105 +1968,80 @@ SWIG_Python_AcquirePtr(PyObject *obj, int own) {
 
 SWIGRUNTIME int
 SWIG_Python_ConvertPtrAndOwn(PyObject *obj, void **ptr, swig_type_info *ty, int flags, int *own) {
-  int res;
-  SwigPyObject *sobj;
-  int implicit_conv = (flags & SWIG_POINTER_IMPLICIT_CONV) != 0;
-
-  if (!obj)
-    return SWIG_ERROR;
-  if (obj == Py_None && !implicit_conv) {
-    if (ptr)
-      *ptr = 0;
+  if (!obj) return SWIG_ERROR;
+  if (obj == Py_None) {
+    if (ptr) *ptr = 0;
     return SWIG_OK;
-  }
-
-  res = SWIG_ERROR;
-
-  sobj = SWIG_Python_GetSwigThis(obj);
-  if (own)
-    *own = 0;
-  while (sobj) {
-    void *vptr = sobj->ptr;
-    if (ty) {
-      swig_type_info *to = sobj->ty;
-      if (to == ty) {
-        /* no type cast needed */
-        if (ptr) *ptr = vptr;
-        break;
+  } else {
+    PySwigObject *sobj = SWIG_Python_GetSwigThis(obj);
+    while (sobj) {
+      void *vptr = sobj->ptr;
+      if (ty) {
+	swig_type_info *to = sobj->ty;
+	if (to == ty) {
+	  /* no type cast needed */
+	  if (ptr) *ptr = vptr;
+	  break;
+	} else {
+	  swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
+	  if (!tc) {
+	    sobj = (PySwigObject *)sobj->next;
+	  } else {
+	    if (ptr) *ptr = SWIG_TypeCast(tc,vptr);
+	    break;
+	  }
+	}
       } else {
-        swig_cast_info *tc = SWIG_TypeCheck(to->name,ty);
-        if (!tc) {
-          sobj = (SwigPyObject *)sobj->next;
-        } else {
-          if (ptr) {
-            int newmemory = 0;
-            *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
-            if (newmemory == SWIG_CAST_NEW_MEMORY) {
-              assert(own); /* badly formed typemap which will lead to a memory leak - it must set and use own to delete *ptr */
-              if (own)
-                *own = *own | SWIG_CAST_NEW_MEMORY;
-            }
-          }
-          break;
-        }
+	if (ptr) *ptr = vptr;
+	break;
       }
-    } else {
-      if (ptr) *ptr = vptr;
-      break;
-    }
-  }
-  if (sobj) {
-    if (own)
-      *own = *own | sobj->own;
-    if (flags & SWIG_POINTER_DISOWN) {
-      sobj->own = 0;
     }
-    res = SWIG_OK;
-  } else {
-    if (implicit_conv) {
-      SwigPyClientData *data = ty ? (SwigPyClientData *) ty->clientdata : 0;
-      if (data && !data->implicitconv) {
-        PyObject *klass = data->klass;
-        if (klass) {
-          PyObject *impconv;
-          data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
-          impconv = SWIG_Python_CallFunctor(klass, obj);
-          data->implicitconv = 0;
-          if (PyErr_Occurred()) {
-            PyErr_Clear();
-            impconv = 0;
-          }
-          if (impconv) {
-            SwigPyObject *iobj = SWIG_Python_GetSwigThis(impconv);
-            if (iobj) {
-              void *vptr;
-              res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
-              if (SWIG_IsOK(res)) {
-                if (ptr) {
-                  *ptr = vptr;
-                  /* transfer the ownership to 'ptr' */
-                  iobj->own = 0;
-                  res = SWIG_AddCast(res);
-                  res = SWIG_AddNewMask(res);
-                } else {
-                  res = SWIG_AddCast(res);		    
-                }
-              }
-            }
-            Py_DECREF(impconv);
-          }
-        }
+    if (sobj) {
+      if (own) *own = sobj->own;
+      if (flags & SWIG_POINTER_DISOWN) {
+	sobj->own = 0;
       }
-    }
-    if (!SWIG_IsOK(res) && obj == Py_None) {
-      if (ptr)
-        *ptr = 0;
-      if (PyErr_Occurred())
-        PyErr_Clear();
-      res = SWIG_OK;
+      return SWIG_OK;
+    } else {
+      int res = SWIG_ERROR;
+      if (flags & SWIG_POINTER_IMPLICIT_CONV) {
+	PySwigClientData *data = ty ? (PySwigClientData *) ty->clientdata : 0;
+	if (data && !data->implicitconv) {
+	  PyObject *klass = data->klass;
+	  if (klass) {
+	    PyObject *impconv;
+	    data->implicitconv = 1; /* avoid recursion and call 'explicit' constructors*/
+	    impconv = SWIG_Python_CallFunctor(klass, obj);
+	    data->implicitconv = 0;
+	    if (PyErr_Occurred()) {
+	      PyErr_Clear();
+	      impconv = 0;
+	    }
+	    if (impconv) {
+	      PySwigObject *iobj = SWIG_Python_GetSwigThis(impconv);
+	      if (iobj) {
+		void *vptr;
+		res = SWIG_Python_ConvertPtrAndOwn((PyObject*)iobj, &vptr, ty, 0, 0);
+		if (SWIG_IsOK(res)) {
+		  if (ptr) {
+		    *ptr = vptr;
+		    /* transfer the ownership to 'ptr' */
+		    iobj->own = 0;
+		    res = SWIG_AddCast(res);
+		    res = SWIG_AddNewMask(res);
+		  } else {
+		    res = SWIG_AddCast(res);		    
+		  }
+		}
+	      }
+	      Py_DECREF(impconv);
+	    }
+	  }
+	}
+      }
+      return res;
     }
   }
-  return res;
 }
 
 /* Convert a function ptr value */
@@ -2390,19 +2056,14 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
     /* here we get the method pointer for callbacks */
     const char *doc = (((PyCFunctionObject *)obj) -> m_ml -> ml_doc);
     const char *desc = doc ? strstr(doc, "swig_ptr: ") : 0;
-    if (desc)
+    if (desc) {
       desc = ty ? SWIG_UnpackVoidPtr(desc + 10, &vptr, ty->name) : 0;
-    if (!desc) 
-      return SWIG_ERROR;
+      if (!desc) return SWIG_ERROR;
+    }
     if (ty) {
       swig_cast_info *tc = SWIG_TypeCheck(desc,ty);
-      if (tc) {
-        int newmemory = 0;
-        *ptr = SWIG_TypeCast(tc,vptr,&newmemory);
-        assert(!newmemory); /* newmemory handling not yet implemented */
-      } else {
-        return SWIG_ERROR;
-      }
+      if (!tc) return SWIG_ERROR;
+      *ptr = SWIG_TypeCast(tc,vptr);
     } else {
       *ptr = vptr;
     }
@@ -2414,7 +2075,7 @@ SWIG_Python_ConvertFunctionPtr(PyObject *obj, void **ptr, swig_type_info *ty) {
 
 SWIGRUNTIME int
 SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *ty) {
-  swig_type_info *to = SwigPyPacked_UnpackData(obj, ptr, sz);
+  swig_type_info *to = PySwigPacked_UnpackData(obj, ptr, sz);
   if (!to) return SWIG_ERROR;
   if (ty) {
     if (to != ty) {
@@ -2431,12 +2092,12 @@ SWIG_Python_ConvertPacked(PyObject *obj, void *ptr, size_t sz, swig_type_info *t
  * ----------------------------------------------------------------------------- */
 
 /*
-  Create a new instance object, without calling __init__, and set the
+  Create a new instance object, whitout calling __init__, and set the
   'this' attribute.
 */
 
 SWIGRUNTIME PyObject* 
-SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
+SWIG_Python_NewShadowInstance(PySwigClientData *data, PyObject *swig_this)
 {
 #if (PY_VERSION_HEX >= 0x02020000)
   PyObject *inst = 0;
@@ -2460,31 +2121,19 @@ SWIG_Python_NewShadowInstance(SwigPyClientData *data, PyObject *swig_this)
 #endif
     }
   } else {
-#if PY_VERSION_HEX >= 0x03000000
-    inst = ((PyTypeObject*) data->newargs)->tp_new((PyTypeObject*) data->newargs, Py_None, Py_None);
-    if (inst) {
-      PyObject_SetAttr(inst, SWIG_This(), swig_this);
-      Py_TYPE(inst)->tp_flags &= ~Py_TPFLAGS_VALID_VERSION_TAG;
-    }
-#else
     PyObject *dict = PyDict_New();
-    if (dict) {
-      PyDict_SetItem(dict, SWIG_This(), swig_this);
-      inst = PyInstance_NewRaw(data->newargs, dict);
-      Py_DECREF(dict);
-    }
-#endif
+    PyDict_SetItem(dict, SWIG_This(), swig_this);
+    inst = PyInstance_NewRaw(data->newargs, dict);
+    Py_DECREF(dict);
   }
   return inst;
 #else
 #if (PY_VERSION_HEX >= 0x02010000)
-  PyObject *inst = 0;
+  PyObject *inst;
   PyObject *dict = PyDict_New();
-  if (dict) {
-    PyDict_SetItem(dict, SWIG_This(), swig_this);
-    inst = PyInstance_NewRaw(data->newargs, dict);
-    Py_DECREF(dict);
-  }
+  PyDict_SetItem(dict, SWIG_This(), swig_this);
+  inst = PyInstance_NewRaw(data->newargs, dict);
+  Py_DECREF(dict);
   return (PyObject *) inst;
 #else
   PyInstanceObject *inst = PyObject_NEW(PyInstanceObject, &PyInstance_Type);
@@ -2535,12 +2184,12 @@ SWIG_Python_SetSwigThis(PyObject *inst, PyObject *swig_this)
 SWIGINTERN PyObject *
 SWIG_Python_InitShadowInstance(PyObject *args) {
   PyObject *obj[2];
-  if (!SWIG_Python_UnpackTuple(args, "swiginit", 2, 2, obj)) {
+  if (!SWIG_Python_UnpackTuple(args,(char*)"swiginit", 2, 2, obj)) {
     return NULL;
   } else {
-    SwigPyObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
+    PySwigObject *sthis = SWIG_Python_GetSwigThis(obj[0]);
     if (sthis) {
-      SwigPyObject_append((PyObject*) sthis, obj[1]);
+      PySwigObject_append((PyObject*) sthis, obj[1]);
     } else {
       SWIG_Python_SetSwigThis(obj[0], obj[1]);
     }
@@ -2551,59 +2200,29 @@ SWIG_Python_InitShadowInstance(PyObject *args) {
 /* Create a new pointer object */
 
 SWIGRUNTIME PyObject *
-SWIG_Python_NewPointerObj(PyObject *self, void *ptr, swig_type_info *type, int flags) {
-  SwigPyClientData *clientdata;
-  PyObject * robj;
-  int own;
-
-  if (!ptr)
+SWIG_Python_NewPointerObj(void *ptr, swig_type_info *type, int flags) {
+  if (!ptr) {
     return SWIG_Py_Void();
-
-  clientdata = type ? (SwigPyClientData *)(type->clientdata) : 0;
-  own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
-  if (clientdata && clientdata->pytype) {
-    SwigPyObject *newobj;
-    if (flags & SWIG_BUILTIN_TP_INIT) {
-      newobj = (SwigPyObject*) self;
-      if (newobj->ptr) {
-        PyObject *next_self = clientdata->pytype->tp_alloc(clientdata->pytype, 0);
-        while (newobj->next)
-	  newobj = (SwigPyObject *) newobj->next;
-        newobj->next = next_self;
-        newobj = (SwigPyObject *)next_self;
+  } else {
+    int own = (flags & SWIG_POINTER_OWN) ? SWIG_POINTER_OWN : 0;
+    PyObject *robj = PySwigObject_New(ptr, type, own);
+    PySwigClientData *clientdata = type ? (PySwigClientData *)(type->clientdata) : 0;
+    if (clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
+      PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
+      if (inst) {
+	Py_DECREF(robj);
+	robj = inst;
       }
-    } else {
-      newobj = PyObject_New(SwigPyObject, clientdata->pytype);
-    }
-    if (newobj) {
-      newobj->ptr = ptr;
-      newobj->ty = type;
-      newobj->own = own;
-      newobj->next = 0;
-#ifdef SWIGPYTHON_BUILTIN
-      newobj->dict = 0;
-#endif
-      return (PyObject*) newobj;
     }
-    return SWIG_Py_Void();
-  }
-
-  assert(!(flags & SWIG_BUILTIN_TP_INIT));
-
-  robj = SwigPyObject_New(ptr, type, own);
-  if (robj && clientdata && !(flags & SWIG_POINTER_NOSHADOW)) {
-    PyObject *inst = SWIG_Python_NewShadowInstance(clientdata, robj);
-    Py_DECREF(robj);
-    robj = inst;
+    return robj;
   }
-  return robj;
 }
 
 /* Create a new packed object */
 
 SWIGRUNTIMEINLINE PyObject *
 SWIG_Python_NewPackedObj(void *ptr, size_t sz, swig_type_info *type) {
-  return ptr ? SwigPyPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
+  return ptr ? PySwigPacked_New((void *) ptr, sz, type) : SWIG_Py_Void();
 }
 
 /* -----------------------------------------------------------------------------*
@@ -2615,19 +2234,15 @@ void *SWIG_ReturnGlobalTypeList(void *);
 #endif
 
 SWIGRUNTIME swig_module_info *
-SWIG_Python_GetModule(void *SWIGUNUSEDPARM(clientdata)) {
+SWIG_Python_GetModule(void) {
   static void *type_pointer = (void *)0;
   /* first check if module already created */
   if (!type_pointer) {
 #ifdef SWIG_LINK_RUNTIME
     type_pointer = SWIG_ReturnGlobalTypeList((void *)0);
 #else
-# ifdef SWIGPY_USE_CAPSULE
-    type_pointer = PyCapsule_Import(SWIGPY_CAPSULE_NAME, 0);
-# else
     type_pointer = PyCObject_Import((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
 				    (char*)"type_pointer" SWIG_TYPE_TABLE_NAME);
-# endif
     if (PyErr_Occurred()) {
       PyErr_Clear();
       type_pointer = (void *)0;
@@ -2670,54 +2285,33 @@ PyModule_AddObject(PyObject *m, char *name, PyObject *o)
 #endif
 
 SWIGRUNTIME void
-#ifdef SWIGPY_USE_CAPSULE
-SWIG_Python_DestroyModule(PyObject *obj)
-#else
 SWIG_Python_DestroyModule(void *vptr)
-#endif
 {
-#ifdef SWIGPY_USE_CAPSULE
-  swig_module_info *swig_module = (swig_module_info *) PyCapsule_GetPointer(obj, SWIGPY_CAPSULE_NAME);
-#else
   swig_module_info *swig_module = (swig_module_info *) vptr;
-#endif
   swig_type_info **types = swig_module->types;
   size_t i;
   for (i =0; i < swig_module->size; ++i) {
     swig_type_info *ty = types[i];
     if (ty->owndata) {
-      SwigPyClientData *data = (SwigPyClientData *) ty->clientdata;
-      if (data) SwigPyClientData_Del(data);
+      PySwigClientData *data = (PySwigClientData *) ty->clientdata;
+      if (data) PySwigClientData_Del(data);
     }
   }
   Py_DECREF(SWIG_This());
-  swig_this = NULL;
 }
 
 SWIGRUNTIME void
 SWIG_Python_SetModule(swig_module_info *swig_module) {
-#if PY_VERSION_HEX >= 0x03000000
- /* Add a dummy module object into sys.modules */
-  PyObject *module = PyImport_AddModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION);
-#else
-  static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} }; /* Sentinel */
-  PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION, swig_empty_runtime_method_table);
-#endif
-#ifdef SWIGPY_USE_CAPSULE
-  PyObject *pointer = PyCapsule_New((void *) swig_module, SWIGPY_CAPSULE_NAME, SWIG_Python_DestroyModule);
-  if (pointer && module) {
-    PyModule_AddObject(module, (char*)"type_pointer_capsule" SWIG_TYPE_TABLE_NAME, pointer);
-  } else {
-    Py_XDECREF(pointer);
-  }
-#else
+  static PyMethodDef swig_empty_runtime_method_table[] = { {NULL, NULL, 0, NULL} };/* Sentinel */
+
+  PyObject *module = Py_InitModule((char*)"swig_runtime_data" SWIG_RUNTIME_VERSION,
+				   swig_empty_runtime_method_table);
   PyObject *pointer = PyCObject_FromVoidPtr((void *) swig_module, SWIG_Python_DestroyModule);
   if (pointer && module) {
     PyModule_AddObject(module, (char*)"type_pointer" SWIG_TYPE_TABLE_NAME, pointer);
   } else {
     Py_XDECREF(pointer);
   }
-#endif
 }
 
 /* The python cached type query */
@@ -2731,24 +2325,16 @@ SWIGRUNTIME swig_type_info *
 SWIG_Python_TypeQuery(const char *type)
 {
   PyObject *cache = SWIG_Python_TypeCache();
-  PyObject *key = SWIG_Python_str_FromChar(type); 
+  PyObject *key = PyString_FromString(type); 
   PyObject *obj = PyDict_GetItem(cache, key);
   swig_type_info *descriptor;
   if (obj) {
-#ifdef SWIGPY_USE_CAPSULE
-    descriptor = (swig_type_info *) PyCapsule_GetPointer(obj, NULL);
-#else
     descriptor = (swig_type_info *) PyCObject_AsVoidPtr(obj);
-#endif
   } else {
-    swig_module_info *swig_module = SWIG_GetModule(0);
+    swig_module_info *swig_module = SWIG_Python_GetModule();
     descriptor = SWIG_TypeQueryModule(swig_module, swig_module, type);
     if (descriptor) {
-#ifdef SWIGPY_USE_CAPSULE
-      obj = PyCapsule_New((void*) descriptor, NULL, NULL);
-#else
       obj = PyCObject_FromVoidPtr(descriptor, NULL);
-#endif
       PyDict_SetItem(cache, key, obj);
       Py_DECREF(obj);
     }
@@ -2766,23 +2352,21 @@ SWIG_Python_TypeQuery(const char *type)
 
 SWIGRUNTIME int
 SWIG_Python_AddErrMesg(const char* mesg, int infront)
-{  
+{
   if (PyErr_Occurred()) {
     PyObject *type = 0;
     PyObject *value = 0;
     PyObject *traceback = 0;
     PyErr_Fetch(&type, &value, &traceback);
     if (value) {
-      char *tmp;
       PyObject *old_str = PyObject_Str(value);
       Py_XINCREF(type);
       PyErr_Clear();
       if (infront) {
-	PyErr_Format(type, "%s %s", mesg, tmp = SWIG_Python_str_AsChar(old_str));
+	PyErr_Format(type, "%s %s", mesg, PyString_AsString(old_str));
       } else {
-	PyErr_Format(type, "%s %s", tmp = SWIG_Python_str_AsChar(old_str), mesg);
+	PyErr_Format(type, "%s %s", PyString_AsString(old_str), mesg);
       }
-      SWIG_Python_str_DelForPy3(tmp);
       Py_DECREF(old_str);
     }
     return 1;
@@ -2805,11 +2389,11 @@ SWIG_Python_ArgFail(int argnum)
 }
 
 SWIGRUNTIMEINLINE const char *
-SwigPyObject_GetDesc(PyObject *self)
+PySwigObject_GetDesc(PyObject *self)
 {
-  SwigPyObject *v = (SwigPyObject *)self;
+  PySwigObject *v = (PySwigObject *)self;
   swig_type_info *ty = v ? v->ty : 0;
-  return ty ? ty->str : "";
+  return ty ? ty->str : (char*)"";
 }
 
 SWIGRUNTIME void
@@ -2817,10 +2401,10 @@ SWIG_Python_TypeError(const char *type, PyObject *obj)
 {
   if (type) {
 #if defined(SWIG_COBJECT_TYPES)
-    if (obj && SwigPyObject_Check(obj)) {
-      const char *otype = (const char *) SwigPyObject_GetDesc(obj);
+    if (obj && PySwigObject_Check(obj)) {
+      const char *otype = (const char *) PySwigObject_GetDesc(obj);
       if (otype) {
-	PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'SwigPyObject(%s)' is received",
+	PyErr_Format(PyExc_TypeError, "a '%s' is expected, 'PySwigObject(%s)' is received",
 		     type, otype);
 	return;
       }
@@ -2830,11 +2414,10 @@ SWIG_Python_TypeError(const char *type, PyObject *obj)
       const char *otype = (obj ? obj->ob_type->tp_name : 0); 
       if (otype) {
 	PyObject *str = PyObject_Str(obj);
-	const char *cstr = str ? SWIG_Python_str_AsChar(str) : 0;
+	const char *cstr = str ? PyString_AsString(str) : 0;
 	if (cstr) {
 	  PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s(%s)' is received",
 		       type, otype, cstr);
-          SWIG_Python_str_DelForPy3(cstr);
 	} else {
 	  PyErr_Format(PyExc_TypeError, "a '%s' is expected, '%s' is received",
 		       type, otype);
@@ -2852,75 +2435,23 @@ SWIG_Python_TypeError(const char *type, PyObject *obj)
 
 /* Convert a pointer value, signal an exception on a type mismatch */
 SWIGRUNTIME void *
-SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int SWIGUNUSEDPARM(argnum), int flags) {
+SWIG_Python_MustGetPtr(PyObject *obj, swig_type_info *ty, int argnum, int flags) {
   void *result;
   if (SWIG_Python_ConvertPtr(obj, &result, ty, flags) == -1) {
     PyErr_Clear();
-#if SWIG_POINTER_EXCEPTION
-    if (flags) {
+    if (flags & SWIG_POINTER_EXCEPTION) {
       SWIG_Python_TypeError(SWIG_TypePrettyName(ty), obj);
       SWIG_Python_ArgFail(argnum);
     }
-#endif
   }
   return result;
 }
 
-#ifdef SWIGPYTHON_BUILTIN
-SWIGRUNTIME int
-SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
-  PyTypeObject *tp = obj->ob_type;
-  PyObject *descr;
-  PyObject *encoded_name;
-  descrsetfunc f;
-  int res = -1;
-
-# ifdef Py_USING_UNICODE
-  if (PyString_Check(name)) {
-    name = PyUnicode_Decode(PyString_AsString(name), PyString_Size(name), NULL, NULL);
-    if (!name)
-      return -1;
-  } else if (!PyUnicode_Check(name))
-# else
-  if (!PyString_Check(name))
-# endif
-  {
-    PyErr_Format(PyExc_TypeError, "attribute name must be string, not '%.200s'", name->ob_type->tp_name);
-    return -1;
-  } else {
-    Py_INCREF(name);
-  }
-
-  if (!tp->tp_dict) {
-    if (PyType_Ready(tp) < 0)
-      goto done;
-  }
-
-  descr = _PyType_Lookup(tp, name);
-  f = NULL;
-  if (descr != NULL)
-    f = descr->ob_type->tp_descr_set;
-  if (!f) {
-    if (PyString_Check(name)) {
-      encoded_name = name;
-      Py_INCREF(name);
-    } else {
-      encoded_name = PyUnicode_AsUTF8String(name);
-    }
-    PyErr_Format(PyExc_AttributeError, "'%.100s' object has no attribute '%.200s'", tp->tp_name, PyString_AsString(encoded_name));
-    Py_DECREF(encoded_name);
-  } else {
-    res = f(descr, obj, value);
-  }
-  
-  done:
-  Py_DECREF(name);
-  return res;
-}
-#endif
-
 
 #ifdef __cplusplus
+#if 0
+{ /* cc-mode */
+#endif
 }
 #endif
 
@@ -2952,36 +2483,39 @@ SWIG_Python_NonDynamicSetAttr(PyObject *obj, PyObject *name, PyObject *value) {
 #define SWIGTYPE_p_p_PyObject swig_types[12]
 #define SWIGTYPE_p_p_double swig_types[13]
 #define SWIGTYPE_p_size_type swig_types[14]
-#define SWIGTYPE_p_std__allocatorT_CdiVariable_t swig_types[15]
-#define SWIGTYPE_p_std__allocatorT_double_t swig_types[16]
-#define SWIGTYPE_p_std__allocatorT_int_t swig_types[17]
-#define SWIGTYPE_p_std__allocatorT_std__pairT_int_const_CdiGrid_t_t swig_types[18]
-#define SWIGTYPE_p_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t swig_types[19]
-#define SWIGTYPE_p_std__allocatorT_std__pairT_int_const_CdiVariable_t_t swig_types[20]
-#define SWIGTYPE_p_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t swig_types[21]
-#define SWIGTYPE_p_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t swig_types[22]
-#define SWIGTYPE_p_std__allocatorT_std__string_t swig_types[23]
-#define SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t swig_types[24]
-#define SWIGTYPE_p_std__invalid_argument swig_types[25]
-#define SWIGTYPE_p_std__lessT_int_t swig_types[26]
-#define SWIGTYPE_p_std__lessT_std__string_t swig_types[27]
-#define SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t swig_types[28]
-#define SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t swig_types[29]
-#define SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t swig_types[30]
-#define SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t swig_types[31]
-#define SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t swig_types[32]
-#define SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t swig_types[33]
-#define SWIGTYPE_p_std__vectorT__Tp__Alloc_t swig_types[34]
-#define SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t swig_types[35]
-#define SWIGTYPE_p_std__vectorT_float_std__allocatorT_float_t_t swig_types[36]
-#define SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t swig_types[37]
-#define SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t swig_types[38]
-#define SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t swig_types[39]
-#define SWIGTYPE_p_std__vectorT_std__vectorT_float_std__allocatorT_float_t_t_std__allocatorT_std__vectorT_float_std__allocatorT_float_t_t_t_t swig_types[40]
-#define SWIGTYPE_p_swig__SwigPyIterator swig_types[41]
-#define SWIGTYPE_p_value_type swig_types[42]
-static swig_type_info *swig_types[44];
-static swig_module_info swig_module = {swig_types, 43, 0, 0, 0, 0};
+#define SWIGTYPE_p_std__invalid_argument swig_types[15]
+#define SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t swig_types[16]
+#define SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__allocator_type swig_types[17]
+#define SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__mapped_type swig_types[18]
+#define SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t swig_types[19]
+#define SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__allocator_type swig_types[20]
+#define SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__mapped_type swig_types[21]
+#define SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t swig_types[22]
+#define SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__allocator_type swig_types[23]
+#define SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__mapped_type swig_types[24]
+#define SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t swig_types[25]
+#define SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__allocator_type swig_types[26]
+#define SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__mapped_type swig_types[27]
+#define SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t swig_types[28]
+#define SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__allocator_type swig_types[29]
+#define SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__mapped_type swig_types[30]
+#define SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t swig_types[31]
+#define SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__allocator_type swig_types[32]
+#define SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type swig_types[33]
+#define SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t swig_types[34]
+#define SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t__allocator_type swig_types[35]
+#define SWIGTYPE_p_std__vectorTfloat_std__allocatorTfloat_t_t swig_types[36]
+#define SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t swig_types[37]
+#define SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t__allocator_type swig_types[38]
+#define SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t swig_types[39]
+#define SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t__allocator_type swig_types[40]
+#define SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t swig_types[41]
+#define SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t__allocator_type swig_types[42]
+#define SWIGTYPE_p_std__vectorTstd__vectorTfloat_std__allocatorTfloat_t_t_std__allocatorTstd__vectorTfloat_std__allocatorTfloat_t_t_t_t swig_types[43]
+#define SWIGTYPE_p_swig__PySwigIterator swig_types[44]
+#define SWIGTYPE_p_value_type swig_types[45]
+static swig_type_info *swig_types[47];
+static swig_module_info swig_module = {swig_types, 46, 0, 0, 0, 0};
 #define SWIG_TypeQuery(name) SWIG_TypeQueryModule(&swig_module, &swig_module, name)
 #define SWIG_MangledTypeQuery(name) SWIG_MangledTypeQueryModule(&swig_module, &swig_module, name)
 
@@ -2996,16 +2530,11 @@ static swig_module_info swig_module = {swig_types, 43, 0, 0, 0, 0};
 /*-----------------------------------------------
               @(target):= _CdiObj.so
   ------------------------------------------------*/
-#if PY_VERSION_HEX >= 0x03000000
-#  define SWIG_init    PyInit__CdiObj
-
-#else
-#  define SWIG_init    init_CdiObj
+#define SWIG_init    init_CdiObj
 
-#endif
 #define SWIG_name    "_CdiObj"
 
-#define SWIGVERSION 0x030002 
+#define SWIGVERSION 0x010331 
 #define SWIG_VERSION SWIGVERSION
 
 
@@ -3017,28 +2546,26 @@ static swig_module_info swig_module = {swig_types, 43, 0, 0, 0, 0};
 
 
 namespace swig {
-  class SwigPtr_PyObject {
+  class PyObject_ptr {
   protected:
     PyObject *_obj;
 
   public:
-    SwigPtr_PyObject() :_obj(0)
+    PyObject_ptr() :_obj(0)
     {
     }
 
-    SwigPtr_PyObject(const SwigPtr_PyObject& item) : _obj(item._obj)
+    PyObject_ptr(const PyObject_ptr& item) : _obj(item._obj)
     {
       Py_XINCREF(_obj);      
     }
     
-    SwigPtr_PyObject(PyObject *obj, bool initial_ref = true) :_obj(obj)
+    PyObject_ptr(PyObject *obj, bool initial_ref = true) :_obj(obj)
     {
-      if (initial_ref) {
-        Py_XINCREF(_obj);
-      }
+      if (initial_ref) Py_XINCREF(_obj);
     }
     
-    SwigPtr_PyObject & operator=(const SwigPtr_PyObject& item) 
+    PyObject_ptr & operator=(const PyObject_ptr& item) 
     {
       Py_XINCREF(item._obj);
       Py_XDECREF(_obj);
@@ -3046,7 +2573,7 @@ namespace swig {
       return *this;      
     }
     
-    ~SwigPtr_PyObject() 
+    ~PyObject_ptr() 
     {
       Py_XDECREF(_obj);
     }
@@ -3065,10 +2592,10 @@ namespace swig {
 
 
 namespace swig {
-  struct SwigVar_PyObject : SwigPtr_PyObject {
-    SwigVar_PyObject(PyObject* obj = 0) : SwigPtr_PyObject(obj, false) { }
+  struct PyObject_var : PyObject_ptr {
+    PyObject_var(PyObject* obj = 0) : PyObject_ptr(obj, false) { }
     
-    SwigVar_PyObject & operator = (PyObject* obj)
+    PyObject_var & operator = (PyObject* obj)
     {
       Py_XDECREF(_obj);
       _obj = obj;
@@ -3085,6 +2612,13 @@ namespace swig {
 #include <stdexcept>
 
 
+  
+#if defined(__SUNPRO_CC) && defined(_RWSTD_VER)
+#  define SWIG_STD_NOASSIGN_STL
+#  define SWIG_STD_NOINSERT_TEMPLATE_STL
+#  define SWIG_STD_NOITERATOR_TRAITS_STL
+#endif
+
 #if defined(__GNUC__)
 #  if __GNUC__ == 2 && __GNUC_MINOR <= 96
 #     define SWIG_STD_NOMODERN_STL
@@ -3092,123 +2626,109 @@ namespace swig {
 #endif
 
 
-#include <string>
 
 
-#include <stddef.h>
+#include <string>
+#include <stdexcept>
 
 
-#include <iostream>
+#include <string>
 
-#if PY_VERSION_HEX >= 0x03020000
-# define SWIGPY_SLICE_ARG(obj) ((PyObject*) (obj))
-#else
-# define SWIGPY_SLICE_ARG(obj) ((PySliceObject*) (obj))
-#endif
 
+#include <iostream>
 
+  
 namespace swig {
   struct stop_iteration {
   };
 
-  struct SwigPyIterator {
+  struct PySwigIterator {
   private:
-    SwigPtr_PyObject _seq;
+    PyObject_ptr _seq;
 
   protected:
-    SwigPyIterator(PyObject *seq) : _seq(seq)
+    PySwigIterator(PyObject *seq) : _seq(seq)
     {
     }
       
   public:
-    virtual ~SwigPyIterator() {}
+    virtual ~PySwigIterator() {}
 
     // Access iterator method, required by Python
     virtual PyObject *value() const = 0;
 
     // Forward iterator method, required by Python
-    virtual SwigPyIterator *incr(size_t n = 1) = 0;
+    virtual PySwigIterator *incr(size_t n = 1) = 0;
     
     // Backward iterator method, very common in C++, but not required in Python
-    virtual SwigPyIterator *decr(size_t /*n*/ = 1)
+    virtual PySwigIterator *decr(size_t n = 1)
     {
       throw stop_iteration();
     }
 
     // Random access iterator methods, but not required in Python
-    virtual ptrdiff_t distance(const SwigPyIterator &/*x*/) const
+    virtual ptrdiff_t distance(const PySwigIterator &x) const
     {
       throw std::invalid_argument("operation not supported");
     }
 
-    virtual bool equal (const SwigPyIterator &/*x*/) const
+    virtual bool equal (const PySwigIterator &x) const
     {
       throw std::invalid_argument("operation not supported");
     }
     
     // C++ common/needed methods
-    virtual SwigPyIterator *copy() const = 0;
+    virtual PySwigIterator *copy() const = 0;
 
-    PyObject *next()     
+    PyObject *next()
     {
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads       
       PyObject *obj = value();
-      incr();       
-      SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads
-      return obj;     
-    }
-
-    /* Make an alias for Python 3.x */
-    PyObject *__next__()
-    {
-      return next();
+      incr();
+      return obj;
     }
 
     PyObject *previous()
     {
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK; // disable threads       
       decr();
-      PyObject *obj = value();
-      SWIG_PYTHON_THREAD_END_BLOCK; // re-enable threads       
-      return obj;
+      return value();
     }
 
-    SwigPyIterator *advance(ptrdiff_t n)
+    PySwigIterator *advance(ptrdiff_t n)
     {
       return  (n > 0) ?  incr(n) : decr(-n);
     }
       
-    bool operator == (const SwigPyIterator& x)  const
+    bool operator == (const PySwigIterator& x)  const
     {
       return equal(x);
     }
       
-    bool operator != (const SwigPyIterator& x) const
+    bool operator != (const PySwigIterator& x) const
     {
       return ! operator==(x);
     }
       
-    SwigPyIterator& operator += (ptrdiff_t n)
+    PySwigIterator& operator += (ptrdiff_t n)
     {
       return *advance(n);
     }
 
-    SwigPyIterator& operator -= (ptrdiff_t n)
+    PySwigIterator& operator -= (ptrdiff_t n)
     {
       return *advance(-n);
     }
       
-    SwigPyIterator* operator + (ptrdiff_t n) const
+    PySwigIterator* operator + (ptrdiff_t n) const
     {
       return copy()->advance(n);
     }
 
-    SwigPyIterator* operator - (ptrdiff_t n) const
+    PySwigIterator* operator - (ptrdiff_t n) const
     {
       return copy()->advance(-n);
     }
       
-    ptrdiff_t operator - (const SwigPyIterator& x) const
+    ptrdiff_t operator - (const PySwigIterator& x) const
     {
       return x.distance(*this);
     }
@@ -3217,20 +2737,12 @@ namespace swig {
       static int init = 0;
       static swig_type_info* desc = 0;
       if (!init) {
-	desc = SWIG_TypeQuery("swig::SwigPyIterator *");
+	desc = SWIG_TypeQuery("swig::PySwigIterator *");
 	init = 1;
       }	
       return desc;
     }    
   };
-
-#if defined(SWIGPYTHON_BUILTIN)
-  inline PyObject* make_output_iterator_builtin (PyObject *pyself)
-  {
-    Py_INCREF(pyself);
-    return pyself;
-  }
-#endif
 }
 
 
@@ -3317,7 +2829,6 @@ SWIG_CanCastAsInteger(double *d, double min, double max) {
 SWIGINTERN int
 SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val) 
 {
-#if PY_VERSION_HEX < 0x03000000
   if (PyInt_Check(obj)) {
     long v = PyInt_AsLong(obj);
     if (v >= 0) {
@@ -3326,27 +2837,13 @@ SWIG_AsVal_unsigned_SS_long (PyObject *obj, unsigned long *val)
     } else {
       return SWIG_OverflowError;
     }
-  } else
-#endif
-  if (PyLong_Check(obj)) {
+  } else if (PyLong_Check(obj)) {
     unsigned long v = PyLong_AsUnsignedLong(obj);
     if (!PyErr_Occurred()) {
       if (val) *val = v;
       return SWIG_OK;
     } else {
       PyErr_Clear();
-#if PY_VERSION_HEX >= 0x03000000
-      {
-        long v = PyLong_AsLong(obj);
-        if (!PyErr_Occurred()) {
-          if (v < 0) {
-            return SWIG_OverflowError;
-          }
-        } else {
-          PyErr_Clear();
-        }
-      }
-#endif
     }
   }
 #ifdef SWIG_PYTHON_CAST_MODE
@@ -3383,7 +2880,7 @@ SWIG_AsVal_size_t (PyObject * obj, size_t *val)
 }
 
 
-  #define SWIG_From_long   PyLong_FromLong 
+  #define SWIG_From_long   PyInt_FromLong 
 
 
 SWIGINTERNINLINE PyObject *
@@ -3449,6 +2946,9 @@ SWIG_AsVal_ptrdiff_t (PyObject * obj, ptrdiff_t *val)
 }
 
 
+#include <stdexcept>
+
+
 #include <algorithm>
 
 
@@ -3459,9 +2959,8 @@ SWIG_AsVal_ptrdiff_t (PyObject * obj, ptrdiff_t *val)
 
 
 #include <map>
-
-
 #include <algorithm>
+#include <stdexcept>
 
 
 namespace swig {  
@@ -3539,7 +3038,7 @@ namespace swig {
   */
   template <class Type> struct traits_from_ptr {
     static PyObject *from(Type *val, int owner = 0) {
-      return SWIG_InternalNewPointerObj(val, type_info<Type>(), owner);
+      return SWIG_NewPointerObj(val, type_info<Type>(), owner);
     }
   };
 
@@ -3579,7 +3078,7 @@ namespace swig {
   struct traits_asptr {   
     static int asptr(PyObject *obj, Type **val) {
       Type *p;
-      int res = SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0);
+      int res = (SWIG_ConvertPtr(obj, (void**)&p, type_info<Type>(), 0) == SWIG_OK) ? SWIG_OLDOBJ : 0;
       if (SWIG_IsOK(res)) {
 	if (val) *val = p;
       }
@@ -3644,7 +3143,7 @@ namespace swig {
       int res = asval(obj, &v);
       if (!obj || !SWIG_IsOK(res)) {
 	if (!PyErr_Occurred()) {
-	  ::SWIG_Error(SWIG_TypeError,  swig::type_name<Type>());
+	  SWIG_Error(SWIG_TypeError,  swig::type_name<Type>());
 	}
 	if (throw_error) throw std::invalid_argument("bad type");
       }
@@ -3734,38 +3233,27 @@ namespace std {
     { 
       bool res;
       SWIG_PYTHON_THREAD_BEGIN_BLOCK;
-      res = PyObject_RichCompareBool(v, w, Py_LT) ? true : false;
-      /* This may fall into a case of inconsistent
-               eg. ObjA > ObjX > ObjB
-               but ObjA < ObjB
-      */
-      if( PyErr_Occurred() && PyErr_ExceptionMatches(PyExc_TypeError) )
-      {
-        /* Objects can't be compared, this mostly occurred in Python 3.0 */
-        /* Compare their ptr directly for a workaround */
-        res = (v < w);
-        PyErr_Clear();
-      }
+      res = PyObject_Compare(v, w) < 0;
       SWIG_PYTHON_THREAD_END_BLOCK;
       return res;
     }
   };
 
   template <>
-  struct less <swig::SwigPtr_PyObject>: public binary_function<swig::SwigPtr_PyObject, swig::SwigPtr_PyObject, bool>
+  struct less <swig::PyObject_ptr>: public binary_function<swig::PyObject_ptr, swig::PyObject_ptr, bool>
   {
     bool
-    operator()(const swig::SwigPtr_PyObject& v, const swig::SwigPtr_PyObject& w) const
+    operator()(const swig::PyObject_ptr& v, const swig::PyObject_ptr& w) const
     {
       return std::less<PyObject *>()(v, w);
     }
   };
 
   template <>
-  struct less <swig::SwigVar_PyObject>: public binary_function<swig::SwigVar_PyObject, swig::SwigVar_PyObject, bool>
+  struct less <swig::PyObject_var>: public binary_function<swig::PyObject_var, swig::PyObject_var, bool>
   {
     bool
-    operator()(const swig::SwigVar_PyObject& v, const swig::SwigVar_PyObject& w) const
+    operator()(const swig::PyObject_var& v, const swig::PyObject_var& w) const
     {
       return std::less<PyObject *>()(v, w);
     }
@@ -3805,9 +3293,8 @@ namespace swig {
 }
 
 namespace swig {
-  template <class Difference>
   inline size_t
-  check_index(Difference i, size_t size, bool insert = false) {
+  check_index(ptrdiff_t i, size_t size, bool insert = false) {
     if ( i < 0 ) {
       if ((size_t) (-i) <= size)
 	return (size_t) (i + size);
@@ -3816,42 +3303,20 @@ namespace swig {
     } else if (insert && ((size_t) i == size)) {
       return size;
     }
+    
     throw std::out_of_range("index out of range");
   }
 
-  template <class Difference>
-  void
-  slice_adjust(Difference i, Difference j, Py_ssize_t step, size_t size, Difference &ii, Difference &jj, bool insert = false) {
-    if (step == 0) {
-      throw std::invalid_argument("slice step cannot be zero");
-    } else if (step > 0) {
-      // Required range: 0 <= i < size, 0 <= j < size
-      if (i < 0) {
-        ii = 0;
-      } else if (i < (Difference)size) {
-        ii = i;
-      } else if (insert && (i >= (Difference)size)) {
-        ii = (Difference)size;
-      }
-      if ( j < 0 ) {
-        jj = 0;
+  inline size_t
+  slice_index(ptrdiff_t i, size_t size) {
+    if ( i < 0 ) {
+      if ((size_t) (-i) <= size) {
+	return (size_t) (i + size);
       } else {
-        jj = (j < (Difference)size) ? j : (Difference)size;
+	throw std::out_of_range("index out of range");
       }
     } else {
-      // Required range: -1 <= i < size-1, -1 <= j < size-1
-      if (i < -1) {
-        ii = -1;
-      } else if (i < (Difference) size) {
-        ii = i;
-      } else if (i >= (Difference)(size-1)) {
-        ii = (Difference)(size-1);
-      }
-      if (j < -1) {
-        jj = -1;
-      } else {
-        jj = (j < (Difference)size ) ? j : (Difference)(size-1);
-      }
+      return ( (size_t) i < size ) ? ((size_t) i) : size;
     }
   }
 
@@ -3873,178 +3338,80 @@ namespace swig {
 
   template <class Sequence, class Difference>
   inline Sequence*
-  getslice(const Sequence* self, Difference i, Difference j, Py_ssize_t step) {
+  getslice(const Sequence* self, Difference i, Difference j) {
     typename Sequence::size_type size = self->size();
-    Difference ii = 0;
-    Difference jj = 0;
-    swig::slice_adjust(i, j, step, size, ii, jj);
-
-    if (step > 0) {
-      typename Sequence::const_iterator sb = self->begin();
-      typename Sequence::const_iterator se = self->begin();
-      std::advance(sb,ii);
-      std::advance(se,jj);
-      if (step == 1) {
-        return new Sequence(sb, se);
-      } else {
-        Sequence *sequence = new Sequence();
-        typename Sequence::const_iterator it = sb;
-        while (it!=se) {
-          sequence->push_back(*it);
-          for (Py_ssize_t c=0; c<step && it!=se; ++c)
-            it++;
-        }
-        return sequence;
-      } 
+    typename Sequence::size_type ii = swig::check_index(i, size);
+    typename Sequence::size_type jj = swig::slice_index(j, size);
+
+    if (jj > ii) {
+      typename Sequence::const_iterator vb = self->begin();
+      typename Sequence::const_iterator ve = self->begin();
+      std::advance(vb,ii);
+      std::advance(ve,jj);
+      return new Sequence(vb, ve);
     } else {
-      Sequence *sequence = new Sequence();
-      if (ii > jj) {
-        typename Sequence::const_reverse_iterator sb = self->rbegin();
-        typename Sequence::const_reverse_iterator se = self->rbegin();
-        std::advance(sb,size-ii-1);
-        std::advance(se,size-jj-1);
-        typename Sequence::const_reverse_iterator it = sb;
-        while (it!=se) {
-          sequence->push_back(*it);
-          for (Py_ssize_t c=0; c<-step && it!=se; ++c)
-            it++;
-        }
-      }
-      return sequence;
+      return new Sequence();
     }
   }
 
   template <class Sequence, class Difference, class InputSeq>
   inline void
-  setslice(Sequence* self, Difference i, Difference j, Py_ssize_t step, const InputSeq& is = InputSeq()) {
+  setslice(Sequence* self, Difference i, Difference j, const InputSeq& v) {
     typename Sequence::size_type size = self->size();
-    Difference ii = 0;
-    Difference jj = 0;
-    swig::slice_adjust(i, j, step, size, ii, jj, true);
-    if (step > 0) {
-      if (jj < ii)
-        jj = ii;
-      if (step == 1) {
-        size_t ssize = jj - ii;
-        if (ssize <= is.size()) {
-          // expanding/staying the same size
-          typename Sequence::iterator sb = self->begin();
-          typename InputSeq::const_iterator isit = is.begin();
-          std::advance(sb,ii);
-          std::advance(isit, jj - ii);
-          self->insert(std::copy(is.begin(), isit, sb), isit, is.end());
-        } else {
-          // shrinking
-          typename Sequence::iterator sb = self->begin();
-          typename Sequence::iterator se = self->begin();
-          std::advance(sb,ii);
-          std::advance(se,jj);
-          self->erase(sb,se);
-          sb = self->begin();
-          std::advance(sb,ii);
-          self->insert(sb, is.begin(), is.end());
-        }
-      } else {
-        size_t replacecount = (jj - ii + step - 1) / step;
-        if (is.size() != replacecount) {
-          char msg[1024];
-          sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount);
-          throw std::invalid_argument(msg);
-        }
-        typename Sequence::const_iterator isit = is.begin();
-        typename Sequence::iterator it = self->begin();
-        std::advance(it,ii);
-        for (size_t rc=0; rc<replacecount; ++rc) {
-          *it++ = *isit++;
-          for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
-            it++;
-        }
-      }
+    typename Sequence::size_type ii = swig::check_index(i, size, true);
+    typename Sequence::size_type jj = swig::slice_index(j, size);
+    if (jj < ii) jj = ii;
+    size_t ssize = jj - ii;
+    if (ssize <= v.size()) {
+      typename Sequence::iterator sb = self->begin();
+      typename InputSeq::const_iterator vmid = v.begin();
+      std::advance(sb,ii);
+      std::advance(vmid, jj - ii);
+      self->insert(std::copy(v.begin(), vmid, sb), vmid, v.end());
     } else {
-      if (jj > ii)
-        jj = ii;
-      size_t replacecount = (ii - jj - step - 1) / -step;
-      if (is.size() != replacecount) {
-        char msg[1024];
-        sprintf(msg, "attempt to assign sequence of size %lu to extended slice of size %lu", (unsigned long)is.size(), (unsigned long)replacecount);
-        throw std::invalid_argument(msg);
-      }
-      typename Sequence::const_iterator isit = is.begin();
-      typename Sequence::reverse_iterator it = self->rbegin();
-      std::advance(it,size-ii-1);
-      for (size_t rc=0; rc<replacecount; ++rc) {
-        *it++ = *isit++;
-        for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
-          it++;
-      }
+      typename Sequence::iterator sb = self->begin();
+      typename Sequence::iterator se = self->begin();
+      std::advance(sb,ii);
+      std::advance(se,jj);
+      self->erase(sb,se);
+      self->insert(sb, v.begin(), v.end());
     }
   }
 
   template <class Sequence, class Difference>
   inline void
-  delslice(Sequence* self, Difference i, Difference j, Py_ssize_t step) {
+  delslice(Sequence* self, Difference i, Difference j) {
     typename Sequence::size_type size = self->size();
-    Difference ii = 0;
-    Difference jj = 0;
-    swig::slice_adjust(i, j, step, size, ii, jj, true);
-    if (step > 0) {
-      if (jj > ii) {
-        typename Sequence::iterator sb = self->begin();
-        std::advance(sb,ii);
-        if (step == 1) {
-          typename Sequence::iterator se = self->begin();
-          std::advance(se,jj);
-          self->erase(sb,se);
-        } else {
-          typename Sequence::iterator it = sb;
-          size_t delcount = (jj - ii + step - 1) / step;
-          while (delcount) {
-            it = self->erase(it);
-            for (Py_ssize_t c=0; c<(step-1) && it != self->end(); ++c)
-              it++;
-            delcount--;
-          }
-        }
-      }
-    } else {
-      if (ii > jj) {
-        typename Sequence::reverse_iterator sb = self->rbegin();
-        std::advance(sb,size-ii-1);
-        typename Sequence::reverse_iterator it = sb;
-        size_t delcount = (ii - jj - step - 1) / -step;
-        while (delcount) {
-          it = typename Sequence::reverse_iterator(self->erase((++it).base()));
-          for (Py_ssize_t c=0; c<(-step-1) && it != self->rend(); ++c)
-            it++;
-          delcount--;
-        }
-      }
+    typename Sequence::size_type ii = swig::check_index(i, size, true);
+    typename Sequence::size_type jj = swig::slice_index(j, size);
+    if (jj > ii) {
+      typename Sequence::iterator sb = self->begin();
+      typename Sequence::iterator se = self->begin();
+      std::advance(sb,ii);
+      std::advance(se,jj);
+      self->erase(sb,se);
     }
   }
 }
 
 
-#if defined(__SUNPRO_CC) && defined(_RWSTD_VER)
-#  if !defined(SWIG_NO_STD_NOITERATOR_TRAITS_STL)
-#    define SWIG_STD_NOITERATOR_TRAITS_STL
-#  endif
-#endif
-
 #if !defined(SWIG_STD_NOITERATOR_TRAITS_STL)
 #include <iterator>
 #else
-namespace std {
+namespace std  {
   template <class Iterator>
   struct iterator_traits {
     typedef ptrdiff_t difference_type;
     typedef typename Iterator::value_type value_type;
   };
 
+#if defined(__SUNPRO_CC) && defined(_RWSTD_VER)
   template <class Iterator, class Category,class T, class Reference, class Pointer, class Distance>
   struct iterator_traits<__reverse_bi_iterator<Iterator,Category,T,Reference,Pointer,Distance> > {
     typedef Distance difference_type;
     typedef T value_type;
   };
+#endif  
 
   template <class T>
   struct iterator_traits<T*> {
@@ -4062,21 +3429,22 @@ namespace std {
     }
     return __n;
   }
-}
+
+} 
 #endif
 
 
 namespace swig {
   template<typename OutIterator>
-  class SwigPyIterator_T :  public SwigPyIterator
+  class PySwigIterator_T :  public PySwigIterator
   {
   public:
     typedef OutIterator out_iterator;
     typedef typename std::iterator_traits<out_iterator>::value_type value_type;    
-    typedef SwigPyIterator_T<out_iterator> self_type;
+    typedef PySwigIterator_T<out_iterator> self_type;
 
-    SwigPyIterator_T(out_iterator curr, PyObject *seq)
-      : SwigPyIterator(seq), current(curr)
+    PySwigIterator_T(out_iterator curr, PyObject *seq)
+      : PySwigIterator(seq), current(curr)
     {
     }
 
@@ -4086,7 +3454,7 @@ namespace swig {
     }
 
     
-    bool equal (const SwigPyIterator &iter) const
+    bool equal (const PySwigIterator &iter) const
     {
       const self_type *iters = dynamic_cast<const self_type *>(&iter);
       if (iters) {
@@ -4096,7 +3464,7 @@ namespace swig {
       }
     }
     
-    ptrdiff_t distance(const SwigPyIterator &iter) const
+    ptrdiff_t distance(const PySwigIterator &iter) const
     {
       const self_type *iters = dynamic_cast<const self_type *>(&iter);
       if (iters) {
@@ -4124,17 +3492,17 @@ namespace swig {
   template<typename OutIterator, 
 	   typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
 	   typename FromOper = from_oper<ValueType> >
-  class SwigPyIteratorOpen_T :  public SwigPyIterator_T<OutIterator>
+  class PySwigIteratorOpen_T :  public PySwigIterator_T<OutIterator>
   {
   public:
     FromOper from;
     typedef OutIterator out_iterator;
     typedef ValueType value_type;
-    typedef SwigPyIterator_T<out_iterator>  base;
-    typedef SwigPyIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
+    typedef PySwigIterator_T<out_iterator>  base;
+    typedef PySwigIteratorOpen_T<OutIterator, ValueType, FromOper> self_type;
     
-    SwigPyIteratorOpen_T(out_iterator curr, PyObject *seq)
-      : SwigPyIterator_T<OutIterator>(curr, seq)
+    PySwigIteratorOpen_T(out_iterator curr, PyObject *seq)
+      : PySwigIterator_T<OutIterator>(curr, seq)
     {
     }
     
@@ -4142,12 +3510,12 @@ namespace swig {
       return from(static_cast<const value_type&>(*(base::current)));
     }
     
-    SwigPyIterator *copy() const
+    PySwigIterator *copy() const
     {
       return new self_type(*this);
     }
 
-    SwigPyIterator *incr(size_t n = 1)
+    PySwigIterator *incr(size_t n = 1)
     {
       while (n--) {
 	++base::current;
@@ -4155,7 +3523,7 @@ namespace swig {
       return this;
     }
 
-    SwigPyIterator *decr(size_t n = 1)
+    PySwigIterator *decr(size_t n = 1)
     {
       while (n--) {
 	--base::current;
@@ -4167,17 +3535,17 @@ namespace swig {
   template<typename OutIterator, 
 	   typename ValueType = typename std::iterator_traits<OutIterator>::value_type,
 	   typename FromOper = from_oper<ValueType> >
-  class SwigPyIteratorClosed_T :  public SwigPyIterator_T<OutIterator>
+  class PySwigIteratorClosed_T :  public PySwigIterator_T<OutIterator>
   {
   public:
     FromOper from;
     typedef OutIterator out_iterator;
     typedef ValueType value_type;
-    typedef SwigPyIterator_T<out_iterator>  base;    
-    typedef SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
+    typedef PySwigIterator_T<out_iterator>  base;    
+    typedef PySwigIteratorClosed_T<OutIterator, ValueType, FromOper> self_type;
     
-    SwigPyIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq)
-      : SwigPyIterator_T<OutIterator>(curr, seq), begin(first), end(last)
+    PySwigIteratorClosed_T(out_iterator curr, out_iterator first, out_iterator last, PyObject *seq)
+      : PySwigIterator_T<OutIterator>(curr, seq), begin(first), end(last)
     {
     }
     
@@ -4189,12 +3557,12 @@ namespace swig {
       }
     }
     
-    SwigPyIterator *copy() const
+    PySwigIterator *copy() const
     {
       return new self_type(*this);
     }
 
-    SwigPyIterator *incr(size_t n = 1)
+    PySwigIterator *incr(size_t n = 1)
     {
       while (n--) {
 	if (base::current == end) {
@@ -4206,7 +3574,7 @@ namespace swig {
       return this;
     }
 
-    SwigPyIterator *decr(size_t n = 1)
+    PySwigIterator *decr(size_t n = 1)
     {
       while (n--) {
 	if (base::current == begin) {
@@ -4224,42 +3592,41 @@ namespace swig {
   };
 
   template<typename OutIter>
-  inline SwigPyIterator*
+  inline PySwigIterator*
   make_output_iterator(const OutIter& current, const OutIter& begin,const OutIter& end, PyObject *seq = 0)
   {
-    return new SwigPyIteratorClosed_T<OutIter>(current, begin, end, seq);
+    return new PySwigIteratorClosed_T<OutIter>(current, begin, end, seq);
   }
 
   template<typename OutIter>
-  inline SwigPyIterator*
+  inline PySwigIterator*
   make_output_iterator(const OutIter& current, PyObject *seq = 0)
   {
-    return new SwigPyIteratorOpen_T<OutIter>(current, seq);
+    return new PySwigIteratorOpen_T<OutIter>(current, seq);
   }
-
 }
 
 
 namespace swig
 {
   template <class T>
-  struct SwigPySequence_Ref
+  struct PySequence_Ref
   {
-    SwigPySequence_Ref(PyObject* seq, int index)
+    PySequence_Ref(PyObject* seq, int index)
       : _seq(seq), _index(index)
     {
     }
     
     operator T () const
     {
-      swig::SwigVar_PyObject item = PySequence_GetItem(_seq, _index);
+      swig::PyObject_var item = PySequence_GetItem(_seq, _index);
       try {
 	return swig::as<T>(item, true);
       } catch (std::exception& e) {
 	char msg[1024];
 	sprintf(msg, "in sequence element %d ", _index);
 	if (!PyErr_Occurred()) {
-	  ::SWIG_Error(SWIG_TypeError,  swig::type_name<T>());
+	  SWIG_Error(SWIG_TypeError,  swig::type_name<T>());
 	}
 	SWIG_Python_AddErrorMsg(msg);
 	SWIG_Python_AddErrorMsg(e.what());
@@ -4267,7 +3634,7 @@ namespace swig
       }
     }
 
-    SwigPySequence_Ref& operator=(const T& v)
+    PySequence_Ref& operator=(const T& v)
     {
       PySequence_SetItem(_seq, _index, swig::from<T>(v));
       return *this;
@@ -4279,18 +3646,18 @@ namespace swig
   };
 
   template <class T>
-  struct SwigPySequence_ArrowProxy
+  struct PySequence_ArrowProxy
   {
-    SwigPySequence_ArrowProxy(const T& x): m_value(x) {}
+    PySequence_ArrowProxy(const T& x): m_value(x) {}
     const T* operator->() const { return &m_value; }
     operator const T*() const { return &m_value; }
     T m_value;
   };
 
   template <class T, class Reference >
-  struct SwigPySequence_InputIterator
+  struct PySequence_InputIterator
   {
-    typedef SwigPySequence_InputIterator<T, Reference > self;
+    typedef PySequence_InputIterator<T, Reference > self;
 
     typedef std::random_access_iterator_tag iterator_category;
     typedef Reference reference;
@@ -4298,11 +3665,11 @@ namespace swig
     typedef T* pointer;
     typedef int difference_type;
 
-    SwigPySequence_InputIterator()
+    PySequence_InputIterator()
     {
     }
 
-    SwigPySequence_InputIterator(PyObject* seq, int index)
+    PySequence_InputIterator(PyObject* seq, int index)
       : _seq(seq), _index(index)
     {
     }
@@ -4312,9 +3679,9 @@ namespace swig
       return reference(_seq, _index);
     }
 
-    SwigPySequence_ArrowProxy<T>
+    PySequence_ArrowProxy<T>
     operator->() const {
-      return SwigPySequence_ArrowProxy<T>(operator*());
+      return PySequence_ArrowProxy<T>(operator*());
     }
 
     bool operator==(const self& ri) const
@@ -4383,19 +3750,19 @@ namespace swig
   };
 
   template <class T>
-  struct SwigPySequence_Cont
+  struct PySequence_Cont
   {
-    typedef SwigPySequence_Ref<T> reference;
-    typedef const SwigPySequence_Ref<T> const_reference;
+    typedef PySequence_Ref<T> reference;
+    typedef const PySequence_Ref<T> const_reference;
     typedef T value_type;
     typedef T* pointer;
     typedef int difference_type;
     typedef int size_type;
     typedef const pointer const_pointer;
-    typedef SwigPySequence_InputIterator<T, reference> iterator;
-    typedef SwigPySequence_InputIterator<T, const_reference> const_iterator;
+    typedef PySequence_InputIterator<T, reference> iterator;
+    typedef PySequence_InputIterator<T, const_reference> const_iterator;
 
-    SwigPySequence_Cont(PyObject* seq) : _seq(0)
+    PySequence_Cont(PyObject* seq) : _seq(0)
     {
       if (!PySequence_Check(seq)) {
 	throw std::invalid_argument("a sequence is expected");
@@ -4404,14 +3771,14 @@ namespace swig
       Py_INCREF(_seq);
     }
 
-    ~SwigPySequence_Cont()
+    ~PySequence_Cont()
     {
-      Py_XDECREF(_seq);
+      if (_seq) Py_DECREF(_seq);
     }
 
     size_type size() const
     {
-      return static_cast<size_type>(PySequence_Size(_seq));
+      return PySequence_Size(_seq);
     }
 
     bool empty() const
@@ -4453,7 +3820,7 @@ namespace swig
     {
       int s = size();
       for (int i = 0; i < s; ++i) {
-	swig::SwigVar_PyObject item = PySequence_GetItem(_seq, i);
+	swig::PyObject_var item = PySequence_GetItem(_seq, i);
 	if (!swig::check<value_type>(item)) {
 	  if (set_err) {
 	    char msg[1024];
@@ -4474,12 +3841,14 @@ namespace swig
 
 
 #include <limits.h>
-#if !defined(SWIG_NO_LLONG_MAX)
-# if !defined(LLONG_MAX) && defined(__GNUC__) && defined (__LONG_LONG_MAX__)
-#   define LLONG_MAX __LONG_LONG_MAX__
-#   define LLONG_MIN (-LLONG_MAX - 1LL)
-#   define ULLONG_MAX (LLONG_MAX * 2ULL + 1ULL)
-# endif
+#ifndef LLONG_MIN
+# define LLONG_MIN	LONG_LONG_MIN
+#endif
+#ifndef LLONG_MAX
+# define LLONG_MAX	LONG_LONG_MAX
+#endif
+#ifndef ULLONG_MAX
+# define ULLONG_MAX	ULONG_LONG_MAX
 #endif
 
 
@@ -4499,10 +3868,10 @@ SWIG_AsVal_int (PyObject * obj, int *val)
 }
 
 
-SWIGINTERNINLINE PyObject*
-  SWIG_From_int  (int value)
-{
-  return PyInt_FromLong((long) value);
+SWIGINTERNINLINE PyObject *
+SWIG_From_int  (int value)
+{    
+  return SWIG_From_long  (value);
 }
 
 
@@ -4527,15 +3896,18 @@ namespace swig {
 
 
 namespace swig {
-  template <class SwigPySeq, class Seq>
+  template <class PySeq, class Seq>
   inline void
-  assign(const SwigPySeq& swigpyseq, Seq* seq) {
-    // seq->assign(swigpyseq.begin(), swigpyseq.end()); // not used as not always implemented
-    typedef typename SwigPySeq::value_type value_type;
-    typename SwigPySeq::const_iterator it = swigpyseq.begin();
-    for (;it != swigpyseq.end(); ++it) {
+  assign(const PySeq& pyseq, Seq* seq) {
+#ifdef SWIG_STD_NOASSIGN_STL
+    typedef typename PySeq::value_type value_type;
+    typename PySeq::const_iterator it = pyseq.begin();
+    for (;it != pyseq.end(); ++it) {
       seq->insert(seq->end(),(value_type)(*it));
     }
+#else
+    seq->assign(pyseq.begin(), pyseq.end());
+#endif
   }
 
   template <class Seq, class T = typename Seq::value_type >
@@ -4544,23 +3916,16 @@ namespace swig {
     typedef T value_type;
 
     static int asptr(PyObject *obj, sequence **seq) {
-      if (obj == Py_None || SWIG_Python_GetSwigThis(obj)) {
-	sequence *p;
-	if (::SWIG_ConvertPtr(obj,(void**)&p,
-			      swig::type_info<sequence>(),0) == SWIG_OK) {
-	  if (seq) *seq = p;
-	  return SWIG_OLDOBJ;
-	}
-      } else if (PySequence_Check(obj)) {
+      if (PySequence_Check(obj)) {
 	try {
-	  SwigPySequence_Cont<value_type> swigpyseq(obj);
+	  PySequence_Cont<value_type> pyseq(obj);
 	  if (seq) {
 	    sequence *pseq = new sequence();
-	    assign(swigpyseq, pseq);
+	    assign(pyseq, pseq);
 	    *seq = pseq;
 	    return SWIG_NEWOBJ;
 	  } else {
-	    return swigpyseq.check() ? SWIG_OK : SWIG_ERROR;
+	    return pyseq.check() ? SWIG_OK : SWIG_ERROR;
 	  }
 	} catch (std::exception& e) {
 	  if (seq) {
@@ -4570,6 +3935,13 @@ namespace swig {
 	  }
 	  return SWIG_ERROR;
 	}
+      } else {
+	sequence *p;
+	if (SWIG_ConvertPtr(obj,(void**)&p,
+			    swig::type_info<sequence>(),0) == SWIG_OK) {
+	  if (seq) *seq = p;
+	  return SWIG_OLDOBJ;
+	}
       }
       return SWIG_ERROR;
     }
@@ -4583,12 +3955,12 @@ namespace swig {
     typedef typename sequence::const_iterator const_iterator;
 
     static PyObject *from(const sequence& seq) {
-#ifdef SWIG_PYTHON_EXTRA_NATIVE_CONTAINERS
-      swig_type_info *desc = swig::type_info<sequence>();
-      if (desc && desc->clientdata) {
-	return SWIG_NewPointerObj(new sequence(seq), desc, SWIG_POINTER_OWN);
-      }
-#endif
+
+
+
+
+
+
       size_type size = seq.size();
       if (size <= (size_type)INT_MAX) {
 	PyObject *obj = PyTuple_New((int)size);
@@ -4625,24 +3997,21 @@ namespace swig {
 
 
       namespace swig {
-	template <>  struct traits<std::vector<int, std::allocator< int > > > {
+	template <>  struct traits<std::vector<int, std::allocator<int > > > {
 	  typedef pointer_category category;
 	  static const char* type_name() {
-	    return "std::vector<" "int" "," "std::allocator< int >" " >";
+	    return "std::vector<" "int" "," "std::allocator<int >" " >";
 	  }
 	};
       }
     
-SWIGINTERN swig::SwigPyIterator *std_vector_Sl_int_Sg__iterator(std::vector< int > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_vector_Sl_int_Sg__iterator(std::vector<int > *self,PyObject **PYTHON_SELF){
       return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN bool std_vector_Sl_int_Sg____nonzero__(std::vector< int > const *self){
-      return !(self->empty());
-    }
-SWIGINTERN bool std_vector_Sl_int_Sg____bool__(std::vector< int > const *self){
+SWIGINTERN bool std_vector_Sl_int_Sg____nonzero__(std::vector<int > const *self){
       return !(self->empty());
     }
-SWIGINTERN std::vector< int >::size_type std_vector_Sl_int_Sg____len__(std::vector< int > const *self){
+SWIGINTERN std::vector<int >::size_type std_vector_Sl_int_Sg____len__(std::vector<int > const *self){
       return self->size();
     }
 
@@ -4650,7 +4019,7 @@ SWIGINTERNINLINE PyObject*
 SWIG_From_unsigned_SS_long  (unsigned long value)
 {
   return (value > LONG_MAX) ?
-    PyLong_FromUnsignedLong(value) : PyLong_FromLong(static_cast< long >(value)); 
+    PyLong_FromUnsignedLong(value) : PyInt_FromLong(static_cast< long >(value)); 
 }
 
 
@@ -4660,82 +4029,34 @@ SWIG_From_size_t  (size_t value)
   return SWIG_From_unsigned_SS_long  (static_cast< unsigned long >(value));
 }
 
-SWIGINTERN std::vector< int >::value_type std_vector_Sl_int_Sg__pop(std::vector< int > *self){
+SWIGINTERN std::vector<int >::value_type std_vector_Sl_int_Sg__pop(std::vector<int > *self){
       if (self->size() == 0)
 	throw std::out_of_range("pop from empty container");
-      std::vector<int,std::allocator< int > >::value_type x = self->back();
+      std::vector<int,std::allocator<int > >::value_type x = self->back();
       self->pop_back();
       return x;
     }
-SWIGINTERN std::vector< int,std::allocator< int > > *std_vector_Sl_int_Sg____getslice__(std::vector< int > *self,std::vector< int >::difference_type i,std::vector< int >::difference_type j){
-      return swig::getslice(self, i, j, 1);
+SWIGINTERN std::vector<int,std::allocator<int > > *std_vector_Sl_int_Sg____getslice__(std::vector<int > *self,std::vector<int >::difference_type i,std::vector<int >::difference_type j){
+      return swig::getslice(self, i, j);
     }
-SWIGINTERN void std_vector_Sl_int_Sg____setslice____SWIG_0(std::vector< int > *self,std::vector< int >::difference_type i,std::vector< int >::difference_type j,std::vector< int,std::allocator< int > > const &v=std::vector< int,std::allocator< int > >()){
-      swig::setslice(self, i, j, 1, v);
+SWIGINTERN void std_vector_Sl_int_Sg____setslice__(std::vector<int > *self,std::vector<int >::difference_type i,std::vector<int >::difference_type j,std::vector<int,std::allocator<int > > const &v){
+      swig::setslice(self, i, j, v);
     }
-SWIGINTERN void std_vector_Sl_int_Sg____delslice__(std::vector< int > *self,std::vector< int >::difference_type i,std::vector< int >::difference_type j){
-      swig::delslice(self, i, j, 1);
+SWIGINTERN void std_vector_Sl_int_Sg____delslice__(std::vector<int > *self,std::vector<int >::difference_type i,std::vector<int >::difference_type j){
+      swig::delslice(self, i, j);
     }
-SWIGINTERN void std_vector_Sl_int_Sg____delitem____SWIG_0(std::vector< int > *self,std::vector< int >::difference_type i){
+SWIGINTERN void std_vector_Sl_int_Sg____delitem__(std::vector<int > *self,std::vector<int >::difference_type i){
       self->erase(swig::getpos(self,i));
     }
-SWIGINTERN std::vector< int,std::allocator< int > > *std_vector_Sl_int_Sg____getitem____SWIG_0(std::vector< int > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return NULL;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<int,std::allocator< int > >::difference_type id = i;
-      std::vector<int,std::allocator< int > >::difference_type jd = j;
-      return swig::getslice(self, id, jd, step);
-    }
-SWIGINTERN void std_vector_Sl_int_Sg____setitem____SWIG_0(std::vector< int > *self,PySliceObject *slice,std::vector< int,std::allocator< int > > const &v){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<int,std::allocator< int > >::difference_type id = i;
-      std::vector<int,std::allocator< int > >::difference_type jd = j;
-      swig::setslice(self, id, jd, step, v);
-    }
-SWIGINTERN void std_vector_Sl_int_Sg____setitem____SWIG_1(std::vector< int > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<int,std::allocator< int > >::difference_type id = i;
-      std::vector<int,std::allocator< int > >::difference_type jd = j;
-      swig::delslice(self, id, jd, step);
-    }
-SWIGINTERN void std_vector_Sl_int_Sg____delitem____SWIG_1(std::vector< int > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<int,std::allocator< int > >::difference_type id = i;
-      std::vector<int,std::allocator< int > >::difference_type jd = j;
-      swig::delslice(self, id, jd, step);
-    }
-SWIGINTERN std::vector< int >::value_type const &std_vector_Sl_int_Sg____getitem____SWIG_1(std::vector< int > const *self,std::vector< int >::difference_type i){
+SWIGINTERN std::vector<int >::value_type const &std_vector_Sl_int_Sg____getitem__(std::vector<int > const *self,std::vector<int >::difference_type i){
       return *(swig::cgetpos(self, i));
     }
-SWIGINTERN void std_vector_Sl_int_Sg____setitem____SWIG_2(std::vector< int > *self,std::vector< int >::difference_type i,std::vector< int >::value_type const &x){
+SWIGINTERN void std_vector_Sl_int_Sg____setitem__(std::vector<int > *self,std::vector<int >::difference_type i,std::vector<int >::value_type const &x){
       *(swig::getpos(self,i)) = x;
     }
-SWIGINTERN void std_vector_Sl_int_Sg__append(std::vector< int > *self,std::vector< int >::value_type const &x){
+SWIGINTERN void std_vector_Sl_int_Sg__append(std::vector<int > *self,std::vector<int >::value_type const &x){
       self->push_back(x);
     }
-SWIGINTERN std::vector< int >::iterator std_vector_Sl_int_Sg__erase__SWIG_0(std::vector< int > *self,std::vector< int >::iterator pos){ return self->erase(pos); }
-SWIGINTERN std::vector< int >::iterator std_vector_Sl_int_Sg__erase__SWIG_1(std::vector< int > *self,std::vector< int >::iterator first,std::vector< int >::iterator last){ return self->erase(first, last); }
-SWIGINTERN std::vector< int >::iterator std_vector_Sl_int_Sg__insert__SWIG_0(std::vector< int > *self,std::vector< int >::iterator pos,std::vector< int >::value_type const &x){ return self->insert(pos, x); }
-SWIGINTERN void std_vector_Sl_int_Sg__insert__SWIG_1(std::vector< int > *self,std::vector< int >::iterator pos,std::vector< int >::size_type n,std::vector< int >::value_type const &x){ self->insert(pos, n, x); }
 
   #define SWIG_From_double   PyFloat_FromDouble 
 
@@ -4761,200 +4082,98 @@ namespace swig {
 
 
       namespace swig {
-	template <>  struct traits<std::vector<double, std::allocator< double > > > {
+	template <>  struct traits<std::vector<double, std::allocator<double > > > {
 	  typedef pointer_category category;
 	  static const char* type_name() {
-	    return "std::vector<" "double" "," "std::allocator< double >" " >";
+	    return "std::vector<" "double" "," "std::allocator<double >" " >";
 	  }
 	};
       }
     
-SWIGINTERN swig::SwigPyIterator *std_vector_Sl_double_Sg__iterator(std::vector< double > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_vector_Sl_double_Sg__iterator(std::vector<double > *self,PyObject **PYTHON_SELF){
       return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN bool std_vector_Sl_double_Sg____nonzero__(std::vector< double > const *self){
-      return !(self->empty());
-    }
-SWIGINTERN bool std_vector_Sl_double_Sg____bool__(std::vector< double > const *self){
+SWIGINTERN bool std_vector_Sl_double_Sg____nonzero__(std::vector<double > const *self){
       return !(self->empty());
     }
-SWIGINTERN std::vector< double >::size_type std_vector_Sl_double_Sg____len__(std::vector< double > const *self){
+SWIGINTERN std::vector<double >::size_type std_vector_Sl_double_Sg____len__(std::vector<double > const *self){
       return self->size();
     }
-SWIGINTERN std::vector< double >::value_type std_vector_Sl_double_Sg__pop(std::vector< double > *self){
+SWIGINTERN std::vector<double >::value_type std_vector_Sl_double_Sg__pop(std::vector<double > *self){
       if (self->size() == 0)
 	throw std::out_of_range("pop from empty container");
-      std::vector<double,std::allocator< double > >::value_type x = self->back();
+      std::vector<double,std::allocator<double > >::value_type x = self->back();
       self->pop_back();
       return x;
     }
-SWIGINTERN std::vector< double,std::allocator< double > > *std_vector_Sl_double_Sg____getslice__(std::vector< double > *self,std::vector< double >::difference_type i,std::vector< double >::difference_type j){
-      return swig::getslice(self, i, j, 1);
+SWIGINTERN std::vector<double,std::allocator<double > > *std_vector_Sl_double_Sg____getslice__(std::vector<double > *self,std::vector<double >::difference_type i,std::vector<double >::difference_type j){
+      return swig::getslice(self, i, j);
     }
-SWIGINTERN void std_vector_Sl_double_Sg____setslice____SWIG_0(std::vector< double > *self,std::vector< double >::difference_type i,std::vector< double >::difference_type j,std::vector< double,std::allocator< double > > const &v=std::vector< double,std::allocator< double > >()){
-      swig::setslice(self, i, j, 1, v);
+SWIGINTERN void std_vector_Sl_double_Sg____setslice__(std::vector<double > *self,std::vector<double >::difference_type i,std::vector<double >::difference_type j,std::vector<double,std::allocator<double > > const &v){
+      swig::setslice(self, i, j, v);
     }
-SWIGINTERN void std_vector_Sl_double_Sg____delslice__(std::vector< double > *self,std::vector< double >::difference_type i,std::vector< double >::difference_type j){
-      swig::delslice(self, i, j, 1);
+SWIGINTERN void std_vector_Sl_double_Sg____delslice__(std::vector<double > *self,std::vector<double >::difference_type i,std::vector<double >::difference_type j){
+      swig::delslice(self, i, j);
     }
-SWIGINTERN void std_vector_Sl_double_Sg____delitem____SWIG_0(std::vector< double > *self,std::vector< double >::difference_type i){
+SWIGINTERN void std_vector_Sl_double_Sg____delitem__(std::vector<double > *self,std::vector<double >::difference_type i){
       self->erase(swig::getpos(self,i));
     }
-SWIGINTERN std::vector< double,std::allocator< double > > *std_vector_Sl_double_Sg____getitem____SWIG_0(std::vector< double > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return NULL;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<double,std::allocator< double > >::difference_type id = i;
-      std::vector<double,std::allocator< double > >::difference_type jd = j;
-      return swig::getslice(self, id, jd, step);
-    }
-SWIGINTERN void std_vector_Sl_double_Sg____setitem____SWIG_0(std::vector< double > *self,PySliceObject *slice,std::vector< double,std::allocator< double > > const &v){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<double,std::allocator< double > >::difference_type id = i;
-      std::vector<double,std::allocator< double > >::difference_type jd = j;
-      swig::setslice(self, id, jd, step, v);
-    }
-SWIGINTERN void std_vector_Sl_double_Sg____setitem____SWIG_1(std::vector< double > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<double,std::allocator< double > >::difference_type id = i;
-      std::vector<double,std::allocator< double > >::difference_type jd = j;
-      swig::delslice(self, id, jd, step);
-    }
-SWIGINTERN void std_vector_Sl_double_Sg____delitem____SWIG_1(std::vector< double > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<double,std::allocator< double > >::difference_type id = i;
-      std::vector<double,std::allocator< double > >::difference_type jd = j;
-      swig::delslice(self, id, jd, step);
-    }
-SWIGINTERN std::vector< double >::value_type const &std_vector_Sl_double_Sg____getitem____SWIG_1(std::vector< double > const *self,std::vector< double >::difference_type i){
+SWIGINTERN std::vector<double >::value_type const &std_vector_Sl_double_Sg____getitem__(std::vector<double > const *self,std::vector<double >::difference_type i){
       return *(swig::cgetpos(self, i));
     }
-SWIGINTERN void std_vector_Sl_double_Sg____setitem____SWIG_2(std::vector< double > *self,std::vector< double >::difference_type i,std::vector< double >::value_type const &x){
+SWIGINTERN void std_vector_Sl_double_Sg____setitem__(std::vector<double > *self,std::vector<double >::difference_type i,std::vector<double >::value_type const &x){
       *(swig::getpos(self,i)) = x;
     }
-SWIGINTERN void std_vector_Sl_double_Sg__append(std::vector< double > *self,std::vector< double >::value_type const &x){
+SWIGINTERN void std_vector_Sl_double_Sg__append(std::vector<double > *self,std::vector<double >::value_type const &x){
       self->push_back(x);
     }
-SWIGINTERN std::vector< double >::iterator std_vector_Sl_double_Sg__erase__SWIG_0(std::vector< double > *self,std::vector< double >::iterator pos){ return self->erase(pos); }
-SWIGINTERN std::vector< double >::iterator std_vector_Sl_double_Sg__erase__SWIG_1(std::vector< double > *self,std::vector< double >::iterator first,std::vector< double >::iterator last){ return self->erase(first, last); }
-SWIGINTERN std::vector< double >::iterator std_vector_Sl_double_Sg__insert__SWIG_0(std::vector< double > *self,std::vector< double >::iterator pos,std::vector< double >::value_type const &x){ return self->insert(pos, x); }
-SWIGINTERN void std_vector_Sl_double_Sg__insert__SWIG_1(std::vector< double > *self,std::vector< double >::iterator pos,std::vector< double >::size_type n,std::vector< double >::value_type const &x){ self->insert(pos, n, x); }
 
       namespace swig {
-	template <>  struct traits<std::vector<std::vector< double,std::allocator< double > >, std::allocator< std::vector< double,std::allocator< double > > > > > {
+	template <>  struct traits<std::vector<std::vector<double,std::allocator<double > >, std::allocator<std::vector<double,std::allocator<double > > > > > {
 	  typedef pointer_category category;
 	  static const char* type_name() {
-	    return "std::vector<" "std::vector< double,std::allocator< double > >" "," "std::allocator< std::vector< double,std::allocator< double > > >" " >";
+	    return "std::vector<" "std::vector<double,std::allocator<double > >" "," "std::allocator<std::vector<double,std::allocator<double > > >" " >";
 	  }
 	};
       }
     
-SWIGINTERN swig::SwigPyIterator *std_vector_Sl_std_vector_Sl_double_Sg__Sg__iterator(std::vector< std::vector< double > > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_vector_Sl_std_vector_Sl_double_Sg__Sg__iterator(std::vector<std::vector<double > > *self,PyObject **PYTHON_SELF){
       return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN bool std_vector_Sl_std_vector_Sl_double_Sg__Sg____nonzero__(std::vector< std::vector< double > > const *self){
-      return !(self->empty());
-    }
-SWIGINTERN bool std_vector_Sl_std_vector_Sl_double_Sg__Sg____bool__(std::vector< std::vector< double > > const *self){
+SWIGINTERN bool std_vector_Sl_std_vector_Sl_double_Sg__Sg____nonzero__(std::vector<std::vector<double > > const *self){
       return !(self->empty());
     }
-SWIGINTERN std::vector< std::vector< double > >::size_type std_vector_Sl_std_vector_Sl_double_Sg__Sg____len__(std::vector< std::vector< double > > const *self){
+SWIGINTERN std::vector<std::vector<double > >::size_type std_vector_Sl_std_vector_Sl_double_Sg__Sg____len__(std::vector<std::vector<double > > const *self){
       return self->size();
     }
-SWIGINTERN std::vector< std::vector< double > >::value_type std_vector_Sl_std_vector_Sl_double_Sg__Sg__pop(std::vector< std::vector< double > > *self){
+SWIGINTERN std::vector<std::vector<double > >::value_type std_vector_Sl_std_vector_Sl_double_Sg__Sg__pop(std::vector<std::vector<double > > *self){
       if (self->size() == 0)
 	throw std::out_of_range("pop from empty container");
-      std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >::value_type x = self->back();
+      std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >::value_type x = self->back();
       self->pop_back();
       return x;
     }
-SWIGINTERN std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *std_vector_Sl_std_vector_Sl_double_Sg__Sg____getslice__(std::vector< std::vector< double > > *self,std::vector< std::vector< double > >::difference_type i,std::vector< std::vector< double > >::difference_type j){
-      return swig::getslice(self, i, j, 1);
+SWIGINTERN std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > *std_vector_Sl_std_vector_Sl_double_Sg__Sg____getslice__(std::vector<std::vector<double > > *self,std::vector<std::vector<double > >::difference_type i,std::vector<std::vector<double > >::difference_type j){
+      return swig::getslice(self, i, j);
     }
-SWIGINTERN void std_vector_Sl_std_vector_Sl_double_Sg__Sg____setslice____SWIG_0(std::vector< std::vector< double > > *self,std::vector< std::vector< double > >::difference_type i,std::vector< std::vector< double > >::difference_type j,std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > const &v=std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double >  [...]
-      swig::setslice(self, i, j, 1, v);
+SWIGINTERN void std_vector_Sl_std_vector_Sl_double_Sg__Sg____setslice__(std::vector<std::vector<double > > *self,std::vector<std::vector<double > >::difference_type i,std::vector<std::vector<double > >::difference_type j,std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > const &v){
+      swig::setslice(self, i, j, v);
     }
-SWIGINTERN void std_vector_Sl_std_vector_Sl_double_Sg__Sg____delslice__(std::vector< std::vector< double > > *self,std::vector< std::vector< double > >::difference_type i,std::vector< std::vector< double > >::difference_type j){
-      swig::delslice(self, i, j, 1);
+SWIGINTERN void std_vector_Sl_std_vector_Sl_double_Sg__Sg____delslice__(std::vector<std::vector<double > > *self,std::vector<std::vector<double > >::difference_type i,std::vector<std::vector<double > >::difference_type j){
+      swig::delslice(self, i, j);
     }
-SWIGINTERN void std_vector_Sl_std_vector_Sl_double_Sg__Sg____delitem____SWIG_0(std::vector< std::vector< double > > *self,std::vector< std::vector< double > >::difference_type i){
+SWIGINTERN void std_vector_Sl_std_vector_Sl_double_Sg__Sg____delitem__(std::vector<std::vector<double > > *self,std::vector<std::vector<double > >::difference_type i){
       self->erase(swig::getpos(self,i));
     }
-SWIGINTERN std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *std_vector_Sl_std_vector_Sl_double_Sg__Sg____getitem____SWIG_0(std::vector< std::vector< double > > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return NULL;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >::difference_type id = i;
-      std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >::difference_type jd = j;
-      return swig::getslice(self, id, jd, step);
-    }
-SWIGINTERN void std_vector_Sl_std_vector_Sl_double_Sg__Sg____setitem____SWIG_0(std::vector< std::vector< double > > *self,PySliceObject *slice,std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > const &v){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >::difference_type id = i;
-      std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >::difference_type jd = j;
-      swig::setslice(self, id, jd, step, v);
-    }
-SWIGINTERN void std_vector_Sl_std_vector_Sl_double_Sg__Sg____setitem____SWIG_1(std::vector< std::vector< double > > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >::difference_type id = i;
-      std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >::difference_type jd = j;
-      swig::delslice(self, id, jd, step);
-    }
-SWIGINTERN void std_vector_Sl_std_vector_Sl_double_Sg__Sg____delitem____SWIG_1(std::vector< std::vector< double > > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >::difference_type id = i;
-      std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >::difference_type jd = j;
-      swig::delslice(self, id, jd, step);
-    }
-SWIGINTERN std::vector< std::vector< double > >::value_type const &std_vector_Sl_std_vector_Sl_double_Sg__Sg____getitem____SWIG_1(std::vector< std::vector< double > > const *self,std::vector< std::vector< double > >::difference_type i){
+SWIGINTERN std::vector<std::vector<double > >::value_type const &std_vector_Sl_std_vector_Sl_double_Sg__Sg____getitem__(std::vector<std::vector<double > > const *self,std::vector<std::vector<double > >::difference_type i){
       return *(swig::cgetpos(self, i));
     }
-SWIGINTERN void std_vector_Sl_std_vector_Sl_double_Sg__Sg____setitem____SWIG_2(std::vector< std::vector< double > > *self,std::vector< std::vector< double > >::difference_type i,std::vector< std::vector< double > >::value_type const &x){
+SWIGINTERN void std_vector_Sl_std_vector_Sl_double_Sg__Sg____setitem__(std::vector<std::vector<double > > *self,std::vector<std::vector<double > >::difference_type i,std::vector<std::vector<double > >::value_type const &x){
       *(swig::getpos(self,i)) = x;
     }
-SWIGINTERN void std_vector_Sl_std_vector_Sl_double_Sg__Sg__append(std::vector< std::vector< double > > *self,std::vector< std::vector< double > >::value_type const &x){
+SWIGINTERN void std_vector_Sl_std_vector_Sl_double_Sg__Sg__append(std::vector<std::vector<double > > *self,std::vector<std::vector<double > >::value_type const &x){
       self->push_back(x);
     }
-SWIGINTERN std::vector< std::vector< double > >::iterator std_vector_Sl_std_vector_Sl_double_Sg__Sg__erase__SWIG_0(std::vector< std::vector< double > > *self,std::vector< std::vector< double > >::iterator pos){ return self->erase(pos); }
-SWIGINTERN std::vector< std::vector< double > >::iterator std_vector_Sl_std_vector_Sl_double_Sg__Sg__erase__SWIG_1(std::vector< std::vector< double > > *self,std::vector< std::vector< double > >::iterator first,std::vector< std::vector< double > >::iterator last){ return self->erase(first, last); }
-SWIGINTERN std::vector< std::vector< double > >::iterator std_vector_Sl_std_vector_Sl_double_Sg__Sg__insert__SWIG_0(std::vector< std::vector< double > > *self,std::vector< std::vector< double > >::iterator pos,std::vector< std::vector< double > >::value_type const &x){ return self->insert(pos, x); }
-SWIGINTERN void std_vector_Sl_std_vector_Sl_double_Sg__Sg__insert__SWIG_1(std::vector< std::vector< double > > *self,std::vector< std::vector< double > >::iterator pos,std::vector< std::vector< double > >::size_type n,std::vector< std::vector< double > >::value_type const &x){ self->insert(pos, n, x); }
 
 SWIGINTERN swig_type_info*
 SWIG_pchar_descriptor(void)
@@ -4972,28 +4191,10 @@ SWIG_pchar_descriptor(void)
 SWIGINTERN int
 SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
 {
-#if PY_VERSION_HEX>=0x03000000
-  if (PyUnicode_Check(obj))
-#else  
-  if (PyString_Check(obj))
-#endif
-  {
+  if (PyString_Check(obj)) {
     char *cstr; Py_ssize_t len;
-#if PY_VERSION_HEX>=0x03000000
-    if (!alloc && cptr) {
-        /* We can't allow converting without allocation, since the internal
-           representation of string in Python 3 is UCS-2/UCS-4 but we require
-           a UTF-8 representation.
-           TODO(bhy) More detailed explanation */
-        return SWIG_RuntimeError;
-    }
-    obj = PyUnicode_AsUTF8String(obj);
-    PyBytes_AsStringAndSize(obj, &cstr, &len);
-    if(alloc) *alloc = SWIG_NEWOBJ;
-#else
     PyString_AsStringAndSize(obj, &cstr, &len);
-#endif
-    if (cptr) {
+    if (cptr)  {
       if (alloc) {
 	/* 
 	   In python the user should not be able to modify the inner
@@ -5018,16 +4219,10 @@ SWIG_AsCharPtrAndSize(PyObject *obj, char** cptr, size_t* psize, int *alloc)
 	  *alloc = SWIG_OLDOBJ;
 	}
       } else {
-        #if PY_VERSION_HEX>=0x03000000
-        assert(0); /* Should never reach here in Python 3 */
-        #endif
-	*cptr = SWIG_Python_str_AsChar(obj);
+	*cptr = PyString_AsString(obj);
       }
     }
     if (psize) *psize = len + 1;
-#if PY_VERSION_HEX>=0x03000000
-    Py_XDECREF(obj);
-#endif
     return SWIG_OK;
   } else {
     swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
@@ -5101,17 +4296,9 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
     if (size > INT_MAX) {
       swig_type_info* pchar_descriptor = SWIG_pchar_descriptor();
       return pchar_descriptor ? 
-	SWIG_InternalNewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void();
+	SWIG_NewPointerObj(const_cast< char * >(carray), pchar_descriptor, 0) : SWIG_Py_Void();
     } else {
-#if PY_VERSION_HEX >= 0x03000000
-#if PY_VERSION_HEX >= 0x03010000
-      return PyUnicode_DecodeUTF8(carray, static_cast< int >(size), "surrogateescape");
-#else
-      return PyUnicode_FromStringAndSize(carray, static_cast< int >(size));
-#endif
-#else
       return PyString_FromStringAndSize(carray, static_cast< int >(size));
-#endif
     }
   } else {
     return SWIG_Py_Void();
@@ -5122,7 +4309,11 @@ SWIG_FromCharPtrAndSize(const char* carray, size_t size)
 SWIGINTERNINLINE PyObject *
 SWIG_From_std_string  (const std::string& s)
 {
-  return SWIG_FromCharPtrAndSize(s.data(), s.size());
+  if (s.size()) {
+    return SWIG_FromCharPtrAndSize(s.data(), s.size());
+  } else {
+    return SWIG_FromCharPtrAndSize(s.c_str(), 0);
+  }
 }
 
 
@@ -5147,102 +4338,51 @@ namespace swig {
 
 
       namespace swig {
-	template <>  struct traits<std::vector<std::string, std::allocator< std::string > > > {
+	template <>  struct traits<std::vector<std::string, std::allocator<std::string > > > {
 	  typedef pointer_category category;
 	  static const char* type_name() {
-	    return "std::vector<" "std::string" "," "std::allocator< std::string >" " >";
+	    return "std::vector<" "std::string" "," "std::allocator<std::string >" " >";
 	  }
 	};
       }
     
-SWIGINTERN swig::SwigPyIterator *std_vector_Sl_std_string_Sg__iterator(std::vector< std::string > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_vector_Sl_std_string_Sg__iterator(std::vector<std::string > *self,PyObject **PYTHON_SELF){
       return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN bool std_vector_Sl_std_string_Sg____nonzero__(std::vector< std::string > const *self){
-      return !(self->empty());
-    }
-SWIGINTERN bool std_vector_Sl_std_string_Sg____bool__(std::vector< std::string > const *self){
+SWIGINTERN bool std_vector_Sl_std_string_Sg____nonzero__(std::vector<std::string > const *self){
       return !(self->empty());
     }
-SWIGINTERN std::vector< std::string >::size_type std_vector_Sl_std_string_Sg____len__(std::vector< std::string > const *self){
+SWIGINTERN std::vector<std::string >::size_type std_vector_Sl_std_string_Sg____len__(std::vector<std::string > const *self){
       return self->size();
     }
-SWIGINTERN std::vector< std::string >::value_type std_vector_Sl_std_string_Sg__pop(std::vector< std::string > *self){
+SWIGINTERN std::vector<std::string >::value_type std_vector_Sl_std_string_Sg__pop(std::vector<std::string > *self){
       if (self->size() == 0)
 	throw std::out_of_range("pop from empty container");
-      std::vector<std::string,std::allocator< std::string > >::value_type x = self->back();
+      std::vector<std::string,std::allocator<std::string > >::value_type x = self->back();
       self->pop_back();
       return x;
     }
-SWIGINTERN std::vector< std::string,std::allocator< std::string > > *std_vector_Sl_std_string_Sg____getslice__(std::vector< std::string > *self,std::vector< std::string >::difference_type i,std::vector< std::string >::difference_type j){
-      return swig::getslice(self, i, j, 1);
+SWIGINTERN std::vector<std::string,std::allocator<std::string > > *std_vector_Sl_std_string_Sg____getslice__(std::vector<std::string > *self,std::vector<std::string >::difference_type i,std::vector<std::string >::difference_type j){
+      return swig::getslice(self, i, j);
     }
-SWIGINTERN void std_vector_Sl_std_string_Sg____setslice____SWIG_0(std::vector< std::string > *self,std::vector< std::string >::difference_type i,std::vector< std::string >::difference_type j,std::vector< std::string,std::allocator< std::string > > const &v=std::vector< std::string,std::allocator< std::string > >()){
-      swig::setslice(self, i, j, 1, v);
+SWIGINTERN void std_vector_Sl_std_string_Sg____setslice__(std::vector<std::string > *self,std::vector<std::string >::difference_type i,std::vector<std::string >::difference_type j,std::vector<std::string,std::allocator<std::string > > const &v){
+      swig::setslice(self, i, j, v);
     }
-SWIGINTERN void std_vector_Sl_std_string_Sg____delslice__(std::vector< std::string > *self,std::vector< std::string >::difference_type i,std::vector< std::string >::difference_type j){
-      swig::delslice(self, i, j, 1);
+SWIGINTERN void std_vector_Sl_std_string_Sg____delslice__(std::vector<std::string > *self,std::vector<std::string >::difference_type i,std::vector<std::string >::difference_type j){
+      swig::delslice(self, i, j);
     }
-SWIGINTERN void std_vector_Sl_std_string_Sg____delitem____SWIG_0(std::vector< std::string > *self,std::vector< std::string >::difference_type i){
+SWIGINTERN void std_vector_Sl_std_string_Sg____delitem__(std::vector<std::string > *self,std::vector<std::string >::difference_type i){
       self->erase(swig::getpos(self,i));
     }
-SWIGINTERN std::vector< std::string,std::allocator< std::string > > *std_vector_Sl_std_string_Sg____getitem____SWIG_0(std::vector< std::string > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return NULL;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<std::string,std::allocator< std::string > >::difference_type id = i;
-      std::vector<std::string,std::allocator< std::string > >::difference_type jd = j;
-      return swig::getslice(self, id, jd, step);
-    }
-SWIGINTERN void std_vector_Sl_std_string_Sg____setitem____SWIG_0(std::vector< std::string > *self,PySliceObject *slice,std::vector< std::string,std::allocator< std::string > > const &v){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<std::string,std::allocator< std::string > >::difference_type id = i;
-      std::vector<std::string,std::allocator< std::string > >::difference_type jd = j;
-      swig::setslice(self, id, jd, step, v);
-    }
-SWIGINTERN void std_vector_Sl_std_string_Sg____setitem____SWIG_1(std::vector< std::string > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<std::string,std::allocator< std::string > >::difference_type id = i;
-      std::vector<std::string,std::allocator< std::string > >::difference_type jd = j;
-      swig::delslice(self, id, jd, step);
-    }
-SWIGINTERN void std_vector_Sl_std_string_Sg____delitem____SWIG_1(std::vector< std::string > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<std::string,std::allocator< std::string > >::difference_type id = i;
-      std::vector<std::string,std::allocator< std::string > >::difference_type jd = j;
-      swig::delslice(self, id, jd, step);
-    }
-SWIGINTERN std::vector< std::string >::value_type const &std_vector_Sl_std_string_Sg____getitem____SWIG_1(std::vector< std::string > const *self,std::vector< std::string >::difference_type i){
+SWIGINTERN std::vector<std::string >::value_type const &std_vector_Sl_std_string_Sg____getitem__(std::vector<std::string > const *self,std::vector<std::string >::difference_type i){
       return *(swig::cgetpos(self, i));
     }
-SWIGINTERN void std_vector_Sl_std_string_Sg____setitem____SWIG_2(std::vector< std::string > *self,std::vector< std::string >::difference_type i,std::vector< std::string >::value_type const &x){
+SWIGINTERN void std_vector_Sl_std_string_Sg____setitem__(std::vector<std::string > *self,std::vector<std::string >::difference_type i,std::vector<std::string >::value_type const &x){
       *(swig::getpos(self,i)) = x;
     }
-SWIGINTERN void std_vector_Sl_std_string_Sg__append(std::vector< std::string > *self,std::vector< std::string >::value_type const &x){
+SWIGINTERN void std_vector_Sl_std_string_Sg__append(std::vector<std::string > *self,std::vector<std::string >::value_type const &x){
       self->push_back(x);
     }
-SWIGINTERN std::vector< std::string >::iterator std_vector_Sl_std_string_Sg__erase__SWIG_0(std::vector< std::string > *self,std::vector< std::string >::iterator pos){ return self->erase(pos); }
-SWIGINTERN std::vector< std::string >::iterator std_vector_Sl_std_string_Sg__erase__SWIG_1(std::vector< std::string > *self,std::vector< std::string >::iterator first,std::vector< std::string >::iterator last){ return self->erase(first, last); }
-SWIGINTERN std::vector< std::string >::iterator std_vector_Sl_std_string_Sg__insert__SWIG_0(std::vector< std::string > *self,std::vector< std::string >::iterator pos,std::vector< std::string >::value_type const &x){ return self->insert(pos, x); }
-SWIGINTERN void std_vector_Sl_std_string_Sg__insert__SWIG_1(std::vector< std::string > *self,std::vector< std::string >::iterator pos,std::vector< std::string >::size_type n,std::vector< std::string >::value_type const &x){ self->insert(pos, n, x); }
 
   namespace swig {
     template <>  struct traits<CdiVariable > {
@@ -5253,102 +4393,51 @@ SWIGINTERN void std_vector_Sl_std_string_Sg__insert__SWIG_1(std::vector< std::st
 
 
       namespace swig {
-	template <>  struct traits<std::vector<CdiVariable, std::allocator< CdiVariable > > > {
+	template <>  struct traits<std::vector<CdiVariable, std::allocator<CdiVariable > > > {
 	  typedef pointer_category category;
 	  static const char* type_name() {
-	    return "std::vector<" "CdiVariable" "," "std::allocator< CdiVariable >" " >";
+	    return "std::vector<" "CdiVariable" "," "std::allocator<CdiVariable >" " >";
 	  }
 	};
       }
     
-SWIGINTERN swig::SwigPyIterator *std_vector_Sl_CdiVariable_Sg__iterator(std::vector< CdiVariable > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_vector_Sl_CdiVariable_Sg__iterator(std::vector<CdiVariable > *self,PyObject **PYTHON_SELF){
       return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN bool std_vector_Sl_CdiVariable_Sg____nonzero__(std::vector< CdiVariable > const *self){
-      return !(self->empty());
-    }
-SWIGINTERN bool std_vector_Sl_CdiVariable_Sg____bool__(std::vector< CdiVariable > const *self){
+SWIGINTERN bool std_vector_Sl_CdiVariable_Sg____nonzero__(std::vector<CdiVariable > const *self){
       return !(self->empty());
     }
-SWIGINTERN std::vector< CdiVariable >::size_type std_vector_Sl_CdiVariable_Sg____len__(std::vector< CdiVariable > const *self){
+SWIGINTERN std::vector<CdiVariable >::size_type std_vector_Sl_CdiVariable_Sg____len__(std::vector<CdiVariable > const *self){
       return self->size();
     }
-SWIGINTERN std::vector< CdiVariable >::value_type std_vector_Sl_CdiVariable_Sg__pop(std::vector< CdiVariable > *self){
+SWIGINTERN std::vector<CdiVariable >::value_type std_vector_Sl_CdiVariable_Sg__pop(std::vector<CdiVariable > *self){
       if (self->size() == 0)
 	throw std::out_of_range("pop from empty container");
-      std::vector<CdiVariable,std::allocator< CdiVariable > >::value_type x = self->back();
+      std::vector<CdiVariable,std::allocator<CdiVariable > >::value_type x = self->back();
       self->pop_back();
       return x;
     }
-SWIGINTERN std::vector< CdiVariable,std::allocator< CdiVariable > > *std_vector_Sl_CdiVariable_Sg____getslice__(std::vector< CdiVariable > *self,std::vector< CdiVariable >::difference_type i,std::vector< CdiVariable >::difference_type j){
-      return swig::getslice(self, i, j, 1);
+SWIGINTERN std::vector<CdiVariable,std::allocator<CdiVariable > > *std_vector_Sl_CdiVariable_Sg____getslice__(std::vector<CdiVariable > *self,std::vector<CdiVariable >::difference_type i,std::vector<CdiVariable >::difference_type j){
+      return swig::getslice(self, i, j);
     }
-SWIGINTERN void std_vector_Sl_CdiVariable_Sg____setslice____SWIG_0(std::vector< CdiVariable > *self,std::vector< CdiVariable >::difference_type i,std::vector< CdiVariable >::difference_type j,std::vector< CdiVariable,std::allocator< CdiVariable > > const &v=std::vector< CdiVariable,std::allocator< CdiVariable > >()){
-      swig::setslice(self, i, j, 1, v);
+SWIGINTERN void std_vector_Sl_CdiVariable_Sg____setslice__(std::vector<CdiVariable > *self,std::vector<CdiVariable >::difference_type i,std::vector<CdiVariable >::difference_type j,std::vector<CdiVariable,std::allocator<CdiVariable > > const &v){
+      swig::setslice(self, i, j, v);
     }
-SWIGINTERN void std_vector_Sl_CdiVariable_Sg____delslice__(std::vector< CdiVariable > *self,std::vector< CdiVariable >::difference_type i,std::vector< CdiVariable >::difference_type j){
-      swig::delslice(self, i, j, 1);
+SWIGINTERN void std_vector_Sl_CdiVariable_Sg____delslice__(std::vector<CdiVariable > *self,std::vector<CdiVariable >::difference_type i,std::vector<CdiVariable >::difference_type j){
+      swig::delslice(self, i, j);
     }
-SWIGINTERN void std_vector_Sl_CdiVariable_Sg____delitem____SWIG_0(std::vector< CdiVariable > *self,std::vector< CdiVariable >::difference_type i){
+SWIGINTERN void std_vector_Sl_CdiVariable_Sg____delitem__(std::vector<CdiVariable > *self,std::vector<CdiVariable >::difference_type i){
       self->erase(swig::getpos(self,i));
     }
-SWIGINTERN std::vector< CdiVariable,std::allocator< CdiVariable > > *std_vector_Sl_CdiVariable_Sg____getitem____SWIG_0(std::vector< CdiVariable > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return NULL;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<CdiVariable,std::allocator< CdiVariable > >::difference_type id = i;
-      std::vector<CdiVariable,std::allocator< CdiVariable > >::difference_type jd = j;
-      return swig::getslice(self, id, jd, step);
-    }
-SWIGINTERN void std_vector_Sl_CdiVariable_Sg____setitem____SWIG_0(std::vector< CdiVariable > *self,PySliceObject *slice,std::vector< CdiVariable,std::allocator< CdiVariable > > const &v){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<CdiVariable,std::allocator< CdiVariable > >::difference_type id = i;
-      std::vector<CdiVariable,std::allocator< CdiVariable > >::difference_type jd = j;
-      swig::setslice(self, id, jd, step, v);
-    }
-SWIGINTERN void std_vector_Sl_CdiVariable_Sg____setitem____SWIG_1(std::vector< CdiVariable > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<CdiVariable,std::allocator< CdiVariable > >::difference_type id = i;
-      std::vector<CdiVariable,std::allocator< CdiVariable > >::difference_type jd = j;
-      swig::delslice(self, id, jd, step);
-    }
-SWIGINTERN void std_vector_Sl_CdiVariable_Sg____delitem____SWIG_1(std::vector< CdiVariable > *self,PySliceObject *slice){
-      Py_ssize_t i, j, step;
-      if( !PySlice_Check(slice) ) {
-        SWIG_Error(SWIG_TypeError, "Slice object expected.");
-        return;
-      }
-      PySlice_GetIndices(SWIGPY_SLICE_ARG(slice), (Py_ssize_t)self->size(), &i, &j, &step);
-      std::vector<CdiVariable,std::allocator< CdiVariable > >::difference_type id = i;
-      std::vector<CdiVariable,std::allocator< CdiVariable > >::difference_type jd = j;
-      swig::delslice(self, id, jd, step);
-    }
-SWIGINTERN std::vector< CdiVariable >::value_type const &std_vector_Sl_CdiVariable_Sg____getitem____SWIG_1(std::vector< CdiVariable > const *self,std::vector< CdiVariable >::difference_type i){
+SWIGINTERN std::vector<CdiVariable >::value_type const &std_vector_Sl_CdiVariable_Sg____getitem__(std::vector<CdiVariable > const *self,std::vector<CdiVariable >::difference_type i){
       return *(swig::cgetpos(self, i));
     }
-SWIGINTERN void std_vector_Sl_CdiVariable_Sg____setitem____SWIG_2(std::vector< CdiVariable > *self,std::vector< CdiVariable >::difference_type i,std::vector< CdiVariable >::value_type const &x){
+SWIGINTERN void std_vector_Sl_CdiVariable_Sg____setitem__(std::vector<CdiVariable > *self,std::vector<CdiVariable >::difference_type i,std::vector<CdiVariable >::value_type const &x){
       *(swig::getpos(self,i)) = x;
     }
-SWIGINTERN void std_vector_Sl_CdiVariable_Sg__append(std::vector< CdiVariable > *self,std::vector< CdiVariable >::value_type const &x){
+SWIGINTERN void std_vector_Sl_CdiVariable_Sg__append(std::vector<CdiVariable > *self,std::vector<CdiVariable >::value_type const &x){
       self->push_back(x);
     }
-SWIGINTERN std::vector< CdiVariable >::iterator std_vector_Sl_CdiVariable_Sg__erase__SWIG_0(std::vector< CdiVariable > *self,std::vector< CdiVariable >::iterator pos){ return self->erase(pos); }
-SWIGINTERN std::vector< CdiVariable >::iterator std_vector_Sl_CdiVariable_Sg__erase__SWIG_1(std::vector< CdiVariable > *self,std::vector< CdiVariable >::iterator first,std::vector< CdiVariable >::iterator last){ return self->erase(first, last); }
-SWIGINTERN std::vector< CdiVariable >::iterator std_vector_Sl_CdiVariable_Sg__insert__SWIG_0(std::vector< CdiVariable > *self,std::vector< CdiVariable >::iterator pos,std::vector< CdiVariable >::value_type const &x){ return self->insert(pos, x); }
-SWIGINTERN void std_vector_Sl_CdiVariable_Sg__insert__SWIG_1(std::vector< CdiVariable > *self,std::vector< CdiVariable >::iterator pos,std::vector< CdiVariable >::size_type n,std::vector< CdiVariable >::value_type const &x){ self->insert(pos, n, x); }
 
   namespace swig {
 
@@ -5436,8 +4525,8 @@ SWIGINTERN void std_vector_Sl_CdiVariable_Sg__insert__SWIG_1(std::vector< CdiVar
 	  }
 	} else if (PySequence_Check(obj)) {
 	  if (PySequence_Size(obj) == 2) {
-	    swig::SwigVar_PyObject first = PySequence_GetItem(obj,0);
-	    swig::SwigVar_PyObject second = PySequence_GetItem(obj,1);
+	    swig::PyObject_var first = PySequence_GetItem(obj,0);
+	    swig::PyObject_var second = PySequence_GetItem(obj,1);
 	    res = get_pair(first, second, val);
 	  }
 	} else {
@@ -5462,41 +4551,6 @@ SWIGINTERN void std_vector_Sl_CdiVariable_Sg__insert__SWIG_1(std::vector< CdiVar
   }
 
 
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
       namespace swig {
 	template <>  struct traits<std::pair< std::string, CdiVariable > > {
 	  typedef pointer_category category;
@@ -5508,6 +4562,64 @@ SWIGINTERN void std_vector_Sl_CdiVariable_Sg__insert__SWIG_1(std::vector< CdiVar
     
 
   namespace swig {
+    template <class PySeq, class K, class T >
+    inline void
+    assign(const PySeq& pyseq, std::map<K,T > *map) {
+      typedef typename std::map<K,T>::value_type value_type;
+      typename PySeq::const_iterator it = pyseq.begin();
+      for (;it != pyseq.end(); ++it) {
+	map->insert(value_type(it->first, it->second));
+      }
+    }
+
+    template <class K, class T>
+    struct traits_asptr<std::map<K,T> >  {
+      typedef std::map<K,T> map_type;
+      static int asptr(PyObject *obj, map_type **val) {
+	int res = SWIG_ERROR;
+	if (PyDict_Check(obj)) {
+	  PyObject_var items = PyMapping_Items(obj);
+	  res = traits_asptr_stdseq<std::map<K,T>, std::pair<K, T> >::asptr(items, val);
+	} else {
+	  map_type *p;
+	  res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
+	  if (SWIG_IsOK(res) && val)  *val = p;
+	}
+	return res;
+      }      
+    };
+      
+    template <class K, class T >
+    struct traits_from<std::map<K,T> >  {
+      typedef std::map<K,T> map_type;
+      typedef typename map_type::const_iterator const_iterator;
+      typedef typename map_type::size_type size_type;
+            
+      static PyObject *from(const map_type& map) {
+	swig_type_info *desc = swig::type_info<map_type>();
+	if (desc && desc->clientdata) {
+	  return SWIG_NewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
+	} else {
+	  size_type size = map.size();
+	  int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
+	  if (pysize < 0) {
+	    SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+	    PyErr_SetString(PyExc_OverflowError,
+			    "map size not valid in python");
+	    SWIG_PYTHON_THREAD_END_BLOCK;
+	    return NULL;
+	  }
+	  PyObject *obj = PyDict_New();
+	  for (const_iterator i= map.begin(); i!= map.end(); ++i) {
+	    swig::PyObject_var key = swig::from(i->first);
+	    swig::PyObject_var val = swig::from(i->second);
+	    PyDict_SetItem(obj, key, val);
+	  }
+	  return obj;
+	}
+      }
+    };
+
     template <class ValueType>
     struct from_key_oper 
     {
@@ -5531,10 +4643,10 @@ SWIGINTERN void std_vector_Sl_CdiVariable_Sg__insert__SWIG_1(std::vector< CdiVar
     };
 
     template<class OutIterator, class FromOper, class ValueType = typename OutIterator::value_type>
-    struct SwigPyMapIterator_T : SwigPyIteratorClosed_T<OutIterator, ValueType, FromOper>
+    struct PyMapIterator_T : PySwigIteratorClosed_T<OutIterator, ValueType, FromOper>
     {
-      SwigPyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
-	: SwigPyIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
+      PyMapIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
+	: PySwigIteratorClosed_T<OutIterator,ValueType,FromOper>(curr, first, last, seq)
       {
       }
     };
@@ -5542,226 +4654,140 @@ SWIGINTERN void std_vector_Sl_CdiVariable_Sg__insert__SWIG_1(std::vector< CdiVar
 
     template<class OutIterator,
 	     class FromOper = from_key_oper<typename OutIterator::value_type> >
-    struct SwigPyMapKeyIterator_T : SwigPyMapIterator_T<OutIterator, FromOper>
+    struct PyMapKeyIterator_T : PyMapIterator_T<OutIterator, FromOper>
     {
-      SwigPyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
-	: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
+      PyMapKeyIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
+	: PyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
       {
       }
     };
 
     template<typename OutIter>
-    inline SwigPyIterator*
+    inline PySwigIterator*
     make_output_key_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
     {
-      return new SwigPyMapKeyIterator_T<OutIter>(current, begin, end, seq);
+      return new PyMapKeyIterator_T<OutIter>(current, begin, end, seq);
     }
 
     template<class OutIterator,
 	     class FromOper = from_value_oper<typename OutIterator::value_type> >
-    struct SwigPyMapValueITerator_T : SwigPyMapIterator_T<OutIterator, FromOper>
+    struct PyMapValueIterator_T : PyMapIterator_T<OutIterator, FromOper>
     {
-      SwigPyMapValueITerator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
-	: SwigPyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
+      PyMapValueIterator_T(OutIterator curr, OutIterator first, OutIterator last, PyObject *seq)
+	: PyMapIterator_T<OutIterator, FromOper>(curr, first, last, seq)
       {
       }
     };
     
 
     template<typename OutIter>
-    inline SwigPyIterator*
+    inline PySwigIterator*
     make_output_value_iterator(const OutIter& current, const OutIter& begin, const OutIter& end, PyObject *seq = 0)
     {
-      return new SwigPyMapValueITerator_T<OutIter>(current, begin, end, seq);
-    }
-  }
-
-
-  namespace swig {
-    template <class SwigPySeq, class K, class T, class Compare, class Alloc >
-    inline void
-    assign(const SwigPySeq& swigpyseq, std::map<K,T,Compare,Alloc > *map) {
-      typedef typename std::map<K,T,Compare,Alloc >::value_type value_type;
-      typename SwigPySeq::const_iterator it = swigpyseq.begin();
-      for (;it != swigpyseq.end(); ++it) {
-	map->insert(value_type(it->first, it->second));
-      }
+      return new PyMapValueIterator_T<OutIter>(current, begin, end, seq);
     }
-
-    template <class K, class T, class Compare, class Alloc>
-    struct traits_asptr<std::map<K,T,Compare,Alloc > >  {
-      typedef std::map<K,T,Compare,Alloc > map_type;
-      static int asptr(PyObject *obj, map_type **val) {
-	int res = SWIG_ERROR;
-	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
-	if (PyDict_Check(obj)) {
-	  SwigVar_PyObject items = PyObject_CallMethod(obj,(char *)"items",NULL);
-#if PY_VERSION_HEX >= 0x03000000
-          /* In Python 3.x the ".items()" method returns a dict_items object */
-          items = PySequence_Fast(items, ".items() didn't return a sequence!");
-#endif
-	  res = traits_asptr_stdseq<map_type, std::pair<K, T> >::asptr(items, val);
-	} else {
-	  map_type *p;
-	  res = SWIG_ConvertPtr(obj,(void**)&p,swig::type_info<map_type>(),0);
-	  if (SWIG_IsOK(res) && val)  *val = p;
-	}
-	SWIG_PYTHON_THREAD_END_BLOCK;
-	return res;
-      }      
-    };
-      
-    template <class K, class T, class Compare, class Alloc >
-    struct traits_from<std::map<K,T,Compare,Alloc > >  {
-      typedef std::map<K,T,Compare,Alloc > map_type;
-      typedef typename map_type::const_iterator const_iterator;
-      typedef typename map_type::size_type size_type;
-
-      static PyObject *asdict(const map_type& map) {
-	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
-	size_type size = map.size();
-	int pysize = (size <= (size_type) INT_MAX) ? (int) size : -1;
-	if (pysize < 0) {
-	  PyErr_SetString(PyExc_OverflowError,
-			  "map size not valid in python");
-	  SWIG_PYTHON_THREAD_END_BLOCK;
-	  return NULL;
-	}
-	PyObject *obj = PyDict_New();
-	for (const_iterator i= map.begin(); i!= map.end(); ++i) {
-	  swig::SwigVar_PyObject key = swig::from(i->first);
-	  swig::SwigVar_PyObject val = swig::from(i->second);
-	  PyDict_SetItem(obj, key, val);
-	}
-	SWIG_PYTHON_THREAD_END_BLOCK;
-	return obj;
-      }
-                
-      static PyObject *from(const map_type& map) {
-	swig_type_info *desc = swig::type_info<map_type>();
-	if (desc && desc->clientdata) {
-	  return SWIG_InternalNewPointerObj(new map_type(map), desc, SWIG_POINTER_OWN);
-	} else {
-	  return asdict(map);
-	}
-      }
-    };
   }
 
 
       namespace swig {
-	template <>  struct traits<std::map<std::string, CdiVariable, std::less< std::string >, std::allocator< std::pair< std::string const,CdiVariable > > > > {
+	template <>  struct traits<std::map<std::string, CdiVariable, std::less<std::string >, std::allocator<std::pair<std::string const,CdiVariable > > > > {
 	  typedef pointer_category category;
 	  static const char* type_name() {
-	    return "std::map<" "std::string" "," "CdiVariable" "," "std::less< std::string >" "," "std::allocator< std::pair< std::string const,CdiVariable > >" " >";
+	    return "std::map<" "std::string" "," "CdiVariable" "," "std::less<std::string >" "," "std::allocator<std::pair<std::string const,CdiVariable > >" " >";
 	  }
 	};
       }
     
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_std_string_Sc_CdiVariable_Sg__iterator(std::map< std::string,CdiVariable > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_std_string_Sc_CdiVariable_Sg__iterator(std::map<std::string,CdiVariable > *self,PyObject **PYTHON_SELF){
       return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN bool std_map_Sl_std_string_Sc_CdiVariable_Sg____nonzero__(std::map< std::string,CdiVariable > const *self){
-      return !(self->empty());
-    }
-SWIGINTERN bool std_map_Sl_std_string_Sc_CdiVariable_Sg____bool__(std::map< std::string,CdiVariable > const *self){
+SWIGINTERN bool std_map_Sl_std_string_Sc_CdiVariable_Sg____nonzero__(std::map<std::string,CdiVariable > const *self){
       return !(self->empty());
     }
-SWIGINTERN std::map< std::string,CdiVariable >::size_type std_map_Sl_std_string_Sc_CdiVariable_Sg____len__(std::map< std::string,CdiVariable > const *self){
+SWIGINTERN std::map<std::string,CdiVariable >::size_type std_map_Sl_std_string_Sc_CdiVariable_Sg____len__(std::map<std::string,CdiVariable > const *self){
       return self->size();
     }
-SWIGINTERN std::map< std::string,CdiVariable >::mapped_type const &std_map_Sl_std_string_Sc_CdiVariable_Sg____getitem__(std::map< std::string,CdiVariable > *self,std::map< std::string,CdiVariable >::key_type const &key){
-      std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >::const_iterator i = self->find(key);
+SWIGINTERN std::map<std::string,CdiVariable >::mapped_type std_map_Sl_std_string_Sc_CdiVariable_Sg____getitem__(std::map<std::string,CdiVariable > const *self,std::map<std::string,CdiVariable >::key_type const &key){
+      std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >::const_iterator i = self->find(key);
       if (i != self->end())
 	return i->second;
       else
 	throw std::out_of_range("key not found");
     }
-SWIGINTERN void std_map_Sl_std_string_Sc_CdiVariable_Sg____delitem__(std::map< std::string,CdiVariable > *self,std::map< std::string,CdiVariable >::key_type const &key){
-      std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >::iterator i = self->find(key);
+SWIGINTERN void std_map_Sl_std_string_Sc_CdiVariable_Sg____delitem__(std::map<std::string,CdiVariable > *self,std::map<std::string,CdiVariable >::key_type const &key){
+      std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >::iterator i = self->find(key);
       if (i != self->end())
 	self->erase(i);
       else
 	throw std::out_of_range("key not found");
     }
-SWIGINTERN bool std_map_Sl_std_string_Sc_CdiVariable_Sg__has_key(std::map< std::string,CdiVariable > const *self,std::map< std::string,CdiVariable >::key_type const &key){
-      std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >::const_iterator i = self->find(key);
+SWIGINTERN bool std_map_Sl_std_string_Sc_CdiVariable_Sg__has_key(std::map<std::string,CdiVariable > const *self,std::map<std::string,CdiVariable >::key_type const &key){
+      std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >::const_iterator i = self->find(key);
       return i != self->end();
     }
-SWIGINTERN PyObject *std_map_Sl_std_string_Sc_CdiVariable_Sg__keys(std::map< std::string,CdiVariable > *self){
-      std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_std_string_Sc_CdiVariable_Sg__keys(std::map<std::string,CdiVariable > *self){
+      std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }
       PyObject* keyList = PyList_New(pysize);
-      std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >::const_iterator i = self->begin();
+      std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(keyList, j, swig::from(i->first));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return keyList;
     }
-SWIGINTERN PyObject *std_map_Sl_std_string_Sc_CdiVariable_Sg__values(std::map< std::string,CdiVariable > *self){
-      std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_std_string_Sc_CdiVariable_Sg__values(std::map<std::string,CdiVariable > *self){
+      std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }
       PyObject* valList = PyList_New(pysize);
-      std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >::const_iterator i = self->begin();
+      std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(valList, j, swig::from(i->second));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return valList;
     }
-SWIGINTERN PyObject *std_map_Sl_std_string_Sc_CdiVariable_Sg__items(std::map< std::string,CdiVariable > *self){
-      std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_std_string_Sc_CdiVariable_Sg__items(std::map<std::string,CdiVariable > *self){
+      std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }    
       PyObject* itemList = PyList_New(pysize);
-      std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >::const_iterator i = self->begin();
+      std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(itemList, j, swig::from(*i));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return itemList;
     }
-SWIGINTERN bool std_map_Sl_std_string_Sc_CdiVariable_Sg____contains__(std::map< std::string,CdiVariable > *self,std::map< std::string,CdiVariable >::key_type const &key){
+SWIGINTERN bool std_map_Sl_std_string_Sc_CdiVariable_Sg____contains__(std::map<std::string,CdiVariable > *self,std::map<std::string,CdiVariable >::key_type const &key){
       return self->find(key) != self->end();
     }
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_std_string_Sc_CdiVariable_Sg__key_iterator(std::map< std::string,CdiVariable > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_std_string_Sc_CdiVariable_Sg__key_iterator(std::map<std::string,CdiVariable > *self,PyObject **PYTHON_SELF){
       return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_std_string_Sc_CdiVariable_Sg__value_iterator(std::map< std::string,CdiVariable > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_std_string_Sc_CdiVariable_Sg__value_iterator(std::map<std::string,CdiVariable > *self,PyObject **PYTHON_SELF){
       return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN void std_map_Sl_std_string_Sc_CdiVariable_Sg____setitem____SWIG_0(std::map< std::string,CdiVariable > *self,std::map< std::string,CdiVariable >::key_type const &key){
-      self->erase(key);
-    }
-SWIGINTERN void std_map_Sl_std_string_Sc_CdiVariable_Sg____setitem____SWIG_1(std::map< std::string,CdiVariable > *self,std::map< std::string,CdiVariable >::key_type const &key,std::map< std::string,CdiVariable >::mapped_type const &x){
+SWIGINTERN void std_map_Sl_std_string_Sc_CdiVariable_Sg____setitem__(std::map<std::string,CdiVariable > *self,std::map<std::string,CdiVariable >::key_type const &key,std::map<std::string,CdiVariable >::mapped_type const &x){
       (*self)[key] = x;
     }
-SWIGINTERN PyObject *std_map_Sl_std_string_Sc_CdiVariable_Sg__asdict(std::map< std::string,CdiVariable > *self){
-      return swig::traits_from< std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > > >::asdict(*self);
-    }
-SWIGINTERN void std_map_Sl_std_string_Sc_CdiVariable_Sg__erase__SWIG_1(std::map< std::string,CdiVariable > *self,std::map< std::string,CdiVariable >::iterator position){ self->erase(position); }
-SWIGINTERN void std_map_Sl_std_string_Sc_CdiVariable_Sg__erase__SWIG_2(std::map< std::string,CdiVariable > *self,std::map< std::string,CdiVariable >::iterator first,std::map< std::string,CdiVariable >::iterator last){ self->erase(first, last); }
 
       namespace swig {
 	template <>  struct traits<std::pair< int, CdiVariable > > {
@@ -5774,118 +4800,104 @@ SWIGINTERN void std_map_Sl_std_string_Sc_CdiVariable_Sg__erase__SWIG_2(std::map<
     
 
       namespace swig {
-	template <>  struct traits<std::map<int, CdiVariable, std::less< int >, std::allocator< std::pair< int const,CdiVariable > > > > {
+	template <>  struct traits<std::map<int, CdiVariable, std::less<int >, std::allocator<std::pair<int const,CdiVariable > > > > {
 	  typedef pointer_category category;
 	  static const char* type_name() {
-	    return "std::map<" "int" "," "CdiVariable" "," "std::less< int >" "," "std::allocator< std::pair< int const,CdiVariable > >" " >";
+	    return "std::map<" "int" "," "CdiVariable" "," "std::less<int >" "," "std::allocator<std::pair<int const,CdiVariable > >" " >";
 	  }
 	};
       }
     
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_int_Sc_CdiVariable_Sg__iterator(std::map< int,CdiVariable > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_int_Sc_CdiVariable_Sg__iterator(std::map<int,CdiVariable > *self,PyObject **PYTHON_SELF){
       return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiVariable_Sg____nonzero__(std::map< int,CdiVariable > const *self){
-      return !(self->empty());
-    }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiVariable_Sg____bool__(std::map< int,CdiVariable > const *self){
+SWIGINTERN bool std_map_Sl_int_Sc_CdiVariable_Sg____nonzero__(std::map<int,CdiVariable > const *self){
       return !(self->empty());
     }
-SWIGINTERN std::map< int,CdiVariable >::size_type std_map_Sl_int_Sc_CdiVariable_Sg____len__(std::map< int,CdiVariable > const *self){
+SWIGINTERN std::map<int,CdiVariable >::size_type std_map_Sl_int_Sc_CdiVariable_Sg____len__(std::map<int,CdiVariable > const *self){
       return self->size();
     }
-SWIGINTERN std::map< int,CdiVariable >::mapped_type const &std_map_Sl_int_Sc_CdiVariable_Sg____getitem__(std::map< int,CdiVariable > *self,std::map< int,CdiVariable >::key_type const &key){
-      std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >::const_iterator i = self->find(key);
+SWIGINTERN std::map<int,CdiVariable >::mapped_type std_map_Sl_int_Sc_CdiVariable_Sg____getitem__(std::map<int,CdiVariable > const *self,std::map<int,CdiVariable >::key_type const &key){
+      std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >::const_iterator i = self->find(key);
       if (i != self->end())
 	return i->second;
       else
 	throw std::out_of_range("key not found");
     }
-SWIGINTERN void std_map_Sl_int_Sc_CdiVariable_Sg____delitem__(std::map< int,CdiVariable > *self,std::map< int,CdiVariable >::key_type const &key){
-      std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >::iterator i = self->find(key);
+SWIGINTERN void std_map_Sl_int_Sc_CdiVariable_Sg____delitem__(std::map<int,CdiVariable > *self,std::map<int,CdiVariable >::key_type const &key){
+      std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >::iterator i = self->find(key);
       if (i != self->end())
 	self->erase(i);
       else
 	throw std::out_of_range("key not found");
     }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiVariable_Sg__has_key(std::map< int,CdiVariable > const *self,std::map< int,CdiVariable >::key_type const &key){
-      std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >::const_iterator i = self->find(key);
+SWIGINTERN bool std_map_Sl_int_Sc_CdiVariable_Sg__has_key(std::map<int,CdiVariable > const *self,std::map<int,CdiVariable >::key_type const &key){
+      std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >::const_iterator i = self->find(key);
       return i != self->end();
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiVariable_Sg__keys(std::map< int,CdiVariable > *self){
-      std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiVariable_Sg__keys(std::map<int,CdiVariable > *self){
+      std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }
       PyObject* keyList = PyList_New(pysize);
-      std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >::const_iterator i = self->begin();
+      std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(keyList, j, swig::from(i->first));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return keyList;
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiVariable_Sg__values(std::map< int,CdiVariable > *self){
-      std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiVariable_Sg__values(std::map<int,CdiVariable > *self){
+      std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }
       PyObject* valList = PyList_New(pysize);
-      std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >::const_iterator i = self->begin();
+      std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(valList, j, swig::from(i->second));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return valList;
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiVariable_Sg__items(std::map< int,CdiVariable > *self){
-      std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiVariable_Sg__items(std::map<int,CdiVariable > *self){
+      std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }    
       PyObject* itemList = PyList_New(pysize);
-      std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >::const_iterator i = self->begin();
+      std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(itemList, j, swig::from(*i));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return itemList;
     }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiVariable_Sg____contains__(std::map< int,CdiVariable > *self,std::map< int,CdiVariable >::key_type const &key){
+SWIGINTERN bool std_map_Sl_int_Sc_CdiVariable_Sg____contains__(std::map<int,CdiVariable > *self,std::map<int,CdiVariable >::key_type const &key){
       return self->find(key) != self->end();
     }
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_int_Sc_CdiVariable_Sg__key_iterator(std::map< int,CdiVariable > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_int_Sc_CdiVariable_Sg__key_iterator(std::map<int,CdiVariable > *self,PyObject **PYTHON_SELF){
       return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_int_Sc_CdiVariable_Sg__value_iterator(std::map< int,CdiVariable > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_int_Sc_CdiVariable_Sg__value_iterator(std::map<int,CdiVariable > *self,PyObject **PYTHON_SELF){
       return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN void std_map_Sl_int_Sc_CdiVariable_Sg____setitem____SWIG_0(std::map< int,CdiVariable > *self,std::map< int,CdiVariable >::key_type const &key){
-      self->erase(key);
-    }
-SWIGINTERN void std_map_Sl_int_Sc_CdiVariable_Sg____setitem____SWIG_1(std::map< int,CdiVariable > *self,std::map< int,CdiVariable >::key_type const &key,std::map< int,CdiVariable >::mapped_type const &x){
+SWIGINTERN void std_map_Sl_int_Sc_CdiVariable_Sg____setitem__(std::map<int,CdiVariable > *self,std::map<int,CdiVariable >::key_type const &key,std::map<int,CdiVariable >::mapped_type const &x){
       (*self)[key] = x;
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiVariable_Sg__asdict(std::map< int,CdiVariable > *self){
-      return swig::traits_from< std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > > >::asdict(*self);
-    }
-SWIGINTERN void std_map_Sl_int_Sc_CdiVariable_Sg__erase__SWIG_1(std::map< int,CdiVariable > *self,std::map< int,CdiVariable >::iterator position){ self->erase(position); }
-SWIGINTERN void std_map_Sl_int_Sc_CdiVariable_Sg__erase__SWIG_2(std::map< int,CdiVariable > *self,std::map< int,CdiVariable >::iterator first,std::map< int,CdiVariable >::iterator last){ self->erase(first, last); }
 
   namespace swig {
     template <>  struct traits<CdiTaxis > {
@@ -5906,118 +4918,104 @@ SWIGINTERN void std_map_Sl_int_Sc_CdiVariable_Sg__erase__SWIG_2(std::map< int,Cd
     
 
       namespace swig {
-	template <>  struct traits<std::map<int, CdiTaxis, std::less< int >, std::allocator< std::pair< int const,CdiTaxis > > > > {
+	template <>  struct traits<std::map<int, CdiTaxis, std::less<int >, std::allocator<std::pair<int const,CdiTaxis > > > > {
 	  typedef pointer_category category;
 	  static const char* type_name() {
-	    return "std::map<" "int" "," "CdiTaxis" "," "std::less< int >" "," "std::allocator< std::pair< int const,CdiTaxis > >" " >";
+	    return "std::map<" "int" "," "CdiTaxis" "," "std::less<int >" "," "std::allocator<std::pair<int const,CdiTaxis > >" " >";
 	  }
 	};
       }
     
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_int_Sc_CdiTaxis_Sg__iterator(std::map< int,CdiTaxis > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_int_Sc_CdiTaxis_Sg__iterator(std::map<int,CdiTaxis > *self,PyObject **PYTHON_SELF){
       return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiTaxis_Sg____nonzero__(std::map< int,CdiTaxis > const *self){
-      return !(self->empty());
-    }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiTaxis_Sg____bool__(std::map< int,CdiTaxis > const *self){
+SWIGINTERN bool std_map_Sl_int_Sc_CdiTaxis_Sg____nonzero__(std::map<int,CdiTaxis > const *self){
       return !(self->empty());
     }
-SWIGINTERN std::map< int,CdiTaxis >::size_type std_map_Sl_int_Sc_CdiTaxis_Sg____len__(std::map< int,CdiTaxis > const *self){
+SWIGINTERN std::map<int,CdiTaxis >::size_type std_map_Sl_int_Sc_CdiTaxis_Sg____len__(std::map<int,CdiTaxis > const *self){
       return self->size();
     }
-SWIGINTERN std::map< int,CdiTaxis >::mapped_type const &std_map_Sl_int_Sc_CdiTaxis_Sg____getitem__(std::map< int,CdiTaxis > *self,std::map< int,CdiTaxis >::key_type const &key){
-      std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >::const_iterator i = self->find(key);
+SWIGINTERN std::map<int,CdiTaxis >::mapped_type std_map_Sl_int_Sc_CdiTaxis_Sg____getitem__(std::map<int,CdiTaxis > const *self,std::map<int,CdiTaxis >::key_type const &key){
+      std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >::const_iterator i = self->find(key);
       if (i != self->end())
 	return i->second;
       else
 	throw std::out_of_range("key not found");
     }
-SWIGINTERN void std_map_Sl_int_Sc_CdiTaxis_Sg____delitem__(std::map< int,CdiTaxis > *self,std::map< int,CdiTaxis >::key_type const &key){
-      std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >::iterator i = self->find(key);
+SWIGINTERN void std_map_Sl_int_Sc_CdiTaxis_Sg____delitem__(std::map<int,CdiTaxis > *self,std::map<int,CdiTaxis >::key_type const &key){
+      std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >::iterator i = self->find(key);
       if (i != self->end())
 	self->erase(i);
       else
 	throw std::out_of_range("key not found");
     }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiTaxis_Sg__has_key(std::map< int,CdiTaxis > const *self,std::map< int,CdiTaxis >::key_type const &key){
-      std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >::const_iterator i = self->find(key);
+SWIGINTERN bool std_map_Sl_int_Sc_CdiTaxis_Sg__has_key(std::map<int,CdiTaxis > const *self,std::map<int,CdiTaxis >::key_type const &key){
+      std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >::const_iterator i = self->find(key);
       return i != self->end();
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiTaxis_Sg__keys(std::map< int,CdiTaxis > *self){
-      std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiTaxis_Sg__keys(std::map<int,CdiTaxis > *self){
+      std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }
       PyObject* keyList = PyList_New(pysize);
-      std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >::const_iterator i = self->begin();
+      std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(keyList, j, swig::from(i->first));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return keyList;
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiTaxis_Sg__values(std::map< int,CdiTaxis > *self){
-      std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiTaxis_Sg__values(std::map<int,CdiTaxis > *self){
+      std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }
       PyObject* valList = PyList_New(pysize);
-      std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >::const_iterator i = self->begin();
+      std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(valList, j, swig::from(i->second));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return valList;
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiTaxis_Sg__items(std::map< int,CdiTaxis > *self){
-      std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiTaxis_Sg__items(std::map<int,CdiTaxis > *self){
+      std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }    
       PyObject* itemList = PyList_New(pysize);
-      std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >::const_iterator i = self->begin();
+      std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(itemList, j, swig::from(*i));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return itemList;
     }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiTaxis_Sg____contains__(std::map< int,CdiTaxis > *self,std::map< int,CdiTaxis >::key_type const &key){
+SWIGINTERN bool std_map_Sl_int_Sc_CdiTaxis_Sg____contains__(std::map<int,CdiTaxis > *self,std::map<int,CdiTaxis >::key_type const &key){
       return self->find(key) != self->end();
     }
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_int_Sc_CdiTaxis_Sg__key_iterator(std::map< int,CdiTaxis > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_int_Sc_CdiTaxis_Sg__key_iterator(std::map<int,CdiTaxis > *self,PyObject **PYTHON_SELF){
       return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_int_Sc_CdiTaxis_Sg__value_iterator(std::map< int,CdiTaxis > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_int_Sc_CdiTaxis_Sg__value_iterator(std::map<int,CdiTaxis > *self,PyObject **PYTHON_SELF){
       return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN void std_map_Sl_int_Sc_CdiTaxis_Sg____setitem____SWIG_0(std::map< int,CdiTaxis > *self,std::map< int,CdiTaxis >::key_type const &key){
-      self->erase(key);
-    }
-SWIGINTERN void std_map_Sl_int_Sc_CdiTaxis_Sg____setitem____SWIG_1(std::map< int,CdiTaxis > *self,std::map< int,CdiTaxis >::key_type const &key,std::map< int,CdiTaxis >::mapped_type const &x){
+SWIGINTERN void std_map_Sl_int_Sc_CdiTaxis_Sg____setitem__(std::map<int,CdiTaxis > *self,std::map<int,CdiTaxis >::key_type const &key,std::map<int,CdiTaxis >::mapped_type const &x){
       (*self)[key] = x;
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiTaxis_Sg__asdict(std::map< int,CdiTaxis > *self){
-      return swig::traits_from< std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > > >::asdict(*self);
-    }
-SWIGINTERN void std_map_Sl_int_Sc_CdiTaxis_Sg__erase__SWIG_1(std::map< int,CdiTaxis > *self,std::map< int,CdiTaxis >::iterator position){ self->erase(position); }
-SWIGINTERN void std_map_Sl_int_Sc_CdiTaxis_Sg__erase__SWIG_2(std::map< int,CdiTaxis > *self,std::map< int,CdiTaxis >::iterator first,std::map< int,CdiTaxis >::iterator last){ self->erase(first, last); }
 
   namespace swig {
     template <>  struct traits<CdiZaxis > {
@@ -6038,118 +5036,104 @@ SWIGINTERN void std_map_Sl_int_Sc_CdiTaxis_Sg__erase__SWIG_2(std::map< int,CdiTa
     
 
       namespace swig {
-	template <>  struct traits<std::map<int, CdiZaxis, std::less< int >, std::allocator< std::pair< int const,CdiZaxis > > > > {
+	template <>  struct traits<std::map<int, CdiZaxis, std::less<int >, std::allocator<std::pair<int const,CdiZaxis > > > > {
 	  typedef pointer_category category;
 	  static const char* type_name() {
-	    return "std::map<" "int" "," "CdiZaxis" "," "std::less< int >" "," "std::allocator< std::pair< int const,CdiZaxis > >" " >";
+	    return "std::map<" "int" "," "CdiZaxis" "," "std::less<int >" "," "std::allocator<std::pair<int const,CdiZaxis > >" " >";
 	  }
 	};
       }
     
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_int_Sc_CdiZaxis_Sg__iterator(std::map< int,CdiZaxis > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_int_Sc_CdiZaxis_Sg__iterator(std::map<int,CdiZaxis > *self,PyObject **PYTHON_SELF){
       return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiZaxis_Sg____nonzero__(std::map< int,CdiZaxis > const *self){
+SWIGINTERN bool std_map_Sl_int_Sc_CdiZaxis_Sg____nonzero__(std::map<int,CdiZaxis > const *self){
       return !(self->empty());
     }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiZaxis_Sg____bool__(std::map< int,CdiZaxis > const *self){
-      return !(self->empty());
-    }
-SWIGINTERN std::map< int,CdiZaxis >::size_type std_map_Sl_int_Sc_CdiZaxis_Sg____len__(std::map< int,CdiZaxis > const *self){
+SWIGINTERN std::map<int,CdiZaxis >::size_type std_map_Sl_int_Sc_CdiZaxis_Sg____len__(std::map<int,CdiZaxis > const *self){
       return self->size();
     }
-SWIGINTERN std::map< int,CdiZaxis >::mapped_type const &std_map_Sl_int_Sc_CdiZaxis_Sg____getitem__(std::map< int,CdiZaxis > *self,std::map< int,CdiZaxis >::key_type const &key){
-      std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >::const_iterator i = self->find(key);
+SWIGINTERN std::map<int,CdiZaxis >::mapped_type std_map_Sl_int_Sc_CdiZaxis_Sg____getitem__(std::map<int,CdiZaxis > const *self,std::map<int,CdiZaxis >::key_type const &key){
+      std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >::const_iterator i = self->find(key);
       if (i != self->end())
 	return i->second;
       else
 	throw std::out_of_range("key not found");
     }
-SWIGINTERN void std_map_Sl_int_Sc_CdiZaxis_Sg____delitem__(std::map< int,CdiZaxis > *self,std::map< int,CdiZaxis >::key_type const &key){
-      std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >::iterator i = self->find(key);
+SWIGINTERN void std_map_Sl_int_Sc_CdiZaxis_Sg____delitem__(std::map<int,CdiZaxis > *self,std::map<int,CdiZaxis >::key_type const &key){
+      std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >::iterator i = self->find(key);
       if (i != self->end())
 	self->erase(i);
       else
 	throw std::out_of_range("key not found");
     }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiZaxis_Sg__has_key(std::map< int,CdiZaxis > const *self,std::map< int,CdiZaxis >::key_type const &key){
-      std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >::const_iterator i = self->find(key);
+SWIGINTERN bool std_map_Sl_int_Sc_CdiZaxis_Sg__has_key(std::map<int,CdiZaxis > const *self,std::map<int,CdiZaxis >::key_type const &key){
+      std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >::const_iterator i = self->find(key);
       return i != self->end();
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiZaxis_Sg__keys(std::map< int,CdiZaxis > *self){
-      std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiZaxis_Sg__keys(std::map<int,CdiZaxis > *self){
+      std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }
       PyObject* keyList = PyList_New(pysize);
-      std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >::const_iterator i = self->begin();
+      std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(keyList, j, swig::from(i->first));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return keyList;
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiZaxis_Sg__values(std::map< int,CdiZaxis > *self){
-      std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiZaxis_Sg__values(std::map<int,CdiZaxis > *self){
+      std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }
       PyObject* valList = PyList_New(pysize);
-      std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >::const_iterator i = self->begin();
+      std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(valList, j, swig::from(i->second));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return valList;
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiZaxis_Sg__items(std::map< int,CdiZaxis > *self){
-      std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiZaxis_Sg__items(std::map<int,CdiZaxis > *self){
+      std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }    
       PyObject* itemList = PyList_New(pysize);
-      std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >::const_iterator i = self->begin();
+      std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(itemList, j, swig::from(*i));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return itemList;
     }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiZaxis_Sg____contains__(std::map< int,CdiZaxis > *self,std::map< int,CdiZaxis >::key_type const &key){
+SWIGINTERN bool std_map_Sl_int_Sc_CdiZaxis_Sg____contains__(std::map<int,CdiZaxis > *self,std::map<int,CdiZaxis >::key_type const &key){
       return self->find(key) != self->end();
     }
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_int_Sc_CdiZaxis_Sg__key_iterator(std::map< int,CdiZaxis > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_int_Sc_CdiZaxis_Sg__key_iterator(std::map<int,CdiZaxis > *self,PyObject **PYTHON_SELF){
       return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_int_Sc_CdiZaxis_Sg__value_iterator(std::map< int,CdiZaxis > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_int_Sc_CdiZaxis_Sg__value_iterator(std::map<int,CdiZaxis > *self,PyObject **PYTHON_SELF){
       return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN void std_map_Sl_int_Sc_CdiZaxis_Sg____setitem____SWIG_0(std::map< int,CdiZaxis > *self,std::map< int,CdiZaxis >::key_type const &key){
-      self->erase(key);
-    }
-SWIGINTERN void std_map_Sl_int_Sc_CdiZaxis_Sg____setitem____SWIG_1(std::map< int,CdiZaxis > *self,std::map< int,CdiZaxis >::key_type const &key,std::map< int,CdiZaxis >::mapped_type const &x){
+SWIGINTERN void std_map_Sl_int_Sc_CdiZaxis_Sg____setitem__(std::map<int,CdiZaxis > *self,std::map<int,CdiZaxis >::key_type const &key,std::map<int,CdiZaxis >::mapped_type const &x){
       (*self)[key] = x;
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiZaxis_Sg__asdict(std::map< int,CdiZaxis > *self){
-      return swig::traits_from< std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > > >::asdict(*self);
-    }
-SWIGINTERN void std_map_Sl_int_Sc_CdiZaxis_Sg__erase__SWIG_1(std::map< int,CdiZaxis > *self,std::map< int,CdiZaxis >::iterator position){ self->erase(position); }
-SWIGINTERN void std_map_Sl_int_Sc_CdiZaxis_Sg__erase__SWIG_2(std::map< int,CdiZaxis > *self,std::map< int,CdiZaxis >::iterator first,std::map< int,CdiZaxis >::iterator last){ self->erase(first, last); }
 
   namespace swig {
     template <>  struct traits<CdiGrid > {
@@ -6170,130 +5154,120 @@ SWIGINTERN void std_map_Sl_int_Sc_CdiZaxis_Sg__erase__SWIG_2(std::map< int,CdiZa
     
 
       namespace swig {
-	template <>  struct traits<std::map<int, CdiGrid, std::less< int >, std::allocator< std::pair< int const,CdiGrid > > > > {
+	template <>  struct traits<std::map<int, CdiGrid, std::less<int >, std::allocator<std::pair<int const,CdiGrid > > > > {
 	  typedef pointer_category category;
 	  static const char* type_name() {
-	    return "std::map<" "int" "," "CdiGrid" "," "std::less< int >" "," "std::allocator< std::pair< int const,CdiGrid > >" " >";
+	    return "std::map<" "int" "," "CdiGrid" "," "std::less<int >" "," "std::allocator<std::pair<int const,CdiGrid > >" " >";
 	  }
 	};
       }
     
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_int_Sc_CdiGrid_Sg__iterator(std::map< int,CdiGrid > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_int_Sc_CdiGrid_Sg__iterator(std::map<int,CdiGrid > *self,PyObject **PYTHON_SELF){
       return swig::make_output_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiGrid_Sg____nonzero__(std::map< int,CdiGrid > const *self){
-      return !(self->empty());
-    }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiGrid_Sg____bool__(std::map< int,CdiGrid > const *self){
+SWIGINTERN bool std_map_Sl_int_Sc_CdiGrid_Sg____nonzero__(std::map<int,CdiGrid > const *self){
       return !(self->empty());
     }
-SWIGINTERN std::map< int,CdiGrid >::size_type std_map_Sl_int_Sc_CdiGrid_Sg____len__(std::map< int,CdiGrid > const *self){
+SWIGINTERN std::map<int,CdiGrid >::size_type std_map_Sl_int_Sc_CdiGrid_Sg____len__(std::map<int,CdiGrid > const *self){
       return self->size();
     }
-SWIGINTERN std::map< int,CdiGrid >::mapped_type const &std_map_Sl_int_Sc_CdiGrid_Sg____getitem__(std::map< int,CdiGrid > *self,std::map< int,CdiGrid >::key_type const &key){
-      std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >::const_iterator i = self->find(key);
+SWIGINTERN std::map<int,CdiGrid >::mapped_type std_map_Sl_int_Sc_CdiGrid_Sg____getitem__(std::map<int,CdiGrid > const *self,std::map<int,CdiGrid >::key_type const &key){
+      std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >::const_iterator i = self->find(key);
       if (i != self->end())
 	return i->second;
       else
 	throw std::out_of_range("key not found");
     }
-SWIGINTERN void std_map_Sl_int_Sc_CdiGrid_Sg____delitem__(std::map< int,CdiGrid > *self,std::map< int,CdiGrid >::key_type const &key){
-      std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >::iterator i = self->find(key);
+SWIGINTERN void std_map_Sl_int_Sc_CdiGrid_Sg____delitem__(std::map<int,CdiGrid > *self,std::map<int,CdiGrid >::key_type const &key){
+      std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >::iterator i = self->find(key);
       if (i != self->end())
 	self->erase(i);
       else
 	throw std::out_of_range("key not found");
     }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiGrid_Sg__has_key(std::map< int,CdiGrid > const *self,std::map< int,CdiGrid >::key_type const &key){
-      std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >::const_iterator i = self->find(key);
+SWIGINTERN bool std_map_Sl_int_Sc_CdiGrid_Sg__has_key(std::map<int,CdiGrid > const *self,std::map<int,CdiGrid >::key_type const &key){
+      std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >::const_iterator i = self->find(key);
       return i != self->end();
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiGrid_Sg__keys(std::map< int,CdiGrid > *self){
-      std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiGrid_Sg__keys(std::map<int,CdiGrid > *self){
+      std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }
       PyObject* keyList = PyList_New(pysize);
-      std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >::const_iterator i = self->begin();
+      std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(keyList, j, swig::from(i->first));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return keyList;
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiGrid_Sg__values(std::map< int,CdiGrid > *self){
-      std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiGrid_Sg__values(std::map<int,CdiGrid > *self){
+      std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }
       PyObject* valList = PyList_New(pysize);
-      std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >::const_iterator i = self->begin();
+      std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(valList, j, swig::from(i->second));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return valList;
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiGrid_Sg__items(std::map< int,CdiGrid > *self){
-      std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >::size_type size = self->size();
-      int pysize = (size <= (std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >::size_type) INT_MAX) ? (int) size : -1;
-      SWIG_PYTHON_THREAD_BEGIN_BLOCK;
+SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiGrid_Sg__items(std::map<int,CdiGrid > *self){
+      std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >::size_type size = self->size();
+      int pysize = (size <= (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >::size_type) INT_MAX) ? (int) size : -1;
       if (pysize < 0) {
+	SWIG_PYTHON_THREAD_BEGIN_BLOCK;
 	PyErr_SetString(PyExc_OverflowError,
 			"map size not valid in python");
 	SWIG_PYTHON_THREAD_END_BLOCK;
 	return NULL;
       }    
       PyObject* itemList = PyList_New(pysize);
-      std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >::const_iterator i = self->begin();
+      std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >::const_iterator i = self->begin();
       for (int j = 0; j < pysize; ++i, ++j) {
 	PyList_SET_ITEM(itemList, j, swig::from(*i));
       }
-      SWIG_PYTHON_THREAD_END_BLOCK;
       return itemList;
     }
-SWIGINTERN bool std_map_Sl_int_Sc_CdiGrid_Sg____contains__(std::map< int,CdiGrid > *self,std::map< int,CdiGrid >::key_type const &key){
+SWIGINTERN bool std_map_Sl_int_Sc_CdiGrid_Sg____contains__(std::map<int,CdiGrid > *self,std::map<int,CdiGrid >::key_type const &key){
       return self->find(key) != self->end();
     }
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_int_Sc_CdiGrid_Sg__key_iterator(std::map< int,CdiGrid > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_int_Sc_CdiGrid_Sg__key_iterator(std::map<int,CdiGrid > *self,PyObject **PYTHON_SELF){
       return swig::make_output_key_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN swig::SwigPyIterator *std_map_Sl_int_Sc_CdiGrid_Sg__value_iterator(std::map< int,CdiGrid > *self,PyObject **PYTHON_SELF){
+SWIGINTERN swig::PySwigIterator *std_map_Sl_int_Sc_CdiGrid_Sg__value_iterator(std::map<int,CdiGrid > *self,PyObject **PYTHON_SELF){
       return swig::make_output_value_iterator(self->begin(), self->begin(), self->end(), *PYTHON_SELF);
     }
-SWIGINTERN void std_map_Sl_int_Sc_CdiGrid_Sg____setitem____SWIG_0(std::map< int,CdiGrid > *self,std::map< int,CdiGrid >::key_type const &key){
-      self->erase(key);
-    }
-SWIGINTERN void std_map_Sl_int_Sc_CdiGrid_Sg____setitem____SWIG_1(std::map< int,CdiGrid > *self,std::map< int,CdiGrid >::key_type const &key,std::map< int,CdiGrid >::mapped_type const &x){
+SWIGINTERN void std_map_Sl_int_Sc_CdiGrid_Sg____setitem__(std::map<int,CdiGrid > *self,std::map<int,CdiGrid >::key_type const &key,std::map<int,CdiGrid >::mapped_type const &x){
       (*self)[key] = x;
     }
-SWIGINTERN PyObject *std_map_Sl_int_Sc_CdiGrid_Sg__asdict(std::map< int,CdiGrid > *self){
-      return swig::traits_from< std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > > >::asdict(*self);
-    }
-SWIGINTERN void std_map_Sl_int_Sc_CdiGrid_Sg__erase__SWIG_1(std::map< int,CdiGrid > *self,std::map< int,CdiGrid >::iterator position){ self->erase(position); }
-SWIGINTERN void std_map_Sl_int_Sc_CdiGrid_Sg__erase__SWIG_2(std::map< int,CdiGrid > *self,std::map< int,CdiGrid >::iterator first,std::map< int,CdiGrid >::iterator last){ self->erase(first, last); }
 
 SWIGINTERN int
 SWIG_AsVal_bool (PyObject *obj, bool *val)
 {
-  int r;
-  if (!PyBool_Check(obj))
-    return SWIG_ERROR;
-  r = PyObject_IsTrue(obj);
-  if (r == -1)
-    return SWIG_ERROR;
-  if (val) *val = r ? true : false;
-  return SWIG_OK;
+  if (obj == Py_True) {
+    if (val) *val = true;
+    return SWIG_OK;
+  } else if (obj == Py_False) {
+    if (val) *val = false;
+    return SWIG_OK;
+  } else {
+    long v = 0;
+    int res = SWIG_AddCast(SWIG_AsVal_long (obj, val ? &v : 0));
+    if (SWIG_IsOK(res) && val) *val = v ? true : false;
+    return res;
+  }
 }
 
 
@@ -6303,8 +5277,7 @@ SWIG_AsCharArray(PyObject * obj, char *val, size_t size)
   char* cptr = 0; size_t csize = 0; int alloc = SWIG_OLDOBJ;
   int res = SWIG_AsCharPtrAndSize(obj, &cptr, &csize, &alloc);
   if (SWIG_IsOK(res)) {
-    /* special case of single char conversion when we don't need space for NUL */
-    if (size == 1 && csize == 2 && cptr && !cptr[1]) --csize;
+    if ((csize == size + 1) && cptr && !(cptr[csize-1])) --csize;
     if (csize <= size) {
       if (val) {
 	if (csize) memcpy(val, cptr, csize*sizeof(char));
@@ -6322,16 +5295,6 @@ SWIG_AsCharArray(PyObject * obj, char *val, size_t size)
 }
 
 
-size_t
-SWIG_strnlen(const char* s, size_t maxlen)
-{
-  const char *p;
-  for (p = s; maxlen-- && *p; p++)
-    ;
-  return p - s;
-}
-
-
 
 
 
@@ -6344,20 +5307,21 @@ SWIG_FromCharPtr(const char *cptr)
 #ifdef __cplusplus
 extern "C" {
 #endif
-SWIGINTERN PyObject *_wrap_delete_SwigPyIterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_delete_PySwigIterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:delete_SwigPyIterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_DISOWN |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:delete_PySwigIterator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_SwigPyIterator" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_PySwigIterator" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
   delete arg1;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -6365,22 +5329,22 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator_value(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator_value(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:SwigPyIterator_value",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:PySwigIterator_value",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_value" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_value" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
   try {
-    result = (PyObject *)((swig::SwigPyIterator const *)arg1)->value();
+    result = (PyObject *)((swig::PySwigIterator const *)arg1)->value();
   }
   catch(swig::stop_iteration &_e) {
     {
@@ -6397,31 +5361,31 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator_incr__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator_incr__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
   size_t arg2 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator_incr",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator_incr",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_incr" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_incr" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SwigPyIterator_incr" "', argument " "2"" of type '" "size_t""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PySwigIterator_incr" "', argument " "2"" of type '" "size_t""'");
   } 
   arg2 = static_cast< size_t >(val2);
   try {
-    result = (swig::SwigPyIterator *)(arg1)->incr(arg2);
+    result = (swig::PySwigIterator *)(arg1)->incr(arg2);
   }
   catch(swig::stop_iteration &_e) {
     {
@@ -6431,29 +5395,29 @@ SWIGINTERN PyObject *_wrap_SwigPyIterator_incr__SWIG_0(PyObject *SWIGUNUSEDPARM(
     }
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator_incr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator_incr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:SwigPyIterator_incr",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:PySwigIterator_incr",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_incr" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_incr" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
   try {
-    result = (swig::SwigPyIterator *)(arg1)->incr();
+    result = (swig::PySwigIterator *)(arg1)->incr();
   }
   catch(swig::stop_iteration &_e) {
     {
@@ -6463,36 +5427,36 @@ SWIGINTERN PyObject *_wrap_SwigPyIterator_incr__SWIG_1(PyObject *SWIGUNUSEDPARM(
     }
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator_incr(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator_incr(PyObject *self, PyObject *args) {
   int argc;
   PyObject *argv[3];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 1) {
     int _v;
     void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__SwigPyIterator, 0);
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__PySwigIterator, 0);
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_SwigPyIterator_incr__SWIG_1(self, args);
+      return _wrap_PySwigIterator_incr__SWIG_1(self, args);
     }
   }
   if (argc == 2) {
     int _v;
     void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__SwigPyIterator, 0);
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__PySwigIterator, 0);
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -6500,45 +5464,42 @@ SWIGINTERN PyObject *_wrap_SwigPyIterator_incr(PyObject *self, PyObject *args) {
         _v = SWIG_CheckState(res);
       }
       if (_v) {
-        return _wrap_SwigPyIterator_incr__SWIG_0(self, args);
+        return _wrap_PySwigIterator_incr__SWIG_0(self, args);
       }
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'SwigPyIterator_incr'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    swig::SwigPyIterator::incr(size_t)\n"
-    "    swig::SwigPyIterator::incr()\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'PySwigIterator_incr'.\n  Possible C/C++ prototypes are:\n    incr(size_t)\n    incr()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator_decr__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator_decr__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
   size_t arg2 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator_decr",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator_decr",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_decr" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_decr" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SwigPyIterator_decr" "', argument " "2"" of type '" "size_t""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PySwigIterator_decr" "', argument " "2"" of type '" "size_t""'");
   } 
   arg2 = static_cast< size_t >(val2);
   try {
-    result = (swig::SwigPyIterator *)(arg1)->decr(arg2);
+    result = (swig::PySwigIterator *)(arg1)->decr(arg2);
   }
   catch(swig::stop_iteration &_e) {
     {
@@ -6548,29 +5509,29 @@ SWIGINTERN PyObject *_wrap_SwigPyIterator_decr__SWIG_0(PyObject *SWIGUNUSEDPARM(
     }
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator_decr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator_decr__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:SwigPyIterator_decr",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:PySwigIterator_decr",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_decr" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_decr" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
   try {
-    result = (swig::SwigPyIterator *)(arg1)->decr();
+    result = (swig::PySwigIterator *)(arg1)->decr();
   }
   catch(swig::stop_iteration &_e) {
     {
@@ -6580,36 +5541,36 @@ SWIGINTERN PyObject *_wrap_SwigPyIterator_decr__SWIG_1(PyObject *SWIGUNUSEDPARM(
     }
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator_decr(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator_decr(PyObject *self, PyObject *args) {
   int argc;
   PyObject *argv[3];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 1) {
     int _v;
     void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__SwigPyIterator, 0);
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__PySwigIterator, 0);
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_SwigPyIterator_decr__SWIG_1(self, args);
+      return _wrap_PySwigIterator_decr__SWIG_1(self, args);
     }
   }
   if (argc == 2) {
     int _v;
     void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__SwigPyIterator, 0);
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__PySwigIterator, 0);
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -6617,48 +5578,45 @@ SWIGINTERN PyObject *_wrap_SwigPyIterator_decr(PyObject *self, PyObject *args) {
         _v = SWIG_CheckState(res);
       }
       if (_v) {
-        return _wrap_SwigPyIterator_decr__SWIG_0(self, args);
+        return _wrap_PySwigIterator_decr__SWIG_0(self, args);
       }
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'SwigPyIterator_decr'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    swig::SwigPyIterator::decr(size_t)\n"
-    "    swig::SwigPyIterator::decr()\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'PySwigIterator_decr'.\n  Possible C/C++ prototypes are:\n    decr(size_t)\n    decr()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator_distance(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator_distance(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
-  swig::SwigPyIterator *arg2 = 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  swig::PySwigIterator *arg2 = 0 ;
+  ptrdiff_t result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
   int res2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  ptrdiff_t result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator_distance",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator_distance",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_distance" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_distance" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__SwigPyIterator,  0  | 0);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__PySwigIterator,  0  | 0);
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SwigPyIterator_distance" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PySwigIterator_distance" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
   }
   if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SwigPyIterator_distance" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PySwigIterator_distance" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
   }
-  arg2 = reinterpret_cast< swig::SwigPyIterator * >(argp2);
+  arg2 = reinterpret_cast< swig::PySwigIterator * >(argp2);
   try {
-    result = ((swig::SwigPyIterator const *)arg1)->distance((swig::SwigPyIterator const &)*arg2);
+    result = ((swig::PySwigIterator const *)arg1)->distance((swig::PySwigIterator const &)*arg2);
   }
   catch(std::invalid_argument &_e) {
     SWIG_Python_Raise(SWIG_NewPointerObj((new std::invalid_argument(static_cast< const std::invalid_argument& >(_e))),SWIGTYPE_p_std__invalid_argument,SWIG_POINTER_OWN), "std::invalid_argument", SWIGTYPE_p_std__invalid_argument); SWIG_fail;
@@ -6671,34 +5629,34 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator_equal(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator_equal(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
-  swig::SwigPyIterator *arg2 = 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  swig::PySwigIterator *arg2 = 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
   int res2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator_equal",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator_equal",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_equal" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_equal" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__SwigPyIterator,  0  | 0);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__PySwigIterator,  0  | 0);
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SwigPyIterator_equal" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PySwigIterator_equal" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
   }
   if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SwigPyIterator_equal" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PySwigIterator_equal" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
   }
-  arg2 = reinterpret_cast< swig::SwigPyIterator * >(argp2);
+  arg2 = reinterpret_cast< swig::PySwigIterator * >(argp2);
   try {
-    result = (bool)((swig::SwigPyIterator const *)arg1)->equal((swig::SwigPyIterator const &)*arg2);
+    result = (bool)((swig::PySwigIterator const *)arg1)->equal((swig::PySwigIterator const &)*arg2);
   }
   catch(std::invalid_argument &_e) {
     SWIG_Python_Raise(SWIG_NewPointerObj((new std::invalid_argument(static_cast< const std::invalid_argument& >(_e))),SWIGTYPE_p_std__invalid_argument,SWIG_POINTER_OWN), "std::invalid_argument", SWIGTYPE_p_std__invalid_argument); SWIG_fail;
@@ -6711,42 +5669,42 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator_copy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator_copy(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:SwigPyIterator_copy",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:PySwigIterator_copy",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_copy" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_copy" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
-  result = (swig::SwigPyIterator *)((swig::SwigPyIterator const *)arg1)->copy();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  result = (swig::PySwigIterator *)((swig::PySwigIterator const *)arg1)->copy();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator_next(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator_next(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:SwigPyIterator_next",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:PySwigIterator_next",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_next" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_next" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
   try {
     result = (PyObject *)(arg1)->next();
   }
@@ -6765,22 +5723,22 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator___next__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator_previous(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:SwigPyIterator___next__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:PySwigIterator_previous",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___next__" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_previous" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
   try {
-    result = (PyObject *)(arg1)->__next__();
+    result = (PyObject *)(arg1)->previous();
   }
   catch(swig::stop_iteration &_e) {
     {
@@ -6797,63 +5755,31 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator_previous(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator_advance(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  ptrdiff_t arg2 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
+  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:SwigPyIterator_previous",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator_advance",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_previous" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator_advance" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
-  try {
-    result = (PyObject *)(arg1)->previous();
-  }
-  catch(swig::stop_iteration &_e) {
-    {
-      (void)_e;
-      SWIG_SetErrorObj(PyExc_StopIteration, SWIG_Py_Void());
-      SWIG_fail;
-    }
-  }
-  
-  resultobj = result;
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_SwigPyIterator_advance(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
-  ptrdiff_t arg2 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  ptrdiff_t val2 ;
-  int ecode2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator_advance",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator_advance" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
-  }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SwigPyIterator_advance" "', argument " "2"" of type '" "ptrdiff_t""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PySwigIterator_advance" "', argument " "2"" of type '" "ptrdiff_t""'");
   } 
   arg2 = static_cast< ptrdiff_t >(val2);
   try {
-    result = (swig::SwigPyIterator *)(arg1)->advance(arg2);
+    result = (swig::PySwigIterator *)(arg1)->advance(arg2);
   }
   catch(swig::stop_iteration &_e) {
     {
@@ -6863,40 +5789,40 @@ SWIGINTERN PyObject *_wrap_SwigPyIterator_advance(PyObject *SWIGUNUSEDPARM(self)
     }
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator___eq__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator___eq__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
-  swig::SwigPyIterator *arg2 = 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  swig::PySwigIterator *arg2 = 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
   int res2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator___eq__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator___eq__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___eq__" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator___eq__" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__SwigPyIterator,  0  | 0);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__PySwigIterator,  0  | 0);
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SwigPyIterator___eq__" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PySwigIterator___eq__" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
   }
   if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SwigPyIterator___eq__" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PySwigIterator___eq__" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
   }
-  arg2 = reinterpret_cast< swig::SwigPyIterator * >(argp2);
-  result = (bool)((swig::SwigPyIterator const *)arg1)->operator ==((swig::SwigPyIterator const &)*arg2);
+  arg2 = reinterpret_cast< swig::PySwigIterator * >(argp2);
+  result = (bool)((swig::PySwigIterator const *)arg1)->operator ==((swig::PySwigIterator const &)*arg2);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -6904,33 +5830,33 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator___ne__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator___ne__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
-  swig::SwigPyIterator *arg2 = 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  swig::PySwigIterator *arg2 = 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
   int res2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator___ne__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator___ne__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___ne__" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator___ne__" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__SwigPyIterator,  0  | 0);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__PySwigIterator,  0  | 0);
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SwigPyIterator___ne__" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PySwigIterator___ne__" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
   }
   if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SwigPyIterator___ne__" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PySwigIterator___ne__" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
   }
-  arg2 = reinterpret_cast< swig::SwigPyIterator * >(argp2);
-  result = (bool)((swig::SwigPyIterator const *)arg1)->operator !=((swig::SwigPyIterator const &)*arg2);
+  arg2 = reinterpret_cast< swig::PySwigIterator * >(argp2);
+  result = (bool)((swig::PySwigIterator const *)arg1)->operator !=((swig::PySwigIterator const &)*arg2);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -6938,31 +5864,34 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator___iadd__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator___iadd__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
   ptrdiff_t arg2 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator___iadd__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_DISOWN |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator___iadd__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___iadd__" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator___iadd__" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SwigPyIterator___iadd__" "', argument " "2"" of type '" "ptrdiff_t""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PySwigIterator___iadd__" "', argument " "2"" of type '" "ptrdiff_t""'");
   } 
   arg2 = static_cast< ptrdiff_t >(val2);
   try {
-    result = (swig::SwigPyIterator *) &(arg1)->operator +=(arg2);
+    {
+      swig::PySwigIterator &_result_ref = (arg1)->operator +=(arg2);
+      result = (swig::PySwigIterator *) &_result_ref;
+    }
   }
   catch(swig::stop_iteration &_e) {
     {
@@ -6972,38 +5901,41 @@ SWIGINTERN PyObject *_wrap_SwigPyIterator___iadd__(PyObject *SWIGUNUSEDPARM(self
     }
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator___isub__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator___isub__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
   ptrdiff_t arg2 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator___isub__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_DISOWN |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator___isub__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___isub__" "', argument " "1"" of type '" "swig::SwigPyIterator *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator___isub__" "', argument " "1"" of type '" "swig::PySwigIterator *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SwigPyIterator___isub__" "', argument " "2"" of type '" "ptrdiff_t""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PySwigIterator___isub__" "', argument " "2"" of type '" "ptrdiff_t""'");
   } 
   arg2 = static_cast< ptrdiff_t >(val2);
   try {
-    result = (swig::SwigPyIterator *) &(arg1)->operator -=(arg2);
+    {
+      swig::PySwigIterator &_result_ref = (arg1)->operator -=(arg2);
+      result = (swig::PySwigIterator *) &_result_ref;
+    }
   }
   catch(swig::stop_iteration &_e) {
     {
@@ -7013,38 +5945,38 @@ SWIGINTERN PyObject *_wrap_SwigPyIterator___isub__(PyObject *SWIGUNUSEDPARM(self
     }
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator___add__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator___add__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
   ptrdiff_t arg2 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator___add__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator___add__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___add__" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator___add__" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SwigPyIterator___add__" "', argument " "2"" of type '" "ptrdiff_t""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PySwigIterator___add__" "', argument " "2"" of type '" "ptrdiff_t""'");
   } 
   arg2 = static_cast< ptrdiff_t >(val2);
   try {
-    result = (swig::SwigPyIterator *)((swig::SwigPyIterator const *)arg1)->operator +(arg2);
+    result = (swig::PySwigIterator *)((swig::PySwigIterator const *)arg1)->operator +(arg2);
   }
   catch(swig::stop_iteration &_e) {
     {
@@ -7054,38 +5986,38 @@ SWIGINTERN PyObject *_wrap_SwigPyIterator___add__(PyObject *SWIGUNUSEDPARM(self)
     }
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator___sub____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator___sub____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
   ptrdiff_t arg2 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator___sub__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator___sub__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___sub__" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator___sub__" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "SwigPyIterator___sub__" "', argument " "2"" of type '" "ptrdiff_t""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "PySwigIterator___sub__" "', argument " "2"" of type '" "ptrdiff_t""'");
   } 
   arg2 = static_cast< ptrdiff_t >(val2);
   try {
-    result = (swig::SwigPyIterator *)((swig::SwigPyIterator const *)arg1)->operator -(arg2);
+    result = (swig::PySwigIterator *)((swig::PySwigIterator const *)arg1)->operator -(arg2);
   }
   catch(swig::stop_iteration &_e) {
     {
@@ -7095,40 +6027,40 @@ SWIGINTERN PyObject *_wrap_SwigPyIterator___sub____SWIG_0(PyObject *SWIGUNUSEDPA
     }
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator___sub____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator___sub____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  swig::SwigPyIterator *arg1 = (swig::SwigPyIterator *) 0 ;
-  swig::SwigPyIterator *arg2 = 0 ;
+  swig::PySwigIterator *arg1 = (swig::PySwigIterator *) 0 ;
+  swig::PySwigIterator *arg2 = 0 ;
+  ptrdiff_t result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
   int res2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  ptrdiff_t result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:SwigPyIterator___sub__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__SwigPyIterator, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:PySwigIterator___sub__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_swig__PySwigIterator, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "SwigPyIterator___sub__" "', argument " "1"" of type '" "swig::SwigPyIterator const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "PySwigIterator___sub__" "', argument " "1"" of type '" "swig::PySwigIterator const *""'"); 
   }
-  arg1 = reinterpret_cast< swig::SwigPyIterator * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__SwigPyIterator,  0  | 0);
+  arg1 = reinterpret_cast< swig::PySwigIterator * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_swig__PySwigIterator,  0  | 0);
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "SwigPyIterator___sub__" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "PySwigIterator___sub__" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
   }
   if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "SwigPyIterator___sub__" "', argument " "2"" of type '" "swig::SwigPyIterator const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "PySwigIterator___sub__" "', argument " "2"" of type '" "swig::PySwigIterator const &""'"); 
   }
-  arg2 = reinterpret_cast< swig::SwigPyIterator * >(argp2);
-  result = ((swig::SwigPyIterator const *)arg1)->operator -((swig::SwigPyIterator const &)*arg2);
+  arg2 = reinterpret_cast< swig::PySwigIterator * >(argp2);
+  result = ((swig::PySwigIterator const *)arg1)->operator -((swig::PySwigIterator const &)*arg2);
   resultobj = SWIG_From_ptrdiff_t(static_cast< ptrdiff_t >(result));
   return resultobj;
 fail:
@@ -7136,33 +6068,33 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_SwigPyIterator___sub__(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_PySwigIterator___sub__(PyObject *self, PyObject *args) {
   int argc;
   PyObject *argv[3];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
     void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__SwigPyIterator, 0);
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__PySwigIterator, 0);
     _v = SWIG_CheckState(res);
     if (_v) {
-      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_swig__SwigPyIterator, 0);
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_swig__PySwigIterator, 0);
       _v = SWIG_CheckState(res);
       if (_v) {
-        return _wrap_SwigPyIterator___sub____SWIG_1(self, args);
+        return _wrap_PySwigIterator___sub____SWIG_1(self, args);
       }
     }
   }
   if (argc == 2) {
     int _v;
     void *vptr = 0;
-    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__SwigPyIterator, 0);
+    int res = SWIG_ConvertPtr(argv[0], &vptr, SWIGTYPE_p_swig__PySwigIterator, 0);
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -7170,7 +6102,7 @@ SWIGINTERN PyObject *_wrap_SwigPyIterator___sub__(PyObject *self, PyObject *args
         _v = SWIG_CheckState(res);
       }
       if (_v) {
-        return _wrap_SwigPyIterator___sub____SWIG_0(self, args);
+        return _wrap_PySwigIterator___sub____SWIG_0(self, args);
       }
     }
   }
@@ -7181,31 +6113,31 @@ fail:
 }
 
 
-SWIGINTERN PyObject *SwigPyIterator_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *PySwigIterator_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
-  SWIG_TypeNewClientData(SWIGTYPE_p_swig__SwigPyIterator, SWIG_NewClientData(obj));
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_swig__PySwigIterator, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
 
 SWIGINTERN PyObject *_wrap_IntVector_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:IntVector_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_iterator" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_iterator" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  result = (swig::SwigPyIterator *)std_vector_Sl_int_Sg__iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = (swig::PySwigIterator *)std_vector_Sl_int_Sg__iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -7214,41 +6146,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_IntVector___nonzero__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
   bool result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:IntVector___nonzero__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___nonzero__" "', argument " "1"" of type '" "std::vector< int > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  result = (bool)std_vector_Sl_int_Sg____nonzero__((std::vector< int > const *)arg1);
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_IntVector___bool__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:IntVector___bool__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:IntVector___nonzero__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___bool__" "', argument " "1"" of type '" "std::vector< int > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___nonzero__" "', argument " "1"" of type '" "std::vector<int > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  result = (bool)std_vector_Sl_int_Sg____bool__((std::vector< int > const *)arg1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = (bool)std_vector_Sl_int_Sg____nonzero__((std::vector<int > const *)arg1);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -7258,19 +6168,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_IntVector___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< int >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:IntVector___len__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___len__" "', argument " "1"" of type '" "std::vector< int > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___len__" "', argument " "1"" of type '" "std::vector<int > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  result = std_vector_Sl_int_Sg____len__((std::vector< int > const *)arg1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = std_vector_Sl_int_Sg____len__((std::vector<int > const *)arg1);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -7280,20 +6190,20 @@ fail:
 
 SWIGINTERN PyObject *_wrap_IntVector_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::value_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< int >::value_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:IntVector_pop",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_pop" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_pop" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
   try {
-    result = (std::vector< int >::value_type)std_vector_Sl_int_Sg__pop(arg1);
+    result = (std::vector<int >::value_type)std_vector_Sl_int_Sg__pop(arg1);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
@@ -7308,9 +6218,10 @@ fail:
 
 SWIGINTERN PyObject *_wrap_IntVector___getslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::difference_type arg2 ;
-  std::vector< int >::difference_type arg3 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::difference_type arg2 ;
+  std::vector<int >::difference_type arg3 ;
+  std::vector<int,std::allocator<int > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -7320,47 +6231,43 @@ SWIGINTERN PyObject *_wrap_IntVector___getslice__(PyObject *SWIGUNUSEDPARM(self)
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
-  std::vector< int,std::allocator< int > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:IntVector___getslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___getslice__" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___getslice__" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector___getslice__" "', argument " "2"" of type '" "std::vector< int >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector___getslice__" "', argument " "2"" of type '" "std::vector<int >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< int >::difference_type >(val2);
+  arg2 = static_cast< std::vector<int >::difference_type >(val2);
   ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector___getslice__" "', argument " "3"" of type '" "std::vector< int >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector___getslice__" "', argument " "3"" of type '" "std::vector<int >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< int >::difference_type >(val3);
+  arg3 = static_cast< std::vector<int >::difference_type >(val3);
   try {
-    result = (std::vector< int,std::allocator< int > > *)std_vector_Sl_int_Sg____getslice__(arg1,arg2,arg3);
+    result = (std::vector<int,std::allocator<int > > *)std_vector_Sl_int_Sg____getslice__(arg1,arg2,arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, SWIG_POINTER_OWN |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector___setslice____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector___setslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::difference_type arg2 ;
-  std::vector< int >::difference_type arg3 ;
-  std::vector< int,std::allocator< int > > *arg4 = 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::difference_type arg2 ;
+  std::vector<int >::difference_type arg3 ;
+  std::vector<int,std::allocator<int > > *arg4 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -7374,34 +6281,34 @@ SWIGINTERN PyObject *_wrap_IntVector___setslice____SWIG_0(PyObject *SWIGUNUSEDPA
   PyObject * obj3 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOOO:IntVector___setslice__",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___setslice__" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___setslice__" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector___setslice__" "', argument " "2"" of type '" "std::vector< int >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector___setslice__" "', argument " "2"" of type '" "std::vector<int >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< int >::difference_type >(val2);
+  arg2 = static_cast< std::vector<int >::difference_type >(val2);
   ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector___setslice__" "', argument " "3"" of type '" "std::vector< int >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector___setslice__" "', argument " "3"" of type '" "std::vector<int >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< int >::difference_type >(val3);
+  arg3 = static_cast< std::vector<int >::difference_type >(val3);
   {
-    std::vector<int,std::allocator< int > > *ptr = (std::vector<int,std::allocator< int > > *)0;
+    std::vector<int,std::allocator<int > > *ptr = (std::vector<int,std::allocator<int > > *)0;
     res4 = swig::asptr(obj3, &ptr);
     if (!SWIG_IsOK(res4)) {
-      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "IntVector___setslice__" "', argument " "4"" of type '" "std::vector< int,std::allocator< int > > const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "IntVector___setslice__" "', argument " "4"" of type '" "std::vector<int,std::allocator<int > > const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IntVector___setslice__" "', argument " "4"" of type '" "std::vector< int,std::allocator< int > > const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IntVector___setslice__" "', argument " "4"" of type '" "std::vector<int,std::allocator<int > > const &""'"); 
     }
     arg4 = ptr;
   }
   try {
-    std_vector_Sl_int_Sg____setslice____SWIG_0(arg1,arg2,arg3,(std::vector< int,std::allocator< int > > const &)*arg4);
+    std_vector_Sl_int_Sg____setslice__(arg1,arg2,arg3,(std::vector<int,std::allocator<int > > const &)*arg4);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
@@ -7419,11 +6326,11 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector___setslice____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector___delslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::difference_type arg2 ;
-  std::vector< int >::difference_type arg3 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::difference_type arg2 ;
+  std::vector<int >::difference_type arg3 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -7434,31 +6341,28 @@ SWIGINTERN PyObject *_wrap_IntVector___setslice____SWIG_1(PyObject *SWIGUNUSEDPA
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:IntVector___setslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OOO:IntVector___delslice__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___setslice__" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___delslice__" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector___setslice__" "', argument " "2"" of type '" "std::vector< int >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector___delslice__" "', argument " "2"" of type '" "std::vector<int >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< int >::difference_type >(val2);
+  arg2 = static_cast< std::vector<int >::difference_type >(val2);
   ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector___setslice__" "', argument " "3"" of type '" "std::vector< int >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector___delslice__" "', argument " "3"" of type '" "std::vector<int >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< int >::difference_type >(val3);
+  arg3 = static_cast< std::vector<int >::difference_type >(val3);
   try {
-    std_vector_Sl_int_Sg____setslice____SWIG_0(arg1,arg2,arg3);
+    std_vector_Sl_int_Sg____delslice__(arg1,arg2,arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -7467,110 +6371,34 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector___setslice__(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[5];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 3) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        {
-          int res = SWIG_AsVal_ptrdiff_t(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          return _wrap_IntVector___setslice____SWIG_1(self, args);
-        }
-      }
-    }
-  }
-  if (argc == 4) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        {
-          int res = SWIG_AsVal_ptrdiff_t(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          int res = swig::asptr(argv[3], (std::vector<int,std::allocator< int > >**)(0));
-          _v = SWIG_CheckState(res);
-          if (_v) {
-            return _wrap_IntVector___setslice____SWIG_0(self, args);
-          }
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'IntVector___setslice__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< int >::__setslice__(std::vector< int >::difference_type,std::vector< int >::difference_type,std::vector< int,std::allocator< int > > const &)\n"
-    "    std::vector< int >::__setslice__(std::vector< int >::difference_type,std::vector< int >::difference_type)\n");
-  return 0;
-}
-
-
-SWIGINTERN PyObject *_wrap_IntVector___delslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector___delitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::difference_type arg2 ;
-  std::vector< int >::difference_type arg3 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::difference_type arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
   int ecode2 = 0 ;
-  ptrdiff_t val3 ;
-  int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:IntVector___delslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:IntVector___delitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___delslice__" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___delitem__" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector___delslice__" "', argument " "2"" of type '" "std::vector< int >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector___delitem__" "', argument " "2"" of type '" "std::vector<int >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< int >::difference_type >(val2);
-  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector___delslice__" "', argument " "3"" of type '" "std::vector< int >::difference_type""'");
-  } 
-  arg3 = static_cast< std::vector< int >::difference_type >(val3);
+  arg2 = static_cast< std::vector<int >::difference_type >(val2);
   try {
-    std_vector_Sl_int_Sg____delslice__(arg1,arg2,arg3);
+    std_vector_Sl_int_Sg____delitem__(arg1,arg2);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -7579,10 +6407,11 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector___delitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::difference_type arg2 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::difference_type arg2 ;
+  std::vector<int >::value_type *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -7590,751 +6419,607 @@ SWIGINTERN PyObject *_wrap_IntVector___delitem____SWIG_0(PyObject *SWIGUNUSEDPAR
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:IntVector___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:IntVector___getitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___delitem__" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___getitem__" "', argument " "1"" of type '" "std::vector<int > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector___delitem__" "', argument " "2"" of type '" "std::vector< int >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector___getitem__" "', argument " "2"" of type '" "std::vector<int >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< int >::difference_type >(val2);
+  arg2 = static_cast< std::vector<int >::difference_type >(val2);
   try {
-    std_vector_Sl_int_Sg____delitem____SWIG_0(arg1,arg2);
+    {
+      std::vector<int >::value_type const &_result_ref = std_vector_Sl_int_Sg____getitem__((std::vector<int > const *)arg1,arg2);
+      result = (std::vector<int >::value_type *) &_result_ref;
+    }
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
-  resultobj = SWIG_Py_Void();
+  resultobj = SWIG_From_int(static_cast< int >(*result));
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector___getitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector___setitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::difference_type arg2 ;
+  std::vector<int >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  std::vector<int >::value_type temp3 ;
+  int val3 ;
+  int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::vector< int,std::allocator< int > > *result = 0 ;
+  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:IntVector___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OOO:IntVector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___getitem__" "', argument " "1"" of type '" "std::vector< int > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector___getitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___setitem__" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector___setitem__" "', argument " "2"" of type '" "std::vector<int >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector<int >::difference_type >(val2);
+  ecode3 = SWIG_AsVal_int(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector___setitem__" "', argument " "3"" of type '" "std::vector<int >::value_type""'");
+  } 
+  temp3 = static_cast< std::vector<int >::value_type >(val3);
+  arg3 = &temp3;
   try {
-    result = (std::vector< int,std::allocator< int > > *)std_vector_Sl_int_Sg____getitem____SWIG_0(arg1,arg2);
+    std_vector_Sl_int_Sg____setitem__(arg1,arg2,(int const &)*arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, SWIG_POINTER_OWN |  0 );
+  resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
-  std::vector< int,std::allocator< int > > *arg3 = 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::value_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  int res3 = SWIG_OLDOBJ ;
+  std::vector<int >::value_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:IntVector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:IntVector_append",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___setitem__" "', argument " "1"" of type '" "std::vector< int > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector___setitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_append" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector_append" "', argument " "2"" of type '" "std::vector<int >::value_type""'");
+  } 
+  temp2 = static_cast< std::vector<int >::value_type >(val2);
+  arg2 = &temp2;
+  std_vector_Sl_int_Sg__append(arg1,(int const &)*arg2);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_IntVector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<int > *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)":new_IntVector")) SWIG_fail;
+  result = (std::vector<int > *)new std::vector<int >();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_IntVector__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<int > *arg1 = 0 ;
+  std::vector<int > *result = 0 ;
+  int res1 = SWIG_OLDOBJ ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:new_IntVector",&obj0)) SWIG_fail;
   {
-    std::vector<int,std::allocator< int > > *ptr = (std::vector<int,std::allocator< int > > *)0;
-    res3 = swig::asptr(obj2, &ptr);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "IntVector___setitem__" "', argument " "3"" of type '" "std::vector< int,std::allocator< int > > const &""'"); 
+    std::vector<int,std::allocator<int > > *ptr = (std::vector<int,std::allocator<int > > *)0;
+    res1 = swig::asptr(obj0, &ptr);
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_IntVector" "', argument " "1"" of type '" "std::vector<int > const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IntVector___setitem__" "', argument " "3"" of type '" "std::vector< int,std::allocator< int > > const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_IntVector" "', argument " "1"" of type '" "std::vector<int > const &""'"); 
     }
-    arg3 = ptr;
-  }
-  try {
-    std_vector_Sl_int_Sg____setitem____SWIG_0(arg1,arg2,(std::vector< int,std::allocator< int > > const &)*arg3);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
-  }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+    arg1 = ptr;
   }
-  
-  resultobj = SWIG_Py_Void();
-  if (SWIG_IsNewObj(res3)) delete arg3;
+  result = (std::vector<int > *)new std::vector<int >((std::vector<int > const &)*arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, SWIG_POINTER_NEW |  0 );
+  if (SWIG_IsNewObj(res1)) delete arg1;
   return resultobj;
 fail:
-  if (SWIG_IsNewObj(res3)) delete arg3;
+  if (SWIG_IsNewObj(res1)) delete arg1;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:IntVector___setitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_empty",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___setitem__" "', argument " "1"" of type '" "std::vector< int > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector___setitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
-  }
-  try {
-    std_vector_Sl_int_Sg____setitem____SWIG_1(arg1,arg2);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_empty" "', argument " "1"" of type '" "std::vector<int > const *""'"); 
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
-  
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = (bool)((std::vector<int > const *)arg1)->empty();
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector___delitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:IntVector___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_size",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___delitem__" "', argument " "1"" of type '" "std::vector< int > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector___delitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
-  }
-  try {
-    std_vector_Sl_int_Sg____delitem____SWIG_1(arg1,arg2);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
-  }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_size" "', argument " "1"" of type '" "std::vector<int > const *""'"); 
   }
-  
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = ((std::vector<int > const *)arg1)->size();
+  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector___delitem__(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[3];
-  int ii;
+SWIGINTERN PyObject *_wrap_IntVector_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_IntVector___delitem____SWIG_1(self, args);
-      }
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_IntVector___delitem____SWIG_0(self, args);
-      }
-    }
+  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_clear",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_clear" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  (arg1)->clear();
+  resultobj = SWIG_Py_Void();
+  return resultobj;
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'IntVector___delitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< int >::__delitem__(std::vector< int >::difference_type)\n"
-    "    std::vector< int >::__delitem__(PySliceObject *)\n");
-  return 0;
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector___getitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::difference_type arg2 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int > *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  ptrdiff_t val2 ;
-  int ecode2 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::vector< int >::value_type *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:IntVector___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:IntVector_swap",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___getitem__" "', argument " "1"" of type '" "std::vector< int > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_swap" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector___getitem__" "', argument " "2"" of type '" "std::vector< int >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< int >::difference_type >(val2);
-  try {
-    result = (std::vector< int >::value_type *) &std_vector_Sl_int_Sg____getitem____SWIG_1((std::vector< int > const *)arg1,arg2);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t,  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IntVector_swap" "', argument " "2"" of type '" "std::vector<int > &""'"); 
   }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IntVector_swap" "', argument " "2"" of type '" "std::vector<int > &""'"); 
   }
-  
-  resultobj = SWIG_From_int(static_cast< int >(*result));
+  arg2 = reinterpret_cast< std::vector<int > * >(argp2);
+  (arg1)->swap(*arg2);
+  resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector___getitem__(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[3];
-  int ii;
+SWIGINTERN PyObject *_wrap_IntVector_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  SwigValueWrapper<std::allocator<int > > result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_IntVector___getitem____SWIG_0(self, args);
-      }
-    }
-  }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_IntVector___getitem____SWIG_1(self, args);
-      }
-    }
+  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_get_allocator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_get_allocator" "', argument " "1"" of type '" "std::vector<int > const *""'"); 
   }
-  
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = ((std::vector<int > const *)arg1)->get_allocator();
+  resultobj = SWIG_NewPointerObj((new std::vector<int >::allocator_type(static_cast< const std::vector<int >::allocator_type& >(result))), SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t__allocator_type, SWIG_POINTER_OWN |  0 );
+  return resultobj;
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'IntVector___getitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< int >::__getitem__(PySliceObject *)\n"
-    "    std::vector< int >::__getitem__(std::vector< int >::difference_type) const\n");
-  return 0;
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector___setitem____SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector_begin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::difference_type arg2 ;
-  std::vector< int >::value_type *arg3 = 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  ptrdiff_t val2 ;
-  int ecode2 = 0 ;
-  std::vector< int >::value_type temp3 ;
-  int val3 ;
-  int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:IntVector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector___setitem__" "', argument " "1"" of type '" "std::vector< int > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector___setitem__" "', argument " "2"" of type '" "std::vector< int >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< int >::difference_type >(val2);
-  ecode3 = SWIG_AsVal_int(obj2, &val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector___setitem__" "', argument " "3"" of type '" "std::vector< int >::value_type""'");
-  } 
-  temp3 = static_cast< std::vector< int >::value_type >(val3);
-  arg3 = &temp3;
-  try {
-    std_vector_Sl_int_Sg____setitem____SWIG_2(arg1,arg2,(int const &)*arg3);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_begin" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = (arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<int >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_IntVector_begin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  resultobj = SWIG_Py_Void();
+  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_begin" "', argument " "1"" of type '" "std::vector<int > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = ((std::vector<int > const *)arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<int >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector___setitem__(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector_begin(PyObject *self, PyObject *args) {
   int argc;
-  PyObject *argv[4];
+  PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_IntVector___setitem____SWIG_1(self, args);
-      }
-    }
-  }
-  if (argc == 3) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        int res = swig::asptr(argv[2], (std::vector<int,std::allocator< int > >**)(0));
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_IntVector___setitem____SWIG_0(self, args);
-        }
-      }
+      return _wrap_IntVector_begin__SWIG_0(self, args);
     }
   }
-  if (argc == 3) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        {
-          int res = SWIG_AsVal_int(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          return _wrap_IntVector___setitem____SWIG_2(self, args);
-        }
-      }
+      return _wrap_IntVector_begin__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'IntVector___setitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< int >::__setitem__(PySliceObject *,std::vector< int,std::allocator< int > > const &)\n"
-    "    std::vector< int >::__setitem__(PySliceObject *)\n"
-    "    std::vector< int >::__setitem__(std::vector< int >::difference_type,std::vector< int >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'IntVector_begin'.\n  Possible C/C++ prototypes are:\n    begin()\n    begin()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector_end__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::value_type *arg2 = 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::vector< int >::value_type temp2 ;
-  int val2 ;
-  int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:IntVector_append",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_append" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_end" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  ecode2 = SWIG_AsVal_int(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector_append" "', argument " "2"" of type '" "std::vector< int >::value_type""'");
-  } 
-  temp2 = static_cast< std::vector< int >::value_type >(val2);
-  arg2 = &temp2;
-  std_vector_Sl_int_Sg__append(arg1,(int const &)*arg2);
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = (arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<int >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_IntVector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector_end__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *result = 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)":new_IntVector")) SWIG_fail;
-  result = (std::vector< int > *)new std::vector< int >();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, SWIG_POINTER_NEW |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_end" "', argument " "1"" of type '" "std::vector<int > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = ((std::vector<int > const *)arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<int >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_IntVector__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< int > *arg1 = 0 ;
-  int res1 = SWIG_OLDOBJ ;
-  PyObject * obj0 = 0 ;
-  std::vector< int > *result = 0 ;
+SWIGINTERN PyObject *_wrap_IntVector_end(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:new_IntVector",&obj0)) SWIG_fail;
-  {
-    std::vector<int,std::allocator< int > > *ptr = (std::vector<int,std::allocator< int > > *)0;
-    res1 = swig::asptr(obj0, &ptr);
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_IntVector" "', argument " "1"" of type '" "std::vector< int > const &""'"); 
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_IntVector_end__SWIG_0(self, args);
     }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_IntVector" "', argument " "1"" of type '" "std::vector< int > const &""'"); 
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_IntVector_end__SWIG_1(self, args);
     }
-    arg1 = ptr;
   }
-  result = (std::vector< int > *)new std::vector< int >((std::vector< int > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, SWIG_POINTER_NEW |  0 );
-  if (SWIG_IsNewObj(res1)) delete arg1;
-  return resultobj;
+  
 fail:
-  if (SWIG_IsNewObj(res1)) delete arg1;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'IntVector_end'.\n  Possible C/C++ prototypes are:\n    end()\n    end()\n");
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector_rbegin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_empty",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_empty" "', argument " "1"" of type '" "std::vector< int > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_rbegin" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  result = (bool)((std::vector< int > const *)arg1)->empty();
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = (arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<int >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector_rbegin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::const_reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< int >::size_type result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_size",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_size" "', argument " "1"" of type '" "std::vector< int > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_rbegin" "', argument " "1"" of type '" "std::vector<int > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  result = ((std::vector< int > const *)arg1)->size();
-  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = ((std::vector<int > const *)arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<int >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector_rbegin(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_IntVector_rbegin__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_IntVector_rbegin__SWIG_1(self, args);
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'IntVector_rbegin'.\n  Possible C/C++ prototypes are:\n    rbegin()\n    rbegin()\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_IntVector_rend__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_clear",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_clear" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_rend" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  (arg1)->clear();
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = (arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<int >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_IntVector_rend__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int > *arg2 = 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::const_reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:IntVector_swap",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_swap" "', argument " "1"" of type '" "std::vector< int > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t,  0 );
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "IntVector_swap" "', argument " "2"" of type '" "std::vector< int > &""'"); 
-  }
-  if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "IntVector_swap" "', argument " "2"" of type '" "std::vector< int > &""'"); 
-  }
-  arg2 = reinterpret_cast< std::vector< int > * >(argp2);
-  (arg1)->swap(*arg2);
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_IntVector_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  SwigValueWrapper< std::allocator< int > > result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_get_allocator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_get_allocator" "', argument " "1"" of type '" "std::vector< int > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_rend" "', argument " "1"" of type '" "std::vector<int > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  result = ((std::vector< int > const *)arg1)->get_allocator();
-  resultobj = SWIG_NewPointerObj((new std::vector< int >::allocator_type(static_cast< const std::vector< int >::allocator_type& >(result))), SWIGTYPE_p_std__allocatorT_int_t, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = ((std::vector<int > const *)arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<int >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_IntVector_begin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< int >::iterator result;
+SWIGINTERN PyObject *_wrap_IntVector_rend(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_begin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_begin" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  result = (arg1)->begin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< int >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_IntVector_end(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< int >::iterator result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_end",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_end" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_IntVector_rend__SWIG_0(self, args);
+    }
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  result = (arg1)->end();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< int >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_IntVector_rbegin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< int >::reverse_iterator result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_rbegin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_rbegin" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_IntVector_rend__SWIG_1(self, args);
+    }
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  result = (arg1)->rbegin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< int >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_IntVector_rend(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< int >::reverse_iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:IntVector_rend",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_rend" "', argument " "1"" of type '" "std::vector< int > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  result = (arg1)->rend();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< int >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'IntVector_rend'.\n  Possible C/C++ prototypes are:\n    rend()\n    rend()\n");
   return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_new_IntVector__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int >::size_type arg1 ;
+  std::vector<int >::size_type arg1 ;
+  std::vector<int > *result = 0 ;
   size_t val1 ;
   int ecode1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< int > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:new_IntVector",&obj0)) SWIG_fail;
   ecode1 = SWIG_AsVal_size_t(obj0, &val1);
   if (!SWIG_IsOK(ecode1)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_IntVector" "', argument " "1"" of type '" "std::vector< int >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_IntVector" "', argument " "1"" of type '" "std::vector<int >::size_type""'");
   } 
-  arg1 = static_cast< std::vector< int >::size_type >(val1);
-  result = (std::vector< int > *)new std::vector< int >(arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, SWIG_POINTER_NEW |  0 );
+  arg1 = static_cast< std::vector<int >::size_type >(val1);
+  result = (std::vector<int > *)new std::vector<int >(arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -8343,17 +7028,17 @@ fail:
 
 SWIGINTERN PyObject *_wrap_IntVector_pop_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:IntVector_pop_back",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_pop_back" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_pop_back" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
   (arg1)->pop_back();
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -8364,8 +7049,8 @@ fail:
 
 SWIGINTERN PyObject *_wrap_IntVector_resize__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::size_type arg2 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::size_type arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
@@ -8374,16 +7059,16 @@ SWIGINTERN PyObject *_wrap_IntVector_resize__SWIG_0(PyObject *SWIGUNUSEDPARM(sel
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:IntVector_resize",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_resize" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_resize" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector_resize" "', argument " "2"" of type '" "std::vector< int >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector_resize" "', argument " "2"" of type '" "std::vector<int >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< int >::size_type >(val2);
+  arg2 = static_cast< std::vector<int >::size_type >(val2);
   (arg1)->resize(arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -8394,36 +7079,36 @@ fail:
 
 SWIGINTERN PyObject *_wrap_IntVector_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::iterator arg2 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::iterator arg2 ;
+  std::vector<int >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::vector< int >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:IntVector_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_erase" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_erase" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_erase" "', argument " "2"" of type '" "std::vector< int >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_erase" "', argument " "2"" of type '" "std::vector<int >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< int >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< int >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<int >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<int >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_erase" "', argument " "2"" of type '" "std::vector< int >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_erase" "', argument " "2"" of type '" "std::vector<int >::iterator""'");
     }
   }
-  result = std_vector_Sl_int_Sg__erase__SWIG_0(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< int >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->erase(arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<int >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
@@ -8432,51 +7117,51 @@ fail:
 
 SWIGINTERN PyObject *_wrap_IntVector_erase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::iterator arg2 ;
-  std::vector< int >::iterator arg3 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::iterator arg2 ;
+  std::vector<int >::iterator arg3 ;
+  std::vector<int >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
-  swig::SwigPyIterator *iter3 = 0 ;
+  swig::PySwigIterator *iter3 = 0 ;
   int res3 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
-  std::vector< int >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:IntVector_erase",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_erase" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_erase" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_erase" "', argument " "2"" of type '" "std::vector< int >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_erase" "', argument " "2"" of type '" "std::vector<int >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< int >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< int >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<int >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<int >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_erase" "', argument " "2"" of type '" "std::vector< int >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_erase" "', argument " "2"" of type '" "std::vector<int >::iterator""'");
     }
   }
-  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::SwigPyIterator::descriptor(), 0);
+  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res3) || !iter3) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_erase" "', argument " "3"" of type '" "std::vector< int >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_erase" "', argument " "3"" of type '" "std::vector<int >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< int >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< int >::iterator > *>(iter3);
+    swig::PySwigIterator_T<std::vector<int >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<int >::iterator > *>(iter3);
     if (iter_t) {
       arg3 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_erase" "', argument " "3"" of type '" "std::vector< int >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_erase" "', argument " "3"" of type '" "std::vector<int >::iterator""'");
     }
   }
-  result = std_vector_Sl_int_Sg__erase__SWIG_1(arg1,arg2,arg3);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< int >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->erase(arg2,arg3);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<int >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
@@ -8489,18 +7174,18 @@ SWIGINTERN PyObject *_wrap_IntVector_erase(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< int >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<int >::iterator > *>(iter) != 0));
       if (_v) {
         return _wrap_IntVector_erase__SWIG_0(self, args);
       }
@@ -8508,16 +7193,16 @@ SWIGINTERN PyObject *_wrap_IntVector_erase(PyObject *self, PyObject *args) {
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< int >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<int >::iterator > *>(iter) != 0));
       if (_v) {
-        swig::SwigPyIterator *iter = 0;
-        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< int >::iterator > *>(iter) != 0));
+        swig::PySwigIterator *iter = 0;
+        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<int >::iterator > *>(iter) != 0));
         if (_v) {
           return _wrap_IntVector_erase__SWIG_1(self, args);
         }
@@ -8526,41 +7211,38 @@ SWIGINTERN PyObject *_wrap_IntVector_erase(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'IntVector_erase'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< int >::erase(std::vector< int >::iterator)\n"
-    "    std::vector< int >::erase(std::vector< int >::iterator,std::vector< int >::iterator)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'IntVector_erase'.\n  Possible C/C++ prototypes are:\n    erase(std::vector<int >::iterator)\n    erase(std::vector<int >::iterator,std::vector<int >::iterator)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_new_IntVector__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int >::size_type arg1 ;
-  std::vector< int >::value_type *arg2 = 0 ;
+  std::vector<int >::size_type arg1 ;
+  std::vector<int >::value_type *arg2 = 0 ;
+  std::vector<int > *result = 0 ;
   size_t val1 ;
   int ecode1 = 0 ;
-  std::vector< int >::value_type temp2 ;
+  std::vector<int >::value_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::vector< int > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:new_IntVector",&obj0,&obj1)) SWIG_fail;
   ecode1 = SWIG_AsVal_size_t(obj0, &val1);
   if (!SWIG_IsOK(ecode1)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_IntVector" "', argument " "1"" of type '" "std::vector< int >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_IntVector" "', argument " "1"" of type '" "std::vector<int >::size_type""'");
   } 
-  arg1 = static_cast< std::vector< int >::size_type >(val1);
+  arg1 = static_cast< std::vector<int >::size_type >(val1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_IntVector" "', argument " "2"" of type '" "std::vector< int >::value_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_IntVector" "', argument " "2"" of type '" "std::vector<int >::value_type""'");
   } 
-  temp2 = static_cast< std::vector< int >::value_type >(val2);
+  temp2 = static_cast< std::vector<int >::value_type >(val2);
   arg2 = &temp2;
-  result = (std::vector< int > *)new std::vector< int >(arg1,(std::vector< int >::value_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, SWIG_POINTER_NEW |  0 );
+  result = (std::vector<int > *)new std::vector<int >(arg1,(std::vector<int >::value_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -8573,8 +7255,8 @@ SWIGINTERN PyObject *_wrap_new_IntVector(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 0) {
@@ -8592,7 +7274,7 @@ SWIGINTERN PyObject *_wrap_new_IntVector(PyObject *self, PyObject *args) {
   }
   if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       return _wrap_new_IntVector__SWIG_1(self, args);
@@ -8616,41 +7298,36 @@ SWIGINTERN PyObject *_wrap_new_IntVector(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_IntVector'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< int >::vector()\n"
-    "    std::vector< int >::vector(std::vector< int > const &)\n"
-    "    std::vector< int >::vector(std::vector< int >::size_type)\n"
-    "    std::vector< int >::vector(std::vector< int >::size_type,std::vector< int >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_IntVector'.\n  Possible C/C++ prototypes are:\n    std::vector<(int)>()\n    std::vector<(int)>(std::vector<int > const &)\n    std::vector<(int)>(std::vector<int >::size_type)\n    std::vector<(int)>(std::vector<int >::size_type,std::vector<int >::value_type const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_IntVector_push_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::value_type *arg2 = 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::value_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::vector< int >::value_type temp2 ;
+  std::vector<int >::value_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:IntVector_push_back",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_push_back" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_push_back" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector_push_back" "', argument " "2"" of type '" "std::vector< int >::value_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector_push_back" "', argument " "2"" of type '" "std::vector<int >::value_type""'");
   } 
-  temp2 = static_cast< std::vector< int >::value_type >(val2);
+  temp2 = static_cast< std::vector<int >::value_type >(val2);
   arg2 = &temp2;
-  (arg1)->push_back((std::vector< int >::value_type const &)*arg2);
+  (arg1)->push_back((std::vector<int >::value_type const &)*arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -8660,19 +7337,22 @@ fail:
 
 SWIGINTERN PyObject *_wrap_IntVector_front(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::value_type *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< int >::value_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:IntVector_front",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_front" "', argument " "1"" of type '" "std::vector< int > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_front" "', argument " "1"" of type '" "std::vector<int > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  {
+    std::vector<int >::value_type const &_result_ref = ((std::vector<int > const *)arg1)->front();
+    result = (std::vector<int >::value_type *) &_result_ref;
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  result = (std::vector< int >::value_type *) &((std::vector< int > const *)arg1)->front();
   resultobj = SWIG_From_int(static_cast< int >(*result));
   return resultobj;
 fail:
@@ -8682,19 +7362,22 @@ fail:
 
 SWIGINTERN PyObject *_wrap_IntVector_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::value_type *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< int >::value_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:IntVector_back",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_back" "', argument " "1"" of type '" "std::vector< int > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_back" "', argument " "1"" of type '" "std::vector<int > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  {
+    std::vector<int >::value_type const &_result_ref = ((std::vector<int > const *)arg1)->back();
+    result = (std::vector<int >::value_type *) &_result_ref;
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  result = (std::vector< int >::value_type *) &((std::vector< int > const *)arg1)->back();
   resultobj = SWIG_From_int(static_cast< int >(*result));
   return resultobj;
 fail:
@@ -8704,14 +7387,14 @@ fail:
 
 SWIGINTERN PyObject *_wrap_IntVector_assign(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::size_type arg2 ;
-  std::vector< int >::value_type *arg3 = 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::size_type arg2 ;
+  std::vector<int >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
   int ecode2 = 0 ;
-  std::vector< int >::value_type temp3 ;
+  std::vector<int >::value_type temp3 ;
   int val3 ;
   int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
@@ -8719,23 +7402,23 @@ SWIGINTERN PyObject *_wrap_IntVector_assign(PyObject *SWIGUNUSEDPARM(self), PyOb
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:IntVector_assign",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_assign" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_assign" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector_assign" "', argument " "2"" of type '" "std::vector< int >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector_assign" "', argument " "2"" of type '" "std::vector<int >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< int >::size_type >(val2);
+  arg2 = static_cast< std::vector<int >::size_type >(val2);
   ecode3 = SWIG_AsVal_int(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector_assign" "', argument " "3"" of type '" "std::vector< int >::value_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector_assign" "', argument " "3"" of type '" "std::vector<int >::value_type""'");
   } 
-  temp3 = static_cast< std::vector< int >::value_type >(val3);
+  temp3 = static_cast< std::vector<int >::value_type >(val3);
   arg3 = &temp3;
-  (arg1)->assign(arg2,(std::vector< int >::value_type const &)*arg3);
+  (arg1)->assign(arg2,(std::vector<int >::value_type const &)*arg3);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -8745,14 +7428,14 @@ fail:
 
 SWIGINTERN PyObject *_wrap_IntVector_resize__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::size_type arg2 ;
-  std::vector< int >::value_type *arg3 = 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::size_type arg2 ;
+  std::vector<int >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
   int ecode2 = 0 ;
-  std::vector< int >::value_type temp3 ;
+  std::vector<int >::value_type temp3 ;
   int val3 ;
   int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
@@ -8760,23 +7443,23 @@ SWIGINTERN PyObject *_wrap_IntVector_resize__SWIG_1(PyObject *SWIGUNUSEDPARM(sel
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:IntVector_resize",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_resize" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_resize" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector_resize" "', argument " "2"" of type '" "std::vector< int >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector_resize" "', argument " "2"" of type '" "std::vector<int >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< int >::size_type >(val2);
+  arg2 = static_cast< std::vector<int >::size_type >(val2);
   ecode3 = SWIG_AsVal_int(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector_resize" "', argument " "3"" of type '" "std::vector< int >::value_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector_resize" "', argument " "3"" of type '" "std::vector<int >::value_type""'");
   } 
-  temp3 = static_cast< std::vector< int >::value_type >(val3);
+  temp3 = static_cast< std::vector<int >::value_type >(val3);
   arg3 = &temp3;
-  (arg1)->resize(arg2,(std::vector< int >::value_type const &)*arg3);
+  (arg1)->resize(arg2,(std::vector<int >::value_type const &)*arg3);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -8790,13 +7473,13 @@ SWIGINTERN PyObject *_wrap_IntVector_resize(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -8810,7 +7493,7 @@ SWIGINTERN PyObject *_wrap_IntVector_resize(PyObject *self, PyObject *args) {
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -8830,57 +7513,54 @@ SWIGINTERN PyObject *_wrap_IntVector_resize(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'IntVector_resize'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< int >::resize(std::vector< int >::size_type)\n"
-    "    std::vector< int >::resize(std::vector< int >::size_type,std::vector< int >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'IntVector_resize'.\n  Possible C/C++ prototypes are:\n    resize(std::vector<int >::size_type)\n    resize(std::vector<int >::size_type,std::vector<int >::value_type const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_IntVector_insert__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::iterator arg2 ;
-  std::vector< int >::value_type *arg3 = 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::iterator arg2 ;
+  std::vector<int >::value_type *arg3 = 0 ;
+  std::vector<int >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
-  std::vector< int >::value_type temp3 ;
+  std::vector<int >::value_type temp3 ;
   int val3 ;
   int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
-  std::vector< int >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:IntVector_insert",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_insert" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_insert" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_insert" "', argument " "2"" of type '" "std::vector< int >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_insert" "', argument " "2"" of type '" "std::vector<int >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< int >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< int >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<int >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<int >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_insert" "', argument " "2"" of type '" "std::vector< int >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_insert" "', argument " "2"" of type '" "std::vector<int >::iterator""'");
     }
   }
   ecode3 = SWIG_AsVal_int(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector_insert" "', argument " "3"" of type '" "std::vector< int >::value_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector_insert" "', argument " "3"" of type '" "std::vector<int >::value_type""'");
   } 
-  temp3 = static_cast< std::vector< int >::value_type >(val3);
+  temp3 = static_cast< std::vector<int >::value_type >(val3);
   arg3 = &temp3;
-  result = std_vector_Sl_int_Sg__insert__SWIG_0(arg1,arg2,(int const &)*arg3);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< int >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->insert(arg2,(std::vector<int >::value_type const &)*arg3);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<int >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
@@ -8889,17 +7569,17 @@ fail:
 
 SWIGINTERN PyObject *_wrap_IntVector_insert__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::iterator arg2 ;
-  std::vector< int >::size_type arg3 ;
-  std::vector< int >::value_type *arg4 = 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::iterator arg2 ;
+  std::vector<int >::size_type arg3 ;
+  std::vector<int >::value_type *arg4 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   size_t val3 ;
   int ecode3 = 0 ;
-  std::vector< int >::value_type temp4 ;
+  std::vector<int >::value_type temp4 ;
   int val4 ;
   int ecode4 = 0 ;
   PyObject * obj0 = 0 ;
@@ -8908,34 +7588,34 @@ SWIGINTERN PyObject *_wrap_IntVector_insert__SWIG_1(PyObject *SWIGUNUSEDPARM(sel
   PyObject * obj3 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOOO:IntVector_insert",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_insert" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_insert" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_insert" "', argument " "2"" of type '" "std::vector< int >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_insert" "', argument " "2"" of type '" "std::vector<int >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< int >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< int >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<int >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<int >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_insert" "', argument " "2"" of type '" "std::vector< int >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "IntVector_insert" "', argument " "2"" of type '" "std::vector<int >::iterator""'");
     }
   }
   ecode3 = SWIG_AsVal_size_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector_insert" "', argument " "3"" of type '" "std::vector< int >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "IntVector_insert" "', argument " "3"" of type '" "std::vector<int >::size_type""'");
   } 
-  arg3 = static_cast< std::vector< int >::size_type >(val3);
+  arg3 = static_cast< std::vector<int >::size_type >(val3);
   ecode4 = SWIG_AsVal_int(obj3, &val4);
   if (!SWIG_IsOK(ecode4)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "IntVector_insert" "', argument " "4"" of type '" "std::vector< int >::value_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "IntVector_insert" "', argument " "4"" of type '" "std::vector<int >::value_type""'");
   } 
-  temp4 = static_cast< std::vector< int >::value_type >(val4);
+  temp4 = static_cast< std::vector<int >::value_type >(val4);
   arg4 = &temp4;
-  std_vector_Sl_int_Sg__insert__SWIG_1(arg1,arg2,arg3,(int const &)*arg4);
+  (arg1)->insert(arg2,arg3,(std::vector<int >::value_type const &)*arg4);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -8949,18 +7629,18 @@ SWIGINTERN PyObject *_wrap_IntVector_insert(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 4); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< int >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<int >::iterator > *>(iter) != 0));
       if (_v) {
         {
           int res = SWIG_AsVal_int(argv[2], NULL);
@@ -8974,12 +7654,12 @@ SWIGINTERN PyObject *_wrap_IntVector_insert(PyObject *self, PyObject *args) {
   }
   if (argc == 4) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<int,std::allocator< int > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<int,std::allocator<int > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< int >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<int >::iterator > *>(iter) != 0));
       if (_v) {
         {
           int res = SWIG_AsVal_size_t(argv[2], NULL);
@@ -8999,18 +7679,15 @@ SWIGINTERN PyObject *_wrap_IntVector_insert(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'IntVector_insert'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< int >::insert(std::vector< int >::iterator,std::vector< int >::value_type const &)\n"
-    "    std::vector< int >::insert(std::vector< int >::iterator,std::vector< int >::size_type,std::vector< int >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'IntVector_insert'.\n  Possible C/C++ prototypes are:\n    insert(std::vector<int >::iterator,std::vector<int >::value_type const &)\n    insert(std::vector<int >::iterator,std::vector<int >::size_type,std::vector<int >::value_type const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_IntVector_reserve(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
-  std::vector< int >::size_type arg2 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::size_type arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
@@ -9019,16 +7696,16 @@ SWIGINTERN PyObject *_wrap_IntVector_reserve(PyObject *SWIGUNUSEDPARM(self), PyO
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:IntVector_reserve",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_reserve" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_reserve" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector_reserve" "', argument " "2"" of type '" "std::vector< int >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "IntVector_reserve" "', argument " "2"" of type '" "std::vector<int >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< int >::size_type >(val2);
+  arg2 = static_cast< std::vector<int >::size_type >(val2);
   (arg1)->reserve(arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -9039,19 +7716,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_IntVector_capacity(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
+  std::vector<int >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< int >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:IntVector_capacity",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_capacity" "', argument " "1"" of type '" "std::vector< int > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "IntVector_capacity" "', argument " "1"" of type '" "std::vector<int > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
-  result = ((std::vector< int > const *)arg1)->capacity();
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
+  result = ((std::vector<int > const *)arg1)->capacity();
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -9061,18 +7738,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_delete_IntVector(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< int > *arg1 = (std::vector< int > *) 0 ;
+  std::vector<int > *arg1 = (std::vector<int > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:delete_IntVector",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, SWIG_POINTER_DISOWN |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IntVector" "', argument " "1"" of type '" "std::vector< int > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_IntVector" "', argument " "1"" of type '" "std::vector<int > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< int > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<int > * >(argp1);
   delete arg1;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -9082,29 +7760,29 @@ fail:
 
 SWIGINTERN PyObject *IntVector_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
-  SWIG_TypeNewClientData(SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, SWIG_NewClientData(obj));
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
 
 SWIGINTERN PyObject *_wrap_DoubleVector_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_iterator" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_iterator" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  result = (swig::SwigPyIterator *)std_vector_Sl_double_Sg__iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = (swig::PySwigIterator *)std_vector_Sl_double_Sg__iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -9113,41 +7791,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleVector___nonzero__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
   bool result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector___nonzero__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___nonzero__" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  result = (bool)std_vector_Sl_double_Sg____nonzero__((std::vector< double > const *)arg1);
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleVector___bool__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector___bool__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector___nonzero__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___bool__" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___nonzero__" "', argument " "1"" of type '" "std::vector<double > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  result = (bool)std_vector_Sl_double_Sg____bool__((std::vector< double > const *)arg1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = (bool)std_vector_Sl_double_Sg____nonzero__((std::vector<double > const *)arg1);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -9157,19 +7813,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleVector___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector___len__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___len__" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___len__" "', argument " "1"" of type '" "std::vector<double > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  result = std_vector_Sl_double_Sg____len__((std::vector< double > const *)arg1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = std_vector_Sl_double_Sg____len__((std::vector<double > const *)arg1);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -9179,20 +7835,20 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleVector_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::value_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double >::value_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_pop",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_pop" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_pop" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
   try {
-    result = (std::vector< double >::value_type)std_vector_Sl_double_Sg__pop(arg1);
+    result = (std::vector<double >::value_type)std_vector_Sl_double_Sg__pop(arg1);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
@@ -9207,9 +7863,10 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleVector___getslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::difference_type arg2 ;
-  std::vector< double >::difference_type arg3 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::difference_type arg2 ;
+  std::vector<double >::difference_type arg3 ;
+  std::vector<double,std::allocator<double > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -9219,47 +7876,43 @@ SWIGINTERN PyObject *_wrap_DoubleVector___getslice__(PyObject *SWIGUNUSEDPARM(se
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
-  std::vector< double,std::allocator< double > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleVector___getslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___getslice__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___getslice__" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector___getslice__" "', argument " "2"" of type '" "std::vector< double >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector___getslice__" "', argument " "2"" of type '" "std::vector<double >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< double >::difference_type >(val2);
+  arg2 = static_cast< std::vector<double >::difference_type >(val2);
   ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector___getslice__" "', argument " "3"" of type '" "std::vector< double >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector___getslice__" "', argument " "3"" of type '" "std::vector<double >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< double >::difference_type >(val3);
+  arg3 = static_cast< std::vector<double >::difference_type >(val3);
   try {
-    result = (std::vector< double,std::allocator< double > > *)std_vector_Sl_double_Sg____getslice__(arg1,arg2,arg3);
+    result = (std::vector<double,std::allocator<double > > *)std_vector_Sl_double_Sg____getslice__(arg1,arg2,arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_POINTER_OWN |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector___setslice____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleVector___setslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::difference_type arg2 ;
-  std::vector< double >::difference_type arg3 ;
-  std::vector< double,std::allocator< double > > *arg4 = 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::difference_type arg2 ;
+  std::vector<double >::difference_type arg3 ;
+  std::vector<double,std::allocator<double > > *arg4 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -9273,34 +7926,34 @@ SWIGINTERN PyObject *_wrap_DoubleVector___setslice____SWIG_0(PyObject *SWIGUNUSE
   PyObject * obj3 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOOO:DoubleVector___setslice__",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___setslice__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___setslice__" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector___setslice__" "', argument " "2"" of type '" "std::vector< double >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector___setslice__" "', argument " "2"" of type '" "std::vector<double >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< double >::difference_type >(val2);
+  arg2 = static_cast< std::vector<double >::difference_type >(val2);
   ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector___setslice__" "', argument " "3"" of type '" "std::vector< double >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector___setslice__" "', argument " "3"" of type '" "std::vector<double >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< double >::difference_type >(val3);
+  arg3 = static_cast< std::vector<double >::difference_type >(val3);
   {
-    std::vector<double,std::allocator< double > > *ptr = (std::vector<double,std::allocator< double > > *)0;
+    std::vector<double,std::allocator<double > > *ptr = (std::vector<double,std::allocator<double > > *)0;
     res4 = swig::asptr(obj3, &ptr);
     if (!SWIG_IsOK(res4)) {
-      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "DoubleVector___setslice__" "', argument " "4"" of type '" "std::vector< double,std::allocator< double > > const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "DoubleVector___setslice__" "', argument " "4"" of type '" "std::vector<double,std::allocator<double > > const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleVector___setslice__" "', argument " "4"" of type '" "std::vector< double,std::allocator< double > > const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleVector___setslice__" "', argument " "4"" of type '" "std::vector<double,std::allocator<double > > const &""'"); 
     }
     arg4 = ptr;
   }
   try {
-    std_vector_Sl_double_Sg____setslice____SWIG_0(arg1,arg2,arg3,(std::vector< double,std::allocator< double > > const &)*arg4);
+    std_vector_Sl_double_Sg____setslice__(arg1,arg2,arg3,(std::vector<double,std::allocator<double > > const &)*arg4);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
@@ -9318,11 +7971,11 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector___setslice____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleVector___delslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::difference_type arg2 ;
-  std::vector< double >::difference_type arg3 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::difference_type arg2 ;
+  std::vector<double >::difference_type arg3 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -9333,31 +7986,28 @@ SWIGINTERN PyObject *_wrap_DoubleVector___setslice____SWIG_1(PyObject *SWIGUNUSE
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleVector___setslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleVector___delslice__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___setslice__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___delslice__" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector___setslice__" "', argument " "2"" of type '" "std::vector< double >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector___delslice__" "', argument " "2"" of type '" "std::vector<double >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< double >::difference_type >(val2);
+  arg2 = static_cast< std::vector<double >::difference_type >(val2);
   ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector___setslice__" "', argument " "3"" of type '" "std::vector< double >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector___delslice__" "', argument " "3"" of type '" "std::vector<double >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< double >::difference_type >(val3);
+  arg3 = static_cast< std::vector<double >::difference_type >(val3);
   try {
-    std_vector_Sl_double_Sg____setslice____SWIG_0(arg1,arg2,arg3);
+    std_vector_Sl_double_Sg____delslice__(arg1,arg2,arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -9366,110 +8016,34 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector___setslice__(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[5];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 3) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        {
-          int res = SWIG_AsVal_ptrdiff_t(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          return _wrap_DoubleVector___setslice____SWIG_1(self, args);
-        }
-      }
-    }
-  }
-  if (argc == 4) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        {
-          int res = SWIG_AsVal_ptrdiff_t(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          int res = swig::asptr(argv[3], (std::vector<double,std::allocator< double > >**)(0));
-          _v = SWIG_CheckState(res);
-          if (_v) {
-            return _wrap_DoubleVector___setslice____SWIG_0(self, args);
-          }
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DoubleVector___setslice__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< double >::__setslice__(std::vector< double >::difference_type,std::vector< double >::difference_type,std::vector< double,std::allocator< double > > const &)\n"
-    "    std::vector< double >::__setslice__(std::vector< double >::difference_type,std::vector< double >::difference_type)\n");
-  return 0;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleVector___delslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleVector___delitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::difference_type arg2 ;
-  std::vector< double >::difference_type arg3 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::difference_type arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
   int ecode2 = 0 ;
-  ptrdiff_t val3 ;
-  int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleVector___delslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector___delitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___delslice__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___delitem__" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector___delslice__" "', argument " "2"" of type '" "std::vector< double >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< double >::difference_type >(val2);
-  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector___delslice__" "', argument " "3"" of type '" "std::vector< double >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector___delitem__" "', argument " "2"" of type '" "std::vector<double >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< double >::difference_type >(val3);
+  arg2 = static_cast< std::vector<double >::difference_type >(val2);
   try {
-    std_vector_Sl_double_Sg____delslice__(arg1,arg2,arg3);
+    std_vector_Sl_double_Sg____delitem__(arg1,arg2);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -9478,10 +8052,11 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector___delitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleVector___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::difference_type arg2 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::difference_type arg2 ;
+  std::vector<double >::value_type *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -9489,155 +8064,213 @@ SWIGINTERN PyObject *_wrap_DoubleVector___delitem____SWIG_0(PyObject *SWIGUNUSED
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector___getitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___delitem__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___getitem__" "', argument " "1"" of type '" "std::vector<double > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector___delitem__" "', argument " "2"" of type '" "std::vector< double >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector___getitem__" "', argument " "2"" of type '" "std::vector<double >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< double >::difference_type >(val2);
+  arg2 = static_cast< std::vector<double >::difference_type >(val2);
   try {
-    std_vector_Sl_double_Sg____delitem____SWIG_0(arg1,arg2);
+    {
+      std::vector<double >::value_type const &_result_ref = std_vector_Sl_double_Sg____getitem__((std::vector<double > const *)arg1,arg2);
+      result = (std::vector<double >::value_type *) &_result_ref;
+    }
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
-  resultobj = SWIG_Py_Void();
+  resultobj = SWIG_From_double(static_cast< double >(*result));
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector___getitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleVector___setitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::difference_type arg2 ;
+  std::vector<double >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  std::vector<double >::value_type temp3 ;
+  double val3 ;
+  int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::vector< double,std::allocator< double > > *result = 0 ;
+  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleVector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___getitem__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector___getitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___setitem__" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector___setitem__" "', argument " "2"" of type '" "std::vector<double >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector<double >::difference_type >(val2);
+  ecode3 = SWIG_AsVal_double(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector___setitem__" "', argument " "3"" of type '" "std::vector<double >::value_type""'");
+  } 
+  temp3 = static_cast< std::vector<double >::value_type >(val3);
+  arg3 = &temp3;
   try {
-    result = (std::vector< double,std::allocator< double > > *)std_vector_Sl_double_Sg____getitem____SWIG_0(arg1,arg2);
+    std_vector_Sl_double_Sg____setitem__(arg1,arg2,(double const &)*arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_POINTER_OWN |  0 );
+  resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleVector_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
-  std::vector< double,std::allocator< double > > *arg3 = 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::value_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  int res3 = SWIG_OLDOBJ ;
+  std::vector<double >::value_type temp2 ;
+  double val2 ;
+  int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleVector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector_append",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___setitem__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_append" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector___setitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
-  }
-  {
-    std::vector<double,std::allocator< double > > *ptr = (std::vector<double,std::allocator< double > > *)0;
-    res3 = swig::asptr(obj2, &ptr);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "DoubleVector___setitem__" "', argument " "3"" of type '" "std::vector< double,std::allocator< double > > const &""'"); 
-    }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleVector___setitem__" "', argument " "3"" of type '" "std::vector< double,std::allocator< double > > const &""'"); 
-    }
-    arg3 = ptr;
-  }
-  try {
-    std_vector_Sl_double_Sg____setitem____SWIG_0(arg1,arg2,(std::vector< double,std::allocator< double > > const &)*arg3);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
-  }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
-  
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  ecode2 = SWIG_AsVal_double(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector_append" "', argument " "2"" of type '" "std::vector<double >::value_type""'");
+  } 
+  temp2 = static_cast< std::vector<double >::value_type >(val2);
+  arg2 = &temp2;
+  std_vector_Sl_double_Sg__append(arg1,(double const &)*arg2);
   resultobj = SWIG_Py_Void();
-  if (SWIG_IsNewObj(res3)) delete arg3;
   return resultobj;
 fail:
-  if (SWIG_IsNewObj(res3)) delete arg3;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_DoubleVector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
+  std::vector<double > *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector___setitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___setitem__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  if (!PyArg_ParseTuple(args,(char *)":new_DoubleVector")) SWIG_fail;
+  result = (std::vector<double > *)new std::vector<double >();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_DoubleVector__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<double > *arg1 = 0 ;
+  std::vector<double > *result = 0 ;
+  int res1 = SWIG_OLDOBJ ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:new_DoubleVector",&obj0)) SWIG_fail;
   {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector___setitem__" "', argument " "2"" of type '" "PySliceObject *""'");
+    std::vector<double,std::allocator<double > > *ptr = (std::vector<double,std::allocator<double > > *)0;
+    res1 = swig::asptr(obj0, &ptr);
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_DoubleVector" "', argument " "1"" of type '" "std::vector<double > const &""'"); 
     }
-    arg2 = (PySliceObject *) obj1;
-  }
-  try {
-    std_vector_Sl_double_Sg____setitem____SWIG_1(arg1,arg2);
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_DoubleVector" "', argument " "1"" of type '" "std::vector<double > const &""'"); 
+    }
+    arg1 = ptr;
   }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  result = (std::vector<double > *)new std::vector<double >((std::vector<double > const &)*arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, SWIG_POINTER_NEW |  0 );
+  if (SWIG_IsNewObj(res1)) delete arg1;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res1)) delete arg1;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleVector_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  bool result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_empty",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_empty" "', argument " "1"" of type '" "std::vector<double > const *""'"); 
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = (bool)((std::vector<double > const *)arg1)->empty();
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleVector_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::size_type result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_size",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_size" "', argument " "1"" of type '" "std::vector<double > const *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = ((std::vector<double > const *)arg1)->size();
+  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleVector_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_clear",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_clear" "', argument " "1"" of type '" "std::vector<double > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  (arg1)->clear();
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -9645,595 +8278,393 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector___delitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleVector_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double > *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector_swap",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___delitem__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_swap" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector___delitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t,  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DoubleVector_swap" "', argument " "2"" of type '" "std::vector<double > &""'"); 
   }
-  try {
-    std_vector_Sl_double_Sg____delitem____SWIG_1(arg1,arg2);
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleVector_swap" "', argument " "2"" of type '" "std::vector<double > &""'"); 
   }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  arg2 = reinterpret_cast< std::vector<double > * >(argp2);
+  (arg1)->swap(*arg2);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleVector_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  SwigValueWrapper<std::allocator<double > > result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_get_allocator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_get_allocator" "', argument " "1"" of type '" "std::vector<double > const *""'"); 
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = ((std::vector<double > const *)arg1)->get_allocator();
+  resultobj = SWIG_NewPointerObj((new std::vector<double >::allocator_type(static_cast< const std::vector<double >::allocator_type& >(result))), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t__allocator_type, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleVector_begin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_begin" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = (arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<double >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleVector_begin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  resultobj = SWIG_Py_Void();
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_begin" "', argument " "1"" of type '" "std::vector<double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = ((std::vector<double > const *)arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<double >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector___delitem__(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleVector_begin(PyObject *self, PyObject *args) {
   int argc;
-  PyObject *argv[3];
+  PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 2) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_DoubleVector___delitem____SWIG_1(self, args);
-      }
+      return _wrap_DoubleVector_begin__SWIG_0(self, args);
     }
   }
-  if (argc == 2) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_DoubleVector___delitem____SWIG_0(self, args);
-      }
+      return _wrap_DoubleVector_begin__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DoubleVector___delitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< double >::__delitem__(std::vector< double >::difference_type)\n"
-    "    std::vector< double >::__delitem__(PySliceObject *)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'DoubleVector_begin'.\n  Possible C/C++ prototypes are:\n    begin()\n    begin()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector___getitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleVector_end__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::difference_type arg2 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  ptrdiff_t val2 ;
-  int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  std::vector< double >::value_type *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___getitem__" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector___getitem__" "', argument " "2"" of type '" "std::vector< double >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< double >::difference_type >(val2);
-  try {
-    result = (std::vector< double >::value_type *) &std_vector_Sl_double_Sg____getitem____SWIG_1((std::vector< double > const *)arg1,arg2);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_end" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = (arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<double >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleVector_end__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  resultobj = SWIG_From_double(static_cast< double >(*result));
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_end" "', argument " "1"" of type '" "std::vector<double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = ((std::vector<double > const *)arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<double >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector___getitem__(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleVector_end(PyObject *self, PyObject *args) {
   int argc;
-  PyObject *argv[3];
+  PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 2) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_DoubleVector___getitem____SWIG_0(self, args);
-      }
+      return _wrap_DoubleVector_end__SWIG_0(self, args);
     }
   }
-  if (argc == 2) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_DoubleVector___getitem____SWIG_1(self, args);
-      }
+      return _wrap_DoubleVector_end__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DoubleVector___getitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< double >::__getitem__(PySliceObject *)\n"
-    "    std::vector< double >::__getitem__(std::vector< double >::difference_type) const\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'DoubleVector_end'.\n  Possible C/C++ prototypes are:\n    end()\n    end()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector___setitem____SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleVector_rbegin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::difference_type arg2 ;
-  std::vector< double >::value_type *arg3 = 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  ptrdiff_t val2 ;
-  int ecode2 = 0 ;
-  std::vector< double >::value_type temp3 ;
-  double val3 ;
-  int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleVector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector___setitem__" "', argument " "1"" of type '" "std::vector< double > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector___setitem__" "', argument " "2"" of type '" "std::vector< double >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< double >::difference_type >(val2);
-  ecode3 = SWIG_AsVal_double(obj2, &val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector___setitem__" "', argument " "3"" of type '" "std::vector< double >::value_type""'");
-  } 
-  temp3 = static_cast< std::vector< double >::value_type >(val3);
-  arg3 = &temp3;
-  try {
-    std_vector_Sl_double_Sg____setitem____SWIG_2(arg1,arg2,(double const &)*arg3);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_rbegin" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = (arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<double >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleVector_rbegin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::const_reverse_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  resultobj = SWIG_Py_Void();
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_rbegin" "', argument " "1"" of type '" "std::vector<double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = ((std::vector<double > const *)arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<double >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector___setitem__(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleVector_rbegin(PyObject *self, PyObject *args) {
   int argc;
-  PyObject *argv[4];
+  PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 2) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_DoubleVector___setitem____SWIG_1(self, args);
-      }
+      return _wrap_DoubleVector_rbegin__SWIG_0(self, args);
     }
   }
-  if (argc == 3) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        int res = swig::asptr(argv[2], (std::vector<double,std::allocator< double > >**)(0));
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_DoubleVector___setitem____SWIG_0(self, args);
-        }
-      }
+      return _wrap_DoubleVector_rbegin__SWIG_1(self, args);
     }
   }
-  if (argc == 3) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        {
-          int res = SWIG_AsVal_double(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          return _wrap_DoubleVector___setitem____SWIG_2(self, args);
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DoubleVector___setitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< double >::__setitem__(PySliceObject *,std::vector< double,std::allocator< double > > const &)\n"
-    "    std::vector< double >::__setitem__(PySliceObject *)\n"
-    "    std::vector< double >::__setitem__(std::vector< double >::difference_type,std::vector< double >::value_type const &)\n");
-  return 0;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleVector_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::value_type *arg2 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  std::vector< double >::value_type temp2 ;
-  double val2 ;
-  int ecode2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector_append",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_append" "', argument " "1"" of type '" "std::vector< double > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  ecode2 = SWIG_AsVal_double(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector_append" "', argument " "2"" of type '" "std::vector< double >::value_type""'");
-  } 
-  temp2 = static_cast< std::vector< double >::value_type >(val2);
-  arg2 = &temp2;
-  std_vector_Sl_double_Sg__append(arg1,(double const &)*arg2);
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_DoubleVector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< double > *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)":new_DoubleVector")) SWIG_fail;
-  result = (std::vector< double > *)new std::vector< double >();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_POINTER_NEW |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_DoubleVector__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< double > *arg1 = 0 ;
-  int res1 = SWIG_OLDOBJ ;
-  PyObject * obj0 = 0 ;
-  std::vector< double > *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:new_DoubleVector",&obj0)) SWIG_fail;
-  {
-    std::vector<double,std::allocator< double > > *ptr = (std::vector<double,std::allocator< double > > *)0;
-    res1 = swig::asptr(obj0, &ptr);
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_DoubleVector" "', argument " "1"" of type '" "std::vector< double > const &""'"); 
-    }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_DoubleVector" "', argument " "1"" of type '" "std::vector< double > const &""'"); 
-    }
-    arg1 = ptr;
-  }
-  result = (std::vector< double > *)new std::vector< double >((std::vector< double > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_POINTER_NEW |  0 );
-  if (SWIG_IsNewObj(res1)) delete arg1;
-  return resultobj;
-fail:
-  if (SWIG_IsNewObj(res1)) delete arg1;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleVector_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  bool result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_empty",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_empty" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  result = (bool)((std::vector< double > const *)arg1)->empty();
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleVector_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< double >::size_type result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_size",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_size" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  result = ((std::vector< double > const *)arg1)->size();
-  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleVector_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_clear",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_clear" "', argument " "1"" of type '" "std::vector< double > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  (arg1)->clear();
-  resultobj = SWIG_Py_Void();
-  return resultobj;
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'DoubleVector_rbegin'.\n  Possible C/C++ prototypes are:\n    rbegin()\n    rbegin()\n");
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleVector_rend__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double > *arg2 = 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector_swap",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_swap" "', argument " "1"" of type '" "std::vector< double > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t,  0 );
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DoubleVector_swap" "', argument " "2"" of type '" "std::vector< double > &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_rend" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleVector_swap" "', argument " "2"" of type '" "std::vector< double > &""'"); 
-  }
-  arg2 = reinterpret_cast< std::vector< double > * >(argp2);
-  (arg1)->swap(*arg2);
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = (arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<double >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleVector_rend__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::const_reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  SwigValueWrapper< std::allocator< double > > result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_get_allocator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_get_allocator" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_rend" "', argument " "1"" of type '" "std::vector<double > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  result = ((std::vector< double > const *)arg1)->get_allocator();
-  resultobj = SWIG_NewPointerObj((new std::vector< double >::allocator_type(static_cast< const std::vector< double >::allocator_type& >(result))), SWIGTYPE_p_std__allocatorT_double_t, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = ((std::vector<double > const *)arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<double >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleVector_begin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< double >::iterator result;
+SWIGINTERN PyObject *_wrap_DoubleVector_rend(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_begin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_begin" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  result = (arg1)->begin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< double >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleVector_end(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< double >::iterator result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_end",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_end" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_DoubleVector_rend__SWIG_0(self, args);
+    }
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  result = (arg1)->end();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< double >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleVector_rbegin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< double >::reverse_iterator result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_rbegin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_rbegin" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_DoubleVector_rend__SWIG_1(self, args);
+    }
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  result = (arg1)->rbegin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< double >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleVector_rend(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< double >::reverse_iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_rend",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_rend" "', argument " "1"" of type '" "std::vector< double > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  result = (arg1)->rend();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< double >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'DoubleVector_rend'.\n  Possible C/C++ prototypes are:\n    rend()\n    rend()\n");
   return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_new_DoubleVector__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double >::size_type arg1 ;
+  std::vector<double >::size_type arg1 ;
+  std::vector<double > *result = 0 ;
   size_t val1 ;
   int ecode1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:new_DoubleVector",&obj0)) SWIG_fail;
   ecode1 = SWIG_AsVal_size_t(obj0, &val1);
   if (!SWIG_IsOK(ecode1)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_DoubleVector" "', argument " "1"" of type '" "std::vector< double >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_DoubleVector" "', argument " "1"" of type '" "std::vector<double >::size_type""'");
   } 
-  arg1 = static_cast< std::vector< double >::size_type >(val1);
-  result = (std::vector< double > *)new std::vector< double >(arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_POINTER_NEW |  0 );
+  arg1 = static_cast< std::vector<double >::size_type >(val1);
+  result = (std::vector<double > *)new std::vector<double >(arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -10242,17 +8673,17 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleVector_pop_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_pop_back",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_pop_back" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_pop_back" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
   (arg1)->pop_back();
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -10263,8 +8694,8 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleVector_resize__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::size_type arg2 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::size_type arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
@@ -10273,16 +8704,16 @@ SWIGINTERN PyObject *_wrap_DoubleVector_resize__SWIG_0(PyObject *SWIGUNUSEDPARM(
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector_resize",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_resize" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_resize" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector_resize" "', argument " "2"" of type '" "std::vector< double >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector_resize" "', argument " "2"" of type '" "std::vector<double >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< double >::size_type >(val2);
+  arg2 = static_cast< std::vector<double >::size_type >(val2);
   (arg1)->resize(arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -10293,36 +8724,36 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleVector_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::iterator arg2 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::iterator arg2 ;
+  std::vector<double >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::vector< double >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_erase" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_erase" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_erase" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_erase" "', argument " "2"" of type '" "std::vector<double >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< double >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<double >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<double >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_erase" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_erase" "', argument " "2"" of type '" "std::vector<double >::iterator""'");
     }
   }
-  result = std_vector_Sl_double_Sg__erase__SWIG_0(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< double >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->erase(arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<double >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
@@ -10331,51 +8762,51 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleVector_erase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::iterator arg2 ;
-  std::vector< double >::iterator arg3 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::iterator arg2 ;
+  std::vector<double >::iterator arg3 ;
+  std::vector<double >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
-  swig::SwigPyIterator *iter3 = 0 ;
+  swig::PySwigIterator *iter3 = 0 ;
   int res3 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
-  std::vector< double >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleVector_erase",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_erase" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_erase" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_erase" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_erase" "', argument " "2"" of type '" "std::vector<double >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< double >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<double >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<double >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_erase" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_erase" "', argument " "2"" of type '" "std::vector<double >::iterator""'");
     }
   }
-  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::SwigPyIterator::descriptor(), 0);
+  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res3) || !iter3) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_erase" "', argument " "3"" of type '" "std::vector< double >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_erase" "', argument " "3"" of type '" "std::vector<double >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< double >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter3);
+    swig::PySwigIterator_T<std::vector<double >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<double >::iterator > *>(iter3);
     if (iter_t) {
       arg3 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_erase" "', argument " "3"" of type '" "std::vector< double >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_erase" "', argument " "3"" of type '" "std::vector<double >::iterator""'");
     }
   }
-  result = std_vector_Sl_double_Sg__erase__SWIG_1(arg1,arg2,arg3);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< double >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->erase(arg2,arg3);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<double >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
@@ -10388,18 +8819,18 @@ SWIGINTERN PyObject *_wrap_DoubleVector_erase(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<double >::iterator > *>(iter) != 0));
       if (_v) {
         return _wrap_DoubleVector_erase__SWIG_0(self, args);
       }
@@ -10407,16 +8838,16 @@ SWIGINTERN PyObject *_wrap_DoubleVector_erase(PyObject *self, PyObject *args) {
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<double >::iterator > *>(iter) != 0));
       if (_v) {
-        swig::SwigPyIterator *iter = 0;
-        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter) != 0));
+        swig::PySwigIterator *iter = 0;
+        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<double >::iterator > *>(iter) != 0));
         if (_v) {
           return _wrap_DoubleVector_erase__SWIG_1(self, args);
         }
@@ -10425,41 +8856,38 @@ SWIGINTERN PyObject *_wrap_DoubleVector_erase(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DoubleVector_erase'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< double >::erase(std::vector< double >::iterator)\n"
-    "    std::vector< double >::erase(std::vector< double >::iterator,std::vector< double >::iterator)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'DoubleVector_erase'.\n  Possible C/C++ prototypes are:\n    erase(std::vector<double >::iterator)\n    erase(std::vector<double >::iterator,std::vector<double >::iterator)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_new_DoubleVector__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double >::size_type arg1 ;
-  std::vector< double >::value_type *arg2 = 0 ;
+  std::vector<double >::size_type arg1 ;
+  std::vector<double >::value_type *arg2 = 0 ;
+  std::vector<double > *result = 0 ;
   size_t val1 ;
   int ecode1 = 0 ;
-  std::vector< double >::value_type temp2 ;
+  std::vector<double >::value_type temp2 ;
   double val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::vector< double > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:new_DoubleVector",&obj0,&obj1)) SWIG_fail;
   ecode1 = SWIG_AsVal_size_t(obj0, &val1);
   if (!SWIG_IsOK(ecode1)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_DoubleVector" "', argument " "1"" of type '" "std::vector< double >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_DoubleVector" "', argument " "1"" of type '" "std::vector<double >::size_type""'");
   } 
-  arg1 = static_cast< std::vector< double >::size_type >(val1);
+  arg1 = static_cast< std::vector<double >::size_type >(val1);
   ecode2 = SWIG_AsVal_double(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_DoubleVector" "', argument " "2"" of type '" "std::vector< double >::value_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "new_DoubleVector" "', argument " "2"" of type '" "std::vector<double >::value_type""'");
   } 
-  temp2 = static_cast< std::vector< double >::value_type >(val2);
+  temp2 = static_cast< std::vector<double >::value_type >(val2);
   arg2 = &temp2;
-  result = (std::vector< double > *)new std::vector< double >(arg1,(std::vector< double >::value_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_POINTER_NEW |  0 );
+  result = (std::vector<double > *)new std::vector<double >(arg1,(std::vector<double >::value_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -10472,8 +8900,8 @@ SWIGINTERN PyObject *_wrap_new_DoubleVector(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 0) {
@@ -10491,7 +8919,7 @@ SWIGINTERN PyObject *_wrap_new_DoubleVector(PyObject *self, PyObject *args) {
   }
   if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       return _wrap_new_DoubleVector__SWIG_1(self, args);
@@ -10515,41 +8943,36 @@ SWIGINTERN PyObject *_wrap_new_DoubleVector(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_DoubleVector'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< double >::vector()\n"
-    "    std::vector< double >::vector(std::vector< double > const &)\n"
-    "    std::vector< double >::vector(std::vector< double >::size_type)\n"
-    "    std::vector< double >::vector(std::vector< double >::size_type,std::vector< double >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_DoubleVector'.\n  Possible C/C++ prototypes are:\n    std::vector<(double)>()\n    std::vector<(double)>(std::vector<double > const &)\n    std::vector<(double)>(std::vector<double >::size_type)\n    std::vector<(double)>(std::vector<double >::size_type,std::vector<double >::value_type const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_DoubleVector_push_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::value_type *arg2 = 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::value_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::vector< double >::value_type temp2 ;
+  std::vector<double >::value_type temp2 ;
   double val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector_push_back",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_push_back" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_push_back" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
   ecode2 = SWIG_AsVal_double(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector_push_back" "', argument " "2"" of type '" "std::vector< double >::value_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector_push_back" "', argument " "2"" of type '" "std::vector<double >::value_type""'");
   } 
-  temp2 = static_cast< std::vector< double >::value_type >(val2);
+  temp2 = static_cast< std::vector<double >::value_type >(val2);
   arg2 = &temp2;
-  (arg1)->push_back((std::vector< double >::value_type const &)*arg2);
+  (arg1)->push_back((std::vector<double >::value_type const &)*arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -10559,19 +8982,22 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleVector_front(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::value_type *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double >::value_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_front",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_front" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_front" "', argument " "1"" of type '" "std::vector<double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  {
+    std::vector<double >::value_type const &_result_ref = ((std::vector<double > const *)arg1)->front();
+    result = (std::vector<double >::value_type *) &_result_ref;
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  result = (std::vector< double >::value_type *) &((std::vector< double > const *)arg1)->front();
   resultobj = SWIG_From_double(static_cast< double >(*result));
   return resultobj;
 fail:
@@ -10581,19 +9007,22 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleVector_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::value_type *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double >::value_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_back",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_back" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_back" "', argument " "1"" of type '" "std::vector<double > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  {
+    std::vector<double >::value_type const &_result_ref = ((std::vector<double > const *)arg1)->back();
+    result = (std::vector<double >::value_type *) &_result_ref;
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  result = (std::vector< double >::value_type *) &((std::vector< double > const *)arg1)->back();
   resultobj = SWIG_From_double(static_cast< double >(*result));
   return resultobj;
 fail:
@@ -10603,14 +9032,14 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleVector_assign(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::size_type arg2 ;
-  std::vector< double >::value_type *arg3 = 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::size_type arg2 ;
+  std::vector<double >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
   int ecode2 = 0 ;
-  std::vector< double >::value_type temp3 ;
+  std::vector<double >::value_type temp3 ;
   double val3 ;
   int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
@@ -10618,23 +9047,23 @@ SWIGINTERN PyObject *_wrap_DoubleVector_assign(PyObject *SWIGUNUSEDPARM(self), P
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleVector_assign",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_assign" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_assign" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector_assign" "', argument " "2"" of type '" "std::vector< double >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector_assign" "', argument " "2"" of type '" "std::vector<double >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< double >::size_type >(val2);
+  arg2 = static_cast< std::vector<double >::size_type >(val2);
   ecode3 = SWIG_AsVal_double(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector_assign" "', argument " "3"" of type '" "std::vector< double >::value_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector_assign" "', argument " "3"" of type '" "std::vector<double >::value_type""'");
   } 
-  temp3 = static_cast< std::vector< double >::value_type >(val3);
+  temp3 = static_cast< std::vector<double >::value_type >(val3);
   arg3 = &temp3;
-  (arg1)->assign(arg2,(std::vector< double >::value_type const &)*arg3);
+  (arg1)->assign(arg2,(std::vector<double >::value_type const &)*arg3);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -10644,14 +9073,14 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleVector_resize__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::size_type arg2 ;
-  std::vector< double >::value_type *arg3 = 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::size_type arg2 ;
+  std::vector<double >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
   int ecode2 = 0 ;
-  std::vector< double >::value_type temp3 ;
+  std::vector<double >::value_type temp3 ;
   double val3 ;
   int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
@@ -10659,23 +9088,23 @@ SWIGINTERN PyObject *_wrap_DoubleVector_resize__SWIG_1(PyObject *SWIGUNUSEDPARM(
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleVector_resize",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_resize" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_resize" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector_resize" "', argument " "2"" of type '" "std::vector< double >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector_resize" "', argument " "2"" of type '" "std::vector<double >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< double >::size_type >(val2);
+  arg2 = static_cast< std::vector<double >::size_type >(val2);
   ecode3 = SWIG_AsVal_double(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector_resize" "', argument " "3"" of type '" "std::vector< double >::value_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector_resize" "', argument " "3"" of type '" "std::vector<double >::value_type""'");
   } 
-  temp3 = static_cast< std::vector< double >::value_type >(val3);
+  temp3 = static_cast< std::vector<double >::value_type >(val3);
   arg3 = &temp3;
-  (arg1)->resize(arg2,(std::vector< double >::value_type const &)*arg3);
+  (arg1)->resize(arg2,(std::vector<double >::value_type const &)*arg3);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -10689,13 +9118,13 @@ SWIGINTERN PyObject *_wrap_DoubleVector_resize(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -10709,7 +9138,7 @@ SWIGINTERN PyObject *_wrap_DoubleVector_resize(PyObject *self, PyObject *args) {
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -10729,57 +9158,54 @@ SWIGINTERN PyObject *_wrap_DoubleVector_resize(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DoubleVector_resize'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< double >::resize(std::vector< double >::size_type)\n"
-    "    std::vector< double >::resize(std::vector< double >::size_type,std::vector< double >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'DoubleVector_resize'.\n  Possible C/C++ prototypes are:\n    resize(std::vector<double >::size_type)\n    resize(std::vector<double >::size_type,std::vector<double >::value_type const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_DoubleVector_insert__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::iterator arg2 ;
-  std::vector< double >::value_type *arg3 = 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::iterator arg2 ;
+  std::vector<double >::value_type *arg3 = 0 ;
+  std::vector<double >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
-  std::vector< double >::value_type temp3 ;
+  std::vector<double >::value_type temp3 ;
   double val3 ;
   int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
-  std::vector< double >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleVector_insert",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_insert" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_insert" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_insert" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_insert" "', argument " "2"" of type '" "std::vector<double >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< double >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<double >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<double >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_insert" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_insert" "', argument " "2"" of type '" "std::vector<double >::iterator""'");
     }
   }
   ecode3 = SWIG_AsVal_double(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector_insert" "', argument " "3"" of type '" "std::vector< double >::value_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector_insert" "', argument " "3"" of type '" "std::vector<double >::value_type""'");
   } 
-  temp3 = static_cast< std::vector< double >::value_type >(val3);
+  temp3 = static_cast< std::vector<double >::value_type >(val3);
   arg3 = &temp3;
-  result = std_vector_Sl_double_Sg__insert__SWIG_0(arg1,arg2,(double const &)*arg3);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< double >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->insert(arg2,(std::vector<double >::value_type const &)*arg3);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<double >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
@@ -10788,17 +9214,17 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleVector_insert__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::iterator arg2 ;
-  std::vector< double >::size_type arg3 ;
-  std::vector< double >::value_type *arg4 = 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::iterator arg2 ;
+  std::vector<double >::size_type arg3 ;
+  std::vector<double >::value_type *arg4 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   size_t val3 ;
   int ecode3 = 0 ;
-  std::vector< double >::value_type temp4 ;
+  std::vector<double >::value_type temp4 ;
   double val4 ;
   int ecode4 = 0 ;
   PyObject * obj0 = 0 ;
@@ -10807,34 +9233,34 @@ SWIGINTERN PyObject *_wrap_DoubleVector_insert__SWIG_1(PyObject *SWIGUNUSEDPARM(
   PyObject * obj3 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOOO:DoubleVector_insert",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_insert" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_insert" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_insert" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_insert" "', argument " "2"" of type '" "std::vector<double >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< double >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<double >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<double >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_insert" "', argument " "2"" of type '" "std::vector< double >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleVector_insert" "', argument " "2"" of type '" "std::vector<double >::iterator""'");
     }
   }
   ecode3 = SWIG_AsVal_size_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector_insert" "', argument " "3"" of type '" "std::vector< double >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleVector_insert" "', argument " "3"" of type '" "std::vector<double >::size_type""'");
   } 
-  arg3 = static_cast< std::vector< double >::size_type >(val3);
+  arg3 = static_cast< std::vector<double >::size_type >(val3);
   ecode4 = SWIG_AsVal_double(obj3, &val4);
   if (!SWIG_IsOK(ecode4)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "DoubleVector_insert" "', argument " "4"" of type '" "std::vector< double >::value_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode4), "in method '" "DoubleVector_insert" "', argument " "4"" of type '" "std::vector<double >::value_type""'");
   } 
-  temp4 = static_cast< std::vector< double >::value_type >(val4);
+  temp4 = static_cast< std::vector<double >::value_type >(val4);
   arg4 = &temp4;
-  std_vector_Sl_double_Sg__insert__SWIG_1(arg1,arg2,arg3,(double const &)*arg4);
+  (arg1)->insert(arg2,arg3,(std::vector<double >::value_type const &)*arg4);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -10848,18 +9274,18 @@ SWIGINTERN PyObject *_wrap_DoubleVector_insert(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 4); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<double >::iterator > *>(iter) != 0));
       if (_v) {
         {
           int res = SWIG_AsVal_double(argv[2], NULL);
@@ -10873,12 +9299,12 @@ SWIGINTERN PyObject *_wrap_DoubleVector_insert(PyObject *self, PyObject *args) {
   }
   if (argc == 4) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<double,std::allocator< double > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<double,std::allocator<double > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< double >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<double >::iterator > *>(iter) != 0));
       if (_v) {
         {
           int res = SWIG_AsVal_size_t(argv[2], NULL);
@@ -10898,18 +9324,15 @@ SWIGINTERN PyObject *_wrap_DoubleVector_insert(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DoubleVector_insert'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< double >::insert(std::vector< double >::iterator,std::vector< double >::value_type const &)\n"
-    "    std::vector< double >::insert(std::vector< double >::iterator,std::vector< double >::size_type,std::vector< double >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'DoubleVector_insert'.\n  Possible C/C++ prototypes are:\n    insert(std::vector<double >::iterator,std::vector<double >::value_type const &)\n    insert(std::vector<double >::iterator,std::vector<double >::size_type,std::vector<double >::value_type const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_DoubleVector_reserve(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
-  std::vector< double >::size_type arg2 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::size_type arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
@@ -10918,16 +9341,16 @@ SWIGINTERN PyObject *_wrap_DoubleVector_reserve(PyObject *SWIGUNUSEDPARM(self),
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:DoubleVector_reserve",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_reserve" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_reserve" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector_reserve" "', argument " "2"" of type '" "std::vector< double >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleVector_reserve" "', argument " "2"" of type '" "std::vector<double >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< double >::size_type >(val2);
+  arg2 = static_cast< std::vector<double >::size_type >(val2);
   (arg1)->reserve(arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -10938,19 +9361,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleVector_capacity(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
+  std::vector<double >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:DoubleVector_capacity",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_capacity" "', argument " "1"" of type '" "std::vector< double > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleVector_capacity" "', argument " "1"" of type '" "std::vector<double > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
-  result = ((std::vector< double > const *)arg1)->capacity();
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
+  result = ((std::vector<double > const *)arg1)->capacity();
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -10960,18 +9383,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_delete_DoubleVector(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< double > *arg1 = (std::vector< double > *) 0 ;
+  std::vector<double > *arg1 = (std::vector<double > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:delete_DoubleVector",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_POINTER_DISOWN |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_DoubleVector" "', argument " "1"" of type '" "std::vector< double > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_DoubleVector" "', argument " "1"" of type '" "std::vector<double > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< double > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<double > * >(argp1);
   delete arg1;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -10981,29 +9405,29 @@ fail:
 
 SWIGINTERN PyObject *DoubleVector_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
-  SWIG_TypeNewClientData(SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, SWIG_NewClientData(obj));
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
 
 SWIGINTERN PyObject *_wrap_DoubleDoubleVector_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_iterator" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_iterator" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  result = (swig::SwigPyIterator *)std_vector_Sl_std_vector_Sl_double_Sg__Sg__iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = (swig::PySwigIterator *)std_vector_Sl_std_vector_Sl_double_Sg__Sg__iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -11012,41 +9436,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleDoubleVector___nonzero__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
   bool result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector___nonzero__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___nonzero__" "', argument " "1"" of type '" "std::vector< std::vector< double > > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  result = (bool)std_vector_Sl_std_vector_Sl_double_Sg__Sg____nonzero__((std::vector< std::vector< double > > const *)arg1);
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___bool__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector___bool__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector___nonzero__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___bool__" "', argument " "1"" of type '" "std::vector< std::vector< double > > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___nonzero__" "', argument " "1"" of type '" "std::vector<std::vector<double > > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  result = (bool)std_vector_Sl_std_vector_Sl_double_Sg__Sg____bool__((std::vector< std::vector< double > > const *)arg1);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = (bool)std_vector_Sl_std_vector_Sl_double_Sg__Sg____nonzero__((std::vector<std::vector<double > > const *)arg1);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -11056,19 +9458,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleDoubleVector___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< std::vector< double > >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector___len__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___len__" "', argument " "1"" of type '" "std::vector< std::vector< double > > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___len__" "', argument " "1"" of type '" "std::vector<std::vector<double > > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  result = std_vector_Sl_std_vector_Sl_double_Sg__Sg____len__((std::vector< std::vector< double > > const *)arg1);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = std_vector_Sl_std_vector_Sl_double_Sg__Sg____len__((std::vector<std::vector<double > > const *)arg1);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -11078,18 +9480,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleDoubleVector_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::value_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< std::vector< double > >::value_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_pop",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_pop" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_pop" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
   try {
     result = std_vector_Sl_std_vector_Sl_double_Sg__Sg__pop(arg1);
   }
@@ -11097,7 +9499,7 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_pop(PyObject *SWIGUNUSEDPARM(self)
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
-  resultobj = swig::from(static_cast< std::vector<double,std::allocator< double > > >(result));
+  resultobj = swig::from(static_cast< std::vector<double,std::allocator<double > > >(result));
   return resultobj;
 fail:
   return NULL;
@@ -11106,9 +9508,10 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleDoubleVector___getslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::difference_type arg2 ;
-  std::vector< std::vector< double > >::difference_type arg3 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::difference_type arg2 ;
+  std::vector<std::vector<double > >::difference_type arg3 ;
+  std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -11118,47 +9521,43 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector___getslice__(PyObject *SWIGUNUSEDP
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
-  std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleDoubleVector___getslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___getslice__" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___getslice__" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector___getslice__" "', argument " "2"" of type '" "std::vector< std::vector< double > >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector___getslice__" "', argument " "2"" of type '" "std::vector<std::vector<double > >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< std::vector< double > >::difference_type >(val2);
+  arg2 = static_cast< std::vector<std::vector<double > >::difference_type >(val2);
   ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleDoubleVector___getslice__" "', argument " "3"" of type '" "std::vector< std::vector< double > >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleDoubleVector___getslice__" "', argument " "3"" of type '" "std::vector<std::vector<double > >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< std::vector< double > >::difference_type >(val3);
+  arg3 = static_cast< std::vector<std::vector<double > >::difference_type >(val3);
   try {
-    result = (std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *)std_vector_Sl_std_vector_Sl_double_Sg__Sg____getslice__(arg1,arg2,arg3);
+    result = (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > *)std_vector_Sl_std_vector_Sl_double_Sg__Sg____getslice__(arg1,arg2,arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, SWIG_POINTER_OWN |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___setslice____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector___setslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::difference_type arg2 ;
-  std::vector< std::vector< double > >::difference_type arg3 ;
-  std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *arg4 = 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::difference_type arg2 ;
+  std::vector<std::vector<double > >::difference_type arg3 ;
+  std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > *arg4 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -11172,34 +9571,34 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector___setslice____SWIG_0(PyObject *SWI
   PyObject * obj3 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOOO:DoubleDoubleVector___setslice__",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___setslice__" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___setslice__" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector___setslice__" "', argument " "2"" of type '" "std::vector< std::vector< double > >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector___setslice__" "', argument " "2"" of type '" "std::vector<std::vector<double > >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< std::vector< double > >::difference_type >(val2);
+  arg2 = static_cast< std::vector<std::vector<double > >::difference_type >(val2);
   ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleDoubleVector___setslice__" "', argument " "3"" of type '" "std::vector< std::vector< double > >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleDoubleVector___setslice__" "', argument " "3"" of type '" "std::vector<std::vector<double > >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< std::vector< double > >::difference_type >(val3);
+  arg3 = static_cast< std::vector<std::vector<double > >::difference_type >(val3);
   {
-    std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *ptr = (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *)0;
+    std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > *ptr = (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > *)0;
     res4 = swig::asptr(obj3, &ptr);
     if (!SWIG_IsOK(res4)) {
-      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "DoubleDoubleVector___setslice__" "', argument " "4"" of type '" "std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "DoubleDoubleVector___setslice__" "', argument " "4"" of type '" "std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector___setslice__" "', argument " "4"" of type '" "std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector___setslice__" "', argument " "4"" of type '" "std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > const &""'"); 
     }
     arg4 = ptr;
   }
   try {
-    std_vector_Sl_std_vector_Sl_double_Sg__Sg____setslice____SWIG_0(arg1,arg2,arg3,(std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > const &)*arg4);
+    std_vector_Sl_std_vector_Sl_double_Sg__Sg____setslice__(arg1,arg2,arg3,(std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > const &)*arg4);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
@@ -11217,11 +9616,11 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___setslice____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector___delslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::difference_type arg2 ;
-  std::vector< std::vector< double > >::difference_type arg3 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::difference_type arg2 ;
+  std::vector<std::vector<double > >::difference_type arg3 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -11232,31 +9631,28 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector___setslice____SWIG_1(PyObject *SWI
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleDoubleVector___setslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleDoubleVector___delslice__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___setslice__" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___delslice__" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector___setslice__" "', argument " "2"" of type '" "std::vector< std::vector< double > >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector___delslice__" "', argument " "2"" of type '" "std::vector<std::vector<double > >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< std::vector< double > >::difference_type >(val2);
+  arg2 = static_cast< std::vector<std::vector<double > >::difference_type >(val2);
   ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleDoubleVector___setslice__" "', argument " "3"" of type '" "std::vector< std::vector< double > >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleDoubleVector___delslice__" "', argument " "3"" of type '" "std::vector<std::vector<double > >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< std::vector< double > >::difference_type >(val3);
+  arg3 = static_cast< std::vector<std::vector<double > >::difference_type >(val3);
   try {
-    std_vector_Sl_std_vector_Sl_double_Sg__Sg____setslice____SWIG_0(arg1,arg2,arg3);
+    std_vector_Sl_std_vector_Sl_double_Sg__Sg____delslice__(arg1,arg2,arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -11265,278 +9661,304 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___setslice__(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[5];
-  int ii;
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector___delitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::difference_type arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
   
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector___delitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___delitem__" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  if (argc == 3) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        {
-          int res = SWIG_AsVal_ptrdiff_t(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          return _wrap_DoubleDoubleVector___setslice____SWIG_1(self, args);
-        }
-      }
-    }
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector___delitem__" "', argument " "2"" of type '" "std::vector<std::vector<double > >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector<std::vector<double > >::difference_type >(val2);
+  try {
+    std_vector_Sl_std_vector_Sl_double_Sg__Sg____delitem__(arg1,arg2);
   }
-  if (argc == 4) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        {
-          int res = SWIG_AsVal_ptrdiff_t(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          int res = swig::asptr(argv[3], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
-          _v = SWIG_CheckState(res);
-          if (_v) {
-            return _wrap_DoubleDoubleVector___setslice____SWIG_0(self, args);
-          }
-        }
-      }
-    }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
+  resultobj = SWIG_Py_Void();
+  return resultobj;
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DoubleDoubleVector___setslice__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::vector< double > >::__setslice__(std::vector< std::vector< double > >::difference_type,std::vector< std::vector< double > >::difference_type,std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > const &)\n"
-    "    std::vector< std::vector< double > >::__setslice__(std::vector< std::vector< double > >::difference_type,std::vector< std::vector< double > >::difference_type)\n");
-  return 0;
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___delslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::difference_type arg2 ;
-  std::vector< std::vector< double > >::difference_type arg3 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::difference_type arg2 ;
+  std::vector<std::vector<double > >::value_type *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
   int ecode2 = 0 ;
-  ptrdiff_t val3 ;
-  int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleDoubleVector___delslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector___getitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___delslice__" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___getitem__" "', argument " "1"" of type '" "std::vector<std::vector<double > > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector___delslice__" "', argument " "2"" of type '" "std::vector< std::vector< double > >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< std::vector< double > >::difference_type >(val2);
-  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleDoubleVector___delslice__" "', argument " "3"" of type '" "std::vector< std::vector< double > >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector___getitem__" "', argument " "2"" of type '" "std::vector<std::vector<double > >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< std::vector< double > >::difference_type >(val3);
+  arg2 = static_cast< std::vector<std::vector<double > >::difference_type >(val2);
   try {
-    std_vector_Sl_std_vector_Sl_double_Sg__Sg____delslice__(arg1,arg2,arg3);
+    {
+      std::vector<std::vector<double > >::value_type const &_result_ref = std_vector_Sl_std_vector_Sl_double_Sg__Sg____getitem__((std::vector<std::vector<double > > const *)arg1,arg2);
+      result = (std::vector<std::vector<double > >::value_type *) &_result_ref;
+    }
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
-  resultobj = SWIG_Py_Void();
+  resultobj = swig::from(static_cast< std::vector<double,std::allocator<double > > >(*result));
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___delitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector___setitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::difference_type arg2 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::difference_type arg2 ;
+  std::vector<std::vector<double > >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
   int ecode2 = 0 ;
+  int res3 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleDoubleVector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___delitem__" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___setitem__" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector___delitem__" "', argument " "2"" of type '" "std::vector< std::vector< double > >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector___setitem__" "', argument " "2"" of type '" "std::vector<std::vector<double > >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< std::vector< double > >::difference_type >(val2);
+  arg2 = static_cast< std::vector<std::vector<double > >::difference_type >(val2);
+  {
+    std::vector<double,std::allocator<double > > *ptr = (std::vector<double,std::allocator<double > > *)0;
+    res3 = swig::asptr(obj2, &ptr);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "DoubleDoubleVector___setitem__" "', argument " "3"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector___setitem__" "', argument " "3"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
+    }
+    arg3 = ptr;
+  }
   try {
-    std_vector_Sl_std_vector_Sl_double_Sg__Sg____delitem____SWIG_0(arg1,arg2);
+    std_vector_Sl_std_vector_Sl_double_Sg__Sg____setitem__(arg1,arg2,(std::vector<double,std::allocator<double > > const &)*arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
   resultobj = SWIG_Py_Void();
+  if (SWIG_IsNewObj(res3)) delete arg3;
   return resultobj;
 fail:
+  if (SWIG_IsNewObj(res3)) delete arg3;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___getitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::value_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector_append",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___getitem__" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_append" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
   {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector___getitem__" "', argument " "2"" of type '" "PySliceObject *""'");
+    std::vector<double,std::allocator<double > > *ptr = (std::vector<double,std::allocator<double > > *)0;
+    res2 = swig::asptr(obj1, &ptr);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DoubleDoubleVector_append" "', argument " "2"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
     }
-    arg2 = (PySliceObject *) obj1;
-  }
-  try {
-    result = (std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *)std_vector_Sl_std_vector_Sl_double_Sg__Sg____getitem____SWIG_0(arg1,arg2);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
-  }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector_append" "', argument " "2"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
+    }
+    arg2 = ptr;
   }
+  std_vector_Sl_std_vector_Sl_double_Sg__Sg__append(arg1,(std::vector<double,std::allocator<double > > const &)*arg2);
+  resultobj = SWIG_Py_Void();
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_DoubleDoubleVector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::vector<double > > *result = 0 ;
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, SWIG_POINTER_OWN |  0 );
+  if (!PyArg_ParseTuple(args,(char *)":new_DoubleDoubleVector")) SWIG_fail;
+  result = (std::vector<std::vector<double > > *)new std::vector<std::vector<double > >();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_DoubleDoubleVector__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
-  std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *arg3 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int res3 = SWIG_OLDOBJ ;
+  std::vector<std::vector<double,std::allocator<double > > > *arg1 = 0 ;
+  std::vector<std::vector<double > > *result = 0 ;
+  int res1 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleDoubleVector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___setitem__" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector___setitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
-  }
+  if (!PyArg_ParseTuple(args,(char *)"O:new_DoubleDoubleVector",&obj0)) SWIG_fail;
   {
-    std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *ptr = (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *)0;
-    res3 = swig::asptr(obj2, &ptr);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "DoubleDoubleVector___setitem__" "', argument " "3"" of type '" "std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > const &""'"); 
+    std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > *ptr = (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > *)0;
+    res1 = swig::asptr(obj0, &ptr);
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_DoubleDoubleVector" "', argument " "1"" of type '" "std::vector<std::vector<double,std::allocator<double > > > const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector___setitem__" "', argument " "3"" of type '" "std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_DoubleDoubleVector" "', argument " "1"" of type '" "std::vector<std::vector<double,std::allocator<double > > > const &""'"); 
     }
-    arg3 = ptr;
-  }
-  try {
-    std_vector_Sl_std_vector_Sl_double_Sg__Sg____setitem____SWIG_0(arg1,arg2,(std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > const &)*arg3);
+    arg1 = ptr;
   }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  result = (std::vector<std::vector<double > > *)new std::vector<std::vector<double > >((std::vector<std::vector<double,std::allocator<double > > > const &)*arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, SWIG_POINTER_NEW |  0 );
+  if (SWIG_IsNewObj(res1)) delete arg1;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res1)) delete arg1;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  bool result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_empty",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_empty" "', argument " "1"" of type '" "std::vector<std::vector<double > > const *""'"); 
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = (bool)((std::vector<std::vector<double > > const *)arg1)->empty();
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::size_type result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_size",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_size" "', argument " "1"" of type '" "std::vector<std::vector<double > > const *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = ((std::vector<std::vector<double > > const *)arg1)->size();
+  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_clear",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_clear" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  (arg1)->clear();
   resultobj = SWIG_Py_Void();
-  if (SWIG_IsNewObj(res3)) delete arg3;
   return resultobj;
 fail:
-  if (SWIG_IsNewObj(res3)) delete arg3;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double,std::allocator<double > > > *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector___setitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector_swap",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___setitem__" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector___setitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
-  }
-  try {
-    std_vector_Sl_std_vector_Sl_double_Sg__Sg____setitem____SWIG_1(arg1,arg2);
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_swap" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t,  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DoubleDoubleVector_swap" "', argument " "2"" of type '" "std::vector<std::vector<double,std::allocator<double > > > &""'"); 
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector_swap" "', argument " "2"" of type '" "std::vector<std::vector<double,std::allocator<double > > > &""'"); 
   }
-  
+  arg2 = reinterpret_cast< std::vector<std::vector<double,std::allocator<double > > > * >(argp2);
+  (arg1)->swap(*arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -11544,433 +9966,410 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___delitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  SwigValueWrapper<std::allocator<std::vector<double,std::allocator<double > > > > result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_get_allocator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___delitem__" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector___delitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
-  }
-  try {
-    std_vector_Sl_std_vector_Sl_double_Sg__Sg____delitem____SWIG_1(arg1,arg2);
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_get_allocator" "', argument " "1"" of type '" "std::vector<std::vector<double > > const *""'"); 
   }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
-  }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = ((std::vector<std::vector<double > > const *)arg1)->get_allocator();
+  resultobj = SWIG_NewPointerObj((new std::vector<std::vector<double > >::allocator_type(static_cast< const std::vector<std::vector<double > >::allocator_type& >(result))), SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t__allocator_type, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_begin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_begin" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = (arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::vector<double > >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_begin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  resultobj = SWIG_Py_Void();
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_begin" "', argument " "1"" of type '" "std::vector<std::vector<double > > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = ((std::vector<std::vector<double > > const *)arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::vector<double > >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___delitem__(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_begin(PyObject *self, PyObject *args) {
   int argc;
-  PyObject *argv[3];
+  PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 2) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_DoubleDoubleVector___delitem____SWIG_1(self, args);
-      }
+      return _wrap_DoubleDoubleVector_begin__SWIG_0(self, args);
     }
   }
-  if (argc == 2) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_DoubleDoubleVector___delitem____SWIG_0(self, args);
-      }
+      return _wrap_DoubleDoubleVector_begin__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DoubleDoubleVector___delitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::vector< double > >::__delitem__(std::vector< std::vector< double > >::difference_type)\n"
-    "    std::vector< std::vector< double > >::__delitem__(PySliceObject *)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'DoubleDoubleVector_begin'.\n  Possible C/C++ prototypes are:\n    begin()\n    begin()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___getitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_end__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::difference_type arg2 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  ptrdiff_t val2 ;
-  int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  std::vector< std::vector< double > >::value_type *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___getitem__" "', argument " "1"" of type '" "std::vector< std::vector< double > > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector___getitem__" "', argument " "2"" of type '" "std::vector< std::vector< double > >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< std::vector< double > >::difference_type >(val2);
-  try {
-    result = (std::vector< std::vector< double > >::value_type *) &std_vector_Sl_std_vector_Sl_double_Sg__Sg____getitem____SWIG_1((std::vector< std::vector< double > > const *)arg1,arg2);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_end" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = (arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::vector<double > >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_end__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  resultobj = swig::from(static_cast< std::vector<double,std::allocator< double > > >(*result));
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_end" "', argument " "1"" of type '" "std::vector<std::vector<double > > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = ((std::vector<std::vector<double > > const *)arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::vector<double > >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___getitem__(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_end(PyObject *self, PyObject *args) {
   int argc;
-  PyObject *argv[3];
+  PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 2) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_DoubleDoubleVector___getitem____SWIG_0(self, args);
-      }
+      return _wrap_DoubleDoubleVector_end__SWIG_0(self, args);
     }
   }
-  if (argc == 2) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_DoubleDoubleVector___getitem____SWIG_1(self, args);
-      }
+      return _wrap_DoubleDoubleVector_end__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DoubleDoubleVector___getitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::vector< double > >::__getitem__(PySliceObject *)\n"
-    "    std::vector< std::vector< double > >::__getitem__(std::vector< std::vector< double > >::difference_type) const\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'DoubleDoubleVector_end'.\n  Possible C/C++ prototypes are:\n    end()\n    end()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___setitem____SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_rbegin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::difference_type arg2 ;
-  std::vector< std::vector< double > >::value_type *arg3 = 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  ptrdiff_t val2 ;
-  int ecode2 = 0 ;
-  int res3 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleDoubleVector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector___setitem__" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector___setitem__" "', argument " "2"" of type '" "std::vector< std::vector< double > >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< std::vector< double > >::difference_type >(val2);
-  {
-    std::vector<double,std::allocator< double > > *ptr = (std::vector<double,std::allocator< double > > *)0;
-    res3 = swig::asptr(obj2, &ptr);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "DoubleDoubleVector___setitem__" "', argument " "3"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
-    }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector___setitem__" "', argument " "3"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
-    }
-    arg3 = ptr;
-  }
-  try {
-    std_vector_Sl_std_vector_Sl_double_Sg__Sg____setitem____SWIG_2(arg1,arg2,(std::vector< double,std::allocator< double > > const &)*arg3);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_rbegin" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = (arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::vector<double > >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_rbegin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::const_reverse_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  resultobj = SWIG_Py_Void();
-  if (SWIG_IsNewObj(res3)) delete arg3;
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_rbegin" "', argument " "1"" of type '" "std::vector<std::vector<double > > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = ((std::vector<std::vector<double > > const *)arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::vector<double > >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
-  if (SWIG_IsNewObj(res3)) delete arg3;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector___setitem__(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_rbegin(PyObject *self, PyObject *args) {
   int argc;
-  PyObject *argv[4];
+  PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_DoubleDoubleVector___setitem____SWIG_1(self, args);
-      }
-    }
-  }
-  if (argc == 3) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        int res = swig::asptr(argv[2], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_DoubleDoubleVector___setitem____SWIG_0(self, args);
-        }
-      }
+      return _wrap_DoubleDoubleVector_rbegin__SWIG_0(self, args);
     }
   }
-  if (argc == 3) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        int res = swig::asptr(argv[2], (std::vector<double,std::allocator< double > >**)(0));
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_DoubleDoubleVector___setitem____SWIG_2(self, args);
-        }
-      }
+      return _wrap_DoubleDoubleVector_rbegin__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DoubleDoubleVector___setitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::vector< double > >::__setitem__(PySliceObject *,std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > const &)\n"
-    "    std::vector< std::vector< double > >::__setitem__(PySliceObject *)\n"
-    "    std::vector< std::vector< double > >::__setitem__(std::vector< std::vector< double > >::difference_type,std::vector< std::vector< double > >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'DoubleDoubleVector_rbegin'.\n  Possible C/C++ prototypes are:\n    rbegin()\n    rbegin()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_rend__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::value_type *arg2 = 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector_append",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_append" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  {
-    std::vector<double,std::allocator< double > > *ptr = (std::vector<double,std::allocator< double > > *)0;
-    res2 = swig::asptr(obj1, &ptr);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DoubleDoubleVector_append" "', argument " "2"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
-    }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector_append" "', argument " "2"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
-    }
-    arg2 = ptr;
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_rend" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  std_vector_Sl_std_vector_Sl_double_Sg__Sg__append(arg1,(std::vector< double,std::allocator< double > > const &)*arg2);
-  resultobj = SWIG_Py_Void();
-  if (SWIG_IsNewObj(res2)) delete arg2;
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = (arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::vector<double > >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
-  if (SWIG_IsNewObj(res2)) delete arg2;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_DoubleDoubleVector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_rend__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *result = 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::const_reverse_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)":new_DoubleDoubleVector")) SWIG_fail;
-  result = (std::vector< std::vector< double > > *)new std::vector< std::vector< double > >();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, SWIG_POINTER_NEW |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_rend" "', argument " "1"" of type '" "std::vector<std::vector<double > > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = ((std::vector<std::vector<double > > const *)arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::vector<double > >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_DoubleDoubleVector__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::vector< double,std::allocator< double > > > *arg1 = 0 ;
-  int res1 = SWIG_OLDOBJ ;
-  PyObject * obj0 = 0 ;
-  std::vector< std::vector< double > > *result = 0 ;
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_rend(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:new_DoubleDoubleVector",&obj0)) SWIG_fail;
-  {
-    std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *ptr = (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *)0;
-    res1 = swig::asptr(obj0, &ptr);
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_DoubleDoubleVector" "', argument " "1"" of type '" "std::vector< std::vector< double,std::allocator< double > > > const &""'"); 
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_DoubleDoubleVector_rend__SWIG_0(self, args);
     }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_DoubleDoubleVector" "', argument " "1"" of type '" "std::vector< std::vector< double,std::allocator< double > > > const &""'"); 
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_DoubleDoubleVector_rend__SWIG_1(self, args);
     }
-    arg1 = ptr;
   }
-  result = (std::vector< std::vector< double > > *)new std::vector< std::vector< double > >((std::vector< std::vector< double,std::allocator< double > > > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, SWIG_POINTER_NEW |  0 );
-  if (SWIG_IsNewObj(res1)) delete arg1;
-  return resultobj;
+  
 fail:
-  if (SWIG_IsNewObj(res1)) delete arg1;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'DoubleDoubleVector_rend'.\n  Possible C/C++ prototypes are:\n    rend()\n    rend()\n");
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_DoubleDoubleVector__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
+  std::vector<std::vector<double > >::size_type arg1 ;
+  std::vector<std::vector<double > > *result = 0 ;
+  size_t val1 ;
+  int ecode1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_empty",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_empty" "', argument " "1"" of type '" "std::vector< std::vector< double > > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  result = (bool)((std::vector< std::vector< double > > const *)arg1)->empty();
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  if (!PyArg_ParseTuple(args,(char *)"O:new_DoubleDoubleVector",&obj0)) SWIG_fail;
+  ecode1 = SWIG_AsVal_size_t(obj0, &val1);
+  if (!SWIG_IsOK(ecode1)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_DoubleDoubleVector" "', argument " "1"" of type '" "std::vector<std::vector<double > >::size_type""'");
+  } 
+  arg1 = static_cast< std::vector<std::vector<double > >::size_type >(val1);
+  result = (std::vector<std::vector<double > > *)new std::vector<std::vector<double > >(arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_pop_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< std::vector< double > >::size_type result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_size",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_pop_back",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_size" "', argument " "1"" of type '" "std::vector< std::vector< double > > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_pop_back" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  result = ((std::vector< std::vector< double > > const *)arg1)->size();
-  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  (arg1)->pop_back();
+  resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_resize__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::size_type arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  size_t val2 ;
+  int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_clear",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector_resize",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_clear" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_resize" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  (arg1)->clear();
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  ecode2 = SWIG_AsVal_size_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector_resize" "', argument " "2"" of type '" "std::vector<std::vector<double > >::size_type""'");
+  } 
+  arg2 = static_cast< std::vector<std::vector<double > >::size_type >(val2);
+  (arg1)->resize(arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -11978,335 +10377,115 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double,std::allocator< double > > > *arg2 = 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::iterator arg2 ;
+  std::vector<std::vector<double > >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
+  int res2 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector_swap",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector_erase",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_swap" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t,  0 );
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DoubleDoubleVector_swap" "', argument " "2"" of type '" "std::vector< std::vector< double,std::allocator< double > > > &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_erase" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector_swap" "', argument " "2"" of type '" "std::vector< std::vector< double,std::allocator< double > > > &""'"); 
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res2) || !iter2) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_erase" "', argument " "2"" of type '" "std::vector<std::vector<double > >::iterator""'");
+  } else {
+    swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *>(iter2);
+    if (iter_t) {
+      arg2 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_erase" "', argument " "2"" of type '" "std::vector<std::vector<double > >::iterator""'");
+    }
   }
-  arg2 = reinterpret_cast< std::vector< std::vector< double,std::allocator< double > > > * >(argp2);
-  (arg1)->swap(*arg2);
-  resultobj = SWIG_Py_Void();
+  result = (arg1)->erase(arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::vector<double > >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_erase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::iterator arg2 ;
+  std::vector<std::vector<double > >::iterator arg3 ;
+  std::vector<std::vector<double > >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
+  int res2 ;
+  swig::PySwigIterator *iter3 = 0 ;
+  int res3 ;
   PyObject * obj0 = 0 ;
-  SwigValueWrapper< std::allocator< std::vector< double,std::allocator< double > > > > result;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_get_allocator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleDoubleVector_erase",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_get_allocator" "', argument " "1"" of type '" "std::vector< std::vector< double > > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_erase" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res2) || !iter2) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_erase" "', argument " "2"" of type '" "std::vector<std::vector<double > >::iterator""'");
+  } else {
+    swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *>(iter2);
+    if (iter_t) {
+      arg2 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_erase" "', argument " "2"" of type '" "std::vector<std::vector<double > >::iterator""'");
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::PySwigIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res3) || !iter3) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_erase" "', argument " "3"" of type '" "std::vector<std::vector<double > >::iterator""'");
+  } else {
+    swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *>(iter3);
+    if (iter_t) {
+      arg3 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_erase" "', argument " "3"" of type '" "std::vector<std::vector<double > >::iterator""'");
+    }
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  result = ((std::vector< std::vector< double > > const *)arg1)->get_allocator();
-  resultobj = SWIG_NewPointerObj((new std::vector< std::vector< double > >::allocator_type(static_cast< const std::vector< std::vector< double > >::allocator_type& >(result))), SWIGTYPE_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t, SWIG_POINTER_OWN |  0 );
+  result = (arg1)->erase(arg2,arg3);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::vector<double > >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_begin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< std::vector< double > >::iterator result;
+SWIGINTERN PyObject *_wrap_DoubleDoubleVector_erase(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[4];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_begin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_begin" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  result = (arg1)->begin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::vector< double > >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_end(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< std::vector< double > >::iterator result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_end",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_end" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  result = (arg1)->end();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::vector< double > >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_rbegin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< std::vector< double > >::reverse_iterator result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_rbegin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_rbegin" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  result = (arg1)->rbegin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::vector< double > >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_rend(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< std::vector< double > >::reverse_iterator result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_rend",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_rend" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  result = (arg1)->rend();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::vector< double > >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_DoubleDoubleVector__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::vector< double > >::size_type arg1 ;
-  size_t val1 ;
-  int ecode1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< std::vector< double > > *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:new_DoubleDoubleVector",&obj0)) SWIG_fail;
-  ecode1 = SWIG_AsVal_size_t(obj0, &val1);
-  if (!SWIG_IsOK(ecode1)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_DoubleDoubleVector" "', argument " "1"" of type '" "std::vector< std::vector< double > >::size_type""'");
-  } 
-  arg1 = static_cast< std::vector< std::vector< double > >::size_type >(val1);
-  result = (std::vector< std::vector< double > > *)new std::vector< std::vector< double > >(arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, SWIG_POINTER_NEW |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_pop_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_pop_back",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_pop_back" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  (arg1)->pop_back();
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_resize__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::size_type arg2 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  size_t val2 ;
-  int ecode2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector_resize",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_resize" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  ecode2 = SWIG_AsVal_size_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector_resize" "', argument " "2"" of type '" "std::vector< std::vector< double > >::size_type""'");
-  } 
-  arg2 = static_cast< std::vector< std::vector< double > >::size_type >(val2);
-  (arg1)->resize(arg2);
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::iterator arg2 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
-  int res2 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  std::vector< std::vector< double > >::iterator result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_erase" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
-  if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_erase" "', argument " "2"" of type '" "std::vector< std::vector< double > >::iterator""'");
-  } else {
-    swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *>(iter2);
-    if (iter_t) {
-      arg2 = iter_t->get_current();
-    } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_erase" "', argument " "2"" of type '" "std::vector< std::vector< double > >::iterator""'");
-    }
-  }
-  result = std_vector_Sl_std_vector_Sl_double_Sg__Sg__erase__SWIG_0(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::vector< double > >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_erase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::iterator arg2 ;
-  std::vector< std::vector< double > >::iterator arg3 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
-  int res2 ;
-  swig::SwigPyIterator *iter3 = 0 ;
-  int res3 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
-  std::vector< std::vector< double > >::iterator result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleDoubleVector_erase",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_erase" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
-  if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_erase" "', argument " "2"" of type '" "std::vector< std::vector< double > >::iterator""'");
-  } else {
-    swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *>(iter2);
-    if (iter_t) {
-      arg2 = iter_t->get_current();
-    } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_erase" "', argument " "2"" of type '" "std::vector< std::vector< double > >::iterator""'");
-    }
-  }
-  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::SwigPyIterator::descriptor(), 0);
-  if (!SWIG_IsOK(res3) || !iter3) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_erase" "', argument " "3"" of type '" "std::vector< std::vector< double > >::iterator""'");
-  } else {
-    swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *>(iter3);
-    if (iter_t) {
-      arg3 = iter_t->get_current();
-    } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_erase" "', argument " "3"" of type '" "std::vector< std::vector< double > >::iterator""'");
-    }
-  }
-  result = std_vector_Sl_std_vector_Sl_double_Sg__Sg__erase__SWIG_1(arg1,arg2,arg3);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::vector< double > >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_DoubleDoubleVector_erase(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[4];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *>(iter) != 0));
       if (_v) {
         return _wrap_DoubleDoubleVector_erase__SWIG_0(self, args);
       }
@@ -12314,16 +10493,16 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_erase(PyObject *self, PyObject *ar
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *>(iter) != 0));
       if (_v) {
-        swig::SwigPyIterator *iter = 0;
-        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *>(iter) != 0));
+        swig::PySwigIterator *iter = 0;
+        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *>(iter) != 0));
         if (_v) {
           return _wrap_DoubleDoubleVector_erase__SWIG_1(self, args);
         }
@@ -12332,44 +10511,41 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_erase(PyObject *self, PyObject *ar
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DoubleDoubleVector_erase'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::vector< double > >::erase(std::vector< std::vector< double > >::iterator)\n"
-    "    std::vector< std::vector< double > >::erase(std::vector< std::vector< double > >::iterator,std::vector< std::vector< double > >::iterator)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'DoubleDoubleVector_erase'.\n  Possible C/C++ prototypes are:\n    erase(std::vector<std::vector<double > >::iterator)\n    erase(std::vector<std::vector<double > >::iterator,std::vector<std::vector<double > >::iterator)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_new_DoubleDoubleVector__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > >::size_type arg1 ;
-  std::vector< std::vector< double > >::value_type *arg2 = 0 ;
+  std::vector<std::vector<double > >::size_type arg1 ;
+  std::vector<std::vector<double > >::value_type *arg2 = 0 ;
+  std::vector<std::vector<double > > *result = 0 ;
   size_t val1 ;
   int ecode1 = 0 ;
   int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::vector< std::vector< double > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:new_DoubleDoubleVector",&obj0,&obj1)) SWIG_fail;
   ecode1 = SWIG_AsVal_size_t(obj0, &val1);
   if (!SWIG_IsOK(ecode1)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_DoubleDoubleVector" "', argument " "1"" of type '" "std::vector< std::vector< double > >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_DoubleDoubleVector" "', argument " "1"" of type '" "std::vector<std::vector<double > >::size_type""'");
   } 
-  arg1 = static_cast< std::vector< std::vector< double > >::size_type >(val1);
+  arg1 = static_cast< std::vector<std::vector<double > >::size_type >(val1);
   {
-    std::vector<double,std::allocator< double > > *ptr = (std::vector<double,std::allocator< double > > *)0;
+    std::vector<double,std::allocator<double > > *ptr = (std::vector<double,std::allocator<double > > *)0;
     res2 = swig::asptr(obj1, &ptr);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_DoubleDoubleVector" "', argument " "2"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_DoubleDoubleVector" "', argument " "2"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_DoubleDoubleVector" "', argument " "2"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_DoubleDoubleVector" "', argument " "2"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
     }
     arg2 = ptr;
   }
-  result = (std::vector< std::vector< double > > *)new std::vector< std::vector< double > >(arg1,(std::vector< std::vector< double > >::value_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, SWIG_POINTER_NEW |  0 );
+  result = (std::vector<std::vector<double > > *)new std::vector<std::vector<double > >(arg1,(std::vector<std::vector<double > >::value_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, SWIG_POINTER_NEW |  0 );
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
 fail:
@@ -12384,8 +10560,8 @@ SWIGINTERN PyObject *_wrap_new_DoubleDoubleVector(PyObject *self, PyObject *args
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 0) {
@@ -12403,7 +10579,7 @@ SWIGINTERN PyObject *_wrap_new_DoubleDoubleVector(PyObject *self, PyObject *args
   }
   if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       return _wrap_new_DoubleDoubleVector__SWIG_1(self, args);
@@ -12416,7 +10592,7 @@ SWIGINTERN PyObject *_wrap_new_DoubleDoubleVector(PyObject *self, PyObject *args
       _v = SWIG_CheckState(res);
     }
     if (_v) {
-      int res = swig::asptr(argv[1], (std::vector<double,std::allocator< double > >**)(0));
+      int res = swig::asptr(argv[1], (std::vector<double,std::allocator<double > >**)(0));
       _v = SWIG_CheckState(res);
       if (_v) {
         return _wrap_new_DoubleDoubleVector__SWIG_3(self, args);
@@ -12425,20 +10601,15 @@ SWIGINTERN PyObject *_wrap_new_DoubleDoubleVector(PyObject *self, PyObject *args
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_DoubleDoubleVector'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::vector< double > >::vector()\n"
-    "    std::vector< std::vector< double > >::vector(std::vector< std::vector< double,std::allocator< double > > > const &)\n"
-    "    std::vector< std::vector< double > >::vector(std::vector< std::vector< double > >::size_type)\n"
-    "    std::vector< std::vector< double > >::vector(std::vector< std::vector< double > >::size_type,std::vector< std::vector< double > >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_DoubleDoubleVector'.\n  Possible C/C++ prototypes are:\n    std::vector<(std::vector<(double)>)>()\n    std::vector<(std::vector<(double)>)>(std::vector<std::vector<double,std::allocator<double > > > const &)\n    std::vector<(std::vector<(double)>)>(std::vector<std::vector<double > >::size_type)\n    std::vector<(std::vector<(double)>)>(std::vector<std::vector<double > >::size_type,std:: [...]
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_DoubleDoubleVector_push_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::value_type *arg2 = 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::value_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 = SWIG_OLDOBJ ;
@@ -12446,23 +10617,23 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_push_back(PyObject *SWIGUNUSEDPARM
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector_push_back",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_push_back" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_push_back" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
   {
-    std::vector<double,std::allocator< double > > *ptr = (std::vector<double,std::allocator< double > > *)0;
+    std::vector<double,std::allocator<double > > *ptr = (std::vector<double,std::allocator<double > > *)0;
     res2 = swig::asptr(obj1, &ptr);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DoubleDoubleVector_push_back" "', argument " "2"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "DoubleDoubleVector_push_back" "', argument " "2"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector_push_back" "', argument " "2"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector_push_back" "', argument " "2"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
     }
     arg2 = ptr;
   }
-  (arg1)->push_back((std::vector< std::vector< double > >::value_type const &)*arg2);
+  (arg1)->push_back((std::vector<std::vector<double > >::value_type const &)*arg2);
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -12474,20 +10645,23 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleDoubleVector_front(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::value_type *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< std::vector< double > >::value_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_front",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_front" "', argument " "1"" of type '" "std::vector< std::vector< double > > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_front" "', argument " "1"" of type '" "std::vector<std::vector<double > > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  {
+    std::vector<std::vector<double > >::value_type const &_result_ref = ((std::vector<std::vector<double > > const *)arg1)->front();
+    result = (std::vector<std::vector<double > >::value_type *) &_result_ref;
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  result = (std::vector< std::vector< double > >::value_type *) &((std::vector< std::vector< double > > const *)arg1)->front();
-  resultobj = swig::from(static_cast< std::vector<double,std::allocator< double > > >(*result));
+  resultobj = swig::from(static_cast< std::vector<double,std::allocator<double > > >(*result));
   return resultobj;
 fail:
   return NULL;
@@ -12496,20 +10670,23 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleDoubleVector_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::value_type *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< std::vector< double > >::value_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_back",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_back" "', argument " "1"" of type '" "std::vector< std::vector< double > > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_back" "', argument " "1"" of type '" "std::vector<std::vector<double > > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  {
+    std::vector<std::vector<double > >::value_type const &_result_ref = ((std::vector<std::vector<double > > const *)arg1)->back();
+    result = (std::vector<std::vector<double > >::value_type *) &_result_ref;
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  result = (std::vector< std::vector< double > >::value_type *) &((std::vector< std::vector< double > > const *)arg1)->back();
-  resultobj = swig::from(static_cast< std::vector<double,std::allocator< double > > >(*result));
+  resultobj = swig::from(static_cast< std::vector<double,std::allocator<double > > >(*result));
   return resultobj;
 fail:
   return NULL;
@@ -12518,9 +10695,9 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleDoubleVector_assign(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::size_type arg2 ;
-  std::vector< std::vector< double > >::value_type *arg3 = 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::size_type arg2 ;
+  std::vector<std::vector<double > >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
@@ -12531,28 +10708,28 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_assign(PyObject *SWIGUNUSEDPARM(se
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleDoubleVector_assign",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_assign" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_assign" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector_assign" "', argument " "2"" of type '" "std::vector< std::vector< double > >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector_assign" "', argument " "2"" of type '" "std::vector<std::vector<double > >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< std::vector< double > >::size_type >(val2);
+  arg2 = static_cast< std::vector<std::vector<double > >::size_type >(val2);
   {
-    std::vector<double,std::allocator< double > > *ptr = (std::vector<double,std::allocator< double > > *)0;
+    std::vector<double,std::allocator<double > > *ptr = (std::vector<double,std::allocator<double > > *)0;
     res3 = swig::asptr(obj2, &ptr);
     if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "DoubleDoubleVector_assign" "', argument " "3"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "DoubleDoubleVector_assign" "', argument " "3"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector_assign" "', argument " "3"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector_assign" "', argument " "3"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
     }
     arg3 = ptr;
   }
-  (arg1)->assign(arg2,(std::vector< std::vector< double > >::value_type const &)*arg3);
+  (arg1)->assign(arg2,(std::vector<std::vector<double > >::value_type const &)*arg3);
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res3)) delete arg3;
   return resultobj;
@@ -12564,9 +10741,9 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleDoubleVector_resize__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::size_type arg2 ;
-  std::vector< std::vector< double > >::value_type *arg3 = 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::size_type arg2 ;
+  std::vector<std::vector<double > >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
@@ -12577,28 +10754,28 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_resize__SWIG_1(PyObject *SWIGUNUSE
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleDoubleVector_resize",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_resize" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_resize" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector_resize" "', argument " "2"" of type '" "std::vector< std::vector< double > >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector_resize" "', argument " "2"" of type '" "std::vector<std::vector<double > >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< std::vector< double > >::size_type >(val2);
+  arg2 = static_cast< std::vector<std::vector<double > >::size_type >(val2);
   {
-    std::vector<double,std::allocator< double > > *ptr = (std::vector<double,std::allocator< double > > *)0;
+    std::vector<double,std::allocator<double > > *ptr = (std::vector<double,std::allocator<double > > *)0;
     res3 = swig::asptr(obj2, &ptr);
     if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "DoubleDoubleVector_resize" "', argument " "3"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "DoubleDoubleVector_resize" "', argument " "3"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector_resize" "', argument " "3"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector_resize" "', argument " "3"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
     }
     arg3 = ptr;
   }
-  (arg1)->resize(arg2,(std::vector< std::vector< double > >::value_type const &)*arg3);
+  (arg1)->resize(arg2,(std::vector<std::vector<double > >::value_type const &)*arg3);
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res3)) delete arg3;
   return resultobj;
@@ -12614,13 +10791,13 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_resize(PyObject *self, PyObject *a
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -12634,7 +10811,7 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_resize(PyObject *self, PyObject *a
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -12642,7 +10819,7 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_resize(PyObject *self, PyObject *a
         _v = SWIG_CheckState(res);
       }
       if (_v) {
-        int res = swig::asptr(argv[2], (std::vector<double,std::allocator< double > >**)(0));
+        int res = swig::asptr(argv[2], (std::vector<double,std::allocator<double > >**)(0));
         _v = SWIG_CheckState(res);
         if (_v) {
           return _wrap_DoubleDoubleVector_resize__SWIG_1(self, args);
@@ -12652,60 +10829,57 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_resize(PyObject *self, PyObject *a
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DoubleDoubleVector_resize'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::vector< double > >::resize(std::vector< std::vector< double > >::size_type)\n"
-    "    std::vector< std::vector< double > >::resize(std::vector< std::vector< double > >::size_type,std::vector< std::vector< double > >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'DoubleDoubleVector_resize'.\n  Possible C/C++ prototypes are:\n    resize(std::vector<std::vector<double > >::size_type)\n    resize(std::vector<std::vector<double > >::size_type,std::vector<std::vector<double > >::value_type const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_DoubleDoubleVector_insert__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::iterator arg2 ;
-  std::vector< std::vector< double > >::value_type *arg3 = 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::iterator arg2 ;
+  std::vector<std::vector<double > >::value_type *arg3 = 0 ;
+  std::vector<std::vector<double > >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   int res3 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
-  std::vector< std::vector< double > >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:DoubleDoubleVector_insert",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_insert" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_insert" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_insert" "', argument " "2"" of type '" "std::vector< std::vector< double > >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_insert" "', argument " "2"" of type '" "std::vector<std::vector<double > >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_insert" "', argument " "2"" of type '" "std::vector< std::vector< double > >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_insert" "', argument " "2"" of type '" "std::vector<std::vector<double > >::iterator""'");
     }
   }
   {
-    std::vector<double,std::allocator< double > > *ptr = (std::vector<double,std::allocator< double > > *)0;
+    std::vector<double,std::allocator<double > > *ptr = (std::vector<double,std::allocator<double > > *)0;
     res3 = swig::asptr(obj2, &ptr);
     if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "DoubleDoubleVector_insert" "', argument " "3"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "DoubleDoubleVector_insert" "', argument " "3"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector_insert" "', argument " "3"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector_insert" "', argument " "3"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
     }
     arg3 = ptr;
   }
-  result = std_vector_Sl_std_vector_Sl_double_Sg__Sg__insert__SWIG_0(arg1,arg2,(std::vector< double,std::allocator< double > > const &)*arg3);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::vector< double > >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->insert(arg2,(std::vector<std::vector<double > >::value_type const &)*arg3);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::vector<double > >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   if (SWIG_IsNewObj(res3)) delete arg3;
   return resultobj;
 fail:
@@ -12716,13 +10890,13 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleDoubleVector_insert__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::iterator arg2 ;
-  std::vector< std::vector< double > >::size_type arg3 ;
-  std::vector< std::vector< double > >::value_type *arg4 = 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::iterator arg2 ;
+  std::vector<std::vector<double > >::size_type arg3 ;
+  std::vector<std::vector<double > >::value_type *arg4 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   size_t val3 ;
   int ecode3 = 0 ;
@@ -12733,39 +10907,39 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_insert__SWIG_1(PyObject *SWIGUNUSE
   PyObject * obj3 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOOO:DoubleDoubleVector_insert",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_insert" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_insert" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_insert" "', argument " "2"" of type '" "std::vector< std::vector< double > >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_insert" "', argument " "2"" of type '" "std::vector<std::vector<double > >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_insert" "', argument " "2"" of type '" "std::vector< std::vector< double > >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "DoubleDoubleVector_insert" "', argument " "2"" of type '" "std::vector<std::vector<double > >::iterator""'");
     }
   }
   ecode3 = SWIG_AsVal_size_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleDoubleVector_insert" "', argument " "3"" of type '" "std::vector< std::vector< double > >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "DoubleDoubleVector_insert" "', argument " "3"" of type '" "std::vector<std::vector<double > >::size_type""'");
   } 
-  arg3 = static_cast< std::vector< std::vector< double > >::size_type >(val3);
+  arg3 = static_cast< std::vector<std::vector<double > >::size_type >(val3);
   {
-    std::vector<double,std::allocator< double > > *ptr = (std::vector<double,std::allocator< double > > *)0;
+    std::vector<double,std::allocator<double > > *ptr = (std::vector<double,std::allocator<double > > *)0;
     res4 = swig::asptr(obj3, &ptr);
     if (!SWIG_IsOK(res4)) {
-      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "DoubleDoubleVector_insert" "', argument " "4"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "DoubleDoubleVector_insert" "', argument " "4"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector_insert" "', argument " "4"" of type '" "std::vector< std::vector< double > >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "DoubleDoubleVector_insert" "', argument " "4"" of type '" "std::vector<std::vector<double > >::value_type const &""'"); 
     }
     arg4 = ptr;
   }
-  std_vector_Sl_std_vector_Sl_double_Sg__Sg__insert__SWIG_1(arg1,arg2,arg3,(std::vector< double,std::allocator< double > > const &)*arg4);
+  (arg1)->insert(arg2,arg3,(std::vector<std::vector<double > >::value_type const &)*arg4);
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res4)) delete arg4;
   return resultobj;
@@ -12781,20 +10955,20 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_insert(PyObject *self, PyObject *a
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 4); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *>(iter) != 0));
       if (_v) {
-        int res = swig::asptr(argv[2], (std::vector<double,std::allocator< double > >**)(0));
+        int res = swig::asptr(argv[2], (std::vector<double,std::allocator<double > >**)(0));
         _v = SWIG_CheckState(res);
         if (_v) {
           return _wrap_DoubleDoubleVector_insert__SWIG_0(self, args);
@@ -12804,19 +10978,19 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_insert(PyObject *self, PyObject *a
   }
   if (argc == 4) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< std::vector< double > >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<std::vector<double > >::iterator > *>(iter) != 0));
       if (_v) {
         {
           int res = SWIG_AsVal_size_t(argv[2], NULL);
           _v = SWIG_CheckState(res);
         }
         if (_v) {
-          int res = swig::asptr(argv[3], (std::vector<double,std::allocator< double > >**)(0));
+          int res = swig::asptr(argv[3], (std::vector<double,std::allocator<double > >**)(0));
           _v = SWIG_CheckState(res);
           if (_v) {
             return _wrap_DoubleDoubleVector_insert__SWIG_1(self, args);
@@ -12827,18 +11001,15 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_insert(PyObject *self, PyObject *a
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'DoubleDoubleVector_insert'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::vector< double > >::insert(std::vector< std::vector< double > >::iterator,std::vector< std::vector< double > >::value_type const &)\n"
-    "    std::vector< std::vector< double > >::insert(std::vector< std::vector< double > >::iterator,std::vector< std::vector< double > >::size_type,std::vector< std::vector< double > >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'DoubleDoubleVector_insert'.\n  Possible C/C++ prototypes are:\n    insert(std::vector<std::vector<double > >::iterator,std::vector<std::vector<double > >::value_type const &)\n    insert(std::vector<std::vector<double > >::iterator,std::vector<std::vector<double > >::size_type,std::vector<std::vector<double > >::value_type const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_DoubleDoubleVector_reserve(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
-  std::vector< std::vector< double > >::size_type arg2 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::size_type arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
@@ -12847,16 +11018,16 @@ SWIGINTERN PyObject *_wrap_DoubleDoubleVector_reserve(PyObject *SWIGUNUSEDPARM(s
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:DoubleDoubleVector_reserve",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_reserve" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_reserve" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector_reserve" "', argument " "2"" of type '" "std::vector< std::vector< double > >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "DoubleDoubleVector_reserve" "', argument " "2"" of type '" "std::vector<std::vector<double > >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< std::vector< double > >::size_type >(val2);
+  arg2 = static_cast< std::vector<std::vector<double > >::size_type >(val2);
   (arg1)->reserve(arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -12867,19 +11038,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_DoubleDoubleVector_capacity(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
+  std::vector<std::vector<double > >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< std::vector< double > >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:DoubleDoubleVector_capacity",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_capacity" "', argument " "1"" of type '" "std::vector< std::vector< double > > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "DoubleDoubleVector_capacity" "', argument " "1"" of type '" "std::vector<std::vector<double > > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
-  result = ((std::vector< std::vector< double > > const *)arg1)->capacity();
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
+  result = ((std::vector<std::vector<double > > const *)arg1)->capacity();
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -12889,18 +11060,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_delete_DoubleDoubleVector(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::vector< double > > *arg1 = (std::vector< std::vector< double > > *) 0 ;
+  std::vector<std::vector<double > > *arg1 = (std::vector<std::vector<double > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:delete_DoubleDoubleVector",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, SWIG_POINTER_DISOWN |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_DoubleDoubleVector" "', argument " "1"" of type '" "std::vector< std::vector< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_DoubleDoubleVector" "', argument " "1"" of type '" "std::vector<std::vector<double > > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::vector< double > > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::vector<double > > * >(argp1);
   delete arg1;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -12910,29 +11082,29 @@ fail:
 
 SWIGINTERN PyObject *DoubleDoubleVector_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
-  SWIG_TypeNewClientData(SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, SWIG_NewClientData(obj));
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
 
 SWIGINTERN PyObject *_wrap_StringVector_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:StringVector_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_iterator" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_iterator" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  result = (swig::SwigPyIterator *)std_vector_Sl_std_string_Sg__iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = (swig::PySwigIterator *)std_vector_Sl_std_string_Sg__iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -12941,41 +11113,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_StringVector___nonzero__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
   bool result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:StringVector___nonzero__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___nonzero__" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  result = (bool)std_vector_Sl_std_string_Sg____nonzero__((std::vector< std::string > const *)arg1);
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_StringVector___bool__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:StringVector___bool__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector___nonzero__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___bool__" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___nonzero__" "', argument " "1"" of type '" "std::vector<std::string > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  result = (bool)std_vector_Sl_std_string_Sg____bool__((std::vector< std::string > const *)arg1);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = (bool)std_vector_Sl_std_string_Sg____nonzero__((std::vector<std::string > const *)arg1);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -12985,19 +11135,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_StringVector___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< std::string >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:StringVector___len__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___len__" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___len__" "', argument " "1"" of type '" "std::vector<std::string > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  result = std_vector_Sl_std_string_Sg____len__((std::vector< std::string > const *)arg1);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = std_vector_Sl_std_string_Sg____len__((std::vector<std::string > const *)arg1);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -13007,18 +11157,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_StringVector_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::value_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< std::string >::value_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:StringVector_pop",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_pop" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_pop" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
   try {
     result = std_vector_Sl_std_string_Sg__pop(arg1);
   }
@@ -13035,9 +11185,10 @@ fail:
 
 SWIGINTERN PyObject *_wrap_StringVector___getslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::difference_type arg2 ;
-  std::vector< std::string >::difference_type arg3 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::difference_type arg2 ;
+  std::vector<std::string >::difference_type arg3 ;
+  std::vector<std::string,std::allocator<std::string > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -13047,47 +11198,43 @@ SWIGINTERN PyObject *_wrap_StringVector___getslice__(PyObject *SWIGUNUSEDPARM(se
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
-  std::vector< std::string,std::allocator< std::string > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:StringVector___getslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___getslice__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___getslice__" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector___getslice__" "', argument " "2"" of type '" "std::vector< std::string >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector___getslice__" "', argument " "2"" of type '" "std::vector<std::string >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< std::string >::difference_type >(val2);
+  arg2 = static_cast< std::vector<std::string >::difference_type >(val2);
   ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "StringVector___getslice__" "', argument " "3"" of type '" "std::vector< std::string >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "StringVector___getslice__" "', argument " "3"" of type '" "std::vector<std::string >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< std::string >::difference_type >(val3);
+  arg3 = static_cast< std::vector<std::string >::difference_type >(val3);
   try {
-    result = (std::vector< std::string,std::allocator< std::string > > *)std_vector_Sl_std_string_Sg____getslice__(arg1,arg2,arg3);
+    result = (std::vector<std::string,std::allocator<std::string > > *)std_vector_Sl_std_string_Sg____getslice__(arg1,arg2,arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, SWIG_POINTER_OWN |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector___setslice____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector___setslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::difference_type arg2 ;
-  std::vector< std::string >::difference_type arg3 ;
-  std::vector< std::string,std::allocator< std::string > > *arg4 = 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::difference_type arg2 ;
+  std::vector<std::string >::difference_type arg3 ;
+  std::vector<std::string,std::allocator<std::string > > *arg4 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -13101,34 +11248,34 @@ SWIGINTERN PyObject *_wrap_StringVector___setslice____SWIG_0(PyObject *SWIGUNUSE
   PyObject * obj3 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOOO:StringVector___setslice__",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___setslice__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___setslice__" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector___setslice__" "', argument " "2"" of type '" "std::vector< std::string >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector___setslice__" "', argument " "2"" of type '" "std::vector<std::string >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< std::string >::difference_type >(val2);
+  arg2 = static_cast< std::vector<std::string >::difference_type >(val2);
   ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "StringVector___setslice__" "', argument " "3"" of type '" "std::vector< std::string >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "StringVector___setslice__" "', argument " "3"" of type '" "std::vector<std::string >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< std::string >::difference_type >(val3);
+  arg3 = static_cast< std::vector<std::string >::difference_type >(val3);
   {
-    std::vector<std::string,std::allocator< std::string > > *ptr = (std::vector<std::string,std::allocator< std::string > > *)0;
+    std::vector<std::string,std::allocator<std::string > > *ptr = (std::vector<std::string,std::allocator<std::string > > *)0;
     res4 = swig::asptr(obj3, &ptr);
     if (!SWIG_IsOK(res4)) {
-      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "StringVector___setslice__" "', argument " "4"" of type '" "std::vector< std::string,std::allocator< std::string > > const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "StringVector___setslice__" "', argument " "4"" of type '" "std::vector<std::string,std::allocator<std::string > > const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector___setslice__" "', argument " "4"" of type '" "std::vector< std::string,std::allocator< std::string > > const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector___setslice__" "', argument " "4"" of type '" "std::vector<std::string,std::allocator<std::string > > const &""'"); 
     }
     arg4 = ptr;
   }
   try {
-    std_vector_Sl_std_string_Sg____setslice____SWIG_0(arg1,arg2,arg3,(std::vector< std::string,std::allocator< std::string > > const &)*arg4);
+    std_vector_Sl_std_string_Sg____setslice__(arg1,arg2,arg3,(std::vector<std::string,std::allocator<std::string > > const &)*arg4);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
@@ -13146,11 +11293,11 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector___setslice____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector___delslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::difference_type arg2 ;
-  std::vector< std::string >::difference_type arg3 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::difference_type arg2 ;
+  std::vector<std::string >::difference_type arg3 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -13161,31 +11308,28 @@ SWIGINTERN PyObject *_wrap_StringVector___setslice____SWIG_1(PyObject *SWIGUNUSE
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:StringVector___setslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OOO:StringVector___delslice__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___setslice__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___delslice__" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector___setslice__" "', argument " "2"" of type '" "std::vector< std::string >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector___delslice__" "', argument " "2"" of type '" "std::vector<std::string >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< std::string >::difference_type >(val2);
+  arg2 = static_cast< std::vector<std::string >::difference_type >(val2);
   ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "StringVector___setslice__" "', argument " "3"" of type '" "std::vector< std::string >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "StringVector___delslice__" "', argument " "3"" of type '" "std::vector<std::string >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< std::string >::difference_type >(val3);
+  arg3 = static_cast< std::vector<std::string >::difference_type >(val3);
   try {
-    std_vector_Sl_std_string_Sg____setslice____SWIG_0(arg1,arg2,arg3);
+    std_vector_Sl_std_string_Sg____delslice__(arg1,arg2,arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -13194,278 +11338,304 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector___setslice__(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[5];
-  int ii;
+SWIGINTERN PyObject *_wrap_StringVector___delitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::difference_type arg2 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
   
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector___delitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___delitem__" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  if (argc == 3) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        {
-          int res = SWIG_AsVal_ptrdiff_t(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          return _wrap_StringVector___setslice____SWIG_1(self, args);
-        }
-      }
-    }
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector___delitem__" "', argument " "2"" of type '" "std::vector<std::string >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector<std::string >::difference_type >(val2);
+  try {
+    std_vector_Sl_std_string_Sg____delitem__(arg1,arg2);
   }
-  if (argc == 4) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        {
-          int res = SWIG_AsVal_ptrdiff_t(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          int res = swig::asptr(argv[3], (std::vector<std::string,std::allocator< std::string > >**)(0));
-          _v = SWIG_CheckState(res);
-          if (_v) {
-            return _wrap_StringVector___setslice____SWIG_0(self, args);
-          }
-        }
-      }
-    }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
+  resultobj = SWIG_Py_Void();
+  return resultobj;
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'StringVector___setslice__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::string >::__setslice__(std::vector< std::string >::difference_type,std::vector< std::string >::difference_type,std::vector< std::string,std::allocator< std::string > > const &)\n"
-    "    std::vector< std::string >::__setslice__(std::vector< std::string >::difference_type,std::vector< std::string >::difference_type)\n");
-  return 0;
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector___delslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::difference_type arg2 ;
-  std::vector< std::string >::difference_type arg3 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::difference_type arg2 ;
+  std::vector<std::string >::value_type *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
   int ecode2 = 0 ;
-  ptrdiff_t val3 ;
-  int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:StringVector___delslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector___getitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___delslice__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___getitem__" "', argument " "1"" of type '" "std::vector<std::string > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector___delslice__" "', argument " "2"" of type '" "std::vector< std::string >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< std::string >::difference_type >(val2);
-  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "StringVector___delslice__" "', argument " "3"" of type '" "std::vector< std::string >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector___getitem__" "', argument " "2"" of type '" "std::vector<std::string >::difference_type""'");
   } 
-  arg3 = static_cast< std::vector< std::string >::difference_type >(val3);
+  arg2 = static_cast< std::vector<std::string >::difference_type >(val2);
   try {
-    std_vector_Sl_std_string_Sg____delslice__(arg1,arg2,arg3);
+    {
+      std::vector<std::string >::value_type const &_result_ref = std_vector_Sl_std_string_Sg____getitem__((std::vector<std::string > const *)arg1,arg2);
+      result = (std::vector<std::string >::value_type *) &_result_ref;
+    }
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
-  resultobj = SWIG_Py_Void();
+  resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector___delitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector___setitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::difference_type arg2 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::difference_type arg2 ;
+  std::vector<std::string >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
   int ecode2 = 0 ;
+  int res3 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OOO:StringVector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___delitem__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___setitem__" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector___delitem__" "', argument " "2"" of type '" "std::vector< std::string >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector___setitem__" "', argument " "2"" of type '" "std::vector<std::string >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< std::string >::difference_type >(val2);
+  arg2 = static_cast< std::vector<std::string >::difference_type >(val2);
+  {
+    std::string *ptr = (std::string *)0;
+    res3 = SWIG_AsPtr_std_string(obj2, &ptr);
+    if (!SWIG_IsOK(res3)) {
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringVector___setitem__" "', argument " "3"" of type '" "std::vector<std::string >::value_type const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector___setitem__" "', argument " "3"" of type '" "std::vector<std::string >::value_type const &""'"); 
+    }
+    arg3 = ptr;
+  }
   try {
-    std_vector_Sl_std_string_Sg____delitem____SWIG_0(arg1,arg2);
+    std_vector_Sl_std_string_Sg____setitem__(arg1,arg2,(std::string const &)*arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
   resultobj = SWIG_Py_Void();
+  if (SWIG_IsNewObj(res3)) delete arg3;
   return resultobj;
 fail:
+  if (SWIG_IsNewObj(res3)) delete arg3;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector___getitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::value_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::vector< std::string,std::allocator< std::string > > *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector_append",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___getitem__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_append" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
   {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector___getitem__" "', argument " "2"" of type '" "PySliceObject *""'");
+    std::string *ptr = (std::string *)0;
+    res2 = SWIG_AsPtr_std_string(obj1, &ptr);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringVector_append" "', argument " "2"" of type '" "std::vector<std::string >::value_type const &""'"); 
     }
-    arg2 = (PySliceObject *) obj1;
-  }
-  try {
-    result = (std::vector< std::string,std::allocator< std::string > > *)std_vector_Sl_std_string_Sg____getitem____SWIG_0(arg1,arg2);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
-  }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector_append" "', argument " "2"" of type '" "std::vector<std::string >::value_type const &""'"); 
+    }
+    arg2 = ptr;
   }
+  std_vector_Sl_std_string_Sg__append(arg1,(std::string const &)*arg2);
+  resultobj = SWIG_Py_Void();
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_StringVector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::string > *result = 0 ;
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, SWIG_POINTER_OWN |  0 );
+  if (!PyArg_ParseTuple(args,(char *)":new_StringVector")) SWIG_fail;
+  result = (std::vector<std::string > *)new std::vector<std::string >();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_StringVector__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
-  std::vector< std::string,std::allocator< std::string > > *arg3 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int res3 = SWIG_OLDOBJ ;
+  std::vector<std::string > *arg1 = 0 ;
+  std::vector<std::string > *result = 0 ;
+  int res1 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:StringVector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___setitem__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector___setitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
-  }
+  if (!PyArg_ParseTuple(args,(char *)"O:new_StringVector",&obj0)) SWIG_fail;
   {
-    std::vector<std::string,std::allocator< std::string > > *ptr = (std::vector<std::string,std::allocator< std::string > > *)0;
-    res3 = swig::asptr(obj2, &ptr);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringVector___setitem__" "', argument " "3"" of type '" "std::vector< std::string,std::allocator< std::string > > const &""'"); 
+    std::vector<std::string,std::allocator<std::string > > *ptr = (std::vector<std::string,std::allocator<std::string > > *)0;
+    res1 = swig::asptr(obj0, &ptr);
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_StringVector" "', argument " "1"" of type '" "std::vector<std::string > const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector___setitem__" "', argument " "3"" of type '" "std::vector< std::string,std::allocator< std::string > > const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringVector" "', argument " "1"" of type '" "std::vector<std::string > const &""'"); 
     }
-    arg3 = ptr;
-  }
-  try {
-    std_vector_Sl_std_string_Sg____setitem____SWIG_0(arg1,arg2,(std::vector< std::string,std::allocator< std::string > > const &)*arg3);
+    arg1 = ptr;
   }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  result = (std::vector<std::string > *)new std::vector<std::string >((std::vector<std::string > const &)*arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, SWIG_POINTER_NEW |  0 );
+  if (SWIG_IsNewObj(res1)) delete arg1;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res1)) delete arg1;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_StringVector_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  bool result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_empty",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_empty" "', argument " "1"" of type '" "std::vector<std::string > const *""'"); 
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = (bool)((std::vector<std::string > const *)arg1)->empty();
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_StringVector_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::size_type result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_size",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_size" "', argument " "1"" of type '" "std::vector<std::string > const *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = ((std::vector<std::string > const *)arg1)->size();
+  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_StringVector_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_clear",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_clear" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  (arg1)->clear();
   resultobj = SWIG_Py_Void();
-  if (SWIG_IsNewObj(res3)) delete arg3;
   return resultobj;
 fail:
-  if (SWIG_IsNewObj(res3)) delete arg3;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string > *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector___setitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector_swap",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___setitem__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector___setitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
-  }
-  try {
-    std_vector_Sl_std_string_Sg____setitem____SWIG_1(arg1,arg2);
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_swap" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t,  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringVector_swap" "', argument " "2"" of type '" "std::vector<std::string > &""'"); 
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector_swap" "', argument " "2"" of type '" "std::vector<std::string > &""'"); 
   }
-  
+  arg2 = reinterpret_cast< std::vector<std::string > * >(argp2);
+  (arg1)->swap(*arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -13473,433 +11643,380 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector___delitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  SwigValueWrapper<std::allocator<std::string > > result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_get_allocator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___delitem__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector___delitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_get_allocator" "', argument " "1"" of type '" "std::vector<std::string > const *""'"); 
   }
-  try {
-    std_vector_Sl_std_string_Sg____delitem____SWIG_1(arg1,arg2);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
-  }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = ((std::vector<std::string > const *)arg1)->get_allocator();
+  resultobj = SWIG_NewPointerObj((new std::vector<std::string >::allocator_type(static_cast< const std::vector<std::string >::allocator_type& >(result))), SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t__allocator_type, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_StringVector_begin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_begin" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = (arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::string >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_StringVector_begin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  resultobj = SWIG_Py_Void();
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_begin" "', argument " "1"" of type '" "std::vector<std::string > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = ((std::vector<std::string > const *)arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::string >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector___delitem__(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_begin(PyObject *self, PyObject *args) {
   int argc;
-  PyObject *argv[3];
+  PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 2) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_StringVector___delitem____SWIG_1(self, args);
-      }
+      return _wrap_StringVector_begin__SWIG_0(self, args);
     }
   }
-  if (argc == 2) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_StringVector___delitem____SWIG_0(self, args);
-      }
+      return _wrap_StringVector_begin__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'StringVector___delitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::string >::__delitem__(std::vector< std::string >::difference_type)\n"
-    "    std::vector< std::string >::__delitem__(PySliceObject *)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'StringVector_begin'.\n  Possible C/C++ prototypes are:\n    begin()\n    begin()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector___getitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_end__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::difference_type arg2 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  ptrdiff_t val2 ;
-  int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  std::vector< std::string >::value_type *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___getitem__" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector___getitem__" "', argument " "2"" of type '" "std::vector< std::string >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< std::string >::difference_type >(val2);
-  try {
-    result = (std::vector< std::string >::value_type *) &std_vector_Sl_std_string_Sg____getitem____SWIG_1((std::vector< std::string > const *)arg1,arg2);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_end" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  
-  resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = (arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::string >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector___getitem__(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[3];
-  int ii;
+SWIGINTERN PyObject *_wrap_StringVector_end__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_end" "', argument " "1"" of type '" "std::vector<std::string > const *""'"); 
   }
-  if (argc == 2) {
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = ((std::vector<std::string > const *)arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::string >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_StringVector_end(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_StringVector___getitem____SWIG_0(self, args);
-      }
+      return _wrap_StringVector_end__SWIG_0(self, args);
     }
   }
-  if (argc == 2) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_StringVector___getitem____SWIG_1(self, args);
-      }
+      return _wrap_StringVector_end__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'StringVector___getitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::string >::__getitem__(PySliceObject *)\n"
-    "    std::vector< std::string >::__getitem__(std::vector< std::string >::difference_type) const\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'StringVector_end'.\n  Possible C/C++ prototypes are:\n    end()\n    end()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector___setitem____SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_rbegin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::difference_type arg2 ;
-  std::vector< std::string >::value_type *arg3 = 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  ptrdiff_t val2 ;
-  int ecode2 = 0 ;
-  int res3 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:StringVector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector___setitem__" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector___setitem__" "', argument " "2"" of type '" "std::vector< std::string >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< std::string >::difference_type >(val2);
-  {
-    std::string *ptr = (std::string *)0;
-    res3 = SWIG_AsPtr_std_string(obj2, &ptr);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringVector___setitem__" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); 
-    }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector___setitem__" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); 
-    }
-    arg3 = ptr;
-  }
-  try {
-    std_vector_Sl_std_string_Sg____setitem____SWIG_2(arg1,arg2,(std::string const &)*arg3);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_rbegin" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = (arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::string >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_StringVector_rbegin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::const_reverse_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  resultobj = SWIG_Py_Void();
-  if (SWIG_IsNewObj(res3)) delete arg3;
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_rbegin" "', argument " "1"" of type '" "std::vector<std::string > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = ((std::vector<std::string > const *)arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::string >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
-  if (SWIG_IsNewObj(res3)) delete arg3;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector___setitem__(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_rbegin(PyObject *self, PyObject *args) {
   int argc;
-  PyObject *argv[4];
+  PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_StringVector___setitem____SWIG_1(self, args);
-      }
-    }
-  }
-  if (argc == 3) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        int res = swig::asptr(argv[2], (std::vector<std::string,std::allocator< std::string > >**)(0));
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_StringVector___setitem____SWIG_0(self, args);
-        }
-      }
+      return _wrap_StringVector_rbegin__SWIG_0(self, args);
     }
   }
-  if (argc == 3) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0));
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_StringVector___setitem____SWIG_2(self, args);
-        }
-      }
+      return _wrap_StringVector_rbegin__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'StringVector___setitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::string >::__setitem__(PySliceObject *,std::vector< std::string,std::allocator< std::string > > const &)\n"
-    "    std::vector< std::string >::__setitem__(PySliceObject *)\n"
-    "    std::vector< std::string >::__setitem__(std::vector< std::string >::difference_type,std::vector< std::string >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'StringVector_rbegin'.\n  Possible C/C++ prototypes are:\n    rbegin()\n    rbegin()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_rend__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::value_type *arg2 = 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector_append",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_append" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  {
-    std::string *ptr = (std::string *)0;
-    res2 = SWIG_AsPtr_std_string(obj1, &ptr);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringVector_append" "', argument " "2"" of type '" "std::vector< std::string >::value_type const &""'"); 
-    }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector_append" "', argument " "2"" of type '" "std::vector< std::string >::value_type const &""'"); 
-    }
-    arg2 = ptr;
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_rend" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  std_vector_Sl_std_string_Sg__append(arg1,(std::string const &)*arg2);
-  resultobj = SWIG_Py_Void();
-  if (SWIG_IsNewObj(res2)) delete arg2;
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = (arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::string >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
-  if (SWIG_IsNewObj(res2)) delete arg2;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_StringVector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_rend__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *result = 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::const_reverse_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)":new_StringVector")) SWIG_fail;
-  result = (std::vector< std::string > *)new std::vector< std::string >();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, SWIG_POINTER_NEW |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_rend" "', argument " "1"" of type '" "std::vector<std::string > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = ((std::vector<std::string > const *)arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::string >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_StringVector__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = 0 ;
-  int res1 = SWIG_OLDOBJ ;
-  PyObject * obj0 = 0 ;
-  std::vector< std::string > *result = 0 ;
+SWIGINTERN PyObject *_wrap_StringVector_rend(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:new_StringVector",&obj0)) SWIG_fail;
-  {
-    std::vector<std::string,std::allocator< std::string > > *ptr = (std::vector<std::string,std::allocator< std::string > > *)0;
-    res1 = swig::asptr(obj0, &ptr);
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_StringVector" "', argument " "1"" of type '" "std::vector< std::string > const &""'"); 
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_StringVector_rend__SWIG_0(self, args);
     }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringVector" "', argument " "1"" of type '" "std::vector< std::string > const &""'"); 
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_StringVector_rend__SWIG_1(self, args);
     }
-    arg1 = ptr;
   }
-  result = (std::vector< std::string > *)new std::vector< std::string >((std::vector< std::string > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, SWIG_POINTER_NEW |  0 );
-  if (SWIG_IsNewObj(res1)) delete arg1;
-  return resultobj;
-fail:
-  if (SWIG_IsNewObj(res1)) delete arg1;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_StringVector_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_empty",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_empty" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  result = (bool)((std::vector< std::string > const *)arg1)->empty();
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
-  return resultobj;
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'StringVector_rend'.\n  Possible C/C++ prototypes are:\n    rend()\n    rend()\n");
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_StringVector__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
+  std::vector<std::string >::size_type arg1 ;
+  std::vector<std::string > *result = 0 ;
+  size_t val1 ;
+  int ecode1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< std::string >::size_type result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_size",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_size" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  result = ((std::vector< std::string > const *)arg1)->size();
-  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  if (!PyArg_ParseTuple(args,(char *)"O:new_StringVector",&obj0)) SWIG_fail;
+  ecode1 = SWIG_AsVal_size_t(obj0, &val1);
+  if (!SWIG_IsOK(ecode1)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_StringVector" "', argument " "1"" of type '" "std::vector<std::string >::size_type""'");
+  } 
+  arg1 = static_cast< std::vector<std::string >::size_type >(val1);
+  result = (std::vector<std::string > *)new std::vector<std::string >(arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_pop_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_clear",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_pop_back",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_clear" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_pop_back" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  (arg1)->clear();
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  (arg1)->pop_back();
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -13907,32 +12024,29 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_resize__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string > *arg2 = 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::size_type arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
+  size_t val2 ;
+  int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector_swap",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector_resize",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_swap" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t,  0 );
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringVector_swap" "', argument " "2"" of type '" "std::vector< std::string > &""'"); 
-  }
-  if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector_swap" "', argument " "2"" of type '" "std::vector< std::string > &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_resize" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< std::string > * >(argp2);
-  (arg1)->swap(*arg2);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  ecode2 = SWIG_AsVal_size_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector_resize" "', argument " "2"" of type '" "std::vector<std::string >::size_type""'");
+  } 
+  arg2 = static_cast< std::vector<std::string >::size_type >(val2);
+  (arg1)->resize(arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -13940,302 +12054,115 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::iterator arg2 ;
+  std::vector<std::string >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
+  int res2 ;
   PyObject * obj0 = 0 ;
-  SwigValueWrapper< std::allocator< std::string > > result;
+  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_get_allocator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector_erase",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_get_allocator" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_erase" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res2) || !iter2) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_erase" "', argument " "2"" of type '" "std::vector<std::string >::iterator""'");
+  } else {
+    swig::PySwigIterator_T<std::vector<std::string >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<std::string >::iterator > *>(iter2);
+    if (iter_t) {
+      arg2 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_erase" "', argument " "2"" of type '" "std::vector<std::string >::iterator""'");
+    }
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  result = ((std::vector< std::string > const *)arg1)->get_allocator();
-  resultobj = SWIG_NewPointerObj((new std::vector< std::string >::allocator_type(static_cast< const std::vector< std::string >::allocator_type& >(result))), SWIGTYPE_p_std__allocatorT_std__string_t, SWIG_POINTER_OWN |  0 );
+  result = (arg1)->erase(arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::string >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector_begin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_erase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::iterator arg2 ;
+  std::vector<std::string >::iterator arg3 ;
+  std::vector<std::string >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
+  int res2 ;
+  swig::PySwigIterator *iter3 = 0 ;
+  int res3 ;
   PyObject * obj0 = 0 ;
-  std::vector< std::string >::iterator result;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_begin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OOO:StringVector_erase",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_begin" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_erase" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  result = (arg1)->begin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::string >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res2) || !iter2) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_erase" "', argument " "2"" of type '" "std::vector<std::string >::iterator""'");
+  } else {
+    swig::PySwigIterator_T<std::vector<std::string >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<std::string >::iterator > *>(iter2);
+    if (iter_t) {
+      arg2 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_erase" "', argument " "2"" of type '" "std::vector<std::string >::iterator""'");
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::PySwigIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res3) || !iter3) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_erase" "', argument " "3"" of type '" "std::vector<std::string >::iterator""'");
+  } else {
+    swig::PySwigIterator_T<std::vector<std::string >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<std::string >::iterator > *>(iter3);
+    if (iter_t) {
+      arg3 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_erase" "', argument " "3"" of type '" "std::vector<std::string >::iterator""'");
+    }
+  }
+  result = (arg1)->erase(arg2,arg3);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::string >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_StringVector_end(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< std::string >::iterator result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_end",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_end" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  result = (arg1)->end();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::string >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_StringVector_rbegin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< std::string >::reverse_iterator result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_rbegin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_rbegin" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  result = (arg1)->rbegin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::string >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_StringVector_rend(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< std::string >::reverse_iterator result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_rend",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_rend" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  result = (arg1)->rend();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::string >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_StringVector__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::string >::size_type arg1 ;
-  size_t val1 ;
-  int ecode1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< std::string > *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:new_StringVector",&obj0)) SWIG_fail;
-  ecode1 = SWIG_AsVal_size_t(obj0, &val1);
-  if (!SWIG_IsOK(ecode1)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_StringVector" "', argument " "1"" of type '" "std::vector< std::string >::size_type""'");
-  } 
-  arg1 = static_cast< std::vector< std::string >::size_type >(val1);
-  result = (std::vector< std::string > *)new std::vector< std::string >(arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, SWIG_POINTER_NEW |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_StringVector_pop_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_pop_back",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_pop_back" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  (arg1)->pop_back();
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_StringVector_resize__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::size_type arg2 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  size_t val2 ;
-  int ecode2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector_resize",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_resize" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  ecode2 = SWIG_AsVal_size_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector_resize" "', argument " "2"" of type '" "std::vector< std::string >::size_type""'");
-  } 
-  arg2 = static_cast< std::vector< std::string >::size_type >(val2);
-  (arg1)->resize(arg2);
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_StringVector_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::iterator arg2 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
-  int res2 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  std::vector< std::string >::iterator result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_erase" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
-  if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_erase" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'");
-  } else {
-    swig::SwigPyIterator_T<std::vector< std::string >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< std::string >::iterator > *>(iter2);
-    if (iter_t) {
-      arg2 = iter_t->get_current();
-    } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_erase" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'");
-    }
-  }
-  result = std_vector_Sl_std_string_Sg__erase__SWIG_0(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::string >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_StringVector_erase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::iterator arg2 ;
-  std::vector< std::string >::iterator arg3 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
-  int res2 ;
-  swig::SwigPyIterator *iter3 = 0 ;
-  int res3 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
-  std::vector< std::string >::iterator result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OOO:StringVector_erase",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_erase" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
-  if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_erase" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'");
-  } else {
-    swig::SwigPyIterator_T<std::vector< std::string >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< std::string >::iterator > *>(iter2);
-    if (iter_t) {
-      arg2 = iter_t->get_current();
-    } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_erase" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'");
-    }
-  }
-  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::SwigPyIterator::descriptor(), 0);
-  if (!SWIG_IsOK(res3) || !iter3) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_erase" "', argument " "3"" of type '" "std::vector< std::string >::iterator""'");
-  } else {
-    swig::SwigPyIterator_T<std::vector< std::string >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< std::string >::iterator > *>(iter3);
-    if (iter_t) {
-      arg3 = iter_t->get_current();
-    } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_erase" "', argument " "3"" of type '" "std::vector< std::string >::iterator""'");
-    }
-  }
-  result = std_vector_Sl_std_string_Sg__erase__SWIG_1(arg1,arg2,arg3);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::string >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_StringVector_erase(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[4];
-  int ii;
+SWIGINTERN PyObject *_wrap_StringVector_erase(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[4];
+  int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< std::string >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<std::string >::iterator > *>(iter) != 0));
       if (_v) {
         return _wrap_StringVector_erase__SWIG_0(self, args);
       }
@@ -14243,16 +12170,16 @@ SWIGINTERN PyObject *_wrap_StringVector_erase(PyObject *self, PyObject *args) {
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< std::string >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<std::string >::iterator > *>(iter) != 0));
       if (_v) {
-        swig::SwigPyIterator *iter = 0;
-        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< std::string >::iterator > *>(iter) != 0));
+        swig::PySwigIterator *iter = 0;
+        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<std::string >::iterator > *>(iter) != 0));
         if (_v) {
           return _wrap_StringVector_erase__SWIG_1(self, args);
         }
@@ -14261,44 +12188,41 @@ SWIGINTERN PyObject *_wrap_StringVector_erase(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'StringVector_erase'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::string >::erase(std::vector< std::string >::iterator)\n"
-    "    std::vector< std::string >::erase(std::vector< std::string >::iterator,std::vector< std::string >::iterator)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'StringVector_erase'.\n  Possible C/C++ prototypes are:\n    erase(std::vector<std::string >::iterator)\n    erase(std::vector<std::string >::iterator,std::vector<std::string >::iterator)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_new_StringVector__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string >::size_type arg1 ;
-  std::vector< std::string >::value_type *arg2 = 0 ;
+  std::vector<std::string >::size_type arg1 ;
+  std::vector<std::string >::value_type *arg2 = 0 ;
+  std::vector<std::string > *result = 0 ;
   size_t val1 ;
   int ecode1 = 0 ;
   int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::vector< std::string > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:new_StringVector",&obj0,&obj1)) SWIG_fail;
   ecode1 = SWIG_AsVal_size_t(obj0, &val1);
   if (!SWIG_IsOK(ecode1)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_StringVector" "', argument " "1"" of type '" "std::vector< std::string >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_StringVector" "', argument " "1"" of type '" "std::vector<std::string >::size_type""'");
   } 
-  arg1 = static_cast< std::vector< std::string >::size_type >(val1);
+  arg1 = static_cast< std::vector<std::string >::size_type >(val1);
   {
     std::string *ptr = (std::string *)0;
     res2 = SWIG_AsPtr_std_string(obj1, &ptr);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_StringVector" "', argument " "2"" of type '" "std::vector< std::string >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_StringVector" "', argument " "2"" of type '" "std::vector<std::string >::value_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringVector" "', argument " "2"" of type '" "std::vector< std::string >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_StringVector" "', argument " "2"" of type '" "std::vector<std::string >::value_type const &""'"); 
     }
     arg2 = ptr;
   }
-  result = (std::vector< std::string > *)new std::vector< std::string >(arg1,(std::vector< std::string >::value_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, SWIG_POINTER_NEW |  0 );
+  result = (std::vector<std::string > *)new std::vector<std::string >(arg1,(std::vector<std::string >::value_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, SWIG_POINTER_NEW |  0 );
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
 fail:
@@ -14313,8 +12237,8 @@ SWIGINTERN PyObject *_wrap_new_StringVector(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 0) {
@@ -14332,7 +12256,7 @@ SWIGINTERN PyObject *_wrap_new_StringVector(PyObject *self, PyObject *args) {
   }
   if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       return _wrap_new_StringVector__SWIG_1(self, args);
@@ -14354,20 +12278,15 @@ SWIGINTERN PyObject *_wrap_new_StringVector(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_StringVector'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::string >::vector()\n"
-    "    std::vector< std::string >::vector(std::vector< std::string > const &)\n"
-    "    std::vector< std::string >::vector(std::vector< std::string >::size_type)\n"
-    "    std::vector< std::string >::vector(std::vector< std::string >::size_type,std::vector< std::string >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_StringVector'.\n  Possible C/C++ prototypes are:\n    std::vector<(std::string)>()\n    std::vector<(std::string)>(std::vector<std::string > const &)\n    std::vector<(std::string)>(std::vector<std::string >::size_type)\n    std::vector<(std::string)>(std::vector<std::string >::size_type,std::vector<std::string >::value_type const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_StringVector_push_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::value_type *arg2 = 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::value_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 = SWIG_OLDOBJ ;
@@ -14375,23 +12294,23 @@ SWIGINTERN PyObject *_wrap_StringVector_push_back(PyObject *SWIGUNUSEDPARM(self)
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:StringVector_push_back",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_push_back" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_push_back" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
   {
     std::string *ptr = (std::string *)0;
     res2 = SWIG_AsPtr_std_string(obj1, &ptr);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringVector_push_back" "', argument " "2"" of type '" "std::vector< std::string >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "StringVector_push_back" "', argument " "2"" of type '" "std::vector<std::string >::value_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector_push_back" "', argument " "2"" of type '" "std::vector< std::string >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector_push_back" "', argument " "2"" of type '" "std::vector<std::string >::value_type const &""'"); 
     }
     arg2 = ptr;
   }
-  (arg1)->push_back((std::vector< std::string >::value_type const &)*arg2);
+  (arg1)->push_back((std::vector<std::string >::value_type const &)*arg2);
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -14403,19 +12322,22 @@ fail:
 
 SWIGINTERN PyObject *_wrap_StringVector_front(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::value_type *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< std::string >::value_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:StringVector_front",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_front" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_front" "', argument " "1"" of type '" "std::vector<std::string > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  {
+    std::vector<std::string >::value_type const &_result_ref = ((std::vector<std::string > const *)arg1)->front();
+    result = (std::vector<std::string >::value_type *) &_result_ref;
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  result = (std::vector< std::string >::value_type *) &((std::vector< std::string > const *)arg1)->front();
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -14425,19 +12347,22 @@ fail:
 
 SWIGINTERN PyObject *_wrap_StringVector_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::value_type *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< std::string >::value_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:StringVector_back",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_back" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_back" "', argument " "1"" of type '" "std::vector<std::string > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  {
+    std::vector<std::string >::value_type const &_result_ref = ((std::vector<std::string > const *)arg1)->back();
+    result = (std::vector<std::string >::value_type *) &_result_ref;
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  result = (std::vector< std::string >::value_type *) &((std::vector< std::string > const *)arg1)->back();
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -14447,9 +12372,9 @@ fail:
 
 SWIGINTERN PyObject *_wrap_StringVector_assign(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::size_type arg2 ;
-  std::vector< std::string >::value_type *arg3 = 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::size_type arg2 ;
+  std::vector<std::string >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
@@ -14460,28 +12385,28 @@ SWIGINTERN PyObject *_wrap_StringVector_assign(PyObject *SWIGUNUSEDPARM(self), P
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:StringVector_assign",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_assign" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_assign" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector_assign" "', argument " "2"" of type '" "std::vector< std::string >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector_assign" "', argument " "2"" of type '" "std::vector<std::string >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< std::string >::size_type >(val2);
+  arg2 = static_cast< std::vector<std::string >::size_type >(val2);
   {
     std::string *ptr = (std::string *)0;
     res3 = SWIG_AsPtr_std_string(obj2, &ptr);
     if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringVector_assign" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringVector_assign" "', argument " "3"" of type '" "std::vector<std::string >::value_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector_assign" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector_assign" "', argument " "3"" of type '" "std::vector<std::string >::value_type const &""'"); 
     }
     arg3 = ptr;
   }
-  (arg1)->assign(arg2,(std::vector< std::string >::value_type const &)*arg3);
+  (arg1)->assign(arg2,(std::vector<std::string >::value_type const &)*arg3);
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res3)) delete arg3;
   return resultobj;
@@ -14493,9 +12418,9 @@ fail:
 
 SWIGINTERN PyObject *_wrap_StringVector_resize__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::size_type arg2 ;
-  std::vector< std::string >::value_type *arg3 = 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::size_type arg2 ;
+  std::vector<std::string >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
@@ -14506,28 +12431,28 @@ SWIGINTERN PyObject *_wrap_StringVector_resize__SWIG_1(PyObject *SWIGUNUSEDPARM(
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:StringVector_resize",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_resize" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_resize" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector_resize" "', argument " "2"" of type '" "std::vector< std::string >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector_resize" "', argument " "2"" of type '" "std::vector<std::string >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< std::string >::size_type >(val2);
+  arg2 = static_cast< std::vector<std::string >::size_type >(val2);
   {
     std::string *ptr = (std::string *)0;
     res3 = SWIG_AsPtr_std_string(obj2, &ptr);
     if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringVector_resize" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringVector_resize" "', argument " "3"" of type '" "std::vector<std::string >::value_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector_resize" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector_resize" "', argument " "3"" of type '" "std::vector<std::string >::value_type const &""'"); 
     }
     arg3 = ptr;
   }
-  (arg1)->resize(arg2,(std::vector< std::string >::value_type const &)*arg3);
+  (arg1)->resize(arg2,(std::vector<std::string >::value_type const &)*arg3);
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res3)) delete arg3;
   return resultobj;
@@ -14543,13 +12468,13 @@ SWIGINTERN PyObject *_wrap_StringVector_resize(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -14563,7 +12488,7 @@ SWIGINTERN PyObject *_wrap_StringVector_resize(PyObject *self, PyObject *args) {
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -14581,60 +12506,57 @@ SWIGINTERN PyObject *_wrap_StringVector_resize(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'StringVector_resize'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::string >::resize(std::vector< std::string >::size_type)\n"
-    "    std::vector< std::string >::resize(std::vector< std::string >::size_type,std::vector< std::string >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'StringVector_resize'.\n  Possible C/C++ prototypes are:\n    resize(std::vector<std::string >::size_type)\n    resize(std::vector<std::string >::size_type,std::vector<std::string >::value_type const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_StringVector_insert__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::iterator arg2 ;
-  std::vector< std::string >::value_type *arg3 = 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::iterator arg2 ;
+  std::vector<std::string >::value_type *arg3 = 0 ;
+  std::vector<std::string >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   int res3 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
-  std::vector< std::string >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:StringVector_insert",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_insert" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_insert" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_insert" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_insert" "', argument " "2"" of type '" "std::vector<std::string >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< std::string >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< std::string >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<std::string >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<std::string >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_insert" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_insert" "', argument " "2"" of type '" "std::vector<std::string >::iterator""'");
     }
   }
   {
     std::string *ptr = (std::string *)0;
     res3 = SWIG_AsPtr_std_string(obj2, &ptr);
     if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringVector_insert" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "StringVector_insert" "', argument " "3"" of type '" "std::vector<std::string >::value_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector_insert" "', argument " "3"" of type '" "std::vector< std::string >::value_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector_insert" "', argument " "3"" of type '" "std::vector<std::string >::value_type const &""'"); 
     }
     arg3 = ptr;
   }
-  result = std_vector_Sl_std_string_Sg__insert__SWIG_0(arg1,arg2,(std::string const &)*arg3);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< std::string >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->insert(arg2,(std::vector<std::string >::value_type const &)*arg3);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<std::string >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   if (SWIG_IsNewObj(res3)) delete arg3;
   return resultobj;
 fail:
@@ -14645,13 +12567,13 @@ fail:
 
 SWIGINTERN PyObject *_wrap_StringVector_insert__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::iterator arg2 ;
-  std::vector< std::string >::size_type arg3 ;
-  std::vector< std::string >::value_type *arg4 = 0 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::iterator arg2 ;
+  std::vector<std::string >::size_type arg3 ;
+  std::vector<std::string >::value_type *arg4 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   size_t val3 ;
   int ecode3 = 0 ;
@@ -14662,516 +12584,93 @@ SWIGINTERN PyObject *_wrap_StringVector_insert__SWIG_1(PyObject *SWIGUNUSEDPARM(
   PyObject * obj3 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOOO:StringVector_insert",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_insert" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
-  if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_insert" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'");
-  } else {
-    swig::SwigPyIterator_T<std::vector< std::string >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< std::string >::iterator > *>(iter2);
-    if (iter_t) {
-      arg2 = iter_t->get_current();
-    } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_insert" "', argument " "2"" of type '" "std::vector< std::string >::iterator""'");
-    }
-  }
-  ecode3 = SWIG_AsVal_size_t(obj2, &val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "StringVector_insert" "', argument " "3"" of type '" "std::vector< std::string >::size_type""'");
-  } 
-  arg3 = static_cast< std::vector< std::string >::size_type >(val3);
-  {
-    std::string *ptr = (std::string *)0;
-    res4 = SWIG_AsPtr_std_string(obj3, &ptr);
-    if (!SWIG_IsOK(res4)) {
-      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "StringVector_insert" "', argument " "4"" of type '" "std::vector< std::string >::value_type const &""'"); 
-    }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector_insert" "', argument " "4"" of type '" "std::vector< std::string >::value_type const &""'"); 
-    }
-    arg4 = ptr;
-  }
-  std_vector_Sl_std_string_Sg__insert__SWIG_1(arg1,arg2,arg3,(std::string const &)*arg4);
-  resultobj = SWIG_Py_Void();
-  if (SWIG_IsNewObj(res4)) delete arg4;
-  return resultobj;
-fail:
-  if (SWIG_IsNewObj(res4)) delete arg4;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_StringVector_insert(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[5];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 3) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< std::string >::iterator > *>(iter) != 0));
-      if (_v) {
-        int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0));
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_StringVector_insert__SWIG_0(self, args);
-        }
-      }
-    }
-  }
-  if (argc == 4) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator< std::string > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< std::string >::iterator > *>(iter) != 0));
-      if (_v) {
-        {
-          int res = SWIG_AsVal_size_t(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
-        if (_v) {
-          int res = SWIG_AsPtr_std_string(argv[3], (std::string**)(0));
-          _v = SWIG_CheckState(res);
-          if (_v) {
-            return _wrap_StringVector_insert__SWIG_1(self, args);
-          }
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'StringVector_insert'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< std::string >::insert(std::vector< std::string >::iterator,std::vector< std::string >::value_type const &)\n"
-    "    std::vector< std::string >::insert(std::vector< std::string >::iterator,std::vector< std::string >::size_type,std::vector< std::string >::value_type const &)\n");
-  return 0;
-}
-
-
-SWIGINTERN PyObject *_wrap_StringVector_reserve(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  std::vector< std::string >::size_type arg2 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  size_t val2 ;
-  int ecode2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector_reserve",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_reserve" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  ecode2 = SWIG_AsVal_size_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector_reserve" "', argument " "2"" of type '" "std::vector< std::string >::size_type""'");
-  } 
-  arg2 = static_cast< std::vector< std::string >::size_type >(val2);
-  (arg1)->reserve(arg2);
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_StringVector_capacity(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< std::string >::size_type result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_capacity",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_capacity" "', argument " "1"" of type '" "std::vector< std::string > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  result = ((std::vector< std::string > const *)arg1)->capacity();
-  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_delete_StringVector(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< std::string > *arg1 = (std::vector< std::string > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:delete_StringVector",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, SWIG_POINTER_DISOWN |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_StringVector" "', argument " "1"" of type '" "std::vector< std::string > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< std::string > * >(argp1);
-  delete arg1;
-  resultobj = SWIG_Py_Void();
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *StringVector_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
-  SWIG_TypeNewClientData(SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, SWIG_NewClientData(obj));
-  return SWIG_Py_Void();
-}
-
-SWIGINTERN PyObject *_wrap_VarsVector_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  PyObject **arg2 = (PyObject **) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
-  
-  arg2 = &obj0;
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_iterator" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  result = (swig::SwigPyIterator *)std_vector_Sl_CdiVariable_Sg__iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_VarsVector___nonzero__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  bool result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector___nonzero__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___nonzero__" "', argument " "1"" of type '" "std::vector< CdiVariable > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  result = (bool)std_vector_Sl_CdiVariable_Sg____nonzero__((std::vector< CdiVariable > const *)arg1);
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_VarsVector___bool__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  bool result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector___bool__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___bool__" "', argument " "1"" of type '" "std::vector< CdiVariable > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  result = (bool)std_vector_Sl_CdiVariable_Sg____bool__((std::vector< CdiVariable > const *)arg1);
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_VarsVector___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< CdiVariable >::size_type result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector___len__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___len__" "', argument " "1"" of type '" "std::vector< CdiVariable > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  result = std_vector_Sl_CdiVariable_Sg____len__((std::vector< CdiVariable > const *)arg1);
-  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_VarsVector_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::vector< CdiVariable >::value_type result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_pop",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_pop" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  try {
-    result = std_vector_Sl_CdiVariable_Sg__pop(arg1);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
-  }
-  
-  resultobj = SWIG_NewPointerObj((new std::vector< CdiVariable >::value_type(static_cast< const std::vector< CdiVariable >::value_type& >(result))), SWIGTYPE_p_CdiVariable, SWIG_POINTER_OWN |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_VarsVector___getslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::difference_type arg2 ;
-  std::vector< CdiVariable >::difference_type arg3 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  ptrdiff_t val2 ;
-  int ecode2 = 0 ;
-  ptrdiff_t val3 ;
-  int ecode3 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
-  std::vector< CdiVariable,std::allocator< CdiVariable > > *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OOO:VarsVector___getslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___getslice__" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector___getslice__" "', argument " "2"" of type '" "std::vector< CdiVariable >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< CdiVariable >::difference_type >(val2);
-  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "VarsVector___getslice__" "', argument " "3"" of type '" "std::vector< CdiVariable >::difference_type""'");
-  } 
-  arg3 = static_cast< std::vector< CdiVariable >::difference_type >(val3);
-  try {
-    result = (std::vector< CdiVariable,std::allocator< CdiVariable > > *)std_vector_Sl_CdiVariable_Sg____getslice__(arg1,arg2,arg3);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
-  }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
-  
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, SWIG_POINTER_OWN |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_VarsVector___setslice____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::difference_type arg2 ;
-  std::vector< CdiVariable >::difference_type arg3 ;
-  std::vector< CdiVariable,std::allocator< CdiVariable > > *arg4 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  ptrdiff_t val2 ;
-  int ecode2 = 0 ;
-  ptrdiff_t val3 ;
-  int ecode3 = 0 ;
-  int res4 = SWIG_OLDOBJ ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
-  PyObject * obj3 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OOOO:VarsVector___setslice__",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___setslice__" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector___setslice__" "', argument " "2"" of type '" "std::vector< CdiVariable >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< CdiVariable >::difference_type >(val2);
-  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "VarsVector___setslice__" "', argument " "3"" of type '" "std::vector< CdiVariable >::difference_type""'");
-  } 
-  arg3 = static_cast< std::vector< CdiVariable >::difference_type >(val3);
-  {
-    std::vector<CdiVariable,std::allocator< CdiVariable > > *ptr = (std::vector<CdiVariable,std::allocator< CdiVariable > > *)0;
-    res4 = swig::asptr(obj3, &ptr);
-    if (!SWIG_IsOK(res4)) {
-      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "VarsVector___setslice__" "', argument " "4"" of type '" "std::vector< CdiVariable,std::allocator< CdiVariable > > const &""'"); 
-    }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector___setslice__" "', argument " "4"" of type '" "std::vector< CdiVariable,std::allocator< CdiVariable > > const &""'"); 
-    }
-    arg4 = ptr;
-  }
-  try {
-    std_vector_Sl_CdiVariable_Sg____setslice____SWIG_0(arg1,arg2,arg3,(std::vector< CdiVariable,std::allocator< CdiVariable > > const &)*arg4);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
-  }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
-  
-  resultobj = SWIG_Py_Void();
-  if (SWIG_IsNewObj(res4)) delete arg4;
-  return resultobj;
-fail:
-  if (SWIG_IsNewObj(res4)) delete arg4;
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_VarsVector___setslice____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::difference_type arg2 ;
-  std::vector< CdiVariable >::difference_type arg3 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  ptrdiff_t val2 ;
-  int ecode2 = 0 ;
-  ptrdiff_t val3 ;
-  int ecode3 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OOO:VarsVector___setslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___setslice__" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_insert" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector___setslice__" "', argument " "2"" of type '" "std::vector< CdiVariable >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< CdiVariable >::difference_type >(val2);
-  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res2) || !iter2) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_insert" "', argument " "2"" of type '" "std::vector<std::string >::iterator""'");
+  } else {
+    swig::PySwigIterator_T<std::vector<std::string >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<std::string >::iterator > *>(iter2);
+    if (iter_t) {
+      arg2 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "StringVector_insert" "', argument " "2"" of type '" "std::vector<std::string >::iterator""'");
+    }
+  }
+  ecode3 = SWIG_AsVal_size_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "VarsVector___setslice__" "', argument " "3"" of type '" "std::vector< CdiVariable >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "StringVector_insert" "', argument " "3"" of type '" "std::vector<std::string >::size_type""'");
   } 
-  arg3 = static_cast< std::vector< CdiVariable >::difference_type >(val3);
-  try {
-    std_vector_Sl_CdiVariable_Sg____setslice____SWIG_0(arg1,arg2,arg3);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
-  }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
+  arg3 = static_cast< std::vector<std::string >::size_type >(val3);
+  {
+    std::string *ptr = (std::string *)0;
+    res4 = SWIG_AsPtr_std_string(obj3, &ptr);
+    if (!SWIG_IsOK(res4)) {
+      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "StringVector_insert" "', argument " "4"" of type '" "std::vector<std::string >::value_type const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "StringVector_insert" "', argument " "4"" of type '" "std::vector<std::string >::value_type const &""'"); 
+    }
+    arg4 = ptr;
   }
-  
+  (arg1)->insert(arg2,arg3,(std::vector<std::string >::value_type const &)*arg4);
   resultobj = SWIG_Py_Void();
+  if (SWIG_IsNewObj(res4)) delete arg4;
   return resultobj;
 fail:
+  if (SWIG_IsNewObj(res4)) delete arg4;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector___setslice__(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_insert(PyObject *self, PyObject *args) {
   int argc;
   PyObject *argv[5];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 4); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<std::string >::iterator > *>(iter) != 0));
       if (_v) {
-        {
-          int res = SWIG_AsVal_ptrdiff_t(argv[2], NULL);
-          _v = SWIG_CheckState(res);
-        }
+        int res = SWIG_AsPtr_std_string(argv[2], (std::string**)(0));
+        _v = SWIG_CheckState(res);
         if (_v) {
-          return _wrap_VarsVector___setslice____SWIG_1(self, args);
+          return _wrap_StringVector_insert__SWIG_0(self, args);
         }
       }
     }
   }
   if (argc == 4) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<std::string,std::allocator<std::string > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<std::string >::iterator > *>(iter) != 0));
       if (_v) {
         {
-          int res = SWIG_AsVal_ptrdiff_t(argv[2], NULL);
+          int res = SWIG_AsVal_size_t(argv[2], NULL);
           _v = SWIG_CheckState(res);
         }
         if (_v) {
-          int res = swig::asptr(argv[3], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
+          int res = SWIG_AsPtr_std_string(argv[3], (std::string**)(0));
           _v = SWIG_CheckState(res);
           if (_v) {
-            return _wrap_VarsVector___setslice____SWIG_0(self, args);
+            return _wrap_StringVector_insert__SWIG_1(self, args);
           }
         }
       }
@@ -15179,55 +12678,34 @@ SWIGINTERN PyObject *_wrap_VarsVector___setslice__(PyObject *self, PyObject *arg
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'VarsVector___setslice__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< CdiVariable >::__setslice__(std::vector< CdiVariable >::difference_type,std::vector< CdiVariable >::difference_type,std::vector< CdiVariable,std::allocator< CdiVariable > > const &)\n"
-    "    std::vector< CdiVariable >::__setslice__(std::vector< CdiVariable >::difference_type,std::vector< CdiVariable >::difference_type)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'StringVector_insert'.\n  Possible C/C++ prototypes are:\n    insert(std::vector<std::string >::iterator,std::vector<std::string >::value_type const &)\n    insert(std::vector<std::string >::iterator,std::vector<std::string >::size_type,std::vector<std::string >::value_type const &)\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector___delslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_reserve(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::difference_type arg2 ;
-  std::vector< CdiVariable >::difference_type arg3 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::size_type arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  ptrdiff_t val2 ;
+  size_t val2 ;
   int ecode2 = 0 ;
-  ptrdiff_t val3 ;
-  int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:VarsVector___delslice__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:StringVector_reserve",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___delslice__" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_reserve" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector___delslice__" "', argument " "2"" of type '" "std::vector< CdiVariable >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< CdiVariable >::difference_type >(val2);
-  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
-  if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "VarsVector___delslice__" "', argument " "3"" of type '" "std::vector< CdiVariable >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "StringVector_reserve" "', argument " "2"" of type '" "std::vector<std::string >::size_type""'");
   } 
-  arg3 = static_cast< std::vector< CdiVariable >::difference_type >(val3);
-  try {
-    std_vector_Sl_CdiVariable_Sg____delslice__(arg1,arg2,arg3);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
-  }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
-  
+  arg2 = static_cast< std::vector<std::string >::size_type >(val2);
+  (arg1)->reserve(arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -15235,34 +12713,42 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector___delitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_StringVector_capacity(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::difference_type arg2 ;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  std::vector<std::string >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  ptrdiff_t val2 ;
-  int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:VarsVector___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:StringVector_capacity",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___delitem__" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector___delitem__" "', argument " "2"" of type '" "std::vector< CdiVariable >::difference_type""'");
-  } 
-  arg2 = static_cast< std::vector< CdiVariable >::difference_type >(val2);
-  try {
-    std_vector_Sl_CdiVariable_Sg____delitem____SWIG_0(arg1,arg2);
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "StringVector_capacity" "', argument " "1"" of type '" "std::vector<std::string > const *""'"); 
   }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  result = ((std::vector<std::string > const *)arg1)->capacity();
+  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_delete_StringVector(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<std::string > *arg1 = (std::vector<std::string > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:delete_StringVector",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, SWIG_POINTER_DISOWN |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_StringVector" "', argument " "1"" of type '" "std::vector<std::string > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<std::string > * >(argp1);
+  delete arg1;
   
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -15271,160 +12757,202 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector___getitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *StringVector_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *obj;
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, SWIG_NewClientData(obj));
+  return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_VarsVector_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  std::vector< CdiVariable,std::allocator< CdiVariable > > *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:VarsVector___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  arg2 = &obj0;
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_iterator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___getitem__" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector___getitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
-  }
-  try {
-    result = (std::vector< CdiVariable,std::allocator< CdiVariable > > *)std_vector_Sl_CdiVariable_Sg____getitem____SWIG_0(arg1,arg2);
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_iterator" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
-  }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
-  
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  result = (swig::PySwigIterator *)std_vector_Sl_CdiVariable_Sg__iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsVector___nonzero__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
-  std::vector< CdiVariable,std::allocator< CdiVariable > > *arg3 = 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  int res3 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:VarsVector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector___nonzero__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___setitem__" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___nonzero__" "', argument " "1"" of type '" "std::vector<CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector___setitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  result = (bool)std_vector_Sl_CdiVariable_Sg____nonzero__((std::vector<CdiVariable > const *)arg1);
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsVector___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::size_type result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector___len__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___len__" "', argument " "1"" of type '" "std::vector<CdiVariable > const *""'"); 
   }
-  {
-    std::vector<CdiVariable,std::allocator< CdiVariable > > *ptr = (std::vector<CdiVariable,std::allocator< CdiVariable > > *)0;
-    res3 = swig::asptr(obj2, &ptr);
-    if (!SWIG_IsOK(res3)) {
-      SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "VarsVector___setitem__" "', argument " "3"" of type '" "std::vector< CdiVariable,std::allocator< CdiVariable > > const &""'"); 
-    }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector___setitem__" "', argument " "3"" of type '" "std::vector< CdiVariable,std::allocator< CdiVariable > > const &""'"); 
-    }
-    arg3 = ptr;
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  result = std_vector_Sl_CdiVariable_Sg____len__((std::vector<CdiVariable > const *)arg1);
+  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsVector_pop(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::value_type result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_pop",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_pop" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
   try {
-    std_vector_Sl_CdiVariable_Sg____setitem____SWIG_0(arg1,arg2,(std::vector< CdiVariable,std::allocator< CdiVariable > > const &)*arg3);
+    result = std_vector_Sl_CdiVariable_Sg__pop(arg1);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
-  resultobj = SWIG_Py_Void();
-  if (SWIG_IsNewObj(res3)) delete arg3;
+  resultobj = SWIG_NewPointerObj((new std::vector<CdiVariable >::value_type(static_cast< const std::vector<CdiVariable >::value_type& >(result))), SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
-  if (SWIG_IsNewObj(res3)) delete arg3;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsVector___getslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::difference_type arg2 ;
+  std::vector<CdiVariable >::difference_type arg3 ;
+  std::vector<CdiVariable,std::allocator<CdiVariable > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  ptrdiff_t val3 ;
+  int ecode3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:VarsVector___setitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OOO:VarsVector___getslice__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___setitem__" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector___setitem__" "', argument " "2"" of type '" "PySliceObject *""'");
-    }
-    arg2 = (PySliceObject *) obj1;
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___getslice__" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector___getslice__" "', argument " "2"" of type '" "std::vector<CdiVariable >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector<CdiVariable >::difference_type >(val2);
+  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "VarsVector___getslice__" "', argument " "3"" of type '" "std::vector<CdiVariable >::difference_type""'");
+  } 
+  arg3 = static_cast< std::vector<CdiVariable >::difference_type >(val3);
   try {
-    std_vector_Sl_CdiVariable_Sg____setitem____SWIG_1(arg1,arg2);
+    result = (std::vector<CdiVariable,std::allocator<CdiVariable > > *)std_vector_Sl_CdiVariable_Sg____getslice__(arg1,arg2,arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
-  catch(std::invalid_argument &_e) {
-    SWIG_exception_fail(SWIG_ValueError, (&_e)->what());
-  }
   
-  resultobj = SWIG_Py_Void();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector___delitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsVector___setslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  PySliceObject *arg2 = (PySliceObject *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::difference_type arg2 ;
+  std::vector<CdiVariable >::difference_type arg3 ;
+  std::vector<CdiVariable,std::allocator<CdiVariable > > *arg4 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  ptrdiff_t val3 ;
+  int ecode3 = 0 ;
+  int res4 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
+  PyObject * obj3 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:VarsVector___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OOOO:VarsVector___setslice__",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___delitem__" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___setslice__" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector___setslice__" "', argument " "2"" of type '" "std::vector<CdiVariable >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector<CdiVariable >::difference_type >(val2);
+  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "VarsVector___setslice__" "', argument " "3"" of type '" "std::vector<CdiVariable >::difference_type""'");
+  } 
+  arg3 = static_cast< std::vector<CdiVariable >::difference_type >(val3);
   {
-    if (!PySlice_Check(obj1)) {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector___delitem__" "', argument " "2"" of type '" "PySliceObject *""'");
+    std::vector<CdiVariable,std::allocator<CdiVariable > > *ptr = (std::vector<CdiVariable,std::allocator<CdiVariable > > *)0;
+    res4 = swig::asptr(obj3, &ptr);
+    if (!SWIG_IsOK(res4)) {
+      SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "VarsVector___setslice__" "', argument " "4"" of type '" "std::vector<CdiVariable,std::allocator<CdiVariable > > const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector___setslice__" "', argument " "4"" of type '" "std::vector<CdiVariable,std::allocator<CdiVariable > > const &""'"); 
     }
-    arg2 = (PySliceObject *) obj1;
+    arg4 = ptr;
   }
   try {
-    std_vector_Sl_CdiVariable_Sg____delitem____SWIG_1(arg1,arg2);
+    std_vector_Sl_CdiVariable_Sg____setslice__(arg1,arg2,arg3,(std::vector<CdiVariable,std::allocator<CdiVariable > > const &)*arg4);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
@@ -15434,148 +12962,140 @@ SWIGINTERN PyObject *_wrap_VarsVector___delitem____SWIG_1(PyObject *SWIGUNUSEDPA
   }
   
   resultobj = SWIG_Py_Void();
+  if (SWIG_IsNewObj(res4)) delete arg4;
   return resultobj;
 fail:
+  if (SWIG_IsNewObj(res4)) delete arg4;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector___delitem__(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[3];
-  int ii;
+SWIGINTERN PyObject *_wrap_VarsVector___delslice__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::difference_type arg2 ;
+  std::vector<CdiVariable >::difference_type arg3 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  ptrdiff_t val3 ;
+  int ecode3 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
   
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  if (!PyArg_ParseTuple(args,(char *)"OOO:VarsVector___delslice__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___delslice__" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_VarsVector___delitem____SWIG_1(self, args);
-      }
-    }
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector___delslice__" "', argument " "2"" of type '" "std::vector<CdiVariable >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector<CdiVariable >::difference_type >(val2);
+  ecode3 = SWIG_AsVal_ptrdiff_t(obj2, &val3);
+  if (!SWIG_IsOK(ecode3)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "VarsVector___delslice__" "', argument " "3"" of type '" "std::vector<CdiVariable >::difference_type""'");
+  } 
+  arg3 = static_cast< std::vector<CdiVariable >::difference_type >(val3);
+  try {
+    std_vector_Sl_CdiVariable_Sg____delslice__(arg1,arg2,arg3);
   }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_VarsVector___delitem____SWIG_0(self, args);
-      }
-    }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
+  resultobj = SWIG_Py_Void();
+  return resultobj;
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'VarsVector___delitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< CdiVariable >::__delitem__(std::vector< CdiVariable >::difference_type)\n"
-    "    std::vector< CdiVariable >::__delitem__(PySliceObject *)\n");
-  return 0;
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector___getitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsVector___delitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::difference_type arg2 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::difference_type arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::vector< CdiVariable >::value_type *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:VarsVector___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:VarsVector___delitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___getitem__" "', argument " "1"" of type '" "std::vector< CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___delitem__" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector___getitem__" "', argument " "2"" of type '" "std::vector< CdiVariable >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector___delitem__" "', argument " "2"" of type '" "std::vector<CdiVariable >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< CdiVariable >::difference_type >(val2);
+  arg2 = static_cast< std::vector<CdiVariable >::difference_type >(val2);
   try {
-    result = (std::vector< CdiVariable >::value_type *) &std_vector_Sl_CdiVariable_Sg____getitem____SWIG_1((std::vector< CdiVariable > const *)arg1,arg2);
+    std_vector_Sl_CdiVariable_Sg____delitem__(arg1,arg2);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CdiVariable, 0 |  0 );
+  resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector___getitem__(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[3];
-  int ii;
+SWIGINTERN PyObject *_wrap_VarsVector___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::difference_type arg2 ;
+  std::vector<CdiVariable >::value_type *result = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  ptrdiff_t val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
   
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  if (!PyArg_ParseTuple(args,(char *)"OO:VarsVector___getitem__",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___getitem__" "', argument " "1"" of type '" "std::vector<CdiVariable > const *""'"); 
   }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_VarsVector___getitem____SWIG_0(self, args);
-      }
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector___getitem__" "', argument " "2"" of type '" "std::vector<CdiVariable >::difference_type""'");
+  } 
+  arg2 = static_cast< std::vector<CdiVariable >::difference_type >(val2);
+  try {
+    {
+      std::vector<CdiVariable >::value_type const &_result_ref = std_vector_Sl_CdiVariable_Sg____getitem__((std::vector<CdiVariable > const *)arg1,arg2);
+      result = (std::vector<CdiVariable >::value_type *) &_result_ref;
     }
   }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_VarsVector___getitem____SWIG_1(self, args);
-      }
-    }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type, 0 |  0 );
+  return resultobj;
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'VarsVector___getitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< CdiVariable >::__getitem__(PySliceObject *)\n"
-    "    std::vector< CdiVariable >::__getitem__(std::vector< CdiVariable >::difference_type) const\n");
-  return 0;
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector___setitem____SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsVector___setitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::difference_type arg2 ;
-  std::vector< CdiVariable >::value_type *arg3 = 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::difference_type arg2 ;
+  std::vector<CdiVariable >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   ptrdiff_t val2 ;
@@ -15587,26 +13107,26 @@ SWIGINTERN PyObject *_wrap_VarsVector___setitem____SWIG_2(PyObject *SWIGUNUSEDPA
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:VarsVector___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___setitem__" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector___setitem__" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_ptrdiff_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector___setitem__" "', argument " "2"" of type '" "std::vector< CdiVariable >::difference_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector___setitem__" "', argument " "2"" of type '" "std::vector<CdiVariable >::difference_type""'");
   } 
-  arg2 = static_cast< std::vector< CdiVariable >::difference_type >(val2);
-  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_CdiVariable,  0  | 0);
+  arg2 = static_cast< std::vector<CdiVariable >::difference_type >(val2);
+  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type,  0  | 0);
   if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "VarsVector___setitem__" "', argument " "3"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "VarsVector___setitem__" "', argument " "3"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
   if (!argp3) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector___setitem__" "', argument " "3"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector___setitem__" "', argument " "3"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
-  arg3 = reinterpret_cast< std::vector< CdiVariable >::value_type * >(argp3);
+  arg3 = reinterpret_cast< std::vector<CdiVariable >::value_type * >(argp3);
   try {
-    std_vector_Sl_CdiVariable_Sg____setitem____SWIG_2(arg1,arg2,(CdiVariable const &)*arg3);
+    std_vector_Sl_CdiVariable_Sg____setitem__(arg1,arg2,(CdiVariable const &)*arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
@@ -15619,79 +13139,10 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector___setitem__(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[4];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        return _wrap_VarsVector___setitem____SWIG_1(self, args);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        _v = PySlice_Check(argv[1]);
-      }
-      if (_v) {
-        int res = swig::asptr(argv[2], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_VarsVector___setitem____SWIG_0(self, args);
-        }
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_ptrdiff_t(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_CdiVariable, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_VarsVector___setitem____SWIG_2(self, args);
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'VarsVector___setitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< CdiVariable >::__setitem__(PySliceObject *,std::vector< CdiVariable,std::allocator< CdiVariable > > const &)\n"
-    "    std::vector< CdiVariable >::__setitem__(PySliceObject *)\n"
-    "    std::vector< CdiVariable >::__setitem__(std::vector< CdiVariable >::difference_type,std::vector< CdiVariable >::value_type const &)\n");
-  return 0;
-}
-
-
 SWIGINTERN PyObject *_wrap_VarsVector_append(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::value_type *arg2 = 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::value_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -15700,19 +13151,19 @@ SWIGINTERN PyObject *_wrap_VarsVector_append(PyObject *SWIGUNUSEDPARM(self), PyO
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsVector_append",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_append" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_append" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_CdiVariable,  0  | 0);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type,  0  | 0);
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsVector_append" "', argument " "2"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsVector_append" "', argument " "2"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
   if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector_append" "', argument " "2"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector_append" "', argument " "2"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< CdiVariable >::value_type * >(argp2);
+  arg2 = reinterpret_cast< std::vector<CdiVariable >::value_type * >(argp2);
   std_vector_Sl_CdiVariable_Sg__append(arg1,(CdiVariable const &)*arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -15723,11 +13174,11 @@ fail:
 
 SWIGINTERN PyObject *_wrap_new_VarsVector__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *result = 0 ;
+  std::vector<CdiVariable > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)":new_VarsVector")) SWIG_fail;
-  result = (std::vector< CdiVariable > *)new std::vector< CdiVariable >();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, SWIG_POINTER_NEW |  0 );
+  result = (std::vector<CdiVariable > *)new std::vector<CdiVariable >();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -15736,25 +13187,25 @@ fail:
 
 SWIGINTERN PyObject *_wrap_new_VarsVector__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = 0 ;
+  std::vector<CdiVariable > *arg1 = 0 ;
+  std::vector<CdiVariable > *result = 0 ;
   int res1 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
-  std::vector< CdiVariable > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:new_VarsVector",&obj0)) SWIG_fail;
   {
-    std::vector<CdiVariable,std::allocator< CdiVariable > > *ptr = (std::vector<CdiVariable,std::allocator< CdiVariable > > *)0;
+    std::vector<CdiVariable,std::allocator<CdiVariable > > *ptr = (std::vector<CdiVariable,std::allocator<CdiVariable > > *)0;
     res1 = swig::asptr(obj0, &ptr);
     if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_VarsVector" "', argument " "1"" of type '" "std::vector< CdiVariable > const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_VarsVector" "', argument " "1"" of type '" "std::vector<CdiVariable > const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_VarsVector" "', argument " "1"" of type '" "std::vector< CdiVariable > const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_VarsVector" "', argument " "1"" of type '" "std::vector<CdiVariable > const &""'"); 
     }
     arg1 = ptr;
   }
-  result = (std::vector< CdiVariable > *)new std::vector< CdiVariable >((std::vector< CdiVariable > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, SWIG_POINTER_NEW |  0 );
+  result = (std::vector<CdiVariable > *)new std::vector<CdiVariable >((std::vector<CdiVariable > const &)*arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, SWIG_POINTER_NEW |  0 );
   if (SWIG_IsNewObj(res1)) delete arg1;
   return resultobj;
 fail:
@@ -15765,19 +13216,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_empty",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_empty" "', argument " "1"" of type '" "std::vector< CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_empty" "', argument " "1"" of type '" "std::vector<CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  result = (bool)((std::vector< CdiVariable > const *)arg1)->empty();
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  result = (bool)((std::vector<CdiVariable > const *)arg1)->empty();
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -15787,19 +13238,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< CdiVariable >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_size",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_size" "', argument " "1"" of type '" "std::vector< CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_size" "', argument " "1"" of type '" "std::vector<CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  result = ((std::vector< CdiVariable > const *)arg1)->size();
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  result = ((std::vector<CdiVariable > const *)arg1)->size();
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -15809,17 +13260,17 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_clear",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_clear" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_clear" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
   (arg1)->clear();
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -15830,8 +13281,8 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable > *arg2 = 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable > *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -15840,19 +13291,19 @@ SWIGINTERN PyObject *_wrap_VarsVector_swap(PyObject *SWIGUNUSEDPARM(self), PyObj
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsVector_swap",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_swap" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_swap" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t,  0 );
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t,  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsVector_swap" "', argument " "2"" of type '" "std::vector< CdiVariable > &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsVector_swap" "', argument " "2"" of type '" "std::vector<CdiVariable > &""'"); 
   }
   if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector_swap" "', argument " "2"" of type '" "std::vector< CdiVariable > &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector_swap" "', argument " "2"" of type '" "std::vector<CdiVariable > &""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< CdiVariable > * >(argp2);
+  arg2 = reinterpret_cast< std::vector<CdiVariable > * >(argp2);
   (arg1)->swap(*arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -15863,134 +13314,358 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  SwigValueWrapper<std::allocator<CdiVariable > > result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  SwigValueWrapper< std::allocator< CdiVariable > > result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_get_allocator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_get_allocator" "', argument " "1"" of type '" "std::vector< CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_get_allocator" "', argument " "1"" of type '" "std::vector<CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  result = ((std::vector< CdiVariable > const *)arg1)->get_allocator();
-  resultobj = SWIG_NewPointerObj((new std::vector< CdiVariable >::allocator_type(static_cast< const std::vector< CdiVariable >::allocator_type& >(result))), SWIGTYPE_p_std__allocatorT_CdiVariable_t, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  result = ((std::vector<CdiVariable > const *)arg1)->get_allocator();
+  resultobj = SWIG_NewPointerObj((new std::vector<CdiVariable >::allocator_type(static_cast< const std::vector<CdiVariable >::allocator_type& >(result))), SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__allocator_type, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector_begin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsVector_begin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< CdiVariable >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_begin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_begin" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_begin" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
   result = (arg1)->begin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsVector_begin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_begin" "', argument " "1"" of type '" "std::vector<CdiVariable > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  result = ((std::vector<CdiVariable > const *)arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<CdiVariable >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector_end(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsVector_begin(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsVector_begin__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsVector_begin__SWIG_1(self, args);
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsVector_begin'.\n  Possible C/C++ prototypes are:\n    begin()\n    begin()\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsVector_end__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< CdiVariable >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_end",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_end" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_end" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
   result = (arg1)->end();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsVector_end__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_end" "', argument " "1"" of type '" "std::vector<CdiVariable > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  result = ((std::vector<CdiVariable > const *)arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<CdiVariable >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector_rbegin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsVector_end(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsVector_end__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsVector_end__SWIG_1(self, args);
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsVector_end'.\n  Possible C/C++ prototypes are:\n    end()\n    end()\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsVector_rbegin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< CdiVariable >::reverse_iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_rbegin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_rbegin" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_rbegin" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
   result = (arg1)->rbegin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< CdiVariable >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<CdiVariable >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsVector_rbegin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::const_reverse_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_rbegin" "', argument " "1"" of type '" "std::vector<CdiVariable > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  result = ((std::vector<CdiVariable > const *)arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<CdiVariable >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsVector_rbegin(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsVector_rbegin__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsVector_rbegin__SWIG_1(self, args);
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsVector_rbegin'.\n  Possible C/C++ prototypes are:\n    rbegin()\n    rbegin()\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsVector_rend__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::reverse_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_rend" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  result = (arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<CdiVariable >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsVector_rend(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsVector_rend__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::const_reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< CdiVariable >::reverse_iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_rend",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_rend" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_rend" "', argument " "1"" of type '" "std::vector<CdiVariable > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  result = ((std::vector<CdiVariable > const *)arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<CdiVariable >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsVector_rend(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  result = (arg1)->rend();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< CdiVariable >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsVector_rend__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsVector_rend__SWIG_1(self, args);
+    }
+  }
+  
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsVector_rend'.\n  Possible C/C++ prototypes are:\n    rend()\n    rend()\n");
   return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_new_VarsVector__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable >::size_type arg1 ;
+  std::vector<CdiVariable >::size_type arg1 ;
+  std::vector<CdiVariable > *result = 0 ;
   size_t val1 ;
   int ecode1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< CdiVariable > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:new_VarsVector",&obj0)) SWIG_fail;
   ecode1 = SWIG_AsVal_size_t(obj0, &val1);
   if (!SWIG_IsOK(ecode1)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_VarsVector" "', argument " "1"" of type '" "std::vector< CdiVariable >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_VarsVector" "', argument " "1"" of type '" "std::vector<CdiVariable >::size_type""'");
   } 
-  arg1 = static_cast< std::vector< CdiVariable >::size_type >(val1);
-  result = (std::vector< CdiVariable > *)new std::vector< CdiVariable >(arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, SWIG_POINTER_NEW |  0 );
+  arg1 = static_cast< std::vector<CdiVariable >::size_type >(val1);
+  result = (std::vector<CdiVariable > *)new std::vector<CdiVariable >(arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -15999,17 +13674,17 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_pop_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_pop_back",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_pop_back" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_pop_back" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
   (arg1)->pop_back();
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -16020,8 +13695,8 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_resize__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::size_type arg2 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::size_type arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
@@ -16030,16 +13705,16 @@ SWIGINTERN PyObject *_wrap_VarsVector_resize__SWIG_0(PyObject *SWIGUNUSEDPARM(se
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsVector_resize",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_resize" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_resize" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector_resize" "', argument " "2"" of type '" "std::vector< CdiVariable >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector_resize" "', argument " "2"" of type '" "std::vector<CdiVariable >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< CdiVariable >::size_type >(val2);
+  arg2 = static_cast< std::vector<CdiVariable >::size_type >(val2);
   (arg1)->resize(arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -16050,36 +13725,36 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::iterator arg2 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::iterator arg2 ;
+  std::vector<CdiVariable >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::vector< CdiVariable >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsVector_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_erase" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_erase" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_erase" "', argument " "2"" of type '" "std::vector< CdiVariable >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_erase" "', argument " "2"" of type '" "std::vector<CdiVariable >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_erase" "', argument " "2"" of type '" "std::vector< CdiVariable >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_erase" "', argument " "2"" of type '" "std::vector<CdiVariable >::iterator""'");
     }
   }
-  result = std_vector_Sl_CdiVariable_Sg__erase__SWIG_0(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->erase(arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
@@ -16088,51 +13763,51 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_erase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::iterator arg2 ;
-  std::vector< CdiVariable >::iterator arg3 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::iterator arg2 ;
+  std::vector<CdiVariable >::iterator arg3 ;
+  std::vector<CdiVariable >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
-  swig::SwigPyIterator *iter3 = 0 ;
+  swig::PySwigIterator *iter3 = 0 ;
   int res3 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
-  std::vector< CdiVariable >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:VarsVector_erase",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_erase" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_erase" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_erase" "', argument " "2"" of type '" "std::vector< CdiVariable >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_erase" "', argument " "2"" of type '" "std::vector<CdiVariable >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_erase" "', argument " "2"" of type '" "std::vector< CdiVariable >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_erase" "', argument " "2"" of type '" "std::vector<CdiVariable >::iterator""'");
     }
   }
-  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::SwigPyIterator::descriptor(), 0);
+  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res3) || !iter3) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_erase" "', argument " "3"" of type '" "std::vector< CdiVariable >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_erase" "', argument " "3"" of type '" "std::vector<CdiVariable >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *>(iter3);
+    swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *>(iter3);
     if (iter_t) {
       arg3 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_erase" "', argument " "3"" of type '" "std::vector< CdiVariable >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_erase" "', argument " "3"" of type '" "std::vector<CdiVariable >::iterator""'");
     }
   }
-  result = std_vector_Sl_CdiVariable_Sg__erase__SWIG_1(arg1,arg2,arg3);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->erase(arg2,arg3);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
@@ -16145,18 +13820,18 @@ SWIGINTERN PyObject *_wrap_VarsVector_erase(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *>(iter) != 0));
       if (_v) {
         return _wrap_VarsVector_erase__SWIG_0(self, args);
       }
@@ -16164,16 +13839,16 @@ SWIGINTERN PyObject *_wrap_VarsVector_erase(PyObject *self, PyObject *args) {
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *>(iter) != 0));
       if (_v) {
-        swig::SwigPyIterator *iter = 0;
-        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *>(iter) != 0));
+        swig::PySwigIterator *iter = 0;
+        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *>(iter) != 0));
         if (_v) {
           return _wrap_VarsVector_erase__SWIG_1(self, args);
         }
@@ -16182,42 +13857,39 @@ SWIGINTERN PyObject *_wrap_VarsVector_erase(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'VarsVector_erase'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< CdiVariable >::erase(std::vector< CdiVariable >::iterator)\n"
-    "    std::vector< CdiVariable >::erase(std::vector< CdiVariable >::iterator,std::vector< CdiVariable >::iterator)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsVector_erase'.\n  Possible C/C++ prototypes are:\n    erase(std::vector<CdiVariable >::iterator)\n    erase(std::vector<CdiVariable >::iterator,std::vector<CdiVariable >::iterator)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_new_VarsVector__SWIG_3(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable >::size_type arg1 ;
-  std::vector< CdiVariable >::value_type *arg2 = 0 ;
+  std::vector<CdiVariable >::size_type arg1 ;
+  std::vector<CdiVariable >::value_type *arg2 = 0 ;
+  std::vector<CdiVariable > *result = 0 ;
   size_t val1 ;
   int ecode1 = 0 ;
   void *argp2 = 0 ;
   int res2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::vector< CdiVariable > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:new_VarsVector",&obj0,&obj1)) SWIG_fail;
   ecode1 = SWIG_AsVal_size_t(obj0, &val1);
   if (!SWIG_IsOK(ecode1)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_VarsVector" "', argument " "1"" of type '" "std::vector< CdiVariable >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode1), "in method '" "new_VarsVector" "', argument " "1"" of type '" "std::vector<CdiVariable >::size_type""'");
   } 
-  arg1 = static_cast< std::vector< CdiVariable >::size_type >(val1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_CdiVariable,  0  | 0);
+  arg1 = static_cast< std::vector<CdiVariable >::size_type >(val1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type,  0  | 0);
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_VarsVector" "', argument " "2"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "new_VarsVector" "', argument " "2"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
   if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_VarsVector" "', argument " "2"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_VarsVector" "', argument " "2"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< CdiVariable >::value_type * >(argp2);
-  result = (std::vector< CdiVariable > *)new std::vector< CdiVariable >(arg1,(std::vector< CdiVariable >::value_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, SWIG_POINTER_NEW |  0 );
+  arg2 = reinterpret_cast< std::vector<CdiVariable >::value_type * >(argp2);
+  result = (std::vector<CdiVariable > *)new std::vector<CdiVariable >(arg1,(std::vector<CdiVariable >::value_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -16230,8 +13902,8 @@ SWIGINTERN PyObject *_wrap_new_VarsVector(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 0) {
@@ -16249,7 +13921,7 @@ SWIGINTERN PyObject *_wrap_new_VarsVector(PyObject *self, PyObject *args) {
   }
   if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       return _wrap_new_VarsVector__SWIG_1(self, args);
@@ -16262,7 +13934,7 @@ SWIGINTERN PyObject *_wrap_new_VarsVector(PyObject *self, PyObject *args) {
       _v = SWIG_CheckState(res);
     }
     if (_v) {
-      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_CdiVariable, 0);
+      int res = SWIG_ConvertPtr(argv[1], 0, SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type, 0);
       _v = SWIG_CheckState(res);
       if (_v) {
         return _wrap_new_VarsVector__SWIG_3(self, args);
@@ -16271,20 +13943,15 @@ SWIGINTERN PyObject *_wrap_new_VarsVector(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_VarsVector'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< CdiVariable >::vector()\n"
-    "    std::vector< CdiVariable >::vector(std::vector< CdiVariable > const &)\n"
-    "    std::vector< CdiVariable >::vector(std::vector< CdiVariable >::size_type)\n"
-    "    std::vector< CdiVariable >::vector(std::vector< CdiVariable >::size_type,std::vector< CdiVariable >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_VarsVector'.\n  Possible C/C++ prototypes are:\n    std::vector<(CdiVariable)>()\n    std::vector<(CdiVariable)>(std::vector<CdiVariable > const &)\n    std::vector<(CdiVariable)>(std::vector<CdiVariable >::size_type)\n    std::vector<(CdiVariable)>(std::vector<CdiVariable >::size_type,std::vector<CdiVariable >::value_type const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_VarsVector_push_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::value_type *arg2 = 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::value_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -16293,20 +13960,20 @@ SWIGINTERN PyObject *_wrap_VarsVector_push_back(PyObject *SWIGUNUSEDPARM(self),
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsVector_push_back",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_push_back" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_push_back" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_CdiVariable,  0  | 0);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type,  0  | 0);
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsVector_push_back" "', argument " "2"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsVector_push_back" "', argument " "2"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
   if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector_push_back" "', argument " "2"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector_push_back" "', argument " "2"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< CdiVariable >::value_type * >(argp2);
-  (arg1)->push_back((std::vector< CdiVariable >::value_type const &)*arg2);
+  arg2 = reinterpret_cast< std::vector<CdiVariable >::value_type * >(argp2);
+  (arg1)->push_back((std::vector<CdiVariable >::value_type const &)*arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -16316,20 +13983,23 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_front(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::value_type *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< CdiVariable >::value_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_front",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_front" "', argument " "1"" of type '" "std::vector< CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_front" "', argument " "1"" of type '" "std::vector<CdiVariable > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  {
+    std::vector<CdiVariable >::value_type const &_result_ref = ((std::vector<CdiVariable > const *)arg1)->front();
+    result = (std::vector<CdiVariable >::value_type *) &_result_ref;
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  result = (std::vector< CdiVariable >::value_type *) &((std::vector< CdiVariable > const *)arg1)->front();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CdiVariable, 0 |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -16338,20 +14008,23 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_back(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::value_type *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< CdiVariable >::value_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_back",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_back" "', argument " "1"" of type '" "std::vector< CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_back" "', argument " "1"" of type '" "std::vector<CdiVariable > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  {
+    std::vector<CdiVariable >::value_type const &_result_ref = ((std::vector<CdiVariable > const *)arg1)->back();
+    result = (std::vector<CdiVariable >::value_type *) &_result_ref;
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  result = (std::vector< CdiVariable >::value_type *) &((std::vector< CdiVariable > const *)arg1)->back();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CdiVariable, 0 |  0 );
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -16360,9 +14033,9 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_assign(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::size_type arg2 ;
-  std::vector< CdiVariable >::value_type *arg3 = 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::size_type arg2 ;
+  std::vector<CdiVariable >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
@@ -16374,25 +14047,25 @@ SWIGINTERN PyObject *_wrap_VarsVector_assign(PyObject *SWIGUNUSEDPARM(self), PyO
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:VarsVector_assign",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_assign" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_assign" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector_assign" "', argument " "2"" of type '" "std::vector< CdiVariable >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector_assign" "', argument " "2"" of type '" "std::vector<CdiVariable >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< CdiVariable >::size_type >(val2);
-  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_CdiVariable,  0  | 0);
+  arg2 = static_cast< std::vector<CdiVariable >::size_type >(val2);
+  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type,  0  | 0);
   if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "VarsVector_assign" "', argument " "3"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "VarsVector_assign" "', argument " "3"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
   if (!argp3) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector_assign" "', argument " "3"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector_assign" "', argument " "3"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
-  arg3 = reinterpret_cast< std::vector< CdiVariable >::value_type * >(argp3);
-  (arg1)->assign(arg2,(std::vector< CdiVariable >::value_type const &)*arg3);
+  arg3 = reinterpret_cast< std::vector<CdiVariable >::value_type * >(argp3);
+  (arg1)->assign(arg2,(std::vector<CdiVariable >::value_type const &)*arg3);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -16402,9 +14075,9 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_resize__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::size_type arg2 ;
-  std::vector< CdiVariable >::value_type *arg3 = 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::size_type arg2 ;
+  std::vector<CdiVariable >::value_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
@@ -16416,25 +14089,25 @@ SWIGINTERN PyObject *_wrap_VarsVector_resize__SWIG_1(PyObject *SWIGUNUSEDPARM(se
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:VarsVector_resize",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_resize" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_resize" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector_resize" "', argument " "2"" of type '" "std::vector< CdiVariable >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector_resize" "', argument " "2"" of type '" "std::vector<CdiVariable >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< CdiVariable >::size_type >(val2);
-  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_CdiVariable,  0  | 0);
+  arg2 = static_cast< std::vector<CdiVariable >::size_type >(val2);
+  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type,  0  | 0);
   if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "VarsVector_resize" "', argument " "3"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "VarsVector_resize" "', argument " "3"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
   if (!argp3) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector_resize" "', argument " "3"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector_resize" "', argument " "3"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
-  arg3 = reinterpret_cast< std::vector< CdiVariable >::value_type * >(argp3);
-  (arg1)->resize(arg2,(std::vector< CdiVariable >::value_type const &)*arg3);
+  arg3 = reinterpret_cast< std::vector<CdiVariable >::value_type * >(argp3);
+  (arg1)->resize(arg2,(std::vector<CdiVariable >::value_type const &)*arg3);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -16448,13 +14121,13 @@ SWIGINTERN PyObject *_wrap_VarsVector_resize(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -16468,7 +14141,7 @@ SWIGINTERN PyObject *_wrap_VarsVector_resize(PyObject *self, PyObject *args) {
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -16476,7 +14149,7 @@ SWIGINTERN PyObject *_wrap_VarsVector_resize(PyObject *self, PyObject *args) {
         _v = SWIG_CheckState(res);
       }
       if (_v) {
-        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_CdiVariable, 0);
+        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type, 0);
         _v = SWIG_CheckState(res);
         if (_v) {
           return _wrap_VarsVector_resize__SWIG_1(self, args);
@@ -16486,58 +14159,55 @@ SWIGINTERN PyObject *_wrap_VarsVector_resize(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'VarsVector_resize'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< CdiVariable >::resize(std::vector< CdiVariable >::size_type)\n"
-    "    std::vector< CdiVariable >::resize(std::vector< CdiVariable >::size_type,std::vector< CdiVariable >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsVector_resize'.\n  Possible C/C++ prototypes are:\n    resize(std::vector<CdiVariable >::size_type)\n    resize(std::vector<CdiVariable >::size_type,std::vector<CdiVariable >::value_type const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_VarsVector_insert__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::iterator arg2 ;
-  std::vector< CdiVariable >::value_type *arg3 = 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::iterator arg2 ;
+  std::vector<CdiVariable >::value_type *arg3 = 0 ;
+  std::vector<CdiVariable >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   void *argp3 = 0 ;
   int res3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
-  std::vector< CdiVariable >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:VarsVector_insert",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_insert" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_insert" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_insert" "', argument " "2"" of type '" "std::vector< CdiVariable >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_insert" "', argument " "2"" of type '" "std::vector<CdiVariable >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_insert" "', argument " "2"" of type '" "std::vector< CdiVariable >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_insert" "', argument " "2"" of type '" "std::vector<CdiVariable >::iterator""'");
     }
   }
-  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_CdiVariable,  0  | 0);
+  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type,  0  | 0);
   if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "VarsVector_insert" "', argument " "3"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "VarsVector_insert" "', argument " "3"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
   if (!argp3) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector_insert" "', argument " "3"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector_insert" "', argument " "3"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
-  arg3 = reinterpret_cast< std::vector< CdiVariable >::value_type * >(argp3);
-  result = std_vector_Sl_CdiVariable_Sg__insert__SWIG_0(arg1,arg2,(CdiVariable const &)*arg3);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector< CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg3 = reinterpret_cast< std::vector<CdiVariable >::value_type * >(argp3);
+  result = (arg1)->insert(arg2,(std::vector<CdiVariable >::value_type const &)*arg3);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::vector<CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
@@ -16546,13 +14216,13 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_insert__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::iterator arg2 ;
-  std::vector< CdiVariable >::size_type arg3 ;
-  std::vector< CdiVariable >::value_type *arg4 = 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::iterator arg2 ;
+  std::vector<CdiVariable >::size_type arg3 ;
+  std::vector<CdiVariable >::value_type *arg4 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   size_t val3 ;
   int ecode3 = 0 ;
@@ -16564,36 +14234,36 @@ SWIGINTERN PyObject *_wrap_VarsVector_insert__SWIG_1(PyObject *SWIGUNUSEDPARM(se
   PyObject * obj3 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOOO:VarsVector_insert",&obj0,&obj1,&obj2,&obj3)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_insert" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_insert" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_insert" "', argument " "2"" of type '" "std::vector< CdiVariable >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_insert" "', argument " "2"" of type '" "std::vector<CdiVariable >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_insert" "', argument " "2"" of type '" "std::vector< CdiVariable >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsVector_insert" "', argument " "2"" of type '" "std::vector<CdiVariable >::iterator""'");
     }
   }
   ecode3 = SWIG_AsVal_size_t(obj2, &val3);
   if (!SWIG_IsOK(ecode3)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "VarsVector_insert" "', argument " "3"" of type '" "std::vector< CdiVariable >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode3), "in method '" "VarsVector_insert" "', argument " "3"" of type '" "std::vector<CdiVariable >::size_type""'");
   } 
-  arg3 = static_cast< std::vector< CdiVariable >::size_type >(val3);
-  res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_CdiVariable,  0  | 0);
+  arg3 = static_cast< std::vector<CdiVariable >::size_type >(val3);
+  res4 = SWIG_ConvertPtr(obj3, &argp4, SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type,  0  | 0);
   if (!SWIG_IsOK(res4)) {
-    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "VarsVector_insert" "', argument " "4"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res4), "in method '" "VarsVector_insert" "', argument " "4"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
   if (!argp4) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector_insert" "', argument " "4"" of type '" "std::vector< CdiVariable >::value_type const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsVector_insert" "', argument " "4"" of type '" "std::vector<CdiVariable >::value_type const &""'"); 
   }
-  arg4 = reinterpret_cast< std::vector< CdiVariable >::value_type * >(argp4);
-  std_vector_Sl_CdiVariable_Sg__insert__SWIG_1(arg1,arg2,arg3,(CdiVariable const &)*arg4);
+  arg4 = reinterpret_cast< std::vector<CdiVariable >::value_type * >(argp4);
+  (arg1)->insert(arg2,arg3,(std::vector<CdiVariable >::value_type const &)*arg4);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -16607,20 +14277,20 @@ SWIGINTERN PyObject *_wrap_VarsVector_insert(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 4) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 4); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *>(iter) != 0));
       if (_v) {
-        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_CdiVariable, 0);
+        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type, 0);
         _v = SWIG_CheckState(res);
         if (_v) {
           return _wrap_VarsVector_insert__SWIG_0(self, args);
@@ -16630,19 +14300,19 @@ SWIGINTERN PyObject *_wrap_VarsVector_insert(PyObject *self, PyObject *args) {
   }
   if (argc == 4) {
     int _v;
-    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator< CdiVariable > >**)(0));
+    int res = swig::asptr(argv[0], (std::vector<CdiVariable,std::allocator<CdiVariable > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::vector< CdiVariable >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::vector<CdiVariable >::iterator > *>(iter) != 0));
       if (_v) {
         {
           int res = SWIG_AsVal_size_t(argv[2], NULL);
           _v = SWIG_CheckState(res);
         }
         if (_v) {
-          int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_CdiVariable, 0);
+          int res = SWIG_ConvertPtr(argv[3], 0, SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type, 0);
           _v = SWIG_CheckState(res);
           if (_v) {
             return _wrap_VarsVector_insert__SWIG_1(self, args);
@@ -16653,18 +14323,15 @@ SWIGINTERN PyObject *_wrap_VarsVector_insert(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'VarsVector_insert'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::vector< CdiVariable >::insert(std::vector< CdiVariable >::iterator,std::vector< CdiVariable >::value_type const &)\n"
-    "    std::vector< CdiVariable >::insert(std::vector< CdiVariable >::iterator,std::vector< CdiVariable >::size_type,std::vector< CdiVariable >::value_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsVector_insert'.\n  Possible C/C++ prototypes are:\n    insert(std::vector<CdiVariable >::iterator,std::vector<CdiVariable >::value_type const &)\n    insert(std::vector<CdiVariable >::iterator,std::vector<CdiVariable >::size_type,std::vector<CdiVariable >::value_type const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_VarsVector_reserve(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
-  std::vector< CdiVariable >::size_type arg2 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::size_type arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   size_t val2 ;
@@ -16673,16 +14340,16 @@ SWIGINTERN PyObject *_wrap_VarsVector_reserve(PyObject *SWIGUNUSEDPARM(self), Py
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsVector_reserve",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_reserve" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_reserve" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_size_t(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector_reserve" "', argument " "2"" of type '" "std::vector< CdiVariable >::size_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsVector_reserve" "', argument " "2"" of type '" "std::vector<CdiVariable >::size_type""'");
   } 
-  arg2 = static_cast< std::vector< CdiVariable >::size_type >(val2);
+  arg2 = static_cast< std::vector<CdiVariable >::size_type >(val2);
   (arg1)->reserve(arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -16693,19 +14360,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsVector_capacity(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
+  std::vector<CdiVariable >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< CdiVariable >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsVector_capacity",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_capacity" "', argument " "1"" of type '" "std::vector< CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsVector_capacity" "', argument " "1"" of type '" "std::vector<CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
-  result = ((std::vector< CdiVariable > const *)arg1)->capacity();
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
+  result = ((std::vector<CdiVariable > const *)arg1)->capacity();
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -16715,18 +14382,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_delete_VarsVector(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::vector< CdiVariable > *arg1 = (std::vector< CdiVariable > *) 0 ;
+  std::vector<CdiVariable > *arg1 = (std::vector<CdiVariable > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:delete_VarsVector",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, SWIG_POINTER_DISOWN |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_VarsVector" "', argument " "1"" of type '" "std::vector< CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_VarsVector" "', argument " "1"" of type '" "std::vector<CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::vector< CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::vector<CdiVariable > * >(argp1);
   delete arg1;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -16736,54 +14404,29 @@ fail:
 
 SWIGINTERN PyObject *VarsVector_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
-  SWIG_TypeNewClientData(SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, SWIG_NewClientData(obj));
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
 
-SWIGINTERN PyObject *_wrap_new_VarsMap__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::less< std::string > *arg1 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::map< std::string,CdiVariable > *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:new_VarsMap",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_std__lessT_std__string_t,  0  | 0);
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_VarsMap" "', argument " "1"" of type '" "std::less< std::string > const &""'"); 
-  }
-  if (!argp1) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_VarsMap" "', argument " "1"" of type '" "std::less< std::string > const &""'"); 
-  }
-  arg1 = reinterpret_cast< std::less< std::string > * >(argp1);
-  result = (std::map< std::string,CdiVariable > *)new std::map< std::string,CdiVariable >((std::less< std::string > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, SWIG_POINTER_NEW |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
 SWIGINTERN PyObject *_wrap_VarsMap_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_iterator" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_iterator" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_std_string_Sc_CdiVariable_Sg__iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_std_string_Sc_CdiVariable_Sg__iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -16792,41 +14435,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap___nonzero__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
   bool result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap___nonzero__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap___nonzero__" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  result = (bool)std_map_Sl_std_string_Sc_CdiVariable_Sg____nonzero__((std::map< std::string,CdiVariable > const *)arg1);
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_VarsMap___bool__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap___bool__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap___nonzero__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap___bool__" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap___nonzero__" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  result = (bool)std_map_Sl_std_string_Sc_CdiVariable_Sg____bool__((std::map< std::string,CdiVariable > const *)arg1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = (bool)std_map_Sl_std_string_Sc_CdiVariable_Sg____nonzero__((std::map<std::string,CdiVariable > const *)arg1);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -16836,19 +14457,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< std::string,CdiVariable >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsMap___len__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap___len__" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap___len__" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  result = std_map_Sl_std_string_Sc_CdiVariable_Sg____len__((std::map< std::string,CdiVariable > const *)arg1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = std_map_Sl_std_string_Sc_CdiVariable_Sg____len__((std::map<std::string,CdiVariable > const *)arg1);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -16858,40 +14479,40 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  std::map< std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable >::mapped_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< std::string,CdiVariable >::mapped_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap___getitem__" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap___getitem__" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
   {
     std::string *ptr = (std::string *)0;
     res2 = SWIG_AsPtr_std_string(obj1, &ptr);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap___getitem__" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap___getitem__" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap___getitem__" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap___getitem__" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     arg2 = ptr;
   }
   try {
-    result = (std::map< std::string,CdiVariable >::mapped_type *) &std_map_Sl_std_string_Sc_CdiVariable_Sg____getitem__(arg1,(std::string const &)*arg2);
+    result = std_map_Sl_std_string_Sc_CdiVariable_Sg____getitem__((std::map<std::string,CdiVariable > const *)arg1,(std::string const &)*arg2);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CdiVariable, 0 |  0 );
+  resultobj = SWIG_NewPointerObj((new std::map<std::string,CdiVariable >::mapped_type(static_cast< const std::map<std::string,CdiVariable >::mapped_type& >(result))), SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__mapped_type, SWIG_POINTER_OWN |  0 );
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
 fail:
@@ -16902,8 +14523,8 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap___delitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  std::map< std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::key_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 = SWIG_OLDOBJ ;
@@ -16911,19 +14532,19 @@ SWIGINTERN PyObject *_wrap_VarsMap___delitem__(PyObject *SWIGUNUSEDPARM(self), P
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap___delitem__" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap___delitem__" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
   {
     std::string *ptr = (std::string *)0;
     res2 = SWIG_AsPtr_std_string(obj1, &ptr);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap___delitem__" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap___delitem__" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap___delitem__" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap___delitem__" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     arg2 = ptr;
   }
@@ -16945,33 +14566,33 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap_has_key(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  std::map< std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::key_type *arg2 = 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap_has_key",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_has_key" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_has_key" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
   {
     std::string *ptr = (std::string *)0;
     res2 = SWIG_AsPtr_std_string(obj1, &ptr);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_has_key" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_has_key" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_has_key" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_has_key" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     arg2 = ptr;
   }
-  result = (bool)std_map_Sl_std_string_Sc_CdiVariable_Sg__has_key((std::map< std::string,CdiVariable > const *)arg1,(std::string const &)*arg2);
+  result = (bool)std_map_Sl_std_string_Sc_CdiVariable_Sg__has_key((std::map<std::string,CdiVariable > const *)arg1,(std::string const &)*arg2);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -16983,18 +14604,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap_keys(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_keys",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_keys" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_keys" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
   result = (PyObject *)std_map_Sl_std_string_Sc_CdiVariable_Sg__keys(arg1);
   resultobj = result;
   return resultobj;
@@ -17005,18 +14626,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap_values(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_values",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_values" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_values" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
   result = (PyObject *)std_map_Sl_std_string_Sc_CdiVariable_Sg__values(arg1);
   resultobj = result;
   return resultobj;
@@ -17027,18 +14648,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap_items(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_items",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_items" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_items" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
   result = (PyObject *)std_map_Sl_std_string_Sc_CdiVariable_Sg__items(arg1);
   resultobj = result;
   return resultobj;
@@ -17049,29 +14670,29 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap___contains__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  std::map< std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::key_type *arg2 = 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap___contains__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap___contains__" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap___contains__" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
   {
     std::string *ptr = (std::string *)0;
     res2 = SWIG_AsPtr_std_string(obj1, &ptr);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap___contains__" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap___contains__" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap___contains__" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap___contains__" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     arg2 = ptr;
   }
@@ -17087,22 +14708,22 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap_key_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_key_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_key_iterator" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_key_iterator" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_std_string_Sc_CdiVariable_Sg__key_iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_std_string_Sc_CdiVariable_Sg__key_iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -17111,70 +14732,33 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap_value_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_value_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_value_iterator" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_std_string_Sc_CdiVariable_Sg__value_iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_VarsMap___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  std::map< std::string,CdiVariable >::key_type *arg2 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  int res2 = SWIG_OLDOBJ ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap___setitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap___setitem__" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_value_iterator" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  {
-    std::string *ptr = (std::string *)0;
-    res2 = SWIG_AsPtr_std_string(obj1, &ptr);
-    if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap___setitem__" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
-    }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap___setitem__" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
-    }
-    arg2 = ptr;
-  }
-  std_map_Sl_std_string_Sc_CdiVariable_Sg____setitem____SWIG_0(arg1,(std::string const &)*arg2);
-  resultobj = SWIG_Py_Void();
-  if (SWIG_IsNewObj(res2)) delete arg2;
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_std_string_Sc_CdiVariable_Sg__value_iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
-  if (SWIG_IsNewObj(res2)) delete arg2;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsMap___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsMap___setitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  std::map< std::string,CdiVariable >::key_type *arg2 = 0 ;
-  std::map< std::string,CdiVariable >::mapped_type *arg3 = 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable >::mapped_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 = SWIG_OLDOBJ ;
@@ -17185,32 +14769,32 @@ SWIGINTERN PyObject *_wrap_VarsMap___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM(
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:VarsMap___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap___setitem__" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap___setitem__" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
   {
     std::string *ptr = (std::string *)0;
     res2 = SWIG_AsPtr_std_string(obj1, &ptr);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap___setitem__" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap___setitem__" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap___setitem__" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap___setitem__" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     arg2 = ptr;
   }
-  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_CdiVariable,  0  | 0);
+  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__mapped_type,  0  | 0);
   if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "VarsMap___setitem__" "', argument " "3"" of type '" "std::map< std::string,CdiVariable >::mapped_type const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "VarsMap___setitem__" "', argument " "3"" of type '" "std::map<std::string,CdiVariable >::mapped_type const &""'"); 
   }
   if (!argp3) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap___setitem__" "', argument " "3"" of type '" "std::map< std::string,CdiVariable >::mapped_type const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap___setitem__" "', argument " "3"" of type '" "std::map<std::string,CdiVariable >::mapped_type const &""'"); 
   }
-  arg3 = reinterpret_cast< std::map< std::string,CdiVariable >::mapped_type * >(argp3);
+  arg3 = reinterpret_cast< std::map<std::string,CdiVariable >::mapped_type * >(argp3);
   try {
-    std_map_Sl_std_string_Sc_CdiVariable_Sg____setitem____SWIG_1(arg1,(std::string const &)*arg2,(CdiVariable const &)*arg3);
+    std_map_Sl_std_string_Sc_CdiVariable_Sg____setitem__(arg1,(std::string const &)*arg2,(CdiVariable const &)*arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
@@ -17225,110 +14809,40 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsMap___setitem__(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[4];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        return _wrap_VarsMap___setitem____SWIG_0(self, args);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
-      _v = SWIG_CheckState(res);
-      if (_v) {
-        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_CdiVariable, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_VarsMap___setitem____SWIG_1(self, args);
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'VarsMap___setitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< std::string,CdiVariable >::__setitem__(std::map< std::string,CdiVariable >::key_type const &)\n"
-    "    std::map< std::string,CdiVariable >::__setitem__(std::map< std::string,CdiVariable >::key_type const &,std::map< std::string,CdiVariable >::mapped_type const &)\n");
-  return 0;
-}
-
-
-SWIGINTERN PyObject *_wrap_VarsMap_asdict(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_asdict",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_asdict" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  result = (PyObject *)std_map_Sl_std_string_Sc_CdiVariable_Sg__asdict(arg1);
-  resultobj = result;
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_VarsMap__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_VarsMap__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *result = 0 ;
+  std::map<std::string,CdiVariable > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)":new_VarsMap")) SWIG_fail;
-  result = (std::map< std::string,CdiVariable > *)new std::map< std::string,CdiVariable >();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, SWIG_POINTER_NEW |  0 );
+  result = (std::map<std::string,CdiVariable > *)new std::map<std::string,CdiVariable >();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_VarsMap__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_VarsMap__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = 0 ;
+  std::map<std::string,CdiVariable > *arg1 = 0 ;
+  std::map<std::string,CdiVariable > *result = 0 ;
   int res1 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
-  std::map< std::string,CdiVariable > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:new_VarsMap",&obj0)) SWIG_fail;
   {
-    std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > > *ptr = (std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > > *)0;
+    std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > > *ptr = (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > > *)0;
     res1 = swig::asptr(obj0, &ptr);
     if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_VarsMap" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_VarsMap" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_VarsMap" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_VarsMap" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const &""'"); 
     }
     arg1 = ptr;
   }
-  result = (std::map< std::string,CdiVariable > *)new std::map< std::string,CdiVariable >((std::map< std::string,CdiVariable > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, SWIG_POINTER_NEW |  0 );
+  result = (std::map<std::string,CdiVariable > *)new std::map<std::string,CdiVariable >((std::map<std::string,CdiVariable > const &)*arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, SWIG_POINTER_NEW |  0 );
   if (SWIG_IsNewObj(res1)) delete arg1;
   return resultobj;
 fail:
@@ -17343,55 +14857,43 @@ SWIGINTERN PyObject *_wrap_new_VarsMap(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 1) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 0) {
-    return _wrap_new_VarsMap__SWIG_1(self, args);
-  }
-  if (argc == 1) {
-    int _v;
-    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__lessT_std__string_t, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_new_VarsMap__SWIG_0(self, args);
-    }
+    return _wrap_new_VarsMap__SWIG_0(self, args);
   }
   if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_new_VarsMap__SWIG_2(self, args);
+      return _wrap_new_VarsMap__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_VarsMap'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< std::string,CdiVariable >::map(std::less< std::string > const &)\n"
-    "    std::map< std::string,CdiVariable >::map()\n"
-    "    std::map< std::string,CdiVariable >::map(std::map< std::string,CdiVariable > const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_VarsMap'.\n  Possible C/C++ prototypes are:\n    std::map<(std::string,CdiVariable)>()\n    std::map<(std::string,CdiVariable)>(std::map<std::string,CdiVariable > const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_VarsMap_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_empty",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_empty" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_empty" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  result = (bool)((std::map< std::string,CdiVariable > const *)arg1)->empty();
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = (bool)((std::map<std::string,CdiVariable > const *)arg1)->empty();
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -17401,19 +14903,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< std::string,CdiVariable >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_size",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_size" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_size" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  result = ((std::map< std::string,CdiVariable > const *)arg1)->size();
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = ((std::map<std::string,CdiVariable > const *)arg1)->size();
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -17423,17 +14925,17 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_clear",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_clear" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_clear" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
   (arg1)->clear();
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -17444,8 +14946,8 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  std::map< std::string,CdiVariable > *arg2 = 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -17454,19 +14956,19 @@ SWIGINTERN PyObject *_wrap_VarsMap_swap(PyObject *SWIGUNUSEDPARM(self), PyObject
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap_swap",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_swap" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_swap" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t,  0 );
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t,  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_swap" "', argument " "2"" of type '" "std::map< std::string,CdiVariable > &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_swap" "', argument " "2"" of type '" "std::map<std::string,CdiVariable > &""'"); 
   }
   if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_swap" "', argument " "2"" of type '" "std::map< std::string,CdiVariable > &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_swap" "', argument " "2"" of type '" "std::map<std::string,CdiVariable > &""'"); 
   }
-  arg2 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp2);
+  arg2 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp2);
   (arg1)->swap(*arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -17475,149 +14977,373 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsMap_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsMap_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  SwigValueWrapper<std::allocator<std::pair<std::string const,CdiVariable > > > result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_get_allocator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_get_allocator" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = ((std::map<std::string,CdiVariable > const *)arg1)->get_allocator();
+  resultobj = SWIG_NewPointerObj((new std::map<std::string,CdiVariable >::allocator_type(static_cast< const std::map<std::string,CdiVariable >::allocator_type& >(result))), SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__allocator_type, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsMap_begin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_begin" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = (arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<std::string,CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsMap_begin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_begin" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = ((std::map<std::string,CdiVariable > const *)arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<std::string,CdiVariable >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsMap_begin(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsMap_begin__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsMap_begin__SWIG_1(self, args);
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsMap_begin'.\n  Possible C/C++ prototypes are:\n    begin()\n    begin()\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsMap_end__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_end" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = (arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<std::string,CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsMap_end__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  SwigValueWrapper< std::allocator< std::pair< std::string const,CdiVariable > > > result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_get_allocator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_get_allocator" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_end" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  result = ((std::map< std::string,CdiVariable > const *)arg1)->get_allocator();
-  resultobj = SWIG_NewPointerObj((new std::map< std::string,CdiVariable >::allocator_type(static_cast< const std::map< std::string,CdiVariable >::allocator_type& >(result))), SWIGTYPE_p_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = ((std::map<std::string,CdiVariable > const *)arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<std::string,CdiVariable >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsMap_begin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsMap_end(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsMap_end__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsMap_end__SWIG_1(self, args);
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsMap_end'.\n  Possible C/C++ prototypes are:\n    end()\n    end()\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsMap_rbegin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< std::string,CdiVariable >::iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_begin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_begin" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_rbegin" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  result = (arg1)->begin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< std::string,CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = (arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<std::string,CdiVariable >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsMap_end(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsMap_rbegin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::const_reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< std::string,CdiVariable >::iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_end",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_end" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_rbegin" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  result = (arg1)->end();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< std::string,CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = ((std::map<std::string,CdiVariable > const *)arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<std::string,CdiVariable >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsMap_rbegin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsMap_rbegin(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsMap_rbegin__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsMap_rbegin__SWIG_1(self, args);
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsMap_rbegin'.\n  Possible C/C++ prototypes are:\n    rbegin()\n    rbegin()\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsMap_rend__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< std::string,CdiVariable >::reverse_iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_rbegin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_rbegin" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_rend" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  result = (arg1)->rbegin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< std::string,CdiVariable >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = (arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<std::string,CdiVariable >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsMap_rend(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsMap_rend__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::const_reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< std::string,CdiVariable >::reverse_iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsMap_rend",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_rend" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_rend" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  result = (arg1)->rend();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< std::string,CdiVariable >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  result = ((std::map<std::string,CdiVariable > const *)arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<std::string,CdiVariable >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
+SWIGINTERN PyObject *_wrap_VarsMap_rend(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsMap_rend__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsMap_rend__SWIG_1(self, args);
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsMap_rend'.\n  Possible C/C++ prototypes are:\n    rend()\n    rend()\n");
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *_wrap_VarsMap_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  std::map< std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< std::string,CdiVariable >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_erase" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_erase" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
   {
     std::string *ptr = (std::string *)0;
     res2 = SWIG_AsPtr_std_string(obj1, &ptr);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_erase" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_erase" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_erase" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_erase" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     arg2 = ptr;
   }
-  result = (arg1)->erase((std::map< std::string,CdiVariable >::key_type const &)*arg2);
+  result = (arg1)->erase((std::map<std::string,CdiVariable >::key_type const &)*arg2);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -17629,33 +15355,33 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap_count(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  std::map< std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< std::string,CdiVariable >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap_count",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_count" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_count" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
   {
     std::string *ptr = (std::string *)0;
     res2 = SWIG_AsPtr_std_string(obj1, &ptr);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_count" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_count" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_count" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_count" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     arg2 = ptr;
   }
-  result = ((std::map< std::string,CdiVariable > const *)arg1)->count((std::map< std::string,CdiVariable >::key_type const &)*arg2);
+  result = ((std::map<std::string,CdiVariable > const *)arg1)->count((std::map<std::string,CdiVariable >::key_type const &)*arg2);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -17667,33 +15393,33 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap_erase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  std::map< std::string,CdiVariable >::iterator arg2 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::iterator arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_erase" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_erase" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsMap_erase" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsMap_erase" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::map< std::string,CdiVariable >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< std::string,CdiVariable >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::map<std::string,CdiVariable >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<std::string,CdiVariable >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsMap_erase" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsMap_erase" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::iterator""'");
     }
   }
-  std_map_Sl_std_string_Sc_CdiVariable_Sg__erase__SWIG_1(arg1,arg2);
+  (arg1)->erase(arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -17703,48 +15429,48 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsMap_erase__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  std::map< std::string,CdiVariable >::iterator arg2 ;
-  std::map< std::string,CdiVariable >::iterator arg3 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::iterator arg2 ;
+  std::map<std::string,CdiVariable >::iterator arg3 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
-  swig::SwigPyIterator *iter3 = 0 ;
+  swig::PySwigIterator *iter3 = 0 ;
   int res3 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:VarsMap_erase",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_erase" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_erase" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsMap_erase" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsMap_erase" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::map< std::string,CdiVariable >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< std::string,CdiVariable >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::map<std::string,CdiVariable >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<std::string,CdiVariable >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsMap_erase" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsMap_erase" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::iterator""'");
     }
   }
-  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::SwigPyIterator::descriptor(), 0);
+  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res3) || !iter3) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsMap_erase" "', argument " "3"" of type '" "std::map< std::string,CdiVariable >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsMap_erase" "', argument " "3"" of type '" "std::map<std::string,CdiVariable >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::map< std::string,CdiVariable >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< std::string,CdiVariable >::iterator > *>(iter3);
+    swig::PySwigIterator_T<std::map<std::string,CdiVariable >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<std::string,CdiVariable >::iterator > *>(iter3);
     if (iter_t) {
       arg3 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsMap_erase" "', argument " "3"" of type '" "std::map< std::string,CdiVariable >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsMap_erase" "', argument " "3"" of type '" "std::map<std::string,CdiVariable >::iterator""'");
     }
   }
-  std_map_Sl_std_string_Sc_CdiVariable_Sg__erase__SWIG_2(arg1,arg2,arg3);
+  (arg1)->erase(arg2,arg3);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -17758,18 +15484,18 @@ SWIGINTERN PyObject *_wrap_VarsMap_erase(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< std::string,CdiVariable >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<std::string,CdiVariable >::iterator > *>(iter) != 0));
       if (_v) {
         return _wrap_VarsMap_erase__SWIG_1(self, args);
       }
@@ -17777,7 +15503,7 @@ SWIGINTERN PyObject *_wrap_VarsMap_erase(PyObject *self, PyObject *args) {
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
@@ -17789,16 +15515,16 @@ SWIGINTERN PyObject *_wrap_VarsMap_erase(PyObject *self, PyObject *args) {
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< std::string,CdiVariable >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<std::string,CdiVariable >::iterator > *>(iter) != 0));
       if (_v) {
-        swig::SwigPyIterator *iter = 0;
-        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< std::string,CdiVariable >::iterator > *>(iter) != 0));
+        swig::PySwigIterator *iter = 0;
+        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<std::string,CdiVariable >::iterator > *>(iter) != 0));
         if (_v) {
           return _wrap_VarsMap_erase__SWIG_2(self, args);
         }
@@ -17807,46 +15533,42 @@ SWIGINTERN PyObject *_wrap_VarsMap_erase(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'VarsMap_erase'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< std::string,CdiVariable >::erase(std::map< std::string,CdiVariable >::key_type const &)\n"
-    "    std::map< std::string,CdiVariable >::erase(std::map< std::string,CdiVariable >::iterator)\n"
-    "    std::map< std::string,CdiVariable >::erase(std::map< std::string,CdiVariable >::iterator,std::map< std::string,CdiVariable >::iterator)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsMap_erase'.\n  Possible C/C++ prototypes are:\n    erase(std::map<std::string,CdiVariable >::key_type const &)\n    erase(std::map<std::string,CdiVariable >::iterator)\n    erase(std::map<std::string,CdiVariable >::iterator,std::map<std::string,CdiVariable >::iterator)\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsMap_find(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsMap_find__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  std::map< std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< std::string,CdiVariable >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap_find",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_find" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_find" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
   {
     std::string *ptr = (std::string *)0;
     res2 = SWIG_AsPtr_std_string(obj1, &ptr);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_find" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_find" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_find" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_find" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     arg2 = ptr;
   }
-  result = (arg1)->find((std::map< std::string,CdiVariable >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< std::string,CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->find((std::map<std::string,CdiVariable >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<std::string,CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
 fail:
@@ -17855,37 +15577,37 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsMap_lower_bound(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsMap_find__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  std::map< std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< std::string,CdiVariable >::iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap_lower_bound",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap_find",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_lower_bound" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_find" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
   {
     std::string *ptr = (std::string *)0;
     res2 = SWIG_AsPtr_std_string(obj1, &ptr);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_lower_bound" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_find" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_lower_bound" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_find" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     arg2 = ptr;
   }
-  result = (arg1)->lower_bound((std::map< std::string,CdiVariable >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< std::string,CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = ((std::map<std::string,CdiVariable > const *)arg1)->find((std::map<std::string,CdiVariable >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<std::string,CdiVariable >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
 fail:
@@ -17894,37 +15616,78 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsMap_upper_bound(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsMap_find(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        return _wrap_VarsMap_find__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        return _wrap_VarsMap_find__SWIG_1(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsMap_find'.\n  Possible C/C++ prototypes are:\n    find(std::map<std::string,CdiVariable >::key_type const &)\n    find(std::map<std::string,CdiVariable >::key_type const &)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsMap_lower_bound__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
-  std::map< std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< std::string,CdiVariable >::iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap_upper_bound",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap_lower_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_upper_bound" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_lower_bound" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
   {
     std::string *ptr = (std::string *)0;
     res2 = SWIG_AsPtr_std_string(obj1, &ptr);
     if (!SWIG_IsOK(res2)) {
-      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_upper_bound" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_lower_bound" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_upper_bound" "', argument " "2"" of type '" "std::map< std::string,CdiVariable >::key_type const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_lower_bound" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
     }
     arg2 = ptr;
   }
-  result = (arg1)->upper_bound((std::map< std::string,CdiVariable >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< std::string,CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->lower_bound((std::map<std::string,CdiVariable >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<std::string,CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
 fail:
@@ -17933,120 +15696,273 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_delete_VarsMap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsMap_lower_bound__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< std::string,CdiVariable > *arg1 = (std::map< std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:delete_VarsMap",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, SWIG_POINTER_DISOWN |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap_lower_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_VarsMap" "', argument " "1"" of type '" "std::map< std::string,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_lower_bound" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< std::string,CdiVariable > * >(argp1);
-  delete arg1;
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  {
+    std::string *ptr = (std::string *)0;
+    res2 = SWIG_AsPtr_std_string(obj1, &ptr);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_lower_bound" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_lower_bound" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
+    }
+    arg2 = ptr;
+  }
+  result = ((std::map<std::string,CdiVariable > const *)arg1)->lower_bound((std::map<std::string,CdiVariable >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<std::string,CdiVariable >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
 fail:
+  if (SWIG_IsNewObj(res2)) delete arg2;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *VarsMap_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
-  SWIG_TypeNewClientData(SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, SWIG_NewClientData(obj));
-  return SWIG_Py_Void();
+SWIGINTERN PyObject *_wrap_VarsMap_lower_bound(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        return _wrap_VarsMap_lower_bound__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        return _wrap_VarsMap_lower_bound__SWIG_1(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsMap_lower_bound'.\n  Possible C/C++ prototypes are:\n    lower_bound(std::map<std::string,CdiVariable >::key_type const &)\n    lower_bound(std::map<std::string,CdiVariable >::key_type const &)\n");
+  return NULL;
 }
 
-SWIGINTERN PyObject *_wrap_new_VarsByCode__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+
+SWIGINTERN PyObject *_wrap_VarsMap_upper_bound__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::less< int > *arg1 = 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  int res2 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiVariable > *result = 0 ;
+  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:new_VarsByCode",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_std__lessT_int_t,  0  | 0);
+  if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap_upper_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_upper_bound" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  {
+    std::string *ptr = (std::string *)0;
+    res2 = SWIG_AsPtr_std_string(obj1, &ptr);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_upper_bound" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_upper_bound" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
+    }
+    arg2 = ptr;
+  }
+  result = (arg1)->upper_bound((std::map<std::string,CdiVariable >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<std::string,CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsMap_upper_bound__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
+  std::map<std::string,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<std::string,CdiVariable >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  int res2 = SWIG_OLDOBJ ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:VarsMap_upper_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_VarsByCode" "', argument " "1"" of type '" "std::less< int > const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsMap_upper_bound" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > const *""'"); 
   }
-  if (!argp1) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_VarsByCode" "', argument " "1"" of type '" "std::less< int > const &""'"); 
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  {
+    std::string *ptr = (std::string *)0;
+    res2 = SWIG_AsPtr_std_string(obj1, &ptr);
+    if (!SWIG_IsOK(res2)) {
+      SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsMap_upper_bound" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsMap_upper_bound" "', argument " "2"" of type '" "std::map<std::string,CdiVariable >::key_type const &""'"); 
+    }
+    arg2 = ptr;
   }
-  arg1 = reinterpret_cast< std::less< int > * >(argp1);
-  result = (std::map< int,CdiVariable > *)new std::map< int,CdiVariable >((std::less< int > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, SWIG_POINTER_NEW |  0 );
+  result = ((std::map<std::string,CdiVariable > const *)arg1)->upper_bound((std::map<std::string,CdiVariable >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<std::string,CdiVariable >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
 fail:
+  if (SWIG_IsNewObj(res2)) delete arg2;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsMap_upper_bound(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        return _wrap_VarsMap_upper_bound__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      int res = SWIG_AsPtr_std_string(argv[1], (std::string**)(0));
+      _v = SWIG_CheckState(res);
+      if (_v) {
+        return _wrap_VarsMap_upper_bound__SWIG_1(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsMap_upper_bound'.\n  Possible C/C++ prototypes are:\n    upper_bound(std::map<std::string,CdiVariable >::key_type const &)\n    upper_bound(std::map<std::string,CdiVariable >::key_type const &)\n");
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_delete_VarsMap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  PyObject **arg2 = (PyObject **) 0 ;
+  std::map<std::string,CdiVariable > *arg1 = (std::map<std::string,CdiVariable > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
-  arg2 = &obj0;
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:delete_VarsMap",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_iterator" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_VarsMap" "', argument " "1"" of type '" "std::map<std::string,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_int_Sc_CdiVariable_Sg__iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<std::string,CdiVariable > * >(argp1);
+  delete arg1;
+  
+  resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode___nonzero__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *VarsMap_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *obj;
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, SWIG_NewClientData(obj));
+  return SWIG_Py_Void();
+}
+
+SWIGINTERN PyObject *_wrap_VarsByCode_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode___nonzero__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  arg2 = &obj0;
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_iterator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode___nonzero__" "', argument " "1"" of type '" "std::map< int,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_iterator" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  result = (bool)std_map_Sl_int_Sc_CdiVariable_Sg____nonzero__((std::map< int,CdiVariable > const *)arg1);
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_int_Sc_CdiVariable_Sg__iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode___bool__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode___nonzero__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode___bool__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode___nonzero__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode___bool__" "', argument " "1"" of type '" "std::map< int,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode___nonzero__" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  result = (bool)std_map_Sl_int_Sc_CdiVariable_Sg____bool__((std::map< int,CdiVariable > const *)arg1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = (bool)std_map_Sl_int_Sc_CdiVariable_Sg____nonzero__((std::map<int,CdiVariable > const *)arg1);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -18056,19 +15972,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsByCode___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiVariable >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode___len__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode___len__" "', argument " "1"" of type '" "std::map< int,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode___len__" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  result = std_map_Sl_int_Sc_CdiVariable_Sg____len__((std::map< int,CdiVariable > const *)arg1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = std_map_Sl_int_Sc_CdiVariable_Sg____len__((std::map<int,CdiVariable > const *)arg1);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -18078,37 +15994,37 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsByCode___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  std::map< int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable >::mapped_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiVariable >::key_type temp2 ;
+  std::map<int,CdiVariable >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiVariable >::mapped_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode___getitem__" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode___getitem__" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode___getitem__" "', argument " "2"" of type '" "std::map< int,CdiVariable >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode___getitem__" "', argument " "2"" of type '" "std::map<int,CdiVariable >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiVariable >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiVariable >::key_type >(val2);
   arg2 = &temp2;
   try {
-    result = (std::map< int,CdiVariable >::mapped_type *) &std_map_Sl_int_Sc_CdiVariable_Sg____getitem__(arg1,(int const &)*arg2);
+    result = std_map_Sl_int_Sc_CdiVariable_Sg____getitem__((std::map<int,CdiVariable > const *)arg1,(int const &)*arg2);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CdiVariable, 0 |  0 );
+  resultobj = SWIG_NewPointerObj((new std::map<int,CdiVariable >::mapped_type(static_cast< const std::map<int,CdiVariable >::mapped_type& >(result))), SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__mapped_type, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -18117,27 +16033,27 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsByCode___delitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  std::map< int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::key_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiVariable >::key_type temp2 ;
+  std::map<int,CdiVariable >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode___delitem__" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode___delitem__" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode___delitem__" "', argument " "2"" of type '" "std::map< int,CdiVariable >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode___delitem__" "', argument " "2"" of type '" "std::map<int,CdiVariable >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiVariable >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiVariable >::key_type >(val2);
   arg2 = &temp2;
   try {
     std_map_Sl_int_Sc_CdiVariable_Sg____delitem__(arg1,(int const &)*arg2);
@@ -18155,30 +16071,30 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsByCode_has_key(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  std::map< int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::key_type *arg2 = 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiVariable >::key_type temp2 ;
+  std::map<int,CdiVariable >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode_has_key",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_has_key" "', argument " "1"" of type '" "std::map< int,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_has_key" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_has_key" "', argument " "2"" of type '" "std::map< int,CdiVariable >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_has_key" "', argument " "2"" of type '" "std::map<int,CdiVariable >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiVariable >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiVariable >::key_type >(val2);
   arg2 = &temp2;
-  result = (bool)std_map_Sl_int_Sc_CdiVariable_Sg__has_key((std::map< int,CdiVariable > const *)arg1,(int const &)*arg2);
+  result = (bool)std_map_Sl_int_Sc_CdiVariable_Sg__has_key((std::map<int,CdiVariable > const *)arg1,(int const &)*arg2);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -18188,18 +16104,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsByCode_keys(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_keys",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_keys" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_keys" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
   result = (PyObject *)std_map_Sl_int_Sc_CdiVariable_Sg__keys(arg1);
   resultobj = result;
   return resultobj;
@@ -18210,18 +16126,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsByCode_values(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_values",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_values" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_values" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
   result = (PyObject *)std_map_Sl_int_Sc_CdiVariable_Sg__values(arg1);
   resultobj = result;
   return resultobj;
@@ -18232,18 +16148,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsByCode_items(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_items",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_items" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_items" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
   result = (PyObject *)std_map_Sl_int_Sc_CdiVariable_Sg__items(arg1);
   resultobj = result;
   return resultobj;
@@ -18254,28 +16170,28 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsByCode___contains__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  std::map< int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::key_type *arg2 = 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiVariable >::key_type temp2 ;
+  std::map<int,CdiVariable >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode___contains__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode___contains__" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode___contains__" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode___contains__" "', argument " "2"" of type '" "std::map< int,CdiVariable >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode___contains__" "', argument " "2"" of type '" "std::map<int,CdiVariable >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiVariable >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiVariable >::key_type >(val2);
   arg2 = &temp2;
   result = (bool)std_map_Sl_int_Sc_CdiVariable_Sg____contains__(arg1,(int const &)*arg2);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
@@ -18287,22 +16203,22 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsByCode_key_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_key_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_key_iterator" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_key_iterator" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_int_Sc_CdiVariable_Sg__key_iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_int_Sc_CdiVariable_Sg__key_iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -18311,68 +16227,36 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsByCode_value_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_value_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_value_iterator" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_int_Sc_CdiVariable_Sg__value_iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_VarsByCode___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  std::map< int,CdiVariable >::key_type *arg2 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  std::map< int,CdiVariable >::key_type temp2 ;
-  int val2 ;
-  int ecode2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode___setitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode___setitem__" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_value_iterator" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  ecode2 = SWIG_AsVal_int(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode___setitem__" "', argument " "2"" of type '" "std::map< int,CdiVariable >::key_type""'");
-  } 
-  temp2 = static_cast< std::map< int,CdiVariable >::key_type >(val2);
-  arg2 = &temp2;
-  std_map_Sl_int_Sc_CdiVariable_Sg____setitem____SWIG_0(arg1,(int const &)*arg2);
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_int_Sc_CdiVariable_Sg__value_iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode___setitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  std::map< int,CdiVariable >::key_type *arg2 = 0 ;
-  std::map< int,CdiVariable >::mapped_type *arg3 = 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable >::mapped_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiVariable >::key_type temp2 ;
+  std::map<int,CdiVariable >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   void *argp3 = 0 ;
@@ -18382,27 +16266,27 @@ SWIGINTERN PyObject *_wrap_VarsByCode___setitem____SWIG_1(PyObject *SWIGUNUSEDPA
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:VarsByCode___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode___setitem__" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode___setitem__" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode___setitem__" "', argument " "2"" of type '" "std::map< int,CdiVariable >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode___setitem__" "', argument " "2"" of type '" "std::map<int,CdiVariable >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiVariable >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiVariable >::key_type >(val2);
   arg2 = &temp2;
-  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_CdiVariable,  0  | 0);
+  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__mapped_type,  0  | 0);
   if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "VarsByCode___setitem__" "', argument " "3"" of type '" "std::map< int,CdiVariable >::mapped_type const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "VarsByCode___setitem__" "', argument " "3"" of type '" "std::map<int,CdiVariable >::mapped_type const &""'"); 
   }
   if (!argp3) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsByCode___setitem__" "', argument " "3"" of type '" "std::map< int,CdiVariable >::mapped_type const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsByCode___setitem__" "', argument " "3"" of type '" "std::map<int,CdiVariable >::mapped_type const &""'"); 
   }
-  arg3 = reinterpret_cast< std::map< int,CdiVariable >::mapped_type * >(argp3);
+  arg3 = reinterpret_cast< std::map<int,CdiVariable >::mapped_type * >(argp3);
   try {
-    std_map_Sl_int_Sc_CdiVariable_Sg____setitem____SWIG_1(arg1,(int const &)*arg2,(CdiVariable const &)*arg3);
+    std_map_Sl_int_Sc_CdiVariable_Sg____setitem__(arg1,(int const &)*arg2,(CdiVariable const &)*arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
@@ -18415,400 +16299,538 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode___setitem__(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_VarsByCode__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiVariable > *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)":new_VarsByCode")) SWIG_fail;
+  result = (std::map<int,CdiVariable > *)new std::map<int,CdiVariable >();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_VarsByCode__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiVariable > *arg1 = 0 ;
+  std::map<int,CdiVariable > *result = 0 ;
+  int res1 = SWIG_OLDOBJ ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:new_VarsByCode",&obj0)) SWIG_fail;
+  {
+    std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > > *ptr = (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > > *)0;
+    res1 = swig::asptr(obj0, &ptr);
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_VarsByCode" "', argument " "1"" of type '" "std::map<int,CdiVariable > const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_VarsByCode" "', argument " "1"" of type '" "std::map<int,CdiVariable > const &""'"); 
+    }
+    arg1 = ptr;
+  }
+  result = (std::map<int,CdiVariable > *)new std::map<int,CdiVariable >((std::map<int,CdiVariable > const &)*arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, SWIG_POINTER_NEW |  0 );
+  if (SWIG_IsNewObj(res1)) delete arg1;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res1)) delete arg1;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_VarsByCode(PyObject *self, PyObject *args) {
   int argc;
-  PyObject *argv[4];
+  PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_int(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_VarsByCode___setitem____SWIG_0(self, args);
-      }
-    }
+  if (argc == 0) {
+    return _wrap_new_VarsByCode__SWIG_0(self, args);
   }
-  if (argc == 3) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_int(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_CdiVariable, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_VarsByCode___setitem____SWIG_1(self, args);
-        }
-      }
+      return _wrap_new_VarsByCode__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'VarsByCode___setitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< int,CdiVariable >::__setitem__(std::map< int,CdiVariable >::key_type const &)\n"
-    "    std::map< int,CdiVariable >::__setitem__(std::map< int,CdiVariable >::key_type const &,std::map< int,CdiVariable >::mapped_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_VarsByCode'.\n  Possible C/C++ prototypes are:\n    std::map<(int,CdiVariable)>()\n    std::map<(int,CdiVariable)>(std::map<int,CdiVariable > const &)\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode_asdict(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_asdict",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_empty",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_asdict" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_empty" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  result = (PyObject *)std_map_Sl_int_Sc_CdiVariable_Sg__asdict(arg1);
-  resultobj = result;
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = (bool)((std::map<int,CdiVariable > const *)arg1)->empty();
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_VarsByCode__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::size_type result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_size",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_size" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = ((std::map<int,CdiVariable > const *)arg1)->size();
+  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsByCode_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *result = 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)":new_VarsByCode")) SWIG_fail;
-  result = (std::map< int,CdiVariable > *)new std::map< int,CdiVariable >();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, SWIG_POINTER_NEW |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_clear",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_clear" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  (arg1)->clear();
+  resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_VarsByCode__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = 0 ;
-  int res1 = SWIG_OLDOBJ ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiVariable > *result = 0 ;
+  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:new_VarsByCode",&obj0)) SWIG_fail;
-  {
-    std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > > *ptr = (std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > > *)0;
-    res1 = swig::asptr(obj0, &ptr);
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_VarsByCode" "', argument " "1"" of type '" "std::map< int,CdiVariable > const &""'"); 
-    }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_VarsByCode" "', argument " "1"" of type '" "std::map< int,CdiVariable > const &""'"); 
-    }
-    arg1 = ptr;
+  if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode_swap",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_swap" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  result = (std::map< int,CdiVariable > *)new std::map< int,CdiVariable >((std::map< int,CdiVariable > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, SWIG_POINTER_NEW |  0 );
-  if (SWIG_IsNewObj(res1)) delete arg1;
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t,  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsByCode_swap" "', argument " "2"" of type '" "std::map<int,CdiVariable > &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsByCode_swap" "', argument " "2"" of type '" "std::map<int,CdiVariable > &""'"); 
+  }
+  arg2 = reinterpret_cast< std::map<int,CdiVariable > * >(argp2);
+  (arg1)->swap(*arg2);
+  resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
-  if (SWIG_IsNewObj(res1)) delete arg1;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_VarsByCode(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  SwigValueWrapper<std::allocator<std::pair<int const,CdiVariable > > > result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_get_allocator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_get_allocator" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = ((std::map<int,CdiVariable > const *)arg1)->get_allocator();
+  resultobj = SWIG_NewPointerObj((new std::map<int,CdiVariable >::allocator_type(static_cast< const std::map<int,CdiVariable >::allocator_type& >(result))), SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__allocator_type, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsByCode_begin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_begin" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = (arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsByCode_begin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_begin" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = ((std::map<int,CdiVariable > const *)arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiVariable >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsByCode_begin(PyObject *self, PyObject *args) {
   int argc;
   PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 1) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 0) {
-    return _wrap_new_VarsByCode__SWIG_1(self, args);
-  }
   if (argc == 1) {
     int _v;
-    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__lessT_int_t, 0);
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_new_VarsByCode__SWIG_0(self, args);
+      return _wrap_VarsByCode_begin__SWIG_0(self, args);
     }
   }
   if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_new_VarsByCode__SWIG_2(self, args);
+      return _wrap_VarsByCode_begin__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_VarsByCode'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< int,CdiVariable >::map(std::less< int > const &)\n"
-    "    std::map< int,CdiVariable >::map()\n"
-    "    std::map< int,CdiVariable >::map(std::map< int,CdiVariable > const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsByCode_begin'.\n  Possible C/C++ prototypes are:\n    begin()\n    begin()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode_end__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_empty",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_empty" "', argument " "1"" of type '" "std::map< int,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_end" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  result = (bool)((std::map< int,CdiVariable > const *)arg1)->empty();
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = (arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode_end__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiVariable >::size_type result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_size",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_size" "', argument " "1"" of type '" "std::map< int,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_end" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  result = ((std::map< int,CdiVariable > const *)arg1)->size();
-  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = ((std::map<int,CdiVariable > const *)arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiVariable >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
+SWIGINTERN PyObject *_wrap_VarsByCode_end(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_clear",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_clear" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsByCode_end__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsByCode_end__SWIG_1(self, args);
+    }
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  (arg1)->clear();
-  resultobj = SWIG_Py_Void();
-  return resultobj;
+  
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsByCode_end'.\n  Possible C/C++ prototypes are:\n    end()\n    end()\n");
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode_rbegin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  std::map< int,CdiVariable > *arg2 = 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode_swap",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_swap" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t,  0 );
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "VarsByCode_swap" "', argument " "2"" of type '" "std::map< int,CdiVariable > &""'"); 
-  }
-  if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "VarsByCode_swap" "', argument " "2"" of type '" "std::map< int,CdiVariable > &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_rbegin" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg2 = reinterpret_cast< std::map< int,CdiVariable > * >(argp2);
-  (arg1)->swap(*arg2);
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = (arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiVariable >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode_rbegin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::const_reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  SwigValueWrapper< std::allocator< std::pair< int const,CdiVariable > > > result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_get_allocator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_get_allocator" "', argument " "1"" of type '" "std::map< int,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_rbegin" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  result = ((std::map< int,CdiVariable > const *)arg1)->get_allocator();
-  resultobj = SWIG_NewPointerObj((new std::map< int,CdiVariable >::allocator_type(static_cast< const std::map< int,CdiVariable >::allocator_type& >(result))), SWIGTYPE_p_std__allocatorT_std__pairT_int_const_CdiVariable_t_t, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = ((std::map<int,CdiVariable > const *)arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiVariable >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode_begin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::map< int,CdiVariable >::iterator result;
+SWIGINTERN PyObject *_wrap_VarsByCode_rbegin(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_begin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_begin" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  result = (arg1)->begin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsByCode_rbegin__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsByCode_rbegin__SWIG_1(self, args);
+    }
+  }
+  
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsByCode_rbegin'.\n  Possible C/C++ prototypes are:\n    rbegin()\n    rbegin()\n");
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode_end(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode_rend__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiVariable >::iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_end",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_end" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_rend" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  result = (arg1)->end();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = (arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiVariable >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode_rbegin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode_rend__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::const_reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiVariable >::reverse_iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_rbegin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_rbegin" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_rend" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  result = (arg1)->rbegin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiVariable >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  result = ((std::map<int,CdiVariable > const *)arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiVariable >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode_rend(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::map< int,CdiVariable >::reverse_iterator result;
+SWIGINTERN PyObject *_wrap_VarsByCode_rend(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:VarsByCode_rend",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_rend" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  result = (arg1)->rend();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiVariable >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsByCode_rend__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_VarsByCode_rend__SWIG_1(self, args);
+    }
+  }
+  
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsByCode_rend'.\n  Possible C/C++ prototypes are:\n    rend()\n    rend()\n");
   return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_VarsByCode_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  std::map< int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiVariable >::key_type temp2 ;
+  std::map<int,CdiVariable >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiVariable >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_erase" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_erase" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_erase" "', argument " "2"" of type '" "std::map< int,CdiVariable >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_erase" "', argument " "2"" of type '" "std::map<int,CdiVariable >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiVariable >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiVariable >::key_type >(val2);
   arg2 = &temp2;
-  result = (arg1)->erase((std::map< int,CdiVariable >::key_type const &)*arg2);
+  result = (arg1)->erase((std::map<int,CdiVariable >::key_type const &)*arg2);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -18818,30 +16840,30 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsByCode_count(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  std::map< int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiVariable >::key_type temp2 ;
+  std::map<int,CdiVariable >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiVariable >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode_count",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_count" "', argument " "1"" of type '" "std::map< int,CdiVariable > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_count" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_count" "', argument " "2"" of type '" "std::map< int,CdiVariable >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_count" "', argument " "2"" of type '" "std::map<int,CdiVariable >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiVariable >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiVariable >::key_type >(val2);
   arg2 = &temp2;
-  result = ((std::map< int,CdiVariable > const *)arg1)->count((std::map< int,CdiVariable >::key_type const &)*arg2);
+  result = ((std::map<int,CdiVariable > const *)arg1)->count((std::map<int,CdiVariable >::key_type const &)*arg2);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -18851,33 +16873,33 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsByCode_erase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  std::map< int,CdiVariable >::iterator arg2 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::iterator arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_erase" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_erase" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsByCode_erase" "', argument " "2"" of type '" "std::map< int,CdiVariable >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsByCode_erase" "', argument " "2"" of type '" "std::map<int,CdiVariable >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::map< int,CdiVariable >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiVariable >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::map<int,CdiVariable >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiVariable >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsByCode_erase" "', argument " "2"" of type '" "std::map< int,CdiVariable >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsByCode_erase" "', argument " "2"" of type '" "std::map<int,CdiVariable >::iterator""'");
     }
   }
-  std_map_Sl_int_Sc_CdiVariable_Sg__erase__SWIG_1(arg1,arg2);
+  (arg1)->erase(arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -18887,48 +16909,48 @@ fail:
 
 SWIGINTERN PyObject *_wrap_VarsByCode_erase__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  std::map< int,CdiVariable >::iterator arg2 ;
-  std::map< int,CdiVariable >::iterator arg3 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::iterator arg2 ;
+  std::map<int,CdiVariable >::iterator arg3 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
-  swig::SwigPyIterator *iter3 = 0 ;
+  swig::PySwigIterator *iter3 = 0 ;
   int res3 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:VarsByCode_erase",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_erase" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_erase" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsByCode_erase" "', argument " "2"" of type '" "std::map< int,CdiVariable >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsByCode_erase" "', argument " "2"" of type '" "std::map<int,CdiVariable >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::map< int,CdiVariable >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiVariable >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::map<int,CdiVariable >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiVariable >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsByCode_erase" "', argument " "2"" of type '" "std::map< int,CdiVariable >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsByCode_erase" "', argument " "2"" of type '" "std::map<int,CdiVariable >::iterator""'");
     }
   }
-  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::SwigPyIterator::descriptor(), 0);
+  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res3) || !iter3) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsByCode_erase" "', argument " "3"" of type '" "std::map< int,CdiVariable >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsByCode_erase" "', argument " "3"" of type '" "std::map<int,CdiVariable >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::map< int,CdiVariable >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiVariable >::iterator > *>(iter3);
+    swig::PySwigIterator_T<std::map<int,CdiVariable >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiVariable >::iterator > *>(iter3);
     if (iter_t) {
       arg3 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsByCode_erase" "', argument " "3"" of type '" "std::map< int,CdiVariable >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "VarsByCode_erase" "', argument " "3"" of type '" "std::map<int,CdiVariable >::iterator""'");
     }
   }
-  std_map_Sl_int_Sc_CdiVariable_Sg__erase__SWIG_2(arg1,arg2,arg3);
+  (arg1)->erase(arg2,arg3);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -18942,18 +16964,18 @@ SWIGINTERN PyObject *_wrap_VarsByCode_erase(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiVariable >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiVariable >::iterator > *>(iter) != 0));
       if (_v) {
         return _wrap_VarsByCode_erase__SWIG_1(self, args);
       }
@@ -18961,7 +16983,7 @@ SWIGINTERN PyObject *_wrap_VarsByCode_erase(PyObject *self, PyObject *args) {
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -18975,16 +16997,16 @@ SWIGINTERN PyObject *_wrap_VarsByCode_erase(PyObject *self, PyObject *args) {
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiVariable >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiVariable >::iterator > *>(iter) != 0));
       if (_v) {
-        swig::SwigPyIterator *iter = 0;
-        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiVariable >::iterator > *>(iter) != 0));
+        swig::PySwigIterator *iter = 0;
+        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiVariable >::iterator > *>(iter) != 0));
         if (_v) {
           return _wrap_VarsByCode_erase__SWIG_2(self, args);
         }
@@ -18993,131 +17015,365 @@ SWIGINTERN PyObject *_wrap_VarsByCode_erase(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'VarsByCode_erase'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< int,CdiVariable >::erase(std::map< int,CdiVariable >::key_type const &)\n"
-    "    std::map< int,CdiVariable >::erase(std::map< int,CdiVariable >::iterator)\n"
-    "    std::map< int,CdiVariable >::erase(std::map< int,CdiVariable >::iterator,std::map< int,CdiVariable >::iterator)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsByCode_erase'.\n  Possible C/C++ prototypes are:\n    erase(std::map<int,CdiVariable >::key_type const &)\n    erase(std::map<int,CdiVariable >::iterator)\n    erase(std::map<int,CdiVariable >::iterator,std::map<int,CdiVariable >::iterator)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsByCode_find__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  std::map<int,CdiVariable >::key_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode_find",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_find" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_find" "', argument " "2"" of type '" "std::map<int,CdiVariable >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiVariable >::key_type >(val2);
+  arg2 = &temp2;
+  result = (arg1)->find((std::map<int,CdiVariable >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode_find(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode_find__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  std::map< int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiVariable >::key_type temp2 ;
+  std::map<int,CdiVariable >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiVariable >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode_find",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_find" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_find" "', argument " "2"" of type '" "std::map<int,CdiVariable >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiVariable >::key_type >(val2);
+  arg2 = &temp2;
+  result = ((std::map<int,CdiVariable > const *)arg1)->find((std::map<int,CdiVariable >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiVariable >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsByCode_find(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_VarsByCode_find__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_VarsByCode_find__SWIG_1(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsByCode_find'.\n  Possible C/C++ prototypes are:\n    find(std::map<int,CdiVariable >::key_type const &)\n    find(std::map<int,CdiVariable >::key_type const &)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsByCode_lower_bound__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  std::map<int,CdiVariable >::key_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode_lower_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_find" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_lower_bound" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_find" "', argument " "2"" of type '" "std::map< int,CdiVariable >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_lower_bound" "', argument " "2"" of type '" "std::map<int,CdiVariable >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiVariable >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiVariable >::key_type >(val2);
   arg2 = &temp2;
-  result = (arg1)->find((std::map< int,CdiVariable >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->lower_bound((std::map<int,CdiVariable >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode_lower_bound(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode_lower_bound__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  std::map< int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiVariable >::key_type temp2 ;
+  std::map<int,CdiVariable >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiVariable >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode_lower_bound",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_lower_bound" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_lower_bound" "', argument " "2"" of type '" "std::map<int,CdiVariable >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiVariable >::key_type >(val2);
+  arg2 = &temp2;
+  result = ((std::map<int,CdiVariable > const *)arg1)->lower_bound((std::map<int,CdiVariable >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiVariable >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsByCode_lower_bound(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_VarsByCode_lower_bound__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_VarsByCode_lower_bound__SWIG_1(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsByCode_lower_bound'.\n  Possible C/C++ prototypes are:\n    lower_bound(std::map<int,CdiVariable >::key_type const &)\n    lower_bound(std::map<int,CdiVariable >::key_type const &)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_VarsByCode_upper_bound__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  std::map<int,CdiVariable >::key_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode_upper_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_lower_bound" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_upper_bound" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_lower_bound" "', argument " "2"" of type '" "std::map< int,CdiVariable >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_upper_bound" "', argument " "2"" of type '" "std::map<int,CdiVariable >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiVariable >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiVariable >::key_type >(val2);
   arg2 = &temp2;
-  result = (arg1)->lower_bound((std::map< int,CdiVariable >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->upper_bound((std::map<int,CdiVariable >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiVariable >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_VarsByCode_upper_bound(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_VarsByCode_upper_bound__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
-  std::map< int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable >::key_type *arg2 = 0 ;
+  std::map<int,CdiVariable >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiVariable >::key_type temp2 ;
+  std::map<int,CdiVariable >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiVariable >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:VarsByCode_upper_bound",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_upper_bound" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "VarsByCode_upper_bound" "', argument " "1"" of type '" "std::map<int,CdiVariable > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_upper_bound" "', argument " "2"" of type '" "std::map< int,CdiVariable >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "VarsByCode_upper_bound" "', argument " "2"" of type '" "std::map<int,CdiVariable >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiVariable >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiVariable >::key_type >(val2);
   arg2 = &temp2;
-  result = (arg1)->upper_bound((std::map< int,CdiVariable >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiVariable >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = ((std::map<int,CdiVariable > const *)arg1)->upper_bound((std::map<int,CdiVariable >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiVariable >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
+SWIGINTERN PyObject *_wrap_VarsByCode_upper_bound(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_VarsByCode_upper_bound__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_VarsByCode_upper_bound__SWIG_1(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'VarsByCode_upper_bound'.\n  Possible C/C++ prototypes are:\n    upper_bound(std::map<int,CdiVariable >::key_type const &)\n    upper_bound(std::map<int,CdiVariable >::key_type const &)\n");
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *_wrap_delete_VarsByCode(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiVariable > *arg1 = (std::map< int,CdiVariable > *) 0 ;
+  std::map<int,CdiVariable > *arg1 = (std::map<int,CdiVariable > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:delete_VarsByCode",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, SWIG_POINTER_DISOWN |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_VarsByCode" "', argument " "1"" of type '" "std::map< int,CdiVariable > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_VarsByCode" "', argument " "1"" of type '" "std::map<int,CdiVariable > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiVariable > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiVariable > * >(argp1);
   delete arg1;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -19127,54 +17383,29 @@ fail:
 
 SWIGINTERN PyObject *VarsByCode_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
-  SWIG_TypeNewClientData(SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, SWIG_NewClientData(obj));
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
 
-SWIGINTERN PyObject *_wrap_new_TaxesMap__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::less< int > *arg1 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::map< int,CdiTaxis > *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:new_TaxesMap",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_std__lessT_int_t,  0  | 0);
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_TaxesMap" "', argument " "1"" of type '" "std::less< int > const &""'"); 
-  }
-  if (!argp1) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_TaxesMap" "', argument " "1"" of type '" "std::less< int > const &""'"); 
-  }
-  arg1 = reinterpret_cast< std::less< int > * >(argp1);
-  result = (std::map< int,CdiTaxis > *)new std::map< int,CdiTaxis >((std::less< int > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, SWIG_POINTER_NEW |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
 SWIGINTERN PyObject *_wrap_TaxesMap_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_iterator" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_iterator" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_int_Sc_CdiTaxis_Sg__iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_int_Sc_CdiTaxis_Sg__iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -19183,41 +17414,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap___nonzero__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
   bool result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap___nonzero__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap___nonzero__" "', argument " "1"" of type '" "std::map< int,CdiTaxis > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  result = (bool)std_map_Sl_int_Sc_CdiTaxis_Sg____nonzero__((std::map< int,CdiTaxis > const *)arg1);
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_TaxesMap___bool__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap___bool__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap___nonzero__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap___bool__" "', argument " "1"" of type '" "std::map< int,CdiTaxis > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap___nonzero__" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  result = (bool)std_map_Sl_int_Sc_CdiTaxis_Sg____bool__((std::map< int,CdiTaxis > const *)arg1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = (bool)std_map_Sl_int_Sc_CdiTaxis_Sg____nonzero__((std::map<int,CdiTaxis > const *)arg1);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -19227,19 +17436,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiTaxis >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap___len__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap___len__" "', argument " "1"" of type '" "std::map< int,CdiTaxis > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap___len__" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  result = std_map_Sl_int_Sc_CdiTaxis_Sg____len__((std::map< int,CdiTaxis > const *)arg1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = std_map_Sl_int_Sc_CdiTaxis_Sg____len__((std::map<int,CdiTaxis > const *)arg1);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -19249,37 +17458,37 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  std::map< int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis >::mapped_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiTaxis >::key_type temp2 ;
+  std::map<int,CdiTaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiTaxis >::mapped_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap___getitem__" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap___getitem__" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap___getitem__" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap___getitem__" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiTaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiTaxis >::key_type >(val2);
   arg2 = &temp2;
   try {
-    result = (std::map< int,CdiTaxis >::mapped_type *) &std_map_Sl_int_Sc_CdiTaxis_Sg____getitem__(arg1,(int const &)*arg2);
+    result = std_map_Sl_int_Sc_CdiTaxis_Sg____getitem__((std::map<int,CdiTaxis > const *)arg1,(int const &)*arg2);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CdiTaxis, 0 |  0 );
+  resultobj = SWIG_NewPointerObj((new std::map<int,CdiTaxis >::mapped_type(static_cast< const std::map<int,CdiTaxis >::mapped_type& >(result))), SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__mapped_type, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -19288,27 +17497,27 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap___delitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  std::map< int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::key_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiTaxis >::key_type temp2 ;
+  std::map<int,CdiTaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap___delitem__" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap___delitem__" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap___delitem__" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap___delitem__" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiTaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiTaxis >::key_type >(val2);
   arg2 = &temp2;
   try {
     std_map_Sl_int_Sc_CdiTaxis_Sg____delitem__(arg1,(int const &)*arg2);
@@ -19326,30 +17535,30 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap_has_key(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  std::map< int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::key_type *arg2 = 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiTaxis >::key_type temp2 ;
+  std::map<int,CdiTaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap_has_key",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_has_key" "', argument " "1"" of type '" "std::map< int,CdiTaxis > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_has_key" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_has_key" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_has_key" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiTaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiTaxis >::key_type >(val2);
   arg2 = &temp2;
-  result = (bool)std_map_Sl_int_Sc_CdiTaxis_Sg__has_key((std::map< int,CdiTaxis > const *)arg1,(int const &)*arg2);
+  result = (bool)std_map_Sl_int_Sc_CdiTaxis_Sg__has_key((std::map<int,CdiTaxis > const *)arg1,(int const &)*arg2);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -19359,18 +17568,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap_keys(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_keys",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_keys" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_keys" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
   result = (PyObject *)std_map_Sl_int_Sc_CdiTaxis_Sg__keys(arg1);
   resultobj = result;
   return resultobj;
@@ -19381,18 +17590,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap_values(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_values",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_values" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_values" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
   result = (PyObject *)std_map_Sl_int_Sc_CdiTaxis_Sg__values(arg1);
   resultobj = result;
   return resultobj;
@@ -19403,18 +17612,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap_items(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_items",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_items" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_items" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
   result = (PyObject *)std_map_Sl_int_Sc_CdiTaxis_Sg__items(arg1);
   resultobj = result;
   return resultobj;
@@ -19425,28 +17634,28 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap___contains__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  std::map< int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::key_type *arg2 = 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiTaxis >::key_type temp2 ;
+  std::map<int,CdiTaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap___contains__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap___contains__" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap___contains__" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap___contains__" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap___contains__" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiTaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiTaxis >::key_type >(val2);
   arg2 = &temp2;
   result = (bool)std_map_Sl_int_Sc_CdiTaxis_Sg____contains__(arg1,(int const &)*arg2);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
@@ -19458,22 +17667,22 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap_key_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_key_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_key_iterator" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_key_iterator" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_int_Sc_CdiTaxis_Sg__key_iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_int_Sc_CdiTaxis_Sg__key_iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -19482,68 +17691,36 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap_value_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_value_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_value_iterator" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_int_Sc_CdiTaxis_Sg__value_iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_TaxesMap___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  std::map< int,CdiTaxis >::key_type *arg2 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  std::map< int,CdiTaxis >::key_type temp2 ;
-  int val2 ;
-  int ecode2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap___setitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap___setitem__" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_value_iterator" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  ecode2 = SWIG_AsVal_int(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap___setitem__" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::key_type""'");
-  } 
-  temp2 = static_cast< std::map< int,CdiTaxis >::key_type >(val2);
-  arg2 = &temp2;
-  std_map_Sl_int_Sc_CdiTaxis_Sg____setitem____SWIG_0(arg1,(int const &)*arg2);
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_int_Sc_CdiTaxis_Sg__value_iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_TaxesMap___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_TaxesMap___setitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  std::map< int,CdiTaxis >::key_type *arg2 = 0 ;
-  std::map< int,CdiTaxis >::mapped_type *arg3 = 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis >::mapped_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiTaxis >::key_type temp2 ;
+  std::map<int,CdiTaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   void *argp3 = 0 ;
@@ -19553,27 +17730,27 @@ SWIGINTERN PyObject *_wrap_TaxesMap___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:TaxesMap___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap___setitem__" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap___setitem__" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap___setitem__" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap___setitem__" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiTaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiTaxis >::key_type >(val2);
   arg2 = &temp2;
-  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_CdiTaxis,  0  | 0);
+  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__mapped_type,  0  | 0);
   if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "TaxesMap___setitem__" "', argument " "3"" of type '" "std::map< int,CdiTaxis >::mapped_type const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "TaxesMap___setitem__" "', argument " "3"" of type '" "std::map<int,CdiTaxis >::mapped_type const &""'"); 
   }
   if (!argp3) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "TaxesMap___setitem__" "', argument " "3"" of type '" "std::map< int,CdiTaxis >::mapped_type const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "TaxesMap___setitem__" "', argument " "3"" of type '" "std::map<int,CdiTaxis >::mapped_type const &""'"); 
   }
-  arg3 = reinterpret_cast< std::map< int,CdiTaxis >::mapped_type * >(argp3);
+  arg3 = reinterpret_cast< std::map<int,CdiTaxis >::mapped_type * >(argp3);
   try {
-    std_map_Sl_int_Sc_CdiTaxis_Sg____setitem____SWIG_1(arg1,(int const &)*arg2,(CdiTaxis const &)*arg3);
+    std_map_Sl_int_Sc_CdiTaxis_Sg____setitem__(arg1,(int const &)*arg2,(CdiTaxis const &)*arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
@@ -19586,114 +17763,40 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_TaxesMap___setitem__(PyObject *self, PyObject *args) {
-  int argc;
-  PyObject *argv[4];
-  int ii;
-  
-  if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
-    argv[ii] = PyTuple_GET_ITEM(args,ii);
-  }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_int(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_TaxesMap___setitem____SWIG_0(self, args);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_int(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_CdiTaxis, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_TaxesMap___setitem____SWIG_1(self, args);
-        }
-      }
-    }
-  }
-  
-fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'TaxesMap___setitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< int,CdiTaxis >::__setitem__(std::map< int,CdiTaxis >::key_type const &)\n"
-    "    std::map< int,CdiTaxis >::__setitem__(std::map< int,CdiTaxis >::key_type const &,std::map< int,CdiTaxis >::mapped_type const &)\n");
-  return 0;
-}
-
-
-SWIGINTERN PyObject *_wrap_TaxesMap_asdict(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_asdict",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_asdict" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  result = (PyObject *)std_map_Sl_int_Sc_CdiTaxis_Sg__asdict(arg1);
-  resultobj = result;
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_TaxesMap__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_TaxesMap__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *result = 0 ;
+  std::map<int,CdiTaxis > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)":new_TaxesMap")) SWIG_fail;
-  result = (std::map< int,CdiTaxis > *)new std::map< int,CdiTaxis >();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, SWIG_POINTER_NEW |  0 );
+  result = (std::map<int,CdiTaxis > *)new std::map<int,CdiTaxis >();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, SWIG_POINTER_NEW |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_TaxesMap__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_TaxesMap__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = 0 ;
+  std::map<int,CdiTaxis > *arg1 = 0 ;
+  std::map<int,CdiTaxis > *result = 0 ;
   int res1 = SWIG_OLDOBJ ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiTaxis > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:new_TaxesMap",&obj0)) SWIG_fail;
   {
-    std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > > *ptr = (std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > > *)0;
+    std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > > *ptr = (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > > *)0;
     res1 = swig::asptr(obj0, &ptr);
     if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_TaxesMap" "', argument " "1"" of type '" "std::map< int,CdiTaxis > const &""'"); 
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_TaxesMap" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const &""'"); 
     }
     if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_TaxesMap" "', argument " "1"" of type '" "std::map< int,CdiTaxis > const &""'"); 
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_TaxesMap" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const &""'"); 
     }
     arg1 = ptr;
   }
-  result = (std::map< int,CdiTaxis > *)new std::map< int,CdiTaxis >((std::map< int,CdiTaxis > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, SWIG_POINTER_NEW |  0 );
+  result = (std::map<int,CdiTaxis > *)new std::map<int,CdiTaxis >((std::map<int,CdiTaxis > const &)*arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, SWIG_POINTER_NEW |  0 );
   if (SWIG_IsNewObj(res1)) delete arg1;
   return resultobj;
 fail:
@@ -19708,55 +17811,43 @@ SWIGINTERN PyObject *_wrap_new_TaxesMap(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 1) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 0) {
-    return _wrap_new_TaxesMap__SWIG_1(self, args);
-  }
-  if (argc == 1) {
-    int _v;
-    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__lessT_int_t, 0);
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      return _wrap_new_TaxesMap__SWIG_0(self, args);
-    }
+    return _wrap_new_TaxesMap__SWIG_0(self, args);
   }
   if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_new_TaxesMap__SWIG_2(self, args);
+      return _wrap_new_TaxesMap__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_TaxesMap'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< int,CdiTaxis >::map(std::less< int > const &)\n"
-    "    std::map< int,CdiTaxis >::map()\n"
-    "    std::map< int,CdiTaxis >::map(std::map< int,CdiTaxis > const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_TaxesMap'.\n  Possible C/C++ prototypes are:\n    std::map<(int,CdiTaxis)>()\n    std::map<(int,CdiTaxis)>(std::map<int,CdiTaxis > const &)\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_TaxesMap_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_empty",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_empty" "', argument " "1"" of type '" "std::map< int,CdiTaxis > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_empty" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  result = (bool)((std::map< int,CdiTaxis > const *)arg1)->empty();
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = (bool)((std::map<int,CdiTaxis > const *)arg1)->empty();
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -19766,19 +17857,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiTaxis >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_size",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_size" "', argument " "1"" of type '" "std::map< int,CdiTaxis > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_size" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  result = ((std::map< int,CdiTaxis > const *)arg1)->size();
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = ((std::map<int,CdiTaxis > const *)arg1)->size();
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -19788,17 +17879,17 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_clear",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_clear" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_clear" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
   (arg1)->clear();
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -19809,8 +17900,8 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  std::map< int,CdiTaxis > *arg2 = 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -19819,19 +17910,19 @@ SWIGINTERN PyObject *_wrap_TaxesMap_swap(PyObject *SWIGUNUSEDPARM(self), PyObjec
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap_swap",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_swap" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_swap" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t,  0 );
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t,  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TaxesMap_swap" "', argument " "2"" of type '" "std::map< int,CdiTaxis > &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "TaxesMap_swap" "', argument " "2"" of type '" "std::map<int,CdiTaxis > &""'"); 
   }
   if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "TaxesMap_swap" "', argument " "2"" of type '" "std::map< int,CdiTaxis > &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "TaxesMap_swap" "', argument " "2"" of type '" "std::map<int,CdiTaxis > &""'"); 
   }
-  arg2 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp2);
+  arg2 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp2);
   (arg1)->swap(*arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
@@ -19842,144 +17933,368 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  SwigValueWrapper<std::allocator<std::pair<int const,CdiTaxis > > > result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  SwigValueWrapper< std::allocator< std::pair< int const,CdiTaxis > > > result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_get_allocator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_get_allocator" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = ((std::map<int,CdiTaxis > const *)arg1)->get_allocator();
+  resultobj = SWIG_NewPointerObj((new std::map<int,CdiTaxis >::allocator_type(static_cast< const std::map<int,CdiTaxis >::allocator_type& >(result))), SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__allocator_type, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_TaxesMap_begin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_begin" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = (arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiTaxis >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_TaxesMap_begin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_begin" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = ((std::map<int,CdiTaxis > const *)arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiTaxis >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_TaxesMap_begin(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_TaxesMap_begin__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_TaxesMap_begin__SWIG_1(self, args);
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'TaxesMap_begin'.\n  Possible C/C++ prototypes are:\n    begin()\n    begin()\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_TaxesMap_end__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_end" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = (arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiTaxis >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_TaxesMap_end__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_end" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = ((std::map<int,CdiTaxis > const *)arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiTaxis >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_TaxesMap_end(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_TaxesMap_end__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_TaxesMap_end__SWIG_1(self, args);
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'TaxesMap_end'.\n  Possible C/C++ prototypes are:\n    end()\n    end()\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_TaxesMap_rbegin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::reverse_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_get_allocator" "', argument " "1"" of type '" "std::map< int,CdiTaxis > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_rbegin" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  result = ((std::map< int,CdiTaxis > const *)arg1)->get_allocator();
-  resultobj = SWIG_NewPointerObj((new std::map< int,CdiTaxis >::allocator_type(static_cast< const std::map< int,CdiTaxis >::allocator_type& >(result))), SWIGTYPE_p_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = (arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiTaxis >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_TaxesMap_begin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_TaxesMap_rbegin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::const_reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiTaxis >::iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_begin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_begin" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_rbegin" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  result = (arg1)->begin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiTaxis >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = ((std::map<int,CdiTaxis > const *)arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiTaxis >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_TaxesMap_end(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::map< int,CdiTaxis >::iterator result;
+SWIGINTERN PyObject *_wrap_TaxesMap_rbegin(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_end",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_end" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  result = (arg1)->end();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiTaxis >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_TaxesMap_rbegin__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_TaxesMap_rbegin__SWIG_1(self, args);
+    }
+  }
+  
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'TaxesMap_rbegin'.\n  Possible C/C++ prototypes are:\n    rbegin()\n    rbegin()\n");
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_TaxesMap_rbegin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_TaxesMap_rend__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiTaxis >::reverse_iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_rbegin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_rbegin" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_rend" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  result = (arg1)->rbegin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiTaxis >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = (arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiTaxis >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_TaxesMap_rend(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_TaxesMap_rend__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::const_reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiTaxis >::reverse_iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:TaxesMap_rend",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_rend" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_rend" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  result = (arg1)->rend();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiTaxis >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  result = ((std::map<int,CdiTaxis > const *)arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiTaxis >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
+SWIGINTERN PyObject *_wrap_TaxesMap_rend(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_TaxesMap_rend__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_TaxesMap_rend__SWIG_1(self, args);
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'TaxesMap_rend'.\n  Possible C/C++ prototypes are:\n    rend()\n    rend()\n");
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *_wrap_TaxesMap_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  std::map< int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiTaxis >::key_type temp2 ;
+  std::map<int,CdiTaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiTaxis >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_erase" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_erase" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_erase" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_erase" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiTaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiTaxis >::key_type >(val2);
   arg2 = &temp2;
-  result = (arg1)->erase((std::map< int,CdiTaxis >::key_type const &)*arg2);
+  result = (arg1)->erase((std::map<int,CdiTaxis >::key_type const &)*arg2);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -19989,30 +18304,30 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap_count(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  std::map< int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiTaxis >::key_type temp2 ;
+  std::map<int,CdiTaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiTaxis >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap_count",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_count" "', argument " "1"" of type '" "std::map< int,CdiTaxis > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_count" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_count" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_count" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiTaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiTaxis >::key_type >(val2);
   arg2 = &temp2;
-  result = ((std::map< int,CdiTaxis > const *)arg1)->count((std::map< int,CdiTaxis >::key_type const &)*arg2);
+  result = ((std::map<int,CdiTaxis > const *)arg1)->count((std::map<int,CdiTaxis >::key_type const &)*arg2);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -20022,33 +18337,33 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap_erase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  std::map< int,CdiTaxis >::iterator arg2 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::iterator arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_erase" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_erase" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "TaxesMap_erase" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "TaxesMap_erase" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::map< int,CdiTaxis >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiTaxis >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::map<int,CdiTaxis >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiTaxis >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "TaxesMap_erase" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "TaxesMap_erase" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::iterator""'");
     }
   }
-  std_map_Sl_int_Sc_CdiTaxis_Sg__erase__SWIG_1(arg1,arg2);
+  (arg1)->erase(arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -20058,48 +18373,48 @@ fail:
 
 SWIGINTERN PyObject *_wrap_TaxesMap_erase__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  std::map< int,CdiTaxis >::iterator arg2 ;
-  std::map< int,CdiTaxis >::iterator arg3 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::iterator arg2 ;
+  std::map<int,CdiTaxis >::iterator arg3 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
-  swig::SwigPyIterator *iter3 = 0 ;
+  swig::PySwigIterator *iter3 = 0 ;
   int res3 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:TaxesMap_erase",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_erase" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_erase" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "TaxesMap_erase" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "TaxesMap_erase" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::map< int,CdiTaxis >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiTaxis >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::map<int,CdiTaxis >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiTaxis >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "TaxesMap_erase" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "TaxesMap_erase" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::iterator""'");
     }
   }
-  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::SwigPyIterator::descriptor(), 0);
+  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res3) || !iter3) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "TaxesMap_erase" "', argument " "3"" of type '" "std::map< int,CdiTaxis >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "TaxesMap_erase" "', argument " "3"" of type '" "std::map<int,CdiTaxis >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::map< int,CdiTaxis >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiTaxis >::iterator > *>(iter3);
+    swig::PySwigIterator_T<std::map<int,CdiTaxis >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiTaxis >::iterator > *>(iter3);
     if (iter_t) {
       arg3 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "TaxesMap_erase" "', argument " "3"" of type '" "std::map< int,CdiTaxis >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "TaxesMap_erase" "', argument " "3"" of type '" "std::map<int,CdiTaxis >::iterator""'");
     }
   }
-  std_map_Sl_int_Sc_CdiTaxis_Sg__erase__SWIG_2(arg1,arg2,arg3);
+  (arg1)->erase(arg2,arg3);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -20113,18 +18428,18 @@ SWIGINTERN PyObject *_wrap_TaxesMap_erase(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiTaxis >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiTaxis >::iterator > *>(iter) != 0));
       if (_v) {
         return _wrap_TaxesMap_erase__SWIG_1(self, args);
       }
@@ -20132,7 +18447,7 @@ SWIGINTERN PyObject *_wrap_TaxesMap_erase(PyObject *self, PyObject *args) {
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -20146,16 +18461,16 @@ SWIGINTERN PyObject *_wrap_TaxesMap_erase(PyObject *self, PyObject *args) {
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiTaxis >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiTaxis >::iterator > *>(iter) != 0));
       if (_v) {
-        swig::SwigPyIterator *iter = 0;
-        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiTaxis >::iterator > *>(iter) != 0));
+        swig::PySwigIterator *iter = 0;
+        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiTaxis >::iterator > *>(iter) != 0));
         if (_v) {
           return _wrap_TaxesMap_erase__SWIG_2(self, args);
         }
@@ -20164,131 +18479,365 @@ SWIGINTERN PyObject *_wrap_TaxesMap_erase(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'TaxesMap_erase'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< int,CdiTaxis >::erase(std::map< int,CdiTaxis >::key_type const &)\n"
-    "    std::map< int,CdiTaxis >::erase(std::map< int,CdiTaxis >::iterator)\n"
-    "    std::map< int,CdiTaxis >::erase(std::map< int,CdiTaxis >::iterator,std::map< int,CdiTaxis >::iterator)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'TaxesMap_erase'.\n  Possible C/C++ prototypes are:\n    erase(std::map<int,CdiTaxis >::key_type const &)\n    erase(std::map<int,CdiTaxis >::iterator)\n    erase(std::map<int,CdiTaxis >::iterator,std::map<int,CdiTaxis >::iterator)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_TaxesMap_find__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  std::map<int,CdiTaxis >::key_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap_find",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_find" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_find" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiTaxis >::key_type >(val2);
+  arg2 = &temp2;
+  result = (arg1)->find((std::map<int,CdiTaxis >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiTaxis >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_TaxesMap_find(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_TaxesMap_find__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  std::map< int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiTaxis >::key_type temp2 ;
+  std::map<int,CdiTaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiTaxis >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap_find",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_find" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_find" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiTaxis >::key_type >(val2);
+  arg2 = &temp2;
+  result = ((std::map<int,CdiTaxis > const *)arg1)->find((std::map<int,CdiTaxis >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiTaxis >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_TaxesMap_find(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_TaxesMap_find__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_TaxesMap_find__SWIG_1(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'TaxesMap_find'.\n  Possible C/C++ prototypes are:\n    find(std::map<int,CdiTaxis >::key_type const &)\n    find(std::map<int,CdiTaxis >::key_type const &)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_TaxesMap_lower_bound__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  std::map<int,CdiTaxis >::key_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap_lower_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_find" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_lower_bound" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_find" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_lower_bound" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiTaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiTaxis >::key_type >(val2);
   arg2 = &temp2;
-  result = (arg1)->find((std::map< int,CdiTaxis >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiTaxis >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->lower_bound((std::map<int,CdiTaxis >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiTaxis >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_TaxesMap_lower_bound(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_TaxesMap_lower_bound__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  std::map< int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiTaxis >::key_type temp2 ;
+  std::map<int,CdiTaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiTaxis >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap_lower_bound",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_lower_bound" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_lower_bound" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiTaxis >::key_type >(val2);
+  arg2 = &temp2;
+  result = ((std::map<int,CdiTaxis > const *)arg1)->lower_bound((std::map<int,CdiTaxis >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiTaxis >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_TaxesMap_lower_bound(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_TaxesMap_lower_bound__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_TaxesMap_lower_bound__SWIG_1(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'TaxesMap_lower_bound'.\n  Possible C/C++ prototypes are:\n    lower_bound(std::map<int,CdiTaxis >::key_type const &)\n    lower_bound(std::map<int,CdiTaxis >::key_type const &)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_TaxesMap_upper_bound__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  std::map<int,CdiTaxis >::key_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap_upper_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_upper_bound" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_upper_bound" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiTaxis >::key_type >(val2);
+  arg2 = &temp2;
+  result = (arg1)->upper_bound((std::map<int,CdiTaxis >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiTaxis >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_TaxesMap_upper_bound__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiTaxis >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  std::map<int,CdiTaxis >::key_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap_upper_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_lower_bound" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_upper_bound" "', argument " "1"" of type '" "std::map<int,CdiTaxis > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_upper_bound" "', argument " "2"" of type '" "std::map<int,CdiTaxis >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiTaxis >::key_type >(val2);
+  arg2 = &temp2;
+  result = ((std::map<int,CdiTaxis > const *)arg1)->upper_bound((std::map<int,CdiTaxis >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiTaxis >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_TaxesMap_upper_bound(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_TaxesMap_upper_bound__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_TaxesMap_upper_bound__SWIG_1(self, args);
+      }
+    }
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  ecode2 = SWIG_AsVal_int(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_lower_bound" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::key_type""'");
-  } 
-  temp2 = static_cast< std::map< int,CdiTaxis >::key_type >(val2);
-  arg2 = &temp2;
-  result = (arg1)->lower_bound((std::map< int,CdiTaxis >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiTaxis >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_TaxesMap_upper_bound(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
-  std::map< int,CdiTaxis >::key_type *arg2 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  std::map< int,CdiTaxis >::key_type temp2 ;
-  int val2 ;
-  int ecode2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  std::map< int,CdiTaxis >::iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:TaxesMap_upper_bound",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "TaxesMap_upper_bound" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
-  ecode2 = SWIG_AsVal_int(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "TaxesMap_upper_bound" "', argument " "2"" of type '" "std::map< int,CdiTaxis >::key_type""'");
-  } 
-  temp2 = static_cast< std::map< int,CdiTaxis >::key_type >(val2);
-  arg2 = &temp2;
-  result = (arg1)->upper_bound((std::map< int,CdiTaxis >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiTaxis >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'TaxesMap_upper_bound'.\n  Possible C/C++ prototypes are:\n    upper_bound(std::map<int,CdiTaxis >::key_type const &)\n    upper_bound(std::map<int,CdiTaxis >::key_type const &)\n");
   return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_delete_TaxesMap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiTaxis > *arg1 = (std::map< int,CdiTaxis > *) 0 ;
+  std::map<int,CdiTaxis > *arg1 = (std::map<int,CdiTaxis > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:delete_TaxesMap",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, SWIG_POINTER_DISOWN |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_TaxesMap" "', argument " "1"" of type '" "std::map< int,CdiTaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_TaxesMap" "', argument " "1"" of type '" "std::map<int,CdiTaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiTaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiTaxis > * >(argp1);
   delete arg1;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -20298,54 +18847,29 @@ fail:
 
 SWIGINTERN PyObject *TaxesMap_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
-  SWIG_TypeNewClientData(SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, SWIG_NewClientData(obj));
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
 
-SWIGINTERN PyObject *_wrap_new_ZaxesMap__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::less< int > *arg1 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::map< int,CdiZaxis > *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:new_ZaxesMap",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_std__lessT_int_t,  0  | 0);
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ZaxesMap" "', argument " "1"" of type '" "std::less< int > const &""'"); 
-  }
-  if (!argp1) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_ZaxesMap" "', argument " "1"" of type '" "std::less< int > const &""'"); 
-  }
-  arg1 = reinterpret_cast< std::less< int > * >(argp1);
-  result = (std::map< int,CdiZaxis > *)new std::map< int,CdiZaxis >((std::less< int > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, SWIG_POINTER_NEW |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
 SWIGINTERN PyObject *_wrap_ZaxesMap_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_iterator" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_iterator" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_int_Sc_CdiZaxis_Sg__iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_int_Sc_CdiZaxis_Sg__iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -20354,41 +18878,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_ZaxesMap___nonzero__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
   bool result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap___nonzero__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap___nonzero__" "', argument " "1"" of type '" "std::map< int,CdiZaxis > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  result = (bool)std_map_Sl_int_Sc_CdiZaxis_Sg____nonzero__((std::map< int,CdiZaxis > const *)arg1);
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_ZaxesMap___bool__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap___bool__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap___nonzero__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap___bool__" "', argument " "1"" of type '" "std::map< int,CdiZaxis > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap___nonzero__" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  result = (bool)std_map_Sl_int_Sc_CdiZaxis_Sg____bool__((std::map< int,CdiZaxis > const *)arg1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = (bool)std_map_Sl_int_Sc_CdiZaxis_Sg____nonzero__((std::map<int,CdiZaxis > const *)arg1);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -20398,19 +18900,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_ZaxesMap___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiZaxis >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap___len__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap___len__" "', argument " "1"" of type '" "std::map< int,CdiZaxis > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap___len__" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  result = std_map_Sl_int_Sc_CdiZaxis_Sg____len__((std::map< int,CdiZaxis > const *)arg1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = std_map_Sl_int_Sc_CdiZaxis_Sg____len__((std::map<int,CdiZaxis > const *)arg1);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -20420,37 +18922,37 @@ fail:
 
 SWIGINTERN PyObject *_wrap_ZaxesMap___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  std::map< int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis >::mapped_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiZaxis >::key_type temp2 ;
+  std::map<int,CdiZaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiZaxis >::mapped_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap___getitem__" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap___getitem__" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap___getitem__" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap___getitem__" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiZaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiZaxis >::key_type >(val2);
   arg2 = &temp2;
   try {
-    result = (std::map< int,CdiZaxis >::mapped_type *) &std_map_Sl_int_Sc_CdiZaxis_Sg____getitem__(arg1,(int const &)*arg2);
+    result = std_map_Sl_int_Sc_CdiZaxis_Sg____getitem__((std::map<int,CdiZaxis > const *)arg1,(int const &)*arg2);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CdiZaxis, 0 |  0 );
+  resultobj = SWIG_NewPointerObj((new std::map<int,CdiZaxis >::mapped_type(static_cast< const std::map<int,CdiZaxis >::mapped_type& >(result))), SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__mapped_type, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -20459,27 +18961,27 @@ fail:
 
 SWIGINTERN PyObject *_wrap_ZaxesMap___delitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  std::map< int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::key_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiZaxis >::key_type temp2 ;
+  std::map<int,CdiZaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap___delitem__" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap___delitem__" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap___delitem__" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap___delitem__" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiZaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiZaxis >::key_type >(val2);
   arg2 = &temp2;
   try {
     std_map_Sl_int_Sc_CdiZaxis_Sg____delitem__(arg1,(int const &)*arg2);
@@ -20497,30 +18999,30 @@ fail:
 
 SWIGINTERN PyObject *_wrap_ZaxesMap_has_key(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  std::map< int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::key_type *arg2 = 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiZaxis >::key_type temp2 ;
+  std::map<int,CdiZaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap_has_key",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_has_key" "', argument " "1"" of type '" "std::map< int,CdiZaxis > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_has_key" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_has_key" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_has_key" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiZaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiZaxis >::key_type >(val2);
   arg2 = &temp2;
-  result = (bool)std_map_Sl_int_Sc_CdiZaxis_Sg__has_key((std::map< int,CdiZaxis > const *)arg1,(int const &)*arg2);
+  result = (bool)std_map_Sl_int_Sc_CdiZaxis_Sg__has_key((std::map<int,CdiZaxis > const *)arg1,(int const &)*arg2);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -20530,18 +19032,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_ZaxesMap_keys(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_keys",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_keys" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_keys" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
   result = (PyObject *)std_map_Sl_int_Sc_CdiZaxis_Sg__keys(arg1);
   resultobj = result;
   return resultobj;
@@ -20552,18 +19054,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_ZaxesMap_values(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_values",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_values" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_values" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
   result = (PyObject *)std_map_Sl_int_Sc_CdiZaxis_Sg__values(arg1);
   resultobj = result;
   return resultobj;
@@ -20574,18 +19076,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_ZaxesMap_items(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_items",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_items" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_items" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
   result = (PyObject *)std_map_Sl_int_Sc_CdiZaxis_Sg__items(arg1);
   resultobj = result;
   return resultobj;
@@ -20596,28 +19098,28 @@ fail:
 
 SWIGINTERN PyObject *_wrap_ZaxesMap___contains__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  std::map< int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::key_type *arg2 = 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiZaxis >::key_type temp2 ;
+  std::map<int,CdiZaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap___contains__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap___contains__" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap___contains__" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap___contains__" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap___contains__" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiZaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiZaxis >::key_type >(val2);
   arg2 = &temp2;
   result = (bool)std_map_Sl_int_Sc_CdiZaxis_Sg____contains__(arg1,(int const &)*arg2);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
@@ -20629,22 +19131,22 @@ fail:
 
 SWIGINTERN PyObject *_wrap_ZaxesMap_key_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_key_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_key_iterator" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_key_iterator" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_int_Sc_CdiZaxis_Sg__key_iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_int_Sc_CdiZaxis_Sg__key_iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -20653,68 +19155,36 @@ fail:
 
 SWIGINTERN PyObject *_wrap_ZaxesMap_value_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_value_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_value_iterator" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_int_Sc_CdiZaxis_Sg__value_iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_ZaxesMap___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  std::map< int,CdiZaxis >::key_type *arg2 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  std::map< int,CdiZaxis >::key_type temp2 ;
-  int val2 ;
-  int ecode2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap___setitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap___setitem__" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_value_iterator" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  ecode2 = SWIG_AsVal_int(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap___setitem__" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::key_type""'");
-  } 
-  temp2 = static_cast< std::map< int,CdiZaxis >::key_type >(val2);
-  arg2 = &temp2;
-  std_map_Sl_int_Sc_CdiZaxis_Sg____setitem____SWIG_0(arg1,(int const &)*arg2);
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_int_Sc_CdiZaxis_Sg__value_iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_ZaxesMap___setitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  std::map< int,CdiZaxis >::key_type *arg2 = 0 ;
-  std::map< int,CdiZaxis >::mapped_type *arg3 = 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis >::mapped_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiZaxis >::key_type temp2 ;
+  std::map<int,CdiZaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   void *argp3 = 0 ;
@@ -20724,27 +19194,27 @@ SWIGINTERN PyObject *_wrap_ZaxesMap___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:ZaxesMap___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap___setitem__" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap___setitem__" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap___setitem__" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap___setitem__" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiZaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiZaxis >::key_type >(val2);
   arg2 = &temp2;
-  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_CdiZaxis,  0  | 0);
+  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__mapped_type,  0  | 0);
   if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ZaxesMap___setitem__" "', argument " "3"" of type '" "std::map< int,CdiZaxis >::mapped_type const &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "ZaxesMap___setitem__" "', argument " "3"" of type '" "std::map<int,CdiZaxis >::mapped_type const &""'"); 
   }
   if (!argp3) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ZaxesMap___setitem__" "', argument " "3"" of type '" "std::map< int,CdiZaxis >::mapped_type const &""'"); 
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ZaxesMap___setitem__" "', argument " "3"" of type '" "std::map<int,CdiZaxis >::mapped_type const &""'"); 
   }
-  arg3 = reinterpret_cast< std::map< int,CdiZaxis >::mapped_type * >(argp3);
+  arg3 = reinterpret_cast< std::map<int,CdiZaxis >::mapped_type * >(argp3);
   try {
-    std_map_Sl_int_Sc_CdiZaxis_Sg____setitem____SWIG_1(arg1,(int const &)*arg2,(CdiZaxis const &)*arg3);
+    std_map_Sl_int_Sc_CdiZaxis_Sg____setitem__(arg1,(int const &)*arg2,(CdiZaxis const &)*arg3);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
@@ -20757,400 +19227,538 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap___setitem__(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_new_ZaxesMap__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiZaxis > *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)":new_ZaxesMap")) SWIG_fail;
+  result = (std::map<int,CdiZaxis > *)new std::map<int,CdiZaxis >();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_ZaxesMap__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiZaxis > *arg1 = 0 ;
+  std::map<int,CdiZaxis > *result = 0 ;
+  int res1 = SWIG_OLDOBJ ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:new_ZaxesMap",&obj0)) SWIG_fail;
+  {
+    std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > > *ptr = (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > > *)0;
+    res1 = swig::asptr(obj0, &ptr);
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ZaxesMap" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_ZaxesMap" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const &""'"); 
+    }
+    arg1 = ptr;
+  }
+  result = (std::map<int,CdiZaxis > *)new std::map<int,CdiZaxis >((std::map<int,CdiZaxis > const &)*arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, SWIG_POINTER_NEW |  0 );
+  if (SWIG_IsNewObj(res1)) delete arg1;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res1)) delete arg1;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_ZaxesMap(PyObject *self, PyObject *args) {
   int argc;
-  PyObject *argv[4];
+  PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 2) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      {
-        int res = SWIG_AsVal_int(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_ZaxesMap___setitem____SWIG_0(self, args);
-      }
-    }
+  if (argc == 0) {
+    return _wrap_new_ZaxesMap__SWIG_0(self, args);
   }
-  if (argc == 3) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_int(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_CdiZaxis, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_ZaxesMap___setitem____SWIG_1(self, args);
-        }
-      }
+      return _wrap_new_ZaxesMap__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'ZaxesMap___setitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< int,CdiZaxis >::__setitem__(std::map< int,CdiZaxis >::key_type const &)\n"
-    "    std::map< int,CdiZaxis >::__setitem__(std::map< int,CdiZaxis >::key_type const &,std::map< int,CdiZaxis >::mapped_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_ZaxesMap'.\n  Possible C/C++ prototypes are:\n    std::map<(int,CdiZaxis)>()\n    std::map<(int,CdiZaxis)>(std::map<int,CdiZaxis > const &)\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap_asdict(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_ZaxesMap_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_asdict",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_empty",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_asdict" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_empty" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  result = (PyObject *)std_map_Sl_int_Sc_CdiZaxis_Sg__asdict(arg1);
-  resultobj = result;
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = (bool)((std::map<int,CdiZaxis > const *)arg1)->empty();
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_ZaxesMap__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_ZaxesMap_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *result = 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::size_type result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)":new_ZaxesMap")) SWIG_fail;
-  result = (std::map< int,CdiZaxis > *)new std::map< int,CdiZaxis >();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, SWIG_POINTER_NEW |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_size",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_size" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = ((std::map<int,CdiZaxis > const *)arg1)->size();
+  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_ZaxesMap__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_ZaxesMap_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = 0 ;
-  int res1 = SWIG_OLDOBJ ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiZaxis > *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:new_ZaxesMap",&obj0)) SWIG_fail;
-  {
-    std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > > *ptr = (std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > > *)0;
-    res1 = swig::asptr(obj0, &ptr);
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_ZaxesMap" "', argument " "1"" of type '" "std::map< int,CdiZaxis > const &""'"); 
-    }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_ZaxesMap" "', argument " "1"" of type '" "std::map< int,CdiZaxis > const &""'"); 
-    }
-    arg1 = ptr;
+  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_clear",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_clear" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  (arg1)->clear();
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ZaxesMap_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap_swap",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_swap" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t,  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ZaxesMap_swap" "', argument " "2"" of type '" "std::map<int,CdiZaxis > &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ZaxesMap_swap" "', argument " "2"" of type '" "std::map<int,CdiZaxis > &""'"); 
+  }
+  arg2 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp2);
+  (arg1)->swap(*arg2);
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ZaxesMap_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  SwigValueWrapper<std::allocator<std::pair<int const,CdiZaxis > > > result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_get_allocator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_get_allocator" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = ((std::map<int,CdiZaxis > const *)arg1)->get_allocator();
+  resultobj = SWIG_NewPointerObj((new std::map<int,CdiZaxis >::allocator_type(static_cast< const std::map<int,CdiZaxis >::allocator_type& >(result))), SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__allocator_type, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ZaxesMap_begin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_begin" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = (arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiZaxis >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ZaxesMap_begin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_begin" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
   }
-  result = (std::map< int,CdiZaxis > *)new std::map< int,CdiZaxis >((std::map< int,CdiZaxis > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, SWIG_POINTER_NEW |  0 );
-  if (SWIG_IsNewObj(res1)) delete arg1;
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = ((std::map<int,CdiZaxis > const *)arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiZaxis >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
-  if (SWIG_IsNewObj(res1)) delete arg1;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_ZaxesMap(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_ZaxesMap_begin(PyObject *self, PyObject *args) {
   int argc;
   PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 1) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 0) {
-    return _wrap_new_ZaxesMap__SWIG_1(self, args);
-  }
   if (argc == 1) {
     int _v;
-    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__lessT_int_t, 0);
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_new_ZaxesMap__SWIG_0(self, args);
+      return _wrap_ZaxesMap_begin__SWIG_0(self, args);
     }
   }
   if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_new_ZaxesMap__SWIG_2(self, args);
+      return _wrap_ZaxesMap_begin__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_ZaxesMap'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< int,CdiZaxis >::map(std::less< int > const &)\n"
-    "    std::map< int,CdiZaxis >::map()\n"
-    "    std::map< int,CdiZaxis >::map(std::map< int,CdiZaxis > const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'ZaxesMap_begin'.\n  Possible C/C++ prototypes are:\n    begin()\n    begin()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_ZaxesMap_end__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_empty",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_empty" "', argument " "1"" of type '" "std::map< int,CdiZaxis > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_end" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  result = (bool)((std::map< int,CdiZaxis > const *)arg1)->empty();
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = (arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiZaxis >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_ZaxesMap_end__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiZaxis >::size_type result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_size",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_size" "', argument " "1"" of type '" "std::map< int,CdiZaxis > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_end" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  result = ((std::map< int,CdiZaxis > const *)arg1)->size();
-  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = ((std::map<int,CdiZaxis > const *)arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiZaxis >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
+SWIGINTERN PyObject *_wrap_ZaxesMap_end(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_clear",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_clear" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  (arg1)->clear();
-  resultobj = SWIG_Py_Void();
-  return resultobj;
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_ZaxesMap_end__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_ZaxesMap_end__SWIG_1(self, args);
+    }
+  }
+  
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'ZaxesMap_end'.\n  Possible C/C++ prototypes are:\n    end()\n    end()\n");
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_ZaxesMap_rbegin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  std::map< int,CdiZaxis > *arg2 = 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap_swap",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_swap" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t,  0 );
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "ZaxesMap_swap" "', argument " "2"" of type '" "std::map< int,CdiZaxis > &""'"); 
-  }
-  if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "ZaxesMap_swap" "', argument " "2"" of type '" "std::map< int,CdiZaxis > &""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_rbegin" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg2 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp2);
-  (arg1)->swap(*arg2);
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = (arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiZaxis >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_ZaxesMap_rbegin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::const_reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  SwigValueWrapper< std::allocator< std::pair< int const,CdiZaxis > > > result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_get_allocator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_get_allocator" "', argument " "1"" of type '" "std::map< int,CdiZaxis > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_rbegin" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  result = ((std::map< int,CdiZaxis > const *)arg1)->get_allocator();
-  resultobj = SWIG_NewPointerObj((new std::map< int,CdiZaxis >::allocator_type(static_cast< const std::map< int,CdiZaxis >::allocator_type& >(result))), SWIGTYPE_p_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = ((std::map<int,CdiZaxis > const *)arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiZaxis >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap_begin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::map< int,CdiZaxis >::iterator result;
+SWIGINTERN PyObject *_wrap_ZaxesMap_rbegin(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_begin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_begin" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  result = (arg1)->begin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiZaxis >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_ZaxesMap_rbegin__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_ZaxesMap_rbegin__SWIG_1(self, args);
+    }
+  }
+  
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'ZaxesMap_rbegin'.\n  Possible C/C++ prototypes are:\n    rbegin()\n    rbegin()\n");
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap_end(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_ZaxesMap_rend__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiZaxis >::iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_end",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_end" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_rend" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  result = (arg1)->end();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiZaxis >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = (arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiZaxis >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap_rbegin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_ZaxesMap_rend__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::const_reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiZaxis >::reverse_iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_rbegin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_rbegin" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_rend" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  result = (arg1)->rbegin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiZaxis >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  result = ((std::map<int,CdiZaxis > const *)arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiZaxis >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap_rend(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::map< int,CdiZaxis >::reverse_iterator result;
+SWIGINTERN PyObject *_wrap_ZaxesMap_rend(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:ZaxesMap_rend",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_rend" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  result = (arg1)->rend();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiZaxis >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_ZaxesMap_rend__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_ZaxesMap_rend__SWIG_1(self, args);
+    }
+  }
+  
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'ZaxesMap_rend'.\n  Possible C/C++ prototypes are:\n    rend()\n    rend()\n");
   return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_ZaxesMap_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  std::map< int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiZaxis >::key_type temp2 ;
+  std::map<int,CdiZaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiZaxis >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_erase" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_erase" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_erase" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_erase" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiZaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiZaxis >::key_type >(val2);
   arg2 = &temp2;
-  result = (arg1)->erase((std::map< int,CdiZaxis >::key_type const &)*arg2);
+  result = (arg1)->erase((std::map<int,CdiZaxis >::key_type const &)*arg2);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -21160,30 +19768,30 @@ fail:
 
 SWIGINTERN PyObject *_wrap_ZaxesMap_count(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  std::map< int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiZaxis >::key_type temp2 ;
+  std::map<int,CdiZaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiZaxis >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap_count",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_count" "', argument " "1"" of type '" "std::map< int,CdiZaxis > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_count" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_count" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_count" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiZaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiZaxis >::key_type >(val2);
   arg2 = &temp2;
-  result = ((std::map< int,CdiZaxis > const *)arg1)->count((std::map< int,CdiZaxis >::key_type const &)*arg2);
+  result = ((std::map<int,CdiZaxis > const *)arg1)->count((std::map<int,CdiZaxis >::key_type const &)*arg2);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -21193,33 +19801,33 @@ fail:
 
 SWIGINTERN PyObject *_wrap_ZaxesMap_erase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  std::map< int,CdiZaxis >::iterator arg2 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::iterator arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_erase" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_erase" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ZaxesMap_erase" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ZaxesMap_erase" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::map< int,CdiZaxis >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiZaxis >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::map<int,CdiZaxis >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiZaxis >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ZaxesMap_erase" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ZaxesMap_erase" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::iterator""'");
     }
   }
-  std_map_Sl_int_Sc_CdiZaxis_Sg__erase__SWIG_1(arg1,arg2);
+  (arg1)->erase(arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -21229,48 +19837,48 @@ fail:
 
 SWIGINTERN PyObject *_wrap_ZaxesMap_erase__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  std::map< int,CdiZaxis >::iterator arg2 ;
-  std::map< int,CdiZaxis >::iterator arg3 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::iterator arg2 ;
+  std::map<int,CdiZaxis >::iterator arg3 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
   int res2 ;
-  swig::SwigPyIterator *iter3 = 0 ;
+  swig::PySwigIterator *iter3 = 0 ;
   int res3 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:ZaxesMap_erase",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_erase" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_erase" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ZaxesMap_erase" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ZaxesMap_erase" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::map< int,CdiZaxis >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiZaxis >::iterator > *>(iter2);
+    swig::PySwigIterator_T<std::map<int,CdiZaxis >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiZaxis >::iterator > *>(iter2);
     if (iter_t) {
       arg2 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ZaxesMap_erase" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ZaxesMap_erase" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::iterator""'");
     }
   }
-  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::SwigPyIterator::descriptor(), 0);
+  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::PySwigIterator::descriptor(), 0);
   if (!SWIG_IsOK(res3) || !iter3) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ZaxesMap_erase" "', argument " "3"" of type '" "std::map< int,CdiZaxis >::iterator""'");
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ZaxesMap_erase" "', argument " "3"" of type '" "std::map<int,CdiZaxis >::iterator""'");
   } else {
-    swig::SwigPyIterator_T<std::map< int,CdiZaxis >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiZaxis >::iterator > *>(iter3);
+    swig::PySwigIterator_T<std::map<int,CdiZaxis >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiZaxis >::iterator > *>(iter3);
     if (iter_t) {
       arg3 = iter_t->get_current();
     } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ZaxesMap_erase" "', argument " "3"" of type '" "std::map< int,CdiZaxis >::iterator""'");
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "ZaxesMap_erase" "', argument " "3"" of type '" "std::map<int,CdiZaxis >::iterator""'");
     }
   }
-  std_map_Sl_int_Sc_CdiZaxis_Sg__erase__SWIG_2(arg1,arg2,arg3);
+  (arg1)->erase(arg2,arg3);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -21284,18 +19892,18 @@ SWIGINTERN PyObject *_wrap_ZaxesMap_erase(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiZaxis >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiZaxis >::iterator > *>(iter) != 0));
       if (_v) {
         return _wrap_ZaxesMap_erase__SWIG_1(self, args);
       }
@@ -21303,7 +19911,7 @@ SWIGINTERN PyObject *_wrap_ZaxesMap_erase(PyObject *self, PyObject *args) {
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -21317,16 +19925,16 @@ SWIGINTERN PyObject *_wrap_ZaxesMap_erase(PyObject *self, PyObject *args) {
   }
   if (argc == 3) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiZaxis >::iterator > *>(iter) != 0));
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiZaxis >::iterator > *>(iter) != 0));
       if (_v) {
-        swig::SwigPyIterator *iter = 0;
-        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiZaxis >::iterator > *>(iter) != 0));
+        swig::PySwigIterator *iter = 0;
+        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiZaxis >::iterator > *>(iter) != 0));
         if (_v) {
           return _wrap_ZaxesMap_erase__SWIG_2(self, args);
         }
@@ -21335,131 +19943,365 @@ SWIGINTERN PyObject *_wrap_ZaxesMap_erase(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'ZaxesMap_erase'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< int,CdiZaxis >::erase(std::map< int,CdiZaxis >::key_type const &)\n"
-    "    std::map< int,CdiZaxis >::erase(std::map< int,CdiZaxis >::iterator)\n"
-    "    std::map< int,CdiZaxis >::erase(std::map< int,CdiZaxis >::iterator,std::map< int,CdiZaxis >::iterator)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'ZaxesMap_erase'.\n  Possible C/C++ prototypes are:\n    erase(std::map<int,CdiZaxis >::key_type const &)\n    erase(std::map<int,CdiZaxis >::iterator)\n    erase(std::map<int,CdiZaxis >::iterator,std::map<int,CdiZaxis >::iterator)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ZaxesMap_find__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  std::map<int,CdiZaxis >::key_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap_find",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_find" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_find" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiZaxis >::key_type >(val2);
+  arg2 = &temp2;
+  result = (arg1)->find((std::map<int,CdiZaxis >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiZaxis >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap_find(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_ZaxesMap_find__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  std::map< int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiZaxis >::key_type temp2 ;
+  std::map<int,CdiZaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiZaxis >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap_find",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_find" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_find" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiZaxis >::key_type >(val2);
+  arg2 = &temp2;
+  result = ((std::map<int,CdiZaxis > const *)arg1)->find((std::map<int,CdiZaxis >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiZaxis >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ZaxesMap_find(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_ZaxesMap_find__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_ZaxesMap_find__SWIG_1(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'ZaxesMap_find'.\n  Possible C/C++ prototypes are:\n    find(std::map<int,CdiZaxis >::key_type const &)\n    find(std::map<int,CdiZaxis >::key_type const &)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ZaxesMap_lower_bound__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  std::map<int,CdiZaxis >::key_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap_lower_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_lower_bound" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_lower_bound" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiZaxis >::key_type >(val2);
+  arg2 = &temp2;
+  result = (arg1)->lower_bound((std::map<int,CdiZaxis >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiZaxis >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ZaxesMap_lower_bound__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  std::map<int,CdiZaxis >::key_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap_lower_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_find" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_lower_bound" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_find" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_lower_bound" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiZaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiZaxis >::key_type >(val2);
   arg2 = &temp2;
-  result = (arg1)->find((std::map< int,CdiZaxis >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiZaxis >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = ((std::map<int,CdiZaxis > const *)arg1)->lower_bound((std::map<int,CdiZaxis >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiZaxis >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap_lower_bound(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_ZaxesMap_lower_bound(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_ZaxesMap_lower_bound__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_ZaxesMap_lower_bound__SWIG_1(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'ZaxesMap_lower_bound'.\n  Possible C/C++ prototypes are:\n    lower_bound(std::map<int,CdiZaxis >::key_type const &)\n    lower_bound(std::map<int,CdiZaxis >::key_type const &)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_ZaxesMap_upper_bound__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  std::map< int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiZaxis >::key_type temp2 ;
+  std::map<int,CdiZaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiZaxis >::iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap_lower_bound",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap_upper_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_lower_bound" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_upper_bound" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_lower_bound" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_upper_bound" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiZaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiZaxis >::key_type >(val2);
   arg2 = &temp2;
-  result = (arg1)->lower_bound((std::map< int,CdiZaxis >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiZaxis >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->upper_bound((std::map<int,CdiZaxis >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiZaxis >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_ZaxesMap_upper_bound(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_ZaxesMap_upper_bound__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
-  std::map< int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis >::key_type *arg2 = 0 ;
+  std::map<int,CdiZaxis >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiZaxis >::key_type temp2 ;
+  std::map<int,CdiZaxis >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiZaxis >::iterator result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:ZaxesMap_upper_bound",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_upper_bound" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "ZaxesMap_upper_bound" "', argument " "1"" of type '" "std::map<int,CdiZaxis > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_upper_bound" "', argument " "2"" of type '" "std::map< int,CdiZaxis >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "ZaxesMap_upper_bound" "', argument " "2"" of type '" "std::map<int,CdiZaxis >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiZaxis >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiZaxis >::key_type >(val2);
   arg2 = &temp2;
-  result = (arg1)->upper_bound((std::map< int,CdiZaxis >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiZaxis >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = ((std::map<int,CdiZaxis > const *)arg1)->upper_bound((std::map<int,CdiZaxis >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiZaxis >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
+SWIGINTERN PyObject *_wrap_ZaxesMap_upper_bound(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_ZaxesMap_upper_bound__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_ZaxesMap_upper_bound__SWIG_1(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'ZaxesMap_upper_bound'.\n  Possible C/C++ prototypes are:\n    upper_bound(std::map<int,CdiZaxis >::key_type const &)\n    upper_bound(std::map<int,CdiZaxis >::key_type const &)\n");
+  return NULL;
+}
+
+
 SWIGINTERN PyObject *_wrap_delete_ZaxesMap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiZaxis > *arg1 = (std::map< int,CdiZaxis > *) 0 ;
+  std::map<int,CdiZaxis > *arg1 = (std::map<int,CdiZaxis > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:delete_ZaxesMap",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, SWIG_POINTER_DISOWN |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ZaxesMap" "', argument " "1"" of type '" "std::map< int,CdiZaxis > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_ZaxesMap" "', argument " "1"" of type '" "std::map<int,CdiZaxis > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiZaxis > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiZaxis > * >(argp1);
   delete arg1;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -21469,54 +20311,29 @@ fail:
 
 SWIGINTERN PyObject *ZaxesMap_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
-  SWIG_TypeNewClientData(SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, SWIG_NewClientData(obj));
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
 
-SWIGINTERN PyObject *_wrap_new_GridsMap__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::less< int > *arg1 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::map< int,CdiGrid > *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:new_GridsMap",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1, SWIGTYPE_p_std__lessT_int_t,  0  | 0);
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_GridsMap" "', argument " "1"" of type '" "std::less< int > const &""'"); 
-  }
-  if (!argp1) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_GridsMap" "', argument " "1"" of type '" "std::less< int > const &""'"); 
-  }
-  arg1 = reinterpret_cast< std::less< int > * >(argp1);
-  result = (std::map< int,CdiGrid > *)new std::map< int,CdiGrid >((std::less< int > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, SWIG_POINTER_NEW |  0 );
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
 SWIGINTERN PyObject *_wrap_GridsMap_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_iterator" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_iterator" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_int_Sc_CdiGrid_Sg__iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_int_Sc_CdiGrid_Sg__iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -21525,41 +20342,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_GridsMap___nonzero__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
   bool result;
-  
-  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap___nonzero__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap___nonzero__" "', argument " "1"" of type '" "std::map< int,CdiGrid > const *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  result = (bool)std_map_Sl_int_Sc_CdiGrid_Sg____nonzero__((std::map< int,CdiGrid > const *)arg1);
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_GridsMap___bool__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap___bool__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap___nonzero__",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap___bool__" "', argument " "1"" of type '" "std::map< int,CdiGrid > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap___nonzero__" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  result = (bool)std_map_Sl_int_Sc_CdiGrid_Sg____bool__((std::map< int,CdiGrid > const *)arg1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = (bool)std_map_Sl_int_Sc_CdiGrid_Sg____nonzero__((std::map<int,CdiGrid > const *)arg1);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -21569,19 +20364,19 @@ fail:
 
 SWIGINTERN PyObject *_wrap_GridsMap___len__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiGrid >::size_type result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:GridsMap___len__",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap___len__" "', argument " "1"" of type '" "std::map< int,CdiGrid > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap___len__" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  result = std_map_Sl_int_Sc_CdiGrid_Sg____len__((std::map< int,CdiGrid > const *)arg1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = std_map_Sl_int_Sc_CdiGrid_Sg____len__((std::map<int,CdiGrid > const *)arg1);
   resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
@@ -21591,37 +20386,37 @@ fail:
 
 SWIGINTERN PyObject *_wrap_GridsMap___getitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  std::map< int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid >::mapped_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiGrid >::key_type temp2 ;
+  std::map<int,CdiGrid >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiGrid >::mapped_type *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap___getitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap___getitem__" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap___getitem__" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap___getitem__" "', argument " "2"" of type '" "std::map< int,CdiGrid >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap___getitem__" "', argument " "2"" of type '" "std::map<int,CdiGrid >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiGrid >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiGrid >::key_type >(val2);
   arg2 = &temp2;
   try {
-    result = (std::map< int,CdiGrid >::mapped_type *) &std_map_Sl_int_Sc_CdiGrid_Sg____getitem__(arg1,(int const &)*arg2);
+    result = std_map_Sl_int_Sc_CdiGrid_Sg____getitem__((std::map<int,CdiGrid > const *)arg1,(int const &)*arg2);
   }
   catch(std::out_of_range &_e) {
     SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
   }
   
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_CdiGrid, 0 |  0 );
+  resultobj = SWIG_NewPointerObj((new std::map<int,CdiGrid >::mapped_type(static_cast< const std::map<int,CdiGrid >::mapped_type& >(result))), SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__mapped_type, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -21630,27 +20425,27 @@ fail:
 
 SWIGINTERN PyObject *_wrap_GridsMap___delitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  std::map< int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::key_type *arg2 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiGrid >::key_type temp2 ;
+  std::map<int,CdiGrid >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap___delitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap___delitem__" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap___delitem__" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap___delitem__" "', argument " "2"" of type '" "std::map< int,CdiGrid >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap___delitem__" "', argument " "2"" of type '" "std::map<int,CdiGrid >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiGrid >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiGrid >::key_type >(val2);
   arg2 = &temp2;
   try {
     std_map_Sl_int_Sc_CdiGrid_Sg____delitem__(arg1,(int const &)*arg2);
@@ -21668,30 +20463,30 @@ fail:
 
 SWIGINTERN PyObject *_wrap_GridsMap_has_key(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  std::map< int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::key_type *arg2 = 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiGrid >::key_type temp2 ;
+  std::map<int,CdiGrid >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_has_key",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_has_key" "', argument " "1"" of type '" "std::map< int,CdiGrid > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_has_key" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_has_key" "', argument " "2"" of type '" "std::map< int,CdiGrid >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_has_key" "', argument " "2"" of type '" "std::map<int,CdiGrid >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiGrid >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiGrid >::key_type >(val2);
   arg2 = &temp2;
-  result = (bool)std_map_Sl_int_Sc_CdiGrid_Sg__has_key((std::map< int,CdiGrid > const *)arg1,(int const &)*arg2);
+  result = (bool)std_map_Sl_int_Sc_CdiGrid_Sg__has_key((std::map<int,CdiGrid > const *)arg1,(int const &)*arg2);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
   return resultobj;
 fail:
@@ -21701,18 +20496,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_GridsMap_keys(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_keys",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_keys" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_keys" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
   result = (PyObject *)std_map_Sl_int_Sc_CdiGrid_Sg__keys(arg1);
   resultobj = result;
   return resultobj;
@@ -21723,18 +20518,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_GridsMap_values(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_values",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_values" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_values" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
   result = (PyObject *)std_map_Sl_int_Sc_CdiGrid_Sg__values(arg1);
   resultobj = result;
   return resultobj;
@@ -21745,18 +20540,18 @@ fail:
 
 SWIGINTERN PyObject *_wrap_GridsMap_items(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  PyObject *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_items",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_items" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_items" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
   result = (PyObject *)std_map_Sl_int_Sc_CdiGrid_Sg__items(arg1);
   resultobj = result;
   return resultobj;
@@ -21767,28 +20562,28 @@ fail:
 
 SWIGINTERN PyObject *_wrap_GridsMap___contains__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  std::map< int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::key_type *arg2 = 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiGrid >::key_type temp2 ;
+  std::map<int,CdiGrid >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap___contains__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap___contains__" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap___contains__" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap___contains__" "', argument " "2"" of type '" "std::map< int,CdiGrid >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap___contains__" "', argument " "2"" of type '" "std::map<int,CdiGrid >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiGrid >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiGrid >::key_type >(val2);
   arg2 = &temp2;
   result = (bool)std_map_Sl_int_Sc_CdiGrid_Sg____contains__(arg1,(int const &)*arg2);
   resultobj = SWIG_From_bool(static_cast< bool >(result));
@@ -21800,22 +20595,22 @@ fail:
 
 SWIGINTERN PyObject *_wrap_GridsMap_key_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_key_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_key_iterator" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_key_iterator" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_int_Sc_CdiGrid_Sg__key_iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_int_Sc_CdiGrid_Sg__key_iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -21824,53 +20619,239 @@ fail:
 
 SWIGINTERN PyObject *_wrap_GridsMap_value_iterator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
   PyObject **arg2 = (PyObject **) 0 ;
+  swig::PySwigIterator *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  swig::SwigPyIterator *result = 0 ;
   
   arg2 = &obj0;
   if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_value_iterator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_value_iterator" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_value_iterator" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  result = (swig::SwigPyIterator *)std_map_Sl_int_Sc_CdiGrid_Sg__value_iterator(arg1,arg2);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__SwigPyIterator, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = (swig::PySwigIterator *)std_map_Sl_int_Sc_CdiGrid_Sg__value_iterator(arg1,arg2);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_swig__PySwigIterator, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap___setitem____SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap___setitem__(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  std::map< int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid >::mapped_type *arg3 = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiGrid >::key_type temp2 ;
+  std::map<int,CdiGrid >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
+  void *argp3 = 0 ;
+  int res3 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap___setitem__",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OOO:GridsMap___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap___setitem__" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap___setitem__" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap___setitem__" "', argument " "2"" of type '" "std::map< int,CdiGrid >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap___setitem__" "', argument " "2"" of type '" "std::map<int,CdiGrid >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiGrid >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiGrid >::key_type >(val2);
   arg2 = &temp2;
-  std_map_Sl_int_Sc_CdiGrid_Sg____setitem____SWIG_0(arg1,(int const &)*arg2);
+  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__mapped_type,  0  | 0);
+  if (!SWIG_IsOK(res3)) {
+    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "GridsMap___setitem__" "', argument " "3"" of type '" "std::map<int,CdiGrid >::mapped_type const &""'"); 
+  }
+  if (!argp3) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "GridsMap___setitem__" "', argument " "3"" of type '" "std::map<int,CdiGrid >::mapped_type const &""'"); 
+  }
+  arg3 = reinterpret_cast< std::map<int,CdiGrid >::mapped_type * >(argp3);
+  try {
+    std_map_Sl_int_Sc_CdiGrid_Sg____setitem__(arg1,(int const &)*arg2,(CdiGrid const &)*arg3);
+  }
+  catch(std::out_of_range &_e) {
+    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+  }
+  
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_GridsMap__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiGrid > *result = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)":new_GridsMap")) SWIG_fail;
+  result = (std::map<int,CdiGrid > *)new std::map<int,CdiGrid >();
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, SWIG_POINTER_NEW |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_GridsMap__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiGrid > *arg1 = 0 ;
+  std::map<int,CdiGrid > *result = 0 ;
+  int res1 = SWIG_OLDOBJ ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:new_GridsMap",&obj0)) SWIG_fail;
+  {
+    std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > > *ptr = (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > > *)0;
+    res1 = swig::asptr(obj0, &ptr);
+    if (!SWIG_IsOK(res1)) {
+      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_GridsMap" "', argument " "1"" of type '" "std::map<int,CdiGrid > const &""'"); 
+    }
+    if (!ptr) {
+      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_GridsMap" "', argument " "1"" of type '" "std::map<int,CdiGrid > const &""'"); 
+    }
+    arg1 = ptr;
+  }
+  result = (std::map<int,CdiGrid > *)new std::map<int,CdiGrid >((std::map<int,CdiGrid > const &)*arg1);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, SWIG_POINTER_NEW |  0 );
+  if (SWIG_IsNewObj(res1)) delete arg1;
+  return resultobj;
+fail:
+  if (SWIG_IsNewObj(res1)) delete arg1;
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_new_GridsMap(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 0) {
+    return _wrap_new_GridsMap__SWIG_0(self, args);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_new_GridsMap__SWIG_1(self, args);
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_GridsMap'.\n  Possible C/C++ prototypes are:\n    std::map<(int,CdiGrid)>()\n    std::map<(int,CdiGrid)>(std::map<int,CdiGrid > const &)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_GridsMap_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  bool result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_empty",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_empty" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = (bool)((std::map<int,CdiGrid > const *)arg1)->empty();
+  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_GridsMap_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::size_type result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_size",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_size" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = ((std::map<int,CdiGrid > const *)arg1)->size();
+  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_GridsMap_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_clear",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_clear" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  (arg1)->clear();
+  resultobj = SWIG_Py_Void();
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_GridsMap_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg2 = 0 ;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  void *argp2 = 0 ;
+  int res2 = 0 ;
+  PyObject * obj0 = 0 ;
+  PyObject * obj1 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_swap",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_swap" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t,  0 );
+  if (!SWIG_IsOK(res2)) {
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "GridsMap_swap" "', argument " "2"" of type '" "std::map<int,CdiGrid > &""'"); 
+  }
+  if (!argp2) {
+    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "GridsMap_swap" "', argument " "2"" of type '" "std::map<int,CdiGrid > &""'"); 
+  }
+  arg2 = reinterpret_cast< std::map<int,CdiGrid > * >(argp2);
+  (arg1)->swap(*arg2);
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -21878,603 +20859,767 @@ fail:
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap___setitem____SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  SwigValueWrapper<std::allocator<std::pair<int const,CdiGrid > > > result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_get_allocator",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_get_allocator" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = ((std::map<int,CdiGrid > const *)arg1)->get_allocator();
+  resultobj = SWIG_NewPointerObj((new std::map<int,CdiGrid >::allocator_type(static_cast< const std::map<int,CdiGrid >::allocator_type& >(result))), SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__allocator_type, SWIG_POINTER_OWN |  0 );
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_GridsMap_begin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+  PyObject *resultobj = 0;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
+  PyObject * obj0 = 0 ;
+  
+  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_begin" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
+  }
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = (arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiGrid >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_GridsMap_begin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  std::map< int,CdiGrid >::key_type *arg2 = 0 ;
-  std::map< int,CdiGrid >::mapped_type *arg3 = 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiGrid >::key_type temp2 ;
-  int val2 ;
-  int ecode2 = 0 ;
-  void *argp3 = 0 ;
-  int res3 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:GridsMap___setitem__",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_begin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap___setitem__" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  ecode2 = SWIG_AsVal_int(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap___setitem__" "', argument " "2"" of type '" "std::map< int,CdiGrid >::key_type""'");
-  } 
-  temp2 = static_cast< std::map< int,CdiGrid >::key_type >(val2);
-  arg2 = &temp2;
-  res3 = SWIG_ConvertPtr(obj2, &argp3, SWIGTYPE_p_CdiGrid,  0  | 0);
-  if (!SWIG_IsOK(res3)) {
-    SWIG_exception_fail(SWIG_ArgError(res3), "in method '" "GridsMap___setitem__" "', argument " "3"" of type '" "std::map< int,CdiGrid >::mapped_type const &""'"); 
-  }
-  if (!argp3) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "GridsMap___setitem__" "', argument " "3"" of type '" "std::map< int,CdiGrid >::mapped_type const &""'"); 
-  }
-  arg3 = reinterpret_cast< std::map< int,CdiGrid >::mapped_type * >(argp3);
-  try {
-    std_map_Sl_int_Sc_CdiGrid_Sg____setitem____SWIG_1(arg1,(int const &)*arg2,(CdiGrid const &)*arg3);
-  }
-  catch(std::out_of_range &_e) {
-    SWIG_exception_fail(SWIG_IndexError, (&_e)->what());
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_begin" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
   }
-  
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = ((std::map<int,CdiGrid > const *)arg1)->begin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiGrid >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap___setitem__(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_begin(PyObject *self, PyObject *args) {
   int argc;
-  PyObject *argv[4];
+  PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 2) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_int(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        return _wrap_GridsMap___setitem____SWIG_0(self, args);
-      }
+      return _wrap_GridsMap_begin__SWIG_0(self, args);
     }
   }
-  if (argc == 3) {
+  if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      {
-        int res = SWIG_AsVal_int(argv[1], NULL);
-        _v = SWIG_CheckState(res);
-      }
-      if (_v) {
-        int res = SWIG_ConvertPtr(argv[2], 0, SWIGTYPE_p_CdiGrid, 0);
-        _v = SWIG_CheckState(res);
-        if (_v) {
-          return _wrap_GridsMap___setitem____SWIG_1(self, args);
-        }
-      }
+      return _wrap_GridsMap_begin__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'GridsMap___setitem__'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< int,CdiGrid >::__setitem__(std::map< int,CdiGrid >::key_type const &)\n"
-    "    std::map< int,CdiGrid >::__setitem__(std::map< int,CdiGrid >::key_type const &,std::map< int,CdiGrid >::mapped_type const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'GridsMap_begin'.\n  Possible C/C++ prototypes are:\n    begin()\n    begin()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_asdict(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_end__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_asdict",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_asdict" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_end" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  result = (PyObject *)std_map_Sl_int_Sc_CdiGrid_Sg__asdict(arg1);
-  resultobj = result;
-  return resultobj;
-fail:
-  return NULL;
-}
-
-
-SWIGINTERN PyObject *_wrap_new_GridsMap__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *result = 0 ;
-  
-  if (!PyArg_ParseTuple(args,(char *)":new_GridsMap")) SWIG_fail;
-  result = (std::map< int,CdiGrid > *)new std::map< int,CdiGrid >();
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, SWIG_POINTER_NEW |  0 );
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = (arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiGrid >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_GridsMap__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_end__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = 0 ;
-  int res1 = SWIG_OLDOBJ ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::const_iterator result;
+  void *argp1 = 0 ;
+  int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiGrid > *result = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:new_GridsMap",&obj0)) SWIG_fail;
-  {
-    std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > > *ptr = (std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > > *)0;
-    res1 = swig::asptr(obj0, &ptr);
-    if (!SWIG_IsOK(res1)) {
-      SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "new_GridsMap" "', argument " "1"" of type '" "std::map< int,CdiGrid > const &""'"); 
-    }
-    if (!ptr) {
-      SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "new_GridsMap" "', argument " "1"" of type '" "std::map< int,CdiGrid > const &""'"); 
-    }
-    arg1 = ptr;
+  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_end",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!SWIG_IsOK(res1)) {
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_end" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
   }
-  result = (std::map< int,CdiGrid > *)new std::map< int,CdiGrid >((std::map< int,CdiGrid > const &)*arg1);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, SWIG_POINTER_NEW |  0 );
-  if (SWIG_IsNewObj(res1)) delete arg1;
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = ((std::map<int,CdiGrid > const *)arg1)->end();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiGrid >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
-  if (SWIG_IsNewObj(res1)) delete arg1;
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_new_GridsMap(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_end(PyObject *self, PyObject *args) {
   int argc;
   PyObject *argv[2];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 1) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (argc == 0) {
-    return _wrap_new_GridsMap__SWIG_1(self, args);
-  }
   if (argc == 1) {
     int _v;
-    int res = SWIG_ConvertPtr(argv[0], 0, SWIGTYPE_p_std__lessT_int_t, 0);
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_new_GridsMap__SWIG_0(self, args);
+      return _wrap_GridsMap_end__SWIG_0(self, args);
     }
   }
   if (argc == 1) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      return _wrap_new_GridsMap__SWIG_2(self, args);
+      return _wrap_GridsMap_end__SWIG_1(self, args);
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_GridsMap'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< int,CdiGrid >::map(std::less< int > const &)\n"
-    "    std::map< int,CdiGrid >::map()\n"
-    "    std::map< int,CdiGrid >::map(std::map< int,CdiGrid > const &)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'GridsMap_end'.\n  Possible C/C++ prototypes are:\n    end()\n    end()\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_empty(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_rbegin__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_empty",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_empty" "', argument " "1"" of type '" "std::map< int,CdiGrid > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_rbegin" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  result = (bool)((std::map< int,CdiGrid > const *)arg1)->empty();
-  resultobj = SWIG_From_bool(static_cast< bool >(result));
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = (arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiGrid >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_size(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_rbegin__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::const_reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiGrid >::size_type result;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_size",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_rbegin",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_size" "', argument " "1"" of type '" "std::map< int,CdiGrid > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_rbegin" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  result = ((std::map< int,CdiGrid > const *)arg1)->size();
-  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = ((std::map<int,CdiGrid > const *)arg1)->rbegin();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiGrid >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_clear(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_rbegin(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_GridsMap_rbegin__SWIG_0(self, args);
+    }
+  }
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_GridsMap_rbegin__SWIG_1(self, args);
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'GridsMap_rbegin'.\n  Possible C/C++ prototypes are:\n    rbegin()\n    rbegin()\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_GridsMap_rend__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_clear",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_clear" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_rend" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  (arg1)->clear();
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = (arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiGrid >::reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_swap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_rend__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  std::map< int,CdiGrid > *arg2 = 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::const_reverse_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  void *argp2 = 0 ;
-  int res2 = 0 ;
   PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_swap",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_rend",&obj0)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_swap" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_rend" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2, SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t,  0 );
-  if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "GridsMap_swap" "', argument " "2"" of type '" "std::map< int,CdiGrid > &""'"); 
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  result = ((std::map<int,CdiGrid > const *)arg1)->rend();
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiGrid >::const_reverse_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
+  return resultobj;
+fail:
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_GridsMap_rend(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[2];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  if (!argp2) {
-    SWIG_exception_fail(SWIG_ValueError, "invalid null reference " "in method '" "GridsMap_swap" "', argument " "2"" of type '" "std::map< int,CdiGrid > &""'"); 
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_GridsMap_rend__SWIG_0(self, args);
+    }
   }
-  arg2 = reinterpret_cast< std::map< int,CdiGrid > * >(argp2);
-  (arg1)->swap(*arg2);
-  resultobj = SWIG_Py_Void();
-  return resultobj;
+  if (argc == 1) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      return _wrap_GridsMap_rend__SWIG_1(self, args);
+    }
+  }
+  
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'GridsMap_rend'.\n  Possible C/C++ prototypes are:\n    rend()\n    rend()\n");
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_get_allocator(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  std::map<int,CdiGrid >::key_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
-  SwigValueWrapper< std::allocator< std::pair< int const,CdiGrid > > > result;
+  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_get_allocator",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_erase",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_get_allocator" "', argument " "1"" of type '" "std::map< int,CdiGrid > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_erase" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  result = ((std::map< int,CdiGrid > const *)arg1)->get_allocator();
-  resultobj = SWIG_NewPointerObj((new std::map< int,CdiGrid >::allocator_type(static_cast< const std::map< int,CdiGrid >::allocator_type& >(result))), SWIGTYPE_p_std__allocatorT_std__pairT_int_const_CdiGrid_t_t, SWIG_POINTER_OWN |  0 );
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_erase" "', argument " "2"" of type '" "std::map<int,CdiGrid >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiGrid >::key_type >(val2);
+  arg2 = &temp2;
+  result = (arg1)->erase((std::map<int,CdiGrid >::key_type const &)*arg2);
+  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_begin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_count(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid >::size_type result;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  std::map<int,CdiGrid >::key_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiGrid >::iterator result;
+  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_begin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_count",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_begin" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_count" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  result = (arg1)->begin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiGrid >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_count" "', argument " "2"" of type '" "std::map<int,CdiGrid >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiGrid >::key_type >(val2);
+  arg2 = &temp2;
+  result = ((std::map<int,CdiGrid > const *)arg1)->count((std::map<int,CdiGrid >::key_type const &)*arg2);
+  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_end(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_erase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::iterator arg2 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
+  int res2 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiGrid >::iterator result;
+  PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_end",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_erase",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_end" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_erase" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  result = (arg1)->end();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiGrid >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res2) || !iter2) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "GridsMap_erase" "', argument " "2"" of type '" "std::map<int,CdiGrid >::iterator""'");
+  } else {
+    swig::PySwigIterator_T<std::map<int,CdiGrid >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiGrid >::iterator > *>(iter2);
+    if (iter_t) {
+      arg2 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "GridsMap_erase" "', argument " "2"" of type '" "std::map<int,CdiGrid >::iterator""'");
+    }
+  }
+  (arg1)->erase(arg2);
+  resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_rbegin(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_erase__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::iterator arg2 ;
+  std::map<int,CdiGrid >::iterator arg3 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
+  swig::PySwigIterator *iter2 = 0 ;
+  int res2 ;
+  swig::PySwigIterator *iter3 = 0 ;
+  int res3 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiGrid >::reverse_iterator result;
+  PyObject * obj1 = 0 ;
+  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_rbegin",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OOO:GridsMap_erase",&obj0,&obj1,&obj2)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_rbegin" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_erase" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  result = (arg1)->rbegin();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiGrid >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::PySwigIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res2) || !iter2) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "GridsMap_erase" "', argument " "2"" of type '" "std::map<int,CdiGrid >::iterator""'");
+  } else {
+    swig::PySwigIterator_T<std::map<int,CdiGrid >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiGrid >::iterator > *>(iter2);
+    if (iter_t) {
+      arg2 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "GridsMap_erase" "', argument " "2"" of type '" "std::map<int,CdiGrid >::iterator""'");
+    }
+  }
+  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::PySwigIterator::descriptor(), 0);
+  if (!SWIG_IsOK(res3) || !iter3) {
+    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "GridsMap_erase" "', argument " "3"" of type '" "std::map<int,CdiGrid >::iterator""'");
+  } else {
+    swig::PySwigIterator_T<std::map<int,CdiGrid >::iterator > *iter_t = dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiGrid >::iterator > *>(iter3);
+    if (iter_t) {
+      arg3 = iter_t->get_current();
+    } else {
+      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "GridsMap_erase" "', argument " "3"" of type '" "std::map<int,CdiGrid >::iterator""'");
+    }
+  }
+  (arg1)->erase(arg2,arg3);
+  resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_rend(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  PyObject * obj0 = 0 ;
-  std::map< int,CdiGrid >::reverse_iterator result;
+SWIGINTERN PyObject *_wrap_GridsMap_erase(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[4];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"O:GridsMap_rend",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_rend" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiGrid >::iterator > *>(iter) != 0));
+      if (_v) {
+        return _wrap_GridsMap_erase__SWIG_1(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_GridsMap_erase__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 3) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      swig::PySwigIterator *iter = 0;
+      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiGrid >::iterator > *>(iter) != 0));
+      if (_v) {
+        swig::PySwigIterator *iter = 0;
+        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::PySwigIterator::descriptor(), 0);
+        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::PySwigIterator_T<std::map<int,CdiGrid >::iterator > *>(iter) != 0));
+        if (_v) {
+          return _wrap_GridsMap_erase__SWIG_2(self, args);
+        }
+      }
+    }
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  result = (arg1)->rend();
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiGrid >::reverse_iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
+  
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'GridsMap_erase'.\n  Possible C/C++ prototypes are:\n    erase(std::map<int,CdiGrid >::key_type const &)\n    erase(std::map<int,CdiGrid >::iterator)\n    erase(std::map<int,CdiGrid >::iterator,std::map<int,CdiGrid >::iterator)\n");
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_erase__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_find__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  std::map< int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiGrid >::key_type temp2 ;
+  std::map<int,CdiGrid >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiGrid >::size_type result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_find",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_erase" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_find" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_erase" "', argument " "2"" of type '" "std::map< int,CdiGrid >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_find" "', argument " "2"" of type '" "std::map<int,CdiGrid >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiGrid >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiGrid >::key_type >(val2);
   arg2 = &temp2;
-  result = (arg1)->erase((std::map< int,CdiGrid >::key_type const &)*arg2);
-  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  result = (arg1)->find((std::map<int,CdiGrid >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiGrid >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_count(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_find__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  std::map< int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiGrid >::key_type temp2 ;
+  std::map<int,CdiGrid >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiGrid >::size_type result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_count",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_find",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_count" "', argument " "1"" of type '" "std::map< int,CdiGrid > const *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_find" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_count" "', argument " "2"" of type '" "std::map< int,CdiGrid >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_find" "', argument " "2"" of type '" "std::map<int,CdiGrid >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiGrid >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiGrid >::key_type >(val2);
   arg2 = &temp2;
-  result = ((std::map< int,CdiGrid > const *)arg1)->count((std::map< int,CdiGrid >::key_type const &)*arg2);
-  resultobj = SWIG_From_size_t(static_cast< size_t >(result));
+  result = ((std::map<int,CdiGrid > const *)arg1)->find((std::map<int,CdiGrid >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiGrid >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_erase__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_find(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
+  
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_GridsMap_find__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_GridsMap_find__SWIG_1(self, args);
+      }
+    }
+  }
+  
+fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'GridsMap_find'.\n  Possible C/C++ prototypes are:\n    find(std::map<int,CdiGrid >::key_type const &)\n    find(std::map<int,CdiGrid >::key_type const &)\n");
+  return NULL;
+}
+
+
+SWIGINTERN PyObject *_wrap_GridsMap_lower_bound__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  std::map< int,CdiGrid >::iterator arg2 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
-  int res2 ;
+  std::map<int,CdiGrid >::key_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_erase",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_lower_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_erase" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_lower_bound" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
-  if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "GridsMap_erase" "', argument " "2"" of type '" "std::map< int,CdiGrid >::iterator""'");
-  } else {
-    swig::SwigPyIterator_T<std::map< int,CdiGrid >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiGrid >::iterator > *>(iter2);
-    if (iter_t) {
-      arg2 = iter_t->get_current();
-    } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "GridsMap_erase" "', argument " "2"" of type '" "std::map< int,CdiGrid >::iterator""'");
-    }
-  }
-  std_map_Sl_int_Sc_CdiGrid_Sg__erase__SWIG_1(arg1,arg2);
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_lower_bound" "', argument " "2"" of type '" "std::map<int,CdiGrid >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiGrid >::key_type >(val2);
+  arg2 = &temp2;
+  result = (arg1)->lower_bound((std::map<int,CdiGrid >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiGrid >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_erase__SWIG_2(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_lower_bound__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  std::map< int,CdiGrid >::iterator arg2 ;
-  std::map< int,CdiGrid >::iterator arg3 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  swig::SwigPyIterator *iter2 = 0 ;
-  int res2 ;
-  swig::SwigPyIterator *iter3 = 0 ;
-  int res3 ;
+  std::map<int,CdiGrid >::key_type temp2 ;
+  int val2 ;
+  int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  PyObject * obj2 = 0 ;
   
-  if (!PyArg_ParseTuple(args,(char *)"OOO:GridsMap_erase",&obj0,&obj1,&obj2)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_lower_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_erase" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
-  }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, SWIG_as_voidptrptr(&iter2), swig::SwigPyIterator::descriptor(), 0);
-  if (!SWIG_IsOK(res2) || !iter2) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "GridsMap_erase" "', argument " "2"" of type '" "std::map< int,CdiGrid >::iterator""'");
-  } else {
-    swig::SwigPyIterator_T<std::map< int,CdiGrid >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiGrid >::iterator > *>(iter2);
-    if (iter_t) {
-      arg2 = iter_t->get_current();
-    } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "GridsMap_erase" "', argument " "2"" of type '" "std::map< int,CdiGrid >::iterator""'");
-    }
-  }
-  res3 = SWIG_ConvertPtr(obj2, SWIG_as_voidptrptr(&iter3), swig::SwigPyIterator::descriptor(), 0);
-  if (!SWIG_IsOK(res3) || !iter3) {
-    SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "GridsMap_erase" "', argument " "3"" of type '" "std::map< int,CdiGrid >::iterator""'");
-  } else {
-    swig::SwigPyIterator_T<std::map< int,CdiGrid >::iterator > *iter_t = dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiGrid >::iterator > *>(iter3);
-    if (iter_t) {
-      arg3 = iter_t->get_current();
-    } else {
-      SWIG_exception_fail(SWIG_ArgError(SWIG_TypeError), "in method '" "GridsMap_erase" "', argument " "3"" of type '" "std::map< int,CdiGrid >::iterator""'");
-    }
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_lower_bound" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
   }
-  std_map_Sl_int_Sc_CdiGrid_Sg__erase__SWIG_2(arg1,arg2,arg3);
-  resultobj = SWIG_Py_Void();
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
+  ecode2 = SWIG_AsVal_int(obj1, &val2);
+  if (!SWIG_IsOK(ecode2)) {
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_lower_bound" "', argument " "2"" of type '" "std::map<int,CdiGrid >::key_type""'");
+  } 
+  temp2 = static_cast< std::map<int,CdiGrid >::key_type >(val2);
+  arg2 = &temp2;
+  result = ((std::map<int,CdiGrid > const *)arg1)->lower_bound((std::map<int,CdiGrid >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiGrid >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_erase(PyObject *self, PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_lower_bound(PyObject *self, PyObject *args) {
   int argc;
-  PyObject *argv[4];
+  PyObject *argv[3];
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiGrid >::iterator > *>(iter) != 0));
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
       if (_v) {
-        return _wrap_GridsMap_erase__SWIG_1(self, args);
+        return _wrap_GridsMap_lower_bound__SWIG_0(self, args);
       }
     }
   }
   if (argc == 2) {
     int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >**)(0));
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
     _v = SWIG_CheckState(res);
     if (_v) {
       {
@@ -22482,155 +21627,145 @@ SWIGINTERN PyObject *_wrap_GridsMap_erase(PyObject *self, PyObject *args) {
         _v = SWIG_CheckState(res);
       }
       if (_v) {
-        return _wrap_GridsMap_erase__SWIG_0(self, args);
-      }
-    }
-  }
-  if (argc == 3) {
-    int _v;
-    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > >**)(0));
-    _v = SWIG_CheckState(res);
-    if (_v) {
-      swig::SwigPyIterator *iter = 0;
-      int res = SWIG_ConvertPtr(argv[1], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-      _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiGrid >::iterator > *>(iter) != 0));
-      if (_v) {
-        swig::SwigPyIterator *iter = 0;
-        int res = SWIG_ConvertPtr(argv[2], SWIG_as_voidptrptr(&iter), swig::SwigPyIterator::descriptor(), 0);
-        _v = (SWIG_IsOK(res) && iter && (dynamic_cast<swig::SwigPyIterator_T<std::map< int,CdiGrid >::iterator > *>(iter) != 0));
-        if (_v) {
-          return _wrap_GridsMap_erase__SWIG_2(self, args);
-        }
+        return _wrap_GridsMap_lower_bound__SWIG_1(self, args);
       }
     }
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'GridsMap_erase'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    std::map< int,CdiGrid >::erase(std::map< int,CdiGrid >::key_type const &)\n"
-    "    std::map< int,CdiGrid >::erase(std::map< int,CdiGrid >::iterator)\n"
-    "    std::map< int,CdiGrid >::erase(std::map< int,CdiGrid >::iterator,std::map< int,CdiGrid >::iterator)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'GridsMap_lower_bound'.\n  Possible C/C++ prototypes are:\n    lower_bound(std::map<int,CdiGrid >::key_type const &)\n    lower_bound(std::map<int,CdiGrid >::key_type const &)\n");
+  return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_find(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_upper_bound__SWIG_0(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  std::map< int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid >::iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiGrid >::key_type temp2 ;
+  std::map<int,CdiGrid >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiGrid >::iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_find",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_upper_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_find" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_upper_bound" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_find" "', argument " "2"" of type '" "std::map< int,CdiGrid >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_upper_bound" "', argument " "2"" of type '" "std::map<int,CdiGrid >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiGrid >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiGrid >::key_type >(val2);
   arg2 = &temp2;
-  result = (arg1)->find((std::map< int,CdiGrid >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiGrid >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = (arg1)->upper_bound((std::map<int,CdiGrid >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiGrid >::iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_lower_bound(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
+SWIGINTERN PyObject *_wrap_GridsMap_upper_bound__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  std::map< int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid >::key_type *arg2 = 0 ;
+  std::map<int,CdiGrid >::const_iterator result;
   void *argp1 = 0 ;
   int res1 = 0 ;
-  std::map< int,CdiGrid >::key_type temp2 ;
+  std::map<int,CdiGrid >::key_type temp2 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  std::map< int,CdiGrid >::iterator result;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_lower_bound",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_upper_bound",&obj0,&obj1)) SWIG_fail;
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_lower_bound" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_upper_bound" "', argument " "1"" of type '" "std::map<int,CdiGrid > const *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
   ecode2 = SWIG_AsVal_int(obj1, &val2);
   if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_lower_bound" "', argument " "2"" of type '" "std::map< int,CdiGrid >::key_type""'");
+    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_upper_bound" "', argument " "2"" of type '" "std::map<int,CdiGrid >::key_type""'");
   } 
-  temp2 = static_cast< std::map< int,CdiGrid >::key_type >(val2);
+  temp2 = static_cast< std::map<int,CdiGrid >::key_type >(val2);
   arg2 = &temp2;
-  result = (arg1)->lower_bound((std::map< int,CdiGrid >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiGrid >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
+  result = ((std::map<int,CdiGrid > const *)arg1)->upper_bound((std::map<int,CdiGrid >::key_type const &)*arg2);
+  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map<int,CdiGrid >::const_iterator & >(result)),
+    swig::PySwigIterator::descriptor(),SWIG_POINTER_OWN);
   return resultobj;
 fail:
   return NULL;
 }
 
 
-SWIGINTERN PyObject *_wrap_GridsMap_upper_bound(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
-  PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
-  std::map< int,CdiGrid >::key_type *arg2 = 0 ;
-  void *argp1 = 0 ;
-  int res1 = 0 ;
-  std::map< int,CdiGrid >::key_type temp2 ;
-  int val2 ;
-  int ecode2 = 0 ;
-  PyObject * obj0 = 0 ;
-  PyObject * obj1 = 0 ;
-  std::map< int,CdiGrid >::iterator result;
+SWIGINTERN PyObject *_wrap_GridsMap_upper_bound(PyObject *self, PyObject *args) {
+  int argc;
+  PyObject *argv[3];
+  int ii;
   
-  if (!PyArg_ParseTuple(args,(char *)"OO:GridsMap_upper_bound",&obj0,&obj1)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
-  if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "GridsMap_upper_bound" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+  if (!PyTuple_Check(args)) SWIG_fail;
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
+    argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
-  ecode2 = SWIG_AsVal_int(obj1, &val2);
-  if (!SWIG_IsOK(ecode2)) {
-    SWIG_exception_fail(SWIG_ArgError(ecode2), "in method '" "GridsMap_upper_bound" "', argument " "2"" of type '" "std::map< int,CdiGrid >::key_type""'");
-  } 
-  temp2 = static_cast< std::map< int,CdiGrid >::key_type >(val2);
-  arg2 = &temp2;
-  result = (arg1)->upper_bound((std::map< int,CdiGrid >::key_type const &)*arg2);
-  resultobj = SWIG_NewPointerObj(swig::make_output_iterator(static_cast< const std::map< int,CdiGrid >::iterator & >(result)),
-    swig::SwigPyIterator::descriptor(),SWIG_POINTER_OWN);
-  return resultobj;
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_GridsMap_upper_bound__SWIG_0(self, args);
+      }
+    }
+  }
+  if (argc == 2) {
+    int _v;
+    int res = swig::asptr(argv[0], (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > >**)(0));
+    _v = SWIG_CheckState(res);
+    if (_v) {
+      {
+        int res = SWIG_AsVal_int(argv[1], NULL);
+        _v = SWIG_CheckState(res);
+      }
+      if (_v) {
+        return _wrap_GridsMap_upper_bound__SWIG_1(self, args);
+      }
+    }
+  }
+  
 fail:
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'GridsMap_upper_bound'.\n  Possible C/C++ prototypes are:\n    upper_bound(std::map<int,CdiGrid >::key_type const &)\n    upper_bound(std::map<int,CdiGrid >::key_type const &)\n");
   return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_delete_GridsMap(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
-  std::map< int,CdiGrid > *arg1 = (std::map< int,CdiGrid > *) 0 ;
+  std::map<int,CdiGrid > *arg1 = (std::map<int,CdiGrid > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:delete_GridsMap",&obj0)) SWIG_fail;
-  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, SWIG_POINTER_DISOWN |  0 );
+  res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, SWIG_POINTER_DISOWN |  0 );
   if (!SWIG_IsOK(res1)) {
-    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_GridsMap" "', argument " "1"" of type '" "std::map< int,CdiGrid > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "delete_GridsMap" "', argument " "1"" of type '" "std::map<int,CdiGrid > *""'"); 
   }
-  arg1 = reinterpret_cast< std::map< int,CdiGrid > * >(argp1);
+  arg1 = reinterpret_cast< std::map<int,CdiGrid > * >(argp1);
   delete arg1;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -22640,8 +21775,8 @@ fail:
 
 SWIGINTERN PyObject *GridsMap_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
-  SWIG_TypeNewClientData(SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, SWIG_NewClientData(obj));
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
+  SWIG_TypeNewClientData(SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
 
@@ -22661,10 +21796,10 @@ fail:
 SWIGINTERN PyObject *_wrap_new_CdiGrid__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   int arg1 ;
+  CdiGrid *result = 0 ;
   int val1 ;
   int ecode1 = 0 ;
   PyObject * obj0 = 0 ;
-  CdiGrid *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:new_CdiGrid",&obj0)) SWIG_fail;
   ecode1 = SWIG_AsVal_int(obj0, &val1);
@@ -22686,8 +21821,8 @@ SWIGINTERN PyObject *_wrap_new_CdiGrid(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 1) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 0) {
@@ -22705,11 +21840,8 @@ SWIGINTERN PyObject *_wrap_new_CdiGrid(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_CdiGrid'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    CdiGrid::CdiGrid()\n"
-    "    CdiGrid::CdiGrid(int)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_CdiGrid'.\n  Possible C/C++ prototypes are:\n    CdiGrid()\n    CdiGrid(int)\n");
+  return NULL;
 }
 
 
@@ -22727,6 +21859,7 @@ SWIGINTERN PyObject *_wrap_delete_CdiGrid(PyObject *SWIGUNUSEDPARM(self), PyObje
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
   delete arg1;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -22757,6 +21890,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_gridID_set(PyObject *SWIGUNUSEDPARM(self), Py
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->gridID = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -22767,10 +21901,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_gridID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_gridID_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -22809,6 +21943,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_type_set(PyObject *SWIGUNUSEDPARM(self), PyOb
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->type = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -22819,10 +21954,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_type_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_type_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -22861,6 +21996,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_size_set(PyObject *SWIGUNUSEDPARM(self), PyOb
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->size = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -22871,10 +22007,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_size_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_size_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -22913,6 +22049,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_xsize_set(PyObject *SWIGUNUSEDPARM(self), PyO
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->xsize = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -22923,10 +22060,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_xsize_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_xsize_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -22965,6 +22102,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_ysize_set(PyObject *SWIGUNUSEDPARM(self), PyO
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->ysize = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -22975,10 +22113,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_ysize_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_ysize_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23017,6 +22155,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_prec_set(PyObject *SWIGUNUSEDPARM(self), PyOb
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->prec = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -23027,10 +22166,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_prec_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_prec_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23069,6 +22208,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_ncorner_set(PyObject *SWIGUNUSEDPARM(self), P
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->ncorner = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -23079,10 +22219,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_ncorner_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_ncorner_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23121,6 +22261,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_hasXValues_set(PyObject *SWIGUNUSEDPARM(self)
   } 
   arg2 = static_cast< bool >(val2);
   if (arg1) (arg1)->hasXValues = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -23131,10 +22272,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_hasXValues_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_hasXValues_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23173,6 +22314,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_hasYValues_set(PyObject *SWIGUNUSEDPARM(self)
   } 
   arg2 = static_cast< bool >(val2);
   if (arg1) (arg1)->hasYValues = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -23183,10 +22325,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_hasYValues_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_hasYValues_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23225,6 +22367,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_hasBounds_set(PyObject *SWIGUNUSEDPARM(self),
   } 
   arg2 = static_cast< bool >(val2);
   if (arg1) (arg1)->hasBounds = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -23235,10 +22378,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_hasBounds_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  bool result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  bool result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_hasBounds_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23257,7 +22400,7 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_xvalues_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
-  std::vector< double,std::allocator< double > > *arg2 = (std::vector< double,std::allocator< double > > *) 0 ;
+  std::vector<double,std::allocator<double > > *arg2 = (std::vector<double,std::allocator<double > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -23271,12 +22414,13 @@ SWIGINTERN PyObject *_wrap_CdiGrid_xvalues_set(PyObject *SWIGUNUSEDPARM(self), P
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_xvalues_set" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiGrid_xvalues_set" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiGrid_xvalues_set" "', argument " "2"" of type '" "std::vector<double,std::allocator<double > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp2);
+  arg2 = reinterpret_cast< std::vector<double,std::allocator<double > > * >(argp2);
   if (arg1) (arg1)->xvalues = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -23287,10 +22431,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_xvalues_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  std::vector<double,std::allocator<double > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double,std::allocator< double > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_xvalues_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23298,8 +22442,8 @@ SWIGINTERN PyObject *_wrap_CdiGrid_xvalues_get(PyObject *SWIGUNUSEDPARM(self), P
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_xvalues_get" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  result = (std::vector< double,std::allocator< double > > *)& ((arg1)->xvalues);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  result = (std::vector<double,std::allocator<double > > *)& ((arg1)->xvalues);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -23309,7 +22453,7 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_yvalues_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
-  std::vector< double,std::allocator< double > > *arg2 = (std::vector< double,std::allocator< double > > *) 0 ;
+  std::vector<double,std::allocator<double > > *arg2 = (std::vector<double,std::allocator<double > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -23323,12 +22467,13 @@ SWIGINTERN PyObject *_wrap_CdiGrid_yvalues_set(PyObject *SWIGUNUSEDPARM(self), P
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_yvalues_set" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiGrid_yvalues_set" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiGrid_yvalues_set" "', argument " "2"" of type '" "std::vector<double,std::allocator<double > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp2);
+  arg2 = reinterpret_cast< std::vector<double,std::allocator<double > > * >(argp2);
   if (arg1) (arg1)->yvalues = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -23339,10 +22484,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_yvalues_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  std::vector<double,std::allocator<double > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double,std::allocator< double > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_yvalues_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23350,8 +22495,8 @@ SWIGINTERN PyObject *_wrap_CdiGrid_yvalues_get(PyObject *SWIGUNUSEDPARM(self), P
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_yvalues_get" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  result = (std::vector< double,std::allocator< double > > *)& ((arg1)->yvalues);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  result = (std::vector<double,std::allocator<double > > *)& ((arg1)->yvalues);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -23361,7 +22506,7 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_xbounds_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
-  std::vector< double,std::allocator< double > > *arg2 = (std::vector< double,std::allocator< double > > *) 0 ;
+  std::vector<double,std::allocator<double > > *arg2 = (std::vector<double,std::allocator<double > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -23375,12 +22520,13 @@ SWIGINTERN PyObject *_wrap_CdiGrid_xbounds_set(PyObject *SWIGUNUSEDPARM(self), P
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_xbounds_set" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiGrid_xbounds_set" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiGrid_xbounds_set" "', argument " "2"" of type '" "std::vector<double,std::allocator<double > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp2);
+  arg2 = reinterpret_cast< std::vector<double,std::allocator<double > > * >(argp2);
   if (arg1) (arg1)->xbounds = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -23391,10 +22537,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_xbounds_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  std::vector<double,std::allocator<double > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double,std::allocator< double > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_xbounds_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23402,8 +22548,8 @@ SWIGINTERN PyObject *_wrap_CdiGrid_xbounds_get(PyObject *SWIGUNUSEDPARM(self), P
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_xbounds_get" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  result = (std::vector< double,std::allocator< double > > *)& ((arg1)->xbounds);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  result = (std::vector<double,std::allocator<double > > *)& ((arg1)->xbounds);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -23413,7 +22559,7 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_ybounds_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
-  std::vector< double,std::allocator< double > > *arg2 = (std::vector< double,std::allocator< double > > *) 0 ;
+  std::vector<double,std::allocator<double > > *arg2 = (std::vector<double,std::allocator<double > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -23427,12 +22573,13 @@ SWIGINTERN PyObject *_wrap_CdiGrid_ybounds_set(PyObject *SWIGUNUSEDPARM(self), P
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_ybounds_set" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiGrid_ybounds_set" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiGrid_ybounds_set" "', argument " "2"" of type '" "std::vector<double,std::allocator<double > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp2);
+  arg2 = reinterpret_cast< std::vector<double,std::allocator<double > > * >(argp2);
   if (arg1) (arg1)->ybounds = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -23443,10 +22590,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_ybounds_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  std::vector<double,std::allocator<double > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double,std::allocator< double > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_ybounds_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23454,8 +22601,8 @@ SWIGINTERN PyObject *_wrap_CdiGrid_ybounds_get(PyObject *SWIGUNUSEDPARM(self), P
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_ybounds_get" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  result = (std::vector< double,std::allocator< double > > *)& ((arg1)->ybounds);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  result = (std::vector<double,std::allocator<double > > *)& ((arg1)->ybounds);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -23490,6 +22637,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_xname_set(PyObject *SWIGUNUSEDPARM(self), PyO
     arg2 = ptr;
   }
   if (arg1) (arg1)->xname = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -23502,10 +22650,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_xname_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_xname_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23513,7 +22661,10 @@ SWIGINTERN PyObject *_wrap_CdiGrid_xname_get(PyObject *SWIGUNUSEDPARM(self), PyO
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_xname_get" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  result = (std::string *) & ((arg1)->xname);
+  {
+    std::string const &_result_ref =  ((arg1)->xname);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -23549,6 +22700,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_xlongname_set(PyObject *SWIGUNUSEDPARM(self),
     arg2 = ptr;
   }
   if (arg1) (arg1)->xlongname = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -23561,10 +22713,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_xlongname_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_xlongname_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23572,7 +22724,10 @@ SWIGINTERN PyObject *_wrap_CdiGrid_xlongname_get(PyObject *SWIGUNUSEDPARM(self),
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_xlongname_get" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  result = (std::string *) & ((arg1)->xlongname);
+  {
+    std::string const &_result_ref =  ((arg1)->xlongname);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -23608,6 +22763,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_xstdname_set(PyObject *SWIGUNUSEDPARM(self),
     arg2 = ptr;
   }
   if (arg1) (arg1)->xstdname = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -23620,10 +22776,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_xstdname_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_xstdname_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23631,7 +22787,10 @@ SWIGINTERN PyObject *_wrap_CdiGrid_xstdname_get(PyObject *SWIGUNUSEDPARM(self),
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_xstdname_get" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  result = (std::string *) & ((arg1)->xstdname);
+  {
+    std::string const &_result_ref =  ((arg1)->xstdname);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -23667,6 +22826,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_xunits_set(PyObject *SWIGUNUSEDPARM(self), Py
     arg2 = ptr;
   }
   if (arg1) (arg1)->xunits = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -23679,10 +22839,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_xunits_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_xunits_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23690,7 +22850,10 @@ SWIGINTERN PyObject *_wrap_CdiGrid_xunits_get(PyObject *SWIGUNUSEDPARM(self), Py
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_xunits_get" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  result = (std::string *) & ((arg1)->xunits);
+  {
+    std::string const &_result_ref =  ((arg1)->xunits);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -23726,6 +22889,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_yname_set(PyObject *SWIGUNUSEDPARM(self), PyO
     arg2 = ptr;
   }
   if (arg1) (arg1)->yname = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -23738,10 +22902,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_yname_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_yname_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23749,7 +22913,10 @@ SWIGINTERN PyObject *_wrap_CdiGrid_yname_get(PyObject *SWIGUNUSEDPARM(self), PyO
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_yname_get" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  result = (std::string *) & ((arg1)->yname);
+  {
+    std::string const &_result_ref =  ((arg1)->yname);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -23785,6 +22952,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_ylongname_set(PyObject *SWIGUNUSEDPARM(self),
     arg2 = ptr;
   }
   if (arg1) (arg1)->ylongname = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -23797,10 +22965,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_ylongname_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_ylongname_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23808,7 +22976,10 @@ SWIGINTERN PyObject *_wrap_CdiGrid_ylongname_get(PyObject *SWIGUNUSEDPARM(self),
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_ylongname_get" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  result = (std::string *) & ((arg1)->ylongname);
+  {
+    std::string const &_result_ref =  ((arg1)->ylongname);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -23844,6 +23015,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_ystdname_set(PyObject *SWIGUNUSEDPARM(self),
     arg2 = ptr;
   }
   if (arg1) (arg1)->ystdname = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -23856,10 +23028,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_ystdname_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_ystdname_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23867,7 +23039,10 @@ SWIGINTERN PyObject *_wrap_CdiGrid_ystdname_get(PyObject *SWIGUNUSEDPARM(self),
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_ystdname_get" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  result = (std::string *) & ((arg1)->ystdname);
+  {
+    std::string const &_result_ref =  ((arg1)->ystdname);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -23903,6 +23078,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_yunits_set(PyObject *SWIGUNUSEDPARM(self), Py
     arg2 = ptr;
   }
   if (arg1) (arg1)->yunits = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -23915,10 +23091,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_yunits_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_yunits_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23926,7 +23102,10 @@ SWIGINTERN PyObject *_wrap_CdiGrid_yunits_get(PyObject *SWIGUNUSEDPARM(self), Py
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_yunits_get" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  result = (std::string *) & ((arg1)->yunits);
+  {
+    std::string const &_result_ref =  ((arg1)->yunits);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -23962,6 +23141,7 @@ SWIGINTERN PyObject *_wrap_CdiGrid_name_set(PyObject *SWIGUNUSEDPARM(self), PyOb
     arg2 = ptr;
   }
   if (arg1) (arg1)->name = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -23974,10 +23154,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiGrid_name_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiGrid *arg1 = (CdiGrid *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiGrid_name_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiGrid, 0 |  0 );
@@ -23985,7 +23165,10 @@ SWIGINTERN PyObject *_wrap_CdiGrid_name_get(PyObject *SWIGUNUSEDPARM(self), PyOb
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiGrid_name_get" "', argument " "1"" of type '" "CdiGrid *""'"); 
   }
   arg1 = reinterpret_cast< CdiGrid * >(argp1);
-  result = (std::string *) & ((arg1)->name);
+  {
+    std::string const &_result_ref =  ((arg1)->name);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -24193,7 +23376,7 @@ fail:
 
 SWIGINTERN PyObject *CdiGrid_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
   SWIG_TypeNewClientData(SWIGTYPE_p_CdiGrid, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
@@ -24214,10 +23397,10 @@ fail:
 SWIGINTERN PyObject *_wrap_new_CdiTaxis__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   int arg1 ;
+  CdiTaxis *result = 0 ;
   int val1 ;
   int ecode1 = 0 ;
   PyObject * obj0 = 0 ;
-  CdiTaxis *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:new_CdiTaxis",&obj0)) SWIG_fail;
   ecode1 = SWIG_AsVal_int(obj0, &val1);
@@ -24239,8 +23422,8 @@ SWIGINTERN PyObject *_wrap_new_CdiTaxis(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 1) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 0) {
@@ -24258,11 +23441,8 @@ SWIGINTERN PyObject *_wrap_new_CdiTaxis(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_CdiTaxis'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    CdiTaxis::CdiTaxis()\n"
-    "    CdiTaxis::CdiTaxis(int)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_CdiTaxis'.\n  Possible C/C++ prototypes are:\n    CdiTaxis()\n    CdiTaxis(int)\n");
+  return NULL;
 }
 
 
@@ -24280,6 +23460,7 @@ SWIGINTERN PyObject *_wrap_delete_CdiTaxis(PyObject *SWIGUNUSEDPARM(self), PyObj
   }
   arg1 = reinterpret_cast< CdiTaxis * >(argp1);
   delete arg1;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -24310,6 +23491,7 @@ SWIGINTERN PyObject *_wrap_CdiTaxis_taxisID_set(PyObject *SWIGUNUSEDPARM(self),
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->taxisID = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -24320,10 +23502,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiTaxis_taxisID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiTaxis *arg1 = (CdiTaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiTaxis_taxisID_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiTaxis, 0 |  0 );
@@ -24362,6 +23544,7 @@ SWIGINTERN PyObject *_wrap_CdiTaxis_ntsteps_set(PyObject *SWIGUNUSEDPARM(self),
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->ntsteps = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -24372,10 +23555,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiTaxis_ntsteps_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiTaxis *arg1 = (CdiTaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiTaxis_ntsteps_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiTaxis, 0 |  0 );
@@ -24414,6 +23597,7 @@ SWIGINTERN PyObject *_wrap_CdiTaxis_unit_set(PyObject *SWIGUNUSEDPARM(self), PyO
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->unit = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -24424,10 +23608,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiTaxis_unit_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiTaxis *arg1 = (CdiTaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiTaxis_unit_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiTaxis, 0 |  0 );
@@ -24466,6 +23650,7 @@ SWIGINTERN PyObject *_wrap_CdiTaxis_rdate_set(PyObject *SWIGUNUSEDPARM(self), Py
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->rdate = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -24476,10 +23661,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiTaxis_rdate_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiTaxis *arg1 = (CdiTaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiTaxis_rdate_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiTaxis, 0 |  0 );
@@ -24518,6 +23703,7 @@ SWIGINTERN PyObject *_wrap_CdiTaxis_rtime_set(PyObject *SWIGUNUSEDPARM(self), Py
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->rtime = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -24528,10 +23714,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiTaxis_rtime_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiTaxis *arg1 = (CdiTaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiTaxis_rtime_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiTaxis, 0 |  0 );
@@ -24570,6 +23756,7 @@ SWIGINTERN PyObject *_wrap_CdiTaxis_vdate_set(PyObject *SWIGUNUSEDPARM(self), Py
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->vdate = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -24580,10 +23767,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiTaxis_vdate_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiTaxis *arg1 = (CdiTaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiTaxis_vdate_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiTaxis, 0 |  0 );
@@ -24622,6 +23809,7 @@ SWIGINTERN PyObject *_wrap_CdiTaxis_vtime_set(PyObject *SWIGUNUSEDPARM(self), Py
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->vtime = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -24632,10 +23820,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiTaxis_vtime_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiTaxis *arg1 = (CdiTaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiTaxis_vtime_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiTaxis, 0 |  0 );
@@ -24674,6 +23862,7 @@ SWIGINTERN PyObject *_wrap_CdiTaxis_type_set(PyObject *SWIGUNUSEDPARM(self), PyO
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->type = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -24684,10 +23873,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiTaxis_type_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiTaxis *arg1 = (CdiTaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiTaxis_type_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiTaxis, 0 |  0 );
@@ -24726,6 +23915,7 @@ SWIGINTERN PyObject *_wrap_CdiTaxis_calendar_set(PyObject *SWIGUNUSEDPARM(self),
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->calendar = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -24736,10 +23926,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiTaxis_calendar_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiTaxis *arg1 = (CdiTaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiTaxis_calendar_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiTaxis, 0 |  0 );
@@ -24778,6 +23968,7 @@ SWIGINTERN PyObject *_wrap_CdiTaxis_hasBounds_set(PyObject *SWIGUNUSEDPARM(self)
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->hasBounds = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -24788,10 +23979,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiTaxis_hasBounds_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiTaxis *arg1 = (CdiTaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiTaxis_hasBounds_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiTaxis, 0 |  0 );
@@ -24841,10 +24032,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiTaxis_name_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiTaxis *arg1 = (CdiTaxis *) 0 ;
+  char *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  char *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiTaxis_name_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiTaxis, 0 |  0 );
@@ -24854,9 +24045,9 @@ SWIGINTERN PyObject *_wrap_CdiTaxis_name_get(PyObject *SWIGUNUSEDPARM(self), PyO
   arg1 = reinterpret_cast< CdiTaxis * >(argp1);
   result = (char *)(char *) ((arg1)->name);
   {
-    size_t size = SWIG_strnlen(result, 128);
-    
+    size_t size = 128;
     
+    while (size && (result[size - 1] == '\0')) --size;
     
     resultobj = SWIG_FromCharPtrAndSize(result, size);
   }
@@ -24886,13 +24077,12 @@ SWIGINTERN PyObject *_wrap_CdiTaxis_unitname_set(PyObject *SWIGUNUSEDPARM(self),
   arg1 = reinterpret_cast< CdiTaxis * >(argp1);
   res2 = SWIG_AsCharPtrAndSize(obj1, &buf2, NULL, &alloc2);
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiTaxis_unitname_set" "', argument " "2"" of type '" "char *""'");
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiTaxis_unitname_set" "', argument " "2"" of type '" "char const *""'");
   }
   arg2 = reinterpret_cast< char * >(buf2);
-  if (arg1->unitname) delete[] arg1->unitname;
   if (arg2) {
-    size_t size = strlen(reinterpret_cast< const char * >(arg2)) + 1;
-    arg1->unitname = (char *)reinterpret_cast< char* >(memcpy((new char[size]), reinterpret_cast< const char * >(arg2), sizeof(char)*(size)));
+    size_t size = strlen(reinterpret_cast< const char * >(reinterpret_cast< const char * >(arg2))) + 1;
+    arg1->unitname = (char const *)reinterpret_cast< char* >(memcpy((new char[size]), arg2, sizeof(char)*(size)));
   } else {
     arg1->unitname = 0;
   }
@@ -24908,10 +24098,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiTaxis_unitname_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiTaxis *arg1 = (CdiTaxis *) 0 ;
+  char *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  char *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiTaxis_unitname_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiTaxis, 0 |  0 );
@@ -24929,7 +24119,7 @@ fail:
 
 SWIGINTERN PyObject *CdiTaxis_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
   SWIG_TypeNewClientData(SWIGTYPE_p_CdiTaxis, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
@@ -24950,10 +24140,10 @@ fail:
 SWIGINTERN PyObject *_wrap_new_CdiZaxis__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   int arg1 ;
+  CdiZaxis *result = 0 ;
   int val1 ;
   int ecode1 = 0 ;
   PyObject * obj0 = 0 ;
-  CdiZaxis *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:new_CdiZaxis",&obj0)) SWIG_fail;
   ecode1 = SWIG_AsVal_int(obj0, &val1);
@@ -24975,8 +24165,8 @@ SWIGINTERN PyObject *_wrap_new_CdiZaxis(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 1) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 1); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 0) {
@@ -24994,11 +24184,8 @@ SWIGINTERN PyObject *_wrap_new_CdiZaxis(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_CdiZaxis'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    CdiZaxis::CdiZaxis()\n"
-    "    CdiZaxis::CdiZaxis(int)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_CdiZaxis'.\n  Possible C/C++ prototypes are:\n    CdiZaxis()\n    CdiZaxis(int)\n");
+  return NULL;
 }
 
 
@@ -25016,6 +24203,7 @@ SWIGINTERN PyObject *_wrap_delete_CdiZaxis(PyObject *SWIGUNUSEDPARM(self), PyObj
   }
   arg1 = reinterpret_cast< CdiZaxis * >(argp1);
   delete arg1;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -25046,6 +24234,7 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_zaxisID_set(PyObject *SWIGUNUSEDPARM(self),
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->zaxisID = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -25056,10 +24245,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_zaxisID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_zaxisID_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25098,6 +24287,7 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_type_set(PyObject *SWIGUNUSEDPARM(self), PyO
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->type = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -25108,10 +24298,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_type_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_type_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25150,6 +24340,7 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_ltype_set(PyObject *SWIGUNUSEDPARM(self), Py
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->ltype = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -25160,10 +24351,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_ltype_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_ltype_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25202,6 +24393,7 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_size_set(PyObject *SWIGUNUSEDPARM(self), PyO
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->size = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -25212,10 +24404,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_size_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_size_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25254,6 +24446,7 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_prec_set(PyObject *SWIGUNUSEDPARM(self), PyO
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->prec = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -25264,10 +24457,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_prec_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_prec_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25306,6 +24499,7 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_plevels_set(PyObject *SWIGUNUSEDPARM(self),
   }
   arg2 = reinterpret_cast< double * >(argp2);
   if (arg1) (arg1)->plevels = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -25316,10 +24510,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_plevels_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  double *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  double *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_plevels_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25358,6 +24552,7 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_plbounds_set(PyObject *SWIGUNUSEDPARM(self),
   }
   arg2 = reinterpret_cast< double * >(argp2);
   if (arg1) (arg1)->plbounds = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -25368,10 +24563,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_plbounds_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  double *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  double *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_plbounds_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25410,6 +24605,7 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_pubounds_set(PyObject *SWIGUNUSEDPARM(self),
   }
   arg2 = reinterpret_cast< double * >(argp2);
   if (arg1) (arg1)->pubounds = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -25420,10 +24616,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_pubounds_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  double *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  double *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_pubounds_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25462,6 +24658,7 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_pweights_set(PyObject *SWIGUNUSEDPARM(self),
   }
   arg2 = reinterpret_cast< double * >(argp2);
   if (arg1) (arg1)->pweights = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -25472,10 +24669,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_pweights_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  double *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  double *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_pweights_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25494,7 +24691,7 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_levels_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
-  std::vector< double,std::allocator< double > > *arg2 = (std::vector< double,std::allocator< double > > *) 0 ;
+  std::vector<double,std::allocator<double > > *arg2 = (std::vector<double,std::allocator<double > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -25508,12 +24705,13 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_levels_set(PyObject *SWIGUNUSEDPARM(self), P
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiZaxis_levels_set" "', argument " "1"" of type '" "CdiZaxis *""'"); 
   }
   arg1 = reinterpret_cast< CdiZaxis * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiZaxis_levels_set" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiZaxis_levels_set" "', argument " "2"" of type '" "std::vector<double,std::allocator<double > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp2);
+  arg2 = reinterpret_cast< std::vector<double,std::allocator<double > > * >(argp2);
   if (arg1) (arg1)->levels = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -25524,10 +24722,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_levels_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  std::vector<double,std::allocator<double > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double,std::allocator< double > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_levels_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25535,8 +24733,8 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_levels_get(PyObject *SWIGUNUSEDPARM(self), P
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiZaxis_levels_get" "', argument " "1"" of type '" "CdiZaxis *""'"); 
   }
   arg1 = reinterpret_cast< CdiZaxis * >(argp1);
-  result = (std::vector< double,std::allocator< double > > *)& ((arg1)->levels);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  result = (std::vector<double,std::allocator<double > > *)& ((arg1)->levels);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -25546,7 +24744,7 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_lbounds_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
-  std::vector< double,std::allocator< double > > *arg2 = (std::vector< double,std::allocator< double > > *) 0 ;
+  std::vector<double,std::allocator<double > > *arg2 = (std::vector<double,std::allocator<double > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -25560,12 +24758,13 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_lbounds_set(PyObject *SWIGUNUSEDPARM(self),
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiZaxis_lbounds_set" "', argument " "1"" of type '" "CdiZaxis *""'"); 
   }
   arg1 = reinterpret_cast< CdiZaxis * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiZaxis_lbounds_set" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiZaxis_lbounds_set" "', argument " "2"" of type '" "std::vector<double,std::allocator<double > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp2);
+  arg2 = reinterpret_cast< std::vector<double,std::allocator<double > > * >(argp2);
   if (arg1) (arg1)->lbounds = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -25576,10 +24775,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_lbounds_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  std::vector<double,std::allocator<double > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double,std::allocator< double > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_lbounds_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25587,8 +24786,8 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_lbounds_get(PyObject *SWIGUNUSEDPARM(self),
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiZaxis_lbounds_get" "', argument " "1"" of type '" "CdiZaxis *""'"); 
   }
   arg1 = reinterpret_cast< CdiZaxis * >(argp1);
-  result = (std::vector< double,std::allocator< double > > *)& ((arg1)->lbounds);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  result = (std::vector<double,std::allocator<double > > *)& ((arg1)->lbounds);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -25598,7 +24797,7 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_ubounds_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
-  std::vector< double,std::allocator< double > > *arg2 = (std::vector< double,std::allocator< double > > *) 0 ;
+  std::vector<double,std::allocator<double > > *arg2 = (std::vector<double,std::allocator<double > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -25612,12 +24811,13 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_ubounds_set(PyObject *SWIGUNUSEDPARM(self),
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiZaxis_ubounds_set" "', argument " "1"" of type '" "CdiZaxis *""'"); 
   }
   arg1 = reinterpret_cast< CdiZaxis * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiZaxis_ubounds_set" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiZaxis_ubounds_set" "', argument " "2"" of type '" "std::vector<double,std::allocator<double > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp2);
+  arg2 = reinterpret_cast< std::vector<double,std::allocator<double > > * >(argp2);
   if (arg1) (arg1)->ubounds = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -25628,10 +24828,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_ubounds_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  std::vector<double,std::allocator<double > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double,std::allocator< double > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_ubounds_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25639,8 +24839,8 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_ubounds_get(PyObject *SWIGUNUSEDPARM(self),
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiZaxis_ubounds_get" "', argument " "1"" of type '" "CdiZaxis *""'"); 
   }
   arg1 = reinterpret_cast< CdiZaxis * >(argp1);
-  result = (std::vector< double,std::allocator< double > > *)& ((arg1)->ubounds);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  result = (std::vector<double,std::allocator<double > > *)& ((arg1)->ubounds);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -25650,7 +24850,7 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_weights_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
-  std::vector< double,std::allocator< double > > *arg2 = (std::vector< double,std::allocator< double > > *) 0 ;
+  std::vector<double,std::allocator<double > > *arg2 = (std::vector<double,std::allocator<double > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -25664,12 +24864,13 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_weights_set(PyObject *SWIGUNUSEDPARM(self),
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiZaxis_weights_set" "', argument " "1"" of type '" "CdiZaxis *""'"); 
   }
   arg1 = reinterpret_cast< CdiZaxis * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiZaxis_weights_set" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiZaxis_weights_set" "', argument " "2"" of type '" "std::vector<double,std::allocator<double > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp2);
+  arg2 = reinterpret_cast< std::vector<double,std::allocator<double > > * >(argp2);
   if (arg1) (arg1)->weights = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -25680,10 +24881,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_weights_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  std::vector<double,std::allocator<double > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double,std::allocator< double > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_weights_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25691,8 +24892,8 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_weights_get(PyObject *SWIGUNUSEDPARM(self),
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiZaxis_weights_get" "', argument " "1"" of type '" "CdiZaxis *""'"); 
   }
   arg1 = reinterpret_cast< CdiZaxis * >(argp1);
-  result = (std::vector< double,std::allocator< double > > *)& ((arg1)->weights);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  result = (std::vector<double,std::allocator<double > > *)& ((arg1)->weights);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -25727,6 +24928,7 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_name_set(PyObject *SWIGUNUSEDPARM(self), PyO
     arg2 = ptr;
   }
   if (arg1) (arg1)->name = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -25739,10 +24941,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_name_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_name_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25750,7 +24952,10 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_name_get(PyObject *SWIGUNUSEDPARM(self), PyO
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiZaxis_name_get" "', argument " "1"" of type '" "CdiZaxis *""'"); 
   }
   arg1 = reinterpret_cast< CdiZaxis * >(argp1);
-  result = (std::string *) & ((arg1)->name);
+  {
+    std::string const &_result_ref =  ((arg1)->name);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -25786,6 +24991,7 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_longname_set(PyObject *SWIGUNUSEDPARM(self),
     arg2 = ptr;
   }
   if (arg1) (arg1)->longname = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -25798,10 +25004,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_longname_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_longname_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25809,7 +25015,10 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_longname_get(PyObject *SWIGUNUSEDPARM(self),
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiZaxis_longname_get" "', argument " "1"" of type '" "CdiZaxis *""'"); 
   }
   arg1 = reinterpret_cast< CdiZaxis * >(argp1);
-  result = (std::string *) & ((arg1)->longname);
+  {
+    std::string const &_result_ref =  ((arg1)->longname);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -25845,6 +25054,7 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_units_set(PyObject *SWIGUNUSEDPARM(self), Py
     arg2 = ptr;
   }
   if (arg1) (arg1)->units = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -25857,10 +25067,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiZaxis_units_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiZaxis *arg1 = (CdiZaxis *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiZaxis_units_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiZaxis, 0 |  0 );
@@ -25868,7 +25078,10 @@ SWIGINTERN PyObject *_wrap_CdiZaxis_units_get(PyObject *SWIGUNUSEDPARM(self), Py
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiZaxis_units_get" "', argument " "1"" of type '" "CdiZaxis *""'"); 
   }
   arg1 = reinterpret_cast< CdiZaxis * >(argp1);
-  result = (std::string *) & ((arg1)->units);
+  {
+    std::string const &_result_ref =  ((arg1)->units);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -25878,7 +25091,7 @@ fail:
 
 SWIGINTERN PyObject *CdiZaxis_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
   SWIG_TypeNewClientData(SWIGTYPE_p_CdiZaxis, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
@@ -25901,6 +25114,7 @@ SWIGINTERN PyObject *_wrap_new_CdiVariable__SWIG_1(PyObject *SWIGUNUSEDPARM(self
   int arg1 ;
   int arg2 ;
   int arg3 ;
+  CdiVariable *result = 0 ;
   int val1 ;
   int ecode1 = 0 ;
   int val2 ;
@@ -25910,7 +25124,6 @@ SWIGINTERN PyObject *_wrap_new_CdiVariable__SWIG_1(PyObject *SWIGUNUSEDPARM(self
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
   PyObject * obj2 = 0 ;
-  CdiVariable *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OOO:new_CdiVariable",&obj0,&obj1,&obj2)) SWIG_fail;
   ecode1 = SWIG_AsVal_int(obj0, &val1);
@@ -25942,8 +25155,8 @@ SWIGINTERN PyObject *_wrap_new_CdiVariable(PyObject *self, PyObject *args) {
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 3) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 3); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 0) {
@@ -25973,11 +25186,8 @@ SWIGINTERN PyObject *_wrap_new_CdiVariable(PyObject *self, PyObject *args) {
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'new_CdiVariable'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    CdiVariable::CdiVariable()\n"
-    "    CdiVariable::CdiVariable(int,int,int)\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'new_CdiVariable'.\n  Possible C/C++ prototypes are:\n    CdiVariable()\n    CdiVariable(int,int,int)\n");
+  return NULL;
 }
 
 
@@ -25995,6 +25205,7 @@ SWIGINTERN PyObject *_wrap_delete_CdiVariable(PyObject *SWIGUNUSEDPARM(self), Py
   }
   arg1 = reinterpret_cast< CdiVariable * >(argp1);
   delete arg1;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26025,6 +25236,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_varID_set(PyObject *SWIGUNUSEDPARM(self),
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->varID = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26035,10 +25247,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_varID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_varID_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26077,6 +25289,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_zaxisID_set(PyObject *SWIGUNUSEDPARM(self
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->zaxisID = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26087,10 +25300,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_zaxisID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_zaxisID_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26129,6 +25342,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_gridID_set(PyObject *SWIGUNUSEDPARM(self)
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->gridID = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26139,10 +25353,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_gridID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_gridID_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26181,6 +25395,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_taxisID_set(PyObject *SWIGUNUSEDPARM(self
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->taxisID = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26191,10 +25406,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_taxisID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_taxisID_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26233,6 +25448,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_timeID_set(PyObject *SWIGUNUSEDPARM(self)
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->timeID = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26243,10 +25459,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_timeID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_timeID_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26285,6 +25501,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_vlistID_set(PyObject *SWIGUNUSEDPARM(self
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->vlistID = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26295,10 +25512,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_vlistID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_vlistID_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26337,6 +25554,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_size_set(PyObject *SWIGUNUSEDPARM(self),
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->size = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26347,10 +25565,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_size_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_size_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26389,6 +25607,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_code_set(PyObject *SWIGUNUSEDPARM(self),
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->code = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26399,10 +25618,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_code_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_code_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26441,6 +25660,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_datatype_set(PyObject *SWIGUNUSEDPARM(sel
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->datatype = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26451,10 +25671,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_datatype_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_datatype_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26493,6 +25713,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_streamID_set(PyObject *SWIGUNUSEDPARM(sel
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->streamID = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26503,10 +25724,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_streamID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_streamID_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26550,6 +25771,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_name_set(PyObject *SWIGUNUSEDPARM(self),
     arg2 = ptr;
   }
   if (arg1) (arg1)->name = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -26562,10 +25784,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_name_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_name_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26573,7 +25795,10 @@ SWIGINTERN PyObject *_wrap_CdiVariable_name_get(PyObject *SWIGUNUSEDPARM(self),
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiVariable_name_get" "', argument " "1"" of type '" "CdiVariable *""'"); 
   }
   arg1 = reinterpret_cast< CdiVariable * >(argp1);
-  result = (std::string *) & ((arg1)->name);
+  {
+    std::string const &_result_ref =  ((arg1)->name);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -26609,6 +25834,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_longname_set(PyObject *SWIGUNUSEDPARM(sel
     arg2 = ptr;
   }
   if (arg1) (arg1)->longname = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -26621,10 +25847,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_longname_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_longname_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26632,7 +25858,10 @@ SWIGINTERN PyObject *_wrap_CdiVariable_longname_get(PyObject *SWIGUNUSEDPARM(sel
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiVariable_longname_get" "', argument " "1"" of type '" "CdiVariable *""'"); 
   }
   arg1 = reinterpret_cast< CdiVariable * >(argp1);
-  result = (std::string *) & ((arg1)->longname);
+  {
+    std::string const &_result_ref =  ((arg1)->longname);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -26668,6 +25897,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_units_set(PyObject *SWIGUNUSEDPARM(self),
     arg2 = ptr;
   }
   if (arg1) (arg1)->units = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -26680,10 +25910,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_units_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_units_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26691,7 +25921,10 @@ SWIGINTERN PyObject *_wrap_CdiVariable_units_get(PyObject *SWIGUNUSEDPARM(self),
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiVariable_units_get" "', argument " "1"" of type '" "CdiVariable *""'"); 
   }
   arg1 = reinterpret_cast< CdiVariable * >(argp1);
-  result = (std::string *) & ((arg1)->units);
+  {
+    std::string const &_result_ref =  ((arg1)->units);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -26727,6 +25960,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_stdname_set(PyObject *SWIGUNUSEDPARM(self
     arg2 = ptr;
   }
   if (arg1) (arg1)->stdname = *arg2;
+  
   resultobj = SWIG_Py_Void();
   if (SWIG_IsNewObj(res2)) delete arg2;
   return resultobj;
@@ -26739,10 +25973,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_stdname_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  std::string *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::string *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_stdname_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26750,7 +25984,10 @@ SWIGINTERN PyObject *_wrap_CdiVariable_stdname_get(PyObject *SWIGUNUSEDPARM(self
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiVariable_stdname_get" "', argument " "1"" of type '" "CdiVariable *""'"); 
   }
   arg1 = reinterpret_cast< CdiVariable * >(argp1);
-  result = (std::string *) & ((arg1)->stdname);
+  {
+    std::string const &_result_ref =  ((arg1)->stdname);
+    result = (std::string *) &_result_ref;
+  }
   resultobj = SWIG_From_std_string(static_cast< std::string >(*result));
   return resultobj;
 fail:
@@ -26781,6 +26018,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_missval_set(PyObject *SWIGUNUSEDPARM(self
   } 
   arg2 = static_cast< double >(val2);
   if (arg1) (arg1)->missval = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26791,10 +26029,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_missval_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  double result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  double result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_missval_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26813,7 +26051,7 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_values_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
-  std::vector< double,std::allocator< double > > *arg2 = (std::vector< double,std::allocator< double > > *) 0 ;
+  std::vector<double,std::allocator<double > > *arg2 = (std::vector<double,std::allocator<double > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -26827,12 +26065,13 @@ SWIGINTERN PyObject *_wrap_CdiVariable_values_set(PyObject *SWIGUNUSEDPARM(self)
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiVariable_values_set" "', argument " "1"" of type '" "CdiVariable *""'"); 
   }
   arg1 = reinterpret_cast< CdiVariable * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiVariable_values_set" "', argument " "2"" of type '" "std::vector< double,std::allocator< double > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiVariable_values_set" "', argument " "2"" of type '" "std::vector<double,std::allocator<double > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< double,std::allocator< double > > * >(argp2);
+  arg2 = reinterpret_cast< std::vector<double,std::allocator<double > > * >(argp2);
   if (arg1) (arg1)->values = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26843,10 +26082,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_values_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  std::vector<double,std::allocator<double > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< double,std::allocator< double > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_values_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26854,8 +26093,8 @@ SWIGINTERN PyObject *_wrap_CdiVariable_values_get(PyObject *SWIGUNUSEDPARM(self)
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiVariable_values_get" "', argument " "1"" of type '" "CdiVariable *""'"); 
   }
   arg1 = reinterpret_cast< CdiVariable * >(argp1);
-  result = (std::vector< double,std::allocator< double > > *)& ((arg1)->values);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_double_std__allocatorT_double_t_t, 0 |  0 );
+  result = (std::vector<double,std::allocator<double > > *)& ((arg1)->values);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTdouble_std__allocatorTdouble_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -26865,7 +26104,7 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_valuesWithLevel_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
-  std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *arg2 = (std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *) 0 ;
+  std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > *arg2 = (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -26879,12 +26118,13 @@ SWIGINTERN PyObject *_wrap_CdiVariable_valuesWithLevel_set(PyObject *SWIGUNUSEDP
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiVariable_valuesWithLevel_set" "', argument " "1"" of type '" "CdiVariable *""'"); 
   }
   arg1 = reinterpret_cast< CdiVariable * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiVariable_valuesWithLevel_set" "', argument " "2"" of type '" "std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "CdiVariable_valuesWithLevel_set" "', argument " "2"" of type '" "std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > * >(argp2);
+  arg2 = reinterpret_cast< std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > * >(argp2);
   if (arg1) (arg1)->valuesWithLevel = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26895,10 +26135,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_valuesWithLevel_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_valuesWithLevel_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26906,8 +26146,8 @@ SWIGINTERN PyObject *_wrap_CdiVariable_valuesWithLevel_get(PyObject *SWIGUNUSEDP
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "CdiVariable_valuesWithLevel_get" "', argument " "1"" of type '" "CdiVariable *""'"); 
   }
   arg1 = reinterpret_cast< CdiVariable * >(argp1);
-  result = (std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *)& ((arg1)->valuesWithLevel);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0 |  0 );
+  result = (std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > *)& ((arg1)->valuesWithLevel);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -26937,6 +26177,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_grid_set(PyObject *SWIGUNUSEDPARM(self),
   }
   arg2 = reinterpret_cast< CdiGrid * >(argp2);
   if (arg1) (arg1)->grid = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26947,10 +26188,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_grid_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  CdiGrid *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  CdiGrid *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_grid_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -26989,6 +26230,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_zaxis_set(PyObject *SWIGUNUSEDPARM(self),
   }
   arg2 = reinterpret_cast< CdiZaxis * >(argp2);
   if (arg1) (arg1)->zaxis = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -26999,10 +26241,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_zaxis_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  CdiZaxis *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  CdiZaxis *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_zaxis_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -27041,6 +26283,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_taxis_set(PyObject *SWIGUNUSEDPARM(self),
   }
   arg2 = reinterpret_cast< CdiTaxis * >(argp2);
   if (arg1) (arg1)->taxis = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -27051,10 +26294,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_taxis_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  CdiTaxis *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  CdiTaxis *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_taxis_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -27169,8 +26412,8 @@ SWIGINTERN PyObject *_wrap_CdiVariable_getValuesWithLevel(PyObject *self, PyObje
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 1) {
@@ -27199,21 +26442,18 @@ SWIGINTERN PyObject *_wrap_CdiVariable_getValuesWithLevel(PyObject *self, PyObje
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'CdiVariable_getValuesWithLevel'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    CdiVariable::getValuesWithLevel(int)\n"
-    "    CdiVariable::getValuesWithLevel()\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'CdiVariable_getValuesWithLevel'.\n  Possible C/C++ prototypes are:\n    getValuesWithLevel(int)\n    getValuesWithLevel()\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_CdiVariable_getFValues(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  SwigValueWrapper<std::vector<float,std::allocator<float > > > result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  SwigValueWrapper< std::vector< float,std::allocator< float > > > result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_getFValues",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -27222,7 +26462,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_getFValues(PyObject *SWIGUNUSEDPARM(self)
   }
   arg1 = reinterpret_cast< CdiVariable * >(argp1);
   result = (arg1)->getFValues();
-  resultobj = SWIG_NewPointerObj((new std::vector< float,std::allocator< float > >(static_cast< const std::vector< float,std::allocator< float > >& >(result))), SWIGTYPE_p_std__vectorT_float_std__allocatorT_float_t_t, SWIG_POINTER_OWN |  0 );
+  resultobj = SWIG_NewPointerObj((new std::vector<float,std::allocator<float > >(static_cast< const std::vector<float,std::allocator<float > >& >(result))), SWIGTYPE_p_std__vectorTfloat_std__allocatorTfloat_t_t, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -27233,13 +26473,13 @@ SWIGINTERN PyObject *_wrap_CdiVariable_getFValuesWithLevel__SWIG_0(PyObject *SWI
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
   int arg2 ;
+  SwigValueWrapper<std::vector<std::vector<float,std::allocator<float > >,std::allocator<std::vector<float,std::allocator<float > > > > > result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  SwigValueWrapper< std::vector< std::vector< float,std::allocator< float > >,std::allocator< std::vector< float,std::allocator< float > > > > > result;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:CdiVariable_getFValuesWithLevel",&obj0,&obj1)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -27253,7 +26493,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_getFValuesWithLevel__SWIG_0(PyObject *SWI
   } 
   arg2 = static_cast< int >(val2);
   result = (arg1)->getFValuesWithLevel(arg2);
-  resultobj = SWIG_NewPointerObj((new std::vector< std::vector< float,std::allocator< float > >,std::allocator< std::vector< float,std::allocator< float > > > >(static_cast< const std::vector< std::vector< float,std::allocator< float > >,std::allocator< std::vector< float,std::allocator< float > > > >& >(result))), SWIGTYPE_p_std__vectorT_std__vectorT_float_std__allocatorT_float_t_t_std__allocatorT_std__vectorT_float_std__allocatorT_float_t_t_t_t, SWIG_POINTER_OWN |  0 );
+  resultobj = SWIG_NewPointerObj((new std::vector<std::vector<float,std::allocator<float > >,std::allocator<std::vector<float,std::allocator<float > > > >(static_cast< const std::vector<std::vector<float,std::allocator<float > >,std::allocator<std::vector<float,std::allocator<float > > > >& >(result))), SWIGTYPE_p_std__vectorTstd__vectorTfloat_std__allocatorTfloat_t_t_std__allocatorTstd__vectorTfloat_std__allocatorTfloat_t_t_t_t, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -27263,10 +26503,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_getFValuesWithLevel__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  SwigValueWrapper<std::vector<std::vector<float,std::allocator<float > >,std::allocator<std::vector<float,std::allocator<float > > > > > result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  SwigValueWrapper< std::vector< std::vector< float,std::allocator< float > >,std::allocator< std::vector< float,std::allocator< float > > > > > result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_getFValuesWithLevel",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -27275,7 +26515,7 @@ SWIGINTERN PyObject *_wrap_CdiVariable_getFValuesWithLevel__SWIG_1(PyObject *SWI
   }
   arg1 = reinterpret_cast< CdiVariable * >(argp1);
   result = (arg1)->getFValuesWithLevel();
-  resultobj = SWIG_NewPointerObj((new std::vector< std::vector< float,std::allocator< float > >,std::allocator< std::vector< float,std::allocator< float > > > >(static_cast< const std::vector< std::vector< float,std::allocator< float > >,std::allocator< std::vector< float,std::allocator< float > > > >& >(result))), SWIGTYPE_p_std__vectorT_std__vectorT_float_std__allocatorT_float_t_t_std__allocatorT_std__vectorT_float_std__allocatorT_float_t_t_t_t, SWIG_POINTER_OWN |  0 );
+  resultobj = SWIG_NewPointerObj((new std::vector<std::vector<float,std::allocator<float > >,std::allocator<std::vector<float,std::allocator<float > > > >(static_cast< const std::vector<std::vector<float,std::allocator<float > >,std::allocator<std::vector<float,std::allocator<float > > > >& >(result))), SWIGTYPE_p_std__vectorTstd__vectorTfloat_std__allocatorTfloat_t_t_std__allocatorTstd__vectorTfloat_std__allocatorTfloat_t_t_t_t, SWIG_POINTER_OWN |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -27288,8 +26528,8 @@ SWIGINTERN PyObject *_wrap_CdiVariable_getFValuesWithLevel(PyObject *self, PyObj
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 1) {
@@ -27318,21 +26558,18 @@ SWIGINTERN PyObject *_wrap_CdiVariable_getFValuesWithLevel(PyObject *self, PyObj
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'CdiVariable_getFValuesWithLevel'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    CdiVariable::getFValuesWithLevel(int)\n"
-    "    CdiVariable::getFValuesWithLevel()\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'CdiVariable_getFValuesWithLevel'.\n  Possible C/C++ prototypes are:\n    getFValuesWithLevel(int)\n    getFValuesWithLevel()\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *_wrap_CdiVariable_getValuesAsPointer(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  double *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  double *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_getValuesAsPointer",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -27352,13 +26589,13 @@ SWIGINTERN PyObject *_wrap_CdiVariable_getValuesWithLevelAsPointer__SWIG_0(PyObj
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
   int arg2 ;
+  double **result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   int val2 ;
   int ecode2 = 0 ;
   PyObject * obj0 = 0 ;
   PyObject * obj1 = 0 ;
-  double **result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"OO:CdiVariable_getValuesWithLevelAsPointer",&obj0,&obj1)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -27382,10 +26619,10 @@ fail:
 SWIGINTERN PyObject *_wrap_CdiVariable_getValuesWithLevelAsPointer__SWIG_1(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   CdiVariable *arg1 = (CdiVariable *) 0 ;
+  double **result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  double **result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:CdiVariable_getValuesWithLevelAsPointer",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_CdiVariable, 0 |  0 );
@@ -27407,8 +26644,8 @@ SWIGINTERN PyObject *_wrap_CdiVariable_getValuesWithLevelAsPointer(PyObject *sel
   int ii;
   
   if (!PyTuple_Check(args)) SWIG_fail;
-  argc = args ? (int)PyObject_Length(args) : 0;
-  for (ii = 0; (ii < 2) && (ii < argc); ii++) {
+  argc = PyObject_Length(args);
+  for (ii = 0; (ii < argc) && (ii < 2); ii++) {
     argv[ii] = PyTuple_GET_ITEM(args,ii);
   }
   if (argc == 1) {
@@ -27437,17 +26674,14 @@ SWIGINTERN PyObject *_wrap_CdiVariable_getValuesWithLevelAsPointer(PyObject *sel
   }
   
 fail:
-  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number or type of arguments for overloaded function 'CdiVariable_getValuesWithLevelAsPointer'.\n"
-    "  Possible C/C++ prototypes are:\n"
-    "    CdiVariable::getValuesWithLevelAsPointer(int)\n"
-    "    CdiVariable::getValuesWithLevelAsPointer()\n");
-  return 0;
+  SWIG_SetErrorMsg(PyExc_NotImplementedError,"Wrong number of arguments for overloaded function 'CdiVariable_getValuesWithLevelAsPointer'.\n  Possible C/C++ prototypes are:\n    getValuesWithLevelAsPointer(int)\n    getValuesWithLevelAsPointer()\n");
+  return NULL;
 }
 
 
 SWIGINTERN PyObject *CdiVariable_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
   SWIG_TypeNewClientData(SWIGTYPE_p_CdiVariable, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
@@ -27455,11 +26689,11 @@ SWIGINTERN PyObject *CdiVariable_swigregister(PyObject *SWIGUNUSEDPARM(self), Py
 SWIGINTERN PyObject *_wrap_new_Cdi(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   char *arg1 = (char *) 0 ;
+  Cdi *result = 0 ;
   int res1 ;
   char *buf1 = 0 ;
   int alloc1 = 0 ;
   PyObject * obj0 = 0 ;
-  Cdi *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:new_Cdi",&obj0)) SWIG_fail;
   res1 = SWIG_AsCharPtrAndSize(obj0, &buf1, NULL, &alloc1);
@@ -27491,6 +26725,7 @@ SWIGINTERN PyObject *_wrap_delete_Cdi(PyObject *SWIGUNUSEDPARM(self), PyObject *
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
   delete arg1;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -27521,6 +26756,7 @@ SWIGINTERN PyObject *_wrap_Cdi_streamID_set(PyObject *SWIGUNUSEDPARM(self), PyOb
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->streamID = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -27531,10 +26767,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_streamID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_streamID_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -27573,6 +26809,7 @@ SWIGINTERN PyObject *_wrap_Cdi_vlistID_set(PyObject *SWIGUNUSEDPARM(self), PyObj
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->vlistID = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -27583,10 +26820,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_vlistID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_vlistID_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -27625,6 +26862,7 @@ SWIGINTERN PyObject *_wrap_Cdi_nvars_set(PyObject *SWIGUNUSEDPARM(self), PyObjec
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->nvars = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -27635,10 +26873,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_nvars_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_nvars_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -27677,6 +26915,7 @@ SWIGINTERN PyObject *_wrap_Cdi_nzaxes_set(PyObject *SWIGUNUSEDPARM(self), PyObje
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->nzaxes = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -27687,10 +26926,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_nzaxes_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_nzaxes_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -27729,6 +26968,7 @@ SWIGINTERN PyObject *_wrap_Cdi_ngrids_set(PyObject *SWIGUNUSEDPARM(self), PyObje
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->ngrids = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -27739,10 +26979,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_ngrids_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_ngrids_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -27781,6 +27021,7 @@ SWIGINTERN PyObject *_wrap_Cdi_ntaxes_set(PyObject *SWIGUNUSEDPARM(self), PyObje
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->ntaxes = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -27791,10 +27032,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_ntaxes_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_ntaxes_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -27833,6 +27074,7 @@ SWIGINTERN PyObject *_wrap_Cdi_taxisID_set(PyObject *SWIGUNUSEDPARM(self), PyObj
   } 
   arg2 = static_cast< int >(val2);
   if (arg1) (arg1)->taxisID = arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -27843,10 +27085,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_taxisID_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  int result;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  int result;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_taxisID_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -27865,7 +27107,7 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_varnames_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
-  std::vector< std::string,std::allocator< std::string > > *arg2 = (std::vector< std::string,std::allocator< std::string > > *) 0 ;
+  std::vector<std::string,std::allocator<std::string > > *arg2 = (std::vector<std::string,std::allocator<std::string > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -27879,12 +27121,13 @@ SWIGINTERN PyObject *_wrap_Cdi_varnames_set(PyObject *SWIGUNUSEDPARM(self), PyOb
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_varnames_set" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_varnames_set" "', argument " "2"" of type '" "std::vector< std::string,std::allocator< std::string > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_varnames_set" "', argument " "2"" of type '" "std::vector<std::string,std::allocator<std::string > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< std::string,std::allocator< std::string > > * >(argp2);
+  arg2 = reinterpret_cast< std::vector<std::string,std::allocator<std::string > > * >(argp2);
   if (arg1) (arg1)->varnames = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -27895,10 +27138,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_varnames_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  std::vector<std::string,std::allocator<std::string > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< std::string,std::allocator< std::string > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_varnames_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -27906,8 +27149,8 @@ SWIGINTERN PyObject *_wrap_Cdi_varnames_get(PyObject *SWIGUNUSEDPARM(self), PyOb
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_varnames_get" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  result = (std::vector< std::string,std::allocator< std::string > > *)& ((arg1)->varnames);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0 |  0 );
+  result = (std::vector<std::string,std::allocator<std::string > > *)& ((arg1)->varnames);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -27917,7 +27160,7 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_codes_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
-  std::vector< int,std::allocator< int > > *arg2 = (std::vector< int,std::allocator< int > > *) 0 ;
+  std::vector<int,std::allocator<int > > *arg2 = (std::vector<int,std::allocator<int > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -27931,12 +27174,13 @@ SWIGINTERN PyObject *_wrap_Cdi_codes_set(PyObject *SWIGUNUSEDPARM(self), PyObjec
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_codes_set" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_codes_set" "', argument " "2"" of type '" "std::vector< int,std::allocator< int > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_codes_set" "', argument " "2"" of type '" "std::vector<int,std::allocator<int > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< int,std::allocator< int > > * >(argp2);
+  arg2 = reinterpret_cast< std::vector<int,std::allocator<int > > * >(argp2);
   if (arg1) (arg1)->codes = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -27947,10 +27191,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_codes_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  std::vector<int,std::allocator<int > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< int,std::allocator< int > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_codes_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -27958,8 +27202,8 @@ SWIGINTERN PyObject *_wrap_Cdi_codes_get(PyObject *SWIGUNUSEDPARM(self), PyObjec
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_codes_get" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  result = (std::vector< int,std::allocator< int > > *)& ((arg1)->codes);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_int_std__allocatorT_int_t_t, 0 |  0 );
+  result = (std::vector<int,std::allocator<int > > *)& ((arg1)->codes);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTint_std__allocatorTint_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -27969,7 +27213,7 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_variables_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
-  std::vector< CdiVariable,std::allocator< CdiVariable > > *arg2 = (std::vector< CdiVariable,std::allocator< CdiVariable > > *) 0 ;
+  std::vector<CdiVariable,std::allocator<CdiVariable > > *arg2 = (std::vector<CdiVariable,std::allocator<CdiVariable > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -27983,12 +27227,13 @@ SWIGINTERN PyObject *_wrap_Cdi_variables_set(PyObject *SWIGUNUSEDPARM(self), PyO
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_variables_set" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_variables_set" "', argument " "2"" of type '" "std::vector< CdiVariable,std::allocator< CdiVariable > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_variables_set" "', argument " "2"" of type '" "std::vector<CdiVariable,std::allocator<CdiVariable > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::vector< CdiVariable,std::allocator< CdiVariable > > * >(argp2);
+  arg2 = reinterpret_cast< std::vector<CdiVariable,std::allocator<CdiVariable > > * >(argp2);
   if (arg1) (arg1)->variables = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -27999,10 +27244,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_variables_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  std::vector<CdiVariable,std::allocator<CdiVariable > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::vector< CdiVariable,std::allocator< CdiVariable > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_variables_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -28010,8 +27255,8 @@ SWIGINTERN PyObject *_wrap_Cdi_variables_get(PyObject *SWIGUNUSEDPARM(self), PyO
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_variables_get" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  result = (std::vector< CdiVariable,std::allocator< CdiVariable > > *)& ((arg1)->variables);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0 |  0 );
+  result = (std::vector<CdiVariable,std::allocator<CdiVariable > > *)& ((arg1)->variables);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -28021,7 +27266,7 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_var_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
-  std::map< std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > > *arg2 = (std::map< std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > > *) 0 ;
+  std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > > *arg2 = (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -28035,12 +27280,13 @@ SWIGINTERN PyObject *_wrap_Cdi_var_set(PyObject *SWIGUNUSEDPARM(self), PyObject
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_var_set" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_var_set" "', argument " "2"" of type '" "std::map< std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_var_set" "', argument " "2"" of type '" "std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::map< std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > > * >(argp2);
+  arg2 = reinterpret_cast< std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > > * >(argp2);
   if (arg1) (arg1)->var = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -28051,10 +27297,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_var_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_var_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -28062,8 +27308,8 @@ SWIGINTERN PyObject *_wrap_Cdi_var_get(PyObject *SWIGUNUSEDPARM(self), PyObject
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_var_get" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  result = (std::map< std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > > *)& ((arg1)->var);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0 |  0 );
+  result = (std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > > *)& ((arg1)->var);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -28073,7 +27319,7 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_varByCode_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
-  std::map< int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > > *arg2 = (std::map< int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > > *) 0 ;
+  std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > > *arg2 = (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -28087,12 +27333,13 @@ SWIGINTERN PyObject *_wrap_Cdi_varByCode_set(PyObject *SWIGUNUSEDPARM(self), PyO
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_varByCode_set" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_varByCode_set" "', argument " "2"" of type '" "std::map< int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_varByCode_set" "', argument " "2"" of type '" "std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::map< int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > > * >(argp2);
+  arg2 = reinterpret_cast< std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > > * >(argp2);
   if (arg1) (arg1)->varByCode = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -28103,10 +27350,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_varByCode_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_varByCode_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -28114,8 +27361,8 @@ SWIGINTERN PyObject *_wrap_Cdi_varByCode_get(PyObject *SWIGUNUSEDPARM(self), PyO
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_varByCode_get" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  result = (std::map< int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > > *)& ((arg1)->varByCode);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0 |  0 );
+  result = (std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > > *)& ((arg1)->varByCode);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -28125,7 +27372,7 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_taxes_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
-  std::map< int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > > *arg2 = (std::map< int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > > *) 0 ;
+  std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > > *arg2 = (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -28139,12 +27386,13 @@ SWIGINTERN PyObject *_wrap_Cdi_taxes_set(PyObject *SWIGUNUSEDPARM(self), PyObjec
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_taxes_set" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_taxes_set" "', argument " "2"" of type '" "std::map< int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_taxes_set" "', argument " "2"" of type '" "std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::map< int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > > * >(argp2);
+  arg2 = reinterpret_cast< std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > > * >(argp2);
   if (arg1) (arg1)->taxes = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -28155,10 +27403,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_taxes_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_taxes_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -28166,8 +27414,8 @@ SWIGINTERN PyObject *_wrap_Cdi_taxes_get(PyObject *SWIGUNUSEDPARM(self), PyObjec
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_taxes_get" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  result = (std::map< int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > > *)& ((arg1)->taxes);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0 |  0 );
+  result = (std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > > *)& ((arg1)->taxes);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -28177,7 +27425,7 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_zaxes_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
-  std::map< int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > > *arg2 = (std::map< int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > > *) 0 ;
+  std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > > *arg2 = (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -28191,12 +27439,13 @@ SWIGINTERN PyObject *_wrap_Cdi_zaxes_set(PyObject *SWIGUNUSEDPARM(self), PyObjec
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_zaxes_set" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_zaxes_set" "', argument " "2"" of type '" "std::map< int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_zaxes_set" "', argument " "2"" of type '" "std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::map< int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > > * >(argp2);
+  arg2 = reinterpret_cast< std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > > * >(argp2);
   if (arg1) (arg1)->zaxes = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -28207,10 +27456,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_zaxes_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_zaxes_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -28218,8 +27467,8 @@ SWIGINTERN PyObject *_wrap_Cdi_zaxes_get(PyObject *SWIGUNUSEDPARM(self), PyObjec
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_zaxes_get" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  result = (std::map< int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > > *)& ((arg1)->zaxes);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0 |  0 );
+  result = (std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > > *)& ((arg1)->zaxes);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -28229,7 +27478,7 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_grids_set(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
-  std::map< int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > > *arg2 = (std::map< int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > > *) 0 ;
+  std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > > *arg2 = (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > > *) 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   void *argp2 = 0 ;
@@ -28243,12 +27492,13 @@ SWIGINTERN PyObject *_wrap_Cdi_grids_set(PyObject *SWIGUNUSEDPARM(self), PyObjec
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_grids_set" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  res2 = SWIG_ConvertPtr(obj1, &argp2,SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   if (!SWIG_IsOK(res2)) {
-    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_grids_set" "', argument " "2"" of type '" "std::map< int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > > *""'"); 
+    SWIG_exception_fail(SWIG_ArgError(res2), "in method '" "Cdi_grids_set" "', argument " "2"" of type '" "std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > > *""'"); 
   }
-  arg2 = reinterpret_cast< std::map< int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > > * >(argp2);
+  arg2 = reinterpret_cast< std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > > * >(argp2);
   if (arg1) (arg1)->grids = *arg2;
+  
   resultobj = SWIG_Py_Void();
   return resultobj;
 fail:
@@ -28259,10 +27509,10 @@ fail:
 SWIGINTERN PyObject *_wrap_Cdi_grids_get(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *resultobj = 0;
   Cdi *arg1 = (Cdi *) 0 ;
+  std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > > *result = 0 ;
   void *argp1 = 0 ;
   int res1 = 0 ;
   PyObject * obj0 = 0 ;
-  std::map< int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > > *result = 0 ;
   
   if (!PyArg_ParseTuple(args,(char *)"O:Cdi_grids_get",&obj0)) SWIG_fail;
   res1 = SWIG_ConvertPtr(obj0, &argp1,SWIGTYPE_p_Cdi, 0 |  0 );
@@ -28270,8 +27520,8 @@ SWIGINTERN PyObject *_wrap_Cdi_grids_get(PyObject *SWIGUNUSEDPARM(self), PyObjec
     SWIG_exception_fail(SWIG_ArgError(res1), "in method '" "Cdi_grids_get" "', argument " "1"" of type '" "Cdi *""'"); 
   }
   arg1 = reinterpret_cast< Cdi * >(argp1);
-  result = (std::map< int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > > *)& ((arg1)->grids);
-  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0 |  0 );
+  result = (std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > > *)& ((arg1)->grids);
+  resultobj = SWIG_NewPointerObj(SWIG_as_voidptr(result), SWIGTYPE_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0 |  0 );
   return resultobj;
 fail:
   return NULL;
@@ -28301,34 +27551,31 @@ fail:
 
 SWIGINTERN PyObject *Cdi_swigregister(PyObject *SWIGUNUSEDPARM(self), PyObject *args) {
   PyObject *obj;
-  if (!PyArg_ParseTuple(args,(char*)"O:swigregister", &obj)) return NULL;
+  if (!PyArg_ParseTuple(args,(char*)"O|swigregister", &obj)) return NULL;
   SWIG_TypeNewClientData(SWIGTYPE_p_Cdi, SWIG_NewClientData(obj));
   return SWIG_Py_Void();
 }
 
 static PyMethodDef SwigMethods[] = {
-	 { (char *)"SWIG_PyInstanceMethod_New", (PyCFunction)SWIG_PyInstanceMethod_New, METH_O, NULL},
-	 { (char *)"delete_SwigPyIterator", _wrap_delete_SwigPyIterator, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator_value", _wrap_SwigPyIterator_value, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator_incr", _wrap_SwigPyIterator_incr, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator_decr", _wrap_SwigPyIterator_decr, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator_distance", _wrap_SwigPyIterator_distance, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator_equal", _wrap_SwigPyIterator_equal, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator_copy", _wrap_SwigPyIterator_copy, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator_next", _wrap_SwigPyIterator_next, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator___next__", _wrap_SwigPyIterator___next__, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator_previous", _wrap_SwigPyIterator_previous, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator_advance", _wrap_SwigPyIterator_advance, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator___eq__", _wrap_SwigPyIterator___eq__, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator___ne__", _wrap_SwigPyIterator___ne__, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator___iadd__", _wrap_SwigPyIterator___iadd__, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator___isub__", _wrap_SwigPyIterator___isub__, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator___add__", _wrap_SwigPyIterator___add__, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator___sub__", _wrap_SwigPyIterator___sub__, METH_VARARGS, NULL},
-	 { (char *)"SwigPyIterator_swigregister", SwigPyIterator_swigregister, METH_VARARGS, NULL},
+	 { (char *)"delete_PySwigIterator", _wrap_delete_PySwigIterator, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_value", _wrap_PySwigIterator_value, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_incr", _wrap_PySwigIterator_incr, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_decr", _wrap_PySwigIterator_decr, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_distance", _wrap_PySwigIterator_distance, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_equal", _wrap_PySwigIterator_equal, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_copy", _wrap_PySwigIterator_copy, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_next", _wrap_PySwigIterator_next, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_previous", _wrap_PySwigIterator_previous, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_advance", _wrap_PySwigIterator_advance, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator___eq__", _wrap_PySwigIterator___eq__, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator___ne__", _wrap_PySwigIterator___ne__, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator___iadd__", _wrap_PySwigIterator___iadd__, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator___isub__", _wrap_PySwigIterator___isub__, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator___add__", _wrap_PySwigIterator___add__, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator___sub__", _wrap_PySwigIterator___sub__, METH_VARARGS, NULL},
+	 { (char *)"PySwigIterator_swigregister", PySwigIterator_swigregister, METH_VARARGS, NULL},
 	 { (char *)"IntVector_iterator", _wrap_IntVector_iterator, METH_VARARGS, NULL},
 	 { (char *)"IntVector___nonzero__", _wrap_IntVector___nonzero__, METH_VARARGS, NULL},
-	 { (char *)"IntVector___bool__", _wrap_IntVector___bool__, METH_VARARGS, NULL},
 	 { (char *)"IntVector___len__", _wrap_IntVector___len__, METH_VARARGS, NULL},
 	 { (char *)"IntVector_pop", _wrap_IntVector_pop, METH_VARARGS, NULL},
 	 { (char *)"IntVector___getslice__", _wrap_IntVector___getslice__, METH_VARARGS, NULL},
@@ -28362,7 +27609,6 @@ static PyMethodDef SwigMethods[] = {
 	 { (char *)"IntVector_swigregister", IntVector_swigregister, METH_VARARGS, NULL},
 	 { (char *)"DoubleVector_iterator", _wrap_DoubleVector_iterator, METH_VARARGS, NULL},
 	 { (char *)"DoubleVector___nonzero__", _wrap_DoubleVector___nonzero__, METH_VARARGS, NULL},
-	 { (char *)"DoubleVector___bool__", _wrap_DoubleVector___bool__, METH_VARARGS, NULL},
 	 { (char *)"DoubleVector___len__", _wrap_DoubleVector___len__, METH_VARARGS, NULL},
 	 { (char *)"DoubleVector_pop", _wrap_DoubleVector_pop, METH_VARARGS, NULL},
 	 { (char *)"DoubleVector___getslice__", _wrap_DoubleVector___getslice__, METH_VARARGS, NULL},
@@ -28396,7 +27642,6 @@ static PyMethodDef SwigMethods[] = {
 	 { (char *)"DoubleVector_swigregister", DoubleVector_swigregister, METH_VARARGS, NULL},
 	 { (char *)"DoubleDoubleVector_iterator", _wrap_DoubleDoubleVector_iterator, METH_VARARGS, NULL},
 	 { (char *)"DoubleDoubleVector___nonzero__", _wrap_DoubleDoubleVector___nonzero__, METH_VARARGS, NULL},
-	 { (char *)"DoubleDoubleVector___bool__", _wrap_DoubleDoubleVector___bool__, METH_VARARGS, NULL},
 	 { (char *)"DoubleDoubleVector___len__", _wrap_DoubleDoubleVector___len__, METH_VARARGS, NULL},
 	 { (char *)"DoubleDoubleVector_pop", _wrap_DoubleDoubleVector_pop, METH_VARARGS, NULL},
 	 { (char *)"DoubleDoubleVector___getslice__", _wrap_DoubleDoubleVector___getslice__, METH_VARARGS, NULL},
@@ -28430,7 +27675,6 @@ static PyMethodDef SwigMethods[] = {
 	 { (char *)"DoubleDoubleVector_swigregister", DoubleDoubleVector_swigregister, METH_VARARGS, NULL},
 	 { (char *)"StringVector_iterator", _wrap_StringVector_iterator, METH_VARARGS, NULL},
 	 { (char *)"StringVector___nonzero__", _wrap_StringVector___nonzero__, METH_VARARGS, NULL},
-	 { (char *)"StringVector___bool__", _wrap_StringVector___bool__, METH_VARARGS, NULL},
 	 { (char *)"StringVector___len__", _wrap_StringVector___len__, METH_VARARGS, NULL},
 	 { (char *)"StringVector_pop", _wrap_StringVector_pop, METH_VARARGS, NULL},
 	 { (char *)"StringVector___getslice__", _wrap_StringVector___getslice__, METH_VARARGS, NULL},
@@ -28464,7 +27708,6 @@ static PyMethodDef SwigMethods[] = {
 	 { (char *)"StringVector_swigregister", StringVector_swigregister, METH_VARARGS, NULL},
 	 { (char *)"VarsVector_iterator", _wrap_VarsVector_iterator, METH_VARARGS, NULL},
 	 { (char *)"VarsVector___nonzero__", _wrap_VarsVector___nonzero__, METH_VARARGS, NULL},
-	 { (char *)"VarsVector___bool__", _wrap_VarsVector___bool__, METH_VARARGS, NULL},
 	 { (char *)"VarsVector___len__", _wrap_VarsVector___len__, METH_VARARGS, NULL},
 	 { (char *)"VarsVector_pop", _wrap_VarsVector_pop, METH_VARARGS, NULL},
 	 { (char *)"VarsVector___getslice__", _wrap_VarsVector___getslice__, METH_VARARGS, NULL},
@@ -28498,7 +27741,6 @@ static PyMethodDef SwigMethods[] = {
 	 { (char *)"VarsVector_swigregister", VarsVector_swigregister, METH_VARARGS, NULL},
 	 { (char *)"VarsMap_iterator", _wrap_VarsMap_iterator, METH_VARARGS, NULL},
 	 { (char *)"VarsMap___nonzero__", _wrap_VarsMap___nonzero__, METH_VARARGS, NULL},
-	 { (char *)"VarsMap___bool__", _wrap_VarsMap___bool__, METH_VARARGS, NULL},
 	 { (char *)"VarsMap___len__", _wrap_VarsMap___len__, METH_VARARGS, NULL},
 	 { (char *)"VarsMap___getitem__", _wrap_VarsMap___getitem__, METH_VARARGS, NULL},
 	 { (char *)"VarsMap___delitem__", _wrap_VarsMap___delitem__, METH_VARARGS, NULL},
@@ -28510,7 +27752,6 @@ static PyMethodDef SwigMethods[] = {
 	 { (char *)"VarsMap_key_iterator", _wrap_VarsMap_key_iterator, METH_VARARGS, NULL},
 	 { (char *)"VarsMap_value_iterator", _wrap_VarsMap_value_iterator, METH_VARARGS, NULL},
 	 { (char *)"VarsMap___setitem__", _wrap_VarsMap___setitem__, METH_VARARGS, NULL},
-	 { (char *)"VarsMap_asdict", _wrap_VarsMap_asdict, METH_VARARGS, NULL},
 	 { (char *)"new_VarsMap", _wrap_new_VarsMap, METH_VARARGS, NULL},
 	 { (char *)"VarsMap_empty", _wrap_VarsMap_empty, METH_VARARGS, NULL},
 	 { (char *)"VarsMap_size", _wrap_VarsMap_size, METH_VARARGS, NULL},
@@ -28530,7 +27771,6 @@ static PyMethodDef SwigMethods[] = {
 	 { (char *)"VarsMap_swigregister", VarsMap_swigregister, METH_VARARGS, NULL},
 	 { (char *)"VarsByCode_iterator", _wrap_VarsByCode_iterator, METH_VARARGS, NULL},
 	 { (char *)"VarsByCode___nonzero__", _wrap_VarsByCode___nonzero__, METH_VARARGS, NULL},
-	 { (char *)"VarsByCode___bool__", _wrap_VarsByCode___bool__, METH_VARARGS, NULL},
 	 { (char *)"VarsByCode___len__", _wrap_VarsByCode___len__, METH_VARARGS, NULL},
 	 { (char *)"VarsByCode___getitem__", _wrap_VarsByCode___getitem__, METH_VARARGS, NULL},
 	 { (char *)"VarsByCode___delitem__", _wrap_VarsByCode___delitem__, METH_VARARGS, NULL},
@@ -28542,7 +27782,6 @@ static PyMethodDef SwigMethods[] = {
 	 { (char *)"VarsByCode_key_iterator", _wrap_VarsByCode_key_iterator, METH_VARARGS, NULL},
 	 { (char *)"VarsByCode_value_iterator", _wrap_VarsByCode_value_iterator, METH_VARARGS, NULL},
 	 { (char *)"VarsByCode___setitem__", _wrap_VarsByCode___setitem__, METH_VARARGS, NULL},
-	 { (char *)"VarsByCode_asdict", _wrap_VarsByCode_asdict, METH_VARARGS, NULL},
 	 { (char *)"new_VarsByCode", _wrap_new_VarsByCode, METH_VARARGS, NULL},
 	 { (char *)"VarsByCode_empty", _wrap_VarsByCode_empty, METH_VARARGS, NULL},
 	 { (char *)"VarsByCode_size", _wrap_VarsByCode_size, METH_VARARGS, NULL},
@@ -28562,7 +27801,6 @@ static PyMethodDef SwigMethods[] = {
 	 { (char *)"VarsByCode_swigregister", VarsByCode_swigregister, METH_VARARGS, NULL},
 	 { (char *)"TaxesMap_iterator", _wrap_TaxesMap_iterator, METH_VARARGS, NULL},
 	 { (char *)"TaxesMap___nonzero__", _wrap_TaxesMap___nonzero__, METH_VARARGS, NULL},
-	 { (char *)"TaxesMap___bool__", _wrap_TaxesMap___bool__, METH_VARARGS, NULL},
 	 { (char *)"TaxesMap___len__", _wrap_TaxesMap___len__, METH_VARARGS, NULL},
 	 { (char *)"TaxesMap___getitem__", _wrap_TaxesMap___getitem__, METH_VARARGS, NULL},
 	 { (char *)"TaxesMap___delitem__", _wrap_TaxesMap___delitem__, METH_VARARGS, NULL},
@@ -28574,7 +27812,6 @@ static PyMethodDef SwigMethods[] = {
 	 { (char *)"TaxesMap_key_iterator", _wrap_TaxesMap_key_iterator, METH_VARARGS, NULL},
 	 { (char *)"TaxesMap_value_iterator", _wrap_TaxesMap_value_iterator, METH_VARARGS, NULL},
 	 { (char *)"TaxesMap___setitem__", _wrap_TaxesMap___setitem__, METH_VARARGS, NULL},
-	 { (char *)"TaxesMap_asdict", _wrap_TaxesMap_asdict, METH_VARARGS, NULL},
 	 { (char *)"new_TaxesMap", _wrap_new_TaxesMap, METH_VARARGS, NULL},
 	 { (char *)"TaxesMap_empty", _wrap_TaxesMap_empty, METH_VARARGS, NULL},
 	 { (char *)"TaxesMap_size", _wrap_TaxesMap_size, METH_VARARGS, NULL},
@@ -28594,7 +27831,6 @@ static PyMethodDef SwigMethods[] = {
 	 { (char *)"TaxesMap_swigregister", TaxesMap_swigregister, METH_VARARGS, NULL},
 	 { (char *)"ZaxesMap_iterator", _wrap_ZaxesMap_iterator, METH_VARARGS, NULL},
 	 { (char *)"ZaxesMap___nonzero__", _wrap_ZaxesMap___nonzero__, METH_VARARGS, NULL},
-	 { (char *)"ZaxesMap___bool__", _wrap_ZaxesMap___bool__, METH_VARARGS, NULL},
 	 { (char *)"ZaxesMap___len__", _wrap_ZaxesMap___len__, METH_VARARGS, NULL},
 	 { (char *)"ZaxesMap___getitem__", _wrap_ZaxesMap___getitem__, METH_VARARGS, NULL},
 	 { (char *)"ZaxesMap___delitem__", _wrap_ZaxesMap___delitem__, METH_VARARGS, NULL},
@@ -28606,7 +27842,6 @@ static PyMethodDef SwigMethods[] = {
 	 { (char *)"ZaxesMap_key_iterator", _wrap_ZaxesMap_key_iterator, METH_VARARGS, NULL},
 	 { (char *)"ZaxesMap_value_iterator", _wrap_ZaxesMap_value_iterator, METH_VARARGS, NULL},
 	 { (char *)"ZaxesMap___setitem__", _wrap_ZaxesMap___setitem__, METH_VARARGS, NULL},
-	 { (char *)"ZaxesMap_asdict", _wrap_ZaxesMap_asdict, METH_VARARGS, NULL},
 	 { (char *)"new_ZaxesMap", _wrap_new_ZaxesMap, METH_VARARGS, NULL},
 	 { (char *)"ZaxesMap_empty", _wrap_ZaxesMap_empty, METH_VARARGS, NULL},
 	 { (char *)"ZaxesMap_size", _wrap_ZaxesMap_size, METH_VARARGS, NULL},
@@ -28626,7 +27861,6 @@ static PyMethodDef SwigMethods[] = {
 	 { (char *)"ZaxesMap_swigregister", ZaxesMap_swigregister, METH_VARARGS, NULL},
 	 { (char *)"GridsMap_iterator", _wrap_GridsMap_iterator, METH_VARARGS, NULL},
 	 { (char *)"GridsMap___nonzero__", _wrap_GridsMap___nonzero__, METH_VARARGS, NULL},
-	 { (char *)"GridsMap___bool__", _wrap_GridsMap___bool__, METH_VARARGS, NULL},
 	 { (char *)"GridsMap___len__", _wrap_GridsMap___len__, METH_VARARGS, NULL},
 	 { (char *)"GridsMap___getitem__", _wrap_GridsMap___getitem__, METH_VARARGS, NULL},
 	 { (char *)"GridsMap___delitem__", _wrap_GridsMap___delitem__, METH_VARARGS, NULL},
@@ -28638,7 +27872,6 @@ static PyMethodDef SwigMethods[] = {
 	 { (char *)"GridsMap_key_iterator", _wrap_GridsMap_key_iterator, METH_VARARGS, NULL},
 	 { (char *)"GridsMap_value_iterator", _wrap_GridsMap_value_iterator, METH_VARARGS, NULL},
 	 { (char *)"GridsMap___setitem__", _wrap_GridsMap___setitem__, METH_VARARGS, NULL},
-	 { (char *)"GridsMap_asdict", _wrap_GridsMap_asdict, METH_VARARGS, NULL},
 	 { (char *)"new_GridsMap", _wrap_new_GridsMap, METH_VARARGS, NULL},
 	 { (char *)"GridsMap_empty", _wrap_GridsMap_empty, METH_VARARGS, NULL},
 	 { (char *)"GridsMap_size", _wrap_GridsMap_size, METH_VARARGS, NULL},
@@ -28864,10 +28097,10 @@ static PyMethodDef SwigMethods[] = {
 /* -------- TYPE CONVERSION AND EQUIVALENCE RULES (BEGIN) -------- */
 
 static swig_type_info _swigt__p_Cdi = {"_p_Cdi", "Cdi *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_CdiGrid = {"_p_CdiGrid", "std::map< int,CdiGrid >::mapped_type *|CdiGrid *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_CdiTaxis = {"_p_CdiTaxis", "std::map< int,CdiTaxis >::mapped_type *|CdiTaxis *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_CdiVariable = {"_p_CdiVariable", "std::map< std::string,CdiVariable >::mapped_type *|std::vector< CdiVariable >::value_type *|std::map< int,CdiVariable >::mapped_type *|CdiVariable *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_CdiZaxis = {"_p_CdiZaxis", "std::map< int,CdiZaxis >::mapped_type *|CdiZaxis *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_CdiGrid = {"_p_CdiGrid", "CdiGrid *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_CdiTaxis = {"_p_CdiTaxis", "CdiTaxis *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_CdiVariable = {"_p_CdiVariable", "CdiVariable *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_CdiZaxis = {"_p_CdiZaxis", "CdiZaxis *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_allocator_type = {"_p_allocator_type", "allocator_type *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_char = {"_p_char", "char *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_difference_type = {"_p_difference_type", "difference_type *", 0, 0, (void*)0, 0};
@@ -28878,33 +28111,36 @@ static swig_type_info _swigt__p_mapped_type = {"_p_mapped_type", "mapped_type *"
 static swig_type_info _swigt__p_p_PyObject = {"_p_p_PyObject", "PyObject **", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_p_double = {"_p_p_double", "double **", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_size_type = {"_p_size_type", "size_type *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__allocatorT_CdiVariable_t = {"_p_std__allocatorT_CdiVariable_t", "std::vector< CdiVariable >::allocator_type *|std::allocator< CdiVariable > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__allocatorT_double_t = {"_p_std__allocatorT_double_t", "std::vector< double >::allocator_type *|std::allocator< double > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__allocatorT_int_t = {"_p_std__allocatorT_int_t", "std::vector< int >::allocator_type *|std::allocator< int > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__allocatorT_std__pairT_int_const_CdiGrid_t_t = {"_p_std__allocatorT_std__pairT_int_const_CdiGrid_t_t", "std::map< int,CdiGrid >::allocator_type *|std::allocator< std::pair< int const,CdiGrid > > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t = {"_p_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t", "std::map< int,CdiTaxis >::allocator_type *|std::allocator< std::pair< int const,CdiTaxis > > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__allocatorT_std__pairT_int_const_CdiVariable_t_t = {"_p_std__allocatorT_std__pairT_int_const_CdiVariable_t_t", "std::map< int,CdiVariable >::allocator_type *|std::allocator< std::pair< int const,CdiVariable > > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t = {"_p_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t", "std::map< int,CdiZaxis >::allocator_type *|std::allocator< std::pair< int const,CdiZaxis > > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t = {"_p_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t", "std::allocator< std::pair< std::string const,CdiVariable > > *|std::map< std::string,CdiVariable >::allocator_type *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__allocatorT_std__string_t = {"_p_std__allocatorT_std__string_t", "std::vector< std::string >::allocator_type *|std::allocator< std::string > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t = {"_p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t", "std::vector< std::vector< double > >::allocator_type *|std::allocator< std::vector< double,std::allocator< double > > > *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_std__invalid_argument = {"_p_std__invalid_argument", "std::invalid_argument *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__lessT_int_t = {"_p_std__lessT_int_t", "std::less< int > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__lessT_std__string_t = {"_p_std__lessT_std__string_t", "std::less< std::string > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t = {"_p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t", "std::map< int,CdiGrid > *|std::map< int,CdiGrid,std::less< int >,std::allocator< std::pair< int const,CdiGrid > > > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t = {"_p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t", "std::map< int,CdiTaxis > *|std::map< int,CdiTaxis,std::less< int >,std::allocator< std::pair< int const,CdiTaxis > > > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t = {"_p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t", "std::map< int,CdiVariable,std::less< int >,std::allocator< std::pair< int const,CdiVariable > > > *|std::map< int,CdiVariable > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t = {"_p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t", "std::map< int,CdiZaxis > *|std::map< int,CdiZaxis,std::less< int >,std::allocator< std::pair< int const,CdiZaxis > > > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t = {"_p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t", "std::map< std::string,CdiVariable,std::less< std::string >,std::allocator< std::pair< std::string const,CdiVariable > > > *|std::map< std::string,CdiVariable > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t = {"_p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t", "std::vector< CdiVariable,std::allocator< CdiVariable > > *|std::vector< CdiVariable > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__vectorT__Tp__Alloc_t = {"_p_std__vectorT__Tp__Alloc_t", "std::vector< _Tp,_Alloc > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__vectorT_double_std__allocatorT_double_t_t = {"_p_std__vectorT_double_std__allocatorT_double_t_t", "std::vector< double,std::allocator< double > > *|std::vector< double > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__vectorT_float_std__allocatorT_float_t_t = {"_p_std__vectorT_float_std__allocatorT_float_t_t", "std::vector< float,std::allocator< float > > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__vectorT_int_std__allocatorT_int_t_t = {"_p_std__vectorT_int_std__allocatorT_int_t_t", "std::vector< int,std::allocator< int > > *|std::vector< int > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__vectorT_std__string_std__allocatorT_std__string_t_t = {"_p_std__vectorT_std__string_std__allocatorT_std__string_t_t", "std::vector< std::string,std::allocator< std::string > > *|std::vector< std::string > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t = {"_p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t", "std::vector< std::vector< double > > *|std::vector< std::vector< double,std::allocator< double > >,std::allocator< std::vector< double,std::allocator< double > > > > *|std::vector< std::vector< do [...]
-static swig_type_info _swigt__p_std__vectorT_std__vectorT_float_std__allocatorT_float_t_t_std__allocatorT_std__vectorT_float_std__allocatorT_float_t_t_t_t = {"_p_std__vectorT_std__vectorT_float_std__allocatorT_float_t_t_std__allocatorT_std__vectorT_float_std__allocatorT_float_t_t_t_t", "std::vector< std::vector< float,std::allocator< float > >,std::allocator< std::vector< float,std::allocator< float > > > > *", 0, 0, (void*)0, 0};
-static swig_type_info _swigt__p_swig__SwigPyIterator = {"_p_swig__SwigPyIterator", "swig::SwigPyIterator *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t = {"_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t", "std::map<int,CdiGrid,std::less<int >,std::allocator<std::pair<int const,CdiGrid > > > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__allocator_type = {"_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__allocator_type", "std::allocator<std::pair<int const,CdiGrid > > *|std::map<int,CdiGrid >::allocator_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__mapped_type = {"_p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__mapped_type", "CdiGrid *|std::map<int,CdiGrid >::mapped_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t = {"_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t", "std::map<int,CdiTaxis,std::less<int >,std::allocator<std::pair<int const,CdiTaxis > > > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__allocator_type = {"_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__allocator_type", "std::allocator<std::pair<int const,CdiTaxis > > *|std::map<int,CdiTaxis >::allocator_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__mapped_type = {"_p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__mapped_type", "CdiTaxis *|std::map<int,CdiTaxis >::mapped_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t = {"_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t", "std::map<int,CdiVariable,std::less<int >,std::allocator<std::pair<int const,CdiVariable > > > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__allocator_type = {"_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__allocator_type", "std::allocator<std::pair<int const,CdiVariable > > *|std::map<int,CdiVariable >::allocator_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__mapped_type = {"_p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__mapped_type", "CdiVariable *|std::map<int,CdiVariable >::mapped_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t = {"_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t", "std::map<int,CdiZaxis,std::less<int >,std::allocator<std::pair<int const,CdiZaxis > > > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__allocator_type = {"_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__allocator_type", "std::allocator<std::pair<int const,CdiZaxis > > *|std::map<int,CdiZaxis >::allocator_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__mapped_type = {"_p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__mapped_type", "CdiZaxis *|std::map<int,CdiZaxis >::mapped_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t = {"_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t", "std::map<std::string,CdiVariable,std::less<std::string >,std::allocator<std::pair<std::string const,CdiVariable > > > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__allocator_type = {"_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__allocator_type", "std::allocator<std::pair<std::string const,CdiVariable > > *|std::map<std::string,CdiVariable >::allocator_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__mapped_type = {"_p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__mapped_type", "CdiVariable *|std::map<std::string,CdiVariable >::mapped_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t = {"_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t", "std::vector<CdiVariable,std::allocator<CdiVariable > > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__allocator_type = {"_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__allocator_type", "std::allocator<CdiVariable > *|std::vector<CdiVariable >::allocator_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type = {"_p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type", "CdiVariable *|std::vector<CdiVariable >::value_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorTdouble_std__allocatorTdouble_t_t = {"_p_std__vectorTdouble_std__allocatorTdouble_t_t", "std::vector<double,std::allocator<double > > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorTdouble_std__allocatorTdouble_t_t__allocator_type = {"_p_std__vectorTdouble_std__allocatorTdouble_t_t__allocator_type", "std::allocator<double > *|std::vector<double >::allocator_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorTfloat_std__allocatorTfloat_t_t = {"_p_std__vectorTfloat_std__allocatorTfloat_t_t", "std::vector<float,std::allocator<float > > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorTint_std__allocatorTint_t_t = {"_p_std__vectorTint_std__allocatorTint_t_t", "std::vector<int,std::allocator<int > > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorTint_std__allocatorTint_t_t__allocator_type = {"_p_std__vectorTint_std__allocatorTint_t_t__allocator_type", "std::allocator<int > *|std::vector<int >::allocator_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorTstd__string_std__allocatorTstd__string_t_t = {"_p_std__vectorTstd__string_std__allocatorTstd__string_t_t", "std::vector<std::string,std::allocator<std::string > > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorTstd__string_std__allocatorTstd__string_t_t__allocator_type = {"_p_std__vectorTstd__string_std__allocatorTstd__string_t_t__allocator_type", "std::allocator<std::string > *|std::vector<std::string >::allocator_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t = {"_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t", "std::vector<std::vector<double,std::allocator<double > >,std::allocator<std::vector<double,std::allocator<double > > > > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t__allocator_type = {"_p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t__allocator_type", "std::allocator<std::vector<double,std::allocator<double > > > *|std::vector<std::vector<double > >::allocator_type *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_std__vectorTstd__vectorTfloat_std__allocatorTfloat_t_t_std__allocatorTstd__vectorTfloat_std__allocatorTfloat_t_t_t_t = {"_p_std__vectorTstd__vectorTfloat_std__allocatorTfloat_t_t_std__allocatorTstd__vectorTfloat_std__allocatorTfloat_t_t_t_t", "std::vector<std::vector<float,std::allocator<float > >,std::allocator<std::vector<float,std::allocator<float > > > > *", 0, 0, (void*)0, 0};
+static swig_type_info _swigt__p_swig__PySwigIterator = {"_p_swig__PySwigIterator", "swig::PySwigIterator *", 0, 0, (void*)0, 0};
 static swig_type_info _swigt__p_value_type = {"_p_value_type", "value_type *", 0, 0, (void*)0, 0};
 
 static swig_type_info *swig_type_initial[] = {
@@ -28923,41 +28159,44 @@ static swig_type_info *swig_type_initial[] = {
   &_swigt__p_p_PyObject,
   &_swigt__p_p_double,
   &_swigt__p_size_type,
-  &_swigt__p_std__allocatorT_CdiVariable_t,
-  &_swigt__p_std__allocatorT_double_t,
-  &_swigt__p_std__allocatorT_int_t,
-  &_swigt__p_std__allocatorT_std__pairT_int_const_CdiGrid_t_t,
-  &_swigt__p_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t,
-  &_swigt__p_std__allocatorT_std__pairT_int_const_CdiVariable_t_t,
-  &_swigt__p_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t,
-  &_swigt__p_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t,
-  &_swigt__p_std__allocatorT_std__string_t,
-  &_swigt__p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t,
   &_swigt__p_std__invalid_argument,
-  &_swigt__p_std__lessT_int_t,
-  &_swigt__p_std__lessT_std__string_t,
-  &_swigt__p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t,
-  &_swigt__p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t,
-  &_swigt__p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t,
-  &_swigt__p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t,
-  &_swigt__p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t,
-  &_swigt__p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t,
-  &_swigt__p_std__vectorT__Tp__Alloc_t,
-  &_swigt__p_std__vectorT_double_std__allocatorT_double_t_t,
-  &_swigt__p_std__vectorT_float_std__allocatorT_float_t_t,
-  &_swigt__p_std__vectorT_int_std__allocatorT_int_t_t,
-  &_swigt__p_std__vectorT_std__string_std__allocatorT_std__string_t_t,
-  &_swigt__p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t,
-  &_swigt__p_std__vectorT_std__vectorT_float_std__allocatorT_float_t_t_std__allocatorT_std__vectorT_float_std__allocatorT_float_t_t_t_t,
-  &_swigt__p_swig__SwigPyIterator,
+  &_swigt__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t,
+  &_swigt__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__allocator_type,
+  &_swigt__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__mapped_type,
+  &_swigt__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t,
+  &_swigt__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__allocator_type,
+  &_swigt__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__mapped_type,
+  &_swigt__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t,
+  &_swigt__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__allocator_type,
+  &_swigt__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__mapped_type,
+  &_swigt__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t,
+  &_swigt__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__allocator_type,
+  &_swigt__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__mapped_type,
+  &_swigt__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t,
+  &_swigt__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__allocator_type,
+  &_swigt__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__mapped_type,
+  &_swigt__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t,
+  &_swigt__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__allocator_type,
+  &_swigt__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type,
+  &_swigt__p_std__vectorTdouble_std__allocatorTdouble_t_t,
+  &_swigt__p_std__vectorTdouble_std__allocatorTdouble_t_t__allocator_type,
+  &_swigt__p_std__vectorTfloat_std__allocatorTfloat_t_t,
+  &_swigt__p_std__vectorTint_std__allocatorTint_t_t,
+  &_swigt__p_std__vectorTint_std__allocatorTint_t_t__allocator_type,
+  &_swigt__p_std__vectorTstd__string_std__allocatorTstd__string_t_t,
+  &_swigt__p_std__vectorTstd__string_std__allocatorTstd__string_t_t__allocator_type,
+  &_swigt__p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t,
+  &_swigt__p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t__allocator_type,
+  &_swigt__p_std__vectorTstd__vectorTfloat_std__allocatorTfloat_t_t_std__allocatorTstd__vectorTfloat_std__allocatorTfloat_t_t_t_t,
+  &_swigt__p_swig__PySwigIterator,
   &_swigt__p_value_type,
 };
 
 static swig_cast_info _swigc__p_Cdi[] = {  {&_swigt__p_Cdi, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_CdiGrid[] = {  {&_swigt__p_CdiGrid, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_CdiTaxis[] = {  {&_swigt__p_CdiTaxis, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_CdiVariable[] = {  {&_swigt__p_CdiVariable, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_CdiZaxis[] = {  {&_swigt__p_CdiZaxis, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_CdiGrid[] = {  {&_swigt__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__mapped_type, 0, 0, 0},  {&_swigt__p_CdiGrid, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_CdiTaxis[] = {  {&_swigt__p_CdiTaxis, 0, 0, 0},  {&_swigt__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__mapped_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_CdiVariable[] = {  {&_swigt__p_CdiVariable, 0, 0, 0},  {&_swigt__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type, 0, 0, 0},  {&_swigt__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__mapped_type, 0, 0, 0},  {&_swigt__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__mapped_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_CdiZaxis[] = {  {&_swigt__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__mapped_type, 0, 0, 0},  {&_swigt__p_CdiZaxis, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_allocator_type[] = {  {&_swigt__p_allocator_type, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_char[] = {  {&_swigt__p_char, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_difference_type[] = {  {&_swigt__p_difference_type, 0, 0, 0},{0, 0, 0, 0}};
@@ -28968,33 +28207,36 @@ static swig_cast_info _swigc__p_mapped_type[] = {  {&_swigt__p_mapped_type, 0, 0
 static swig_cast_info _swigc__p_p_PyObject[] = {  {&_swigt__p_p_PyObject, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_p_double[] = {  {&_swigt__p_p_double, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_size_type[] = {  {&_swigt__p_size_type, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__allocatorT_CdiVariable_t[] = {  {&_swigt__p_std__allocatorT_CdiVariable_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__allocatorT_double_t[] = {  {&_swigt__p_std__allocatorT_double_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__allocatorT_int_t[] = {  {&_swigt__p_std__allocatorT_int_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__allocatorT_std__pairT_int_const_CdiGrid_t_t[] = {  {&_swigt__p_std__allocatorT_std__pairT_int_const_CdiGrid_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t[] = {  {&_swigt__p_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__allocatorT_std__pairT_int_const_CdiVariable_t_t[] = {  {&_swigt__p_std__allocatorT_std__pairT_int_const_CdiVariable_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t[] = {  {&_swigt__p_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t[] = {  {&_swigt__p_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__allocatorT_std__string_t[] = {  {&_swigt__p_std__allocatorT_std__string_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t[] = {  {&_swigt__p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_std__invalid_argument[] = {  {&_swigt__p_std__invalid_argument, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__lessT_int_t[] = {  {&_swigt__p_std__lessT_int_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__lessT_std__string_t[] = {  {&_swigt__p_std__lessT_std__string_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t[] = {  {&_swigt__p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t[] = {  {&_swigt__p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t[] = {  {&_swigt__p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t[] = {  {&_swigt__p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t[] = {  {&_swigt__p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t[] = {  {&_swigt__p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__vectorT__Tp__Alloc_t[] = {  {&_swigt__p_std__vectorT__Tp__Alloc_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__vectorT_double_std__allocatorT_double_t_t[] = {  {&_swigt__p_std__vectorT_double_std__allocatorT_double_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__vectorT_float_std__allocatorT_float_t_t[] = {  {&_swigt__p_std__vectorT_float_std__allocatorT_float_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__vectorT_int_std__allocatorT_int_t_t[] = {  {&_swigt__p_std__vectorT_int_std__allocatorT_int_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__vectorT_std__string_std__allocatorT_std__string_t_t[] = {  {&_swigt__p_std__vectorT_std__string_std__allocatorT_std__string_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t[] = {  {&_swigt__p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_std__vectorT_std__vectorT_float_std__allocatorT_float_t_t_std__allocatorT_std__vectorT_float_std__allocatorT_float_t_t_t_t[] = {  {&_swigt__p_std__vectorT_std__vectorT_float_std__allocatorT_float_t_t_std__allocatorT_std__vectorT_float_std__allocatorT_float_t_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
-static swig_cast_info _swigc__p_swig__SwigPyIterator[] = {  {&_swigt__p_swig__SwigPyIterator, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t[] = {  {&_swigt__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__allocator_type[] = {  {&_swigt__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__allocator_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__mapped_type[] = {  {&_swigt__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__mapped_type, 0, 0, 0},  {&_swigt__p_CdiGrid, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t[] = {  {&_swigt__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__allocator_type[] = {  {&_swigt__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__allocator_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__mapped_type[] = {  {&_swigt__p_CdiTaxis, 0, 0, 0},  {&_swigt__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__mapped_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t[] = {  {&_swigt__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__allocator_type[] = {  {&_swigt__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__allocator_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__mapped_type[] = {  {&_swigt__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type, 0, 0, 0},  {&_swigt__p_CdiVariable, 0, 0, 0},  {&_swigt__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__mapped_type, 0, 0, 0},  {&_swigt__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd_ [...]
+static swig_cast_info _swigc__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t[] = {  {&_swigt__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__allocator_type[] = {  {&_swigt__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__allocator_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__mapped_type[] = {  {&_swigt__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__mapped_type, 0, 0, 0},  {&_swigt__p_CdiZaxis, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t[] = {  {&_swigt__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__allocator_type[] = {  {&_swigt__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__allocator_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__mapped_type[] = {  {&_swigt__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type, 0, 0, 0},  {&_swigt__p_CdiVariable, 0, 0, 0},  {&_swigt__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__mapped_type, 0, 0, 0},  {&_swigt__p_std__mapTstd__string_CdiVariable_std__lessTstd__stri [...]
+static swig_cast_info _swigc__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t[] = {  {&_swigt__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__allocator_type[] = {  {&_swigt__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__allocator_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type[] = {  {&_swigt__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type, 0, 0, 0},  {&_swigt__p_CdiVariable, 0, 0, 0},  {&_swigt__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__mapped_type, 0, 0, 0},  {&_swigt__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_ [...]
+static swig_cast_info _swigc__p_std__vectorTdouble_std__allocatorTdouble_t_t[] = {  {&_swigt__p_std__vectorTdouble_std__allocatorTdouble_t_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__vectorTdouble_std__allocatorTdouble_t_t__allocator_type[] = {  {&_swigt__p_std__vectorTdouble_std__allocatorTdouble_t_t__allocator_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__vectorTfloat_std__allocatorTfloat_t_t[] = {  {&_swigt__p_std__vectorTfloat_std__allocatorTfloat_t_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__vectorTint_std__allocatorTint_t_t[] = {  {&_swigt__p_std__vectorTint_std__allocatorTint_t_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__vectorTint_std__allocatorTint_t_t__allocator_type[] = {  {&_swigt__p_std__vectorTint_std__allocatorTint_t_t__allocator_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__vectorTstd__string_std__allocatorTstd__string_t_t[] = {  {&_swigt__p_std__vectorTstd__string_std__allocatorTstd__string_t_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__vectorTstd__string_std__allocatorTstd__string_t_t__allocator_type[] = {  {&_swigt__p_std__vectorTstd__string_std__allocatorTstd__string_t_t__allocator_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t[] = {  {&_swigt__p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t__allocator_type[] = {  {&_swigt__p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t__allocator_type, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_std__vectorTstd__vectorTfloat_std__allocatorTfloat_t_t_std__allocatorTstd__vectorTfloat_std__allocatorTfloat_t_t_t_t[] = {  {&_swigt__p_std__vectorTstd__vectorTfloat_std__allocatorTfloat_t_t_std__allocatorTstd__vectorTfloat_std__allocatorTfloat_t_t_t_t, 0, 0, 0},{0, 0, 0, 0}};
+static swig_cast_info _swigc__p_swig__PySwigIterator[] = {  {&_swigt__p_swig__PySwigIterator, 0, 0, 0},{0, 0, 0, 0}};
 static swig_cast_info _swigc__p_value_type[] = {  {&_swigt__p_value_type, 0, 0, 0},{0, 0, 0, 0}};
 
 static swig_cast_info *swig_cast_initial[] = {
@@ -29013,33 +28255,36 @@ static swig_cast_info *swig_cast_initial[] = {
   _swigc__p_p_PyObject,
   _swigc__p_p_double,
   _swigc__p_size_type,
-  _swigc__p_std__allocatorT_CdiVariable_t,
-  _swigc__p_std__allocatorT_double_t,
-  _swigc__p_std__allocatorT_int_t,
-  _swigc__p_std__allocatorT_std__pairT_int_const_CdiGrid_t_t,
-  _swigc__p_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t,
-  _swigc__p_std__allocatorT_std__pairT_int_const_CdiVariable_t_t,
-  _swigc__p_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t,
-  _swigc__p_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t,
-  _swigc__p_std__allocatorT_std__string_t,
-  _swigc__p_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t,
   _swigc__p_std__invalid_argument,
-  _swigc__p_std__lessT_int_t,
-  _swigc__p_std__lessT_std__string_t,
-  _swigc__p_std__mapT_int_CdiGrid_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiGrid_t_t_t,
-  _swigc__p_std__mapT_int_CdiTaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiTaxis_t_t_t,
-  _swigc__p_std__mapT_int_CdiVariable_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiVariable_t_t_t,
-  _swigc__p_std__mapT_int_CdiZaxis_std__lessT_int_t_std__allocatorT_std__pairT_int_const_CdiZaxis_t_t_t,
-  _swigc__p_std__mapT_std__string_CdiVariable_std__lessT_std__string_t_std__allocatorT_std__pairT_std__string_const_CdiVariable_t_t_t,
-  _swigc__p_std__vectorT_CdiVariable_std__allocatorT_CdiVariable_t_t,
-  _swigc__p_std__vectorT__Tp__Alloc_t,
-  _swigc__p_std__vectorT_double_std__allocatorT_double_t_t,
-  _swigc__p_std__vectorT_float_std__allocatorT_float_t_t,
-  _swigc__p_std__vectorT_int_std__allocatorT_int_t_t,
-  _swigc__p_std__vectorT_std__string_std__allocatorT_std__string_t_t,
-  _swigc__p_std__vectorT_std__vectorT_double_std__allocatorT_double_t_t_std__allocatorT_std__vectorT_double_std__allocatorT_double_t_t_t_t,
-  _swigc__p_std__vectorT_std__vectorT_float_std__allocatorT_float_t_t_std__allocatorT_std__vectorT_float_std__allocatorT_float_t_t_t_t,
-  _swigc__p_swig__SwigPyIterator,
+  _swigc__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t,
+  _swigc__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__allocator_type,
+  _swigc__p_std__mapTint_CdiGrid_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiGrid_t_t_t__mapped_type,
+  _swigc__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t,
+  _swigc__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__allocator_type,
+  _swigc__p_std__mapTint_CdiTaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiTaxis_t_t_t__mapped_type,
+  _swigc__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t,
+  _swigc__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__allocator_type,
+  _swigc__p_std__mapTint_CdiVariable_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiVariable_t_t_t__mapped_type,
+  _swigc__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t,
+  _swigc__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__allocator_type,
+  _swigc__p_std__mapTint_CdiZaxis_std__lessTint_t_std__allocatorTstd__pairTint_const_CdiZaxis_t_t_t__mapped_type,
+  _swigc__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t,
+  _swigc__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__allocator_type,
+  _swigc__p_std__mapTstd__string_CdiVariable_std__lessTstd__string_t_std__allocatorTstd__pairTstd__string_const_CdiVariable_t_t_t__mapped_type,
+  _swigc__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t,
+  _swigc__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__allocator_type,
+  _swigc__p_std__vectorTCdiVariable_std__allocatorTCdiVariable_t_t__value_type,
+  _swigc__p_std__vectorTdouble_std__allocatorTdouble_t_t,
+  _swigc__p_std__vectorTdouble_std__allocatorTdouble_t_t__allocator_type,
+  _swigc__p_std__vectorTfloat_std__allocatorTfloat_t_t,
+  _swigc__p_std__vectorTint_std__allocatorTint_t_t,
+  _swigc__p_std__vectorTint_std__allocatorTint_t_t__allocator_type,
+  _swigc__p_std__vectorTstd__string_std__allocatorTstd__string_t_t,
+  _swigc__p_std__vectorTstd__string_std__allocatorTstd__string_t_t__allocator_type,
+  _swigc__p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t,
+  _swigc__p_std__vectorTstd__vectorTdouble_std__allocatorTdouble_t_t_std__allocatorTstd__vectorTdouble_std__allocatorTdouble_t_t_t_t__allocator_type,
+  _swigc__p_std__vectorTstd__vectorTfloat_std__allocatorTfloat_t_t_std__allocatorTstd__vectorTfloat_std__allocatorTfloat_t_t_t_t,
+  _swigc__p_swig__PySwigIterator,
   _swigc__p_value_type,
 };
 
@@ -29054,18 +28299,18 @@ static swig_const_info swig_const_table[] = {
 #endif
 /* -----------------------------------------------------------------------------
  * Type initialization:
- * This problem is tough by the requirement that no dynamic
- * memory is used. Also, since swig_type_info structures store pointers to
+ * This problem is tough by the requirement that no dynamic 
+ * memory is used. Also, since swig_type_info structures store pointers to 
  * swig_cast_info structures and swig_cast_info structures store pointers back
- * to swig_type_info structures, we need some lookup code at initialization.
- * The idea is that swig generates all the structures that are needed.
- * The runtime then collects these partially filled structures.
- * The SWIG_InitializeModule function takes these initial arrays out of
+ * to swig_type_info structures, we need some lookup code at initialization. 
+ * The idea is that swig generates all the structures that are needed. 
+ * The runtime then collects these partially filled structures. 
+ * The SWIG_InitializeModule function takes these initial arrays out of 
  * swig_module, and does all the lookup, filling in the swig_module.types
  * array with the correct data and linking the correct swig_cast_info
  * structures together.
  *
- * The generated swig_type_info structures are assigned statically to an initial
+ * The generated swig_type_info structures are assigned staticly to an initial 
  * array. We just loop through that array, and handle each type individually.
  * First we lookup if this type has been already loaded, and if so, use the
  * loaded structure instead of the generated one. Then we have to fill in the
@@ -29075,17 +28320,17 @@ static swig_const_info swig_const_table[] = {
  * a column is one of the swig_cast_info structures for that type.
  * The cast_initial array is actually an array of arrays, because each row has
  * a variable number of columns. So to actually build the cast linked list,
- * we find the array of casts associated with the type, and loop through it
+ * we find the array of casts associated with the type, and loop through it 
  * adding the casts to the list. The one last trick we need to do is making
  * sure the type pointer in the swig_cast_info struct is correct.
  *
- * First off, we lookup the cast->type name to see if it is already loaded.
+ * First off, we lookup the cast->type name to see if it is already loaded. 
  * There are three cases to handle:
  *  1) If the cast->type has already been loaded AND the type we are adding
  *     casting info to has not been loaded (it is in this module), THEN we
  *     replace the cast->type pointer with the type pointer that has already
  *     been loaded.
- *  2) If BOTH types (the one we are adding casting info to, and the
+ *  2) If BOTH types (the one we are adding casting info to, and the 
  *     cast->type) are loaded, THEN the cast info has already been loaded by
  *     the previous module so we just ignore it.
  *  3) Finally, if cast->type has not already been loaded, then we add that
@@ -29109,7 +28354,9 @@ SWIGRUNTIME void
 SWIG_InitializeModule(void *clientdata) {
   size_t i;
   swig_module_info *module_head, *iter;
-  int found, init;
+  int found;
+  
+  clientdata = clientdata;
   
   /* check to see if the circular list has been setup, if not, set it up */
   if (swig_module.next==0) {
@@ -29117,9 +28364,6 @@ SWIG_InitializeModule(void *clientdata) {
     swig_module.type_initial = swig_type_initial;
     swig_module.cast_initial = swig_cast_initial;
     swig_module.next = &swig_module;
-    init = 1;
-  } else {
-    init = 0;
   }
   
   /* Try and load any already created modules */
@@ -29148,12 +28392,6 @@ SWIG_InitializeModule(void *clientdata) {
     module_head->next = &swig_module;
   }
   
-  /* When multiple interpreters are used, a module could have already been initialized in
-       a different interpreter, but not yet have a pointer in this interpreter.
-       In this case, we do not want to continue adding types... everything should be
-       set up already */
-  if (init == 0) return;
-  
   /* Now work on filling in swig_module.types */
 #ifdef SWIGRUNTIME_DEBUG
   printf("SWIG_InitializeModule: size %d\n", swig_module.size);
@@ -29316,58 +28554,26 @@ extern "C" {
   
   SWIGINTERN PyObject *
   swig_varlink_repr(swig_varlinkobject *SWIGUNUSEDPARM(v)) {
-#if PY_VERSION_HEX >= 0x03000000
-    return PyUnicode_InternFromString("<Swig global variables>");
-#else
     return PyString_FromString("<Swig global variables>");
-#endif
   }
   
   SWIGINTERN PyObject *
   swig_varlink_str(swig_varlinkobject *v) {
-#if PY_VERSION_HEX >= 0x03000000
-    PyObject *str = PyUnicode_InternFromString("(");
-    PyObject *tail;
-    PyObject *joined;
-    swig_globalvar *var;
-    for (var = v->vars; var; var=var->next) {
-      tail = PyUnicode_FromString(var->name);
-      joined = PyUnicode_Concat(str, tail);
-      Py_DecRef(str);
-      Py_DecRef(tail);
-      str = joined;
-      if (var->next) {
-        tail = PyUnicode_InternFromString(", ");
-        joined = PyUnicode_Concat(str, tail);
-        Py_DecRef(str);
-        Py_DecRef(tail);
-        str = joined;
-      }
-    }
-    tail = PyUnicode_InternFromString(")");
-    joined = PyUnicode_Concat(str, tail);
-    Py_DecRef(str);
-    Py_DecRef(tail);
-    str = joined;
-#else
     PyObject *str = PyString_FromString("(");
-    swig_globalvar *var;
+    swig_globalvar  *var;
     for (var = v->vars; var; var=var->next) {
       PyString_ConcatAndDel(&str,PyString_FromString(var->name));
       if (var->next) PyString_ConcatAndDel(&str,PyString_FromString(", "));
     }
     PyString_ConcatAndDel(&str,PyString_FromString(")"));
-#endif
     return str;
   }
   
   SWIGINTERN int
   swig_varlink_print(swig_varlinkobject *v, FILE *fp, int SWIGUNUSEDPARM(flags)) {
-    char *tmp;
     PyObject *str = swig_varlink_str(v);
     fprintf(fp,"Swig global variables ");
-    fprintf(fp,"%s\n", tmp = SWIG_Python_str_AsChar(str));
-    SWIG_Python_str_DelForPy3(tmp);
+    fprintf(fp,"%s\n", PyString_AsString(str));
     Py_DECREF(str);
     return 0;
   }
@@ -29395,7 +28601,7 @@ extern "C" {
       var = var->next;
     }
     if (res == NULL && !PyErr_Occurred()) {
-      PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n);
+      PyErr_SetString(PyExc_NameError,"Unknown C global variable");
     }
     return res;
   }
@@ -29412,7 +28618,7 @@ extern "C" {
       var = var->next;
     }
     if (res == 1 && !PyErr_Occurred()) {
-      PyErr_Format(PyExc_AttributeError, "Unknown C global variable '%s'", n);
+      PyErr_SetString(PyExc_NameError,"Unknown C global variable");
     }
     return res;
   }
@@ -29421,23 +28627,19 @@ extern "C" {
   swig_varlink_type(void) {
     static char varlink__doc__[] = "Swig var link object";
     static PyTypeObject varlink_type;
-    static int type_init = 0;
+    static int type_init = 0;  
     if (!type_init) {
-      const PyTypeObject tmp = {
-        /* PyObject header changed in Python 3 */
-#if PY_VERSION_HEX >= 0x03000000
-        PyVarObject_HEAD_INIT(NULL, 0)
-#else
+      const PyTypeObject tmp
+      = {
         PyObject_HEAD_INIT(NULL)
-        0,                                  /* ob_size */
-#endif
-        (char *)"swigvarlink",              /* tp_name */
-        sizeof(swig_varlinkobject),         /* tp_basicsize */
-        0,                                  /* tp_itemsize */
-        (destructor) swig_varlink_dealloc,  /* tp_dealloc */
-        (printfunc) swig_varlink_print,     /* tp_print */
-        (getattrfunc) swig_varlink_getattr, /* tp_getattr */
-        (setattrfunc) swig_varlink_setattr, /* tp_setattr */
+        0,                                  /* Number of items in variable part (ob_size) */
+        (char *)"swigvarlink",              /* Type name (tp_name) */
+        sizeof(swig_varlinkobject),         /* Basic size (tp_basicsize) */
+        0,                                  /* Itemsize (tp_itemsize) */
+        (destructor) swig_varlink_dealloc,   /* Deallocator (tp_dealloc) */ 
+        (printfunc) swig_varlink_print,     /* Print (tp_print) */
+        (getattrfunc) swig_varlink_getattr, /* get attr (tp_getattr) */
+        (setattrfunc) swig_varlink_setattr, /* Set attr (tp_setattr) */
         0,                                  /* tp_compare */
         (reprfunc) swig_varlink_repr,       /* tp_repr */
         0,                                  /* tp_as_number */
@@ -29445,7 +28647,7 @@ extern "C" {
         0,                                  /* tp_as_mapping */
         0,                                  /* tp_hash */
         0,                                  /* tp_call */
-        (reprfunc) swig_varlink_str,        /* tp_str */
+        (reprfunc)swig_varlink_str,        /* tp_str */
         0,                                  /* tp_getattro */
         0,                                  /* tp_setattro */
         0,                                  /* tp_as_buffer */
@@ -29461,21 +28663,13 @@ extern "C" {
 #if PY_VERSION_HEX >= 0x02030000
         0,                                  /* tp_del */
 #endif
-#if PY_VERSION_HEX >= 0x02060000
-        0,                                  /* tp_version */
-#endif
 #ifdef COUNT_ALLOCS
         0,0,0,0                             /* tp_alloc -> tp_next */
 #endif
       };
       varlink_type = tmp;
-      type_init = 1;
-#if PY_VERSION_HEX < 0x02020000
       varlink_type.ob_type = &PyType_Type;
-#else
-      if (PyType_Ready(&varlink_type) < 0)
-      return NULL;
-#endif
+      type_init = 1;
     }
     return &varlink_type;
   }
@@ -29526,7 +28720,7 @@ extern "C" {
     for (i = 0; constants[i].type; ++i) {
       switch(constants[i].type) {
       case SWIG_PY_POINTER:
-        obj = SWIG_InternalNewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
+        obj = SWIG_NewPointerObj(constants[i].pvalue, *(constants[i]).ptype,0);
         break;
       case SWIG_PY_BINARY:
         obj = SWIG_NewPackedObj(constants[i].pvalue, constants[i].lvalue, *(constants[i].ptype));
@@ -29566,15 +28760,15 @@ extern "C" {
           }
         }
         if (ci) {
-          void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
-          if (ptr) {
-            size_t shift = (ci->ptype) - types;
-            swig_type_info *ty = types_initial[shift];
-            size_t ldoc = (c - methods[i].ml_doc);
-            size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
-            char *ndoc = (char*)malloc(ldoc + lptr + 10);
-            if (ndoc) {
-              char *buff = ndoc;
+          size_t shift = (ci->ptype) - types;
+          swig_type_info *ty = types_initial[shift];
+          size_t ldoc = (c - methods[i].ml_doc);
+          size_t lptr = strlen(ty->name)+2*sizeof(void*)+2;
+          char *ndoc = (char*)malloc(ldoc + lptr + 10);
+          if (ndoc) {
+            char *buff = ndoc;
+            void *ptr = (ci->type == SWIG_PY_POINTER) ? ci->pvalue : 0;
+            if (ptr) {
               strncpy(buff, methods[i].ml_doc, ldoc);
               buff += ldoc;
               strncpy(buff, "swig_ptr: ", 10);
@@ -29599,137 +28793,19 @@ extern "C" {
 #ifdef __cplusplus
 extern "C"
 #endif
-
-SWIGEXPORT 
-#if PY_VERSION_HEX >= 0x03000000
-PyObject*
-#else
-void
-#endif
-SWIG_init(void) {
-  PyObject *m, *d, *md;
-#if PY_VERSION_HEX >= 0x03000000
-  static struct PyModuleDef SWIG_module = {
-# if PY_VERSION_HEX >= 0x03020000
-    PyModuleDef_HEAD_INIT,
-# else
-    {
-      PyObject_HEAD_INIT(NULL)
-      NULL, /* m_init */
-      0,    /* m_index */
-      NULL, /* m_copy */
-    },
-# endif
-    (char *) SWIG_name,
-    NULL,
-    -1,
-    SwigMethods,
-    NULL,
-    NULL,
-    NULL,
-    NULL
-  };
-#endif
-  
-#if defined(SWIGPYTHON_BUILTIN)
-  static SwigPyClientData SwigPyObject_clientdata = {
-    0, 0, 0, 0, 0, 0, 0
-  };
-  static PyGetSetDef this_getset_def = {
-    (char *)"this", &SwigPyBuiltin_ThisClosure, NULL, NULL, NULL
-  };
-  static SwigPyGetSet thisown_getset_closure = {
-    (PyCFunction) SwigPyObject_own,
-    (PyCFunction) SwigPyObject_own
-  };
-  static PyGetSetDef thisown_getset_def = {
-    (char *)"thisown", SwigPyBuiltin_GetterClosure, SwigPyBuiltin_SetterClosure, NULL, &thisown_getset_closure
-  };
-  PyObject *metatype_args;
-  PyTypeObject *builtin_pytype;
-  int builtin_base_count;
-  swig_type_info *builtin_basetype;
-  PyObject *tuple;
-  PyGetSetDescrObject *static_getset;
-  PyTypeObject *metatype;
-  SwigPyClientData *cd;
-  PyObject *public_interface, *public_symbol;
-  PyObject *this_descr;
-  PyObject *thisown_descr;
-  int i;
-  
-  (void)builtin_pytype;
-  (void)builtin_base_count;
-  (void)builtin_basetype;
-  (void)tuple;
-  (void)static_getset;
-  
-  /* metatype is used to implement static member variables. */
-  metatype_args = Py_BuildValue("(s(O){})", "SwigPyObjectType", &PyType_Type);
-  assert(metatype_args);
-  metatype = (PyTypeObject *) PyType_Type.tp_call((PyObject *) &PyType_Type, metatype_args, NULL);
-  assert(metatype);
-  Py_DECREF(metatype_args);
-  metatype->tp_setattro = (setattrofunc) &SwigPyObjectType_setattro;
-  assert(PyType_Ready(metatype) >= 0);
-#endif
+SWIGEXPORT void SWIG_init(void) {
+  PyObject *m, *d;
   
   /* Fix SwigMethods to carry the callback ptrs when needed */
   SWIG_Python_FixMethods(SwigMethods, swig_const_table, swig_types, swig_type_initial);
   
-#if PY_VERSION_HEX >= 0x03000000
-  m = PyModule_Create(&SWIG_module);
-#else
   m = Py_InitModule((char *) SWIG_name, SwigMethods);
-#endif
-  md = d = PyModule_GetDict(m);
-  (void)md;
+  d = PyModule_GetDict(m);
   
   SWIG_InitializeModule(0);
-  
-#ifdef SWIGPYTHON_BUILTIN
-  SwigPyObject_stype = SWIG_MangledTypeQuery("_p_SwigPyObject");
-  assert(SwigPyObject_stype);
-  cd = (SwigPyClientData*) SwigPyObject_stype->clientdata;
-  if (!cd) {
-    SwigPyObject_stype->clientdata = &SwigPyObject_clientdata;
-    SwigPyObject_clientdata.pytype = SwigPyObject_TypeOnce();
-  } else if (SwigPyObject_TypeOnce()->tp_basicsize != cd->pytype->tp_basicsize) {
-    PyErr_SetString(PyExc_RuntimeError, "Import error: attempted to load two incompatible swig-generated modules.");
-# if PY_VERSION_HEX >= 0x03000000
-    return NULL;
-# else
-    return;
-# endif
-  }
-  
-  /* All objects have a 'this' attribute */
-  this_descr = PyDescr_NewGetSet(SwigPyObject_type(), &this_getset_def);
-  (void)this_descr;
-  
-  /* All objects have a 'thisown' attribute */
-  thisown_descr = PyDescr_NewGetSet(SwigPyObject_type(), &thisown_getset_def);
-  (void)thisown_descr;
-  
-  public_interface = PyList_New(0);
-  public_symbol = 0;
-  (void)public_symbol;
-  
-  PyDict_SetItemString(md, "__all__", public_interface);
-  Py_DECREF(public_interface);
-  for (i = 0; SwigMethods[i].ml_name != NULL; ++i)
-  SwigPyBuiltin_AddPublicSymbol(public_interface, SwigMethods[i].ml_name);
-  for (i = 0; swig_const_table[i].name != 0; ++i)
-  SwigPyBuiltin_AddPublicSymbol(public_interface, swig_const_table[i].name);
-#endif
-  
   SWIG_InstallConstants(d,swig_const_table);
   
+  
   SWIG_Python_SetConstant(d, "CHARSIZE",SWIG_From_int(static_cast< int >(128)));
-#if PY_VERSION_HEX >= 0x03000000
-  return m;
-#else
-  return;
-#endif
 }
 
diff --git a/libcdi/m4/acx_cfortran_flags.m4 b/libcdi/m4/acx_cfortran_flags.m4
new file mode 100644
index 0000000..35fe2cd
--- /dev/null
+++ b/libcdi/m4/acx_cfortran_flags.m4
@@ -0,0 +1,171 @@
+dnl acx_fc_c_link.m4 --- transform library c flags into version
+dnl                      that suits the fortran compiler
+dnl
+dnl Copyright  (C)  2011  Thomas Jahns <jahns at dkrz.de>
+dnl
+dnl Version: 1.0
+dnl Keywords:
+dnl Author: Thomas Jahns <jahns at dkrz.de>
+dnl Maintainer: Thomas Jahns <jahns at dkrz.de>
+dnl URL: https://www.dkrz.de/redmine/projects/show/scales-ppm
+dnl
+dnl Redistribution and use in source and binary forms, with or without
+dnl modification, are  permitted provided that the following conditions are
+dnl met:
+dnl
+dnl Redistributions of source code must retain the above copyright notice,
+dnl this list of conditions and the following disclaimer.
+dnl
+dnl Redistributions in binary form must reproduce the above copyright
+dnl notice, this list of conditions and the following disclaimer in the
+dnl documentation and/or other materials provided with the distribution.
+dnl
+dnl Neither the name of the DKRZ GmbH nor the names of its contributors
+dnl may be used to endorse or promote products derived from this software
+dnl without specific prior written permission.
+dnl
+dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+dnl IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+dnl TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+dnl PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+dnl OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+dnl
+dnl ACX_FC_XLF_QEXTNAME_ADD_APPENDUS
+dnl Test if compiler is xlf and if -qextname is in use.
+dnl Add -Dappendus to CPPFLAGS if the above applies.
+dnl
+AC_DEFUN([ACX_XLF_QEXTNAME_ADD_APPENDUS],
+  [AS_CASE([$host],
+     [*-ibm-aix*],
+     [AC_MSG_CHECKING([if -Dappendus needs to be added to CPPFLAGS for cfortran.h])
+      AS_IF([$CC -qversion 2>&1 | grep '^IBM XL C' >/dev/null],
+        [acx_temp_qextname_f77flags=`echo "$FFLAGS" | sed -n '/-qextname/{ s/^\(.* \)*-qextname\( .*\)*$/-qextname/;p;}'`
+         acx_temp_qextname_fcflags=`echo "$FCFLAGS" | sed -n '/-qextname/{ s/^\(.* \)*-qextname\( .*\)*$/-qextname/;p;}'`
+      dnl pretend the same option as for FC was used if F77 isn't used at all
+      dnl also in case a non-xl compiler is used it will append an underscore
+         AC_PROVIDE_IFELSE([AC_PROG_F77],,
+           [AC_PROVIDE_IFELSE([AC_PROG_FC],
+              [acx_temp_qextname_f77flags=$acx_temp_qextname_fcflags],
+              [m4_fatal([AC_PROG_F77 or AC_PROG_FC must have been invoked prior to ACX_XLF_QEXTNAME_ADD_APPENDUS])])])
+      dnl and vice versa for FC
+         AC_PROVIDE_IFELSE([AC_PROG_FC],
+           [AS_IF([$FC -qversion 2>&1 | grep '^IBM XL Fortran' >/dev/null],,
+              [acx_temp_qextname_fcflags=-qextname])],
+           [AC_PROVIDE_IFELSE([AC_PROG_F77],
+              [acx_temp_qextname_fcflags=$acx_temp_qextname_f77flags])])
+         AS_CASE([x"$acx_temp_qextname_fcflags$acx_temp_qextname_f77flags"],
+           [x-qextname],
+           [AC_MSG_ERROR([Option -qextname must be provided consistently to F77 and FC])],
+           [x-qextname-qextname],
+           [AC_MSG_RESULT([yes])
+            CPPFLAGS="${CPPFLAGS+$CPPFLAGS }-Dappendus"],
+           [AC_MSG_RESULT([no])])
+        ],[AC_MSG_RESULT([no])])])])
+dnl
+dnl automate flag elicitation for cfortran.h
+AC_DEFUN([_ACX_FIND_CFORTRAN_DEF],
+  [AC_REQUIRE([AC_CANONICAL_HOST])
+   _AC_FORTRAN_ASSERT
+   AC_LANG_CASE([Fortran],[save_FC=$FC ; acx_FC=$FC],
+     [Fortran 77],[save_F77=$F77 ; acx_FC=$F77])
+   AS_CASE([$host],
+     [x86_64-*-linux-*|i*86-*-linux-*|*-apple-darwin*|ia64-*-linux-*|x86_64-*-freebsd*|i*86-*-freebsd*],
+     [acx_temp=`$acx_FC -V 2>&1`
+      AS_IF([echo "$acx_temp" | grep '^Copyright.*\(The Portland Group\|NVIDIA CORPORATION\)' >/dev/null],
+        [AS_VAR_SET([acx_cf_flag],[-DgFortran])],
+        [echo "$acx_temp" | grep '^NAG Fortran Compiler Release' >/dev/null],
+        [AS_VAR_SET([acx_cf_flag],[-DNAGf90Fortran])],
+        [echo "$acx_temp" | grep '^Intel(R) Fortran.*Compiler' >/dev/null],
+        [AS_VAR_SET([acx_cf_flag],[-DgFortran])],
+        [echo "$acx_temp" | grep '^Cray Fortran' >/dev/null],
+        [AS_VAR_SET([acx_cf_flag],[-DgFortran])],
+        [acx_temp=`$acx_FC --version 2>&1` \
+         && echo $acx_temp | grep '^GNU Fortran' >/dev/null],
+        [AS_IF([echo $acx_temp | grep g77 >/dev/null],
+           [AS_VAR_SET([acx_cf_flag],[-Dg77Fortran])],
+           [dnl assume gfortran
+dnl check if compiling with f2c bindings or with default bindings
+            AS_IF([echo "]AC_LANG_CASE([Fortran],[$FCFLAGS],
+              [Fortran 77],[$FFLAGS])[" | grep '^\(.* \)*-ff2c\( .*\)*$' >/dev/null],
+              [AS_VAR_SET([acx_cf_flag],[-Df2cFortran])],
+              [AS_VAR_SET([acx_cf_flag],[-DgFortran])])])],
+        [acx_temp=`$acx_FC -v 2>&1` \
+         && echo $acx_temp | grep '^f2c'],
+        [AS_VAR_SET([acx_cf_flag],[-Df2cFortran])])],
+     [*-ibm-aix*],
+     [dnl xlc set _IBMR2 so nothing needs to be done
+      AS_IF([$CC -qversion 2>&1 | grep '^IBM XL C' >/dev/null],,
+        [dnl but for other compilers set IBMR2Fortran
+         AS_VAR_SET([acx_cf_flag],[-DIBMR2Fortran])])
+     ],
+     [*-*-hpux*],
+     [AS_VAR_SET([acx_cf_flag],[-DhpuxFortran])],
+     [sx*-*-*|es*-*-*],
+     [dnl fixme: make sure user is actually using sxf90
+dnl but currently there is no alternative I know of
+      AS_VAR_SET([acx_cf_flag],[-DSXFortran])])])
+
+AC_DEFUN([ACX_FIND_CFORTRAN_DEF],
+  [AC_CACHE_CHECK([C preprocessor flags for Fortran calling convention cfortran.h],
+     [acx_cv_cf_flag],
+     [acx_cv_cf_flag=''
+dnl test if user already provided a flag
+      AS_FOR([MACRO],[macro],[pgiFortran NAGf90Fortran f2cFortran hpuxFortran apolloFortran sunFortran IBMR2Fortran CRAYFortran PATHSCALE_COMPILER gFortran mipsFortran DECFortran vmsFortran CONVEXFortran PowerStationFortran AbsoftUNIXFortran AbsoftProFortran SXFortran],
+        [acx_temp=`echo "$CPPFLAGS $CFLAGS" | sed -n 's/^\(.* \)*-D\('"MACRO"'\)\( .*\)*$/\2/;t print
+b
+: print
+p'`
+         AS_IF([test x"$acx_temp" != x],
+           [AS_IF([test x"$acx_cv_cf_flag" = x],
+              [acx_cv_cf_flag="$acx_temp (user-specified)"],
+              [echo ; echo '"'"$acx_cv_cf_flag $acx_temp"'"'
+               AC_MSG_ERROR([Multiple specification of cfortran.h flags])])])])
+dnl find automatically from machine/compiler
+      AS_IF([test x"$acx_cv_cf_flag" = x],
+        [AC_PROVIDE_IFELSE([AC_PROG_FC],
+           [AS_IF([test -n "$FC" -a X"$FC" != Xno],
+              [AC_LANG_PUSH([Fortran])
+               AS_VAR_PUSHDEF([acx_cf_flag],[acx_cv_]_AC_LANG_ABBREV[_cf_flag])
+               _ACX_FIND_CFORTRAN_DEF
+               AS_VAR_POPDEF([acx_cf_flag])
+               AC_LANG_POP([Fortran])])])
+         AC_PROVIDE_IFELSE([AC_PROG_F77],
+           [AS_IF([test -n "$F77" -a X"$F77" != Xno],
+              [AC_LANG_PUSH([Fortran 77])
+               AS_VAR_PUSHDEF([acx_cf_flag],[acx_cv_]_AC_LANG_ABBREV[_cf_flag])
+               _ACX_FIND_CFORTRAN_DEF
+               AS_VAR_POPDEF([acx_cf_flag])
+               AC_LANG_POP([Fortran 77])])])
+dnl check f77 flag matches fc flag
+         AC_PROVIDE_IFELSE([AC_PROG_F77],
+           [AC_PROVIDE_IFELSE([AC_PROG_FC],
+              [dnl both FC and F77 are configured
+               AS_IF([test -z "$F77" -o X"$F77" = Xno],
+                 [acx_cv_cf_flag="$acx_cv_fc_cf_flag (probed)"],
+                 [test -z "$FC" -o X"$FC" = Xno],
+                 [acx_cv_cf_flag="$acx_cv_f77_cf_flag (probed)"],
+                 [AS_IF([test x"$acx_cv_f77_cf_flag" = x"$acx_cv_fc_cf_flag"],
+                    [acx_cv_cf_flag="$acx_cv_f77_cf_flag (probed)"],
+                    [AC_MSG_ERROR([cfortran.h flag for $F77 does not match the flag for $FC.
+Have you configured compatible compilers?])])])
+              ],
+              [acx_cv_cf_flag="$acx_cv_f77_cf_flag (probed)"])],
+           [acx_cv_cf_flag="$acx_cv_fc_cf_flag (probed)"])
+        ])
+     ])
+dnl now that flag is established, add (probed) defines to CPPFLAGS
+   AS_IF([echo "$acx_cv_cf_flag" | grep ' (probed)$' >/dev/null],
+     [CPPFLAGS="${CPPFLAGS+$CPPFLAGS }`echo "$acx_cv_cf_flag" | sed 's/ (probed)$//'`"])
+  ])
+dnl
+dnl Local Variables:
+dnl mode: autoconf
+dnl license-project-url: "https://www.dkrz.de/redmine/projects/show/scales-ppm"
+dnl license-default: "bsd"
+dnl End:
diff --git a/libcdi/m4/acx_check_cfortran.m4 b/libcdi/m4/acx_check_cfortran.m4
new file mode 100644
index 0000000..c69ebd0
--- /dev/null
+++ b/libcdi/m4/acx_check_cfortran.m4
@@ -0,0 +1,275 @@
+dnl acx_check_cfortran.m4 --- test if a program compiled from
+dnl                           a main Fortran program and
+dnl                           C functions gives expected results
+dnl
+dnl Copyright  (C)  2013  Thomas Jahns <jahns at dkrz.de>
+dnl
+dnl Version: 1.0
+dnl Keywords:
+dnl Author: Thomas Jahns <jahns at dkrz.de>
+dnl Maintainer: Thomas Jahns <jahns at dkrz.de>
+dnl URL: https://www.dkrz.de/redmine/projects/show/scales-ppm
+dnl
+dnl Redistribution and use in source and binary forms, with or without
+dnl modification, are  permitted provided that the following conditions are
+dnl met:
+dnl
+dnl Redistributions of source code must retain the above copyright notice,
+dnl this list of conditions and the following disclaimer.
+dnl
+dnl Redistributions in binary form must reproduce the above copyright
+dnl notice, this list of conditions and the following disclaimer in the
+dnl documentation and/or other materials provided with the distribution.
+dnl
+dnl Neither the name of the DKRZ GmbH nor the names of its contributors
+dnl may be used to endorse or promote products derived from this software
+dnl without specific prior written permission.
+dnl
+dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+dnl IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+dnl TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+dnl PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+dnl OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+dnl
+dnl helper function to emit Fortran test code
+AC_DEFUN([_ACX_CHECK_CFORTRAN_FC],
+  [AC_LANG_PUSH([Fortran])
+         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+[      MODULE conftest_data
+      IMPLICIT NONE
+      PRIVATE
+      REAL :: ri
+      PUBLIC :: ri
+      END MODULE conftest_data
+
+      FUNCTION cftstf(v) RESULT(r)
+      USE conftest_data, ONLY: ri
+      REAL, INTENT(in) :: v
+      REAL :: r
+      r = v * 100.0
+      ri = 1.0 / v
+      END FUNCTION cftstf])],
+           [_AC_RUN_LOG([mv "conftest.$ac_objext" "conftest_f.$ac_objext"],
+              [_AS_ECHO_LOG([Renaming Fortran object file.])])
+            save_LIBS=$LIBS
+            LIBS="conftest_c.$ac_objext conftest_f.$ac_objext $LIBS"
+            AC_RUN_IFELSE([AC_LANG_PROGRAM(,
+[      USE conftest_data, ONLY: ri
+      IMPLICIT NONE
+      INTERFACE
+       FUNCTION cftstc(i, v, p, q) RESULT(f)
+         INTEGER, INTENT(in) :: i
+         REAL, INTENT(in) :: v
+         INTEGER, INTENT(out) :: p
+         REAL, INTENT(out) :: q
+         REAL :: f
+       END FUNCTION cftstc
+       FUNCTION chtst() result(s)
+         CHARACTER(99) :: s
+       END FUNCTION chtst
+      END INTERFACE
+      REAL, PARAMETER :: eps = 10e-6
+      REAL :: foo, boo, too
+      INTEGER :: bar, baz, i
+      CHARACTER(99) :: aaaaaa
+      bar = 5
+      foo = 0.3
+      too = cftstc(bar, foo, baz, boo)
+      IF (ABS(baz - NINT(bar * foo)) /= 0) THEN
+        WRITE (0, '(2(a,i0))') "error checking, when baz, baz=", baz, &
+             ", NINT(bar * foo) =", NINT(bar * foo)
+        FLUSH(0)
+        CALL err_exit
+      END IF
+      IF (ABS((ri - 1.0 / (bar * foo)) / ABS(ri)) > eps)  THEN
+        WRITE (0, '(2(a,g24.15))') "error checking ri, ri=", ri, ", 1.0 / &
+             &(bar * foo) = ", 1.0 / (bar * foo)
+        FLUSH(0)
+        CALL err_exit
+      END IF
+      IF (ABS((boo - (bar * foo * 100.0))/ABS(boo)) > eps)  THEN
+        WRITE (0, '(2(a,g24.15))') "error checking boo, boo=", boo, &
+             ", bar * foo * 100.0 = ", bar * foo * 100.0
+        FLUSH(0)
+        CALL err_exit
+      END IF
+      IF (too /= boo) THEN
+        WRITE (0, '(2(a,g24.15))') "error checking too vs. boo, too=", too, &
+             ", boo = ", boo
+        FLUSH(0)
+        CALL err_exit
+      END IF
+      aaaaaa = chtst()
+      DO i = 1, 99
+        IF (aaaaaa(i:i) /= 'A') THEN
+          WRITE (0, '(a,i0,a)') "error checking aaaaaa(", i, ")=", &
+              aaaaaa(i:i)
+          FLUSH(0)
+          CALL err_exit
+        END IF
+      END DO])],
+              [acx_cv_cfortran_works=yes],
+              [acx_cv_cfortran_works="error"],
+              [AC_MSG_NOTICE([Skipping run test for cfortran.h in cross-compilation mode,])
+	       AC_MSG_NOTICE([link test succeeded.])
+               acx_cv_cfortran_works=yes])
+	    LIBS=$save_LIBS],
+           [acx_cv_cfortran_works="error compiling Fortran subroutine"])
+         AC_LANG_POP([Fortran])])
+
+dnl helper function to emit Fortran 77 test code
+AC_DEFUN([_ACX_CHECK_CFORTRAN_F77],
+  [AC_LANG_PUSH([Fortran 77])
+         AC_COMPILE_IFELSE([AC_LANG_SOURCE(
+[      REAL FUNCTION CFTSTF(v)
+      REAL RI
+      COMMON /CFTSTD/ RI
+      REAL V
+      REAL R
+      CFTSTF = V * 100.0
+      RI = 1.0 / V
+      END FUNCTION CFTSTF])],
+           [_AC_RUN_LOG([mv "conftest.$ac_objext" "conftest_f.$ac_objext"],
+              [_AS_ECHO_LOG([Renaming Fortran object file.])])
+            save_LIBS=$LIBS
+            LIBS="conftest_c.$ac_objext conftest_f.$ac_objext $LIBS"
+            AC_RUN_IFELSE([AC_LANG_PROGRAM(,
+[      REAL RI
+      COMMON /CFTSTD/ RI
+      REAL EPS
+      PARAMETER(EPS=10E-6)
+      REAL FOO, BOO, TOO
+      INTEGER BAR, BAZ, I
+      CHARACTER(99) AAAAAA
+      EXTERNAL CFTSTC, CFTSTF, CHTST, ERR_EXIT
+      REAL CFTSTC, CFTSTF
+      CHARACTER(99) CHTST
+      BAR = 5
+      FOO = 0.3
+      TOO = CFTSTC(BAR, FOO, BAZ, BOO)
+      IF (ABS(BAZ - NINT(BAR * FOO)) /= 0) THEN
+        WRITE (0, '(2(A,I0))') "ERROR CHECKING, WHEN BAZ, BAZ=", BAZ,
+     &       ", NINT(BAR * FOO) =", NINT(BAR * FOO)
+        CALL ERR_EXIT
+      END IF
+      IF (ABS((RI - 1.0 / (BAR * FOO)) / ABS(RI)) > EPS)  THEN
+        WRITE (0, '(2(A,F24.15))') "ERROR CHECKING RI, RI=", RI, ",
+     &       1.0 / (BAR * FOO) = ", 1.0 / (BAR * FOO)
+        CALL err_exit
+      END IF
+      IF (ABS((BOO - (BAR * FOO * 100.0))/ABS(BOO)) > EPS)  THEN
+        WRITE (0, '(2(A,F24.15))') "ERROR CHECKING BOO, BOO=", BOO,
+     &       ", BAR * FOO * 100.0 = ", BAR * FOO * 100.0
+        CALL ERR_EXIT
+      END IF
+      IF (TOO /= BOO) THEN
+        WRITE (0, '(2(A,F24.15))') "ERROR CHECKING TOO VS. BOO, TOO=",
+     &       TOO, ", BOO = ", BOO
+        CALL ERR_EXIT
+      END IF
+      AAAAAA = CHTST()
+      DO i = 1, 99
+        IF (AAAAAA(I:I) /= 'A') THEN
+          WRITE (0, '(A,I0,2A)') "ERROR CHECKING AAAAAA(", I, ")=",
+     &        AAAAAA(I:I)
+          CALL ERR_EXIT
+        END IF
+      END DO])],
+              [acx_cv_cfortran_works=yes],
+              [acx_cv_cfortran_works="error"],
+              [AC_MSG_NOTICE([Skipping run test for cfortran.h in cross-compilation mode,])
+	       AC_MSG_NOTICE([link test succeeded.])
+               acx_cv_cfortran_works=yes])
+	    LIBS=$save_LIBS],
+           [acx_cv_cfortran_works="error compiling Fortran subroutine"])
+         AC_LANG_POP([Fortran 77])])
+
+dnl ACX_CHECK_CFORTRAN([OPTIONAL-CFORTRAN-INC-DIR],[ACTION-IF-SUCCESS],
+dnl                    [ACTION-IF-FAILED])
+dnl Test if C compiler can produce objects that link fine to Fortran programs
+dnl when using cfortran.h.
+dnl
+AC_DEFUN([ACX_CHECK_CFORTRAN],
+  [AC_CACHE_CHECK([if C externals constructed with cfortran.h work],
+     [acx_cv_cfortran_works],
+     [acx_cv_cfortran_works=no
+      save_CPPFLAGS=$CPPFLAGS
+      CPPFLAGS="-I]m4_ifval([$1],[$1],[$srcdir/include])[ $CPPFLAGS"
+dnl build C function
+      AC_LANG_PUSH([C])
+      AC_COMPILE_IFELSE([AC_LANG_SOURCE([@%:@include "cfortran.h"
+@%:@include <math.h>
+@%:@include <stdio.h>
+@%:@include <stdlib.h>
+
+PROTOCCALLSFFUN1(FLOAT,CFTSTF,cftstf,FLOAT)
+#define conftest_F(v) \
+  CCALLSFFUN1(CFTSTF,cftstf,FLOAT,(v));
+
+static float
+cftstC(int i, float v, int *p, float *q)
+{
+  float f;
+  *p = (int)roundf(v * i);
+  *q = f = conftest_F(v * i);
+  return f;
+}
+
+FCALLSCFUN4(FLOAT,cftstC,CFTSTC,cftstc,INT,FLOAT,PINT,PFLOAT)
+
+/* test string returns */
+static const char *
+conftest_str_C(void)
+{
+  static const char msg@<:@100@:>@ = "AAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
+    "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA";
+  return msg;
+}
+
+FCALLSCFUN0(STRING,conftest_str_C,CHTST,chtst)
+
+/* This function is required simply because some Fortran compilers
+ * won't stop with exit code n when encountering STOP n */
+static void
+errExit(void)
+{
+  exit(1);
+}
+
+FCALLSCSUB0(errExit,ERR_EXIT,err_exit)
+
+])],
+        [_AC_RUN_LOG([mv "conftest.$ac_objext" "conftest_c.$ac_objext"],
+           [_AS_ECHO_LOG([Renaming C object file.])])
+         AC_PROVIDE_IFELSE([AC_PROG_FC],[_ACX_CHECK_CFORTRAN_FC])
+         AC_PROVIDE_IFELSE([AC_PROG_F77],[_ACX_CHECK_CFORTRAN_F77])
+        ],
+        [acx_cv_cfortran_works="compiling with cfortran.h failed"])
+      AC_LANG_POP([C])
+      CPPFLAGS=$save_CPPFLAGS
+     ])
+   m4_ifval([$3],
+     [AS_IF([test x"$acx_cv_cfortran_works" = xyes],[$2],[$3])],
+     [AS_CASE([x"$acx_cv_cfortran_works"],
+       [x"error"],
+       [AC_MSG_FAILURE([Linking/Running with C EXTERNAL built with cfortran.h does not work!])],
+       [x"compiling with cfortran.h failed"],
+       [AC_MSG_FAILURE([Compilation with cfortran.h is not working!])],
+       [x"error compiling Fortran subroutine"],
+       [AC_MSG_FAILURE([compilation of simple Fortran source failed!])],
+       [xyes],[$2],
+       [AC_MSG_FAILURE([Unexpected error when linking C and Fortran via cfortran.h!])])])
+  ])
+dnl
+dnl Local Variables:
+dnl mode: autoconf
+dnl license-project-url: "https://www.dkrz.de/redmine/projects/show/scales-ppm"
+dnl license-default: "bsd"
+dnl End:
diff --git a/libcdi/m4/acx_check_strptr_convert.m4 b/libcdi/m4/acx_check_strptr_convert.m4
index 26f95f4..157e33c 100644
--- a/libcdi/m4/acx_check_strptr_convert.m4
+++ b/libcdi/m4/acx_check_strptr_convert.m4
@@ -1,4 +1,4 @@
-dnl acx_fc_check_strprt_convert.m4 --- unset a shell variable
+dnl acx_fc_check_strprt_convert.m4 --- check F2003 string pointer conversion
 dnl
 dnl Copyright  (C)  2010  Thomas Jahns <jahns at dkrz.de>
 dnl
@@ -37,8 +37,7 @@ dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 dnl
 dnl Commentary:
 dnl
-dnl FIXME: this is currently only a placeholder that expects unset to
-dnl be present although it's not universally available
+dnl Check if FC can handle complex string pointer conversions.
 dnl
 dnl
 dnl Code:
diff --git a/libcdi/m4/acx_lt_problems.m4 b/libcdi/m4/acx_lt_problems.m4
new file mode 100644
index 0000000..f2e1e58
--- /dev/null
+++ b/libcdi/m4/acx_lt_problems.m4
@@ -0,0 +1,96 @@
+dnl acx_lt_problems.m4 --- prevent problematic libtool build configurations
+dnl
+dnl Copyright  (C)  2011  Thomas Jahns <jahns at dkrz.de>
+dnl
+dnl Version: 1.0
+dnl Keywords:
+dnl Author: Thomas Jahns <jahns at dkrz.de>
+dnl Maintainer: Thomas Jahns <jahns at dkrz.de>
+dnl URL: https://www.dkrz.de/redmine/projects/show/scales-ppm
+dnl
+dnl Redistribution and use in source and binary forms, with or without
+dnl modification, are  permitted provided that the following conditions are
+dnl met:
+dnl
+dnl Redistributions of source code must retain the above copyright notice,
+dnl this list of conditions and the following disclaimer.
+dnl
+dnl Redistributions in binary form must reproduce the above copyright
+dnl notice, this list of conditions and the following disclaimer in the
+dnl documentation and/or other materials provided with the distribution.
+dnl
+dnl Neither the name of the DKRZ GmbH nor the names of its contributors
+dnl may be used to endorse or promote products derived from this software
+dnl without specific prior written permission.
+dnl
+dnl THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
+dnl IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+dnl TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
+dnl PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
+dnl OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+dnl EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+dnl PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
+dnl PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
+dnl LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
+dnl NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+dnl SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+dnl
+dnl ACX_LT_PROBLEMS
+dnl Test if compiler is able to produce working shared objects
+dnl and prevent builds of shared libraries that would not work anyway.
+dnl
+dnl The following problems are known so far:
+dnl
+dnl - Intel ifort versions 15.0.1, 15.0.2 or 15.0.3 compile the Fortran
+dnl     runtime into any shared object, thus producing various
+dnl     interpositioning problems with little likelyness that
+dnl     executables linking the shared objects can actually work.
+dnl
+dnl - IBM mp-compilers (mpcc, mpcc_r, mpCC, mpCC_r, mpxlf, mpxlf_r,
+dnl     mpxlf2003_r, mpxlf90, mpxlf90_r, mpxlf95, mpxlf95_r) link
+dnl     shared objects with linker option -binitfini:poe_remote_main
+dnl     even though this option should only be set for executables, it
+dnl     causes a duplicate exit handler that fails and clobbers the
+dnl     programs exit status (set to 128).
+dnl
+AC_DEFUN([_ACX_LT_PROBLEMS],
+  [AC_REQUIRE([AC_CANONICAL_HOST])
+   AC_LANG_CASE([Fortran],[acx_Comp=$FC],
+     [Fortran 77],[acx_Comp=$F77],
+     [C],[acx_Comp=$CC])
+   _AS_ECHO_LOG([testing if $acx_Comp cannot build working shared objects])
+   AS_CASE([$host],
+     [*-ibm-aix*],
+     [AS_IF([$acx_Comp -G -v 2>&1 | grep ' -binitfini:poe_remote_main ' >/dev/null],
+        [acx_cv_disable_shared=yes])],
+     [x86_64-*-linux-*|i*86-*-linux-*|*-apple-darwin*|ia64-*-linux-*|x86_64-*-freebsd*|i*86-*-freebsd*],
+     [AS_IF([$acx_Comp -V 2>&1 | grep '^Intel(R).*Fortran.*Compiler.*Version 15.0.@<:@123@:>@' >/dev/null],
+        [acx_cv_disable_shared=yes])])
+   _AS_ECHO_LOG([result: $acx_cv_disable_shared])])
+dnl
+dnl run test for C and Fortran compilers
+AC_DEFUN([ACX_LT_PROBLEMS],
+  [AS_IF([test x"$enable_shared" != xno],
+     [AC_CACHE_CHECK([any compiler has problems building shared objects],
+        [acx_cv_disable_shared],
+        [acx_cv_disable_shared=no
+         AC_PROVIDE_IFELSE([AC_PROG_FC],
+           [AC_LANG_PUSH([Fortran])
+            _ACX_LT_PROBLEMS
+            AC_LANG_POP([Fortran])])
+         AC_PROVIDE_IFELSE([AC_PROG_F77],
+           [AC_LANG_PUSH([Fortran 77])
+            _ACX_LT_PROBLEMS
+            AC_LANG_POP([Fortran 77])])
+         AC_PROVIDE_IFELSE([AC_PROG_CC],
+           [AC_LANG_PUSH([C])
+            _ACX_LT_PROBLEMS
+            AC_LANG_POP([C])])])
+       AS_IF([test x"$acx_cv_disable_shared" = xyes],
+         [enable_shared=no])])])
+dnl
+dnl Local Variables:
+dnl mode: autoconf
+dnl license-project-url: "https://www.dkrz.de/redmine/projects/show/scales-ppm"
+dnl license-default: "bsd"
+dnl End:
diff --git a/libcdi/m4/kpse_libtool.m4 b/libcdi/m4/kpse_libtool.m4
new file mode 100644
index 0000000..a0286fb
--- /dev/null
+++ b/libcdi/m4/kpse_libtool.m4
@@ -0,0 +1,37 @@
+# Public macros for the TeX Live (TL) tree.
+# Copyright (C) 1995 - 2009 Karl Berry <tex-live at tug.org>
+# Copyright (C) 2009, 2010 Peter Breitenlohner <tex-live at tug.org>
+#
+# This file is free software; the copyright holders
+# give unlimited permission to copy and/or distribute it,
+# with or without modifications, as long as this notice is preserved.
+
+# serial 1
+
+# _KPSE_USE_LIBTOOL()
+# Switch link tests over to use libtool so as not to require dependent
+# libraries to be listed explicitly.
+# Extended for Fortran by Thomas Jahns <jahns at dkrz.de>, 2015
+# -------------------
+AC_DEFUN([_KPSE_USE_LIBTOOL],
+[## $0: Generate a libtool script for use in configure tests
+AC_PROVIDE_IFELSE([LT_INIT], ,
+                  [m4_fatal([$0: requires libtool])])[]dnl
+LT_OUTPUT
+m4_append([AC_LANG(C)],
+[ac_link="./libtool --mode=link --tag=CC $ac_link"
+])[]dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+[m4_append([AC_LANG(C++)],
+[ac_link="./libtool --mode=link --tag=CXX $ac_link"
+])])[]dnl
+AC_PROVIDE_IFELSE([AC_PROG_FC],
+[m4_append([AC_LANG(Fortran)],
+[ac_link="./libtool --mode=link --tag=FC $ac_link"
+])])[]dnl
+AC_PROVIDE_IFELSE([AC_PROG_F77],
+[m4_append([AC_LANG(Fortran 77)],
+[ac_link="./libtool --mode=link --tag=F77 $ac_link"
+])])[]dnl
+AC_LANG(_AC_LANG)[]dnl
+]) # _KPSE_USE_LIBTOOL
diff --git a/libcdi/m4/starlink_fpp.m4 b/libcdi/m4/starlink_fpp.m4
index e09f132..7178f3e 100644
--- a/libcdi/m4/starlink_fpp.m4
+++ b/libcdi/m4/starlink_fpp.m4
@@ -284,7 +284,7 @@ dnl preprocessing failed. So this command doesn't work.
 # _ACX_SL_PROG_FPP([SUFFIX], [ACTION-IF-FOUND], [ACTION-IF-NOT-FOUND])
 # ------------
 # Try to figure out how to preprocess files with the given suffix
-# for use with the selected Fortran compiler
+# just like the selected Fortran compiler does
 #
 # Must be run after _ACX_SL_PROG_FC_CPP
 AC_DEFUN([_ACX_SL_PROG_FPP],
@@ -305,12 +305,9 @@ AC_DEFUN([_ACX_SL_PROG_FPP],
            `cd $srcdir ; pwd`/util/xlfpreproc-wrapper \
            `cd $srcdir ; pwd`/util/sunf95preproc-wrapper \
            `cd $srcdir ; pwd`/util/crayftnpreproc-wrapper \
-           "$FC -F" "$FC -F -fpp" "$FC -E" "$FC -E" "$FC -E -cpp" \
+           "$FC -F" "$FC -F -fpp" "$FC -E" "$FC -E -cpp" \
            "$FC $FCFLAGS -F" "$FC $FCFLAGS -E" "$FC $FCFLAGS -E" \
-           "$FC $FCFLAGS -E -cpp" "$FC $FCFLAGS -x f95-cpp-input -E -P" \
-           "${F77-f77} -F" "${F77-f77} -E" 'fpp' \
-           "$CPP" "$CPP -x c" 'cpp' '/lib/cpp' \
-           '/usr/ccs/lib/cpp' 'g77 -E' '${CC-cc} -E'
+           "$FC $FCFLAGS -E -cpp" "$FC $FCFLAGS -x f95-cpp-input -E -P"
          do
            _ACX_SL_TEST_FPP([$ac_fpp],[$acx_sl_fpp_srcext],[FPP="$ac_fpp"
               break])
diff --git a/libcdi/src/Makefile.am b/libcdi/src/Makefile.am
index ceaa0d1..b00051d 100644
--- a/libcdi/src/Makefile.am
+++ b/libcdi/src/Makefile.am
@@ -28,8 +28,6 @@ libcdi_la_SOURCES = 	 \
 	cdi_error.c      \
 	cdi_limits.h	 \
 	cdi_util.c       \
-	cdiFortran.c     \
-	cfortran.h       \
 	cgribex.h	 \
 	cgribexlib.c  	 \
 	datetime.h	 \
@@ -43,6 +41,7 @@ libcdi_la_SOURCES = 	 \
 	dtypes.h	 \
 	error.c        	 \
 	error.h	 	 \
+	exse.h	 	 \
 	extra.h	 	 \
 	extralib.c       \
 	file.c         	 \
@@ -51,7 +50,6 @@ libcdi_la_SOURCES = 	 \
 	gaussgrid.h	 \
 	gribapi.c  	 \
 	gribapi.h	 \
-	gribapi_utilities.c \
 	gribapi_utilities.h \
 	grid.c           \
 	grid.h	 	 \
@@ -67,8 +65,6 @@ libcdi_la_SOURCES = 	 \
 	namespace.h      \
 	serialize.h	\
 	serialize.c	\
-	proprietarySystemWorkarounds.c \
-	proprietarySystemWorkarounds.h \
 	referenceCounting.c \
 	referenceCounting.h \
 	resource_handle.c\
@@ -96,6 +92,8 @@ libcdi_la_SOURCES = 	 \
 	stream_srv.c     \
 	stream_srv.h	 \
 	stream_var.c     \
+        subtype.c        \
+        subtype.h        \
 	swap.h	 	 \
 	table.c        	 \
 	table.h	 	 \
@@ -117,19 +115,41 @@ libcdi_la_SOURCES = 	 \
 	vlist_var.h	 \
 	zaxis.c		 \
 	zaxis.h		 \
-        stream.c         \
-        swap.c
-
-if HAVE_LIBGRIB_API
-libcdi_la_SOURCES +=        \
+	stream.c         \
+	swap.c          \
 	iterator.c          \
 	iterator.h          \
 	iterator_fallback.c \
 	iterator_fallback.h \
 	iterator_grib.c     \
 	iterator_grib.h
+
+# cfortran.h is an optional part of libcdi
+libcdi_la_USE_FC_extra_sources = \
+	cfortran.h       \
+	cdiFortran.c
+
+# these only contain code iff grib_api is available
+libcdi_la_HAVE_LIBGRIB_API_extra_sources = \
+	gribapi_utilities.c
+
+if USE_FC
+libcdi_la_SOURCES += 	 \
+	$(libcdi_la_USE_FC_extra_sources)
+endif
+
+if HAVE_LIBGRIB_API
+libcdi_la_SOURCES += 	 \
+	$(libcdi_la_HAVE_LIBGRIB_API_extra_sources)
 endif
 
+EXTRA_DIST += \
+	$(libcdi_la_USE_FC_extra_sources) \
+	$(libcdi_la_HAVE_LIBGRIB_API_extra_sources) \
+	$(libcdipio_la_HAVE_PARALLEL_NC4_extra_sources)
+
+
+
 libcdiresunpack_la_SOURCES = \
 	resource_unpack.c
 
@@ -150,11 +170,17 @@ libcdipio_la_SOURCES =							\
 	pio.h								\
 	pio_comm.c							\
 	pio_comm.h							\
+	pio_conf.c							\
+	pio_conf.h							\
 	pio_dbuffer.c							\
+	pio_id_set.h							\
 	pio_impl.h							\
 	pio_interface.c							\
 	pio_interface.h							\
 	pio_mpinonb.c							\
+	pio_mpi_fw_ordered.c						\
+	pio_mpi_fw_at_all.c						\
+	pio_mpi_fw_at_reblock.c						\
 	pio_record_send.c						\
 	pio_posixasynch.c						\
 	pio_posixfpguardsendrecv.c					\
@@ -162,22 +188,31 @@ libcdipio_la_SOURCES =							\
 	pio_list_set.c							\
 	resource_unpack.h						\
 	resource_unpack.c						\
-	pio_rpc.h							\
 	pio_client.c							\
 	pio_client.h							\
+	pio_roles.c							\
+	pio_rpc.c							\
+	pio_rpc.h							\
 	pio_server.c							\
 	pio_server.h							\
 	pio_serialize.h							\
 	pio_serialize.c							\
 	pio_util.c							\
 	pio_util.h							\
-	pio_cdf_int.c							\
 	pio_cdf_int.h
 
+libcdipio_la_HAVE_PARALLEL_NC4_extra_sources =				\
+	pio_cdf_int.c
+
+if USE_MPI
+if HAVE_PARALLEL_NC4
+libcdipio_la_SOURCES += $(libcdipio_la_HAVE_PARALLEL_NC4_extra_sources)
+endif
+endif
+
 libcdipio_la_LIBADD    = libcdi.la $(PPM_CORE_LIBS) $(YAXT_LIBS) $(MPI_C_LIB)
 
 libcdi_la_LIBADD    = $(UUID_C_LIB)
-libcdi_la_CFLAGS    = -DpgiFortran
 #
 #cdilib.c:
 #	$(top_srcdir)/src/make_cdilib $(top_srcdir)/src
@@ -198,7 +233,7 @@ LOCALTARGETS += mo_cdi.$(OBJEXT)
 endif
 #
 mo_cdi.f90: $(top_srcdir)/src/cdi.h $(top_srcdir)/interfaces/f2003/bindGen.rb
-	ruby $(top_srcdir)/interfaces/f2003/bindGen.rb $(top_srcdir)/src/cdi.h $@
+	$(RUBY) $(top_srcdir)/interfaces/f2003/bindGen.rb $(top_srcdir)/src/cdi.h $@
 #
 mo_cdi.$(OBJEXT): mo_cdi.f90
 	$(FC) $(FCFLAGS) -c $(FCFLAGS_f90) $<
@@ -214,7 +249,7 @@ all-local: $(LOCALTARGETS)
 CLEANFILES  = `ls *~`
 #CLEANFILES += cdilib.c
 if CREATE_ISOC
-CLEANFILES += mo_cdi.$(FCMODEXT) mo_cdi.$(OBJEXT) mo_cdi.f90
+CLEANFILES += mo_cdi.$(FCMODEXT) mo_cdi.$(OBJEXT)
 endif
 
 if ENABLE_CDI_LIB
diff --git a/libcdi/src/Makefile.in b/libcdi/src/Makefile.in
index e2cad83..3d93ab7 100644
--- a/libcdi/src/Makefile.in
+++ b/libcdi/src/Makefile.in
@@ -80,25 +80,24 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 @ENABLE_CDI_LIB_FALSE at am__append_1 = libcdi.la
- at HAVE_LIBGRIB_API_TRUE@am__append_2 = \
- at HAVE_LIBGRIB_API_TRUE@	iterator.c          \
- at HAVE_LIBGRIB_API_TRUE@	iterator.h          \
- at HAVE_LIBGRIB_API_TRUE@	iterator_fallback.c \
- at HAVE_LIBGRIB_API_TRUE@	iterator_fallback.h \
- at HAVE_LIBGRIB_API_TRUE@	iterator_grib.c     \
- at HAVE_LIBGRIB_API_TRUE@	iterator_grib.h
-
- at ENABLE_CDI_LIB_TRUE@@USE_MPI_TRUE at am__append_3 = libcdipio.la
- at ENABLE_CDI_LIB_TRUE@@USE_MPI_TRUE at am__append_4 = cdipio.h cdipio.inc
- at ENABLE_CDI_LIB_FALSE@@USE_MPI_TRUE at am__append_5 = libcdipio.la
- at ENABLE_CDI_LIB_TRUE@am__append_6 = pkgconfig/cdi.pc
- at ENABLE_CDI_LIB_TRUE@@USE_MPI_TRUE at am__append_7 = pkgconfig/cdipio.pc
- at CREATE_ISOC_TRUE@am__append_8 = mo_cdi.$(OBJEXT)
+ at USE_FC_TRUE@am__append_2 = \
+ at USE_FC_TRUE@	$(libcdi_la_USE_FC_extra_sources)
+
+ at HAVE_LIBGRIB_API_TRUE@am__append_3 = \
+ at HAVE_LIBGRIB_API_TRUE@	$(libcdi_la_HAVE_LIBGRIB_API_extra_sources)
+
+ at ENABLE_CDI_LIB_TRUE@@USE_MPI_TRUE at am__append_4 = libcdipio.la
+ at ENABLE_CDI_LIB_TRUE@@USE_MPI_TRUE at am__append_5 = cdipio.h cdipio.inc
+ at ENABLE_CDI_LIB_FALSE@@USE_MPI_TRUE at am__append_6 = libcdipio.la
+ at HAVE_PARALLEL_NC4_TRUE@@USE_MPI_TRUE at am__append_7 = $(libcdipio_la_HAVE_PARALLEL_NC4_extra_sources)
+ at ENABLE_CDI_LIB_TRUE@am__append_8 = pkgconfig/cdi.pc
+ at ENABLE_CDI_LIB_TRUE@@USE_MPI_TRUE at am__append_9 = pkgconfig/cdipio.pc
+ at CREATE_ISOC_TRUE@am__append_10 = mo_cdi.$(OBJEXT)
 #CLEANFILES += cdilib.c
- at CREATE_ISOC_TRUE@am__append_9 = mo_cdi.$(FCMODEXT) mo_cdi.$(OBJEXT) mo_cdi.f90
- at ENABLE_CDI_LIB_TRUE@am__append_10 = pkgconfig/cdi.pc
- at ENABLE_CDI_LIB_TRUE@@USE_MPI_TRUE at am__append_11 = pkgconfig/cdipio.pc
- at ENABLE_CDI_LIB_TRUE@@USE_MPI_TRUE at am__append_12 = pkgconfig/cdipio.pc
+ at CREATE_ISOC_TRUE@am__append_11 = mo_cdi.$(FCMODEXT) mo_cdi.$(OBJEXT)
+ at ENABLE_CDI_LIB_TRUE@am__append_12 = pkgconfig/cdi.pc
+ at ENABLE_CDI_LIB_TRUE@@USE_MPI_TRUE at am__append_13 = pkgconfig/cdipio.pc
+ at ENABLE_CDI_LIB_TRUE@@USE_MPI_TRUE at am__append_14 = pkgconfig/cdipio.pc
 subdir = src
 DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
 	$(srcdir)/config.h.in $(top_srcdir)/config/mkinstalldirs \
@@ -107,18 +106,22 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps =  \
 	$(top_srcdir)/m4/acx_assert_lang_is_fortran_variant.m4 \
 	$(top_srcdir)/m4/acx_c_package.m4 \
+	$(top_srcdir)/m4/acx_cfortran_flags.m4 \
+	$(top_srcdir)/m4/acx_check_cfortran.m4 \
 	$(top_srcdir)/m4/acx_check_strptr_convert.m4 \
 	$(top_srcdir)/m4/acx_execinfo.m4 \
 	$(top_srcdir)/m4/acx_fortran_package.m4 \
 	$(top_srcdir)/m4/acx_lang_check_include.m4 \
 	$(top_srcdir)/m4/acx_lang_other_suffix_conftest.m4 \
 	$(top_srcdir)/m4/acx_lang_package.m4 \
+	$(top_srcdir)/m4/acx_lt_problems.m4 \
 	$(top_srcdir)/m4/acx_option_search_libs.m4 \
 	$(top_srcdir)/m4/acx_options.m4 \
 	$(top_srcdir)/m4/acx_sl_fc_mod_path_flag.m4 \
 	$(top_srcdir)/m4/acx_sl_mod_suffix.m4 \
 	$(top_srcdir)/m4/asx_tr_arg.m4 $(top_srcdir)/m4/asx_unset.m4 \
-	$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
+	$(top_srcdir)/m4/ax_pthread.m4 \
+	$(top_srcdir)/m4/kpse_libtool.m4 $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/starlink_fpp.m4 \
@@ -166,74 +169,74 @@ am__DEPENDENCIES_1 =
 libcdi_la_DEPENDENCIES = $(am__DEPENDENCIES_1)
 am__libcdi_la_SOURCES_DIST = basetime.c basetime.h binary.c binary.h \
 	calendar.c calendar.h cdf.c cdf.h cdf_int.c cdf_int.h cdi.h \
-	cdi_error.c cdi_limits.h cdi_util.c cdiFortran.c cfortran.h \
-	cgribex.h cgribexlib.c datetime.h dmemory.c dmemory.h cksum.c \
-	cksum.h cdi_cksum.c cdi_cksum.h create_uuid.h dtypes.h error.c \
-	error.h extra.h extralib.c file.c file.h gaussgrid.c \
-	gaussgrid.h gribapi.c gribapi.h gribapi_utilities.c \
-	gribapi_utilities.h grid.c grid.h ieg.h ieglib.c input_file.c \
-	input_file.h institution.c institution.h model.c model.h \
-	namespace.c namespace.h serialize.h serialize.c \
-	proprietarySystemWorkarounds.c proprietarySystemWorkarounds.h \
-	referenceCounting.c referenceCounting.h resource_handle.c \
-	resource_handle.h service.h servicelib.c stream_cdf.c \
-	stream_cdf.h stream_cgribex.c stream_cgribex.h stream_ext.c \
-	stream_ext.h stream_grb.c stream_grb.h stream_gribapi.c \
-	stream_gribapi.h stream_history.c stream_ieg.c stream_ieg.h \
-	stream_fcommon.c stream_fcommon.h cdi_int.c cdi_int.h \
-	stream_record.c stream_srv.c stream_srv.h stream_var.c swap.h \
-	table.c table.h tablepar.h taxis.c taxis.h timebase.c \
-	timebase.h tsteps.c util.c varscan.c varscan.h version.c \
-	vlist.c vlist.h vlist_att.c vlist_att.h vlist_var.c \
-	vlist_var.h zaxis.c zaxis.h stream.c swap.c iterator.c \
-	iterator.h iterator_fallback.c iterator_fallback.h \
-	iterator_grib.c iterator_grib.h
- at HAVE_LIBGRIB_API_TRUE@am__objects_1 = libcdi_la-iterator.lo \
- at HAVE_LIBGRIB_API_TRUE@	libcdi_la-iterator_fallback.lo \
- at HAVE_LIBGRIB_API_TRUE@	libcdi_la-iterator_grib.lo
-am_libcdi_la_OBJECTS = libcdi_la-basetime.lo libcdi_la-binary.lo \
-	libcdi_la-calendar.lo libcdi_la-cdf.lo libcdi_la-cdf_int.lo \
-	libcdi_la-cdi_error.lo libcdi_la-cdi_util.lo \
-	libcdi_la-cdiFortran.lo libcdi_la-cgribexlib.lo \
-	libcdi_la-dmemory.lo libcdi_la-cksum.lo libcdi_la-cdi_cksum.lo \
-	libcdi_la-error.lo libcdi_la-extralib.lo libcdi_la-file.lo \
-	libcdi_la-gaussgrid.lo libcdi_la-gribapi.lo \
-	libcdi_la-gribapi_utilities.lo libcdi_la-grid.lo \
-	libcdi_la-ieglib.lo libcdi_la-input_file.lo \
-	libcdi_la-institution.lo libcdi_la-model.lo \
-	libcdi_la-namespace.lo libcdi_la-serialize.lo \
-	libcdi_la-proprietarySystemWorkarounds.lo \
-	libcdi_la-referenceCounting.lo libcdi_la-resource_handle.lo \
-	libcdi_la-servicelib.lo libcdi_la-stream_cdf.lo \
-	libcdi_la-stream_cgribex.lo libcdi_la-stream_ext.lo \
-	libcdi_la-stream_grb.lo libcdi_la-stream_gribapi.lo \
-	libcdi_la-stream_history.lo libcdi_la-stream_ieg.lo \
-	libcdi_la-stream_fcommon.lo libcdi_la-cdi_int.lo \
-	libcdi_la-stream_record.lo libcdi_la-stream_srv.lo \
-	libcdi_la-stream_var.lo libcdi_la-table.lo libcdi_la-taxis.lo \
-	libcdi_la-timebase.lo libcdi_la-tsteps.lo libcdi_la-util.lo \
-	libcdi_la-varscan.lo libcdi_la-version.lo libcdi_la-vlist.lo \
-	libcdi_la-vlist_att.lo libcdi_la-vlist_var.lo \
-	libcdi_la-zaxis.lo libcdi_la-stream.lo libcdi_la-swap.lo \
-	$(am__objects_1)
+	cdi_error.c cdi_limits.h cdi_util.c cgribex.h cgribexlib.c \
+	datetime.h dmemory.c dmemory.h cksum.c cksum.h cdi_cksum.c \
+	cdi_cksum.h create_uuid.h dtypes.h error.c error.h exse.h \
+	extra.h extralib.c file.c file.h gaussgrid.c gaussgrid.h \
+	gribapi.c gribapi.h gribapi_utilities.h grid.c grid.h ieg.h \
+	ieglib.c input_file.c input_file.h institution.c institution.h \
+	model.c model.h namespace.c namespace.h serialize.h \
+	serialize.c referenceCounting.c referenceCounting.h \
+	resource_handle.c resource_handle.h service.h servicelib.c \
+	stream_cdf.c stream_cdf.h stream_cgribex.c stream_cgribex.h \
+	stream_ext.c stream_ext.h stream_grb.c stream_grb.h \
+	stream_gribapi.c stream_gribapi.h stream_history.c \
+	stream_ieg.c stream_ieg.h stream_fcommon.c stream_fcommon.h \
+	cdi_int.c cdi_int.h stream_record.c stream_srv.c stream_srv.h \
+	stream_var.c subtype.c subtype.h swap.h table.c table.h \
+	tablepar.h taxis.c taxis.h timebase.c timebase.h tsteps.c \
+	util.c varscan.c varscan.h version.c vlist.c vlist.h \
+	vlist_att.c vlist_att.h vlist_var.c vlist_var.h zaxis.c \
+	zaxis.h stream.c swap.c iterator.c iterator.h \
+	iterator_fallback.c iterator_fallback.h iterator_grib.c \
+	iterator_grib.h cfortran.h cdiFortran.c gribapi_utilities.c
+am__objects_1 = cdiFortran.lo
+ at USE_FC_TRUE@am__objects_2 = $(am__objects_1)
+am__objects_3 = gribapi_utilities.lo
+ at HAVE_LIBGRIB_API_TRUE@am__objects_4 = $(am__objects_3)
+am_libcdi_la_OBJECTS = basetime.lo binary.lo calendar.lo cdf.lo \
+	cdf_int.lo cdi_error.lo cdi_util.lo cgribexlib.lo dmemory.lo \
+	cksum.lo cdi_cksum.lo error.lo extralib.lo file.lo \
+	gaussgrid.lo gribapi.lo grid.lo ieglib.lo input_file.lo \
+	institution.lo model.lo namespace.lo serialize.lo \
+	referenceCounting.lo resource_handle.lo servicelib.lo \
+	stream_cdf.lo stream_cgribex.lo stream_ext.lo stream_grb.lo \
+	stream_gribapi.lo stream_history.lo stream_ieg.lo \
+	stream_fcommon.lo cdi_int.lo stream_record.lo stream_srv.lo \
+	stream_var.lo subtype.lo table.lo taxis.lo timebase.lo \
+	tsteps.lo util.lo varscan.lo version.lo vlist.lo vlist_att.lo \
+	vlist_var.lo zaxis.lo stream.lo swap.lo iterator.lo \
+	iterator_fallback.lo iterator_grib.lo $(am__objects_2) \
+	$(am__objects_4)
 libcdi_la_OBJECTS = $(am_libcdi_la_OBJECTS)
 AM_V_lt = $(am__v_lt_ at AM_V@)
 am__v_lt_ = $(am__v_lt_ at AM_DEFAULT_V@)
 am__v_lt_0 = --silent
 am__v_lt_1 = 
-libcdi_la_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) \
-	$(LIBTOOLFLAGS) --mode=link $(CCLD) $(libcdi_la_CFLAGS) \
-	$(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
 @ENABLE_CDI_LIB_FALSE at am_libcdi_la_rpath =
 @ENABLE_CDI_LIB_TRUE at am_libcdi_la_rpath = -rpath $(libdir)
 libcdipio_la_DEPENDENCIES = libcdi.la $(am__DEPENDENCIES_1) \
 	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
+am__libcdipio_la_SOURCES_DIST = cdipio.h cdipioFortran.c cfortran.h \
+	pio.c pio.h pio_comm.c pio_comm.h pio_conf.c pio_conf.h \
+	pio_dbuffer.c pio_id_set.h pio_impl.h pio_interface.c \
+	pio_interface.h pio_mpinonb.c pio_mpi_fw_ordered.c \
+	pio_mpi_fw_at_all.c pio_mpi_fw_at_reblock.c pio_record_send.c \
+	pio_posixasynch.c pio_posixfpguardsendrecv.c pio_posixnonb.c \
+	pio_list_set.c resource_unpack.h resource_unpack.c \
+	pio_client.c pio_client.h pio_roles.c pio_rpc.c pio_rpc.h \
+	pio_server.c pio_server.h pio_serialize.h pio_serialize.c \
+	pio_util.c pio_util.h pio_cdf_int.h pio_cdf_int.c
+am__objects_5 = pio_cdf_int.lo
+ at HAVE_PARALLEL_NC4_TRUE@@USE_MPI_TRUE at am__objects_6 =  \
+ at HAVE_PARALLEL_NC4_TRUE@@USE_MPI_TRUE@	$(am__objects_5)
 am_libcdipio_la_OBJECTS = cdipioFortran.lo pio.lo pio_comm.lo \
-	pio_dbuffer.lo pio_interface.lo pio_mpinonb.lo \
-	pio_record_send.lo pio_posixasynch.lo \
+	pio_conf.lo pio_dbuffer.lo pio_interface.lo pio_mpinonb.lo \
+	pio_mpi_fw_ordered.lo pio_mpi_fw_at_all.lo \
+	pio_mpi_fw_at_reblock.lo pio_record_send.lo pio_posixasynch.lo \
 	pio_posixfpguardsendrecv.lo pio_posixnonb.lo pio_list_set.lo \
-	resource_unpack.lo pio_client.lo pio_server.lo \
-	pio_serialize.lo pio_util.lo pio_cdf_int.lo
+	resource_unpack.lo pio_client.lo pio_roles.lo pio_rpc.lo \
+	pio_server.lo pio_serialize.lo pio_util.lo $(am__objects_6)
 libcdipio_la_OBJECTS = $(am_libcdipio_la_OBJECTS)
 @ENABLE_CDI_LIB_FALSE@@USE_MPI_TRUE at am_libcdipio_la_rpath =
 @ENABLE_CDI_LIB_TRUE@@USE_MPI_TRUE at am_libcdipio_la_rpath = -rpath \
@@ -277,8 +280,8 @@ am__v_CCLD_0 = @echo "  CCLD    " $@;
 am__v_CCLD_1 = 
 SOURCES = $(libcdi_la_SOURCES) $(libcdipio_la_SOURCES) \
 	$(libcdiresunpack_la_SOURCES)
-DIST_SOURCES = $(am__libcdi_la_SOURCES_DIST) $(libcdipio_la_SOURCES) \
-	$(libcdiresunpack_la_SOURCES)
+DIST_SOURCES = $(am__libcdi_la_SOURCES_DIST) \
+	$(am__libcdipio_la_SOURCES_DIST) $(libcdiresunpack_la_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -311,7 +314,6 @@ ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
-AS = @AS@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
@@ -502,83 +504,78 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 
 #
-EXTRA_DIST = cdilib.c mo_cdi.f90
+EXTRA_DIST = cdilib.c mo_cdi.f90 $(libcdi_la_USE_FC_extra_sources) \
+	$(libcdi_la_HAVE_LIBGRIB_API_extra_sources) \
+	$(libcdipio_la_HAVE_PARALLEL_NC4_extra_sources)
 noinst_LTLIBRARIES = libcdiresunpack.la $(am__append_1) \
-	$(am__append_5)
- at ENABLE_CDI_LIB_TRUE@lib_LTLIBRARIES = libcdi.la $(am__append_3)
- at ENABLE_CDI_LIB_TRUE@include_HEADERS = cdi.h cdi.inc $(am__append_4)
+	$(am__append_6)
+ at ENABLE_CDI_LIB_TRUE@lib_LTLIBRARIES = libcdi.la $(am__append_4)
+ at ENABLE_CDI_LIB_TRUE@include_HEADERS = cdi.h cdi.inc $(am__append_5)
 AM_CFLAGS = $(PPM_CORE_CFLAGS) $(YAXT_CFLAGS) $(MPI_C_INCLUDE)
 libcdi_la_SOURCES = basetime.c basetime.h binary.c binary.h calendar.c \
 	calendar.h cdf.c cdf.h cdf_int.c cdf_int.h cdi.h cdi_error.c \
-	cdi_limits.h cdi_util.c cdiFortran.c cfortran.h cgribex.h \
-	cgribexlib.c datetime.h dmemory.c dmemory.h cksum.c cksum.h \
-	cdi_cksum.c cdi_cksum.h create_uuid.h dtypes.h error.c error.h \
-	extra.h extralib.c file.c file.h gaussgrid.c gaussgrid.h \
-	gribapi.c gribapi.h gribapi_utilities.c gribapi_utilities.h \
-	grid.c grid.h ieg.h ieglib.c input_file.c input_file.h \
-	institution.c institution.h model.c model.h namespace.c \
-	namespace.h serialize.h serialize.c \
-	proprietarySystemWorkarounds.c proprietarySystemWorkarounds.h \
+	cdi_limits.h cdi_util.c cgribex.h cgribexlib.c datetime.h \
+	dmemory.c dmemory.h cksum.c cksum.h cdi_cksum.c cdi_cksum.h \
+	create_uuid.h dtypes.h error.c error.h exse.h extra.h \
+	extralib.c file.c file.h gaussgrid.c gaussgrid.h gribapi.c \
+	gribapi.h gribapi_utilities.h grid.c grid.h ieg.h ieglib.c \
+	input_file.c input_file.h institution.c institution.h model.c \
+	model.h namespace.c namespace.h serialize.h serialize.c \
 	referenceCounting.c referenceCounting.h resource_handle.c \
 	resource_handle.h service.h servicelib.c stream_cdf.c \
 	stream_cdf.h stream_cgribex.c stream_cgribex.h stream_ext.c \
 	stream_ext.h stream_grb.c stream_grb.h stream_gribapi.c \
 	stream_gribapi.h stream_history.c stream_ieg.c stream_ieg.h \
 	stream_fcommon.c stream_fcommon.h cdi_int.c cdi_int.h \
-	stream_record.c stream_srv.c stream_srv.h stream_var.c swap.h \
-	table.c table.h tablepar.h taxis.c taxis.h timebase.c \
-	timebase.h tsteps.c util.c varscan.c varscan.h version.c \
-	vlist.c vlist.h vlist_att.c vlist_att.h vlist_var.c \
-	vlist_var.h zaxis.c zaxis.h stream.c swap.c $(am__append_2)
+	stream_record.c stream_srv.c stream_srv.h stream_var.c \
+	subtype.c subtype.h swap.h table.c table.h tablepar.h taxis.c \
+	taxis.h timebase.c timebase.h tsteps.c util.c varscan.c \
+	varscan.h version.c vlist.c vlist.h vlist_att.c vlist_att.h \
+	vlist_var.c vlist_var.h zaxis.c zaxis.h stream.c swap.c \
+	iterator.c iterator.h iterator_fallback.c iterator_fallback.h \
+	iterator_grib.c iterator_grib.h $(am__append_2) \
+	$(am__append_3)
+
+# cfortran.h is an optional part of libcdi
+libcdi_la_USE_FC_extra_sources = \
+	cfortran.h       \
+	cdiFortran.c
+
+
+# these only contain code iff grib_api is available
+libcdi_la_HAVE_LIBGRIB_API_extra_sources = \
+	gribapi_utilities.c
+
 libcdiresunpack_la_SOURCES = \
 	resource_unpack.c
 
-libcdipio_la_SOURCES = \
-	cdipio.h							\
-	cdipioFortran.c							\
-	cfortran.h							\
-	pio.c								\
-	pio.h								\
-	pio_comm.c							\
-	pio_comm.h							\
-	pio_dbuffer.c							\
-	pio_impl.h							\
-	pio_interface.c							\
-	pio_interface.h							\
-	pio_mpinonb.c							\
-	pio_record_send.c						\
-	pio_posixasynch.c						\
-	pio_posixfpguardsendrecv.c					\
-	pio_posixnonb.c							\
-	pio_list_set.c							\
-	resource_unpack.h						\
-	resource_unpack.c						\
-	pio_rpc.h							\
-	pio_client.c							\
-	pio_client.h							\
-	pio_server.c							\
-	pio_server.h							\
-	pio_serialize.h							\
-	pio_serialize.c							\
-	pio_util.c							\
-	pio_util.h							\
-	pio_cdf_int.c							\
-	pio_cdf_int.h
+libcdipio_la_SOURCES = cdipio.h cdipioFortran.c cfortran.h pio.c pio.h \
+	pio_comm.c pio_comm.h pio_conf.c pio_conf.h pio_dbuffer.c \
+	pio_id_set.h pio_impl.h pio_interface.c pio_interface.h \
+	pio_mpinonb.c pio_mpi_fw_ordered.c pio_mpi_fw_at_all.c \
+	pio_mpi_fw_at_reblock.c pio_record_send.c pio_posixasynch.c \
+	pio_posixfpguardsendrecv.c pio_posixnonb.c pio_list_set.c \
+	resource_unpack.h resource_unpack.c pio_client.c pio_client.h \
+	pio_roles.c pio_rpc.c pio_rpc.h pio_server.c pio_server.h \
+	pio_serialize.h pio_serialize.c pio_util.c pio_util.h \
+	pio_cdf_int.h $(am__append_7)
+libcdipio_la_HAVE_PARALLEL_NC4_extra_sources = \
+	pio_cdf_int.c
 
 libcdipio_la_LIBADD = libcdi.la $(PPM_CORE_LIBS) $(YAXT_LIBS) $(MPI_C_LIB)
 libcdi_la_LIBADD = $(UUID_C_LIB)
-libcdi_la_CFLAGS = -DpgiFortran
 #
 #cdilib.c:
 #	$(top_srcdir)/src/make_cdilib $(top_srcdir)/src
 #
 #cdilib.o: cdilib.c
 #	$(COMPILE) -c $<
-LOCALTARGETS = $(am__append_6) $(am__append_7) $(am__append_8)
+LOCALTARGETS = $(am__append_8) $(am__append_9) $(am__append_10)
 #
-CLEANFILES = `ls *~` $(am__append_9) $(am__append_10) $(am__append_11)
+CLEANFILES = `ls *~` $(am__append_11) $(am__append_12) \
+	$(am__append_13)
 @ENABLE_CDI_LIB_TRUE at PKGCONFIG_FILES = pkgconfig/cdi.pc \
- at ENABLE_CDI_LIB_TRUE@	$(am__append_12)
+ at ENABLE_CDI_LIB_TRUE@	$(am__append_14)
 all: config.h
 	$(MAKE) $(AM_MAKEFLAGS) all-am
 
@@ -677,7 +674,7 @@ clean-noinstLTLIBRARIES:
 	}
 
 libcdi.la: $(libcdi_la_OBJECTS) $(libcdi_la_DEPENDENCIES) $(EXTRA_libcdi_la_DEPENDENCIES) 
-	$(AM_V_CCLD)$(libcdi_la_LINK) $(am_libcdi_la_rpath) $(libcdi_la_OBJECTS) $(libcdi_la_LIBADD) $(LIBS)
+	$(AM_V_CCLD)$(LINK) $(am_libcdi_la_rpath) $(libcdi_la_OBJECTS) $(libcdi_la_LIBADD) $(LIBS)
 
 libcdipio.la: $(libcdipio_la_OBJECTS) $(libcdipio_la_DEPENDENCIES) $(EXTRA_libcdipio_la_DEPENDENCIES) 
 	$(AM_V_CCLD)$(LINK) $(am_libcdipio_la_rpath) $(libcdipio_la_OBJECTS) $(libcdipio_la_LIBADD) $(LIBS)
@@ -691,80 +688,86 @@ mostlyclean-compile:
 distclean-compile:
 	-rm -f *.tab.c
 
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/basetime.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/binary.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/calendar.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdf.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdf_int.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdiFortran.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdi_cksum.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdi_error.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdi_int.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdi_util.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdipioFortran.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-basetime.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-binary.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-calendar.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-cdf.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-cdf_int.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-cdiFortran.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-cdi_cksum.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-cdi_error.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-cdi_int.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-cdi_util.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-cgribexlib.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-cksum.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-dmemory.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-error.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-extralib.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-file.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-gaussgrid.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-gribapi.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-gribapi_utilities.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-grid.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-ieglib.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-input_file.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-institution.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-iterator.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-iterator_fallback.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-iterator_grib.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-model.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-namespace.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-proprietarySystemWorkarounds.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-referenceCounting.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-resource_handle.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-serialize.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-servicelib.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-stream.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-stream_cdf.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-stream_cgribex.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-stream_ext.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-stream_fcommon.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-stream_grb.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-stream_gribapi.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-stream_history.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-stream_ieg.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-stream_record.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-stream_srv.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-stream_var.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-swap.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-table.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-taxis.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-timebase.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-tsteps.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-util.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-varscan.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-version.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-vlist.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-vlist_att.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-vlist_var.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdi_la-zaxis.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cgribexlib.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cksum.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/dmemory.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/error.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/extralib.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/file.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gaussgrid.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gribapi.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/gribapi_utilities.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/grid.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/ieglib.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/input_file.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/institution.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/iterator.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/iterator_fallback.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/iterator_grib.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/model.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/namespace.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_cdf_int.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_client.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_comm.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_conf.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_dbuffer.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_interface.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_list_set.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_mpi_fw_at_all.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_mpi_fw_at_reblock.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_mpi_fw_ordered.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_mpinonb.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_posixasynch.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_posixfpguardsendrecv.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_posixnonb.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_record_send.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_roles.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_rpc.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_serialize.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_server.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/pio_util.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/referenceCounting.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/resource_handle.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/resource_unpack.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/serialize.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/servicelib.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stream.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stream_cdf.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stream_cgribex.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stream_ext.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stream_fcommon.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stream_grb.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stream_gribapi.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stream_history.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stream_ieg.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stream_record.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stream_srv.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stream_var.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/subtype.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/swap.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/table.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/taxis.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/timebase.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/tsteps.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/util.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/varscan.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/version.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/vlist.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/vlist_att.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/vlist_var.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/zaxis.Plo at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
@@ -787,405 +790,6 @@ distclean-compile:
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LTCOMPILE) -c -o $@ $<
 
-libcdi_la-basetime.lo: basetime.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-basetime.lo -MD -MP -MF $(DEPDIR)/libcdi_la-basetime.Tpo -c -o libcdi_la-basetime.lo `test -f 'basetime.c' || echo '$(srcdir)/'`basetime.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-basetime.Tpo $(DEPDIR)/libcdi_la-basetime.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='basetime.c' object='libcdi_la-basetime.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-basetime.lo `test -f 'basetime.c' || echo '$(srcdir)/'`basetime.c
-
-libcdi_la-binary.lo: binary.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-binary.lo -MD -MP -MF $(DEPDIR)/libcdi_la-binary.Tpo -c -o libcdi_la-binary.lo `test -f 'binary.c' || echo '$(srcdir)/'`binary.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-binary.Tpo $(DEPDIR)/libcdi_la-binary.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='binary.c' object='libcdi_la-binary.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-binary.lo `test -f 'binary.c' || echo '$(srcdir)/'`binary.c
-
-libcdi_la-calendar.lo: calendar.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-calendar.lo -MD -MP -MF $(DEPDIR)/libcdi_la-calendar.Tpo -c -o libcdi_la-calendar.lo `test -f 'calendar.c' || echo '$(srcdir)/'`calendar.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-calendar.Tpo $(DEPDIR)/libcdi_la-calendar.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='calendar.c' object='libcdi_la-calendar.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-calendar.lo `test -f 'calendar.c' || echo '$(srcdir)/'`calendar.c
-
-libcdi_la-cdf.lo: cdf.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-cdf.lo -MD -MP -MF $(DEPDIR)/libcdi_la-cdf.Tpo -c -o libcdi_la-cdf.lo `test -f 'cdf.c' || echo '$(srcdir)/'`cdf.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-cdf.Tpo $(DEPDIR)/libcdi_la-cdf.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='cdf.c' object='libcdi_la-cdf.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-cdf.lo `test -f 'cdf.c' || echo '$(srcdir)/'`cdf.c
-
-libcdi_la-cdf_int.lo: cdf_int.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-cdf_int.lo -MD -MP -MF $(DEPDIR)/libcdi_la-cdf_int.Tpo -c -o libcdi_la-cdf_int.lo `test -f 'cdf_int.c' || echo '$(srcdir)/'`cdf_int.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-cdf_int.Tpo $(DEPDIR)/libcdi_la-cdf_int.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='cdf_int.c' object='libcdi_la-cdf_int.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-cdf_int.lo `test -f 'cdf_int.c' || echo '$(srcdir)/'`cdf_int.c
-
-libcdi_la-cdi_error.lo: cdi_error.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-cdi_error.lo -MD -MP -MF $(DEPDIR)/libcdi_la-cdi_error.Tpo -c -o libcdi_la-cdi_error.lo `test -f 'cdi_error.c' || echo '$(srcdir)/'`cdi_error.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-cdi_error.Tpo $(DEPDIR)/libcdi_la-cdi_error.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='cdi_error.c' object='libcdi_la-cdi_error.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-cdi_error.lo `test -f 'cdi_error.c' || echo '$(srcdir)/'`cdi_error.c
-
-libcdi_la-cdi_util.lo: cdi_util.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-cdi_util.lo -MD -MP -MF $(DEPDIR)/libcdi_la-cdi_util.Tpo -c -o libcdi_la-cdi_util.lo `test -f 'cdi_util.c' || echo '$(srcdir)/'`cdi_util.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-cdi_util.Tpo $(DEPDIR)/libcdi_la-cdi_util.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='cdi_util.c' object='libcdi_la-cdi_util.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-cdi_util.lo `test -f 'cdi_util.c' || echo '$(srcdir)/'`cdi_util.c
-
-libcdi_la-cdiFortran.lo: cdiFortran.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-cdiFortran.lo -MD -MP -MF $(DEPDIR)/libcdi_la-cdiFortran.Tpo -c -o libcdi_la-cdiFortran.lo `test -f 'cdiFortran.c' || echo '$(srcdir)/'`cdiFortran.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-cdiFortran.Tpo $(DEPDIR)/libcdi_la-cdiFortran.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='cdiFortran.c' object='libcdi_la-cdiFortran.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-cdiFortran.lo `test -f 'cdiFortran.c' || echo '$(srcdir)/'`cdiFortran.c
-
-libcdi_la-cgribexlib.lo: cgribexlib.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-cgribexlib.lo -MD -MP -MF $(DEPDIR)/libcdi_la-cgribexlib.Tpo -c -o libcdi_la-cgribexlib.lo `test -f 'cgribexlib.c' || echo '$(srcdir)/'`cgribexlib.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-cgribexlib.Tpo $(DEPDIR)/libcdi_la-cgribexlib.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='cgribexlib.c' object='libcdi_la-cgribexlib.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-cgribexlib.lo `test -f 'cgribexlib.c' || echo '$(srcdir)/'`cgribexlib.c
-
-libcdi_la-dmemory.lo: dmemory.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-dmemory.lo -MD -MP -MF $(DEPDIR)/libcdi_la-dmemory.Tpo -c -o libcdi_la-dmemory.lo `test -f 'dmemory.c' || echo '$(srcdir)/'`dmemory.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-dmemory.Tpo $(DEPDIR)/libcdi_la-dmemory.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='dmemory.c' object='libcdi_la-dmemory.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-dmemory.lo `test -f 'dmemory.c' || echo '$(srcdir)/'`dmemory.c
-
-libcdi_la-cksum.lo: cksum.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-cksum.lo -MD -MP -MF $(DEPDIR)/libcdi_la-cksum.Tpo -c -o libcdi_la-cksum.lo `test -f 'cksum.c' || echo '$(srcdir)/'`cksum.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-cksum.Tpo $(DEPDIR)/libcdi_la-cksum.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='cksum.c' object='libcdi_la-cksum.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-cksum.lo `test -f 'cksum.c' || echo '$(srcdir)/'`cksum.c
-
-libcdi_la-cdi_cksum.lo: cdi_cksum.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-cdi_cksum.lo -MD -MP -MF $(DEPDIR)/libcdi_la-cdi_cksum.Tpo -c -o libcdi_la-cdi_cksum.lo `test -f 'cdi_cksum.c' || echo '$(srcdir)/'`cdi_cksum.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-cdi_cksum.Tpo $(DEPDIR)/libcdi_la-cdi_cksum.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='cdi_cksum.c' object='libcdi_la-cdi_cksum.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-cdi_cksum.lo `test -f 'cdi_cksum.c' || echo '$(srcdir)/'`cdi_cksum.c
-
-libcdi_la-error.lo: error.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-error.lo -MD -MP -MF $(DEPDIR)/libcdi_la-error.Tpo -c -o libcdi_la-error.lo `test -f 'error.c' || echo '$(srcdir)/'`error.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-error.Tpo $(DEPDIR)/libcdi_la-error.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='error.c' object='libcdi_la-error.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-error.lo `test -f 'error.c' || echo '$(srcdir)/'`error.c
-
-libcdi_la-extralib.lo: extralib.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-extralib.lo -MD -MP -MF $(DEPDIR)/libcdi_la-extralib.Tpo -c -o libcdi_la-extralib.lo `test -f 'extralib.c' || echo '$(srcdir)/'`extralib.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-extralib.Tpo $(DEPDIR)/libcdi_la-extralib.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='extralib.c' object='libcdi_la-extralib.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-extralib.lo `test -f 'extralib.c' || echo '$(srcdir)/'`extralib.c
-
-libcdi_la-file.lo: file.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-file.lo -MD -MP -MF $(DEPDIR)/libcdi_la-file.Tpo -c -o libcdi_la-file.lo `test -f 'file.c' || echo '$(srcdir)/'`file.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-file.Tpo $(DEPDIR)/libcdi_la-file.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='file.c' object='libcdi_la-file.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-file.lo `test -f 'file.c' || echo '$(srcdir)/'`file.c
-
-libcdi_la-gaussgrid.lo: gaussgrid.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-gaussgrid.lo -MD -MP -MF $(DEPDIR)/libcdi_la-gaussgrid.Tpo -c -o libcdi_la-gaussgrid.lo `test -f 'gaussgrid.c' || echo '$(srcdir)/'`gaussgrid.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-gaussgrid.Tpo $(DEPDIR)/libcdi_la-gaussgrid.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gaussgrid.c' object='libcdi_la-gaussgrid.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-gaussgrid.lo `test -f 'gaussgrid.c' || echo '$(srcdir)/'`gaussgrid.c
-
-libcdi_la-gribapi.lo: gribapi.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-gribapi.lo -MD -MP -MF $(DEPDIR)/libcdi_la-gribapi.Tpo -c -o libcdi_la-gribapi.lo `test -f 'gribapi.c' || echo '$(srcdir)/'`gribapi.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-gribapi.Tpo $(DEPDIR)/libcdi_la-gribapi.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gribapi.c' object='libcdi_la-gribapi.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-gribapi.lo `test -f 'gribapi.c' || echo '$(srcdir)/'`gribapi.c
-
-libcdi_la-gribapi_utilities.lo: gribapi_utilities.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-gribapi_utilities.lo -MD -MP -MF $(DEPDIR)/libcdi_la-gribapi_utilities.Tpo -c -o libcdi_la-gribapi_utilities.lo `test -f 'gribapi_utilities.c' || echo '$(srcdir)/'`gribapi_utilities.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-gribapi_utilities.Tpo $(DEPDIR)/libcdi_la-gribapi_utilities.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='gribapi_utilities.c' object='libcdi_la-gribapi_utilities.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-gribapi_utilities.lo `test -f 'gribapi_utilities.c' || echo '$(srcdir)/'`gribapi_utilities.c
-
-libcdi_la-grid.lo: grid.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-grid.lo -MD -MP -MF $(DEPDIR)/libcdi_la-grid.Tpo -c -o libcdi_la-grid.lo `test -f 'grid.c' || echo '$(srcdir)/'`grid.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-grid.Tpo $(DEPDIR)/libcdi_la-grid.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='grid.c' object='libcdi_la-grid.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-grid.lo `test -f 'grid.c' || echo '$(srcdir)/'`grid.c
-
-libcdi_la-ieglib.lo: ieglib.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-ieglib.lo -MD -MP -MF $(DEPDIR)/libcdi_la-ieglib.Tpo -c -o libcdi_la-ieglib.lo `test -f 'ieglib.c' || echo '$(srcdir)/'`ieglib.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-ieglib.Tpo $(DEPDIR)/libcdi_la-ieglib.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='ieglib.c' object='libcdi_la-ieglib.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-ieglib.lo `test -f 'ieglib.c' || echo '$(srcdir)/'`ieglib.c
-
-libcdi_la-input_file.lo: input_file.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-input_file.lo -MD -MP -MF $(DEPDIR)/libcdi_la-input_file.Tpo -c -o libcdi_la-input_file.lo `test -f 'input_file.c' || echo '$(srcdir)/'`input_file.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-input_file.Tpo $(DEPDIR)/libcdi_la-input_file.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='input_file.c' object='libcdi_la-input_file.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-input_file.lo `test -f 'input_file.c' || echo '$(srcdir)/'`input_file.c
-
-libcdi_la-institution.lo: institution.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-institution.lo -MD -MP -MF $(DEPDIR)/libcdi_la-institution.Tpo -c -o libcdi_la-institution.lo `test -f 'institution.c' || echo '$(srcdir)/'`institution.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-institution.Tpo $(DEPDIR)/libcdi_la-institution.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='institution.c' object='libcdi_la-institution.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-institution.lo `test -f 'institution.c' || echo '$(srcdir)/'`institution.c
-
-libcdi_la-model.lo: model.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-model.lo -MD -MP -MF $(DEPDIR)/libcdi_la-model.Tpo -c -o libcdi_la-model.lo `test -f 'model.c' || echo '$(srcdir)/'`model.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-model.Tpo $(DEPDIR)/libcdi_la-model.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='model.c' object='libcdi_la-model.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-model.lo `test -f 'model.c' || echo '$(srcdir)/'`model.c
-
-libcdi_la-namespace.lo: namespace.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-namespace.lo -MD -MP -MF $(DEPDIR)/libcdi_la-namespace.Tpo -c -o libcdi_la-namespace.lo `test -f 'namespace.c' || echo '$(srcdir)/'`namespace.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-namespace.Tpo $(DEPDIR)/libcdi_la-namespace.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='namespace.c' object='libcdi_la-namespace.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-namespace.lo `test -f 'namespace.c' || echo '$(srcdir)/'`namespace.c
-
-libcdi_la-serialize.lo: serialize.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-serialize.lo -MD -MP -MF $(DEPDIR)/libcdi_la-serialize.Tpo -c -o libcdi_la-serialize.lo `test -f 'serialize.c' || echo '$(srcdir)/'`serialize.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-serialize.Tpo $(DEPDIR)/libcdi_la-serialize.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='serialize.c' object='libcdi_la-serialize.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-serialize.lo `test -f 'serialize.c' || echo '$(srcdir)/'`serialize.c
-
-libcdi_la-proprietarySystemWorkarounds.lo: proprietarySystemWorkarounds.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-proprietarySystemWorkarounds.lo -MD -MP -MF $(DEPDIR)/libcdi_la-proprietarySystemWorkarounds.Tpo -c -o libcdi_la-proprietarySystemWorkarounds.lo `test -f 'proprietarySystemWorkarounds.c' || echo '$(srcdir)/'`proprietarySystemWorkarounds.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-proprietarySystemWorkarounds.Tpo $(DEPDIR)/libcdi_la-proprietarySystemWorkarounds.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='proprietarySystemWorkarounds.c' object='libcdi_la-proprietarySystemWorkarounds.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-proprietarySystemWorkarounds.lo `test -f 'proprietarySystemWorkarounds.c' || echo '$(srcdir)/'`proprietarySystemWorkarounds.c
-
-libcdi_la-referenceCounting.lo: referenceCounting.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-referenceCounting.lo -MD -MP -MF $(DEPDIR)/libcdi_la-referenceCounting.Tpo -c -o libcdi_la-referenceCounting.lo `test -f 'referenceCounting.c' || echo '$(srcdir)/'`referenceCounting.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-referenceCounting.Tpo $(DEPDIR)/libcdi_la-referenceCounting.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='referenceCounting.c' object='libcdi_la-referenceCounting.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-referenceCounting.lo `test -f 'referenceCounting.c' || echo '$(srcdir)/'`referenceCounting.c
-
-libcdi_la-resource_handle.lo: resource_handle.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-resource_handle.lo -MD -MP -MF $(DEPDIR)/libcdi_la-resource_handle.Tpo -c -o libcdi_la-resource_handle.lo `test -f 'resource_handle.c' || echo '$(srcdir)/'`resource_handle.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-resource_handle.Tpo $(DEPDIR)/libcdi_la-resource_handle.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='resource_handle.c' object='libcdi_la-resource_handle.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-resource_handle.lo `test -f 'resource_handle.c' || echo '$(srcdir)/'`resource_handle.c
-
-libcdi_la-servicelib.lo: servicelib.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-servicelib.lo -MD -MP -MF $(DEPDIR)/libcdi_la-servicelib.Tpo -c -o libcdi_la-servicelib.lo `test -f 'servicelib.c' || echo '$(srcdir)/'`servicelib.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-servicelib.Tpo $(DEPDIR)/libcdi_la-servicelib.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='servicelib.c' object='libcdi_la-servicelib.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-servicelib.lo `test -f 'servicelib.c' || echo '$(srcdir)/'`servicelib.c
-
-libcdi_la-stream_cdf.lo: stream_cdf.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-stream_cdf.lo -MD -MP -MF $(DEPDIR)/libcdi_la-stream_cdf.Tpo -c -o libcdi_la-stream_cdf.lo `test -f 'stream_cdf.c' || echo '$(srcdir)/'`stream_cdf.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-stream_cdf.Tpo $(DEPDIR)/libcdi_la-stream_cdf.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stream_cdf.c' object='libcdi_la-stream_cdf.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-stream_cdf.lo `test -f 'stream_cdf.c' || echo '$(srcdir)/'`stream_cdf.c
-
-libcdi_la-stream_cgribex.lo: stream_cgribex.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-stream_cgribex.lo -MD -MP -MF $(DEPDIR)/libcdi_la-stream_cgribex.Tpo -c -o libcdi_la-stream_cgribex.lo `test -f 'stream_cgribex.c' || echo '$(srcdir)/'`stream_cgribex.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-stream_cgribex.Tpo $(DEPDIR)/libcdi_la-stream_cgribex.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stream_cgribex.c' object='libcdi_la-stream_cgribex.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-stream_cgribex.lo `test -f 'stream_cgribex.c' || echo '$(srcdir)/'`stream_cgribex.c
-
-libcdi_la-stream_ext.lo: stream_ext.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-stream_ext.lo -MD -MP -MF $(DEPDIR)/libcdi_la-stream_ext.Tpo -c -o libcdi_la-stream_ext.lo `test -f 'stream_ext.c' || echo '$(srcdir)/'`stream_ext.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-stream_ext.Tpo $(DEPDIR)/libcdi_la-stream_ext.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stream_ext.c' object='libcdi_la-stream_ext.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-stream_ext.lo `test -f 'stream_ext.c' || echo '$(srcdir)/'`stream_ext.c
-
-libcdi_la-stream_grb.lo: stream_grb.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-stream_grb.lo -MD -MP -MF $(DEPDIR)/libcdi_la-stream_grb.Tpo -c -o libcdi_la-stream_grb.lo `test -f 'stream_grb.c' || echo '$(srcdir)/'`stream_grb.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-stream_grb.Tpo $(DEPDIR)/libcdi_la-stream_grb.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stream_grb.c' object='libcdi_la-stream_grb.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-stream_grb.lo `test -f 'stream_grb.c' || echo '$(srcdir)/'`stream_grb.c
-
-libcdi_la-stream_gribapi.lo: stream_gribapi.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-stream_gribapi.lo -MD -MP -MF $(DEPDIR)/libcdi_la-stream_gribapi.Tpo -c -o libcdi_la-stream_gribapi.lo `test -f 'stream_gribapi.c' || echo '$(srcdir)/'`stream_gribapi.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-stream_gribapi.Tpo $(DEPDIR)/libcdi_la-stream_gribapi.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stream_gribapi.c' object='libcdi_la-stream_gribapi.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-stream_gribapi.lo `test -f 'stream_gribapi.c' || echo '$(srcdir)/'`stream_gribapi.c
-
-libcdi_la-stream_history.lo: stream_history.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-stream_history.lo -MD -MP -MF $(DEPDIR)/libcdi_la-stream_history.Tpo -c -o libcdi_la-stream_history.lo `test -f 'stream_history.c' || echo '$(srcdir)/'`stream_history.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-stream_history.Tpo $(DEPDIR)/libcdi_la-stream_history.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stream_history.c' object='libcdi_la-stream_history.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-stream_history.lo `test -f 'stream_history.c' || echo '$(srcdir)/'`stream_history.c
-
-libcdi_la-stream_ieg.lo: stream_ieg.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-stream_ieg.lo -MD -MP -MF $(DEPDIR)/libcdi_la-stream_ieg.Tpo -c -o libcdi_la-stream_ieg.lo `test -f 'stream_ieg.c' || echo '$(srcdir)/'`stream_ieg.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-stream_ieg.Tpo $(DEPDIR)/libcdi_la-stream_ieg.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stream_ieg.c' object='libcdi_la-stream_ieg.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-stream_ieg.lo `test -f 'stream_ieg.c' || echo '$(srcdir)/'`stream_ieg.c
-
-libcdi_la-stream_fcommon.lo: stream_fcommon.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-stream_fcommon.lo -MD -MP -MF $(DEPDIR)/libcdi_la-stream_fcommon.Tpo -c -o libcdi_la-stream_fcommon.lo `test -f 'stream_fcommon.c' || echo '$(srcdir)/'`stream_fcommon.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-stream_fcommon.Tpo $(DEPDIR)/libcdi_la-stream_fcommon.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stream_fcommon.c' object='libcdi_la-stream_fcommon.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-stream_fcommon.lo `test -f 'stream_fcommon.c' || echo '$(srcdir)/'`stream_fcommon.c
-
-libcdi_la-cdi_int.lo: cdi_int.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-cdi_int.lo -MD -MP -MF $(DEPDIR)/libcdi_la-cdi_int.Tpo -c -o libcdi_la-cdi_int.lo `test -f 'cdi_int.c' || echo '$(srcdir)/'`cdi_int.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-cdi_int.Tpo $(DEPDIR)/libcdi_la-cdi_int.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='cdi_int.c' object='libcdi_la-cdi_int.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-cdi_int.lo `test -f 'cdi_int.c' || echo '$(srcdir)/'`cdi_int.c
-
-libcdi_la-stream_record.lo: stream_record.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-stream_record.lo -MD -MP -MF $(DEPDIR)/libcdi_la-stream_record.Tpo -c -o libcdi_la-stream_record.lo `test -f 'stream_record.c' || echo '$(srcdir)/'`stream_record.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-stream_record.Tpo $(DEPDIR)/libcdi_la-stream_record.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stream_record.c' object='libcdi_la-stream_record.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-stream_record.lo `test -f 'stream_record.c' || echo '$(srcdir)/'`stream_record.c
-
-libcdi_la-stream_srv.lo: stream_srv.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-stream_srv.lo -MD -MP -MF $(DEPDIR)/libcdi_la-stream_srv.Tpo -c -o libcdi_la-stream_srv.lo `test -f 'stream_srv.c' || echo '$(srcdir)/'`stream_srv.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-stream_srv.Tpo $(DEPDIR)/libcdi_la-stream_srv.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stream_srv.c' object='libcdi_la-stream_srv.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-stream_srv.lo `test -f 'stream_srv.c' || echo '$(srcdir)/'`stream_srv.c
-
-libcdi_la-stream_var.lo: stream_var.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-stream_var.lo -MD -MP -MF $(DEPDIR)/libcdi_la-stream_var.Tpo -c -o libcdi_la-stream_var.lo `test -f 'stream_var.c' || echo '$(srcdir)/'`stream_var.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-stream_var.Tpo $(DEPDIR)/libcdi_la-stream_var.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stream_var.c' object='libcdi_la-stream_var.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-stream_var.lo `test -f 'stream_var.c' || echo '$(srcdir)/'`stream_var.c
-
-libcdi_la-table.lo: table.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-table.lo -MD -MP -MF $(DEPDIR)/libcdi_la-table.Tpo -c -o libcdi_la-table.lo `test -f 'table.c' || echo '$(srcdir)/'`table.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-table.Tpo $(DEPDIR)/libcdi_la-table.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='table.c' object='libcdi_la-table.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-table.lo `test -f 'table.c' || echo '$(srcdir)/'`table.c
-
-libcdi_la-taxis.lo: taxis.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-taxis.lo -MD -MP -MF $(DEPDIR)/libcdi_la-taxis.Tpo -c -o libcdi_la-taxis.lo `test -f 'taxis.c' || echo '$(srcdir)/'`taxis.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-taxis.Tpo $(DEPDIR)/libcdi_la-taxis.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='taxis.c' object='libcdi_la-taxis.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-taxis.lo `test -f 'taxis.c' || echo '$(srcdir)/'`taxis.c
-
-libcdi_la-timebase.lo: timebase.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-timebase.lo -MD -MP -MF $(DEPDIR)/libcdi_la-timebase.Tpo -c -o libcdi_la-timebase.lo `test -f 'timebase.c' || echo '$(srcdir)/'`timebase.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-timebase.Tpo $(DEPDIR)/libcdi_la-timebase.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='timebase.c' object='libcdi_la-timebase.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-timebase.lo `test -f 'timebase.c' || echo '$(srcdir)/'`timebase.c
-
-libcdi_la-tsteps.lo: tsteps.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-tsteps.lo -MD -MP -MF $(DEPDIR)/libcdi_la-tsteps.Tpo -c -o libcdi_la-tsteps.lo `test -f 'tsteps.c' || echo '$(srcdir)/'`tsteps.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-tsteps.Tpo $(DEPDIR)/libcdi_la-tsteps.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='tsteps.c' object='libcdi_la-tsteps.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-tsteps.lo `test -f 'tsteps.c' || echo '$(srcdir)/'`tsteps.c
-
-libcdi_la-util.lo: util.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-util.lo -MD -MP -MF $(DEPDIR)/libcdi_la-util.Tpo -c -o libcdi_la-util.lo `test -f 'util.c' || echo '$(srcdir)/'`util.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-util.Tpo $(DEPDIR)/libcdi_la-util.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='util.c' object='libcdi_la-util.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-util.lo `test -f 'util.c' || echo '$(srcdir)/'`util.c
-
-libcdi_la-varscan.lo: varscan.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-varscan.lo -MD -MP -MF $(DEPDIR)/libcdi_la-varscan.Tpo -c -o libcdi_la-varscan.lo `test -f 'varscan.c' || echo '$(srcdir)/'`varscan.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-varscan.Tpo $(DEPDIR)/libcdi_la-varscan.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='varscan.c' object='libcdi_la-varscan.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-varscan.lo `test -f 'varscan.c' || echo '$(srcdir)/'`varscan.c
-
-libcdi_la-version.lo: version.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-version.lo -MD -MP -MF $(DEPDIR)/libcdi_la-version.Tpo -c -o libcdi_la-version.lo `test -f 'version.c' || echo '$(srcdir)/'`version.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-version.Tpo $(DEPDIR)/libcdi_la-version.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='version.c' object='libcdi_la-version.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-version.lo `test -f 'version.c' || echo '$(srcdir)/'`version.c
-
-libcdi_la-vlist.lo: vlist.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-vlist.lo -MD -MP -MF $(DEPDIR)/libcdi_la-vlist.Tpo -c -o libcdi_la-vlist.lo `test -f 'vlist.c' || echo '$(srcdir)/'`vlist.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-vlist.Tpo $(DEPDIR)/libcdi_la-vlist.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='vlist.c' object='libcdi_la-vlist.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-vlist.lo `test -f 'vlist.c' || echo '$(srcdir)/'`vlist.c
-
-libcdi_la-vlist_att.lo: vlist_att.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-vlist_att.lo -MD -MP -MF $(DEPDIR)/libcdi_la-vlist_att.Tpo -c -o libcdi_la-vlist_att.lo `test -f 'vlist_att.c' || echo '$(srcdir)/'`vlist_att.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-vlist_att.Tpo $(DEPDIR)/libcdi_la-vlist_att.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='vlist_att.c' object='libcdi_la-vlist_att.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-vlist_att.lo `test -f 'vlist_att.c' || echo '$(srcdir)/'`vlist_att.c
-
-libcdi_la-vlist_var.lo: vlist_var.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-vlist_var.lo -MD -MP -MF $(DEPDIR)/libcdi_la-vlist_var.Tpo -c -o libcdi_la-vlist_var.lo `test -f 'vlist_var.c' || echo '$(srcdir)/'`vlist_var.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-vlist_var.Tpo $(DEPDIR)/libcdi_la-vlist_var.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='vlist_var.c' object='libcdi_la-vlist_var.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-vlist_var.lo `test -f 'vlist_var.c' || echo '$(srcdir)/'`vlist_var.c
-
-libcdi_la-zaxis.lo: zaxis.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-zaxis.lo -MD -MP -MF $(DEPDIR)/libcdi_la-zaxis.Tpo -c -o libcdi_la-zaxis.lo `test -f 'zaxis.c' || echo '$(srcdir)/'`zaxis.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-zaxis.Tpo $(DEPDIR)/libcdi_la-zaxis.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='zaxis.c' object='libcdi_la-zaxis.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-zaxis.lo `test -f 'zaxis.c' || echo '$(srcdir)/'`zaxis.c
-
-libcdi_la-stream.lo: stream.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-stream.lo -MD -MP -MF $(DEPDIR)/libcdi_la-stream.Tpo -c -o libcdi_la-stream.lo `test -f 'stream.c' || echo '$(srcdir)/'`stream.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-stream.Tpo $(DEPDIR)/libcdi_la-stream.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='stream.c' object='libcdi_la-stream.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-stream.lo `test -f 'stream.c' || echo '$(srcdir)/'`stream.c
-
-libcdi_la-swap.lo: swap.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-swap.lo -MD -MP -MF $(DEPDIR)/libcdi_la-swap.Tpo -c -o libcdi_la-swap.lo `test -f 'swap.c' || echo '$(srcdir)/'`swap.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-swap.Tpo $(DEPDIR)/libcdi_la-swap.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='swap.c' object='libcdi_la-swap.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-swap.lo `test -f 'swap.c' || echo '$(srcdir)/'`swap.c
-
-libcdi_la-iterator.lo: iterator.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-iterator.lo -MD -MP -MF $(DEPDIR)/libcdi_la-iterator.Tpo -c -o libcdi_la-iterator.lo `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-iterator.Tpo $(DEPDIR)/libcdi_la-iterator.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='iterator.c' object='libcdi_la-iterator.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-iterator.lo `test -f 'iterator.c' || echo '$(srcdir)/'`iterator.c
-
-libcdi_la-iterator_fallback.lo: iterator_fallback.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-iterator_fallback.lo -MD -MP -MF $(DEPDIR)/libcdi_la-iterator_fallback.Tpo -c -o libcdi_la-iterator_fallback.lo `test -f 'iterator_fallback.c' || echo '$(srcdir)/'`iterator_fallback.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-iterator_fallback.Tpo $(DEPDIR)/libcdi_la-iterator_fallback.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='iterator_fallback.c' object='libcdi_la-iterator_fallback.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-iterator_fallback.lo `test -f 'iterator_fallback.c' || echo '$(srcdir)/'`iterator_fallback.c
-
-libcdi_la-iterator_grib.lo: iterator_grib.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -MT libcdi_la-iterator_grib.lo -MD -MP -MF $(DEPDIR)/libcdi_la-iterator_grib.Tpo -c -o libcdi_la-iterator_grib.lo `test -f 'iterator_grib.c' || echo '$(srcdir)/'`iterator_grib.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdi_la-iterator_grib.Tpo $(DEPDIR)/libcdi_la-iterator_grib.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='iterator_grib.c' object='libcdi_la-iterator_grib.lo' libtool=yes @AMDEPBACKSLASH@
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcdi_la_CFLAGS) $(CFLAGS) -c -o libcdi_la-iterator_grib.lo `test -f 'iterator_grib.c' || echo '$(srcdir)/'`iterator_grib.c
-
 mostlyclean-libtool:
 	-rm -f *.lo
 
@@ -1431,7 +1035,7 @@ uninstall-am: uninstall-includeHEADERS uninstall-libLTLIBRARIES \
 
 #
 mo_cdi.f90: $(top_srcdir)/src/cdi.h $(top_srcdir)/interfaces/f2003/bindGen.rb
-	ruby $(top_srcdir)/interfaces/f2003/bindGen.rb $(top_srcdir)/src/cdi.h $@
+	$(RUBY) $(top_srcdir)/interfaces/f2003/bindGen.rb $(top_srcdir)/src/cdi.h $@
 #
 mo_cdi.$(OBJEXT): mo_cdi.f90
 	$(FC) $(FCFLAGS) -c $(FCFLAGS_f90) $<
diff --git a/libcdi/src/basetime.c b/libcdi/src/basetime.c
index 3d4d5e3..5d0efba 100644
--- a/libcdi/src/basetime.c
+++ b/libcdi/src/basetime.c
@@ -32,3 +32,4 @@ void basetimeInit(basetime_t *basetime)
  * require-trailing-newline: t
  * End:
  */
+ 
\ No newline at end of file
diff --git a/libcdi/src/binary.c b/libcdi/src/binary.c
index 416f35f..9772272 100644
--- a/libcdi/src/binary.c
+++ b/libcdi/src/binary.c
@@ -2,65 +2,76 @@
 #  include "config.h"
 #endif
 
+#include <inttypes.h>
+
+#include "cdi.h"
 #include "error.h"
 #include "file.h"
 #include "swap.h"
 #include "binary.h"
 
 
-#undef  IsBigendian
-#define IsBigendian()  ( u_byteorder.c[sizeof(long) - 1] )
-
-
 UINT32 get_UINT32(unsigned char *x)
 {
-  /* IsBigendian returns 1 for big endian byte order */
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
-
-  if ( IsBigendian() )
-    return((UINT32)(((UINT32)x[0]<<24)+((UINT32)x[1]<<16)+((UINT32)x[2]<< 8)+ (UINT32)x[3]));
-  else
-    return((UINT32)(((UINT32)x[3]<<24)+((UINT32)x[2]<<16)+((UINT32)x[1]<< 8)+ (UINT32)x[0]));
+  switch (HOST_ENDIANNESS)
+    {
+    case CDI_BIGENDIAN:
+      return((UINT32)(((UINT32)x[0]<<24)+((UINT32)x[1]<<16)+((UINT32)x[2]<< 8)+ (UINT32)x[3]));
+    case CDI_LITTLEENDIAN:
+      return ((UINT32)(((UINT32)x[3]<<24)+((UINT32)x[2]<<16)+((UINT32)x[1]<< 8)+ (UINT32)x[0]));
+    default:
+      Error("unhandled endianness %d", HOST_ENDIANNESS);
+      return UINT32_C(0xFFFFFFFF);
+    }
 }
 
 
 UINT32 get_SUINT32(unsigned char *x)
 {
-  /* IsBigendian returns 1 for big endian byte order */
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
-
-  if ( IsBigendian() )
-    return((UINT32)(((UINT32)x[3]<<24)+((UINT32)x[2]<<16)+((UINT32)x[1]<< 8)+ (UINT32)x[0]));
-  else
-    return((UINT32)(((UINT32)x[0]<<24)+((UINT32)x[1]<<16)+((UINT32)x[2]<< 8)+ (UINT32)x[3]));
+  switch (HOST_ENDIANNESS)
+    {
+    case CDI_BIGENDIAN:
+      return((UINT32)(((UINT32)x[3]<<24)+((UINT32)x[2]<<16)+((UINT32)x[1]<< 8)+ (UINT32)x[0]));
+    case CDI_LITTLEENDIAN:
+      return((UINT32)(((UINT32)x[0]<<24)+((UINT32)x[1]<<16)+((UINT32)x[2]<< 8)+ (UINT32)x[3]));
+    default:
+      Error("unhandled endianness %d", HOST_ENDIANNESS);
+      return UINT32_C(0xFFFFFFFF);
+    }
 }
 
 
 UINT64 get_UINT64(unsigned char *x)
 {
-  /* IsBigendian returns 1 for big endian byte order */
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
-
-  if ( IsBigendian() )
-    return((UINT64)(((UINT64)x[0]<<56)+((UINT64)x[1]<<48)+((UINT64)x[2]<<40)+((UINT64)x[3]<<32)+
-		    ((UINT64)x[4]<<24)+((UINT64)x[5]<<16)+((UINT64)x[6]<< 8)+ (UINT64)x[7]));
-  else
-    return((UINT64)(((UINT64)x[7]<<56)+((UINT64)x[6]<<48)+((UINT64)x[5]<<40)+((UINT64)x[4]<<32)+
-		    ((UINT64)x[3]<<24)+((UINT64)x[2]<<16)+((UINT64)x[1]<< 8)+ (UINT64)x[0]));
+  switch (HOST_ENDIANNESS)
+    {
+    case CDI_BIGENDIAN:
+      return((UINT64)(((UINT64)x[0]<<56)+((UINT64)x[1]<<48)+((UINT64)x[2]<<40)+((UINT64)x[3]<<32)+
+                      ((UINT64)x[4]<<24)+((UINT64)x[5]<<16)+((UINT64)x[6]<< 8)+ (UINT64)x[7]));
+    case CDI_LITTLEENDIAN:
+      return((UINT64)(((UINT64)x[7]<<56)+((UINT64)x[6]<<48)+((UINT64)x[5]<<40)+((UINT64)x[4]<<32)+
+                      ((UINT64)x[3]<<24)+((UINT64)x[2]<<16)+((UINT64)x[1]<< 8)+ (UINT64)x[0]));
+    default:
+      Error("unhandled endianness %d", HOST_ENDIANNESS);
+      return UINT64_C(0xFFFFFFFFFFFFFFFF);
+    }
 }
 
 
 UINT64 get_SUINT64(unsigned char *x)
 {
-  /* IsBigendian returns 1 for big endian byte order */
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
-
-  if ( IsBigendian() )
-    return((UINT64)(((UINT64)x[7]<<56)+((UINT64)x[6]<<48)+((UINT64)x[5]<<40)+((UINT64)x[4]<<32)+
-		    ((UINT64)x[3]<<24)+((UINT64)x[2]<<16)+((UINT64)x[1]<< 8)+ (UINT64)x[0]));
-  else
-    return((UINT64)(((UINT64)x[0]<<56)+((UINT64)x[1]<<48)+((UINT64)x[2]<<40)+((UINT64)x[3]<<32)+
-		    ((UINT64)x[4]<<24)+((UINT64)x[5]<<16)+((UINT64)x[6]<< 8)+ (UINT64)x[7]));
+  switch (HOST_ENDIANNESS)
+    {
+    case CDI_BIGENDIAN:
+      return((UINT64)(((UINT64)x[7]<<56)+((UINT64)x[6]<<48)+((UINT64)x[5]<<40)+((UINT64)x[4]<<32)+
+                      ((UINT64)x[3]<<24)+((UINT64)x[2]<<16)+((UINT64)x[1]<< 8)+ (UINT64)x[0]));
+    case CDI_LITTLEENDIAN:
+      return((UINT64)(((UINT64)x[0]<<56)+((UINT64)x[1]<<48)+((UINT64)x[2]<<40)+((UINT64)x[3]<<32)+
+                      ((UINT64)x[4]<<24)+((UINT64)x[5]<<16)+((UINT64)x[6]<< 8)+ (UINT64)x[7]));
+    default:
+      Error("unhandled endianness %d", HOST_ENDIANNESS);
+      return UINT64_C(0xFFFFFFFFFFFFFFFF);
+    }
 }
 
 
@@ -83,11 +94,11 @@ size_t binReadF77Block(int fileID, int byteswap)
 
 void binWriteF77Block(int fileID, int byteswap, size_t blocksize)
 {
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
   unsigned char f77block[4];
 
-  if ( IsBigendian() )
+  switch (HOST_ENDIANNESS)
     {
+    case CDI_BIGENDIAN:
       if ( byteswap )
 	{
 	  f77block[0] = (unsigned char) (blocksize);
@@ -102,9 +113,8 @@ void binWriteF77Block(int fileID, int byteswap, size_t blocksize)
 	  f77block[1] = (unsigned char) (blocksize >> 16);
 	  f77block[0] = (unsigned char) (blocksize >> 24);
 	}
-    }
-  else
-    {
+      break;
+    case CDI_LITTLEENDIAN:
       if ( byteswap )
 	{
 	  f77block[3] = (unsigned char) (blocksize);
@@ -119,6 +129,9 @@ void binWriteF77Block(int fileID, int byteswap, size_t blocksize)
 	  f77block[2] = (unsigned char) (blocksize >> 16);
 	  f77block[3] = (unsigned char) (blocksize >> 24);
 	}
+      break;
+    default:
+      Error("unhandled endianness %d", HOST_ENDIANNESS);
     }
 
   if ( fileWrite(fileID, f77block, 4) != 4 )
diff --git a/libcdi/src/binary.h b/libcdi/src/binary.h
index 2decfe5..1bd560f 100644
--- a/libcdi/src/binary.h
+++ b/libcdi/src/binary.h
@@ -1,12 +1,26 @@
 #ifndef _BINARY_H
 #define _BINARY_H
 
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <inttypes.h>
 #include <stdio.h>
 
 #ifndef _DTYPES_H
 #include "dtypes.h"
 #endif
 
+#ifndef HOST_ENDIANNESS
+#ifdef __cplusplus
+static const uint32_t HOST_ENDIANNESS_temp[1] = { UINT32_C(0x00030201) };
+#define HOST_ENDIANNESS (((const unsigned char *)HOST_ENDIANNESS_temp)[0])
+#else
+#define HOST_ENDIANNESS (((const unsigned char *)&(const uint32_t[1]){UINT32_C(0x00030201)})[0])
+#endif
+#endif
+
 
 UINT32 get_UINT32(unsigned char *x);
 UINT32 get_SUINT32(unsigned char *x);
diff --git a/libcdi/src/calendar.c b/libcdi/src/calendar.c
index b3b8ad7..ea4be87 100644
--- a/libcdi/src/calendar.c
+++ b/libcdi/src/calendar.c
@@ -2,6 +2,7 @@
 #include <stdio.h>
 
 #include "cdi.h"  		/* CALENDAR_ */
+#include "calendar.h"
 #include "error.h"
 #include "timebase.h"
 
@@ -128,79 +129,79 @@ static int encode_day(int dpy, int year, int month, int day)
 }
 
 
-int date_to_calday(int calendar, int date)
+void encode_caldaysec(int calendar, int year, int month, int day, int hour, int minute, int second,
+		      int *julday, int *secofday)
 {
-  int calday;
   int dpy;
-  int year, month, day;
 
   dpy = calendar_dpy(calendar);
 
-  cdiDecodeDate(date, &year, &month, &day);
-
   if ( dpy == 360 || dpy == 365 || dpy == 366 )
-    calday = encode_day(dpy, year, month, day);
+    *julday = encode_day(dpy, year, month, day);
   else
-    calday = encode_julday(calendar, year, month, day);
+    *julday = encode_julday(calendar, year, month, day);
 
-  return (calday);
+  *secofday = hour*3600 + minute*60 + second;
 }
 
 
-int calday_to_date(int calendar, int calday)
+void decode_caldaysec(int calendar, int julday, int secofday, 
+		      int *year, int *month, int *day, int *hour, int *minute, int *second)
 {
-  int date;
   int dpy;
-  int year, month, day;
 
   dpy = calendar_dpy(calendar);
 
   if ( dpy == 360 || dpy == 365 || dpy == 366 )
-    decode_day(dpy, calday, &year, &month, &day);
+    decode_day(dpy, julday, year, month, day);
   else
-    decode_julday(calendar, calday, &year, &month, &day);
-
-  date = cdiEncodeDate(year, month, day);
+    decode_julday(calendar, julday, year, month, day);
 
-  return (date);
+  *hour   = secofday/3600;
+  *minute = secofday/60 - *hour*60;
+  *second = secofday - *hour*3600 - *minute*60;
 }
 
 
-void encode_caldaysec(int calendar, int year, int month, int day, int hour, int minute, int second,
-		      int *julday, int *secofday)
+#ifdef TEST
+static int date_to_calday(int calendar, int date)
 {
+  int calday;
   int dpy;
+  int year, month, day;
 
   dpy = calendar_dpy(calendar);
 
+  cdiDecodeDate(date, &year, &month, &day);
+
   if ( dpy == 360 || dpy == 365 || dpy == 366 )
-    *julday = encode_day(dpy, year, month, day);
+    calday = encode_day(dpy, year, month, day);
   else
-    *julday = encode_julday(calendar, year, month, day);
+    calday = encode_julday(calendar, year, month, day);
 
-  *secofday = hour*3600 + minute*60 + second;
+  return (calday);
 }
 
 
-void decode_caldaysec(int calendar, int julday, int secofday, 
-		      int *year, int *month, int *day, int *hour, int *minute, int *second)
+static int calday_to_date(int calendar, int calday)
 {
+  int date;
   int dpy;
+  int year, month, day;
 
   dpy = calendar_dpy(calendar);
 
   if ( dpy == 360 || dpy == 365 || dpy == 366 )
-    decode_day(dpy, julday, year, month, day);
+    decode_day(dpy, calday, &year, &month, &day);
   else
-    decode_julday(calendar, julday, year, month, day);
+    decode_julday(calendar, calday, &year, &month, &day);
 
-  *hour   = secofday/3600;
-  *minute = secofday/60 - *hour*60;
-  *second = secofday - *hour*3600 - *minute*60;
+  date = cdiEncodeDate(year, month, day);
+
+  return (date);
 }
 
 
-#ifdef TEST
 int main(void)
 {
   int calendar = CALENDAR_STANDARD;
diff --git a/libcdi/src/calendar.h b/libcdi/src/calendar.h
index a0c432d..c5836e9 100644
--- a/libcdi/src/calendar.h
+++ b/libcdi/src/calendar.h
@@ -6,6 +6,11 @@ void encode_caldaysec(int calendar, int year, int month, int day, int hour, int
 void decode_caldaysec(int calendar, int julday, int secofday, 
 		      int *year, int *month, int *day, int *hour, int *minute, int *second);
 
+int calendar_dpy(int calendar);
+int days_per_year(int calendar, int year);
+int days_per_month(int calendar, int year, int month);
+
+
 #endif  /* _CALENDAR_H */
 /*
  * Local Variables:
diff --git a/libcdi/src/cdf.c b/libcdi/src/cdf.c
index 6832576..867e97e 100644
--- a/libcdi/src/cdf.c
+++ b/libcdi/src/cdf.c
@@ -83,11 +83,10 @@ void cdfComment(int ncid)
     }
 
   cdf_put_att_text(ncid, NC_GLOBAL, "CDI", strlen(comment), comment);
-  cdf_put_att_text(ncid, NC_GLOBAL, "Conventions", 6, "CF-1.4");
 }
 #endif
 
-int cdfOpenFile(const char *filename, const char *mode, int *filetype)
+static int cdfOpenFile(const char *filename, const char *mode, int *filetype)
 {
   int ncid = -1;
 #if  defined  (HAVE_LIBNETCDF)
@@ -126,7 +125,8 @@ int cdfOpenFile(const char *filename, const char *mode, int *filetype)
 	  else if ( *filetype == FILETYPE_NC4C ) writemode |= NC_NETCDF4 | NC_CLASSIC_MODEL;
 #endif
 	  cdf_create(filename, writemode, &ncid);
-	  cdfComment(ncid);
+	  if ( CDI_Version_Info ) cdfComment(ncid);
+          cdf_put_att_text(ncid, NC_GLOBAL, "Conventions", 6, "CF-1.4");
 	  break;
 	case 'a':
 	  cdf_open(filename, NC_WRITE, &ncid);
@@ -217,7 +217,7 @@ int cdf4Open(const char *filename, const char *mode, int *filetype)
 }
 
 
-void cdfCloseFile(int fileID)
+static void cdfCloseFile(int fileID)
 {
 #if  defined  (HAVE_LIBNETCDF)
   cdf_close(fileID);
diff --git a/libcdi/src/cdf.h b/libcdi/src/cdf.h
index 536c296..c15acf0 100644
--- a/libcdi/src/cdf.h
+++ b/libcdi/src/cdf.h
@@ -3,6 +3,8 @@
 
 void cdfDebug(int debug);
 
+extern int CDF_Debug;
+
 const char *cdfLibraryVersion(void);
 const char *hdfLibraryVersion(void);
 
diff --git a/libcdi/src/cdf_int.c b/libcdi/src/cdf_int.c
index 58d3d25..e9d1fbb 100644
--- a/libcdi/src/cdf_int.c
+++ b/libcdi/src/cdf_int.c
@@ -9,11 +9,10 @@
 
 #include "cdi.h"
 #include "cdi_int.h"
+#include "cdf.h"
 #include "cdf_int.h"
 #include "namespace.h"
 
-extern int CDF_Debug;
-
 #if  defined  (HAVE_LIBNETCDF)
 /*
 #if ! defined (MIN_BUF_SIZE)
@@ -24,7 +23,6 @@ static size_t ChunkSizeMin = MIN_BUF_SIZE;
 */
 void cdf_create(const char *path, int cmode, int *ncidp)
 {
-  int status;
   int oldfill;
   size_t initialsz = 0, chunksizehint = 0;
   /*
@@ -59,7 +57,7 @@ void cdf_create(const char *path, int cmode, int *ncidp)
 
   cdi_nc__create_funcp my_nc__create =
     (cdi_nc__create_funcp)namespaceSwitchGet(NSSWITCH_NC__CREATE).func;
-  status = my_nc__create(path, cmode, initialsz, &chunksizehint, ncidp);
+  int status = my_nc__create(path, cmode, initialsz, &chunksizehint, ncidp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d  mode = %d  file = %s", *ncidp, cmode, path);
@@ -114,15 +112,13 @@ int cdf_open(const char *path, int omode, int *ncidp)
 
   if ( CDF_Debug && status != NC_NOERR ) Message("%s", nc_strerror(status));
 
-  return (status);
+  return status;
 }
 
 
 void cdf_close(int ncid)
 {
-  int status;
-
-  status = nc_close(ncid);
+  int status = nc_close(ncid);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -130,9 +126,7 @@ void cdf_close(int ncid)
 
 void cdf_redef(int ncid)
 {
-  int status;
-
-  status = nc_redef(ncid);
+  int status = nc_redef(ncid);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -140,9 +134,7 @@ void cdf_redef(int ncid)
 
 void cdf_enddef(int ncid)
 {
-  int status;
-
-  status = nc_enddef(ncid);
+  int status = nc_enddef(ncid);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -150,13 +142,12 @@ void cdf_enddef(int ncid)
 
 void cdf__enddef(const int ncid, const size_t hdr_pad)
 {
-  int status;
   const size_t v_align   = 4UL; /* [B] Alignment of beginning of data section for fixed variables */
   const size_t v_minfree = 0UL; /* [B] Pad at end of data section for fixed size variables */
   const size_t r_align   = 4UL; /* [B] Alignment of beginning of data section for record variables */
 
   /* nc_enddef(ncid) is equivalent to nc__enddef(ncid, 0, 4, 0, 4) */
-  status = nc__enddef(ncid, hdr_pad, v_align, v_minfree, r_align);
+  int status = nc__enddef(ncid, hdr_pad, v_align, v_minfree, r_align);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -164,9 +155,7 @@ void cdf__enddef(const int ncid, const size_t hdr_pad)
 
 void cdf_sync(int ncid)
 {
-  int status;
-
-  status = nc_sync(ncid);
+  int status = nc_sync(ncid);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -174,9 +163,7 @@ void cdf_sync(int ncid)
 
 void cdf_inq(int ncid, int *ndimsp, int *nvarsp, int *ngattsp, int *unlimdimidp)
 {
-  int status;
-
-  status = nc_inq(ncid, ndimsp, nvarsp, ngattsp, unlimdimidp);
+  int status = nc_inq(ncid, ndimsp, nvarsp, ngattsp, unlimdimidp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d ndims = %d nvars = %d ngatts = %d unlimid = %d",
@@ -188,9 +175,7 @@ void cdf_inq(int ncid, int *ndimsp, int *nvarsp, int *ngattsp, int *unlimdimidp)
 
 void cdf_def_dim(int ncid, const char *name, size_t len, int *dimidp)
 {
-  int status;
-
-  status = nc_def_dim(ncid, name, len, dimidp);
+  int status = nc_def_dim(ncid, name, len, dimidp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d  name = %s  len = %d", ncid, name, len);
@@ -201,9 +186,7 @@ void cdf_def_dim(int ncid, const char *name, size_t len, int *dimidp)
 
 void cdf_inq_dimid(int ncid, const char *name, int *dimidp)
 {
-  int status;
-
-  status = nc_inq_dimid(ncid, name, dimidp);
+  int status = nc_inq_dimid(ncid, name, dimidp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d  name = %s  dimid= %d", ncid, name, *dimidp);
@@ -214,9 +197,7 @@ void cdf_inq_dimid(int ncid, const char *name, int *dimidp)
 
 void cdf_inq_dim(int ncid, int dimid, char *name, size_t * lengthp)
 {
-  int status;
-
-  status = nc_inq_dim(ncid, dimid, name, lengthp);
+  int status = nc_inq_dim(ncid, dimid, name, lengthp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d  dimid = %d  length = %d name = %s", ncid, dimid, *lengthp, name);
@@ -227,9 +208,7 @@ void cdf_inq_dim(int ncid, int dimid, char *name, size_t * lengthp)
 
 void cdf_inq_dimname(int ncid, int dimid, char *name)
 {
-  int status;
-
-  status = nc_inq_dimname(ncid, dimid, name);
+  int status = nc_inq_dimname(ncid, dimid, name);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d  dimid = %d  name = %s", ncid, dimid, name);
@@ -240,9 +219,7 @@ void cdf_inq_dimname(int ncid, int dimid, char *name)
 
 void cdf_inq_dimlen(int ncid, int dimid, size_t * lengthp)
 {
-  int status;
-
-  status = nc_inq_dimlen(ncid, dimid, lengthp);
+  int status = nc_inq_dimlen(ncid, dimid, lengthp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d dimid = %d length = %d", ncid, dimid, *lengthp);
@@ -276,9 +253,7 @@ cdf_def_var_serial(int ncid, const char *name, nc_type xtype, int ndims,
 
 void cdf_inq_varid(int ncid, const char *name, int *varidp)
 {
-  int status;
-
-  status = nc_inq_varid(ncid, name, varidp);
+  int status = nc_inq_varid(ncid, name, varidp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d  name = %s  varid = %d ", ncid, name, *varidp);
@@ -289,9 +264,7 @@ void cdf_inq_varid(int ncid, const char *name, int *varidp)
 
 void cdf_inq_nvars(int ncid, int *nvarsp)
 {
-  int status;
-
-  status = nc_inq_nvars(ncid, nvarsp);
+  int status = nc_inq_nvars(ncid, nvarsp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d  nvars = %d", ncid, *nvarsp);
@@ -303,9 +276,7 @@ void cdf_inq_nvars(int ncid, int *nvarsp)
 void cdf_inq_var(int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp,
 		 int dimids[], int *nattsp)
 {
-  int status;
-
-  status = nc_inq_var(ncid, varid, name, xtypep, ndimsp, dimids, nattsp);
+  int status = nc_inq_var(ncid, varid, name, xtypep, ndimsp, dimids, nattsp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d ndims = %d xtype = %d natts = %d name = %s",
@@ -317,9 +288,7 @@ void cdf_inq_var(int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp,
 
 void cdf_inq_varname(int ncid, int varid, char *name)
 {
-  int status;
-
-  status = nc_inq_varname(ncid, varid, name);
+  int status = nc_inq_varname(ncid, varid, name);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d name = %s", ncid, varid, name);
@@ -330,9 +299,7 @@ void cdf_inq_varname(int ncid, int varid, char *name)
 
 void cdf_inq_vartype(int ncid, int varid, nc_type *xtypep)
 {
-  int status;
-
-  status = nc_inq_vartype(ncid, varid, xtypep);
+  int status = nc_inq_vartype(ncid, varid, xtypep);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d xtype = %s", ncid, varid, *xtypep);
@@ -343,9 +310,7 @@ void cdf_inq_vartype(int ncid, int varid, nc_type *xtypep)
 
 void cdf_inq_varndims(int ncid, int varid, int *ndimsp)
 {
-  int status;
-
-  status = nc_inq_varndims(ncid, varid, ndimsp);
+  int status = nc_inq_varndims(ncid, varid, ndimsp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -356,9 +321,7 @@ void cdf_inq_varndims(int ncid, int varid, int *ndimsp)
 
 void cdf_inq_vardimid(int ncid, int varid, int dimids[])
 {
-  int status;
-
-  status = nc_inq_vardimid(ncid, varid, dimids);
+  int status = nc_inq_vardimid(ncid, varid, dimids);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -369,9 +332,7 @@ void cdf_inq_vardimid(int ncid, int varid, int dimids[])
 
 void cdf_inq_varnatts(int ncid, int varid, int *nattsp)
 {
-  int status;
-
-  status = nc_inq_varnatts(ncid, varid, nattsp);
+  int status = nc_inq_varnatts(ncid, varid, nattsp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d nattsp = %d", ncid, varid, *nattsp);
@@ -382,9 +343,7 @@ void cdf_inq_varnatts(int ncid, int varid, int *nattsp)
 
 void cdf_put_var_text(int ncid, int varid, const char *tp)
 {
-  int status;
-
-  status = nc_put_var_text(ncid, varid, tp);
+  int status = nc_put_var_text(ncid, varid, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("%d %d %s", ncid, varid, tp);
@@ -395,9 +354,7 @@ void cdf_put_var_text(int ncid, int varid, const char *tp)
 
 void cdf_put_var_short(int ncid, int varid, const short *sp)
 {
-  int status;
-
-  status = nc_put_var_short(ncid, varid, sp);
+  int status = nc_put_var_short(ncid, varid, sp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("%d %d %hd", ncid, varid, *sp);
@@ -408,9 +365,7 @@ void cdf_put_var_short(int ncid, int varid, const short *sp)
 
 void cdf_put_var_int(int ncid, int varid, const int *ip)
 {
-  int status;
-
-  status = nc_put_var_int(ncid, varid, ip);
+  int status = nc_put_var_int(ncid, varid, ip);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("%d %d %d", ncid, varid, *ip);
@@ -421,9 +376,7 @@ void cdf_put_var_int(int ncid, int varid, const int *ip)
 
 void cdf_put_var_long(int ncid, int varid, const long *lp)
 {
-  int status;
-
-  status = nc_put_var_long(ncid, varid, lp);
+  int status = nc_put_var_long(ncid, varid, lp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("%d %d %ld", ncid, varid, *lp);
@@ -434,9 +387,7 @@ void cdf_put_var_long(int ncid, int varid, const long *lp)
 
 void cdf_put_var_float(int ncid, int varid, const float *fp)
 {
-  int status;
-
-  status = nc_put_var_float(ncid, varid, fp);
+  int status = nc_put_var_float(ncid, varid, fp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("%d %d %f", ncid, varid, *fp);
@@ -448,9 +399,7 @@ void cdf_put_var_float(int ncid, int varid, const float *fp)
 void cdf_put_vara_double(int ncid, int varid, const size_t start[],
                          const size_t count[], const double *dp)
 {
-  int status;
-
-  status = nc_put_vara_double(ncid, varid, start, count, dp);
+  int status = nc_put_vara_double(ncid, varid, start, count, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d val0 = %f", ncid, varid, *dp);
@@ -469,9 +418,7 @@ void cdf_put_vara_double(int ncid, int varid, const size_t start[],
 void  cdf_put_vara_float(int ncid, int varid, const size_t start[],
                          const size_t count[], const float *fp)
 {
-  int status;
-
-  status = nc_put_vara_float(ncid, varid, start, count, fp);
+  int status = nc_put_vara_float(ncid, varid, start, count, fp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d val0 = %f", ncid, varid, *fp);
@@ -483,9 +430,7 @@ void  cdf_put_vara_float(int ncid, int varid, const size_t start[],
 void  cdf_get_vara_int(int ncid, int varid, const size_t start[],
                        const size_t count[], int *dp)
 {
-  int status;
-
-  status = nc_get_vara_int(ncid, varid, start, count, dp);
+  int status = nc_get_vara_int(ncid, varid, start, count, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -497,9 +442,7 @@ void  cdf_get_vara_int(int ncid, int varid, const size_t start[],
 void  cdf_get_vara_double(int ncid, int varid, const size_t start[],
                           const size_t count[], double *dp)
 {
-  int status;
-
-  status = nc_get_vara_double(ncid, varid, start, count, dp);
+  int status = nc_get_vara_double(ncid, varid, start, count, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -511,9 +454,7 @@ void  cdf_get_vara_double(int ncid, int varid, const size_t start[],
 void  cdf_get_vara_float(int ncid, int varid, const size_t start[],
                          const size_t count[], float *fp)
 {
-  int status;
-
-  status = nc_get_vara_float(ncid, varid, start, count, fp);
+  int status = nc_get_vara_float(ncid, varid, start, count, fp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -525,9 +466,7 @@ void  cdf_get_vara_float(int ncid, int varid, const size_t start[],
 void  cdf_get_vara_text(int ncid, int varid, const size_t start[],
 			const size_t count[], char *tp)
 {
-  int status;
-
-  status = nc_get_vara_text(ncid, varid, start, count, tp);
+  int status = nc_get_vara_text(ncid, varid, start, count, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -538,9 +477,7 @@ void  cdf_get_vara_text(int ncid, int varid, const size_t start[],
 
 void  cdf_get_vara_uchar(int ncid, int varid, const size_t start[], const size_t count[], unsigned char *tp)
 {
-  int status;
-
-  status = nc_get_vara_uchar(ncid, varid, start, count, tp);
+  int status = nc_get_vara_uchar(ncid, varid, start, count, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -551,9 +488,7 @@ void  cdf_get_vara_uchar(int ncid, int varid, const size_t start[], const size_t
 
 void cdf_put_var_double(int ncid, int varid, const double *dp)
 {
-  int status;
-
-  status = nc_put_var_double(ncid, varid, dp);
+  int status = nc_put_var_double(ncid, varid, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d val0 = %f", ncid, varid, *dp);
@@ -564,9 +499,7 @@ void cdf_put_var_double(int ncid, int varid, const double *dp)
 
 void cdf_get_var1_text(int ncid, int varid, const size_t index[], char *tp)
 {
-  int status;
-
-  status = nc_get_var1_text(ncid, varid, index, tp);
+  int status = nc_get_var1_text(ncid, varid, index, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -577,9 +510,7 @@ void cdf_get_var1_text(int ncid, int varid, const size_t index[], char *tp)
 
 void cdf_get_var1_double(int ncid, int varid, const size_t index[], double *dp)
 {
-  int status;
-
-  status = nc_get_var1_double(ncid, varid, index, dp);
+  int status = nc_get_var1_double(ncid, varid, index, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -590,9 +521,7 @@ void cdf_get_var1_double(int ncid, int varid, const size_t index[], double *dp)
 
 void cdf_put_var1_double(int ncid, int varid, const size_t index[], const double *dp)
 {
-  int status;
-
-  status = nc_put_var1_double(ncid, varid, index, dp);
+  int status = nc_put_var1_double(ncid, varid, index, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d val = %f", ncid, varid, *dp);
@@ -603,9 +532,7 @@ void cdf_put_var1_double(int ncid, int varid, const size_t index[], const double
 
 void cdf_get_var_text(int ncid, int varid, char *tp)
 {
-  int status;
-
-  status = nc_get_var_text(ncid, varid, tp);
+  int status = nc_get_var_text(ncid, varid, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -616,9 +543,7 @@ void cdf_get_var_text(int ncid, int varid, char *tp)
 
 void cdf_get_var_short(int ncid, int varid, short *sp)
 {
-  int status;
-
-  status = nc_get_var_short(ncid, varid, sp);
+  int status = nc_get_var_short(ncid, varid, sp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -629,9 +554,7 @@ void cdf_get_var_short(int ncid, int varid, short *sp)
 
 void cdf_get_var_int(int ncid, int varid, int *ip)
 {
-  int status;
-
-  status = nc_get_var_int(ncid, varid, ip);
+  int status = nc_get_var_int(ncid, varid, ip);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -642,9 +565,7 @@ void cdf_get_var_int(int ncid, int varid, int *ip)
 
 void cdf_get_var_long(int ncid, int varid, long *lp)
 {
-  int status;
-
-  status = nc_get_var_long(ncid, varid, lp);
+  int status = nc_get_var_long(ncid, varid, lp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -655,9 +576,7 @@ void cdf_get_var_long(int ncid, int varid, long *lp)
 
 void cdf_get_var_float(int ncid, int varid, float *fp)
 {
-  int status;
-
-  status = nc_get_var_float(ncid, varid, fp);
+  int status = nc_get_var_float(ncid, varid, fp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -668,9 +587,7 @@ void cdf_get_var_float(int ncid, int varid, float *fp)
 
 void cdf_get_var_double(int ncid, int varid, double *dp)
 {
-  int status;
-
-  status = nc_get_var_double(ncid, varid, dp);
+  int status = nc_get_var_double(ncid, varid, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d val[0] = %f", ncid, varid, *dp);
@@ -682,9 +599,7 @@ void cdf_get_var_double(int ncid, int varid, double *dp)
 void cdf_copy_att(int ncid_in, int varid_in, const char *name, int ncid_out,
 		  int varid_out)
 {
-  int status;
-
-  status = nc_copy_att(ncid_in, varid_in, name, ncid_out, varid_out);
+  int status = nc_copy_att(ncid_in, varid_in, name, ncid_out, varid_out);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("%d %d %s %d %d", ncid_in, varid_out, name, ncid_out, varid_out);
@@ -696,9 +611,7 @@ void cdf_copy_att(int ncid_in, int varid_in, const char *name, int ncid_out,
 void cdf_put_att_text(int ncid, int varid, const char *name, size_t len,
 		      const char *tp)
 {
-  int status;
-
-  status = nc_put_att_text(ncid, varid, name, len, tp);
+  int status = nc_put_att_text(ncid, varid, name, len, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d att = %s text = %.*s", ncid, varid, name, (int)len, tp);
@@ -710,9 +623,7 @@ void cdf_put_att_text(int ncid, int varid, const char *name, size_t len,
 void cdf_put_att_int(int ncid, int varid, const char *name, nc_type xtype,
 		     size_t len, const int *ip)
 {
-  int status;
-
-  status = nc_put_att_int(ncid, varid, name, xtype, len, ip);
+  int status = nc_put_att_int(ncid, varid, name, xtype, len, ip);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d att = %s val = %d", ncid, varid, name, *ip);
@@ -721,15 +632,25 @@ void cdf_put_att_int(int ncid, int varid, const char *name, nc_type xtype,
 }
 
 
+void cdf_put_att_float(int ncid, int varid, const char *name, nc_type xtype,
+                       size_t len, const float *dp)
+{
+  int status = nc_put_att_float(ncid, varid, name, xtype, len, dp);
+
+  if ( CDF_Debug || status != NC_NOERR )
+    Message("ncid = %d varid = %d att = %s val = %g", ncid, varid, name, *dp);
+
+  if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
+}
+
+
 void cdf_put_att_double(int ncid, int varid, const char *name, nc_type xtype,
 			size_t len, const double *dp)
 {
-  int status;
-
-  status = nc_put_att_double(ncid, varid, name, xtype, len, dp);
+  int status = nc_put_att_double(ncid, varid, name, xtype, len, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("%d %d %f", ncid, varid, *dp);
+    Message("ncid = %d varid = %d att = %s val = %g", ncid, varid, name, *dp);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -737,9 +658,7 @@ void cdf_put_att_double(int ncid, int varid, const char *name, nc_type xtype,
 
 void cdf_get_att_text(int ncid, int varid, const char *name, char *tp)
 {
-  int status;
-
-  status = nc_get_att_text(ncid, varid, name, tp);
+  int status = nc_get_att_text(ncid, varid, name, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d name = %s", ncid, varid, name);
@@ -750,9 +669,7 @@ void cdf_get_att_text(int ncid, int varid, const char *name, char *tp)
 void cdf_get_att_string(int ncid, int varid, const char *name, char **tp)
 {
 #if  defined  (HAVE_NETCDF4)
-  int status;
-
-  status = nc_get_att_string(ncid, varid, name, tp);
+  int status = nc_get_att_string(ncid, varid, name, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d name = %s", ncid, varid, name);
@@ -764,9 +681,7 @@ void cdf_get_att_string(int ncid, int varid, const char *name, char **tp)
 
 void cdf_get_att_int(int ncid, int varid, const char *name, int *ip)
 {
-  int status;
-
-  status = nc_get_att_int(ncid, varid, name, ip);
+  int status = nc_get_att_int(ncid, varid, name, ip);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d att = %s val = %d", ncid, varid, name, *ip);
@@ -782,8 +697,7 @@ void cdf_get_att_double(int ncid, int varid, const char *name, double *dp)
   status = nc_get_att_double(ncid, varid, name, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("ncid = %d varid = %d att = %s val = %.9g",
-	    ncid, varid, name, *dp);
+    Message("ncid = %d varid = %d att = %s val = %.9g", ncid, varid, name, *dp);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -792,12 +706,10 @@ void cdf_get_att_double(int ncid, int varid, const char *name, double *dp)
 void cdf_inq_att(int ncid, int varid, const char *name, nc_type *xtypep,
 		 size_t *lenp)
 {
-  int status;
-
-  status = nc_inq_att(ncid, varid, name, xtypep, lenp);
+  int status = nc_inq_att(ncid, varid, name, xtypep, lenp);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("ncid = %d varid = %d", ncid, varid);
+    Message("ncid = %d varid = %d att = %s", ncid, varid, name);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -805,12 +717,10 @@ void cdf_inq_att(int ncid, int varid, const char *name, nc_type *xtypep,
 
 void cdf_inq_atttype(int ncid, int varid, const char *name, nc_type * xtypep)
 {
-  int status;
-
-  status = nc_inq_atttype(ncid, varid, name, xtypep);
+  int status = nc_inq_atttype(ncid, varid, name, xtypep);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("ncid = %d varid = %d", ncid, varid);
+    Message("ncid = %d varid = %d att = %s", ncid, varid, name);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -818,12 +728,10 @@ void cdf_inq_atttype(int ncid, int varid, const char *name, nc_type * xtypep)
 
 void cdf_inq_attlen(int ncid, int varid, const char *name, size_t * lenp)
 {
-  int status;
-
-  status = nc_inq_attlen(ncid, varid, name, lenp);
+  int status = nc_inq_attlen(ncid, varid, name, lenp);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("ncid = %d varid = %d name = %s len = %d", ncid, varid, name, *lenp);
+    Message("ncid = %d varid = %d att = %s len = %d", ncid, varid, name, *lenp);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -831,12 +739,10 @@ void cdf_inq_attlen(int ncid, int varid, const char *name, size_t * lenp)
 
 void cdf_inq_attname(int ncid, int varid, int attnum, char *name)
 {
-  int status;
-
-  status = nc_inq_attname(ncid, varid, attnum, name);
+  int status = nc_inq_attname(ncid, varid, attnum, name);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("ncid = %d varid = %d attnum = %d name = %s", ncid, varid, attnum, name);
+    Message("ncid = %d varid = %d attnum = %d att = %s", ncid, varid, attnum, name);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -844,12 +750,10 @@ void cdf_inq_attname(int ncid, int varid, int attnum, char *name)
 
 void cdf_inq_attid(int ncid, int varid, const char *name, int *attnump)
 {
-  int status;
-
-  status = nc_inq_attid(ncid, varid, name, attnump);
+  int status = nc_inq_attid(ncid, varid, name, attnump);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("ncid = %d varid = %d", ncid, varid);
+    Message("ncid = %d varid = %d att = %s", ncid, varid, name);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
diff --git a/libcdi/src/cdf_int.h b/libcdi/src/cdf_int.h
index 759d447..223091e 100644
--- a/libcdi/src/cdf_int.h
+++ b/libcdi/src/cdf_int.h
@@ -65,9 +65,12 @@ void cdf_put_vara_double(int ncid, int varid, const size_t start[], const size_t
 
 void cdf_get_vara_float(int ncid, int varid, const size_t start[], const size_t count[], float *fp);
 void cdf_put_vara_float(int ncid, int varid, const size_t start[], const size_t count[], const float *fp);
+void  cdf_get_vara_int(int ncid, int varid, const size_t start[],
+                       const size_t count[], int *dp);
 
 void cdf_put_att_text(int ncid, int varid, const char *name, size_t len, const char *tp);
 void cdf_put_att_int(int ncid, int varid, const char *name, nc_type xtype, size_t len, const int *ip);
+void cdf_put_att_float(int ncid, int varid, const char *name, nc_type xtype, size_t len, const float *dp);
 void cdf_put_att_double(int ncid, int varid, const char *name, nc_type xtype, size_t len, const double *dp);
 
 void cdf_get_att_string(int ncid, int varid, const char *name, char **tp);
diff --git a/libcdi/src/cdi.h b/libcdi/src/cdi.h
index 8b1dc0e..60d383e 100644
--- a/libcdi/src/cdi.h
+++ b/libcdi/src/cdi.h
@@ -10,7 +10,7 @@
 #include <stdio.h>
 #include <sys/types.h>
 /*
-#if defined(__cplusplus)
+#ifdef __cplusplus
 extern "C" {
 #endif
 */
@@ -23,6 +23,7 @@ extern "C" {
 
 #define  CDI_BIGENDIAN            0   /* Byte order BIGENDIAN                 */
 #define  CDI_LITTLEENDIAN         1   /* Byte order LITTLEENDIAN              */
+#define  CDI_PDPENDIAN            2
 
 #define  CDI_REAL                 1   /* Real numbers                         */
 #define  CDI_COMP                 2   /* Complex numbers                      */
@@ -169,6 +170,26 @@ extern "C" {
 #define  ZAXIS_MIX_LAYER           24  /* Mixing Layer                                          */
 #define  ZAXIS_REFERENCE           25  /* zaxis reference number                                */
 
+/* SUBTYPE types */
+
+enum {
+  SUBTYPE_TILES                         = 0  /* Tiles variable                                  */
+};
+
+#define MAX_KV_PAIRS_MATCH 10
+
+/* Data structure defining a key-value search, possibly with multiple
+   key-value pairs in combination.
+
+   Currently, only multiple pairs combined by AND are supported.
+*/
+typedef struct  {
+  int nAND;                                   /* no. of key-value pairs that have to match */
+  int key_value_pairs[2][MAX_KV_PAIRS_MATCH]; /* key-value pairs */
+} subtype_query_t;
+
+
+
 /* TIME types */
 
 #define  TIME_CONSTANT              0  /* obsolate, use TSTEP_CONSTANT                          */
@@ -249,8 +270,9 @@ void    cdiDefMissval(double missval);
 double  cdiInqMissval(void);
 void    cdiDefGlobal(const char *string, int val);
 
-int     namespaceNew();
+int     namespaceNew(void);
 void    namespaceSetActive(int namespaceID);
+int     namespaceGetActive(void);
 void    namespaceDelete(int namespaceID);
 
 
@@ -296,8 +318,6 @@ void    streamDefVlist(int streamID, int vlistID);
 
 /*      streamInqVlist: Get the Vlist of a stream */
 int     streamInqVlist(int streamID);
-/*      PIO: */
-int     streamInqVlistIDorig(int streamID);
 
 /*      streamInqFiletype: Get the filetype */
 int     streamInqFiletype(int streamID);
@@ -329,8 +349,8 @@ int     streamInqTimestep(int streamID, int tsID);
 /*      PIO: query currently set timestep id  */
 int     streamInqCurTimestepID(int streamID);
 
-const char* streamFilename(int streamID);
-const char* streamFilesuffix(int filetype);
+const char *streamFilename(int streamID);
+const char *streamFilesuffix(int filetype);
 
 off_t   streamNvals(int streamID);
 
@@ -339,31 +359,31 @@ int     streamInqNvars ( int streamID );
 /* STREAM var I/O routines */
 
 /*      streamWriteVar: Write a variable */
-void    streamWriteVar(int streamID, int varID, const double *data_vec, int nmiss);
-void    streamWriteVarF(int streamID, int varID, const float *data_vec, int nmiss);
+void    streamWriteVar(int streamID, int varID, const double data[], int nmiss);
+void    streamWriteVarF(int streamID, int varID, const float data[], int nmiss);
 
 /*      streamReadVar: Read a variable */
-void    streamReadVar(int streamID, int varID, double *data_vec, int *nmiss);
-void    streamReadVarF(int streamID, int varID, float *data_vec, int *nmiss);
+void    streamReadVar(int streamID, int varID, double data[], int *nmiss);
+void    streamReadVarF(int streamID, int varID, float data[], int *nmiss);
 
 /*      streamWriteVarSlice: Write a horizontal slice of a variable */
-void    streamWriteVarSlice(int streamID, int varID, int levelID, const double *data_vec, int nmiss);
-void    streamWriteVarSliceF(int streamID, int varID, int levelID, const float *data_vec, int nmiss);
+void    streamWriteVarSlice(int streamID, int varID, int levelID, const double data[], int nmiss);
+void    streamWriteVarSliceF(int streamID, int varID, int levelID, const float data[], int nmiss);
 
 /*      streamReadVarSlice: Read a horizontal slice of a variable */
-void    streamReadVarSlice(int streamID, int varID, int levelID, double *data_vec, int *nmiss);
-void    streamReadVarSliceF(int streamID, int varID, int levelID, float *data_vec, int *nmiss);
+void    streamReadVarSlice(int streamID, int varID, int levelID, double data[], int *nmiss);
+void    streamReadVarSliceF(int streamID, int varID, int levelID, float data[], int *nmiss);
 
-void    streamWriteVarChunk(int streamID, int varID, const int rect[3][2], const double *data_vec, int nmiss);
+void    streamWriteVarChunk(int streamID, int varID, const int rect[3][2], const double data[], int nmiss);
 
 
 /* STREAM record I/O routines */
 
 void    streamDefRecord(int streamID, int  varID, int  levelID);
 void    streamInqRecord(int streamID, int *varID, int *levelID);
-void    streamWriteRecord(int streamID, const double *data_vec, int nmiss);
-void    streamWriteRecordF(int streamID, const float *data_vec, int nmiss);
-void    streamReadRecord(int streamID, double *data_vec, int *nmiss);
+void    streamWriteRecord(int streamID, const double data[], int nmiss);
+void    streamWriteRecordF(int streamID, const float data[], int nmiss);
+void    streamReadRecord(int streamID, double data[], int *nmiss);
 void    streamCopyRecord(int streamIDdest, int streamIDsrc);
 
 void    streamInqGRIBinfo(int streamID, int *intnum, float *fltnum, off_t *bignum);
@@ -372,56 +392,56 @@ void    streamInqGRIBinfo(int streamID, int *intnum, float *fltnum, off_t *bignu
 /* File driven I/O (may yield better performance than using the streamXXX functions) */
 
 //Creation & Destruction
-CdiIterator* cdiIterator_new(const char* path);  //Requires a subsequent call to cdiIteratorNextField() to point the iterator at the first field.
-CdiIterator* cdiIterator_clone(CdiIterator* me);
-char* cdiIterator_serialize(CdiIterator* me);  //Returns a malloc'ed string.
-CdiIterator* cdiIterator_deserialize(const char* description);  //description is a string that was returned by cdiIteratorSerialize(). Returns a copy of the original iterator.
-void cdiIterator_print(CdiIterator* me, FILE* stream);
-void cdiIterator_delete(CdiIterator* me);
+CdiIterator *cdiIterator_new(const char *path);  //Requires a subsequent call to cdiIteratorNextField() to point the iterator at the first field.
+CdiIterator *cdiIterator_clone(CdiIterator *me);
+char *cdiIterator_serialize(CdiIterator *me);  //Returns a malloc'ed string.
+CdiIterator *cdiIterator_deserialize(const char *description);  //description is a string that was returned by cdiIteratorSerialize(). Returns a copy of the original iterator.
+void cdiIterator_print(CdiIterator *me, FILE *stream);
+void cdiIterator_delete(CdiIterator *me);
 
 //Advancing an iterator
-int cdiIterator_nextField(CdiIterator* me);      //Points the iterator at the next field, returns CDI_EEOF if there are no more fields in the file.
+int cdiIterator_nextField(CdiIterator *me);      //Points the iterator at the next field, returns CDI_EEOF if there are no more fields in the file.
 
 //Introspecting metadata
 //All outXXX arguments to these functions may be NULL.
-char* cdiIterator_inqStartTime(CdiIterator* me);      //Returns the (start) time as an ISO-8601 coded string. The caller is responsible to free() the returned string.
-char* cdiIterator_inqEndTime(CdiIterator* me);      //Returns the end time of an integration period as an ISO-8601 coded string, or NULL if there is no end time. The caller is responsible to free() the returned string.
-char* cdiIterator_inqVTime(CdiIterator* me);      //Returns the validity date as an ISO-8601 coded string. The caller is responsible to free() the returned string.
-int cdiIterator_inqLevelType(CdiIterator* me, int levelSelector, char** outName, char** outLongName, char** outStdName, char** outUnit);      //callers are responsible to free() strings that they request
-int cdiIterator_inqLevel(CdiIterator* me, int levelSelector, double* outValue1, double* outValue2);       //outValue2 is only written to if the level is a hybrid level
-int cdiIterator_inqLevelUuid(CdiIterator* me, int* outVgridNumber, int* outLevelCount, unsigned char (*outUuid)[CDI_UUID_SIZE]);   //outUuid must point to a buffer of 16 bytes, returns an error code if no generalized zaxis is used.
-CdiParam cdiIterator_inqParam(CdiIterator* me);
-int cdiIterator_inqDatatype(CdiIterator* me);
-int cdiIterator_inqTsteptype(CdiIterator* me);
-char* cdiIterator_inqVariableName(CdiIterator* me);        //The caller is responsible to free() the returned buffer.
-int cdiIterator_inqGridId(CdiIterator* me);         //The returned id is only valid until the next call to cdiIteratorNextField().
+char *cdiIterator_inqStartTime(CdiIterator *me);      //Returns the (start) time as an ISO-8601 coded string. The caller is responsible to Free() the returned string.
+char *cdiIterator_inqEndTime(CdiIterator *me);      //Returns the end time of an integration period as an ISO-8601 coded string, or NULL if there is no end time. The caller is responsible to Free() the returned string.
+char *cdiIterator_inqVTime(CdiIterator *me);      //Returns the validity date as an ISO-8601 coded string. The caller is responsible to Free() the returned string.
+int cdiIterator_inqLevelType(CdiIterator *me, int levelSelector, char **outName_optional, char **outLongName_optional, char **outStdName_optional, char **outUnit_optional);      //callers are responsible to Free() strings that they request
+int cdiIterator_inqLevel(CdiIterator *me, int levelSelector, double *outValue1_optional, double *outValue2_optional);       //outValue2 is only written to if the level is a hybrid level
+int cdiIterator_inqLevelUuid(CdiIterator *me, int *outVgridNumber_optional, int *outLevelCount_optional, unsigned char outUuid_optional[CDI_UUID_SIZE]);   //outUuid must point to a buffer of 16 bytes, returns an error code if no generalized zaxis is used.
+CdiParam cdiIterator_inqParam(CdiIterator *me);
+int cdiIterator_inqDatatype(CdiIterator *me);
+int cdiIterator_inqTsteptype(CdiIterator *me);
+char *cdiIterator_inqVariableName(CdiIterator *me);        //The caller is responsible to Free() the returned buffer.
+int cdiIterator_inqGridId(CdiIterator *me);         //The returned id is only valid until the next call to cdiIteratorNextField().
 
 //Reading data
-void cdiIterator_readField(CdiIterator* me, double* data_vec, size_t* nmiss);
-void cdiIterator_readFieldF(CdiIterator* me, float* data_vec, size_t* nmiss);
+void cdiIterator_readField(CdiIterator *me, double data[], size_t *nmiss_optional);
+void cdiIterator_readFieldF(CdiIterator *me, float data[], size_t *nmiss_optional);
 //TODO[NH]: Add functions to read partial fields.
 
 
 //Direct access to grib fields
-CdiGribIterator* cdiGribIterator_clone(CdiIterator* me);  //Returns NULL if the associated file is not a GRIB file.
-void cdiGribIterator_delete(CdiGribIterator* me);
+CdiGribIterator *cdiGribIterator_clone(CdiIterator *me);  //Returns NULL if the associated file is not a GRIB file.
+void cdiGribIterator_delete(CdiGribIterator *me);
 
 //Callthroughs to GRIB-API
-int cdiGribIterator_getLong(CdiGribIterator* me, const char* key, long* value); //Same semantics as grib_get_long().
-int cdiGribIterator_getDouble(CdiGribIterator* me, const char* key, double* value); //Same semantics as grib_get_double().
-int cdiGribIterator_getLength(CdiGribIterator* me, const char* key, size_t* value);     //Same semantics as grib_get_length().
-int cdiGribIterator_getString(CdiGribIterator* me, const char* key, char* value, size_t* length);       //Same semantics as grib_get_string().
-int cdiGribIterator_getSize(CdiGribIterator* me, const char* key, size_t* value);     //Same semantics as grib_get_size().
-int cdiGribIterator_getLongArray(CdiGribIterator* me, const char* key, long* value, size_t* array_size);       //Same semantics as grib_get_long_array().
-int cdiGribIterator_getDoubleArray(CdiGribIterator* me, const char* key, double* value, size_t* array_size);       //Same semantics as grib_get_double_array().
+int cdiGribIterator_getLong(CdiGribIterator *me, const char *key, long *value); //Same semantics as grib_get_long().
+int cdiGribIterator_getDouble(CdiGribIterator *me, const char *key, double *value); //Same semantics as grib_get_double().
+int cdiGribIterator_getLength(CdiGribIterator *me, const char *key, size_t *value);     //Same semantics as grib_get_length().
+int cdiGribIterator_getString(CdiGribIterator *me, const char *key, char *value, size_t *length);       //Same semantics as grib_get_string().
+int cdiGribIterator_getSize(CdiGribIterator *me, const char *key, size_t *value);     //Same semantics as grib_get_size().
+int cdiGribIterator_getLongArray(CdiGribIterator *me, const char *key, long *value, size_t *array_size);       //Same semantics as grib_get_long_array().
+int cdiGribIterator_getDoubleArray(CdiGribIterator *me, const char *key, double *value, size_t *array_size);       //Same semantics as grib_get_double_array().
 
 //Convenience functions for accessing GRIB-API keys
-int cdiGribIterator_inqEdition(CdiGribIterator* me);
-long cdiGribIterator_inqLongValue(CdiGribIterator* me, const char* key);   //Aborts on failure to fetch the given key.
-long cdiGribIterator_inqLongDefaultValue(CdiGribIterator* me, const char* key, long defaultValue); //Returns the default value if the given key is not present.
-double cdiGribIterator_inqDoubleValue(CdiGribIterator* me, const char* key);   //Aborts on failure to fetch the given key.
-double cdiGribIterator_inqDoubleDefaultValue(CdiGribIterator* me, const char* key, double defaultValue); //Returns the default value if the given key is not present.
-char* cdiGribIterator_inqStringValue(CdiGribIterator* me, const char* key);        //Returns a malloc'ed string.
+int cdiGribIterator_inqEdition(CdiGribIterator *me);
+long cdiGribIterator_inqLongValue(CdiGribIterator *me, const char *key);   //Aborts on failure to fetch the given key.
+long cdiGribIterator_inqLongDefaultValue(CdiGribIterator *me, const char *key, long defaultValue); //Returns the default value if the given key is not present.
+double cdiGribIterator_inqDoubleValue(CdiGribIterator *me, const char *key);   //Aborts on failure to fetch the given key.
+double cdiGribIterator_inqDoubleDefaultValue(CdiGribIterator *me, const char *key, double defaultValue); //Returns the default value if the given key is not present.
+char *cdiGribIterator_inqStringValue(CdiGribIterator *me, const char *key);        //Returns a malloc'ed string.
 
 /* VLIST routines */
 
@@ -462,6 +482,9 @@ int     vlistNgrids(int vlistID);
 /*      vlistNzaxis: Number of zaxis in a variable list */
 int     vlistNzaxis(int vlistID);
 
+/*      vlistNsubtypes: Number of subtypes in a variable list */
+int     vlistNsubtypes(int vlistID);
+
 void    vlistDefNtsteps(int vlistID, int nts);
 int     vlistNtsteps(int vlistID);
 int     vlistGridsizeMax(int vlistID);
@@ -474,6 +497,8 @@ int     vlistZaxisIndex(int vlistID, int zaxisID);
 void    vlistChangeZaxisIndex(int vlistID, int index, int zaxisID);
 void    vlistChangeZaxis(int vlistID, int zaxisID1, int zaxisID2);
 int     vlistNrecs(int vlistID);
+int     vlistSubtype(int vlistID, int index);
+int     vlistSubtypeIndex(int vlistID, int subtypeID);
 
 /*      vlistDefTaxis: Define the time axis of a variable list */
 void    vlistDefTaxis(int vlistID, int taxisID);
@@ -491,7 +516,10 @@ int     vlistInqModel(int vlistID);
 
 /* VLIST VAR routines */
 
-/*      vlistDefVar: Create a new Variable */
+/*      vlistDefVarTiles: Create a new tile-based variable */
+int     vlistDefVarTiles(int vlistID, int gridID, int zaxisID, int tsteptype, int tilesetID);
+
+/*      vlistDefVar: Create a new variable */
 int     vlistDefVar(int vlistID, int gridID, int zaxisID, int tsteptype);
 
 void    vlistChangeVarGrid(int vlistID, int varID, int gridID);
@@ -552,7 +580,7 @@ void    vlistDefVarName(int vlistID, int varID, const char *name);
 void    vlistInqVarName(int vlistID, int varID, char *name);
 
 /*      vlistCopyVarName: Safe and convenient version of vlistInqVarName */
-char* vlistCopyVarName(int vlistId, int varId);
+char *vlistCopyVarName(int vlistId, int varId);
 
 /*      vlistDefVarStdname: Define the standard name of a Variable */
 void    vlistDefVarStdname(int vlistID, int varID, const char *stdname);
@@ -616,7 +644,7 @@ void    vlistDefVarEnsemble(int vlistID, int varID, int ensID, int ensCount, int
 int     vlistInqVarEnsemble(int vlistID, int varID, int *ensID, int *ensCount, int *forecast_type);
 
 /* cdiClearAdditionalKeys: Clear the list of additional GRIB keys. */
-void    cdiClearAdditionalKeys();
+void    cdiClearAdditionalKeys(void);
 /* cdiDefAdditionalKey: Register an additional GRIB key which is read when file is opened. */
 void    cdiDefAdditionalKey(const char *string);
 
@@ -642,16 +670,16 @@ int     vlistInqAtt(int vlistID, int varID, int attrnum, char *name, int *typep,
 int     vlistDelAtt(int vlistID, int varID, const char *name);
 
 /*      vlistDefAttInt: Define an integer attribute */
-int     vlistDefAttInt(int vlistID, int varID, const char *name, int type, int len, const int *ip_vec);
+int     vlistDefAttInt(int vlistID, int varID, const char *name, int type, int len, const int ip[]);
 /*      vlistDefAttFlt: Define a floating point attribute */
-int     vlistDefAttFlt(int vlistID, int varID, const char *name, int type, int len, const double *dp_vec);
+int     vlistDefAttFlt(int vlistID, int varID, const char *name, int type, int len, const double dp[]);
 /*      vlistDefAttTxt: Define a text attribute */
 int     vlistDefAttTxt(int vlistID, int varID, const char *name, int len, const char *tp_cbuf);
 
 /*      vlistInqAttInt: Get the value(s) of an integer attribute */
-int     vlistInqAttInt(int vlistID, int varID, const char *name, int mlen, int *ip_vec);
+int     vlistInqAttInt(int vlistID, int varID, const char *name, int mlen, int ip[]);
 /*      vlistInqAttFlt: Get the value(s) of a floating point attribute */
-int     vlistInqAttFlt(int vlistID, int varID, const char *name, int mlen, double *dp_vec);
+int     vlistInqAttFlt(int vlistID, int varID, const char *name, int mlen, double dp[]);
 /*      vlistInqAttTxt: Get the value(s) of a text attribute */
 int     vlistInqAttTxt(int vlistID, int varID, const char *name, int mlen, char *tp_cbuf);
 
@@ -663,11 +691,11 @@ const char *gridNamePtr(int gridtype);
 
 void    gridCompress(int gridID);
 
-void    gridDefMaskGME(int gridID, const int *mask_vec);
-int     gridInqMaskGME(int gridID, int *mask_vec);
+void    gridDefMaskGME(int gridID, const int mask[]);
+int     gridInqMaskGME(int gridID, int mask[]);
 
-void    gridDefMask(int gridID, const int *mask_vec);
-int     gridInqMask(int gridID, int *mask_vec);
+void    gridDefMask(int gridID, const int mask[]);
+int     gridInqMask(int gridID, int mask[]);
 
 void    gridPrint(int gridID, int index, int opt);
 
@@ -705,16 +733,16 @@ void    gridDefNP(int gridID, int np);
 int     gridInqNP(int gridID);
 
 /*      gridDefXvals: Define the values of a X-axis */
-void    gridDefXvals(int gridID, const double *xvals_vec);
+void    gridDefXvals(int gridID, const double xvals[]);
 
 /*      gridInqXvals: Get all values of a X-axis */
-int     gridInqXvals(int gridID, double *xvals_vec);
+int     gridInqXvals(int gridID, double xvals[]);
 
 /*      gridDefYvals: Define the values of a Y-axis */
-void    gridDefYvals(int gridID, const double *yvals_vec);
+void    gridDefYvals(int gridID, const double yvals[]);
 
 /*      gridInqYvals: Get all values of a Y-axis */
-int     gridInqYvals(int gridID, double *yvals_vec);
+int     gridInqYvals(int gridID, double yvals[]);
 
 /*      gridDefXname: Define the name of a X-axis */
 void    gridDefXname(int gridID, const char *xname);
@@ -814,11 +842,18 @@ void    gridDefReference(int gridID, const char *reference);
 int     gridInqReference(int gridID, char *reference);
 
 /*      gridDefUUID: Define the UUID of an unstructured grid */
+#ifdef __cplusplus
+void    gridDefUUID(int gridID, const unsigned char *uuid);
+#else
 void    gridDefUUID(int gridID, const unsigned char uuid[CDI_UUID_SIZE]);
+#endif
 
 /*      gridInqUUID: Get the UUID of an unstructured grid */
+#ifdef __cplusplus
+void    gridInqUUID(int gridID, unsigned char *uuid);
+#else
 void    gridInqUUID(int gridID, unsigned char uuid[CDI_UUID_SIZE]);
-
+#endif
 
 /* Lambert Conformal Conic grid (GRIB version) */
 void gridDefLCC(int gridID, double originLon, double originLat, double lonParY, double lat1, double lat2, double xinc, double yinc, int projflag, int scanflag);
@@ -833,8 +868,8 @@ void gridDefLaea(int gridID, double earth_radius, double lon_0, double lat_0);
 void gridInqLaea(int gridID, double *earth_radius, double *lon_0, double *lat_0);
 
 
-void    gridDefArea(int gridID, const double *area_vec);
-void    gridInqArea(int gridID, double *area_vec);
+void    gridDefArea(int gridID, const double area[]);
+void    gridInqArea(int gridID, double area[]);
 int     gridHasArea(int gridID);
 
 /*      gridDefNvertex: Define the number of vertex of a Gridbox */
@@ -844,19 +879,19 @@ void    gridDefNvertex(int gridID, int nvertex);
 int     gridInqNvertex(int gridID);
 
 /*      gridDefXbounds: Define the bounds of a X-axis */
-void    gridDefXbounds(int gridID, const double *xbounds_vec);
+void    gridDefXbounds(int gridID, const double xbounds[]);
 
 /*      gridInqXbounds: Get the bounds of a X-axis */
-int     gridInqXbounds(int gridID, double *xbounds_vec);
+int     gridInqXbounds(int gridID, double xbounds[]);
 
 /*      gridDefYbounds: Define the bounds of a Y-axis */
-void    gridDefYbounds(int gridID, const double *ybounds_vec);
+void    gridDefYbounds(int gridID, const double ybounds[]);
 
 /*      gridInqYbounds: Get the bounds of a Y-axis */
-int     gridInqYbounds(int gridID, double *ybounds_vec);
+int     gridInqYbounds(int gridID, double ybounds[]);
 
-void    gridDefRowlon(int gridID, int nrowlon, const int* rowlon_vec);
-void    gridInqRowlon(int gridID, int *rowlon_vec);
+void    gridDefRowlon(int gridID, int nrowlon, const int rowlon[]);
+void    gridInqRowlon(int gridID, int rowlon[]);
 void    gridChangeType(int gridID, int gridtype);
 
 void    gridDefComplexPacking(int gridID, int lpack);
@@ -886,10 +921,10 @@ void    zaxisResize(int zaxisID, int size);
 void    zaxisPrint(int zaxisID, int index);
 
 /*      zaxisDefLevels: Define the levels of a Z-axis */
-void    zaxisDefLevels(int zaxisID, const double *levels_vec);
+void    zaxisDefLevels(int zaxisID, const double levels[]);
 
 /*      zaxisInqLevels: Get all levels of a Z-axis */
-void    zaxisInqLevels(int zaxisID, double *levels_vec);
+void    zaxisInqLevels(int zaxisID, double levels[]);
 
 /*      zaxisDefLevel: Define one level of a Z-axis */
 void    zaxisDefLevel(int zaxisID, int levelID, double levels);
@@ -916,19 +951,19 @@ void    zaxisDefUUID(int zaxisID, const unsigned char uuid[CDI_UUID_SIZE]);
 void    zaxisInqUUID(int zaxisID, unsigned char uuid[CDI_UUID_SIZE]);
 
 /*      zaxisDefName: Define the name of a Z-axis */
-void    zaxisDefName(int zaxisID, const char *name);
+void    zaxisDefName(int zaxisID, const char *name_optional);
 
 /*      zaxisInqName: Get the name of a Z-axis */
 void    zaxisInqName(int zaxisID, char *name);
 
 /*      zaxisDefLongname: Define the longname of a Z-axis */
-void    zaxisDefLongname(int zaxisID, const char *longname);
+void    zaxisDefLongname(int zaxisID, const char *longname_optional);
 
 /*      zaxisInqLongname: Get the longname of a Z-axis */
 void    zaxisInqLongname(int zaxisID, char *longname);
 
 /*      zaxisDefUnits: Define the units of a Z-axis */
-void    zaxisDefUnits(int zaxisID, const char *units);
+void    zaxisDefUnits(int zaxisID, const char *units_optional);
 
 /*      zaxisInqUnits: Get the units of a Z-axis */
 void    zaxisInqUnits(int zaxisID, char *units);
@@ -936,28 +971,37 @@ void    zaxisInqUnits(int zaxisID, char *units);
 /*      zaxisInqStdname: Get the standard name of a Z-axis */
 void    zaxisInqStdname(int zaxisID, char *stdname);
 
+/*      zaxisDefPsName: Define the name of the surface pressure variable of a hybrid sigma pressure Z-axis */
+void    zaxisDefPsName(int zaxisID, const char *psname_optional);
+
+/*      zaxisInqPsName: Get the name of the surface pressure variable of a hybrid sigma pressure Z-axis */
+void    zaxisInqPsName(int zaxisID, char *psname);
+
 void    zaxisDefPrec(int zaxisID, int prec);
 int     zaxisInqPrec(int zaxisID);
 
 void    zaxisDefPositive(int zaxisID, int positive);
 int     zaxisInqPositive(int zaxisID);
 
+void    zaxisDefScalar(int zaxisID);
+int     zaxisInqScalar(int zaxisID);
+
 void    zaxisDefLtype(int zaxisID, int ltype);
 int     zaxisInqLtype(int zaxisID);
 
 const double *zaxisInqLevelsPtr(int zaxisID);
-void    zaxisDefVct(int zaxisID, int size, const double *vct_vec);
-void    zaxisInqVct(int zaxisID, double *vct_vec);
+void    zaxisDefVct(int zaxisID, int size, const double vct[]);
+void    zaxisInqVct(int zaxisID, double vct[]);
 int     zaxisInqVctSize(int zaxisID);
 const double *zaxisInqVctPtr(int zaxisID);
-void    zaxisDefLbounds(int zaxisID, const double *lbounds_vec);
-int     zaxisInqLbounds(int zaxisID, double *lbounds_vec);
+void    zaxisDefLbounds(int zaxisID, const double lbounds[]);
+int     zaxisInqLbounds(int zaxisID, double lbounds_optional[]);
 double  zaxisInqLbound(int zaxisID, int index);
-void    zaxisDefUbounds(int zaxisID, const double *ubounds_vec);
-int     zaxisInqUbounds(int zaxisID, double *ubounds_vec);
+void    zaxisDefUbounds(int zaxisID, const double ubounds[]);
+int     zaxisInqUbounds(int zaxisID, double ubounds_optional[]);
 double  zaxisInqUbound(int zaxisID, int index);
-void    zaxisDefWeights(int zaxisID, const double *weights_vec);
-int     zaxisInqWeights(int zaxisID, double *weights_vec);
+void    zaxisDefWeights(int zaxisID, const double weights[]);
+int     zaxisInqWeights(int zaxisID, double weights_optional[]);
 void    zaxisChangeType(int zaxisID, int zaxistype);
 
 /* TAXIS routines */
@@ -1043,7 +1087,7 @@ int     taxisInqType(int taxisID);
 
 int     taxisInqNumavg(int taxisID);
 
-const char* tunitNamePtr(int tunitID);
+const char *tunitNamePtr(int tunitID);
 
 
 /* Institut routines */
@@ -1054,25 +1098,29 @@ int     institutInqNumber(void);
 int     institutInqCenter(int instID);
 int     institutInqSubcenter(int instID);
 const char *institutInqNamePtr(int instID);
-const char* institutInqLongnamePtr(int instID);
+const char *institutInqLongnamePtr(int instID);
 
 /* Model routines */
 
 int     modelDef(int instID, int modelgribID, const char *name);
-int     modelInq(int instID, int modelgribID, char *name);
-int     modelInqInstitut(int modelID);
+int     modelInq(int instID, int modelgribID, const char *name);
+int     modelInqInstitut(int modelID) ;
 int     modelInqGribID(int modelID);
 const char *modelInqNamePtr(int modelID);
 
 /* Table routines */
 
+/*      tableWriteC: write table of parameters to file in C language format */
 void    tableWriteC(const char *filename, int tableID);
+/*      tableFWriteC: write table of parameters to FILE* in C language format */
 void    tableFWriteC(FILE *ptfp, int tableID);
+/*      tableWrite: write table of parameters to file in tabular format */
 void    tableWrite(const char *filename, int tableID);
+/*      tableRead: read table of parameters from file in tabular format */
 int     tableRead(const char *tablefile);
 int     tableDef(int modelID, int tablenum, const char *tablename);
 
-const char* tableInqNamePtr(int tableID);
+const char *tableInqNamePtr(int tableID);
 void    tableDefEntry(int tableID, int code, const char *name, const char *longname, const char *units);
 
 int     tableInq(int modelID, int tablenum, const char *tablename);
@@ -1098,9 +1146,46 @@ void    streamDefHistory(int streamID, int size, const char *history);
 int     streamInqHistorySize(int streamID);
 void    streamInqHistoryString(int streamID, char *history);
 
+/* Subtype routines */
+
+/*      subtypeCreate: Create a variable subtype */
+int     subtypeCreate(int subtype);
+
+/*      Gives a textual summary of the variable subtype */
+void    subtypePrint(int subtypeID);
+
+/* Compares two subtype data structures. */
+int     subtypeCompare(int subtypeID1, int subtypeID2);
+
+/*      subtypeInqSize: Get the size of a subtype (e.g. no. of tiles). */
+int     subtypeInqSize(int subtypeID);
+
+/*      subtypeInqActiveIndex: Get the currently active index of a subtype (e.g. current tile index). */
+int     subtypeInqActiveIndex(int subtypeID);
+
+/*      subtypeDefActiveIndex: Set the currently active index of a subtype (e.g. current tile index). */
+void    subtypeDefActiveIndex(int subtypeID, int index);
+
+/*      Generate a "query object" out of a key-value pair. */
+subtype_query_t keyValuePair(const char *key, int value);
+
+/*       Generate an AND-combined "query object" out of two previous
+         query objects. */
+subtype_query_t matchAND(subtype_query_t q1, subtype_query_t q2);
+
+/*      subtypeInqSubEntry: Returns subtype entry ID for a given criterion. */
+int     subtypeInqSubEntry(int subtypeID, subtype_query_t criterion);
+
+/*      subtypeInqTile: Specialized version of subtypeInqSubEntry looking for tile/attribute pair. */
+int     subtypeInqTile(int subtypeID, int tileindex, int attribute);
+
+/*      vlistInqVarSubtype: Return subtype ID for a given variable. */
+int     vlistInqVarSubtype(int vlistID, int varID);
+
 
 void gribapiLibraryVersion(int *major_version, int *minor_version, int *revision_version);
 
+
 /*
 #if defined (__cplusplus)
 }
diff --git a/libcdi/src/cdi.inc b/libcdi/src/cdi.inc
index 866891a..057f9f0 100644
--- a/libcdi/src/cdi.inc
+++ b/libcdi/src/cdi.inc
@@ -1,10 +1,10 @@
 ! This file was automatically generated, don't edit!
 !
-! Fortran interface for CDI library version 1.6.9
+! Fortran interface for CDI library version 1.7.0
 !
 ! Author:
 ! -------
-! Uwe Schulzweida, MPI-MET, Hamburg,   April 2015
+! Uwe Schulzweida, MPI-MET, Hamburg,   October 2015
 !
 
       INTEGER    CDI_MAX_NAME          
@@ -20,6 +20,8 @@
       PARAMETER (CDI_BIGENDIAN          =  0)
       INTEGER    CDI_LITTLEENDIAN      
       PARAMETER (CDI_LITTLEENDIAN       =  1)
+      INTEGER    CDI_PDPENDIAN         
+      PARAMETER (CDI_PDPENDIAN          =  2)
       INTEGER    CDI_REAL              
       PARAMETER (CDI_REAL               =  1)
       INTEGER    CDI_COMP              
@@ -287,6 +289,17 @@
       INTEGER    ZAXIS_REFERENCE       
       PARAMETER (ZAXIS_REFERENCE        = 25)
 !
+!  SUBTYPE types
+!
+      INTEGER    MAX_KV_PAIRS_MATCH    
+      PARAMETER (MAX_KV_PAIRS_MATCH     = 10)
+!
+!  Data structure defining a key-value search, possibly with multiple
+!  key-value pairs in combination.
+!  
+!  Currently, only multiple pairs combined by AND are supported.
+!
+!
 !  TIME types
 !
       INTEGER    TIME_CONSTANT         
@@ -427,6 +440,9 @@
 !                                    (INTEGER         namespaceID)
       EXTERNAL        namespaceSetActive
 
+      INTEGER         namespaceGetActive
+      EXTERNAL        namespaceGetActive
+
 !                     namespaceDelete
 !                                    (INTEGER         namespaceID)
       EXTERNAL        namespaceDelete
@@ -526,13 +542,6 @@
 !                                    (INTEGER         streamID)
       EXTERNAL        streamInqVlist
 
-!
-!  PIO:
-!
-      INTEGER         streamInqVlistIDorig
-!                                    (INTEGER         streamID)
-      EXTERNAL        streamInqVlistIDorig
-
       INTEGER         streamInqFiletype
 !                                    (INTEGER         streamID)
       EXTERNAL        streamInqFiletype
@@ -578,6 +587,14 @@
 !                                    (INTEGER         streamID)
       EXTERNAL        streamInqCurTimestepID
 
+      CHARACTER(80)   streamFilename
+!                                    (INTEGER         streamID)
+      EXTERNAL        streamFilename
+
+      CHARACTER(80)   streamFilesuffix
+!                                    (INTEGER         filetype)
+      EXTERNAL        streamFilesuffix
+
       INTEGER         streamInqNvars
 !                                    (INTEGER         streamID)
       EXTERNAL        streamInqNvars
@@ -588,28 +605,28 @@
 !                     streamWriteVar
 !                                    (INTEGER         streamID,
 !                                     INTEGER         varID,
-!                                     DOUBLEPRECISION data_vec,
+!                                     DOUBLEPRECISION data(*),
 !                                     INTEGER         nmiss)
       EXTERNAL        streamWriteVar
 
 !                     streamWriteVarF
 !                                    (INTEGER         streamID,
 !                                     INTEGER         varID,
-!                                     REAL            data_vec,
+!                                     REAL            data(*),
 !                                     INTEGER         nmiss)
       EXTERNAL        streamWriteVarF
 
 !                     streamReadVar
 !                                    (INTEGER         streamID,
 !                                     INTEGER         varID,
-!                                     DOUBLEPRECISION data_vec,
+!                                     DOUBLEPRECISION data(*),
 !                                     INTEGER         nmiss)
       EXTERNAL        streamReadVar
 
 !                     streamReadVarF
 !                                    (INTEGER         streamID,
 !                                     INTEGER         varID,
-!                                     REAL            data_vec,
+!                                     REAL            data(*),
 !                                     INTEGER         nmiss)
       EXTERNAL        streamReadVarF
 
@@ -617,7 +634,7 @@
 !                                    (INTEGER         streamID,
 !                                     INTEGER         varID,
 !                                     INTEGER         levelID,
-!                                     DOUBLEPRECISION data_vec,
+!                                     DOUBLEPRECISION data(*),
 !                                     INTEGER         nmiss)
       EXTERNAL        streamWriteVarSlice
 
@@ -625,7 +642,7 @@
 !                                    (INTEGER         streamID,
 !                                     INTEGER         varID,
 !                                     INTEGER         levelID,
-!                                     REAL            data_vec,
+!                                     REAL            data(*),
 !                                     INTEGER         nmiss)
       EXTERNAL        streamWriteVarSliceF
 
@@ -633,7 +650,7 @@
 !                                    (INTEGER         streamID,
 !                                     INTEGER         varID,
 !                                     INTEGER         levelID,
-!                                     DOUBLEPRECISION data_vec,
+!                                     DOUBLEPRECISION data(*),
 !                                     INTEGER         nmiss)
       EXTERNAL        streamReadVarSlice
 
@@ -641,15 +658,15 @@
 !                                    (INTEGER         streamID,
 !                                     INTEGER         varID,
 !                                     INTEGER         levelID,
-!                                     REAL            data_vec,
+!                                     REAL            data(*),
 !                                     INTEGER         nmiss)
       EXTERNAL        streamReadVarSliceF
 
 !                     streamWriteVarChunk
 !                                    (INTEGER         streamID,
 !                                     INTEGER         varID,
-!                                     INTEGER         rect,
-!                                     DOUBLEPRECISION data_vec,
+!                                     INTEGER         rect(*),
+!                                     DOUBLEPRECISION data(*),
 !                                     INTEGER         nmiss)
       EXTERNAL        streamWriteVarChunk
 
@@ -670,19 +687,19 @@
 
 !                     streamWriteRecord
 !                                    (INTEGER         streamID,
-!                                     DOUBLEPRECISION data_vec,
+!                                     DOUBLEPRECISION data(*),
 !                                     INTEGER         nmiss)
       EXTERNAL        streamWriteRecord
 
 !                     streamWriteRecordF
 !                                    (INTEGER         streamID,
-!                                     REAL            data_vec,
+!                                     REAL            data(*),
 !                                     INTEGER         nmiss)
       EXTERNAL        streamWriteRecordF
 
 !                     streamReadRecord
 !                                    (INTEGER         streamID,
-!                                     DOUBLEPRECISION data_vec,
+!                                     DOUBLEPRECISION data(*),
 !                                     INTEGER         nmiss)
       EXTERNAL        streamReadRecord
 
@@ -752,6 +769,10 @@
 !                                    (INTEGER         vlistID)
       EXTERNAL        vlistNzaxis
 
+      INTEGER         vlistNsubtypes
+!                                    (INTEGER         vlistID)
+      EXTERNAL        vlistNsubtypes
+
 !                     vlistDefNtsteps
 !                                    (INTEGER         vlistID,
 !                                     INTEGER         nts)
@@ -813,6 +834,16 @@
 !                                    (INTEGER         vlistID)
       EXTERNAL        vlistNrecs
 
+      INTEGER         vlistSubtype
+!                                    (INTEGER         vlistID,
+!                                     INTEGER         index)
+      EXTERNAL        vlistSubtype
+
+      INTEGER         vlistSubtypeIndex
+!                                    (INTEGER         vlistID,
+!                                     INTEGER         subtypeID)
+      EXTERNAL        vlistSubtypeIndex
+
 !                     vlistDefTaxis
 !                                    (INTEGER         vlistID,
 !                                     INTEGER         taxisID)
@@ -852,6 +883,14 @@
 !
 !  VLIST VAR routines
 !
+      INTEGER         vlistDefVarTiles
+!                                    (INTEGER         vlistID,
+!                                     INTEGER         gridID,
+!                                     INTEGER         zaxisID,
+!                                     INTEGER         tsteptype,
+!                                     INTEGER         tilesetID)
+      EXTERNAL        vlistDefVarTiles
+
       INTEGER         vlistDefVar
 !                                    (INTEGER         vlistID,
 !                                     INTEGER         gridID,
@@ -1035,6 +1074,11 @@
 !                                     CHARACTER*(*)   name)
       EXTERNAL        vlistInqVarName
 
+      CHARACTER(80)   vlistCopyVarName
+!                                    (INTEGER         vlistId,
+!                                     INTEGER         varId)
+      EXTERNAL        vlistCopyVarName
+
 !                     vlistDefVarStdname
 !                                    (INTEGER         vlistID,
 !                                     INTEGER         varID,
@@ -1301,7 +1345,7 @@
 !                                     CHARACTER*(*)   name,
 !                                     INTEGER         type,
 !                                     INTEGER         len,
-!                                     INTEGER         ip_vec)
+!                                     INTEGER         ip(*))
       EXTERNAL        vlistDefAttInt
 
       INTEGER         vlistDefAttFlt
@@ -1310,7 +1354,7 @@
 !                                     CHARACTER*(*)   name,
 !                                     INTEGER         type,
 !                                     INTEGER         len,
-!                                     DOUBLEPRECISION dp_vec)
+!                                     DOUBLEPRECISION dp(*))
       EXTERNAL        vlistDefAttFlt
 
       INTEGER         vlistDefAttTxt
@@ -1326,7 +1370,7 @@
 !                                     INTEGER         varID,
 !                                     CHARACTER*(*)   name,
 !                                     INTEGER         mlen,
-!                                     INTEGER         ip_vec)
+!                                     INTEGER         ip(*))
       EXTERNAL        vlistInqAttInt
 
       INTEGER         vlistInqAttFlt
@@ -1334,7 +1378,7 @@
 !                                     INTEGER         varID,
 !                                     CHARACTER*(*)   name,
 !                                     INTEGER         mlen,
-!                                     DOUBLEPRECISION dp_vec)
+!                                     DOUBLEPRECISION dp(*))
       EXTERNAL        vlistInqAttFlt
 
       INTEGER         vlistInqAttTxt
@@ -1363,22 +1407,22 @@
 
 !                     gridDefMaskGME
 !                                    (INTEGER         gridID,
-!                                     INTEGER         mask_vec)
+!                                     INTEGER         mask(*))
       EXTERNAL        gridDefMaskGME
 
       INTEGER         gridInqMaskGME
 !                                    (INTEGER         gridID,
-!                                     INTEGER         mask_vec)
+!                                     INTEGER         mask(*))
       EXTERNAL        gridInqMaskGME
 
 !                     gridDefMask
 !                                    (INTEGER         gridID,
-!                                     INTEGER         mask_vec)
+!                                     INTEGER         mask(*))
       EXTERNAL        gridDefMask
 
       INTEGER         gridInqMask
 !                                    (INTEGER         gridID,
-!                                     INTEGER         mask_vec)
+!                                     INTEGER         mask(*))
       EXTERNAL        gridInqMask
 
 !                     gridPrint
@@ -1437,22 +1481,22 @@
 
 !                     gridDefXvals
 !                                    (INTEGER         gridID,
-!                                     DOUBLEPRECISION xvals_vec)
+!                                     DOUBLEPRECISION xvals(*))
       EXTERNAL        gridDefXvals
 
       INTEGER         gridInqXvals
 !                                    (INTEGER         gridID,
-!                                     DOUBLEPRECISION xvals_vec)
+!                                     DOUBLEPRECISION xvals(*))
       EXTERNAL        gridInqXvals
 
 !                     gridDefYvals
 !                                    (INTEGER         gridID,
-!                                     DOUBLEPRECISION yvals_vec)
+!                                     DOUBLEPRECISION yvals(*))
       EXTERNAL        gridDefYvals
 
       INTEGER         gridInqYvals
 !                                    (INTEGER         gridID,
-!                                     DOUBLEPRECISION yvals_vec)
+!                                     DOUBLEPRECISION yvals(*))
       EXTERNAL        gridInqYvals
 
 !                     gridDefXname
@@ -1745,12 +1789,12 @@
 
 !                     gridDefArea
 !                                    (INTEGER         gridID,
-!                                     DOUBLEPRECISION area_vec)
+!                                     DOUBLEPRECISION area(*))
       EXTERNAL        gridDefArea
 
 !                     gridInqArea
 !                                    (INTEGER         gridID,
-!                                     DOUBLEPRECISION area_vec)
+!                                     DOUBLEPRECISION area(*))
       EXTERNAL        gridInqArea
 
       INTEGER         gridHasArea
@@ -1768,27 +1812,33 @@
 
 !                     gridDefXbounds
 !                                    (INTEGER         gridID,
-!                                     DOUBLEPRECISION xbounds_vec)
+!                                     DOUBLEPRECISION xbounds(*))
       EXTERNAL        gridDefXbounds
 
       INTEGER         gridInqXbounds
 !                                    (INTEGER         gridID,
-!                                     DOUBLEPRECISION xbounds_vec)
+!                                     DOUBLEPRECISION xbounds(*))
       EXTERNAL        gridInqXbounds
 
 !                     gridDefYbounds
 !                                    (INTEGER         gridID,
-!                                     DOUBLEPRECISION ybounds_vec)
+!                                     DOUBLEPRECISION ybounds(*))
       EXTERNAL        gridDefYbounds
 
       INTEGER         gridInqYbounds
 !                                    (INTEGER         gridID,
-!                                     DOUBLEPRECISION ybounds_vec)
+!                                     DOUBLEPRECISION ybounds(*))
       EXTERNAL        gridInqYbounds
 
+!                     gridDefRowlon
+!                                    (INTEGER         gridID,
+!                                     INTEGER         nrowlon,
+!                                     INTEGER         rowlon(*))
+      EXTERNAL        gridDefRowlon
+
 !                     gridInqRowlon
 !                                    (INTEGER         gridID,
-!                                     INTEGER         rowlon_vec)
+!                                     INTEGER         rowlon(*))
       EXTERNAL        gridInqRowlon
 
 !                     gridChangeType
@@ -1846,12 +1896,12 @@
 
 !                     zaxisDefLevels
 !                                    (INTEGER         zaxisID,
-!                                     DOUBLEPRECISION levels_vec)
+!                                     DOUBLEPRECISION levels(*))
       EXTERNAL        zaxisDefLevels
 
 !                     zaxisInqLevels
 !                                    (INTEGER         zaxisID,
-!                                     DOUBLEPRECISION levels_vec)
+!                                     DOUBLEPRECISION levels(*))
       EXTERNAL        zaxisInqLevels
 
 !                     zaxisDefLevel
@@ -1895,7 +1945,7 @@
 
 !                     zaxisDefName
 !                                    (INTEGER         zaxisID,
-!                                     CHARACTER*(*)   name)
+!                                     CHARACTER*(*)   name_optional)
       EXTERNAL        zaxisDefName
 
 !                     zaxisInqName
@@ -1905,7 +1955,7 @@
 
 !                     zaxisDefLongname
 !                                    (INTEGER         zaxisID,
-!                                     CHARACTER*(*)   longname)
+!                                     CHARACTER*(*)   longname_optional)
       EXTERNAL        zaxisDefLongname
 
 !                     zaxisInqLongname
@@ -1915,7 +1965,7 @@
 
 !                     zaxisDefUnits
 !                                    (INTEGER         zaxisID,
-!                                     CHARACTER*(*)   units)
+!                                     CHARACTER*(*)   units_optional)
       EXTERNAL        zaxisDefUnits
 
 !                     zaxisInqUnits
@@ -1928,6 +1978,16 @@
 !                                     CHARACTER*(*)   stdname)
       EXTERNAL        zaxisInqStdname
 
+!                     zaxisDefPsName
+!                                    (INTEGER         zaxisID,
+!                                     CHARACTER*(*)   psname_optional)
+      EXTERNAL        zaxisDefPsName
+
+!                     zaxisInqPsName
+!                                    (INTEGER         zaxisID,
+!                                     CHARACTER*(*)   psname)
+      EXTERNAL        zaxisInqPsName
+
 !                     zaxisDefPrec
 !                                    (INTEGER         zaxisID,
 !                                     INTEGER         prec)
@@ -1946,6 +2006,14 @@
 !                                    (INTEGER         zaxisID)
       EXTERNAL        zaxisInqPositive
 
+!                     zaxisDefScalar
+!                                    (INTEGER         zaxisID)
+      EXTERNAL        zaxisDefScalar
+
+      INTEGER         zaxisInqScalar
+!                                    (INTEGER         zaxisID)
+      EXTERNAL        zaxisInqScalar
+
 !                     zaxisDefLtype
 !                                    (INTEGER         zaxisID,
 !                                     INTEGER         ltype)
@@ -1958,12 +2026,12 @@
 !                     zaxisDefVct
 !                                    (INTEGER         zaxisID,
 !                                     INTEGER         size,
-!                                     DOUBLEPRECISION vct_vec)
+!                                     DOUBLEPRECISION vct(*))
       EXTERNAL        zaxisDefVct
 
 !                     zaxisInqVct
 !                                    (INTEGER         zaxisID,
-!                                     DOUBLEPRECISION vct_vec)
+!                                     DOUBLEPRECISION vct(*))
       EXTERNAL        zaxisInqVct
 
       INTEGER         zaxisInqVctSize
@@ -1972,12 +2040,12 @@
 
 !                     zaxisDefLbounds
 !                                    (INTEGER         zaxisID,
-!                                     DOUBLEPRECISION lbounds_vec)
+!                                     DOUBLEPRECISION lbounds(*))
       EXTERNAL        zaxisDefLbounds
 
       INTEGER         zaxisInqLbounds
 !                                    (INTEGER         zaxisID,
-!                                     DOUBLEPRECISION lbounds_vec)
+!                                     DOUBLEPRECISION lbounds_optional(*))
       EXTERNAL        zaxisInqLbounds
 
       DOUBLEPRECISION zaxisInqLbound
@@ -1987,12 +2055,12 @@
 
 !                     zaxisDefUbounds
 !                                    (INTEGER         zaxisID,
-!                                     DOUBLEPRECISION ubounds_vec)
+!                                     DOUBLEPRECISION ubounds(*))
       EXTERNAL        zaxisDefUbounds
 
       INTEGER         zaxisInqUbounds
 !                                    (INTEGER         zaxisID,
-!                                     DOUBLEPRECISION ubounds_vec)
+!                                     DOUBLEPRECISION ubounds_optional(*))
       EXTERNAL        zaxisInqUbounds
 
       DOUBLEPRECISION zaxisInqUbound
@@ -2002,12 +2070,12 @@
 
 !                     zaxisDefWeights
 !                                    (INTEGER         zaxisID,
-!                                     DOUBLEPRECISION weights_vec)
+!                                     DOUBLEPRECISION weights(*))
       EXTERNAL        zaxisDefWeights
 
       INTEGER         zaxisInqWeights
 !                                    (INTEGER         zaxisID,
-!                                     DOUBLEPRECISION weights_vec)
+!                                     DOUBLEPRECISION weights_optional(*))
       EXTERNAL        zaxisInqWeights
 
 !                     zaxisChangeType
@@ -2175,6 +2243,10 @@
 !                                    (INTEGER         taxisID)
       EXTERNAL        taxisInqNumavg
 
+      CHARACTER(80)   tunitNamePtr
+!                                    (INTEGER         tunitID)
+      EXTERNAL        tunitNamePtr
+
 !
 !  Institut routines
 !
@@ -2207,6 +2279,10 @@
 !                                    (INTEGER         instID)
       EXTERNAL        institutInqNamePtr
 
+      CHARACTER(80)   institutInqLongnamePtr
+!                                    (INTEGER         instID)
+      EXTERNAL        institutInqLongnamePtr
+
 !
 !  Model routines
 !
@@ -2257,6 +2333,10 @@
 !                                     CHARACTER*(*)   tablename)
       EXTERNAL        tableDef
 
+      CHARACTER(80)   tableInqNamePtr
+!                                    (INTEGER         tableID)
+      EXTERNAL        tableInqNamePtr
+
 !                     tableDefEntry
 !                                    (INTEGER         tableID,
 !                                     INTEGER         code,
@@ -2347,6 +2427,59 @@
 !                                     CHARACTER*(*)   history)
       EXTERNAL        streamInqHistoryString
 
+!
+!  Subtype routines
+!
+      INTEGER         subtypeCreate
+!                                    (INTEGER         subtype)
+      EXTERNAL        subtypeCreate
+
+!
+!  Gives a textual summary of the variable subtype
+!
+!                     subtypePrint
+!                                    (INTEGER         subtypeID)
+      EXTERNAL        subtypePrint
+
+!
+!  Compares two subtype data structures.
+!
+      INTEGER         subtypeCompare
+!                                    (INTEGER         subtypeID1,
+!                                     INTEGER         subtypeID2)
+      EXTERNAL        subtypeCompare
+
+      INTEGER         subtypeInqSize
+!                                    (INTEGER         subtypeID)
+      EXTERNAL        subtypeInqSize
+
+      INTEGER         subtypeInqActiveIndex
+!                                    (INTEGER         subtypeID)
+      EXTERNAL        subtypeInqActiveIndex
+
+!                     subtypeDefActiveIndex
+!                                    (INTEGER         subtypeID,
+!                                     INTEGER         index)
+      EXTERNAL        subtypeDefActiveIndex
+
+!
+!  Generate a "query object" out of a key-value pair.
+!
+!
+!  Generate an AND-combined "query object" out of two previous
+!  query objects.
+!
+      INTEGER         subtypeInqTile
+!                                    (INTEGER         subtypeID,
+!                                     INTEGER         tileindex,
+!                                     INTEGER         attribute)
+      EXTERNAL        subtypeInqTile
+
+      INTEGER         vlistInqVarSubtype
+!                                    (INTEGER         vlistID,
+!                                     INTEGER         varID)
+      EXTERNAL        vlistInqVarSubtype
+
 !                     gribapiLibraryVersion
 !                                    (INTEGER         major_version,
 !                                     INTEGER         minor_version,
diff --git a/libcdi/src/cdiFortran.c b/libcdi/src/cdiFortran.c
index baec75b..dd53644 100644
--- a/libcdi/src/cdiFortran.c
+++ b/libcdi/src/cdiFortran.c
@@ -42,6 +42,15 @@
 /*  ZAXIS types  */
 
 
+/*  SUBTYPE types  */
+
+
+/*  Data structure defining a key-value search, possibly with multiple
+   key-value pairs in combination.
+
+   Currently, only multiple pairs combined by AND are supported.  */
+
+
 /*  TIME types  */
 
 
@@ -79,6 +88,7 @@ FCALLSCFUN0 (DOUBLE, cdiInqMissval, CDIINQMISSVAL, cdiinqmissval)
 FCALLSCSUB2 (cdiDefGlobal, CDIDEFGLOBAL, cdidefglobal, STRING, INT)
 FCALLSCFUN0 (INT, namespaceNew, NAMESPACENEW, namespacenew)
 FCALLSCSUB1 (namespaceSetActive, NAMESPACESETACTIVE, namespacesetactive, INT)
+FCALLSCFUN0 (INT, namespaceGetActive, NAMESPACEGETACTIVE, namespacegetactive)
 FCALLSCSUB1 (namespaceDelete, NAMESPACEDELETE, namespacedelete, INT)
 
 /*  CDI converter routines  */
@@ -110,10 +120,6 @@ FCALLSCSUB1 (streamClose, STREAMCLOSE, streamclose, INT)
 FCALLSCSUB1 (streamSync, STREAMSYNC, streamsync, INT)
 FCALLSCSUB2 (streamDefVlist, STREAMDEFVLIST, streamdefvlist, INT, INT)
 FCALLSCFUN1 (INT, streamInqVlist, STREAMINQVLIST, streaminqvlist, INT)
-
-/*  PIO:  */
-
-FCALLSCFUN1 (INT, streamInqVlistIDorig, STREAMINQVLISTIDORIG, streaminqvlistidorig, INT)
 FCALLSCFUN1 (INT, streamInqFiletype, STREAMINQFILETYPE, streaminqfiletype, INT)
 FCALLSCSUB2 (streamDefByteorder, STREAMDEFBYTEORDER, streamdefbyteorder, INT, INT)
 FCALLSCFUN1 (INT, streamInqByteorder, STREAMINQBYTEORDER, streaminqbyteorder, INT)
@@ -124,27 +130,29 @@ FCALLSCFUN1 (INT, streamInqCompLevel, STREAMINQCOMPLEVEL, streaminqcomplevel, IN
 FCALLSCFUN2 (INT, streamDefTimestep, STREAMDEFTIMESTEP, streamdeftimestep, INT, INT)
 FCALLSCFUN2 (INT, streamInqTimestep, STREAMINQTIMESTEP, streaminqtimestep, INT, INT)
 FCALLSCFUN1 (INT, streamInqCurTimestepID, STREAMINQCURTIMESTEPID, streaminqcurtimestepid, INT)
+FCALLSCFUN1 (STRING, streamFilename, STREAMFILENAME, streamfilename, INT)
+FCALLSCFUN1 (STRING, streamFilesuffix, STREAMFILESUFFIX, streamfilesuffix, INT)
 FCALLSCFUN1 (INT, streamInqNvars, STREAMINQNVARS, streaminqnvars, INT)
 
 /*  STREAM var I/O routines  */
 
-FCALLSCSUB4 (streamWriteVar, STREAMWRITEVAR, streamwritevar, INT, INT, PDOUBLE, INT)
-FCALLSCSUB4 (streamWriteVarF, STREAMWRITEVARF, streamwritevarf, INT, INT, PFLOAT, INT)
-FCALLSCSUB4 (streamReadVar, STREAMREADVAR, streamreadvar, INT, INT, PDOUBLE, PINT)
-FCALLSCSUB4 (streamReadVarF, STREAMREADVARF, streamreadvarf, INT, INT, PFLOAT, PINT)
-FCALLSCSUB5 (streamWriteVarSlice, STREAMWRITEVARSLICE, streamwritevarslice, INT, INT, INT, PDOUBLE, INT)
-FCALLSCSUB5 (streamWriteVarSliceF, STREAMWRITEVARSLICEF, streamwritevarslicef, INT, INT, INT, PFLOAT, INT)
-FCALLSCSUB5 (streamReadVarSlice, STREAMREADVARSLICE, streamreadvarslice, INT, INT, INT, PDOUBLE, PINT)
-FCALLSCSUB5 (streamReadVarSliceF, STREAMREADVARSLICEF, streamreadvarslicef, INT, INT, INT, PFLOAT, PINT)
-FCALLSCSUB5 (streamWriteVarChunk, STREAMWRITEVARCHUNK, streamwritevarchunk, INT, INT, INTVV, PDOUBLE, INT)
+FCALLSCSUB4 (streamWriteVar, STREAMWRITEVAR, streamwritevar, INT, INT, DOUBLEV, INT)
+FCALLSCSUB4 (streamWriteVarF, STREAMWRITEVARF, streamwritevarf, INT, INT, FLOATV, INT)
+FCALLSCSUB4 (streamReadVar, STREAMREADVAR, streamreadvar, INT, INT, DOUBLEV, PINT)
+FCALLSCSUB4 (streamReadVarF, STREAMREADVARF, streamreadvarf, INT, INT, FLOATV, PINT)
+FCALLSCSUB5 (streamWriteVarSlice, STREAMWRITEVARSLICE, streamwritevarslice, INT, INT, INT, DOUBLEV, INT)
+FCALLSCSUB5 (streamWriteVarSliceF, STREAMWRITEVARSLICEF, streamwritevarslicef, INT, INT, INT, FLOATV, INT)
+FCALLSCSUB5 (streamReadVarSlice, STREAMREADVARSLICE, streamreadvarslice, INT, INT, INT, DOUBLEV, PINT)
+FCALLSCSUB5 (streamReadVarSliceF, STREAMREADVARSLICEF, streamreadvarslicef, INT, INT, INT, FLOATV, PINT)
+FCALLSCSUB5 (streamWriteVarChunk, STREAMWRITEVARCHUNK, streamwritevarchunk, INT, INT, INTVV, DOUBLEV, INT)
 
 /*  STREAM record I/O routines  */
 
 FCALLSCSUB3 (streamDefRecord, STREAMDEFRECORD, streamdefrecord, INT, INT, INT)
 FCALLSCSUB3 (streamInqRecord, STREAMINQRECORD, streaminqrecord, INT, PINT, PINT)
-FCALLSCSUB3 (streamWriteRecord, STREAMWRITERECORD, streamwriterecord, INT, PDOUBLE, INT)
-FCALLSCSUB3 (streamWriteRecordF, STREAMWRITERECORDF, streamwriterecordf, INT, PFLOAT, INT)
-FCALLSCSUB3 (streamReadRecord, STREAMREADRECORD, streamreadrecord, INT, PDOUBLE, PINT)
+FCALLSCSUB3 (streamWriteRecord, STREAMWRITERECORD, streamwriterecord, INT, DOUBLEV, INT)
+FCALLSCSUB3 (streamWriteRecordF, STREAMWRITERECORDF, streamwriterecordf, INT, FLOATV, INT)
+FCALLSCSUB3 (streamReadRecord, STREAMREADRECORD, streamreadrecord, INT, DOUBLEV, PINT)
 FCALLSCSUB2 (streamCopyRecord, STREAMCOPYRECORD, streamcopyrecord, INT, INT)
 
 /*  File driven I/O (may yield better performance than using the streamXXX functions)  */
@@ -165,6 +173,7 @@ FCALLSCFUN1 (INT, vlistNumber, VLISTNUMBER, vlistnumber, INT)
 FCALLSCFUN1 (INT, vlistNvars, VLISTNVARS, vlistnvars, INT)
 FCALLSCFUN1 (INT, vlistNgrids, VLISTNGRIDS, vlistngrids, INT)
 FCALLSCFUN1 (INT, vlistNzaxis, VLISTNZAXIS, vlistnzaxis, INT)
+FCALLSCFUN1 (INT, vlistNsubtypes, VLISTNSUBTYPES, vlistnsubtypes, INT)
 FCALLSCSUB2 (vlistDefNtsteps, VLISTDEFNTSTEPS, vlistdefntsteps, INT, INT)
 FCALLSCFUN1 (INT, vlistNtsteps, VLISTNTSTEPS, vlistntsteps, INT)
 FCALLSCFUN1 (INT, vlistGridsizeMax, VLISTGRIDSIZEMAX, vlistgridsizemax, INT)
@@ -177,6 +186,8 @@ FCALLSCFUN2 (INT, vlistZaxisIndex, VLISTZAXISINDEX, vlistzaxisindex, INT, INT)
 FCALLSCSUB3 (vlistChangeZaxisIndex, VLISTCHANGEZAXISINDEX, vlistchangezaxisindex, INT, INT, INT)
 FCALLSCSUB3 (vlistChangeZaxis, VLISTCHANGEZAXIS, vlistchangezaxis, INT, INT, INT)
 FCALLSCFUN1 (INT, vlistNrecs, VLISTNRECS, vlistnrecs, INT)
+FCALLSCFUN2 (INT, vlistSubtype, VLISTSUBTYPE, vlistsubtype, INT, INT)
+FCALLSCFUN2 (INT, vlistSubtypeIndex, VLISTSUBTYPEINDEX, vlistsubtypeindex, INT, INT)
 FCALLSCSUB2 (vlistDefTaxis, VLISTDEFTAXIS, vlistdeftaxis, INT, INT)
 FCALLSCFUN1 (INT, vlistInqTaxis, VLISTINQTAXIS, vlistinqtaxis, INT)
 FCALLSCSUB2 (vlistDefTable, VLISTDEFTABLE, vlistdeftable, INT, INT)
@@ -188,6 +199,7 @@ FCALLSCFUN1 (INT, vlistInqModel, VLISTINQMODEL, vlistinqmodel, INT)
 
 /*  VLIST VAR routines  */
 
+FCALLSCFUN5 (INT, vlistDefVarTiles, VLISTDEFVARTILES, vlistdefvartiles, INT, INT, INT, INT, INT)
 FCALLSCFUN4 (INT, vlistDefVar, VLISTDEFVAR, vlistdefvar, INT, INT, INT, INT)
 FCALLSCSUB3 (vlistChangeVarGrid, VLISTCHANGEVARGRID, vlistchangevargrid, INT, INT, INT)
 FCALLSCSUB3 (vlistChangeVarZaxis, VLISTCHANGEVARZAXIS, vlistchangevarzaxis, INT, INT, INT)
@@ -223,6 +235,7 @@ FCALLSCSUB3 (vlistDefVarTable, VLISTDEFVARTABLE, vlistdefvartable, INT, INT, INT
 FCALLSCFUN2 (INT, vlistInqVarTable, VLISTINQVARTABLE, vlistinqvartable, INT, INT)
 FCALLSCSUB3 (vlistDefVarName, VLISTDEFVARNAME, vlistdefvarname, INT, INT, STRING)
 FCALLSCSUB3 (vlistInqVarName, VLISTINQVARNAME, vlistinqvarname, INT, INT, PSTRING)
+FCALLSCFUN2 (STRING, vlistCopyVarName, VLISTCOPYVARNAME, vlistcopyvarname, INT, INT)
 FCALLSCSUB3 (vlistDefVarStdname, VLISTDEFVARSTDNAME, vlistdefvarstdname, INT, INT, STRING)
 FCALLSCSUB3 (vlistInqVarStdname, VLISTINQVARSTDNAME, vlistinqvarstdname, INT, INT, PSTRING)
 FCALLSCSUB3 (vlistDefVarLongname, VLISTDEFVARLONGNAME, vlistdefvarlongname, INT, INT, STRING)
@@ -272,11 +285,11 @@ FCALLSCFUN3 (INT, vlistInqVarIntKey, VLISTINQVARINTKEY, vlistinqvarintkey, INT,
 FCALLSCFUN3 (INT, vlistInqNatts, VLISTINQNATTS, vlistinqnatts, INT, INT, PINT)
 FCALLSCFUN6 (INT, vlistInqAtt, VLISTINQATT, vlistinqatt, INT, INT, INT, PSTRING, PINT, PINT)
 FCALLSCFUN3 (INT, vlistDelAtt, VLISTDELATT, vlistdelatt, INT, INT, STRING)
-FCALLSCFUN6 (INT, vlistDefAttInt, VLISTDEFATTINT, vlistdefattint, INT, INT, STRING, INT, INT, PINT)
-FCALLSCFUN6 (INT, vlistDefAttFlt, VLISTDEFATTFLT, vlistdefattflt, INT, INT, STRING, INT, INT, PDOUBLE)
+FCALLSCFUN6 (INT, vlistDefAttInt, VLISTDEFATTINT, vlistdefattint, INT, INT, STRING, INT, INT, INTV)
+FCALLSCFUN6 (INT, vlistDefAttFlt, VLISTDEFATTFLT, vlistdefattflt, INT, INT, STRING, INT, INT, DOUBLEV)
 FCALLSCFUN5 (INT, vlistDefAttTxt, VLISTDEFATTTXT, vlistdefatttxt, INT, INT, STRING, INT, PPSTRING)
-FCALLSCFUN5 (INT, vlistInqAttInt, VLISTINQATTINT, vlistinqattint, INT, INT, STRING, INT, PINT)
-FCALLSCFUN5 (INT, vlistInqAttFlt, VLISTINQATTFLT, vlistinqattflt, INT, INT, STRING, INT, PDOUBLE)
+FCALLSCFUN5 (INT, vlistInqAttInt, VLISTINQATTINT, vlistinqattint, INT, INT, STRING, INT, INTV)
+FCALLSCFUN5 (INT, vlistInqAttFlt, VLISTINQATTFLT, vlistinqattflt, INT, INT, STRING, INT, DOUBLEV)
 FCALLSCFUN5 (INT, vlistInqAttTxt, VLISTINQATTTXT, vlistinqatttxt, INT, INT, STRING, INT, PPSTRING)
 
 /*  GRID routines  */
@@ -284,10 +297,10 @@ FCALLSCFUN5 (INT, vlistInqAttTxt, VLISTINQATTTXT, vlistinqatttxt, INT, INT, STRI
 FCALLSCSUB2 (gridName, GRIDNAME, gridname, INT, PSTRING)
 FCALLSCFUN1 (STRING, gridNamePtr, GRIDNAMEPTR, gridnameptr, INT)
 FCALLSCSUB1 (gridCompress, GRIDCOMPRESS, gridcompress, INT)
-FCALLSCSUB2 (gridDefMaskGME, GRIDDEFMASKGME, griddefmaskgme, INT, PINT)
-FCALLSCFUN2 (INT, gridInqMaskGME, GRIDINQMASKGME, gridinqmaskgme, INT, PINT)
-FCALLSCSUB2 (gridDefMask, GRIDDEFMASK, griddefmask, INT, PINT)
-FCALLSCFUN2 (INT, gridInqMask, GRIDINQMASK, gridinqmask, INT, PINT)
+FCALLSCSUB2 (gridDefMaskGME, GRIDDEFMASKGME, griddefmaskgme, INT, INTV)
+FCALLSCFUN2 (INT, gridInqMaskGME, GRIDINQMASKGME, gridinqmaskgme, INT, INTV)
+FCALLSCSUB2 (gridDefMask, GRIDDEFMASK, griddefmask, INT, INTV)
+FCALLSCFUN2 (INT, gridInqMask, GRIDINQMASK, gridinqmask, INT, INTV)
 FCALLSCSUB3 (gridPrint, GRIDPRINT, gridprint, INT, INT, INT)
 FCALLSCFUN2 (INT, gridCreate, GRIDCREATE, gridcreate, INT, INT)
 FCALLSCSUB1 (gridDestroy, GRIDDESTROY, griddestroy, INT)
@@ -300,10 +313,10 @@ FCALLSCSUB2 (gridDefYsize, GRIDDEFYSIZE, griddefysize, INT, INT)
 FCALLSCFUN1 (INT, gridInqYsize, GRIDINQYSIZE, gridinqysize, INT)
 FCALLSCSUB2 (gridDefNP, GRIDDEFNP, griddefnp, INT, INT)
 FCALLSCFUN1 (INT, gridInqNP, GRIDINQNP, gridinqnp, INT)
-FCALLSCSUB2 (gridDefXvals, GRIDDEFXVALS, griddefxvals, INT, PDOUBLE)
-FCALLSCFUN2 (INT, gridInqXvals, GRIDINQXVALS, gridinqxvals, INT, PDOUBLE)
-FCALLSCSUB2 (gridDefYvals, GRIDDEFYVALS, griddefyvals, INT, PDOUBLE)
-FCALLSCFUN2 (INT, gridInqYvals, GRIDINQYVALS, gridinqyvals, INT, PDOUBLE)
+FCALLSCSUB2 (gridDefXvals, GRIDDEFXVALS, griddefxvals, INT, DOUBLEV)
+FCALLSCFUN2 (INT, gridInqXvals, GRIDINQXVALS, gridinqxvals, INT, DOUBLEV)
+FCALLSCSUB2 (gridDefYvals, GRIDDEFYVALS, griddefyvals, INT, DOUBLEV)
+FCALLSCFUN2 (INT, gridInqYvals, GRIDINQYVALS, gridinqyvals, INT, DOUBLEV)
 FCALLSCSUB2 (gridDefXname, GRIDDEFXNAME, griddefxname, INT, STRING)
 FCALLSCSUB2 (gridInqXname, GRIDINQXNAME, gridinqxname, INT, PSTRING)
 FCALLSCSUB2 (gridDefXlongname, GRIDDEFXLONGNAME, griddefxlongname, INT, STRING)
@@ -371,16 +384,17 @@ FCALLSCSUB6 (gridInqLcc2, GRIDINQLCC2, gridinqlcc2, INT, PDOUBLE, PDOUBLE, PDOUB
 
 FCALLSCSUB4 (gridDefLaea, GRIDDEFLAEA, griddeflaea, INT, DOUBLE, DOUBLE, DOUBLE)
 FCALLSCSUB4 (gridInqLaea, GRIDINQLAEA, gridinqlaea, INT, PDOUBLE, PDOUBLE, PDOUBLE)
-FCALLSCSUB2 (gridDefArea, GRIDDEFAREA, griddefarea, INT, PDOUBLE)
-FCALLSCSUB2 (gridInqArea, GRIDINQAREA, gridinqarea, INT, PDOUBLE)
+FCALLSCSUB2 (gridDefArea, GRIDDEFAREA, griddefarea, INT, DOUBLEV)
+FCALLSCSUB2 (gridInqArea, GRIDINQAREA, gridinqarea, INT, DOUBLEV)
 FCALLSCFUN1 (INT, gridHasArea, GRIDHASAREA, gridhasarea, INT)
 FCALLSCSUB2 (gridDefNvertex, GRIDDEFNVERTEX, griddefnvertex, INT, INT)
 FCALLSCFUN1 (INT, gridInqNvertex, GRIDINQNVERTEX, gridinqnvertex, INT)
-FCALLSCSUB2 (gridDefXbounds, GRIDDEFXBOUNDS, griddefxbounds, INT, PDOUBLE)
-FCALLSCFUN2 (INT, gridInqXbounds, GRIDINQXBOUNDS, gridinqxbounds, INT, PDOUBLE)
-FCALLSCSUB2 (gridDefYbounds, GRIDDEFYBOUNDS, griddefybounds, INT, PDOUBLE)
-FCALLSCFUN2 (INT, gridInqYbounds, GRIDINQYBOUNDS, gridinqybounds, INT, PDOUBLE)
-FCALLSCSUB2 (gridInqRowlon, GRIDINQROWLON, gridinqrowlon, INT, PINT)
+FCALLSCSUB2 (gridDefXbounds, GRIDDEFXBOUNDS, griddefxbounds, INT, DOUBLEV)
+FCALLSCFUN2 (INT, gridInqXbounds, GRIDINQXBOUNDS, gridinqxbounds, INT, DOUBLEV)
+FCALLSCSUB2 (gridDefYbounds, GRIDDEFYBOUNDS, griddefybounds, INT, DOUBLEV)
+FCALLSCFUN2 (INT, gridInqYbounds, GRIDINQYBOUNDS, gridinqybounds, INT, DOUBLEV)
+FCALLSCSUB3 (gridDefRowlon, GRIDDEFROWLON, griddefrowlon, INT, INT, INTV)
+FCALLSCSUB2 (gridInqRowlon, GRIDINQROWLON, gridinqrowlon, INT, INTV)
 FCALLSCSUB2 (gridChangeType, GRIDCHANGETYPE, gridchangetype, INT, INT)
 FCALLSCSUB2 (gridDefComplexPacking, GRIDDEFCOMPLEXPACKING, griddefcomplexpacking, INT, INT)
 FCALLSCFUN1 (INT, gridInqComplexPacking, GRIDINQCOMPLEXPACKING, gridinqcomplexpacking, INT)
@@ -395,8 +409,8 @@ FCALLSCFUN1 (INT, zaxisInqSize, ZAXISINQSIZE, zaxisinqsize, INT)
 FCALLSCFUN1 (INT, zaxisDuplicate, ZAXISDUPLICATE, zaxisduplicate, INT)
 FCALLSCSUB2 (zaxisResize, ZAXISRESIZE, zaxisresize, INT, INT)
 FCALLSCSUB2 (zaxisPrint, ZAXISPRINT, zaxisprint, INT, INT)
-FCALLSCSUB2 (zaxisDefLevels, ZAXISDEFLEVELS, zaxisdeflevels, INT, PDOUBLE)
-FCALLSCSUB2 (zaxisInqLevels, ZAXISINQLEVELS, zaxisinqlevels, INT, PDOUBLE)
+FCALLSCSUB2 (zaxisDefLevels, ZAXISDEFLEVELS, zaxisdeflevels, INT, DOUBLEV)
+FCALLSCSUB2 (zaxisInqLevels, ZAXISINQLEVELS, zaxisinqlevels, INT, DOUBLEV)
 FCALLSCSUB3 (zaxisDefLevel, ZAXISDEFLEVEL, zaxisdeflevel, INT, INT, DOUBLE)
 FCALLSCFUN2 (DOUBLE, zaxisInqLevel, ZAXISINQLEVEL, zaxisinqlevel, INT, INT)
 FCALLSCSUB2 (zaxisDefNlevRef, ZAXISDEFNLEVREF, zaxisdefnlevref, INT, INT)
@@ -412,23 +426,27 @@ FCALLSCSUB2 (zaxisInqLongname, ZAXISINQLONGNAME, zaxisinqlongname, INT, PSTRING)
 FCALLSCSUB2 (zaxisDefUnits, ZAXISDEFUNITS, zaxisdefunits, INT, STRING)
 FCALLSCSUB2 (zaxisInqUnits, ZAXISINQUNITS, zaxisinqunits, INT, PSTRING)
 FCALLSCSUB2 (zaxisInqStdname, ZAXISINQSTDNAME, zaxisinqstdname, INT, PSTRING)
+FCALLSCSUB2 (zaxisDefPsName, ZAXISDEFPSNAME, zaxisdefpsname, INT, STRING)
+FCALLSCSUB2 (zaxisInqPsName, ZAXISINQPSNAME, zaxisinqpsname, INT, PSTRING)
 FCALLSCSUB2 (zaxisDefPrec, ZAXISDEFPREC, zaxisdefprec, INT, INT)
 FCALLSCFUN1 (INT, zaxisInqPrec, ZAXISINQPREC, zaxisinqprec, INT)
 FCALLSCSUB2 (zaxisDefPositive, ZAXISDEFPOSITIVE, zaxisdefpositive, INT, INT)
 FCALLSCFUN1 (INT, zaxisInqPositive, ZAXISINQPOSITIVE, zaxisinqpositive, INT)
+FCALLSCSUB1 (zaxisDefScalar, ZAXISDEFSCALAR, zaxisdefscalar, INT)
+FCALLSCFUN1 (INT, zaxisInqScalar, ZAXISINQSCALAR, zaxisinqscalar, INT)
 FCALLSCSUB2 (zaxisDefLtype, ZAXISDEFLTYPE, zaxisdefltype, INT, INT)
 FCALLSCFUN1 (INT, zaxisInqLtype, ZAXISINQLTYPE, zaxisinqltype, INT)
-FCALLSCSUB3 (zaxisDefVct, ZAXISDEFVCT, zaxisdefvct, INT, INT, PDOUBLE)
-FCALLSCSUB2 (zaxisInqVct, ZAXISINQVCT, zaxisinqvct, INT, PDOUBLE)
+FCALLSCSUB3 (zaxisDefVct, ZAXISDEFVCT, zaxisdefvct, INT, INT, DOUBLEV)
+FCALLSCSUB2 (zaxisInqVct, ZAXISINQVCT, zaxisinqvct, INT, DOUBLEV)
 FCALLSCFUN1 (INT, zaxisInqVctSize, ZAXISINQVCTSIZE, zaxisinqvctsize, INT)
-FCALLSCSUB2 (zaxisDefLbounds, ZAXISDEFLBOUNDS, zaxisdeflbounds, INT, PDOUBLE)
-FCALLSCFUN2 (INT, zaxisInqLbounds, ZAXISINQLBOUNDS, zaxisinqlbounds, INT, PDOUBLE)
+FCALLSCSUB2 (zaxisDefLbounds, ZAXISDEFLBOUNDS, zaxisdeflbounds, INT, DOUBLEV)
+FCALLSCFUN2 (INT, zaxisInqLbounds, ZAXISINQLBOUNDS, zaxisinqlbounds, INT, DOUBLEV)
 FCALLSCFUN2 (DOUBLE, zaxisInqLbound, ZAXISINQLBOUND, zaxisinqlbound, INT, INT)
-FCALLSCSUB2 (zaxisDefUbounds, ZAXISDEFUBOUNDS, zaxisdefubounds, INT, PDOUBLE)
-FCALLSCFUN2 (INT, zaxisInqUbounds, ZAXISINQUBOUNDS, zaxisinqubounds, INT, PDOUBLE)
+FCALLSCSUB2 (zaxisDefUbounds, ZAXISDEFUBOUNDS, zaxisdefubounds, INT, DOUBLEV)
+FCALLSCFUN2 (INT, zaxisInqUbounds, ZAXISINQUBOUNDS, zaxisinqubounds, INT, DOUBLEV)
 FCALLSCFUN2 (DOUBLE, zaxisInqUbound, ZAXISINQUBOUND, zaxisinqubound, INT, INT)
-FCALLSCSUB2 (zaxisDefWeights, ZAXISDEFWEIGHTS, zaxisdefweights, INT, PDOUBLE)
-FCALLSCFUN2 (INT, zaxisInqWeights, ZAXISINQWEIGHTS, zaxisinqweights, INT, PDOUBLE)
+FCALLSCSUB2 (zaxisDefWeights, ZAXISDEFWEIGHTS, zaxisdefweights, INT, DOUBLEV)
+FCALLSCFUN2 (INT, zaxisInqWeights, ZAXISINQWEIGHTS, zaxisinqweights, INT, DOUBLEV)
 FCALLSCSUB2 (zaxisChangeType, ZAXISCHANGETYPE, zaxischangetype, INT, INT)
 
 /*  TAXIS routines  */
@@ -467,6 +485,7 @@ FCALLSCFUN1 (DOUBLE, taxisInqForecastPeriod, TAXISINQFORECASTPERIOD, taxisinqfor
 FCALLSCSUB2 (taxisDefNumavg, TAXISDEFNUMAVG, taxisdefnumavg, INT, INT)
 FCALLSCFUN1 (INT, taxisInqType, TAXISINQTYPE, taxisinqtype, INT)
 FCALLSCFUN1 (INT, taxisInqNumavg, TAXISINQNUMAVG, taxisinqnumavg, INT)
+FCALLSCFUN1 (STRING, tunitNamePtr, TUNITNAMEPTR, tunitnameptr, INT)
 
 /*  Institut routines  */
 
@@ -476,11 +495,12 @@ FCALLSCFUN0 (INT, institutInqNumber, INSTITUTINQNUMBER, institutinqnumber)
 FCALLSCFUN1 (INT, institutInqCenter, INSTITUTINQCENTER, institutinqcenter, INT)
 FCALLSCFUN1 (INT, institutInqSubcenter, INSTITUTINQSUBCENTER, institutinqsubcenter, INT)
 FCALLSCFUN1 (STRING, institutInqNamePtr, INSTITUTINQNAMEPTR, institutinqnameptr, INT)
+FCALLSCFUN1 (STRING, institutInqLongnamePtr, INSTITUTINQLONGNAMEPTR, institutinqlongnameptr, INT)
 
 /*  Model routines  */
 
 FCALLSCFUN3 (INT, modelDef, MODELDEF, modeldef, INT, INT, STRING)
-FCALLSCFUN3 (INT, modelInq, MODELINQ, modelinq, INT, INT, PSTRING)
+FCALLSCFUN3 (INT, modelInq, MODELINQ, modelinq, INT, INT, STRING)
 FCALLSCFUN1 (INT, modelInqInstitut, MODELINQINSTITUT, modelinqinstitut, INT)
 FCALLSCFUN1 (INT, modelInqGribID, MODELINQGRIBID, modelinqgribid, INT)
 FCALLSCFUN1 (STRING, modelInqNamePtr, MODELINQNAMEPTR, modelinqnameptr, INT)
@@ -491,6 +511,7 @@ FCALLSCSUB2 (tableWriteC, TABLEWRITEC, tablewritec, STRING, INT)
 FCALLSCSUB2 (tableWrite, TABLEWRITE, tablewrite, STRING, INT)
 FCALLSCFUN1 (INT, tableRead, TABLEREAD, tableread, STRING)
 FCALLSCFUN3 (INT, tableDef, TABLEDEF, tabledef, INT, INT, STRING)
+FCALLSCFUN1 (STRING, tableInqNamePtr, TABLEINQNAMEPTR, tableinqnameptr, INT)
 FCALLSCSUB5 (tableDefEntry, TABLEDEFENTRY, tabledefentry, INT, INT, STRING, STRING, STRING)
 FCALLSCFUN3 (INT, tableInq, TABLEINQ, tableinq, INT, INT, STRING)
 FCALLSCFUN0 (INT, tableInqNumber, TABLEINQNUMBER, tableinqnumber)
@@ -510,6 +531,30 @@ FCALLSCFUN2 (STRING, tableInqParUnitsPtr, TABLEINQPARUNITSPTR, tableinqparunitsp
 FCALLSCSUB3 (streamDefHistory, STREAMDEFHISTORY, streamdefhistory, INT, INT, STRING)
 FCALLSCFUN1 (INT, streamInqHistorySize, STREAMINQHISTORYSIZE, streaminqhistorysize, INT)
 FCALLSCSUB2 (streamInqHistoryString, STREAMINQHISTORYSTRING, streaminqhistorystring, INT, PSTRING)
+
+/*  Subtype routines  */
+
+FCALLSCFUN1 (INT, subtypeCreate, SUBTYPECREATE, subtypecreate, INT)
+
+/*  Gives a textual summary of the variable subtype  */
+
+FCALLSCSUB1 (subtypePrint, SUBTYPEPRINT, subtypeprint, INT)
+
+/*  Compares two subtype data structures.  */
+
+FCALLSCFUN2 (INT, subtypeCompare, SUBTYPECOMPARE, subtypecompare, INT, INT)
+FCALLSCFUN1 (INT, subtypeInqSize, SUBTYPEINQSIZE, subtypeinqsize, INT)
+FCALLSCFUN1 (INT, subtypeInqActiveIndex, SUBTYPEINQACTIVEINDEX, subtypeinqactiveindex, INT)
+FCALLSCSUB2 (subtypeDefActiveIndex, SUBTYPEDEFACTIVEINDEX, subtypedefactiveindex, INT, INT)
+
+/*  Generate a "query object" out of a key-value pair.  */
+
+
+/*  Generate an AND-combined "query object" out of two previous
+         query objects.  */
+
+FCALLSCFUN3 (INT, subtypeInqTile, SUBTYPEINQTILE, subtypeinqtile, INT, INT, INT)
+FCALLSCFUN2 (INT, vlistInqVarSubtype, VLISTINQVARSUBTYPE, vlistinqvarsubtype, INT, INT)
 FCALLSCSUB3 (gribapiLibraryVersion, GRIBAPILIBRARYVERSION, gribapilibraryversion, PINT, PINT, PINT)
 
 #endif
diff --git a/libcdi/src/cdi_cksum.c b/libcdi/src/cdi_cksum.c
index 04733d6..7244725 100644
--- a/libcdi/src/cdi_cksum.c
+++ b/libcdi/src/cdi_cksum.c
@@ -20,3 +20,13 @@ uint32_t cdiCheckSum(int type, int count, const void *buffer)
   s = memcrc_finish(&s, (off_t)(elemSize * (size_t)count));
   return s;
 }
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/cdi_cksum.h b/libcdi/src/cdi_cksum.h
index 2a29a34..99fa6b1 100644
--- a/libcdi/src/cdi_cksum.h
+++ b/libcdi/src/cdi_cksum.h
@@ -6,3 +6,13 @@
 uint32_t cdiCheckSum(int type, int count, const void *data);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/cdi_error.c b/libcdi/src/cdi_error.c
index 8170b77..36be80a 100644
--- a/libcdi/src/cdi_error.c
+++ b/libcdi/src/cdi_error.c
@@ -19,7 +19,7 @@ const char *cdiStringError(int cdiErrno)
   switch (cdiErrno) {
   case CDI_ESYSTEM:
     {
-      char *cp = (char *) strerror(errno);
+      const char *cp = strerror(errno);
       if ( cp == NULL ) break;
       return cp;
     }
@@ -32,6 +32,7 @@ const char *cdiStringError(int cdiErrno)
 
   return UnknownError;
 }
+
 /*
  * Local Variables:
  * c-file-style: "Java"
diff --git a/libcdi/src/cdi_int.c b/libcdi/src/cdi_int.c
index 53d2afa..332b641 100644
--- a/libcdi/src/cdi_int.c
+++ b/libcdi/src/cdi_int.c
@@ -21,8 +21,6 @@
 #include "cgribex.h"
 #endif
 
-extern int cdiPioSerialOpenFileMap(int streamID);
-
 int cdiDefaultCalendar = CALENDAR_PROLEPTIC;
 
 int cdiDefaultInstID   = CDI_UNDEFID;
@@ -36,7 +34,10 @@ int cdiSplitLtype105   = CDI_UNDEFID;
 int cdiIgnoreAttCoordinates = FALSE;
 int cdiIgnoreValidRange     = FALSE;
 int cdiSkipRecords          = 0;
+int cdiConvention           = CDI_CONVENTION_ECHAM;
 int cdiInventoryMode        = 1;
+int CDI_Version_Info        = 1;
+int CDI_cmor_mode           = 0;
 size_t CDI_netcdf_hdr_pad   = 0UL;
 
 char *cdiPartabPath   = NULL;
@@ -44,7 +45,7 @@ int   cdiPartabIntern = 1;
 
 double cdiDefaultMissval = -9.E33;
 
-const char Filetypes[][9] = {
+static const char Filetypes[][9] = {
   "UNKNOWN",
   "GRIB",
   "GRIB2",
@@ -58,11 +59,8 @@ const char Filetypes[][9] = {
   "HDF5",
 };
 
-#undef  UNDEFID
-#define UNDEFID  CDI_UNDEFID
-
-
 int CDI_Debug   = 0;    /* If set to 1, debugging           */
+int CDI_Recopt = 0;
 
 int cdiGribApiDebug     = 0;
 int cdiDefaultLeveltype = -1;
@@ -71,7 +69,7 @@ int cdiSortName = 0;
 int cdiHaveMissval = 0;
 
 
-static long cdiGetenvInt(char *envName)
+static long cdiGetenvInt(const char *envName)
 {
   char *envString;
   long envValue = -1;
@@ -271,7 +269,7 @@ void cdiSetChunk(const char *chunkAlgo)
 void cdiInitialize(void)
 {
   static int Init_CDI = FALSE;
-  char *envString;
+  char *envstr;
   long value;
 
   if ( ! Init_CDI )
@@ -289,6 +287,9 @@ void cdiInitialize(void)
       value = cdiGetenvInt("CDI_GRIBAPI_DEBUG");
       if ( value >= 0 ) cdiGribApiDebug = (int) value;
 
+      value = cdiGetenvInt("CDI_RECOPT");
+      if ( value >= 0 ) CDI_Recopt = (int) value;
+
       value = cdiGetenvInt("CDI_REGULARGRID");
       if ( value >= 0 ) cdiDataUnreduced = (int) value;
 
@@ -304,38 +305,49 @@ void cdiInitialize(void)
       value = cdiGetenvInt("CDI_NETCDF_HDR_PAD");
       if ( value >= 0 ) CDI_netcdf_hdr_pad = (size_t) value;
 
-      envString = getenv("CDI_MISSVAL");
-      if ( envString ) cdiDefaultMissval = atof(envString);
+      envstr = getenv("CDI_MISSVAL");
+      if ( envstr ) cdiDefaultMissval = atof(envstr);
       /*
-      envString = getenv("NC_MISSING_VALUE");
-      if ( envString ) cdiNcMissingValue = atoi(envString);
+      envstr = getenv("NC_MISSING_VALUE");
+      if ( envstr ) cdiNcMissingValue = atoi(envstr);
       */
-      envString = getenv("NC_CHUNKSIZEHINT");
-      if ( envString ) cdiNcChunksizehint = atoi(envString);
+      envstr = getenv("NC_CHUNKSIZEHINT");
+      if ( envstr ) cdiNcChunksizehint = atoi(envstr);
 
-      envString = getenv("CDI_CHUNK_ALGO");
-      if ( envString ) cdiSetChunk(envString);
+      envstr = getenv("CDI_CHUNK_ALGO");
+      if ( envstr ) cdiSetChunk(envstr);
 
-      envString = getenv("SPLIT_LTYPE_105");
-      if ( envString ) cdiSplitLtype105 = atoi(envString);
+      envstr = getenv("SPLIT_LTYPE_105");
+      if ( envstr ) cdiSplitLtype105 = atoi(envstr);
 
-      envString = getenv("IGNORE_ATT_COORDINATES");
-      if ( envString ) cdiIgnoreAttCoordinates = atoi(envString);
+      envstr = getenv("IGNORE_ATT_COORDINATES");
+      if ( envstr ) cdiIgnoreAttCoordinates = atoi(envstr);
 
-      envString = getenv("IGNORE_VALID_RANGE");
-      if ( envString ) cdiIgnoreValidRange = atoi(envString);
+      envstr = getenv("IGNORE_VALID_RANGE");
+      if ( envstr ) cdiIgnoreValidRange = atoi(envstr);
 
-      envString = getenv("CDI_SKIP_RECORDS");
-      if ( envString )
+      envstr = getenv("CDI_SKIP_RECORDS");
+      if ( envstr )
 	{
-	  cdiSkipRecords = atoi(envString);
+	  cdiSkipRecords = atoi(envstr);
 	  cdiSkipRecords = cdiSkipRecords > 0 ? cdiSkipRecords : 0;
 	}
 
-      envString = getenv("CDI_INVENTORY_MODE");
-      if ( envString )
+      envstr = getenv("CDI_CONVENTION");
+      if ( envstr )
+	{
+	  if ( strcmp(envstr, "CF") == 0 || strcmp(envstr, "cf") == 0 )
+	    {
+	      cdiConvention = CDI_CONVENTION_CF;
+	      if ( CDI_Debug )
+		Message("CDI convention was set to CF!");
+	    }
+	}
+
+      envstr = getenv("CDI_INVENTORY_MODE");
+      if ( envstr )
 	{
-	  if ( strncmp(envString, "time", 4) == 0 )
+	  if ( strncmp(envstr, "time", 4) == 0 )
 	    {
 	      cdiInventoryMode = 2;
 	      if ( CDI_Debug )
@@ -343,34 +355,47 @@ void cdiInitialize(void)
 	    }
 	}
 
-      envString = getenv("CDI_CALENDAR");
-      if ( envString )
+      envstr = getenv("CDI_VERSION_INFO");
+      if ( envstr )
+        {
+          int ival = atoi(envstr);
+          if ( ival == 0 || ival == 1 )
+            {
+              CDI_Version_Info = ival;
+              if ( CDI_Debug )
+                Message("CDI_Version_Info = %s", envstr);
+            }
+        }
+
+
+      envstr = getenv("CDI_CALENDAR");
+      if ( envstr )
 	{
-	  if      ( strncmp(envString, "standard", 8) == 0 )
+	  if      ( strncmp(envstr, "standard", 8) == 0 )
 	    cdiDefaultCalendar = CALENDAR_STANDARD;
-	  else if ( strncmp(envString, "proleptic", 9) == 0 )
+	  else if ( strncmp(envstr, "proleptic", 9) == 0 )
 	    cdiDefaultCalendar = CALENDAR_PROLEPTIC;
-	  else if ( strncmp(envString, "360days", 7) == 0 )
+	  else if ( strncmp(envstr, "360days", 7) == 0 )
 	    cdiDefaultCalendar = CALENDAR_360DAYS;
-	  else if ( strncmp(envString, "365days", 7) == 0 )
+	  else if ( strncmp(envstr, "365days", 7) == 0 )
 	    cdiDefaultCalendar = CALENDAR_365DAYS;
-	  else if ( strncmp(envString, "366days", 7) == 0 )
+	  else if ( strncmp(envstr, "366days", 7) == 0 )
 	    cdiDefaultCalendar = CALENDAR_366DAYS;
-	  else if ( strncmp(envString, "none", 4) == 0 )
+	  else if ( strncmp(envstr, "none", 4) == 0 )
 	    cdiDefaultCalendar = CALENDAR_NONE;
 
 	  if ( CDI_Debug )
-	    Message("Default calendar set to %s!", envString);
+	    Message("Default calendar set to %s!", envstr);
 	}
 #if  defined  (HAVE_LIBCGRIBEX)
       gribSetCalendar(cdiDefaultCalendar);
 #endif
 
-      envString = getenv("PARTAB_INTERN");
-      if ( envString ) cdiPartabIntern = atoi(envString);
+      envstr = getenv("PARTAB_INTERN");
+      if ( envstr ) cdiPartabIntern = atoi(envstr);
 
-      envString = getenv("PARTAB_PATH");
-      if ( envString ) cdiPartabPath = strdup(envString);
+      envstr = getenv("PARTAB_PATH");
+      if ( envstr ) cdiPartabPath = strdup(envstr);
     }
 }
 
@@ -396,6 +421,7 @@ void cdiDefGlobal(const char *string, int val)
   else if ( strcmp(string, "SORTNAME")         == 0 ) cdiSortName = val;
   else if ( strcmp(string, "HAVE_MISSVAL")     == 0 ) cdiHaveMissval = val;
   else if ( strcmp(string, "NC_CHUNKSIZEHINT") == 0 ) cdiNcChunksizehint = val;
+  else if ( strcmp(string, "CMOR_MODE")        == 0 ) CDI_cmor_mode = val;
   else if ( strcmp(string, "NETCDF_HDR_PAD")   == 0 ) CDI_netcdf_hdr_pad = (size_t) val;
   else Warning("Unsupported global key: %s", string);
 }
@@ -425,3 +451,4 @@ double cdiInqMissval(void)
  * require-trailing-newline: t
  * End:
  */
+
diff --git a/libcdi/src/cdi_int.h b/libcdi/src/cdi_int.h
index d85041d..b53a829 100644
--- a/libcdi/src/cdi_int.h
+++ b/libcdi/src/cdi_int.h
@@ -2,7 +2,7 @@
 #define _CDI_INT_H
 
 #if defined (HAVE_CONFIG_H)
-#  include "config.h"
+#include "config.h"
 #endif
 
 #include <assert.h>
@@ -13,8 +13,12 @@
 #include <math.h>
 #include <sys/types.h>
 
+#include "cdi.h"
+
 /* dummy use of unused parameters to silence compiler warnings */
+#ifndef UNUSED
 #define  UNUSED(x) (void)x
+#endif
 
 #ifndef strdupx
 #ifndef strdup
@@ -26,7 +30,7 @@ char *strdup(const char *s);
 ({					      	  \
    const char *__old = (s);			  \
    size_t __len = strlen(__old) + 1;		  \
-   char *__new = (char *) malloc(__len);	  \
+   char *__new = (char *) Malloc(__len);	  \
    (char *) memcpy(__new, __old, __len);	  \
 })
 */
@@ -65,7 +69,6 @@ char *strdup(const char *s);
 #  include "resource_handle.h"
 #endif
 
-#include "cdi.h"
 
 #define check_parg(arg)  if ( arg == 0 ) Warning("Argument '" #arg "' not allocated!")
 
@@ -95,7 +98,6 @@ char *strdup(const char *s);
 #  define IS_EQUAL(x,y)     (!IS_NOT_EQUAL(x,y))
 #endif
 
-
 #define  FALSE  0
 #define  TRUE   1
 
@@ -127,6 +129,18 @@ typedef struct
 }
 Record;
 
+/* data structure specifying tile-related meta-data. structure
+ * contains "-1" if this is no tile-variable. */
+typedef struct {
+  int
+    tileindex,
+    totalno_of_tileattr_pairs,
+    tileClassification,
+    numberOfTiles,
+    numberOfAttributes,
+    attribute;
+} var_tile_t;
+
 
 typedef struct
 {
@@ -142,14 +156,15 @@ typedef struct
   short     varID;
   short     levelID;
   char      varname[32]; /* needed for grib decoding with GRIB_API */
+  var_tile_t tiles;      /* tile-related meta-data, currently for GRIB-API only. */
 }
 record_t;
 
 
 typedef struct {
   record_t *records;
-  int       recordSize;  /* number of allocated records           */
   int      *recIDs;      /* IDs of non constant records           */
+  int       recordSize;  /* number of allocated records           */
   int       nrecs;       /* number of used records                */
                          /* tsID=0 nallrecs                       */
                          /* tsID>0 number of non constant records */
@@ -163,16 +178,24 @@ tsteps_t;
 
 
 typedef struct {
-  int       ncvarid;
   int       nlevs;
-  int      *level;       /* record IDs */
-  int      *lindex;      /* level index */
-  int       defmiss;     /* TRUE if missval is defined in file */
-
-  int       isUsed;
-  int       gridID;
-  int       zaxisID;
-  int       tsteptype;   /* TSTEP_* */
+  int       subtypeIndex; /* corresponding tile in subtype_t structure (subtype->self) */
+  int      *recordID;     /* record IDs: [nlevs] */
+  int      *lindex;       /* level index */
+} sleveltable_t;
+
+
+typedef struct {
+  int            ncvarid;
+  int            subtypeSize;
+  sleveltable_t *recordTable; /* record IDs for each subtype */
+  int            defmiss;     /* TRUE if missval is defined in file */
+
+  int            isUsed;
+  int            gridID;
+  int            zaxisID;
+  int            tsteptype;   /* TSTEP_* */
+  int            subtypeID;   /* subtype ID, e.g. for tile-related meta-data (currently for GRIB-API only). */
 }
 svarinfo_t;
 
@@ -194,12 +217,12 @@ typedef struct {
   int         byteorder;
   int         fileID;
   int         filemode;
+  int         nrecs;        /* number of records                  */
   off_t       numvals;
   char       *filename;
   Record     *record;
-  int         nrecs;        /* number of records                  */
-  int         nvars;        /* number of variables                */
   svarinfo_t *vars;
+  int         nvars;        /* number of variables                */
   int         varsAllocated;
   int         curTsID;      /* current timestep ID */
   int         rtsteps;      /* number of tsteps accessed       */
@@ -213,6 +236,7 @@ typedef struct {
   int         xdimID[MAX_GRIDS_PS];	//Warning: synchronous array to vlist_to_pointer(vlistID)->gridIDs
   int         ydimID[MAX_GRIDS_PS];	//Warning: synchronous array to vlist_to_pointer(vlistID)->gridIDs
   int         zaxisID[MAX_ZAXES_PS];	//Warning: synchronous array to vlist_to_pointer(vlistID)->zaxisIDs
+  int         nczvarID[MAX_ZAXES_PS];
   int         ncxvarID[MAX_GRIDS_PS];
   int         ncyvarID[MAX_GRIDS_PS];
   int         ncavarID[MAX_GRIDS_PS];
@@ -230,25 +254,46 @@ typedef struct {
 #else
   void       *gribContainers;
 #endif
-  int         vlistIDorig;
-  /* only used by MPI-parallelized version of library */
-  int       ownerRank;    // MPI rank of owner process
-  /* ---------------------------------- */
-  /* Local change: 2013-02-18, FP (DWD) */
-  /* ---------------------------------- */
 
   void *gh; // grib handle
 }
 stream_t;
 
 
+/* Length of optional keyword/value pair list */
+#define MAX_OPT_GRIB_ENTRIES 500
+
+enum cdi_convention {CDI_CONVENTION_ECHAM, CDI_CONVENTION_CF};
+
+/* Data type specification for optional key/value pairs (GRIB) */
+typedef enum {
+  t_double = 0,
+  t_int    = 1
+} key_val_pair_datatype;
+
+/* Data structure holding optional key/value pairs for GRIB */
+typedef struct
+{
+  char*                  keyword;        /* keyword string */
+  int                    update;
+  key_val_pair_datatype  data_type;      /* data type of this key/value pair */
+  double                 dbl_val;        /* double value (data_type == t_double) */
+  int                    int_val;        /* integer value (data_type == t_int) */
+  int                    subtype_index;  /* tile index for this key-value pair */
+} opt_key_val_pair_t;
+
+
+
+
 extern int CDI_Debug;      /* If set to 1, debuggig (default 0)            */
+extern int CDI_Recopt;
 extern int cdiGribApiDebug;
 extern double cdiDefaultMissval;
 extern int cdiDefaultInstID;
 extern int cdiDefaultModelID;
 extern int cdiDefaultTableID;
 extern int cdiDefaultLeveltype;
+extern int cdiDefaultCalendar;
 //extern int cdiNcMissingValue;
 extern int cdiNcChunksizehint;
 extern int cdiChunkType;
@@ -256,6 +301,14 @@ extern int cdiSplitLtype105;
 extern int cdiDataUnreduced;
 extern int cdiSortName;
 extern int cdiHaveMissval;
+extern int cdiIgnoreAttCoordinates;
+extern int cdiIgnoreValidRange;
+extern int cdiSkipRecords;
+extern int cdiConvention;
+extern int cdiInventoryMode;
+extern int CDI_Version_Info;
+extern int CDI_cmor_mode;
+extern size_t CDI_netcdf_hdr_pad;
 extern int STREAM_Debug;
 
 
@@ -266,7 +319,7 @@ extern const resOps streamOps;
 static inline stream_t *
 stream_to_pointer(int idx)
 {
-  return reshGetVal(idx, &streamOps);
+  return (stream_t *)reshGetVal(idx, &streamOps);
 }
 
 static inline void
@@ -281,7 +334,7 @@ int     streamInqFileID(int streamID);
 void    gridDefHasDims(int gridID, int hasdims);
 int     gridInqHasDims(int gridID);
 const char *gridNamePtr(int gridtype);
-char   *zaxisNamePtr(int leveltype);
+const char   *zaxisNamePtr(int leveltype);
 int     zaxisInqLevelID(int zaxisID, double level);
 
 void    streamCheckID(const char *caller, int streamID);
@@ -290,8 +343,10 @@ void    streamDefineTaxis(int streamID);
 
 int     streamsNewEntry(int filetype);
 void    streamsInitEntry(int streamID);
-void    cdiStreamSetupVlist(stream_t *streamptr, int vlistID, int vlistIDorig);
-int     stream_new_var(stream_t *streamptr, int gridID, int zaxisID);
+void    cdiStreamSetupVlist(stream_t *streamptr, int vlistID);
+/* default implementation of the overridable function */
+void    cdiStreamSetupVlist_(stream_t *streamptr, int vlistID);
+int     stream_new_var(stream_t *streamptr, int gridID, int zaxisID, int tilesetID);
 
 int     tstepsNewEntry(stream_t *streamptr);
 
@@ -318,22 +373,25 @@ int     cdiInqAccesstype(int streamID);
 
 int     getByteswap(int byteorder);
 
-void cdiStreamGetIndexList(unsigned numIDs, int IDs[numIDs]);
+void cdiStreamGetIndexList(unsigned numIDs, int IDs[]);
 
 
 void  cdiInitialize(void);
 
-void uuid2str(const unsigned char *uuid, char *uuidstr);
-int str2uuid(const char *uuidstr, unsigned char *uuid);
+void uuid2str(const unsigned char uuid[], char uuidstr[]);
+int str2uuid(const char *uuidstr, unsigned char uuid[]);
 
-static inline int cdiUUIDIsNull(const unsigned char uuid[CDI_UUID_SIZE])
+static inline int cdiUUIDIsNull(const unsigned char uuid[])
 {
-  static const unsigned char uuid_nil[CDI_UUID_SIZE];
-  return !memcmp(uuid, uuid_nil, CDI_UUID_SIZE);
+  int isNull = 1;
+  for (size_t i = 0; i < CDI_UUID_SIZE; ++i)
+    isNull &= (uuid[i] == 0);
+  return isNull;
 }
 
-char* cdiEscapeSpaces(const char* string);
-char* cdiUnescapeSpaces(const char* string, const char** outStringEnd);
+
+char *cdiEscapeSpaces(const char *string);
+char *cdiUnescapeSpaces(const char *string, const char **outStringEnd);
 
 #define CDI_UNIT_PA   1
 #define CDI_UNIT_HPA  2
@@ -344,25 +402,29 @@ char* cdiUnescapeSpaces(const char* string, const char** outStringEnd);
 
 struct streamAssoc
 {
-  int streamID, vlistID, vlistIDorig;
+  int streamID, vlistID;
 };
 
 struct streamAssoc
-streamUnpack(char * unpackBuffer, int unpackBufferSize,
-             int * unpackBufferPos, int originNamespace, void *context);
+streamUnpack(char *unpackBuffer, int unpackBufferSize,
+             int *unpackBufferPos, int originNamespace, void *context);
 
 int
-cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
+cdiStreamOpenDefaultDelegate(const char *filename, char filemode,
                              int filetype, stream_t *streamptr,
                              int recordBufIsToBeCreated);
 
+int
+streamOpenID(const char *filename, char filemode, int filetype,
+             int resH);
+
 void
 cdiStreamDefVlist_(int streamID, int vlistID);
 void
 cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
                    int nmiss);
 void
-cdiStreamwriteVarChunk_(int streamID, int varID, int memtype,
+cdiStreamWriteVarChunk_(int streamID, int varID, int memtype,
                         const int rect[][2], const void *data, int nmiss);
 void
 cdiStreamCloseDefaultDelegate(stream_t *streamptr,
@@ -372,13 +434,16 @@ int cdiStreamDefTimestep_(stream_t *streamptr, int tsID);
 
 void cdiStreamSync_(stream_t *streamptr);
 
-char *cdiUnitNamePtr(int cdi_unit);
+const char *cdiUnitNamePtr(int cdi_unit);
 
 void zaxisGetIndexList(int nzaxis, int *zaxisIndexList);
 
 void zaxisDefLtype2(int zaxisID, int ltype2);
 int  zaxisInqLtype2(int zaxisID);
 
+/* used by CDO */
+void cdiDefTableID(int tableID);
+
 #endif  /* _CDI_INT_H */
 /*
  * Local Variables:
diff --git a/libcdi/src/cdi_limits.h b/libcdi/src/cdi_limits.h
index 0ef0207..8c797ad 100644
--- a/libcdi/src/cdi_limits.h
+++ b/libcdi/src/cdi_limits.h
@@ -1,9 +1,10 @@
 #ifndef _CDI_LIMITS_H
 #define _CDI_LIMITS_H
 
-#define  MAX_GRIDS_PS    128  /* maximum number of different grids per stream */
-#define  MAX_ZAXES_PS    128  /* maximum number of different zaxes per stream */
-#define  MAX_ATTRIBUTES  256  /* maximum number of attributes per variable    */
+#define  MAX_GRIDS_PS    128  /* maximum number of different grids per stream    */
+#define  MAX_ZAXES_PS    128  /* maximum number of different zaxes per stream    */
+#define  MAX_ATTRIBUTES  256  /* maximum number of attributes per variable       */
+#define  MAX_SUBTYPES_PS 128  /* maximum number of different subtypes per stream */
 
 #endif  /* _CDI_LIMITS_H */
 /*
diff --git a/libcdi/src/cdi_util.c b/libcdi/src/cdi_util.c
index 7966321..600a974 100644
--- a/libcdi/src/cdi_util.c
+++ b/libcdi/src/cdi_util.c
@@ -1,4 +1,12 @@
+#if defined (HAVE_CONFIG_H)
+#  include "config.h"
+#endif
+
 #include <stdio.h>
+#include <stdlib.h>
+
+#include "cdi.h"
+#include "cdi_int.h"
 
 void cdiDecodeParam(int param, int *pnum, int *pcat, int *pdis)
 {
@@ -31,48 +39,41 @@ int cdiEncodeParam(int pnum, int pcat, int pdis)
 
 void cdiDecodeDate(int date, int *year, int *month, int *day)
 {
-  int idate;
 
-  *year  =  date / 10000;
-  idate  = date - *year*10000;
-  if ( idate < 0 ) idate = -idate;
-  *month = idate / 100;
-  *day   = idate - *month*100;
+  int iyear = date / 10000;
+  *year = iyear;
+  int idate = abs(date - iyear * 10000),
+    imonth = idate / 100;
+  *month = imonth;
+  *day   = idate - imonth * 100;
 }
 
 
 int cdiEncodeDate(int year, int month, int day)
 {
-  int date;
-  int iyear;
-
-  iyear = year;
-  if ( iyear < 0 ) iyear = -iyear;
-  date = iyear*10000 + month*100 + day;
+  int iyear = abs(year),
+    date = iyear * 10000 + month * 100 + day;
   if ( year < 0 ) date = -date;
-
   return (date);
 }
 
 
 void cdiDecodeTime(int time, int *hour, int *minute, int *second)
 {
-  int itime;
-
-  *hour   = time / 10000;
-  itime   = time - *hour*10000;
-  *minute = itime / 100;
-  *second = itime - *minute*100;
+  int ihour = time / 10000,
+    itime = time - ihour * 10000,
+    iminute = itime / 100;
+  *hour   = ihour;
+  *minute = iminute;
+  *second = itime - iminute * 100;
 }
 
 
 int cdiEncodeTime(int hour, int minute, int second)
 {
-  int time;
+  int time = hour*10000 + minute*100 + second;
 
-  time = hour*10000 + minute*100 + second;
-
-  return (time);
+  return time;
 }
 
 
@@ -83,21 +84,22 @@ void cdiParamToString(int param, char *paramstr, int maxlen)
 
   cdiDecodeParam(param, &num, &cat, &dis);
 
+  size_t umaxlen = maxlen >= 0 ? (unsigned)maxlen : 0U;
   if ( dis == 255 && (cat == 255 || cat == 0 ) )
-    len = sprintf(paramstr, "%d", num);
+    len = snprintf(paramstr, umaxlen, "%d", num);
   else  if ( dis == 255 )
-    len = sprintf(paramstr, "%d.%d", num, cat);
+    len = snprintf(paramstr, umaxlen, "%d.%d", num, cat);
   else
-    len = sprintf(paramstr, "%d.%d.%d", num, cat, dis);
+    len = snprintf(paramstr, umaxlen, "%d.%d.%d", num, cat, dis);
 
-  if ( len > ( maxlen-1) )
+  if ( len >= maxlen || len < 0)
     fprintf(stderr, "Internal problem (%s): size of input string is too small!\n", __func__);
 }
 
 
-char *cdiUnitNamePtr(int cdi_unit)
+const char *cdiUnitNamePtr(int cdi_unit)
 {
-  char *cdiUnits[] = {
+  const char *cdiUnits[] = {
     /*  0 */  "undefined",
     /*  1 */  "Pa",
     /*  2 */  "hPa",
@@ -106,15 +108,10 @@ char *cdiUnitNamePtr(int cdi_unit)
     /*  5 */  "dm",
     /*  6 */  "m",
   };
-  char *name;
-  int size = (int) (sizeof(cdiUnits)/sizeof(char *));
-
-  if ( cdi_unit > 0 && cdi_unit < size )
-    name = cdiUnits[cdi_unit];
-  else
-    name = NULL;
-
-  return (name);
+  enum { numUnits = (int) (sizeof(cdiUnits)/sizeof(char *)) };
+  const char *name = ( cdi_unit > 0 && cdi_unit < numUnits ) ?
+    cdiUnits[cdi_unit] : NULL;
+  return name;
 }
 
 /*
diff --git a/libcdi/src/cdilib.c b/libcdi/src/cdilib.c
index a6185d8..4f455df 100644
--- a/libcdi/src/cdilib.c
+++ b/libcdi/src/cdilib.c
@@ -1,7 +1,7 @@
 
-/* Automatically generated by m214003 at 2015-04-27, do not edit */
+/* Automatically generated by m214003 at 2015-10-25, do not edit */
 
-/* CDILIB_VERSION="1.6.9" */
+/* CDILIB_VERSION="1.7.0" */
 
 #ifdef _ARCH_PWR6
 #pragma options nostrict
@@ -148,7 +148,7 @@ cdiAbortC_serial(const char *caller, const char *filename,
 #include <stdio.h>
 #include <sys/types.h>
 /*
-#if defined(__cplusplus)
+#ifdef __cplusplus
 extern "C" {
 #endif
 */
@@ -161,6 +161,7 @@ extern "C" {
 
 #define  CDI_BIGENDIAN            0   /* Byte order BIGENDIAN                 */
 #define  CDI_LITTLEENDIAN         1   /* Byte order LITTLEENDIAN              */
+#define  CDI_PDPENDIAN            2
 
 #define  CDI_REAL                 1   /* Real numbers                         */
 #define  CDI_COMP                 2   /* Complex numbers                      */
@@ -307,6 +308,26 @@ extern "C" {
 #define  ZAXIS_MIX_LAYER           24  /* Mixing Layer                                          */
 #define  ZAXIS_REFERENCE           25  /* zaxis reference number                                */
 
+/* SUBTYPE types */
+
+enum {
+  SUBTYPE_TILES                         = 0  /* Tiles variable                                  */
+};
+
+#define MAX_KV_PAIRS_MATCH 10
+
+/* Data structure defining a key-value search, possibly with multiple
+   key-value pairs in combination.
+
+   Currently, only multiple pairs combined by AND are supported.
+*/
+typedef struct  {
+  int nAND;                                   /* no. of key-value pairs that have to match */
+  int key_value_pairs[2][MAX_KV_PAIRS_MATCH]; /* key-value pairs */
+} subtype_query_t;
+
+
+
 /* TIME types */
 
 #define  TIME_CONSTANT              0  /* obsolate, use TSTEP_CONSTANT                          */
@@ -387,8 +408,9 @@ void    cdiDefMissval(double missval);
 double  cdiInqMissval(void);
 void    cdiDefGlobal(const char *string, int val);
 
-int     namespaceNew();
+int     namespaceNew(void);
 void    namespaceSetActive(int namespaceID);
+int     namespaceGetActive(void);
 void    namespaceDelete(int namespaceID);
 
 
@@ -434,8 +456,6 @@ void    streamDefVlist(int streamID, int vlistID);
 
 /*      streamInqVlist: Get the Vlist of a stream */
 int     streamInqVlist(int streamID);
-/*      PIO: */
-int     streamInqVlistIDorig(int streamID);
 
 /*      streamInqFiletype: Get the filetype */
 int     streamInqFiletype(int streamID);
@@ -467,8 +487,8 @@ int     streamInqTimestep(int streamID, int tsID);
 /*      PIO: query currently set timestep id  */
 int     streamInqCurTimestepID(int streamID);
 
-const char* streamFilename(int streamID);
-const char* streamFilesuffix(int filetype);
+const char *streamFilename(int streamID);
+const char *streamFilesuffix(int filetype);
 
 off_t   streamNvals(int streamID);
 
@@ -477,31 +497,31 @@ int     streamInqNvars ( int streamID );
 /* STREAM var I/O routines */
 
 /*      streamWriteVar: Write a variable */
-void    streamWriteVar(int streamID, int varID, const double *data_vec, int nmiss);
-void    streamWriteVarF(int streamID, int varID, const float *data_vec, int nmiss);
+void    streamWriteVar(int streamID, int varID, const double data[], int nmiss);
+void    streamWriteVarF(int streamID, int varID, const float data[], int nmiss);
 
 /*      streamReadVar: Read a variable */
-void    streamReadVar(int streamID, int varID, double *data_vec, int *nmiss);
-void    streamReadVarF(int streamID, int varID, float *data_vec, int *nmiss);
+void    streamReadVar(int streamID, int varID, double data[], int *nmiss);
+void    streamReadVarF(int streamID, int varID, float data[], int *nmiss);
 
 /*      streamWriteVarSlice: Write a horizontal slice of a variable */
-void    streamWriteVarSlice(int streamID, int varID, int levelID, const double *data_vec, int nmiss);
-void    streamWriteVarSliceF(int streamID, int varID, int levelID, const float *data_vec, int nmiss);
+void    streamWriteVarSlice(int streamID, int varID, int levelID, const double data[], int nmiss);
+void    streamWriteVarSliceF(int streamID, int varID, int levelID, const float data[], int nmiss);
 
 /*      streamReadVarSlice: Read a horizontal slice of a variable */
-void    streamReadVarSlice(int streamID, int varID, int levelID, double *data_vec, int *nmiss);
-void    streamReadVarSliceF(int streamID, int varID, int levelID, float *data_vec, int *nmiss);
+void    streamReadVarSlice(int streamID, int varID, int levelID, double data[], int *nmiss);
+void    streamReadVarSliceF(int streamID, int varID, int levelID, float data[], int *nmiss);
 
-void    streamWriteVarChunk(int streamID, int varID, const int rect[3][2], const double *data_vec, int nmiss);
+void    streamWriteVarChunk(int streamID, int varID, const int rect[3][2], const double data[], int nmiss);
 
 
 /* STREAM record I/O routines */
 
 void    streamDefRecord(int streamID, int  varID, int  levelID);
 void    streamInqRecord(int streamID, int *varID, int *levelID);
-void    streamWriteRecord(int streamID, const double *data_vec, int nmiss);
-void    streamWriteRecordF(int streamID, const float *data_vec, int nmiss);
-void    streamReadRecord(int streamID, double *data_vec, int *nmiss);
+void    streamWriteRecord(int streamID, const double data[], int nmiss);
+void    streamWriteRecordF(int streamID, const float data[], int nmiss);
+void    streamReadRecord(int streamID, double data[], int *nmiss);
 void    streamCopyRecord(int streamIDdest, int streamIDsrc);
 
 void    streamInqGRIBinfo(int streamID, int *intnum, float *fltnum, off_t *bignum);
@@ -510,56 +530,56 @@ void    streamInqGRIBinfo(int streamID, int *intnum, float *fltnum, off_t *bignu
 /* File driven I/O (may yield better performance than using the streamXXX functions) */
 
 //Creation & Destruction
-CdiIterator* cdiIterator_new(const char* path);  //Requires a subsequent call to cdiIteratorNextField() to point the iterator at the first field.
-CdiIterator* cdiIterator_clone(CdiIterator* me);
-char* cdiIterator_serialize(CdiIterator* me);  //Returns a malloc'ed string.
-CdiIterator* cdiIterator_deserialize(const char* description);  //description is a string that was returned by cdiIteratorSerialize(). Returns a copy of the original iterator.
-void cdiIterator_print(CdiIterator* me, FILE* stream);
-void cdiIterator_delete(CdiIterator* me);
+CdiIterator *cdiIterator_new(const char *path);  //Requires a subsequent call to cdiIteratorNextField() to point the iterator at the first field.
+CdiIterator *cdiIterator_clone(CdiIterator *me);
+char *cdiIterator_serialize(CdiIterator *me);  //Returns a malloc'ed string.
+CdiIterator *cdiIterator_deserialize(const char *description);  //description is a string that was returned by cdiIteratorSerialize(). Returns a copy of the original iterator.
+void cdiIterator_print(CdiIterator *me, FILE *stream);
+void cdiIterator_delete(CdiIterator *me);
 
 //Advancing an iterator
-int cdiIterator_nextField(CdiIterator* me);      //Points the iterator at the next field, returns CDI_EEOF if there are no more fields in the file.
+int cdiIterator_nextField(CdiIterator *me);      //Points the iterator at the next field, returns CDI_EEOF if there are no more fields in the file.
 
 //Introspecting metadata
 //All outXXX arguments to these functions may be NULL.
-char* cdiIterator_inqStartTime(CdiIterator* me);      //Returns the (start) time as an ISO-8601 coded string. The caller is responsible to free() the returned string.
-char* cdiIterator_inqEndTime(CdiIterator* me);      //Returns the end time of an integration period as an ISO-8601 coded string, or NULL if there is no end time. The caller is responsible to free() the returned string.
-char* cdiIterator_inqVTime(CdiIterator* me);      //Returns the validity date as an ISO-8601 coded string. The caller is responsible to free() the returned string.
-int cdiIterator_inqLevelType(CdiIterator* me, int levelSelector, char** outName, char** outLongName, char** outStdName, char** outUnit);      //callers are responsible to free() strings that they request
-int cdiIterator_inqLevel(CdiIterator* me, int levelSelector, double* outValue1, double* outValue2);       //outValue2 is only written to if the level is a hybrid level
-int cdiIterator_inqLevelUuid(CdiIterator* me, int* outVgridNumber, int* outLevelCount, unsigned char (*outUuid)[CDI_UUID_SIZE]);   //outUuid must point to a buffer of 16 bytes, returns an error code if no generalized zaxis is used.
-CdiParam cdiIterator_inqParam(CdiIterator* me);
-int cdiIterator_inqDatatype(CdiIterator* me);
-int cdiIterator_inqTsteptype(CdiIterator* me);
-char* cdiIterator_inqVariableName(CdiIterator* me);        //The caller is responsible to free() the returned buffer.
-int cdiIterator_inqGridId(CdiIterator* me);         //The returned id is only valid until the next call to cdiIteratorNextField().
+char *cdiIterator_inqStartTime(CdiIterator *me);      //Returns the (start) time as an ISO-8601 coded string. The caller is responsible to Free() the returned string.
+char *cdiIterator_inqEndTime(CdiIterator *me);      //Returns the end time of an integration period as an ISO-8601 coded string, or NULL if there is no end time. The caller is responsible to Free() the returned string.
+char *cdiIterator_inqVTime(CdiIterator *me);      //Returns the validity date as an ISO-8601 coded string. The caller is responsible to Free() the returned string.
+int cdiIterator_inqLevelType(CdiIterator *me, int levelSelector, char **outName_optional, char **outLongName_optional, char **outStdName_optional, char **outUnit_optional);      //callers are responsible to Free() strings that they request
+int cdiIterator_inqLevel(CdiIterator *me, int levelSelector, double *outValue1_optional, double *outValue2_optional);       //outValue2 is only written to if the level is a hybrid level
+int cdiIterator_inqLevelUuid(CdiIterator *me, int *outVgridNumber_optional, int *outLevelCount_optional, unsigned char outUuid_optional[CDI_UUID_SIZE]);   //outUuid must point to a buffer of 16 bytes, returns an error code if no generalized zaxis is used.
+CdiParam cdiIterator_inqParam(CdiIterator *me);
+int cdiIterator_inqDatatype(CdiIterator *me);
+int cdiIterator_inqTsteptype(CdiIterator *me);
+char *cdiIterator_inqVariableName(CdiIterator *me);        //The caller is responsible to Free() the returned buffer.
+int cdiIterator_inqGridId(CdiIterator *me);         //The returned id is only valid until the next call to cdiIteratorNextField().
 
 //Reading data
-void cdiIterator_readField(CdiIterator* me, double* data_vec, size_t* nmiss);
-void cdiIterator_readFieldF(CdiIterator* me, float* data_vec, size_t* nmiss);
+void cdiIterator_readField(CdiIterator *me, double data[], size_t *nmiss_optional);
+void cdiIterator_readFieldF(CdiIterator *me, float data[], size_t *nmiss_optional);
 //TODO[NH]: Add functions to read partial fields.
 
 
 //Direct access to grib fields
-CdiGribIterator* cdiGribIterator_clone(CdiIterator* me);  //Returns NULL if the associated file is not a GRIB file.
-void cdiGribIterator_delete(CdiGribIterator* me);
+CdiGribIterator *cdiGribIterator_clone(CdiIterator *me);  //Returns NULL if the associated file is not a GRIB file.
+void cdiGribIterator_delete(CdiGribIterator *me);
 
 //Callthroughs to GRIB-API
-int cdiGribIterator_getLong(CdiGribIterator* me, const char* key, long* value); //Same semantics as grib_get_long().
-int cdiGribIterator_getDouble(CdiGribIterator* me, const char* key, double* value); //Same semantics as grib_get_double().
-int cdiGribIterator_getLength(CdiGribIterator* me, const char* key, size_t* value);     //Same semantics as grib_get_length().
-int cdiGribIterator_getString(CdiGribIterator* me, const char* key, char* value, size_t* length);       //Same semantics as grib_get_string().
-int cdiGribIterator_getSize(CdiGribIterator* me, const char* key, size_t* value);     //Same semantics as grib_get_size().
-int cdiGribIterator_getLongArray(CdiGribIterator* me, const char* key, long* value, size_t* array_size);       //Same semantics as grib_get_long_array().
-int cdiGribIterator_getDoubleArray(CdiGribIterator* me, const char* key, double* value, size_t* array_size);       //Same semantics as grib_get_double_array().
+int cdiGribIterator_getLong(CdiGribIterator *me, const char *key, long *value); //Same semantics as grib_get_long().
+int cdiGribIterator_getDouble(CdiGribIterator *me, const char *key, double *value); //Same semantics as grib_get_double().
+int cdiGribIterator_getLength(CdiGribIterator *me, const char *key, size_t *value);     //Same semantics as grib_get_length().
+int cdiGribIterator_getString(CdiGribIterator *me, const char *key, char *value, size_t *length);       //Same semantics as grib_get_string().
+int cdiGribIterator_getSize(CdiGribIterator *me, const char *key, size_t *value);     //Same semantics as grib_get_size().
+int cdiGribIterator_getLongArray(CdiGribIterator *me, const char *key, long *value, size_t *array_size);       //Same semantics as grib_get_long_array().
+int cdiGribIterator_getDoubleArray(CdiGribIterator *me, const char *key, double *value, size_t *array_size);       //Same semantics as grib_get_double_array().
 
 //Convenience functions for accessing GRIB-API keys
-int cdiGribIterator_inqEdition(CdiGribIterator* me);
-long cdiGribIterator_inqLongValue(CdiGribIterator* me, const char* key);   //Aborts on failure to fetch the given key.
-long cdiGribIterator_inqLongDefaultValue(CdiGribIterator* me, const char* key, long defaultValue); //Returns the default value if the given key is not present.
-double cdiGribIterator_inqDoubleValue(CdiGribIterator* me, const char* key);   //Aborts on failure to fetch the given key.
-double cdiGribIterator_inqDoubleDefaultValue(CdiGribIterator* me, const char* key, double defaultValue); //Returns the default value if the given key is not present.
-char* cdiGribIterator_inqStringValue(CdiGribIterator* me, const char* key);        //Returns a malloc'ed string.
+int cdiGribIterator_inqEdition(CdiGribIterator *me);
+long cdiGribIterator_inqLongValue(CdiGribIterator *me, const char *key);   //Aborts on failure to fetch the given key.
+long cdiGribIterator_inqLongDefaultValue(CdiGribIterator *me, const char *key, long defaultValue); //Returns the default value if the given key is not present.
+double cdiGribIterator_inqDoubleValue(CdiGribIterator *me, const char *key);   //Aborts on failure to fetch the given key.
+double cdiGribIterator_inqDoubleDefaultValue(CdiGribIterator *me, const char *key, double defaultValue); //Returns the default value if the given key is not present.
+char *cdiGribIterator_inqStringValue(CdiGribIterator *me, const char *key);        //Returns a malloc'ed string.
 
 /* VLIST routines */
 
@@ -600,6 +620,9 @@ int     vlistNgrids(int vlistID);
 /*      vlistNzaxis: Number of zaxis in a variable list */
 int     vlistNzaxis(int vlistID);
 
+/*      vlistNsubtypes: Number of subtypes in a variable list */
+int     vlistNsubtypes(int vlistID);
+
 void    vlistDefNtsteps(int vlistID, int nts);
 int     vlistNtsteps(int vlistID);
 int     vlistGridsizeMax(int vlistID);
@@ -612,6 +635,8 @@ int     vlistZaxisIndex(int vlistID, int zaxisID);
 void    vlistChangeZaxisIndex(int vlistID, int index, int zaxisID);
 void    vlistChangeZaxis(int vlistID, int zaxisID1, int zaxisID2);
 int     vlistNrecs(int vlistID);
+int     vlistSubtype(int vlistID, int index);
+int     vlistSubtypeIndex(int vlistID, int subtypeID);
 
 /*      vlistDefTaxis: Define the time axis of a variable list */
 void    vlistDefTaxis(int vlistID, int taxisID);
@@ -629,7 +654,10 @@ int     vlistInqModel(int vlistID);
 
 /* VLIST VAR routines */
 
-/*      vlistDefVar: Create a new Variable */
+/*      vlistDefVarTiles: Create a new tile-based variable */
+int     vlistDefVarTiles(int vlistID, int gridID, int zaxisID, int tsteptype, int tilesetID);
+
+/*      vlistDefVar: Create a new variable */
 int     vlistDefVar(int vlistID, int gridID, int zaxisID, int tsteptype);
 
 void    vlistChangeVarGrid(int vlistID, int varID, int gridID);
@@ -690,7 +718,7 @@ void    vlistDefVarName(int vlistID, int varID, const char *name);
 void    vlistInqVarName(int vlistID, int varID, char *name);
 
 /*      vlistCopyVarName: Safe and convenient version of vlistInqVarName */
-char* vlistCopyVarName(int vlistId, int varId);
+char *vlistCopyVarName(int vlistId, int varId);
 
 /*      vlistDefVarStdname: Define the standard name of a Variable */
 void    vlistDefVarStdname(int vlistID, int varID, const char *stdname);
@@ -754,7 +782,7 @@ void    vlistDefVarEnsemble(int vlistID, int varID, int ensID, int ensCount, int
 int     vlistInqVarEnsemble(int vlistID, int varID, int *ensID, int *ensCount, int *forecast_type);
 
 /* cdiClearAdditionalKeys: Clear the list of additional GRIB keys. */
-void    cdiClearAdditionalKeys();
+void    cdiClearAdditionalKeys(void);
 /* cdiDefAdditionalKey: Register an additional GRIB key which is read when file is opened. */
 void    cdiDefAdditionalKey(const char *string);
 
@@ -780,16 +808,16 @@ int     vlistInqAtt(int vlistID, int varID, int attrnum, char *name, int *typep,
 int     vlistDelAtt(int vlistID, int varID, const char *name);
 
 /*      vlistDefAttInt: Define an integer attribute */
-int     vlistDefAttInt(int vlistID, int varID, const char *name, int type, int len, const int *ip_vec);
+int     vlistDefAttInt(int vlistID, int varID, const char *name, int type, int len, const int ip[]);
 /*      vlistDefAttFlt: Define a floating point attribute */
-int     vlistDefAttFlt(int vlistID, int varID, const char *name, int type, int len, const double *dp_vec);
+int     vlistDefAttFlt(int vlistID, int varID, const char *name, int type, int len, const double dp[]);
 /*      vlistDefAttTxt: Define a text attribute */
 int     vlistDefAttTxt(int vlistID, int varID, const char *name, int len, const char *tp_cbuf);
 
 /*      vlistInqAttInt: Get the value(s) of an integer attribute */
-int     vlistInqAttInt(int vlistID, int varID, const char *name, int mlen, int *ip_vec);
+int     vlistInqAttInt(int vlistID, int varID, const char *name, int mlen, int ip[]);
 /*      vlistInqAttFlt: Get the value(s) of a floating point attribute */
-int     vlistInqAttFlt(int vlistID, int varID, const char *name, int mlen, double *dp_vec);
+int     vlistInqAttFlt(int vlistID, int varID, const char *name, int mlen, double dp[]);
 /*      vlistInqAttTxt: Get the value(s) of a text attribute */
 int     vlistInqAttTxt(int vlistID, int varID, const char *name, int mlen, char *tp_cbuf);
 
@@ -801,11 +829,11 @@ const char *gridNamePtr(int gridtype);
 
 void    gridCompress(int gridID);
 
-void    gridDefMaskGME(int gridID, const int *mask_vec);
-int     gridInqMaskGME(int gridID, int *mask_vec);
+void    gridDefMaskGME(int gridID, const int mask[]);
+int     gridInqMaskGME(int gridID, int mask[]);
 
-void    gridDefMask(int gridID, const int *mask_vec);
-int     gridInqMask(int gridID, int *mask_vec);
+void    gridDefMask(int gridID, const int mask[]);
+int     gridInqMask(int gridID, int mask[]);
 
 void    gridPrint(int gridID, int index, int opt);
 
@@ -843,16 +871,16 @@ void    gridDefNP(int gridID, int np);
 int     gridInqNP(int gridID);
 
 /*      gridDefXvals: Define the values of a X-axis */
-void    gridDefXvals(int gridID, const double *xvals_vec);
+void    gridDefXvals(int gridID, const double xvals[]);
 
 /*      gridInqXvals: Get all values of a X-axis */
-int     gridInqXvals(int gridID, double *xvals_vec);
+int     gridInqXvals(int gridID, double xvals[]);
 
 /*      gridDefYvals: Define the values of a Y-axis */
-void    gridDefYvals(int gridID, const double *yvals_vec);
+void    gridDefYvals(int gridID, const double yvals[]);
 
 /*      gridInqYvals: Get all values of a Y-axis */
-int     gridInqYvals(int gridID, double *yvals_vec);
+int     gridInqYvals(int gridID, double yvals[]);
 
 /*      gridDefXname: Define the name of a X-axis */
 void    gridDefXname(int gridID, const char *xname);
@@ -952,11 +980,18 @@ void    gridDefReference(int gridID, const char *reference);
 int     gridInqReference(int gridID, char *reference);
 
 /*      gridDefUUID: Define the UUID of an unstructured grid */
+#ifdef __cplusplus
+void    gridDefUUID(int gridID, const unsigned char *uuid);
+#else
 void    gridDefUUID(int gridID, const unsigned char uuid[CDI_UUID_SIZE]);
+#endif
 
 /*      gridInqUUID: Get the UUID of an unstructured grid */
+#ifdef __cplusplus
+void    gridInqUUID(int gridID, unsigned char *uuid);
+#else
 void    gridInqUUID(int gridID, unsigned char uuid[CDI_UUID_SIZE]);
-
+#endif
 
 /* Lambert Conformal Conic grid (GRIB version) */
 void gridDefLCC(int gridID, double originLon, double originLat, double lonParY, double lat1, double lat2, double xinc, double yinc, int projflag, int scanflag);
@@ -971,8 +1006,8 @@ void gridDefLaea(int gridID, double earth_radius, double lon_0, double lat_0);
 void gridInqLaea(int gridID, double *earth_radius, double *lon_0, double *lat_0);
 
 
-void    gridDefArea(int gridID, const double *area_vec);
-void    gridInqArea(int gridID, double *area_vec);
+void    gridDefArea(int gridID, const double area[]);
+void    gridInqArea(int gridID, double area[]);
 int     gridHasArea(int gridID);
 
 /*      gridDefNvertex: Define the number of vertex of a Gridbox */
@@ -982,19 +1017,19 @@ void    gridDefNvertex(int gridID, int nvertex);
 int     gridInqNvertex(int gridID);
 
 /*      gridDefXbounds: Define the bounds of a X-axis */
-void    gridDefXbounds(int gridID, const double *xbounds_vec);
+void    gridDefXbounds(int gridID, const double xbounds[]);
 
 /*      gridInqXbounds: Get the bounds of a X-axis */
-int     gridInqXbounds(int gridID, double *xbounds_vec);
+int     gridInqXbounds(int gridID, double xbounds[]);
 
 /*      gridDefYbounds: Define the bounds of a Y-axis */
-void    gridDefYbounds(int gridID, const double *ybounds_vec);
+void    gridDefYbounds(int gridID, const double ybounds[]);
 
 /*      gridInqYbounds: Get the bounds of a Y-axis */
-int     gridInqYbounds(int gridID, double *ybounds_vec);
+int     gridInqYbounds(int gridID, double ybounds[]);
 
-void    gridDefRowlon(int gridID, int nrowlon, const int* rowlon_vec);
-void    gridInqRowlon(int gridID, int *rowlon_vec);
+void    gridDefRowlon(int gridID, int nrowlon, const int rowlon[]);
+void    gridInqRowlon(int gridID, int rowlon[]);
 void    gridChangeType(int gridID, int gridtype);
 
 void    gridDefComplexPacking(int gridID, int lpack);
@@ -1024,10 +1059,10 @@ void    zaxisResize(int zaxisID, int size);
 void    zaxisPrint(int zaxisID, int index);
 
 /*      zaxisDefLevels: Define the levels of a Z-axis */
-void    zaxisDefLevels(int zaxisID, const double *levels_vec);
+void    zaxisDefLevels(int zaxisID, const double levels[]);
 
 /*      zaxisInqLevels: Get all levels of a Z-axis */
-void    zaxisInqLevels(int zaxisID, double *levels_vec);
+void    zaxisInqLevels(int zaxisID, double levels[]);
 
 /*      zaxisDefLevel: Define one level of a Z-axis */
 void    zaxisDefLevel(int zaxisID, int levelID, double levels);
@@ -1054,19 +1089,19 @@ void    zaxisDefUUID(int zaxisID, const unsigned char uuid[CDI_UUID_SIZE]);
 void    zaxisInqUUID(int zaxisID, unsigned char uuid[CDI_UUID_SIZE]);
 
 /*      zaxisDefName: Define the name of a Z-axis */
-void    zaxisDefName(int zaxisID, const char *name);
+void    zaxisDefName(int zaxisID, const char *name_optional);
 
 /*      zaxisInqName: Get the name of a Z-axis */
 void    zaxisInqName(int zaxisID, char *name);
 
 /*      zaxisDefLongname: Define the longname of a Z-axis */
-void    zaxisDefLongname(int zaxisID, const char *longname);
+void    zaxisDefLongname(int zaxisID, const char *longname_optional);
 
 /*      zaxisInqLongname: Get the longname of a Z-axis */
 void    zaxisInqLongname(int zaxisID, char *longname);
 
 /*      zaxisDefUnits: Define the units of a Z-axis */
-void    zaxisDefUnits(int zaxisID, const char *units);
+void    zaxisDefUnits(int zaxisID, const char *units_optional);
 
 /*      zaxisInqUnits: Get the units of a Z-axis */
 void    zaxisInqUnits(int zaxisID, char *units);
@@ -1074,28 +1109,37 @@ void    zaxisInqUnits(int zaxisID, char *units);
 /*      zaxisInqStdname: Get the standard name of a Z-axis */
 void    zaxisInqStdname(int zaxisID, char *stdname);
 
+/*      zaxisDefPsName: Define the name of the surface pressure variable of a hybrid sigma pressure Z-axis */
+void    zaxisDefPsName(int zaxisID, const char *psname_optional);
+
+/*      zaxisInqPsName: Get the name of the surface pressure variable of a hybrid sigma pressure Z-axis */
+void    zaxisInqPsName(int zaxisID, char *psname);
+
 void    zaxisDefPrec(int zaxisID, int prec);
 int     zaxisInqPrec(int zaxisID);
 
 void    zaxisDefPositive(int zaxisID, int positive);
 int     zaxisInqPositive(int zaxisID);
 
+void    zaxisDefScalar(int zaxisID);
+int     zaxisInqScalar(int zaxisID);
+
 void    zaxisDefLtype(int zaxisID, int ltype);
 int     zaxisInqLtype(int zaxisID);
 
 const double *zaxisInqLevelsPtr(int zaxisID);
-void    zaxisDefVct(int zaxisID, int size, const double *vct_vec);
-void    zaxisInqVct(int zaxisID, double *vct_vec);
+void    zaxisDefVct(int zaxisID, int size, const double vct[]);
+void    zaxisInqVct(int zaxisID, double vct[]);
 int     zaxisInqVctSize(int zaxisID);
 const double *zaxisInqVctPtr(int zaxisID);
-void    zaxisDefLbounds(int zaxisID, const double *lbounds_vec);
-int     zaxisInqLbounds(int zaxisID, double *lbounds_vec);
+void    zaxisDefLbounds(int zaxisID, const double lbounds[]);
+int     zaxisInqLbounds(int zaxisID, double lbounds_optional[]);
 double  zaxisInqLbound(int zaxisID, int index);
-void    zaxisDefUbounds(int zaxisID, const double *ubounds_vec);
-int     zaxisInqUbounds(int zaxisID, double *ubounds_vec);
+void    zaxisDefUbounds(int zaxisID, const double ubounds[]);
+int     zaxisInqUbounds(int zaxisID, double ubounds_optional[]);
 double  zaxisInqUbound(int zaxisID, int index);
-void    zaxisDefWeights(int zaxisID, const double *weights_vec);
-int     zaxisInqWeights(int zaxisID, double *weights_vec);
+void    zaxisDefWeights(int zaxisID, const double weights[]);
+int     zaxisInqWeights(int zaxisID, double weights_optional[]);
 void    zaxisChangeType(int zaxisID, int zaxistype);
 
 /* TAXIS routines */
@@ -1181,7 +1225,7 @@ int     taxisInqType(int taxisID);
 
 int     taxisInqNumavg(int taxisID);
 
-const char* tunitNamePtr(int tunitID);
+const char *tunitNamePtr(int tunitID);
 
 
 /* Institut routines */
@@ -1192,25 +1236,29 @@ int     institutInqNumber(void);
 int     institutInqCenter(int instID);
 int     institutInqSubcenter(int instID);
 const char *institutInqNamePtr(int instID);
-const char* institutInqLongnamePtr(int instID);
+const char *institutInqLongnamePtr(int instID);
 
 /* Model routines */
 
 int     modelDef(int instID, int modelgribID, const char *name);
-int     modelInq(int instID, int modelgribID, char *name);
-int     modelInqInstitut(int modelID);
+int     modelInq(int instID, int modelgribID, const char *name);
+int     modelInqInstitut(int modelID) ;
 int     modelInqGribID(int modelID);
 const char *modelInqNamePtr(int modelID);
 
 /* Table routines */
 
+/*      tableWriteC: write table of parameters to file in C language format */
 void    tableWriteC(const char *filename, int tableID);
+/*      tableFWriteC: write table of parameters to FILE* in C language format */
 void    tableFWriteC(FILE *ptfp, int tableID);
+/*      tableWrite: write table of parameters to file in tabular format */
 void    tableWrite(const char *filename, int tableID);
+/*      tableRead: read table of parameters from file in tabular format */
 int     tableRead(const char *tablefile);
 int     tableDef(int modelID, int tablenum, const char *tablename);
 
-const char* tableInqNamePtr(int tableID);
+const char *tableInqNamePtr(int tableID);
 void    tableDefEntry(int tableID, int code, const char *name, const char *longname, const char *units);
 
 int     tableInq(int modelID, int tablenum, const char *tablename);
@@ -1236,9 +1284,46 @@ void    streamDefHistory(int streamID, int size, const char *history);
 int     streamInqHistorySize(int streamID);
 void    streamInqHistoryString(int streamID, char *history);
 
+/* Subtype routines */
+
+/*      subtypeCreate: Create a variable subtype */
+int     subtypeCreate(int subtype);
+
+/*      Gives a textual summary of the variable subtype */
+void    subtypePrint(int subtypeID);
+
+/* Compares two subtype data structures. */
+int     subtypeCompare(int subtypeID1, int subtypeID2);
+
+/*      subtypeInqSize: Get the size of a subtype (e.g. no. of tiles). */
+int     subtypeInqSize(int subtypeID);
+
+/*      subtypeInqActiveIndex: Get the currently active index of a subtype (e.g. current tile index). */
+int     subtypeInqActiveIndex(int subtypeID);
+
+/*      subtypeDefActiveIndex: Set the currently active index of a subtype (e.g. current tile index). */
+void    subtypeDefActiveIndex(int subtypeID, int index);
+
+/*      Generate a "query object" out of a key-value pair. */
+subtype_query_t keyValuePair(const char *key, int value);
+
+/*       Generate an AND-combined "query object" out of two previous
+         query objects. */
+subtype_query_t matchAND(subtype_query_t q1, subtype_query_t q2);
+
+/*      subtypeInqSubEntry: Returns subtype entry ID for a given criterion. */
+int     subtypeInqSubEntry(int subtypeID, subtype_query_t criterion);
+
+/*      subtypeInqTile: Specialized version of subtypeInqSubEntry looking for tile/attribute pair. */
+int     subtypeInqTile(int subtypeID, int tileindex, int attribute);
+
+/*      vlistInqVarSubtype: Return subtype ID for a given variable. */
+int     vlistInqVarSubtype(int vlistID, int varID);
+
 
 void gribapiLibraryVersion(int *major_version, int *minor_version, int *revision_version);
 
+
 /*
 #if defined (__cplusplus)
 }
@@ -1320,6 +1405,7 @@ void basetimeInit(basetime_t *basetime)
  * require-trailing-newline: t
  * End:
  */
+ 
 #ifndef _FILE_H
 #define _FILE_H
 
@@ -1452,11 +1538,24 @@ void swap8byte(void *ptr, size_t size);
 #ifndef _BINARY_H
 #define _BINARY_H
 
+#ifdef HAVE_CONFIG_H
+#endif
+
+#include <inttypes.h>
 #include <stdio.h>
 
 #ifndef _DTYPES_H
 #endif
 
+#ifndef HOST_ENDIANNESS
+#ifdef __cplusplus
+static const uint32_t HOST_ENDIANNESS_temp[1] = { UINT32_C(0x00030201) };
+#define HOST_ENDIANNESS (((const unsigned char *)HOST_ENDIANNESS_temp)[0])
+#else
+#define HOST_ENDIANNESS (((const unsigned char *)&(const uint32_t[1]){UINT32_C(0x00030201)})[0])
+#endif
+#endif
+
 
 UINT32 get_UINT32(unsigned char *x);
 UINT32 get_SUINT32(unsigned char *x);
@@ -1492,61 +1591,71 @@ int binWriteFlt64(int fileID, int byteswap, size_t size, FLT64 *ptr);
 #if defined (HAVE_CONFIG_H)
 #endif
 
+#include <inttypes.h>
 
 
-#undef  IsBigendian
-#define IsBigendian()  ( u_byteorder.c[sizeof(long) - 1] )
-
 
 UINT32 get_UINT32(unsigned char *x)
 {
-  /* IsBigendian returns 1 for big endian byte order */
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
-
-  if ( IsBigendian() )
-    return((UINT32)(((UINT32)x[0]<<24)+((UINT32)x[1]<<16)+((UINT32)x[2]<< 8)+ (UINT32)x[3]));
-  else
-    return((UINT32)(((UINT32)x[3]<<24)+((UINT32)x[2]<<16)+((UINT32)x[1]<< 8)+ (UINT32)x[0]));
+  switch (HOST_ENDIANNESS)
+    {
+    case CDI_BIGENDIAN:
+      return((UINT32)(((UINT32)x[0]<<24)+((UINT32)x[1]<<16)+((UINT32)x[2]<< 8)+ (UINT32)x[3]));
+    case CDI_LITTLEENDIAN:
+      return ((UINT32)(((UINT32)x[3]<<24)+((UINT32)x[2]<<16)+((UINT32)x[1]<< 8)+ (UINT32)x[0]));
+    default:
+      Error("unhandled endianness %d", HOST_ENDIANNESS);
+      return UINT32_C(0xFFFFFFFF);
+    }
 }
 
 
 UINT32 get_SUINT32(unsigned char *x)
 {
-  /* IsBigendian returns 1 for big endian byte order */
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
-
-  if ( IsBigendian() )
-    return((UINT32)(((UINT32)x[3]<<24)+((UINT32)x[2]<<16)+((UINT32)x[1]<< 8)+ (UINT32)x[0]));
-  else
-    return((UINT32)(((UINT32)x[0]<<24)+((UINT32)x[1]<<16)+((UINT32)x[2]<< 8)+ (UINT32)x[3]));
+  switch (HOST_ENDIANNESS)
+    {
+    case CDI_BIGENDIAN:
+      return((UINT32)(((UINT32)x[3]<<24)+((UINT32)x[2]<<16)+((UINT32)x[1]<< 8)+ (UINT32)x[0]));
+    case CDI_LITTLEENDIAN:
+      return((UINT32)(((UINT32)x[0]<<24)+((UINT32)x[1]<<16)+((UINT32)x[2]<< 8)+ (UINT32)x[3]));
+    default:
+      Error("unhandled endianness %d", HOST_ENDIANNESS);
+      return UINT32_C(0xFFFFFFFF);
+    }
 }
 
 
 UINT64 get_UINT64(unsigned char *x)
 {
-  /* IsBigendian returns 1 for big endian byte order */
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
-
-  if ( IsBigendian() )
-    return((UINT64)(((UINT64)x[0]<<56)+((UINT64)x[1]<<48)+((UINT64)x[2]<<40)+((UINT64)x[3]<<32)+
-		    ((UINT64)x[4]<<24)+((UINT64)x[5]<<16)+((UINT64)x[6]<< 8)+ (UINT64)x[7]));
-  else
-    return((UINT64)(((UINT64)x[7]<<56)+((UINT64)x[6]<<48)+((UINT64)x[5]<<40)+((UINT64)x[4]<<32)+
-		    ((UINT64)x[3]<<24)+((UINT64)x[2]<<16)+((UINT64)x[1]<< 8)+ (UINT64)x[0]));
+  switch (HOST_ENDIANNESS)
+    {
+    case CDI_BIGENDIAN:
+      return((UINT64)(((UINT64)x[0]<<56)+((UINT64)x[1]<<48)+((UINT64)x[2]<<40)+((UINT64)x[3]<<32)+
+                      ((UINT64)x[4]<<24)+((UINT64)x[5]<<16)+((UINT64)x[6]<< 8)+ (UINT64)x[7]));
+    case CDI_LITTLEENDIAN:
+      return((UINT64)(((UINT64)x[7]<<56)+((UINT64)x[6]<<48)+((UINT64)x[5]<<40)+((UINT64)x[4]<<32)+
+                      ((UINT64)x[3]<<24)+((UINT64)x[2]<<16)+((UINT64)x[1]<< 8)+ (UINT64)x[0]));
+    default:
+      Error("unhandled endianness %d", HOST_ENDIANNESS);
+      return UINT64_C(0xFFFFFFFFFFFFFFFF);
+    }
 }
 
 
 UINT64 get_SUINT64(unsigned char *x)
 {
-  /* IsBigendian returns 1 for big endian byte order */
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
-
-  if ( IsBigendian() )
-    return((UINT64)(((UINT64)x[7]<<56)+((UINT64)x[6]<<48)+((UINT64)x[5]<<40)+((UINT64)x[4]<<32)+
-		    ((UINT64)x[3]<<24)+((UINT64)x[2]<<16)+((UINT64)x[1]<< 8)+ (UINT64)x[0]));
-  else
-    return((UINT64)(((UINT64)x[0]<<56)+((UINT64)x[1]<<48)+((UINT64)x[2]<<40)+((UINT64)x[3]<<32)+
-		    ((UINT64)x[4]<<24)+((UINT64)x[5]<<16)+((UINT64)x[6]<< 8)+ (UINT64)x[7]));
+  switch (HOST_ENDIANNESS)
+    {
+    case CDI_BIGENDIAN:
+      return((UINT64)(((UINT64)x[7]<<56)+((UINT64)x[6]<<48)+((UINT64)x[5]<<40)+((UINT64)x[4]<<32)+
+                      ((UINT64)x[3]<<24)+((UINT64)x[2]<<16)+((UINT64)x[1]<< 8)+ (UINT64)x[0]));
+    case CDI_LITTLEENDIAN:
+      return((UINT64)(((UINT64)x[0]<<56)+((UINT64)x[1]<<48)+((UINT64)x[2]<<40)+((UINT64)x[3]<<32)+
+                      ((UINT64)x[4]<<24)+((UINT64)x[5]<<16)+((UINT64)x[6]<< 8)+ (UINT64)x[7]));
+    default:
+      Error("unhandled endianness %d", HOST_ENDIANNESS);
+      return UINT64_C(0xFFFFFFFFFFFFFFFF);
+    }
 }
 
 
@@ -1569,11 +1678,11 @@ size_t binReadF77Block(int fileID, int byteswap)
 
 void binWriteF77Block(int fileID, int byteswap, size_t blocksize)
 {
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
   unsigned char f77block[4];
 
-  if ( IsBigendian() )
+  switch (HOST_ENDIANNESS)
     {
+    case CDI_BIGENDIAN:
       if ( byteswap )
 	{
 	  f77block[0] = (unsigned char) (blocksize);
@@ -1588,9 +1697,8 @@ void binWriteF77Block(int fileID, int byteswap, size_t blocksize)
 	  f77block[1] = (unsigned char) (blocksize >> 16);
 	  f77block[0] = (unsigned char) (blocksize >> 24);
 	}
-    }
-  else
-    {
+      break;
+    case CDI_LITTLEENDIAN:
       if ( byteswap )
 	{
 	  f77block[3] = (unsigned char) (blocksize);
@@ -1605,6 +1713,9 @@ void binWriteF77Block(int fileID, int byteswap, size_t blocksize)
 	  f77block[2] = (unsigned char) (blocksize >> 16);
 	  f77block[3] = (unsigned char) (blocksize >> 24);
 	}
+      break;
+    default:
+      Error("unhandled endianness %d", HOST_ENDIANNESS);
     }
 
   if ( fileWrite(fileID, f77block, 4) != 4 )
@@ -1747,6 +1858,29 @@ int binWriteFlt64(int fileID, int byteswap, size_t size, FLT64 *ptr)
  * require-trailing-newline: t
  * End:
  */
+#ifndef _CALENDAR_H
+#define _CALENDAR_H
+
+void encode_caldaysec(int calendar, int year, int month, int day, int hour, int minute, int second,
+		      int *julday, int *secofday);
+void decode_caldaysec(int calendar, int julday, int secofday, 
+		      int *year, int *month, int *day, int *hour, int *minute, int *second);
+
+int calendar_dpy(int calendar);
+int days_per_year(int calendar, int year);
+int days_per_month(int calendar, int year, int month);
+
+
+#endif  /* _CALENDAR_H */
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #ifndef  _TIMEBASE_H
 #define  _TIMEBASE_H
 
@@ -1772,6 +1906,16 @@ void encode_juldaysec(int calendar, int year, int month, int day, int hour, int
 void decode_juldaysec(int calendar, int julday, int secofday, int *year, int *month, int *day, int *hour, int *minute, int *second);
 
 #endif  /* _TIMEBASE_H */
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #include <limits.h>
 #include <stdio.h>
 
@@ -1899,79 +2043,79 @@ static int encode_day(int dpy, int year, int month, int day)
 }
 
 
-int date_to_calday(int calendar, int date)
+void encode_caldaysec(int calendar, int year, int month, int day, int hour, int minute, int second,
+		      int *julday, int *secofday)
 {
-  int calday;
   int dpy;
-  int year, month, day;
 
   dpy = calendar_dpy(calendar);
 
-  cdiDecodeDate(date, &year, &month, &day);
-
   if ( dpy == 360 || dpy == 365 || dpy == 366 )
-    calday = encode_day(dpy, year, month, day);
+    *julday = encode_day(dpy, year, month, day);
   else
-    calday = encode_julday(calendar, year, month, day);
+    *julday = encode_julday(calendar, year, month, day);
 
-  return (calday);
+  *secofday = hour*3600 + minute*60 + second;
 }
 
 
-int calday_to_date(int calendar, int calday)
+void decode_caldaysec(int calendar, int julday, int secofday, 
+		      int *year, int *month, int *day, int *hour, int *minute, int *second)
 {
-  int date;
   int dpy;
-  int year, month, day;
 
   dpy = calendar_dpy(calendar);
 
   if ( dpy == 360 || dpy == 365 || dpy == 366 )
-    decode_day(dpy, calday, &year, &month, &day);
+    decode_day(dpy, julday, year, month, day);
   else
-    decode_julday(calendar, calday, &year, &month, &day);
-
-  date = cdiEncodeDate(year, month, day);
+    decode_julday(calendar, julday, year, month, day);
 
-  return (date);
+  *hour   = secofday/3600;
+  *minute = secofday/60 - *hour*60;
+  *second = secofday - *hour*3600 - *minute*60;
 }
 
 
-void encode_caldaysec(int calendar, int year, int month, int day, int hour, int minute, int second,
-		      int *julday, int *secofday)
+#ifdef TEST
+static int date_to_calday(int calendar, int date)
 {
+  int calday;
   int dpy;
+  int year, month, day;
 
   dpy = calendar_dpy(calendar);
 
+  cdiDecodeDate(date, &year, &month, &day);
+
   if ( dpy == 360 || dpy == 365 || dpy == 366 )
-    *julday = encode_day(dpy, year, month, day);
+    calday = encode_day(dpy, year, month, day);
   else
-    *julday = encode_julday(calendar, year, month, day);
+    calday = encode_julday(calendar, year, month, day);
 
-  *secofday = hour*3600 + minute*60 + second;
+  return (calday);
 }
 
 
-void decode_caldaysec(int calendar, int julday, int secofday, 
-		      int *year, int *month, int *day, int *hour, int *minute, int *second)
+static int calday_to_date(int calendar, int calday)
 {
+  int date;
   int dpy;
+  int year, month, day;
 
   dpy = calendar_dpy(calendar);
 
   if ( dpy == 360 || dpy == 365 || dpy == 366 )
-    decode_day(dpy, julday, year, month, day);
+    decode_day(dpy, calday, &year, &month, &day);
   else
-    decode_julday(calendar, julday, year, month, day);
+    decode_julday(calendar, calday, &year, &month, &day);
 
-  *hour   = secofday/3600;
-  *minute = secofday/60 - *hour*60;
-  *second = secofday - *hour*3600 - *minute*60;
+  date = cdiEncodeDate(year, month, day);
+
+  return (date);
 }
 
 
-#ifdef TEST
 int main(void)
 {
   int calendar = CALENDAR_STANDARD;
@@ -2113,6 +2257,8 @@ int main(void)
 
 void cdfDebug(int debug);
 
+extern int CDF_Debug;
+
 const char *cdfLibraryVersion(void);
 const char *hdfLibraryVersion(void);
 
@@ -2194,8 +2340,7 @@ unsigned reshCountType(const resOps *resTypeOps);
 void * reshGetValue(const char* caller, const char* expressionString, cdiResH id, const resOps* ops);
 #define reshGetVal(resH, ops)  reshGetValue(__func__, #resH, resH, ops)
 
-
-void reshGetResHListOfType(unsigned numIDs, int IDs[numIDs], const resOps *ops);
+void reshGetResHListOfType(unsigned numIDs, int IDs[], const resOps *ops);
 
 enum cdiApplyRet {
   CDI_APPLY_ERROR = -1,
@@ -2211,7 +2356,7 @@ cdiResHFilterApply(const resOps *p,
                                             void *data),
                    void *data);
 
-void   reshPackBufferCreate ( char **, int *, void *context );
+int reshPackBufferCreate(char **packBuf, int *packBufSize, void *context);
 void   reshPackBufferDestroy ( char ** );
 int    reshResourceGetPackSize_intern(int resh, const resOps *ops, void *context, const char* caller, const char* expressionString);
 #define reshResourceGetPackSize(resh, ops, context) reshResourceGetPackSize_intern(resh, ops, context, __func__, #resh)
@@ -2253,7 +2398,8 @@ typedef struct {
   /* Date format  YYYYMMDD */
   /* Time format    hhmmss */
   int     self;
-  int     used;
+  short   used;
+  short   has_bounds;
   int     type;           // time type
   int     vdate;          // verification date
   int     vtime;          // verification time
@@ -2265,7 +2411,6 @@ typedef struct {
   int     unit;           // time unit
   int     numavg;
   int     climatology;
-  int     has_bounds;
   int     vdate_lb;       // lower bounds of vdate
   int     vtime_lb;       // lower bounds of vtime
   int     vdate_ub;       // upper bounds of vdate
@@ -2310,9 +2455,10 @@ taxisUnpack(char *unpackBuffer, int unpackBufferSize, int *unpackBufferPos,
 #ifndef _CDI_LIMITS_H
 #define _CDI_LIMITS_H
 
-#define  MAX_GRIDS_PS    128  /* maximum number of different grids per stream */
-#define  MAX_ZAXES_PS    128  /* maximum number of different zaxes per stream */
-#define  MAX_ATTRIBUTES  256  /* maximum number of attributes per variable    */
+#define  MAX_GRIDS_PS    128  /* maximum number of different grids per stream    */
+#define  MAX_ZAXES_PS    128  /* maximum number of different zaxes per stream    */
+#define  MAX_ATTRIBUTES  256  /* maximum number of attributes per variable       */
+#define  MAX_SUBTYPES_PS 128  /* maximum number of different subtypes per stream */
 
 #endif  /* _CDI_LIMITS_H */
 /*
@@ -2347,19 +2493,19 @@ void srvDebug(int debug);
 
 int  srvCheckFiletype(int fileID, int *swap);
 
-srvrec_t *srvNew(void);
-void srvDelete(srvrec_t *srvp);
+void *srvNew(void);
+void srvDelete(void *srv);
 
-int  srvRead(int fileID, srvrec_t *srvp);
-void srvWrite(int fileID, srvrec_t *srvp);
+int  srvRead(int fileID, void *srv);
+void srvWrite(int fileID, void *srv);
 
-int  srvInqHeader(srvrec_t *srvp, int *header);
-int  srvInqDataSP(srvrec_t *srvp, float *data);
-int  srvInqDataDP(srvrec_t *srvp, double *data);
+int  srvInqHeader(void *srv, int *header);
+int  srvInqDataSP(void *srv, float *data);
+int  srvInqDataDP(void *srv, double *data);
 
-int  srvDefHeader(srvrec_t *srvp, const int *header);
-int  srvDefDataSP(srvrec_t *srvp, const float *data);
-int  srvDefDataDP(srvrec_t *srvp, const double *data);
+int  srvDefHeader(void *srv, const int *header);
+int  srvDefDataSP(void *srv, const float *data);
+int  srvDefDataDP(void *srv, const double *data);
 
 
 #endif  /* _SERVICE_H */
@@ -2482,8 +2628,8 @@ typedef struct {
   int    checked;
   int    byteswap;
   int    dprec;      /* data   precision */
-  double refval;
   int    ipdb[37];
+  double refval;
   int    igdb[22];
   double vct[100];
   size_t datasize;
@@ -2498,23 +2644,21 @@ const char *iegLibraryVersion(void);
 void iegDebug(int debug);
 int  iegCheckFiletype(int fileID, int *swap);
 
-iegrec_t *iegNew(void);
-void iegDelete(iegrec_t *iegp);
-void iegInit(iegrec_t *iegp);
-void iegInitMem(iegrec_t *iegp);
+void *iegNew(void);
+void iegDelete(void *ieg);
+void iegInitMem(void *ieg);
 
-int  iegRead(int fileID, iegrec_t *iegp);
-int  iegWrite(int fileID, iegrec_t *iegp);
+int  iegRead(int fileID, void *ieg);
+int  iegWrite(int fileID, void *ieg);
 
-void iegCopyMeta(iegrec_t *diegp, iegrec_t *siegp);
-int  iegInqHeader(iegrec_t *iegp, int *header);
-int  iegInqDataSP(iegrec_t *iegp, float *data);
-int  iegInqDataDP(iegrec_t *iegp, double *data);
-
-int  iegDefHeader(iegrec_t *iegp, const int *header);
-int  iegDefDataSP(iegrec_t *iegp, const float *data);
-int  iegDefDataDP(iegrec_t *iegp, const double *data);
+void iegCopyMeta(void *dieg, void *sieg);
+int  iegInqHeader(void *ieg, int *header);
+int  iegInqDataSP(void *ieg, float *data);
+int  iegInqDataDP(void *ieg, double *data);
 
+int  iegDefHeader(void *ieg, const int *header);
+int  iegDefDataSP(void *ieg, const float *data);
+int  iegDefDataDP(void *ieg, const double *data);
 
 #endif  /* _IEG_H */
 /*
@@ -2540,8 +2684,11 @@ int  iegDefDataDP(iegrec_t *iegp, const double *data);
 #include <math.h>
 #include <sys/types.h>
 
+
 /* dummy use of unused parameters to silence compiler warnings */
+#ifndef UNUSED
 #define  UNUSED(x) (void)x
+#endif
 
 #ifndef strdupx
 #ifndef strdup
@@ -2553,7 +2700,7 @@ char *strdup(const char *s);
 ({					      	  \
    const char *__old = (s);			  \
    size_t __len = strlen(__old) + 1;		  \
-   char *__new = (char *) malloc(__len);	  \
+   char *__new = (char *) Malloc(__len);	  \
    (char *) memcpy(__new, __old, __len);	  \
 })
 */
@@ -2612,7 +2759,6 @@ char *strdup(const char *s);
 #  define IS_EQUAL(x,y)     (!IS_NOT_EQUAL(x,y))
 #endif
 
-
 #define  FALSE  0
 #define  TRUE   1
 
@@ -2644,6 +2790,18 @@ typedef struct
 }
 Record;
 
+/* data structure specifying tile-related meta-data. structure
+ * contains "-1" if this is no tile-variable. */
+typedef struct {
+  int
+    tileindex,
+    totalno_of_tileattr_pairs,
+    tileClassification,
+    numberOfTiles,
+    numberOfAttributes,
+    attribute;
+} var_tile_t;
+
 
 typedef struct
 {
@@ -2659,14 +2817,15 @@ typedef struct
   short     varID;
   short     levelID;
   char      varname[32]; /* needed for grib decoding with GRIB_API */
+  var_tile_t tiles;      /* tile-related meta-data, currently for GRIB-API only. */
 }
 record_t;
 
 
 typedef struct {
   record_t *records;
-  int       recordSize;  /* number of allocated records           */
   int      *recIDs;      /* IDs of non constant records           */
+  int       recordSize;  /* number of allocated records           */
   int       nrecs;       /* number of used records                */
                          /* tsID=0 nallrecs                       */
                          /* tsID>0 number of non constant records */
@@ -2680,16 +2839,24 @@ tsteps_t;
 
 
 typedef struct {
-  int       ncvarid;
   int       nlevs;
-  int      *level;       /* record IDs */
-  int      *lindex;      /* level index */
-  int       defmiss;     /* TRUE if missval is defined in file */
+  int       subtypeIndex; /* corresponding tile in subtype_t structure (subtype->self) */
+  int      *recordID;     /* record IDs: [nlevs] */
+  int      *lindex;       /* level index */
+} sleveltable_t;
 
-  int       isUsed;
-  int       gridID;
-  int       zaxisID;
-  int       tsteptype;   /* TSTEP_* */
+
+typedef struct {
+  int            ncvarid;
+  int            subtypeSize;
+  sleveltable_t *recordTable; /* record IDs for each subtype */
+  int            defmiss;     /* TRUE if missval is defined in file */
+
+  int            isUsed;
+  int            gridID;
+  int            zaxisID;
+  int            tsteptype;   /* TSTEP_* */
+  int            subtypeID;   /* subtype ID, e.g. for tile-related meta-data (currently for GRIB-API only). */
 }
 svarinfo_t;
 
@@ -2711,12 +2878,12 @@ typedef struct {
   int         byteorder;
   int         fileID;
   int         filemode;
+  int         nrecs;        /* number of records                  */
   off_t       numvals;
   char       *filename;
   Record     *record;
-  int         nrecs;        /* number of records                  */
-  int         nvars;        /* number of variables                */
   svarinfo_t *vars;
+  int         nvars;        /* number of variables                */
   int         varsAllocated;
   int         curTsID;      /* current timestep ID */
   int         rtsteps;      /* number of tsteps accessed       */
@@ -2730,6 +2897,7 @@ typedef struct {
   int         xdimID[MAX_GRIDS_PS];	//Warning: synchronous array to vlist_to_pointer(vlistID)->gridIDs
   int         ydimID[MAX_GRIDS_PS];	//Warning: synchronous array to vlist_to_pointer(vlistID)->gridIDs
   int         zaxisID[MAX_ZAXES_PS];	//Warning: synchronous array to vlist_to_pointer(vlistID)->zaxisIDs
+  int         nczvarID[MAX_ZAXES_PS];
   int         ncxvarID[MAX_GRIDS_PS];
   int         ncyvarID[MAX_GRIDS_PS];
   int         ncavarID[MAX_GRIDS_PS];
@@ -2747,25 +2915,46 @@ typedef struct {
 #else
   void       *gribContainers;
 #endif
-  int         vlistIDorig;
-  /* only used by MPI-parallelized version of library */
-  int       ownerRank;    // MPI rank of owner process
-  /* ---------------------------------- */
-  /* Local change: 2013-02-18, FP (DWD) */
-  /* ---------------------------------- */
 
   void *gh; // grib handle
 }
 stream_t;
 
 
+/* Length of optional keyword/value pair list */
+#define MAX_OPT_GRIB_ENTRIES 500
+
+enum cdi_convention {CDI_CONVENTION_ECHAM, CDI_CONVENTION_CF};
+
+/* Data type specification for optional key/value pairs (GRIB) */
+typedef enum {
+  t_double = 0,
+  t_int    = 1
+} key_val_pair_datatype;
+
+/* Data structure holding optional key/value pairs for GRIB */
+typedef struct
+{
+  char*                  keyword;        /* keyword string */
+  int                    update;
+  key_val_pair_datatype  data_type;      /* data type of this key/value pair */
+  double                 dbl_val;        /* double value (data_type == t_double) */
+  int                    int_val;        /* integer value (data_type == t_int) */
+  int                    subtype_index;  /* tile index for this key-value pair */
+} opt_key_val_pair_t;
+
+
+
+
 extern int CDI_Debug;      /* If set to 1, debuggig (default 0)            */
+extern int CDI_Recopt;
 extern int cdiGribApiDebug;
 extern double cdiDefaultMissval;
 extern int cdiDefaultInstID;
 extern int cdiDefaultModelID;
 extern int cdiDefaultTableID;
 extern int cdiDefaultLeveltype;
+extern int cdiDefaultCalendar;
 //extern int cdiNcMissingValue;
 extern int cdiNcChunksizehint;
 extern int cdiChunkType;
@@ -2773,6 +2962,14 @@ extern int cdiSplitLtype105;
 extern int cdiDataUnreduced;
 extern int cdiSortName;
 extern int cdiHaveMissval;
+extern int cdiIgnoreAttCoordinates;
+extern int cdiIgnoreValidRange;
+extern int cdiSkipRecords;
+extern int cdiConvention;
+extern int cdiInventoryMode;
+extern int CDI_Version_Info;
+extern int CDI_cmor_mode;
+extern size_t CDI_netcdf_hdr_pad;
 extern int STREAM_Debug;
 
 
@@ -2783,7 +2980,7 @@ extern const resOps streamOps;
 static inline stream_t *
 stream_to_pointer(int idx)
 {
-  return reshGetVal(idx, &streamOps);
+  return (stream_t *)reshGetVal(idx, &streamOps);
 }
 
 static inline void
@@ -2798,7 +2995,7 @@ int     streamInqFileID(int streamID);
 void    gridDefHasDims(int gridID, int hasdims);
 int     gridInqHasDims(int gridID);
 const char *gridNamePtr(int gridtype);
-char   *zaxisNamePtr(int leveltype);
+const char   *zaxisNamePtr(int leveltype);
 int     zaxisInqLevelID(int zaxisID, double level);
 
 void    streamCheckID(const char *caller, int streamID);
@@ -2807,8 +3004,10 @@ void    streamDefineTaxis(int streamID);
 
 int     streamsNewEntry(int filetype);
 void    streamsInitEntry(int streamID);
-void    cdiStreamSetupVlist(stream_t *streamptr, int vlistID, int vlistIDorig);
-int     stream_new_var(stream_t *streamptr, int gridID, int zaxisID);
+void    cdiStreamSetupVlist(stream_t *streamptr, int vlistID);
+/* default implementation of the overridable function */
+void    cdiStreamSetupVlist_(stream_t *streamptr, int vlistID);
+int     stream_new_var(stream_t *streamptr, int gridID, int zaxisID, int tilesetID);
 
 int     tstepsNewEntry(stream_t *streamptr);
 
@@ -2835,22 +3034,25 @@ int     cdiInqAccesstype(int streamID);
 
 int     getByteswap(int byteorder);
 
-void cdiStreamGetIndexList(unsigned numIDs, int IDs[numIDs]);
+void cdiStreamGetIndexList(unsigned numIDs, int IDs[]);
 
 
 void  cdiInitialize(void);
 
-void uuid2str(const unsigned char *uuid, char *uuidstr);
-int str2uuid(const char *uuidstr, unsigned char *uuid);
+void uuid2str(const unsigned char uuid[], char uuidstr[]);
+int str2uuid(const char *uuidstr, unsigned char uuid[]);
 
-static inline int cdiUUIDIsNull(const unsigned char uuid[CDI_UUID_SIZE])
+static inline int cdiUUIDIsNull(const unsigned char uuid[])
 {
-  static const unsigned char uuid_nil[CDI_UUID_SIZE];
-  return !memcmp(uuid, uuid_nil, CDI_UUID_SIZE);
+  int isNull = 1;
+  for (size_t i = 0; i < CDI_UUID_SIZE; ++i)
+    isNull &= (uuid[i] == 0);
+  return isNull;
 }
 
-char* cdiEscapeSpaces(const char* string);
-char* cdiUnescapeSpaces(const char* string, const char** outStringEnd);
+
+char *cdiEscapeSpaces(const char *string);
+char *cdiUnescapeSpaces(const char *string, const char **outStringEnd);
 
 #define CDI_UNIT_PA   1
 #define CDI_UNIT_HPA  2
@@ -2861,25 +3063,29 @@ char* cdiUnescapeSpaces(const char* string, const char** outStringEnd);
 
 struct streamAssoc
 {
-  int streamID, vlistID, vlistIDorig;
+  int streamID, vlistID;
 };
 
 struct streamAssoc
-streamUnpack(char * unpackBuffer, int unpackBufferSize,
-             int * unpackBufferPos, int originNamespace, void *context);
+streamUnpack(char *unpackBuffer, int unpackBufferSize,
+             int *unpackBufferPos, int originNamespace, void *context);
 
 int
-cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
+cdiStreamOpenDefaultDelegate(const char *filename, char filemode,
                              int filetype, stream_t *streamptr,
                              int recordBufIsToBeCreated);
 
+int
+streamOpenID(const char *filename, char filemode, int filetype,
+             int resH);
+
 void
 cdiStreamDefVlist_(int streamID, int vlistID);
 void
 cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
                    int nmiss);
 void
-cdiStreamwriteVarChunk_(int streamID, int varID, int memtype,
+cdiStreamWriteVarChunk_(int streamID, int varID, int memtype,
                         const int rect[][2], const void *data, int nmiss);
 void
 cdiStreamCloseDefaultDelegate(stream_t *streamptr,
@@ -2889,13 +3095,16 @@ int cdiStreamDefTimestep_(stream_t *streamptr, int tsID);
 
 void cdiStreamSync_(stream_t *streamptr);
 
-char *cdiUnitNamePtr(int cdi_unit);
+const char *cdiUnitNamePtr(int cdi_unit);
 
 void zaxisGetIndexList(int nzaxis, int *zaxisIndexList);
 
 void zaxisDefLtype2(int zaxisID, int ltype2);
 int  zaxisInqLtype2(int zaxisID);
 
+/* used by CDO */
+void cdiDefTableID(int tableID);
+
 #endif  /* _CDI_INT_H */
 /*
  * Local Variables:
@@ -2973,9 +3182,12 @@ void cdf_put_vara_double(int ncid, int varid, const size_t start[], const size_t
 
 void cdf_get_vara_float(int ncid, int varid, const size_t start[], const size_t count[], float *fp);
 void cdf_put_vara_float(int ncid, int varid, const size_t start[], const size_t count[], const float *fp);
+void  cdf_get_vara_int(int ncid, int varid, const size_t start[],
+                       const size_t count[], int *dp);
 
 void cdf_put_att_text(int ncid, int varid, const char *name, size_t len, const char *tp);
 void cdf_put_att_int(int ncid, int varid, const char *name, nc_type xtype, size_t len, const int *ip);
+void cdf_put_att_float(int ncid, int varid, const char *name, nc_type xtype, size_t len, const float *dp);
 void cdf_put_att_double(int ncid, int varid, const char *name, nc_type xtype, size_t len, const double *dp);
 
 void cdf_get_att_string(int ncid, int varid, const char *name, char **tp);
@@ -3089,11 +3301,10 @@ void cdfComment(int ncid)
     }
 
   cdf_put_att_text(ncid, NC_GLOBAL, "CDI", strlen(comment), comment);
-  cdf_put_att_text(ncid, NC_GLOBAL, "Conventions", 6, "CF-1.4");
 }
 #endif
 
-int cdfOpenFile(const char *filename, const char *mode, int *filetype)
+static int cdfOpenFile(const char *filename, const char *mode, int *filetype)
 {
   int ncid = -1;
 #if  defined  (HAVE_LIBNETCDF)
@@ -3132,7 +3343,8 @@ int cdfOpenFile(const char *filename, const char *mode, int *filetype)
 	  else if ( *filetype == FILETYPE_NC4C ) writemode |= NC_NETCDF4 | NC_CLASSIC_MODEL;
 #endif
 	  cdf_create(filename, writemode, &ncid);
-	  cdfComment(ncid);
+	  if ( CDI_Version_Info ) cdfComment(ncid);
+          cdf_put_att_text(ncid, NC_GLOBAL, "Conventions", 6, "CF-1.4");
 	  break;
 	case 'a':
 	  cdf_open(filename, NC_WRITE, &ncid);
@@ -3223,7 +3435,7 @@ int cdf4Open(const char *filename, const char *mode, int *filetype)
 }
 
 
-void cdfCloseFile(int fileID)
+static void cdfCloseFile(int fileID)
 {
 #if  defined  (HAVE_LIBNETCDF)
   cdf_close(fileID);
@@ -3250,13 +3462,6 @@ void cdfClose(int fileID)
 #endif
 
 
-typedef enum {
-  STAGE_DEFINITION = 0,
-  STAGE_TIMELOOP   = 1,
-  STAGE_CLEANUP    = 2,
-  STAGE_UNUSED     = 3,
-} statusCode;
-
 typedef struct {
   int idx;
   int nsp;
@@ -3275,6 +3480,7 @@ enum namespaceSwitch
   NSSWITCH_FILE_CLOSE,
   NSSWITCH_STREAM_OPEN_BACKEND,
   NSSWITCH_STREAM_DEF_VLIST_,
+  NSSWITCH_STREAM_SETUP_VLIST,
   NSSWITCH_STREAM_WRITE_VAR_,
   NSSWITCH_STREAM_WRITE_VAR_CHUNK_,
   NSSWITCH_STREAM_WRITE_VAR_PART_,
@@ -3300,19 +3506,17 @@ union namespaceSwitchValue
 #define NSSW_FUNC(p) ((union namespaceSwitchValue){ .func = (void (*)())(p) })
 #define NSSW_DATA(p) ((union namespaceSwitchValue){ .data = (void *)(p) })
 
-int              namespaceNew();
-void             namespaceDelete(int namespaceID);
+//int              namespaceNew();
+//void             namespaceDelete(int namespaceID);
 void             namespaceCleanup      ( void );
 int              namespaceGetNumber    ( void );
-void namespaceSetActive(int namespaceID);
+//void             namespaceSetActive(int namespaceID);
 int              namespaceGetActive    ( void );
 int              namespaceIdxEncode    ( namespaceTuple_t );
 int              namespaceIdxEncode2   ( int, int );
 namespaceTuple_t namespaceResHDecode   ( int );
 int              namespaceAdaptKey     ( int originResH, int originNamespace);
 int              namespaceAdaptKey2    ( int );
-void             namespaceDefResStatus ( statusCode );
-statusCode       namespaceInqResStatus ( void );
 void namespaceSwitchSet(enum namespaceSwitch sw,
                         union namespaceSwitchValue value);
 union namespaceSwitchValue namespaceSwitchGet(enum namespaceSwitch sw);
@@ -3337,8 +3541,6 @@ union namespaceSwitchValue namespaceSwitchGet(enum namespaceSwitch sw);
 #include <string.h>
 
 
-extern int CDF_Debug;
-
 #if  defined  (HAVE_LIBNETCDF)
 /*
 #if ! defined (MIN_BUF_SIZE)
@@ -3349,7 +3551,6 @@ static size_t ChunkSizeMin = MIN_BUF_SIZE;
 */
 void cdf_create(const char *path, int cmode, int *ncidp)
 {
-  int status;
   int oldfill;
   size_t initialsz = 0, chunksizehint = 0;
   /*
@@ -3384,7 +3585,7 @@ void cdf_create(const char *path, int cmode, int *ncidp)
 
   cdi_nc__create_funcp my_nc__create =
     (cdi_nc__create_funcp)namespaceSwitchGet(NSSWITCH_NC__CREATE).func;
-  status = my_nc__create(path, cmode, initialsz, &chunksizehint, ncidp);
+  int status = my_nc__create(path, cmode, initialsz, &chunksizehint, ncidp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d  mode = %d  file = %s", *ncidp, cmode, path);
@@ -3439,15 +3640,13 @@ int cdf_open(const char *path, int omode, int *ncidp)
 
   if ( CDF_Debug && status != NC_NOERR ) Message("%s", nc_strerror(status));
 
-  return (status);
+  return status;
 }
 
 
 void cdf_close(int ncid)
 {
-  int status;
-
-  status = nc_close(ncid);
+  int status = nc_close(ncid);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -3455,9 +3654,7 @@ void cdf_close(int ncid)
 
 void cdf_redef(int ncid)
 {
-  int status;
-
-  status = nc_redef(ncid);
+  int status = nc_redef(ncid);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -3465,9 +3662,7 @@ void cdf_redef(int ncid)
 
 void cdf_enddef(int ncid)
 {
-  int status;
-
-  status = nc_enddef(ncid);
+  int status = nc_enddef(ncid);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -3475,13 +3670,12 @@ void cdf_enddef(int ncid)
 
 void cdf__enddef(const int ncid, const size_t hdr_pad)
 {
-  int status;
   const size_t v_align   = 4UL; /* [B] Alignment of beginning of data section for fixed variables */
   const size_t v_minfree = 0UL; /* [B] Pad at end of data section for fixed size variables */
   const size_t r_align   = 4UL; /* [B] Alignment of beginning of data section for record variables */
 
   /* nc_enddef(ncid) is equivalent to nc__enddef(ncid, 0, 4, 0, 4) */
-  status = nc__enddef(ncid, hdr_pad, v_align, v_minfree, r_align);
+  int status = nc__enddef(ncid, hdr_pad, v_align, v_minfree, r_align);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -3489,9 +3683,7 @@ void cdf__enddef(const int ncid, const size_t hdr_pad)
 
 void cdf_sync(int ncid)
 {
-  int status;
-
-  status = nc_sync(ncid);
+  int status = nc_sync(ncid);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -3499,9 +3691,7 @@ void cdf_sync(int ncid)
 
 void cdf_inq(int ncid, int *ndimsp, int *nvarsp, int *ngattsp, int *unlimdimidp)
 {
-  int status;
-
-  status = nc_inq(ncid, ndimsp, nvarsp, ngattsp, unlimdimidp);
+  int status = nc_inq(ncid, ndimsp, nvarsp, ngattsp, unlimdimidp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d ndims = %d nvars = %d ngatts = %d unlimid = %d",
@@ -3513,9 +3703,7 @@ void cdf_inq(int ncid, int *ndimsp, int *nvarsp, int *ngattsp, int *unlimdimidp)
 
 void cdf_def_dim(int ncid, const char *name, size_t len, int *dimidp)
 {
-  int status;
-
-  status = nc_def_dim(ncid, name, len, dimidp);
+  int status = nc_def_dim(ncid, name, len, dimidp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d  name = %s  len = %d", ncid, name, len);
@@ -3526,9 +3714,7 @@ void cdf_def_dim(int ncid, const char *name, size_t len, int *dimidp)
 
 void cdf_inq_dimid(int ncid, const char *name, int *dimidp)
 {
-  int status;
-
-  status = nc_inq_dimid(ncid, name, dimidp);
+  int status = nc_inq_dimid(ncid, name, dimidp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d  name = %s  dimid= %d", ncid, name, *dimidp);
@@ -3539,9 +3725,7 @@ void cdf_inq_dimid(int ncid, const char *name, int *dimidp)
 
 void cdf_inq_dim(int ncid, int dimid, char *name, size_t * lengthp)
 {
-  int status;
-
-  status = nc_inq_dim(ncid, dimid, name, lengthp);
+  int status = nc_inq_dim(ncid, dimid, name, lengthp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d  dimid = %d  length = %d name = %s", ncid, dimid, *lengthp, name);
@@ -3552,9 +3736,7 @@ void cdf_inq_dim(int ncid, int dimid, char *name, size_t * lengthp)
 
 void cdf_inq_dimname(int ncid, int dimid, char *name)
 {
-  int status;
-
-  status = nc_inq_dimname(ncid, dimid, name);
+  int status = nc_inq_dimname(ncid, dimid, name);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d  dimid = %d  name = %s", ncid, dimid, name);
@@ -3565,9 +3747,7 @@ void cdf_inq_dimname(int ncid, int dimid, char *name)
 
 void cdf_inq_dimlen(int ncid, int dimid, size_t * lengthp)
 {
-  int status;
-
-  status = nc_inq_dimlen(ncid, dimid, lengthp);
+  int status = nc_inq_dimlen(ncid, dimid, lengthp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d dimid = %d length = %d", ncid, dimid, *lengthp);
@@ -3601,9 +3781,7 @@ cdf_def_var_serial(int ncid, const char *name, nc_type xtype, int ndims,
 
 void cdf_inq_varid(int ncid, const char *name, int *varidp)
 {
-  int status;
-
-  status = nc_inq_varid(ncid, name, varidp);
+  int status = nc_inq_varid(ncid, name, varidp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d  name = %s  varid = %d ", ncid, name, *varidp);
@@ -3614,9 +3792,7 @@ void cdf_inq_varid(int ncid, const char *name, int *varidp)
 
 void cdf_inq_nvars(int ncid, int *nvarsp)
 {
-  int status;
-
-  status = nc_inq_nvars(ncid, nvarsp);
+  int status = nc_inq_nvars(ncid, nvarsp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d  nvars = %d", ncid, *nvarsp);
@@ -3628,9 +3804,7 @@ void cdf_inq_nvars(int ncid, int *nvarsp)
 void cdf_inq_var(int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp,
 		 int dimids[], int *nattsp)
 {
-  int status;
-
-  status = nc_inq_var(ncid, varid, name, xtypep, ndimsp, dimids, nattsp);
+  int status = nc_inq_var(ncid, varid, name, xtypep, ndimsp, dimids, nattsp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d ndims = %d xtype = %d natts = %d name = %s",
@@ -3642,9 +3816,7 @@ void cdf_inq_var(int ncid, int varid, char *name, nc_type *xtypep, int *ndimsp,
 
 void cdf_inq_varname(int ncid, int varid, char *name)
 {
-  int status;
-
-  status = nc_inq_varname(ncid, varid, name);
+  int status = nc_inq_varname(ncid, varid, name);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d name = %s", ncid, varid, name);
@@ -3655,9 +3827,7 @@ void cdf_inq_varname(int ncid, int varid, char *name)
 
 void cdf_inq_vartype(int ncid, int varid, nc_type *xtypep)
 {
-  int status;
-
-  status = nc_inq_vartype(ncid, varid, xtypep);
+  int status = nc_inq_vartype(ncid, varid, xtypep);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d xtype = %s", ncid, varid, *xtypep);
@@ -3668,9 +3838,7 @@ void cdf_inq_vartype(int ncid, int varid, nc_type *xtypep)
 
 void cdf_inq_varndims(int ncid, int varid, int *ndimsp)
 {
-  int status;
-
-  status = nc_inq_varndims(ncid, varid, ndimsp);
+  int status = nc_inq_varndims(ncid, varid, ndimsp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -3681,9 +3849,7 @@ void cdf_inq_varndims(int ncid, int varid, int *ndimsp)
 
 void cdf_inq_vardimid(int ncid, int varid, int dimids[])
 {
-  int status;
-
-  status = nc_inq_vardimid(ncid, varid, dimids);
+  int status = nc_inq_vardimid(ncid, varid, dimids);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -3694,9 +3860,7 @@ void cdf_inq_vardimid(int ncid, int varid, int dimids[])
 
 void cdf_inq_varnatts(int ncid, int varid, int *nattsp)
 {
-  int status;
-
-  status = nc_inq_varnatts(ncid, varid, nattsp);
+  int status = nc_inq_varnatts(ncid, varid, nattsp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d nattsp = %d", ncid, varid, *nattsp);
@@ -3707,9 +3871,7 @@ void cdf_inq_varnatts(int ncid, int varid, int *nattsp)
 
 void cdf_put_var_text(int ncid, int varid, const char *tp)
 {
-  int status;
-
-  status = nc_put_var_text(ncid, varid, tp);
+  int status = nc_put_var_text(ncid, varid, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("%d %d %s", ncid, varid, tp);
@@ -3720,9 +3882,7 @@ void cdf_put_var_text(int ncid, int varid, const char *tp)
 
 void cdf_put_var_short(int ncid, int varid, const short *sp)
 {
-  int status;
-
-  status = nc_put_var_short(ncid, varid, sp);
+  int status = nc_put_var_short(ncid, varid, sp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("%d %d %hd", ncid, varid, *sp);
@@ -3733,9 +3893,7 @@ void cdf_put_var_short(int ncid, int varid, const short *sp)
 
 void cdf_put_var_int(int ncid, int varid, const int *ip)
 {
-  int status;
-
-  status = nc_put_var_int(ncid, varid, ip);
+  int status = nc_put_var_int(ncid, varid, ip);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("%d %d %d", ncid, varid, *ip);
@@ -3746,9 +3904,7 @@ void cdf_put_var_int(int ncid, int varid, const int *ip)
 
 void cdf_put_var_long(int ncid, int varid, const long *lp)
 {
-  int status;
-
-  status = nc_put_var_long(ncid, varid, lp);
+  int status = nc_put_var_long(ncid, varid, lp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("%d %d %ld", ncid, varid, *lp);
@@ -3759,9 +3915,7 @@ void cdf_put_var_long(int ncid, int varid, const long *lp)
 
 void cdf_put_var_float(int ncid, int varid, const float *fp)
 {
-  int status;
-
-  status = nc_put_var_float(ncid, varid, fp);
+  int status = nc_put_var_float(ncid, varid, fp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("%d %d %f", ncid, varid, *fp);
@@ -3773,9 +3927,7 @@ void cdf_put_var_float(int ncid, int varid, const float *fp)
 void cdf_put_vara_double(int ncid, int varid, const size_t start[],
                          const size_t count[], const double *dp)
 {
-  int status;
-
-  status = nc_put_vara_double(ncid, varid, start, count, dp);
+  int status = nc_put_vara_double(ncid, varid, start, count, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d val0 = %f", ncid, varid, *dp);
@@ -3794,9 +3946,7 @@ void cdf_put_vara_double(int ncid, int varid, const size_t start[],
 void  cdf_put_vara_float(int ncid, int varid, const size_t start[],
                          const size_t count[], const float *fp)
 {
-  int status;
-
-  status = nc_put_vara_float(ncid, varid, start, count, fp);
+  int status = nc_put_vara_float(ncid, varid, start, count, fp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d val0 = %f", ncid, varid, *fp);
@@ -3808,9 +3958,7 @@ void  cdf_put_vara_float(int ncid, int varid, const size_t start[],
 void  cdf_get_vara_int(int ncid, int varid, const size_t start[],
                        const size_t count[], int *dp)
 {
-  int status;
-
-  status = nc_get_vara_int(ncid, varid, start, count, dp);
+  int status = nc_get_vara_int(ncid, varid, start, count, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -3822,9 +3970,7 @@ void  cdf_get_vara_int(int ncid, int varid, const size_t start[],
 void  cdf_get_vara_double(int ncid, int varid, const size_t start[],
                           const size_t count[], double *dp)
 {
-  int status;
-
-  status = nc_get_vara_double(ncid, varid, start, count, dp);
+  int status = nc_get_vara_double(ncid, varid, start, count, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -3836,9 +3982,7 @@ void  cdf_get_vara_double(int ncid, int varid, const size_t start[],
 void  cdf_get_vara_float(int ncid, int varid, const size_t start[],
                          const size_t count[], float *fp)
 {
-  int status;
-
-  status = nc_get_vara_float(ncid, varid, start, count, fp);
+  int status = nc_get_vara_float(ncid, varid, start, count, fp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -3850,9 +3994,7 @@ void  cdf_get_vara_float(int ncid, int varid, const size_t start[],
 void  cdf_get_vara_text(int ncid, int varid, const size_t start[],
 			const size_t count[], char *tp)
 {
-  int status;
-
-  status = nc_get_vara_text(ncid, varid, start, count, tp);
+  int status = nc_get_vara_text(ncid, varid, start, count, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -3863,9 +4005,7 @@ void  cdf_get_vara_text(int ncid, int varid, const size_t start[],
 
 void  cdf_get_vara_uchar(int ncid, int varid, const size_t start[], const size_t count[], unsigned char *tp)
 {
-  int status;
-
-  status = nc_get_vara_uchar(ncid, varid, start, count, tp);
+  int status = nc_get_vara_uchar(ncid, varid, start, count, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -3876,9 +4016,7 @@ void  cdf_get_vara_uchar(int ncid, int varid, const size_t start[], const size_t
 
 void cdf_put_var_double(int ncid, int varid, const double *dp)
 {
-  int status;
-
-  status = nc_put_var_double(ncid, varid, dp);
+  int status = nc_put_var_double(ncid, varid, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d val0 = %f", ncid, varid, *dp);
@@ -3889,9 +4027,7 @@ void cdf_put_var_double(int ncid, int varid, const double *dp)
 
 void cdf_get_var1_text(int ncid, int varid, const size_t index[], char *tp)
 {
-  int status;
-
-  status = nc_get_var1_text(ncid, varid, index, tp);
+  int status = nc_get_var1_text(ncid, varid, index, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -3902,9 +4038,7 @@ void cdf_get_var1_text(int ncid, int varid, const size_t index[], char *tp)
 
 void cdf_get_var1_double(int ncid, int varid, const size_t index[], double *dp)
 {
-  int status;
-
-  status = nc_get_var1_double(ncid, varid, index, dp);
+  int status = nc_get_var1_double(ncid, varid, index, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -3915,9 +4049,7 @@ void cdf_get_var1_double(int ncid, int varid, const size_t index[], double *dp)
 
 void cdf_put_var1_double(int ncid, int varid, const size_t index[], const double *dp)
 {
-  int status;
-
-  status = nc_put_var1_double(ncid, varid, index, dp);
+  int status = nc_put_var1_double(ncid, varid, index, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d val = %f", ncid, varid, *dp);
@@ -3928,9 +4060,7 @@ void cdf_put_var1_double(int ncid, int varid, const size_t index[], const double
 
 void cdf_get_var_text(int ncid, int varid, char *tp)
 {
-  int status;
-
-  status = nc_get_var_text(ncid, varid, tp);
+  int status = nc_get_var_text(ncid, varid, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -3941,9 +4071,7 @@ void cdf_get_var_text(int ncid, int varid, char *tp)
 
 void cdf_get_var_short(int ncid, int varid, short *sp)
 {
-  int status;
-
-  status = nc_get_var_short(ncid, varid, sp);
+  int status = nc_get_var_short(ncid, varid, sp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -3954,9 +4082,7 @@ void cdf_get_var_short(int ncid, int varid, short *sp)
 
 void cdf_get_var_int(int ncid, int varid, int *ip)
 {
-  int status;
-
-  status = nc_get_var_int(ncid, varid, ip);
+  int status = nc_get_var_int(ncid, varid, ip);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -3967,9 +4093,7 @@ void cdf_get_var_int(int ncid, int varid, int *ip)
 
 void cdf_get_var_long(int ncid, int varid, long *lp)
 {
-  int status;
-
-  status = nc_get_var_long(ncid, varid, lp);
+  int status = nc_get_var_long(ncid, varid, lp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -3980,9 +4104,7 @@ void cdf_get_var_long(int ncid, int varid, long *lp)
 
 void cdf_get_var_float(int ncid, int varid, float *fp)
 {
-  int status;
-
-  status = nc_get_var_float(ncid, varid, fp);
+  int status = nc_get_var_float(ncid, varid, fp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d", ncid, varid);
@@ -3993,9 +4115,7 @@ void cdf_get_var_float(int ncid, int varid, float *fp)
 
 void cdf_get_var_double(int ncid, int varid, double *dp)
 {
-  int status;
-
-  status = nc_get_var_double(ncid, varid, dp);
+  int status = nc_get_var_double(ncid, varid, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d val[0] = %f", ncid, varid, *dp);
@@ -4007,9 +4127,7 @@ void cdf_get_var_double(int ncid, int varid, double *dp)
 void cdf_copy_att(int ncid_in, int varid_in, const char *name, int ncid_out,
 		  int varid_out)
 {
-  int status;
-
-  status = nc_copy_att(ncid_in, varid_in, name, ncid_out, varid_out);
+  int status = nc_copy_att(ncid_in, varid_in, name, ncid_out, varid_out);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("%d %d %s %d %d", ncid_in, varid_out, name, ncid_out, varid_out);
@@ -4021,9 +4139,7 @@ void cdf_copy_att(int ncid_in, int varid_in, const char *name, int ncid_out,
 void cdf_put_att_text(int ncid, int varid, const char *name, size_t len,
 		      const char *tp)
 {
-  int status;
-
-  status = nc_put_att_text(ncid, varid, name, len, tp);
+  int status = nc_put_att_text(ncid, varid, name, len, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d att = %s text = %.*s", ncid, varid, name, (int)len, tp);
@@ -4035,9 +4151,7 @@ void cdf_put_att_text(int ncid, int varid, const char *name, size_t len,
 void cdf_put_att_int(int ncid, int varid, const char *name, nc_type xtype,
 		     size_t len, const int *ip)
 {
-  int status;
-
-  status = nc_put_att_int(ncid, varid, name, xtype, len, ip);
+  int status = nc_put_att_int(ncid, varid, name, xtype, len, ip);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d att = %s val = %d", ncid, varid, name, *ip);
@@ -4046,15 +4160,25 @@ void cdf_put_att_int(int ncid, int varid, const char *name, nc_type xtype,
 }
 
 
+void cdf_put_att_float(int ncid, int varid, const char *name, nc_type xtype,
+                       size_t len, const float *dp)
+{
+  int status = nc_put_att_float(ncid, varid, name, xtype, len, dp);
+
+  if ( CDF_Debug || status != NC_NOERR )
+    Message("ncid = %d varid = %d att = %s val = %g", ncid, varid, name, *dp);
+
+  if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
+}
+
+
 void cdf_put_att_double(int ncid, int varid, const char *name, nc_type xtype,
 			size_t len, const double *dp)
 {
-  int status;
-
-  status = nc_put_att_double(ncid, varid, name, xtype, len, dp);
+  int status = nc_put_att_double(ncid, varid, name, xtype, len, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("%d %d %f", ncid, varid, *dp);
+    Message("ncid = %d varid = %d att = %s val = %g", ncid, varid, name, *dp);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -4062,9 +4186,7 @@ void cdf_put_att_double(int ncid, int varid, const char *name, nc_type xtype,
 
 void cdf_get_att_text(int ncid, int varid, const char *name, char *tp)
 {
-  int status;
-
-  status = nc_get_att_text(ncid, varid, name, tp);
+  int status = nc_get_att_text(ncid, varid, name, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d name = %s", ncid, varid, name);
@@ -4075,9 +4197,7 @@ void cdf_get_att_text(int ncid, int varid, const char *name, char *tp)
 void cdf_get_att_string(int ncid, int varid, const char *name, char **tp)
 {
 #if  defined  (HAVE_NETCDF4)
-  int status;
-
-  status = nc_get_att_string(ncid, varid, name, tp);
+  int status = nc_get_att_string(ncid, varid, name, tp);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d name = %s", ncid, varid, name);
@@ -4089,9 +4209,7 @@ void cdf_get_att_string(int ncid, int varid, const char *name, char **tp)
 
 void cdf_get_att_int(int ncid, int varid, const char *name, int *ip)
 {
-  int status;
-
-  status = nc_get_att_int(ncid, varid, name, ip);
+  int status = nc_get_att_int(ncid, varid, name, ip);
 
   if ( CDF_Debug || status != NC_NOERR )
     Message("ncid = %d varid = %d att = %s val = %d", ncid, varid, name, *ip);
@@ -4107,8 +4225,7 @@ void cdf_get_att_double(int ncid, int varid, const char *name, double *dp)
   status = nc_get_att_double(ncid, varid, name, dp);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("ncid = %d varid = %d att = %s val = %.9g",
-	    ncid, varid, name, *dp);
+    Message("ncid = %d varid = %d att = %s val = %.9g", ncid, varid, name, *dp);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -4117,12 +4234,10 @@ void cdf_get_att_double(int ncid, int varid, const char *name, double *dp)
 void cdf_inq_att(int ncid, int varid, const char *name, nc_type *xtypep,
 		 size_t *lenp)
 {
-  int status;
-
-  status = nc_inq_att(ncid, varid, name, xtypep, lenp);
+  int status = nc_inq_att(ncid, varid, name, xtypep, lenp);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("ncid = %d varid = %d", ncid, varid);
+    Message("ncid = %d varid = %d att = %s", ncid, varid, name);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -4130,12 +4245,10 @@ void cdf_inq_att(int ncid, int varid, const char *name, nc_type *xtypep,
 
 void cdf_inq_atttype(int ncid, int varid, const char *name, nc_type * xtypep)
 {
-  int status;
-
-  status = nc_inq_atttype(ncid, varid, name, xtypep);
+  int status = nc_inq_atttype(ncid, varid, name, xtypep);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("ncid = %d varid = %d", ncid, varid);
+    Message("ncid = %d varid = %d att = %s", ncid, varid, name);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -4143,12 +4256,10 @@ void cdf_inq_atttype(int ncid, int varid, const char *name, nc_type * xtypep)
 
 void cdf_inq_attlen(int ncid, int varid, const char *name, size_t * lenp)
 {
-  int status;
-
-  status = nc_inq_attlen(ncid, varid, name, lenp);
+  int status = nc_inq_attlen(ncid, varid, name, lenp);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("ncid = %d varid = %d name = %s len = %d", ncid, varid, name, *lenp);
+    Message("ncid = %d varid = %d att = %s len = %d", ncid, varid, name, *lenp);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -4156,12 +4267,10 @@ void cdf_inq_attlen(int ncid, int varid, const char *name, size_t * lenp)
 
 void cdf_inq_attname(int ncid, int varid, int attnum, char *name)
 {
-  int status;
-
-  status = nc_inq_attname(ncid, varid, attnum, name);
+  int status = nc_inq_attname(ncid, varid, attnum, name);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("ncid = %d varid = %d attnum = %d name = %s", ncid, varid, attnum, name);
+    Message("ncid = %d varid = %d attnum = %d att = %s", ncid, varid, attnum, name);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -4169,12 +4278,10 @@ void cdf_inq_attname(int ncid, int varid, int attnum, char *name)
 
 void cdf_inq_attid(int ncid, int varid, const char *name, int *attnump)
 {
-  int status;
-
-  status = nc_inq_attid(ncid, varid, name, attnump);
+  int status = nc_inq_attid(ncid, varid, name, attnump);
 
   if ( CDF_Debug || status != NC_NOERR )
-    Message("ncid = %d varid = %d", ncid, varid);
+    Message("ncid = %d varid = %d att = %s", ncid, varid, name);
 
   if ( status != NC_NOERR ) Error("%s", nc_strerror(status));
 }
@@ -4197,6 +4304,16 @@ void cdf_inq_attid(int ncid, int varid, const char *name, int *attnump)
 uint32_t cdiCheckSum(int type, int count, const void *data);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #ifdef HAVE_CONFIG_H
 #endif
 
@@ -4216,6 +4333,15 @@ memcrc_finish(uint32_t *state, off_t total_size);
 uint32_t
 memcrc(const unsigned char *b, size_t n);
 
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #ifdef HAVE_CONFIG_H
 #endif
 
@@ -4267,12 +4393,12 @@ serializeStrTabPack(const char **strTab, int numStr,
   xassert(numStr >= 0);
   for (size_t i = 0; i < (size_t)numStr; ++i)
   {
-    size_t len = strlen(strTab[i]);
-    serializePack(&(int){(int)len}, 1, DATATYPE_INT,
+    int len = (int)strlen(strTab[i]);
+    serializePack(&len, 1, DATATYPE_INT,
                   buf, buf_size, position, context);
-    serializePack(strTab[i], (int)len, DATATYPE_TXT,
+    serializePack(strTab[i], len, DATATYPE_TXT,
                   buf, buf_size, position, context);
-    d ^= cdiCheckSum(DATATYPE_TXT, (int)len, strTab[i]);
+    d ^= cdiCheckSum(DATATYPE_TXT, len, strTab[i]);
   }
   serializePack(&d, 1, DATATYPE_UINT32,
                 buf, buf_size, position, context);
@@ -4292,7 +4418,7 @@ serializeStrTabUnpack(const void *buf, int buf_size, int *position,
       serializeUnpack(buf, buf_size, position,
                       strTab[i], len, DATATYPE_TXT, context);
       strTab[i][len] = '\0';
-      d2 ^= cdiCheckSum(DATATYPE_TXT, (size_t)len, strTab[i]);
+      d2 ^= cdiCheckSum(DATATYPE_TXT, len, strTab[i]);
     }
   serializeUnpack(buf, buf_size, position,
                   &d, 1, DATATYPE_UINT32, context);
@@ -4335,6 +4461,16 @@ uint32_t cdiCheckSum(int type, int count, const void *buffer)
   s = memcrc_finish(&s, (off_t)(elemSize * (size_t)count));
   return s;
 }
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #if defined (HAVE_CONFIG_H)
 #endif
 
@@ -4354,7 +4490,7 @@ const char *cdiStringError(int cdiErrno)
   switch (cdiErrno) {
   case CDI_ESYSTEM:
     {
-      char *cp = (char *) strerror(errno);
+      const char *cp = strerror(errno);
       if ( cp == NULL ) break;
       return cp;
     }
@@ -4367,6 +4503,7 @@ const char *cdiStringError(int cdiErrno)
 
   return UnknownError;
 }
+
 /*
  * Local Variables:
  * c-file-style: "Java"
@@ -4379,20 +4516,13 @@ const char *cdiStringError(int cdiErrno)
 #ifndef _DMEMORY_H
 #define _DMEMORY_H
 
-//Ensure that all standard headers that may declare malloc() and friends are already included so that our macros won't clobber their definitions.
-#include <stdlib.h>
-#ifdef HAVE_MALLOC_H
-    #include <malloc.h>
-#endif
-
-/*
- * if DEBUG_MEMORY is defined setenv MEMORY_DEBUG to debug memory
- */
+#include <stdio.h>
 
+// if DEBUG_MEMORY is defined setenv MEMORY_DEBUG to debug memory
 #define  DEBUG_MEMORY
 
-#ifndef  WITH_CALLER_NAME
-#define  WITH_CALLER_NAME
+#ifndef  WITH_FUNCTION_NAME
+#define  WITH_FUNCTION_NAME
 #endif
 
 extern size_t  memTotal(void);
@@ -4401,38 +4531,25 @@ extern void    memExitOnError(void);
 
 #if  defined  DEBUG_MEMORY
 
-extern void   *Realloc(const char *caller, const char *file, int line, void *ptr, size_t size);
-extern void   *Calloc (const char *caller, const char *file, int line, size_t nmemb, size_t size);
-extern void   *Malloc (const char *caller, const char *file, int line, size_t size);
-extern void    Free   (const char *caller, const char *file, int line, void *ptr);
-
-#if  defined  calloc
-#  undef  calloc
-#endif
+extern void   *memRealloc(void *ptr, size_t size, const char *file, const char *functionname, int line);
+extern void   *memCalloc (size_t nmemb, size_t size, const char *file, const char *functionname, int line);
+extern void   *memMalloc (size_t size, const char *file, const char *functionname, int line);
+extern void    memFree   (void *ptr, const char *file, const char *functionname, int line);
 
-#if  defined  WITH_CALLER_NAME
-#  define  realloc(p, s)  Realloc(__func__, __FILE__, __LINE__, (p), (s))
-#  define   calloc(n, s)   Calloc(__func__, __FILE__, __LINE__, (n), (s))
-#  define   malloc(s)      Malloc(__func__, __FILE__, __LINE__, (s))
-#  define     free(p)        Free(__func__, __FILE__, __LINE__, (p))
+#if  defined  WITH_FUNCTION_NAME
+#  define  Realloc(p, s)  memRealloc((p), (s), __FILE__, __func__, __LINE__)
+#  define   Calloc(n, s)   memCalloc((n), (s), __FILE__, __func__, __LINE__)
+#  define   Malloc(s)      memMalloc((s), __FILE__, __func__, __LINE__)
+#  define     Free(p)        memFree((p), __FILE__, __func__, __LINE__)
 #else
-#  define  realloc(p, s)  Realloc((void *) NULL, __FILE__, __LINE__, (p), (s))
-#  define   calloc(n, s)   Calloc((void *) NULL, __FILE__, __LINE__, (n), (s))
-#  define   malloc(s)      Malloc((void *) NULL, __FILE__, __LINE__, (s))
-#  define     free(p)        Free((void *) NULL, __FILE__, __LINE__, (p))
+#  define  Realloc(p, s)  memRealloc((p), (s), __FILE__, (void *) NULL, __LINE__)
+#  define   Calloc(n, s)   memCalloc((n), (s), __FILE__, (void *) NULL, __LINE__)
+#  define   Malloc(s)      memMalloc((s), __FILE__, (void *) NULL, __LINE__)
+#  define     Free(p)        memFree((p), __FILE__, (void *) NULL, __LINE__)
 #endif
 
 #endif /* DEBUG_MEMORY */
 
-void *cdiXmalloc(size_t, const char *, const char *, int);
-#define xmalloc(size) cdiXmalloc((size), __FILE__, __func__,  __LINE__ )
-
-void *cdiXcalloc(size_t, size_t, const char *, const char *, int);
-#define xcalloc(nmemb,size) cdiXcalloc((nmemb), (size), __FILE__, __func__, __LINE__)
-
-void *cdiXrealloc(void *, size_t, const char *, const char *, int);
-#define xrealloc(p,size) cdiXrealloc((p), (size), __FILE__, __func__, __LINE__)
-
 #endif /* _DMEMORY_H */
 /*
  * Local Variables:
@@ -4510,9 +4627,42 @@ static inline void *gribHandleNew(int editionNumber)
   return gh;
 }
 
+static inline int my_grib_set_double(grib_handle* h, const char* key, double val)
+{
+  if ( cdiGribApiDebug )
+    fprintf(stderr, "grib_set_double(\tgrib_handle* h, \"%s\", %f)\n", key, val);
+
+  int ret_val = grib_set_double(h, key, val);
+  if (ret_val != 0)
+    fprintf(stderr, "!!! failed call to grib_set_double(\tgrib_handle* h, \"%s\", %f) !!!\n", key, val);
+  return ret_val;
+}
+
+static inline int my_grib_set_long(grib_handle* h, const char* key, long val)
+{
+  if ( cdiGribApiDebug )
+    fprintf(stderr, "grib_set_long(  \tgrib_handle* h, \"%s\", %ld)\n", key, val);
+
+  int ret_val = grib_set_long(h, key, val);
+  if (ret_val != 0)
+    fprintf(stderr, "!!! failed call to grib_set_long(  \tgrib_handle* h, \"%s\", %ld) !!!\n", key, val);
+  return ret_val;
+}
+
+static inline int my_grib_set_string(grib_handle* h, const char* key, const char* val, size_t* length)
+{
+  if ( cdiGribApiDebug )
+    fprintf(stderr, "grib_set_string(\tgrib_handle* h, \"%s\", \"%s\")\n", key, val);
+
+  int ret_val = grib_set_string(h, key, val, length);
+  if (ret_val != 0)
+    fprintf(stderr, "!!! grib_set_string(\tgrib_handle* h, \"%s\", \"%s\") !!!\n", key, val);
+  return ret_val;
+}
+
 static inline void gribHandleDelete(void *gh)
 {
-  grib_handle_delete(gh);
+  grib_handle_delete((struct grib_handle *)gh);
 }
 #else
 #define gribHandleNew(editionNumber) (NULL)
@@ -4837,8 +4987,6 @@ double calculate_pfactor(const double* spectralField, long fieldTruncation, long
 #if  defined  (HAVE_LIBCGRIBEX)
 #endif
 
-extern int cdiPioSerialOpenFileMap(int streamID);
-
 int cdiDefaultCalendar = CALENDAR_PROLEPTIC;
 
 int cdiDefaultInstID   = CDI_UNDEFID;
@@ -4852,7 +5000,10 @@ int cdiSplitLtype105   = CDI_UNDEFID;
 int cdiIgnoreAttCoordinates = FALSE;
 int cdiIgnoreValidRange     = FALSE;
 int cdiSkipRecords          = 0;
+int cdiConvention           = CDI_CONVENTION_ECHAM;
 int cdiInventoryMode        = 1;
+int CDI_Version_Info        = 1;
+int CDI_cmor_mode           = 0;
 size_t CDI_netcdf_hdr_pad   = 0UL;
 
 char *cdiPartabPath   = NULL;
@@ -4860,7 +5011,7 @@ int   cdiPartabIntern = 1;
 
 double cdiDefaultMissval = -9.E33;
 
-const char Filetypes[][9] = {
+static const char Filetypes[][9] = {
   "UNKNOWN",
   "GRIB",
   "GRIB2",
@@ -4874,11 +5025,8 @@ const char Filetypes[][9] = {
   "HDF5",
 };
 
-#undef  UNDEFID
-#define UNDEFID  CDI_UNDEFID
-
-
 int CDI_Debug   = 0;    /* If set to 1, debugging           */
+int CDI_Recopt = 0;
 
 int cdiGribApiDebug     = 0;
 int cdiDefaultLeveltype = -1;
@@ -4887,7 +5035,7 @@ int cdiSortName = 0;
 int cdiHaveMissval = 0;
 
 
-static long cdiGetenvInt(char *envName)
+static long cdiGetenvInt(const char *envName)
 {
   char *envString;
   long envValue = -1;
@@ -5087,7 +5235,7 @@ void cdiSetChunk(const char *chunkAlgo)
 void cdiInitialize(void)
 {
   static int Init_CDI = FALSE;
-  char *envString;
+  char *envstr;
   long value;
 
   if ( ! Init_CDI )
@@ -5105,6 +5253,9 @@ void cdiInitialize(void)
       value = cdiGetenvInt("CDI_GRIBAPI_DEBUG");
       if ( value >= 0 ) cdiGribApiDebug = (int) value;
 
+      value = cdiGetenvInt("CDI_RECOPT");
+      if ( value >= 0 ) CDI_Recopt = (int) value;
+
       value = cdiGetenvInt("CDI_REGULARGRID");
       if ( value >= 0 ) cdiDataUnreduced = (int) value;
 
@@ -5120,38 +5271,49 @@ void cdiInitialize(void)
       value = cdiGetenvInt("CDI_NETCDF_HDR_PAD");
       if ( value >= 0 ) CDI_netcdf_hdr_pad = (size_t) value;
 
-      envString = getenv("CDI_MISSVAL");
-      if ( envString ) cdiDefaultMissval = atof(envString);
+      envstr = getenv("CDI_MISSVAL");
+      if ( envstr ) cdiDefaultMissval = atof(envstr);
       /*
-      envString = getenv("NC_MISSING_VALUE");
-      if ( envString ) cdiNcMissingValue = atoi(envString);
+      envstr = getenv("NC_MISSING_VALUE");
+      if ( envstr ) cdiNcMissingValue = atoi(envstr);
       */
-      envString = getenv("NC_CHUNKSIZEHINT");
-      if ( envString ) cdiNcChunksizehint = atoi(envString);
+      envstr = getenv("NC_CHUNKSIZEHINT");
+      if ( envstr ) cdiNcChunksizehint = atoi(envstr);
 
-      envString = getenv("CDI_CHUNK_ALGO");
-      if ( envString ) cdiSetChunk(envString);
+      envstr = getenv("CDI_CHUNK_ALGO");
+      if ( envstr ) cdiSetChunk(envstr);
 
-      envString = getenv("SPLIT_LTYPE_105");
-      if ( envString ) cdiSplitLtype105 = atoi(envString);
+      envstr = getenv("SPLIT_LTYPE_105");
+      if ( envstr ) cdiSplitLtype105 = atoi(envstr);
 
-      envString = getenv("IGNORE_ATT_COORDINATES");
-      if ( envString ) cdiIgnoreAttCoordinates = atoi(envString);
+      envstr = getenv("IGNORE_ATT_COORDINATES");
+      if ( envstr ) cdiIgnoreAttCoordinates = atoi(envstr);
 
-      envString = getenv("IGNORE_VALID_RANGE");
-      if ( envString ) cdiIgnoreValidRange = atoi(envString);
+      envstr = getenv("IGNORE_VALID_RANGE");
+      if ( envstr ) cdiIgnoreValidRange = atoi(envstr);
 
-      envString = getenv("CDI_SKIP_RECORDS");
-      if ( envString )
+      envstr = getenv("CDI_SKIP_RECORDS");
+      if ( envstr )
 	{
-	  cdiSkipRecords = atoi(envString);
+	  cdiSkipRecords = atoi(envstr);
 	  cdiSkipRecords = cdiSkipRecords > 0 ? cdiSkipRecords : 0;
 	}
 
-      envString = getenv("CDI_INVENTORY_MODE");
-      if ( envString )
+      envstr = getenv("CDI_CONVENTION");
+      if ( envstr )
+	{
+	  if ( strcmp(envstr, "CF") == 0 || strcmp(envstr, "cf") == 0 )
+	    {
+	      cdiConvention = CDI_CONVENTION_CF;
+	      if ( CDI_Debug )
+		Message("CDI convention was set to CF!");
+	    }
+	}
+
+      envstr = getenv("CDI_INVENTORY_MODE");
+      if ( envstr )
 	{
-	  if ( strncmp(envString, "time", 4) == 0 )
+	  if ( strncmp(envstr, "time", 4) == 0 )
 	    {
 	      cdiInventoryMode = 2;
 	      if ( CDI_Debug )
@@ -5159,34 +5321,47 @@ void cdiInitialize(void)
 	    }
 	}
 
-      envString = getenv("CDI_CALENDAR");
-      if ( envString )
+      envstr = getenv("CDI_VERSION_INFO");
+      if ( envstr )
+        {
+          int ival = atoi(envstr);
+          if ( ival == 0 || ival == 1 )
+            {
+              CDI_Version_Info = ival;
+              if ( CDI_Debug )
+                Message("CDI_Version_Info = %s", envstr);
+            }
+        }
+
+
+      envstr = getenv("CDI_CALENDAR");
+      if ( envstr )
 	{
-	  if      ( strncmp(envString, "standard", 8) == 0 )
+	  if      ( strncmp(envstr, "standard", 8) == 0 )
 	    cdiDefaultCalendar = CALENDAR_STANDARD;
-	  else if ( strncmp(envString, "proleptic", 9) == 0 )
+	  else if ( strncmp(envstr, "proleptic", 9) == 0 )
 	    cdiDefaultCalendar = CALENDAR_PROLEPTIC;
-	  else if ( strncmp(envString, "360days", 7) == 0 )
+	  else if ( strncmp(envstr, "360days", 7) == 0 )
 	    cdiDefaultCalendar = CALENDAR_360DAYS;
-	  else if ( strncmp(envString, "365days", 7) == 0 )
+	  else if ( strncmp(envstr, "365days", 7) == 0 )
 	    cdiDefaultCalendar = CALENDAR_365DAYS;
-	  else if ( strncmp(envString, "366days", 7) == 0 )
+	  else if ( strncmp(envstr, "366days", 7) == 0 )
 	    cdiDefaultCalendar = CALENDAR_366DAYS;
-	  else if ( strncmp(envString, "none", 4) == 0 )
+	  else if ( strncmp(envstr, "none", 4) == 0 )
 	    cdiDefaultCalendar = CALENDAR_NONE;
 
 	  if ( CDI_Debug )
-	    Message("Default calendar set to %s!", envString);
+	    Message("Default calendar set to %s!", envstr);
 	}
 #if  defined  (HAVE_LIBCGRIBEX)
       gribSetCalendar(cdiDefaultCalendar);
 #endif
 
-      envString = getenv("PARTAB_INTERN");
-      if ( envString ) cdiPartabIntern = atoi(envString);
+      envstr = getenv("PARTAB_INTERN");
+      if ( envstr ) cdiPartabIntern = atoi(envstr);
 
-      envString = getenv("PARTAB_PATH");
-      if ( envString ) cdiPartabPath = strdup(envString);
+      envstr = getenv("PARTAB_PATH");
+      if ( envstr ) cdiPartabPath = strdup(envstr);
     }
 }
 
@@ -5212,6 +5387,7 @@ void cdiDefGlobal(const char *string, int val)
   else if ( strcmp(string, "SORTNAME")         == 0 ) cdiSortName = val;
   else if ( strcmp(string, "HAVE_MISSVAL")     == 0 ) cdiHaveMissval = val;
   else if ( strcmp(string, "NC_CHUNKSIZEHINT") == 0 ) cdiNcChunksizehint = val;
+  else if ( strcmp(string, "CMOR_MODE")        == 0 ) CDI_cmor_mode = val;
   else if ( strcmp(string, "NETCDF_HDR_PAD")   == 0 ) CDI_netcdf_hdr_pad = (size_t) val;
   else Warning("Unsupported global key: %s", string);
 }
@@ -5241,7 +5417,13 @@ double cdiInqMissval(void)
  * require-trailing-newline: t
  * End:
  */
+
+#if defined (HAVE_CONFIG_H)
+#endif
+
 #include <stdio.h>
+#include <stdlib.h>
+
 
 void cdiDecodeParam(int param, int *pnum, int *pcat, int *pdis)
 {
@@ -5274,48 +5456,41 @@ int cdiEncodeParam(int pnum, int pcat, int pdis)
 
 void cdiDecodeDate(int date, int *year, int *month, int *day)
 {
-  int idate;
 
-  *year  =  date / 10000;
-  idate  = date - *year*10000;
-  if ( idate < 0 ) idate = -idate;
-  *month = idate / 100;
-  *day   = idate - *month*100;
+  int iyear = date / 10000;
+  *year = iyear;
+  int idate = abs(date - iyear * 10000),
+    imonth = idate / 100;
+  *month = imonth;
+  *day   = idate - imonth * 100;
 }
 
 
 int cdiEncodeDate(int year, int month, int day)
 {
-  int date;
-  int iyear;
-
-  iyear = year;
-  if ( iyear < 0 ) iyear = -iyear;
-  date = iyear*10000 + month*100 + day;
+  int iyear = abs(year),
+    date = iyear * 10000 + month * 100 + day;
   if ( year < 0 ) date = -date;
-
   return (date);
 }
 
 
 void cdiDecodeTime(int time, int *hour, int *minute, int *second)
 {
-  int itime;
-
-  *hour   = time / 10000;
-  itime   = time - *hour*10000;
-  *minute = itime / 100;
-  *second = itime - *minute*100;
+  int ihour = time / 10000,
+    itime = time - ihour * 10000,
+    iminute = itime / 100;
+  *hour   = ihour;
+  *minute = iminute;
+  *second = itime - iminute * 100;
 }
 
 
 int cdiEncodeTime(int hour, int minute, int second)
 {
-  int time;
+  int time = hour*10000 + minute*100 + second;
 
-  time = hour*10000 + minute*100 + second;
-
-  return (time);
+  return time;
 }
 
 
@@ -5326,21 +5501,22 @@ void cdiParamToString(int param, char *paramstr, int maxlen)
 
   cdiDecodeParam(param, &num, &cat, &dis);
 
+  size_t umaxlen = maxlen >= 0 ? (unsigned)maxlen : 0U;
   if ( dis == 255 && (cat == 255 || cat == 0 ) )
-    len = sprintf(paramstr, "%d", num);
+    len = snprintf(paramstr, umaxlen, "%d", num);
   else  if ( dis == 255 )
-    len = sprintf(paramstr, "%d.%d", num, cat);
+    len = snprintf(paramstr, umaxlen, "%d.%d", num, cat);
   else
-    len = sprintf(paramstr, "%d.%d.%d", num, cat, dis);
+    len = snprintf(paramstr, umaxlen, "%d.%d.%d", num, cat, dis);
 
-  if ( len > ( maxlen-1) )
+  if ( len >= maxlen || len < 0)
     fprintf(stderr, "Internal problem (%s): size of input string is too small!\n", __func__);
 }
 
 
-char *cdiUnitNamePtr(int cdi_unit)
+const char *cdiUnitNamePtr(int cdi_unit)
 {
-  char *cdiUnits[] = {
+  const char *cdiUnits[] = {
     /*  0 */  "undefined",
     /*  1 */  "Pa",
     /*  2 */  "hPa",
@@ -5349,15 +5525,10 @@ char *cdiUnitNamePtr(int cdi_unit)
     /*  5 */  "dm",
     /*  6 */  "m",
   };
-  char *name;
-  int size = (int) (sizeof(cdiUnits)/sizeof(char *));
-
-  if ( cdi_unit > 0 && cdi_unit < size )
-    name = cdiUnits[cdi_unit];
-  else
-    name = NULL;
-
-  return (name);
+  enum { numUnits = (int) (sizeof(cdiUnits)/sizeof(char *)) };
+  const char *name = ( cdi_unit > 0 && cdi_unit < numUnits ) ?
+    cdiUnits[cdi_unit] : NULL;
+  return name;
 }
 
 /*
@@ -5369,33 +5540,13 @@ char *cdiUnitNamePtr(int cdi_unit)
  * require-trailing-newline: t
  * End:
  */
-#ifndef _CALENDAR_H
-#define _CALENDAR_H
 
-void encode_caldaysec(int calendar, int year, int month, int day, int hour, int minute, int second,
-		      int *julday, int *secofday);
-void decode_caldaysec(int calendar, int julday, int secofday, 
-		      int *year, int *month, int *day, int *hour, int *minute, int *second);
+/* Automatically generated by m214003 at 2015-09-14, do not edit */
 
-#endif  /* _CALENDAR_H */
-/*
- * Local Variables:
- * c-file-style: "Java"
- * c-basic-offset: 2
- * indent-tabs-mode: nil
- * show-trailing-whitespace: t
- * require-trailing-newline: t
- * End:
- */
+/* CGRIBEXLIB_VERSION="1.7.3" */
 
-/* Automatically generated by m214003 at 2015-04-22, do not edit */
-
-/* CGRIBEXLIB_VERSION="1.7.2" */
-
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5) || defined (__clang__)
 #pragma GCC diagnostic push
-#endif
-#ifdef __GNUC__
 #pragma GCC diagnostic ignored "-Wconversion"
 #pragma GCC diagnostic ignored "-Wsign-conversion"
 #pragma GCC diagnostic warning "-Wstrict-overflow"
@@ -6581,7 +6732,7 @@ int main(void)
 
   {
     float fmin, fmax;
-    float *data_sp = (float*) malloc(datasize*sizeof(float));
+    float *data_sp = (float*) Malloc(datasize*sizeof(float));
 
     for ( long i = 0; i < datasize/2; i++ )        data_sp[i] = (float) (i);
     for ( long i = datasize/2; i < datasize; i++ ) data_sp[i] = (float) (-datasize + i);
@@ -6596,12 +6747,12 @@ int main(void)
       }
     t_end = dtime();
     printf("minmax_val: fmin: %ld  fmax: %ld  time: %6.2fs\n", (long)fmin, (long) fmax, t_end-t_begin);
-    free(data_sp);
+    Free(data_sp);
   }
 
   {
     double fmin, fmax;
-    double *data_dp = (double*) malloc(datasize*sizeof(double));
+    double *data_dp = (double*) Malloc(datasize*sizeof(double));
 
     // for ( long i = datasize-1; i >= 0; i-- ) data[i] = (double) (-datasize/2 + i);
     for ( long i = 0; i < datasize/2; i++ )        data_dp[i] = (double) (i);
@@ -6667,7 +6818,7 @@ int main(void)
     t_end = dtime();
     printf("pwr6u6  : fmin: %ld  fmax: %ld  time: %6.2fs\n", (long)fmin, (long) fmax, t_end-t_begin);
 #endif
-    free(data_dp);
+    Free(data_dp);
   }
 
   return (0);
@@ -6679,6 +6830,14 @@ int main(void)
 #undef _ENABLE_SSE2
 #undef GNUC_PUSH_POP
 /* 
+icc -g -Wall -O3 -march=native -std=c99 -qopt-report=5 -DTEST_ENCODE encode_array.c
+ result on hama (icc 15.0.1):
+  float:
+    orig: val1: 1  val2: 1  val3: 2  valn: 66  time: 8.7936s
+  double:
+    orig: val1: 1  val2: 1  val3: 2  valn: 66  time: 13.6093s
+     avx: val1: 1  val2: 1  val3: 2  valn: 66  time: 3.90009s
+
 gcc -g -Wall -O3 -march=native -std=c99 -DTEST_ENCODE encode_array.c
  result on hama (gcc 4.8.2):
   orig    : val1: 1  val2: 1  val3: 2  valn: 66  time: 16.0471s
@@ -7041,7 +7200,8 @@ double dtime()
 static
 void pout(char *name, int s, unsigned char *lgrib, long datasize, double tt)
 {
-  printf("%8s: val1: %d  val2: %d  val3: %d  valn: %d  time: %gs\n", name, (int) lgrib[s*1+1], (int) lgrib[s*2+1], (int) lgrib[s*3+1], (int) lgrib[2*datasize-1], tt);
+  printf("%8s: val1: %d  val2: %d  val3: %d  valn: %d  time: %gs\n",
+         name, (int) lgrib[s*1+1], (int) lgrib[s*2+1], (int) lgrib[s*3+1], (int) lgrib[2*datasize-1], tt);
 }
 
 int main(void)
@@ -7052,9 +7212,9 @@ int main(void)
   double t_begin, t_end;
   unsigned char *lgrib;
 
-  dataf = (float*) malloc(datasize*sizeof(float));
-  data  = (double*) malloc(datasize*sizeof(double));
-  lgrib = (unsigned char*) malloc(2*datasize*sizeof(unsigned char));
+  dataf = (float*) Malloc(datasize*sizeof(float));
+  data  = (double*) Malloc(datasize*sizeof(double));
+  lgrib = (unsigned char*) Malloc(2*datasize*sizeof(unsigned char));
 
   for ( long i = 0; i < datasize; ++i ) dataf[i] = (float) (-datasize/2 + i);
   for ( long i = 0; i < datasize; ++i ) data[i] = (double) (-datasize/2 + i);
@@ -7161,7 +7321,9 @@ int main(void)
 #include <mach/mach_time.h>
 #endif
 
+#ifdef __cplusplus
 #define __STDC_FORMAT_MACROS
+#endif
 #include <inttypes.h>
 
 #if   defined(__GNUC__) && (__GNUC__ >= 4)
@@ -7480,8 +7642,8 @@ void confp3(double pval, int *kexp, int *kmant, int kbits, int kround)
     {
       *kexp  = 0;
       *kmant = 0;
-      iexp   = 0;
-      isign  = 0;
+      // iexp   = 0;
+      // isign  = 0;
       goto LABEL900;
     }
 
@@ -7570,8 +7732,8 @@ void confp3(double pval, int *kexp, int *kmant, int kbits, int kround)
           Message("Value arbitrarily set to zero.");
           *kexp  = 0;
           *kmant = 0;
-          iexp  = 0;
-          isign = 0;
+          // iexp  = 0;
+          // isign = 0;
           goto LABEL900;
 	}
 
@@ -8023,7 +8185,7 @@ gribExSP_old(int *isec0, int *isec1, int *isec2, float *fsec2sp, int *isec3,
       fsec3dp[1] = fsec3sp[1];
 
       inum = isec4[0];
-      fsec4dp = (double*) malloc(inum*sizeof(double));
+      fsec4dp = (double*) Malloc(inum*sizeof(double));
       if ( fsec4dp == NULL ) SysError("No Memory!");
 
       for ( j = 0; j < inum; j++ ) fsec4dp[j] = fsec4sp[j];
@@ -8032,13 +8194,13 @@ gribExSP_old(int *isec0, int *isec1, int *isec2, float *fsec2sp, int *isec3,
 	       fsec3dp, isec4, fsec4dp, klenp, kgrib,
 	       kleng, kword, hoper, kret);
 
-      free(fsec4dp);
+      Free(fsec4dp);
     }
   else if ( yfunc == 'D' || yfunc == 'J' || yfunc == 'R' )
     {
       if ( yfunc == 'D' || yfunc == 'R' )
 	{
-	  fsec4dp = (double*) malloc(klenp*sizeof(double));
+	  fsec4dp = (double*) Malloc(klenp*sizeof(double));
 	  if ( fsec4dp == NULL ) SysError("No Memory!");
 	}
 
@@ -8070,7 +8232,7 @@ gribExSP_old(int *isec0, int *isec1, int *isec2, float *fsec2sp, int *isec3,
 		fsec4sp[j] = fsec4dp[j];
 	    }
 
-	  free(fsec4dp);
+	  Free(fsec4dp);
 	}
     }
   else if ( yfunc == 'V' )
@@ -8744,7 +8906,6 @@ void gribPrintSec1(int *isec0, int *isec1)
           fprintf(grprsm, " Number of different time intervals used  %5d\n", isec1[48]);
           fprintf(grprsm, " List of different time intervals used:\n");
           iprev  = isec1[49];
-          icurr  = 0;
           unsigned icount = 0;
           for (jloop = 1; jloop <= isec1[48]; jloop++)
 	    {
@@ -9234,7 +9395,7 @@ void gribPrintSec2DP(int *isec0, int *isec2, double *fsec2)
       fprintf(grprsm, " Number of points along Y axis.               %9d\n", isec2[2]);
       fprintf(grprsm, " Latitude of sub-satellite point.             %9d\n", isec2[3]);
       fprintf(grprsm, " Longitude of sub-satellite point.            %9d\n", isec2[4]);
-      iresol = isec2[17] + isec2[18];
+      //iresol = isec2[17] + isec2[18];
       fprintf(grprsm, " Diameter of the earth in x direction.        %9d\n", isec2[6]);
       fprintf(grprsm, " Y coordinate of sub-satellite point.         %9d\n", isec2[9]);
       ibit = 8;
@@ -9363,7 +9524,7 @@ void gribPrintSec2SP(int *isec0, int *isec2, float  *fsec2sp)
 
   inum = 10 + isec2[11];
 
-  fsec2 = (double*) malloc(inum*sizeof(double));
+  fsec2 = (double*) Malloc(inum*sizeof(double));
   if ( fsec2 == NULL ) SysError("No Memory!");
 
   for ( j = 0; j < inum; j++ )
@@ -9371,7 +9532,7 @@ void gribPrintSec2SP(int *isec0, int *isec2, float  *fsec2sp)
   
   gribPrintSec2DP(isec0, isec2, fsec2);
 
-  free(fsec2);
+  Free(fsec2);
 }
 
 void gribPrintSec3DP(int *isec0, int *isec3, double *fsec3)
@@ -11102,7 +11263,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
 
       /* section 3 */
       sec_len = GRIB2_SECLEN(section);
-      sec_num = GRIB2_SECNUM(section);
+      //sec_num = GRIB2_SECNUM(section);
       //fprintf(stderr, "gds %d %ld\n", sec_num, sec_len);
 
       *gdsp = section;
@@ -11881,7 +12042,7 @@ void repair1(unsigned char *gbuf, long gbufsize)
       long nelem;
       unsigned char *pbuf;
       nelem = sourceLen/3;
-      pbuf = (unsigned char*) malloc(sourceLen);
+      pbuf = (unsigned char*) Malloc(sourceLen);
       for ( i = 0; i < nelem; i++ )
 	{
 	  pbuf[3*i  ] = source[        i];
@@ -11889,7 +12050,7 @@ void repair1(unsigned char *gbuf, long gbufsize)
 	  pbuf[3*i+2] = source[2*nelem+i];
 	}
       memcpy(source, pbuf, sourceLen);
-      free(pbuf);
+      Free(pbuf);
     }
 }
 
@@ -12162,7 +12323,7 @@ int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
       {
 	long nelem;
 	nelem = sourceLen/3;
-	pbuf = (unsigned char*) malloc(sourceLen);
+	pbuf = (unsigned char*) Malloc(sourceLen);
 	for ( i = 0; i < nelem; i++ )
 	  {
 	    pbuf[        i] = source[3*i  ];
@@ -12204,7 +12365,7 @@ int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
       }
 #endif
     
-    if ( pbuf ) free(pbuf);
+    if ( pbuf ) Free(pbuf);
     /*
     fprintf(stderr, "sourceLen, destLen %d %d\n", sourceLen, destLen);
     */
@@ -12520,7 +12681,7 @@ int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
 	long nelem;
 	unsigned char *pbuf;
 	nelem = tmpLen/3;
-	pbuf = (unsigned char*) malloc(tmpLen);
+	pbuf = (unsigned char*) Malloc(tmpLen);
 	for ( i = 0; i < nelem; i++ )
 	  {
 	    pbuf[3*i  ] = dest[        i];
@@ -12528,7 +12689,7 @@ int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
 	    pbuf[3*i+2] = dest[2*nelem+i];
 	  }
 	memcpy(dest, pbuf, tmpLen);
-	free(pbuf);
+        Free(pbuf);
       }
 #endif
 
@@ -12628,14 +12789,14 @@ double calculate_pfactor(const double* spectralField, long fieldTruncation, long
 
   range = (double) (ismax - ismin +1);
 
-  weights = (double*) malloc((ismax+1)*sizeof(double));
+  weights = (double*) Malloc((ismax+1)*sizeof(double));
   for( loop = ismin; loop <= ismax; loop++ )
     weights[loop] = range / (double) (loop-ismin+1);
   /*
   // Compute norms
   // Handle values 2 at a time (real and imaginary parts).
    */
-  norms = (double*) malloc((ismax+1)*sizeof(double));
+  norms = (double*) Malloc((ismax+1)*sizeof(double));
 
   for( loop = 0; loop < ismax+1; loop++ ) norms[loop] = 0.0;
   /*
@@ -12709,8 +12870,8 @@ double calculate_pfactor(const double* spectralField, long fieldTruncation, long
   }
   slope = numerator / denominator;
 
-  free(weights);
-  free(norms);
+  Free(weights);
+  Free(norms);
 
   pFactor = -slope;
   if( pFactor < -9999.9 ) pFactor = -9999.9;
@@ -12904,10 +13065,10 @@ int qu2reg2(double *pfield, int *kpoint, int klat, int klon,
    int iregno, iquano, j210, j220, j230, j240, j225;
 
 
-   zline = (double*) malloc(2*klon*sizeof(double));
+   zline = (double*) Malloc(2*klon*sizeof(double));
    if ( zline == NULL ) SysError("No Memory!");
 
-   zwork = (double*) malloc(3*(2*klon+3)*sizeof(double));
+   zwork = (double*) Malloc(3*(2*klon+3)*sizeof(double));
    if ( zwork == NULL ) SysError("No Memory!");
 
    /* Parameter adjustments */
@@ -13044,8 +13205,8 @@ int qu2reg2(double *pfield, int *kpoint, int klat, int klon,
 
 L900:
 
-   free(zline);
-   free(zwork);
+   Free(zline);
+   Free(zwork);
 
    return 0;
 } /* qu2reg2 */
@@ -13061,7 +13222,7 @@ L900:
 void TEMPLATE(scale_complex,T)(T *fpdata, int pcStart, int pcScale, int trunc, int inv)
 {
   double power;
-  double *scale = (double*) malloc((trunc+1)*sizeof(double));
+  double *scale = (double*) Malloc((trunc+1)*sizeof(double));
   int  n, m;
   int  index;
 
@@ -13114,13 +13275,13 @@ void TEMPLATE(scale_complex,T)(T *fpdata, int pcStart, int pcScale, int trunc, i
 	index += 2;
       }
 
-  free(scale);
+  Free(scale);
 }
 
 
 void TEMPLATE(scatter_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 {
-  T *fphelp = (T*) malloc(nsp*sizeof(T));
+  T *fphelp = (T*) Malloc(nsp*sizeof(T));
   int  m, n;
   int  index, inext;
 
@@ -13153,13 +13314,13 @@ void TEMPLATE(scatter_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 
   for ( m = 0; m < nsp; m++ ) fpdata[m] = fphelp[m];
 
-  free(fphelp);
+  Free(fphelp);
 }
 
 
 void TEMPLATE(gather_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 {
-  T *fphelp = (T*) malloc(nsp*sizeof(T));
+  T *fphelp = (T*) Malloc(nsp*sizeof(T));
   int  m, n;
   int  index, inext;
 
@@ -13192,7 +13353,7 @@ void TEMPLATE(gather_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 
   for ( m = 0; m < nsp; m++ ) fpdata[m] = fphelp[m];
 
-  free(fphelp);
+  Free(fphelp);
 }
 
 
@@ -13596,13 +13757,13 @@ C
    T *zline = NULL;
    T *zwork = NULL;
 
-   ztemp = (T*) malloc(klon*klat*sizeof(T));
+   ztemp = (T*) Malloc(klon*klat*sizeof(T));
    if ( ztemp == NULL ) SysError("No Memory!");
 
-   zline = (T*) malloc(2*klon*sizeof(T));
+   zline = (T*) Malloc(2*klon*sizeof(T));
    if ( zline == NULL ) SysError("No Memory!");
 
-   zwork = (T*) malloc(3*(2*klon+3)*sizeof(T));
+   zwork = (T*) Malloc(3*(2*klon+3)*sizeof(T));
    if ( zwork == NULL ) SysError("No Memory!");
 
    /* Parameter adjustments */
@@ -13706,9 +13867,9 @@ C
 
 L900:
 
-   free(zwork);
-   free(zline);
-   free(ztemp);
+   Free(zwork);
+   Free(zline);
+   Free(ztemp);
 
    return 0;
 } /* qu2reg3 */
@@ -13724,7 +13885,7 @@ L900:
 void TEMPLATE(scale_complex,T)(T *fpdata, int pcStart, int pcScale, int trunc, int inv)
 {
   double power;
-  double *scale = (double*) malloc((trunc+1)*sizeof(double));
+  double *scale = (double*) Malloc((trunc+1)*sizeof(double));
   int  n, m;
   int  index;
 
@@ -13777,13 +13938,13 @@ void TEMPLATE(scale_complex,T)(T *fpdata, int pcStart, int pcScale, int trunc, i
 	index += 2;
       }
 
-  free(scale);
+  Free(scale);
 }
 
 
 void TEMPLATE(scatter_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 {
-  T *fphelp = (T*) malloc(nsp*sizeof(T));
+  T *fphelp = (T*) Malloc(nsp*sizeof(T));
   int  m, n;
   int  index, inext;
 
@@ -13816,13 +13977,13 @@ void TEMPLATE(scatter_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 
   for ( m = 0; m < nsp; m++ ) fpdata[m] = fphelp[m];
 
-  free(fphelp);
+  Free(fphelp);
 }
 
 
 void TEMPLATE(gather_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 {
-  T *fphelp = (T*) malloc(nsp*sizeof(T));
+  T *fphelp = (T*) Malloc(nsp*sizeof(T));
   int  m, n;
   int  index, inext;
 
@@ -13855,7 +14016,7 @@ void TEMPLATE(gather_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 
   for ( m = 0; m < nsp; m++ ) fpdata[m] = fphelp[m];
 
-  free(fphelp);
+  Free(fphelp);
 }
 
 
@@ -14259,13 +14420,13 @@ C
    T *zline = NULL;
    T *zwork = NULL;
 
-   ztemp = (T*) malloc(klon*klat*sizeof(T));
+   ztemp = (T*) Malloc(klon*klat*sizeof(T));
    if ( ztemp == NULL ) SysError("No Memory!");
 
-   zline = (T*) malloc(2*klon*sizeof(T));
+   zline = (T*) Malloc(2*klon*sizeof(T));
    if ( zline == NULL ) SysError("No Memory!");
 
-   zwork = (T*) malloc(3*(2*klon+3)*sizeof(T));
+   zwork = (T*) Malloc(3*(2*klon+3)*sizeof(T));
    if ( zwork == NULL ) SysError("No Memory!");
 
    /* Parameter adjustments */
@@ -14369,9 +14530,9 @@ C
 
 L900:
 
-   free(zwork);
-   free(zline);
-   free(ztemp);
+   Free(zwork);
+   Free(zline);
+   Free(ztemp);
 
    return 0;
 } /* qu2reg3 */
@@ -14779,7 +14940,7 @@ void TEMPLATE(decode_array,T)(const unsigned char *restrict igrib, long jlend, i
       long jlenc = jlend * numBits / 8;
       if ( jlenc > 0 ) 
 	{
-	  lgrib = (GRIBPACK*) malloc(jlenc*sizeof(GRIBPACK));
+	  lgrib = (GRIBPACK*) Malloc(jlenc*sizeof(GRIBPACK));
 	  if ( lgrib == NULL ) SysError("No Memory!");
 
 	  (void) UNPACK_GRIB(igrib, lgrib, jlenc, -1L);
@@ -14830,7 +14991,7 @@ void TEMPLATE(decode_array,T)(const unsigned char *restrict igrib, long jlend, i
       Error("Unimplemented packing factor %d!", numBits);
     }
 
-  if ( lgrib ) free(lgrib);
+  if ( lgrib ) Free(lgrib);
 
 #else
   if ( numBits ==  0 )
@@ -15037,7 +15198,7 @@ void TEMPLATE(decode_array,T)(const unsigned char *restrict igrib, long jlend, i
       long jlenc = jlend * numBits / 8;
       if ( jlenc > 0 ) 
 	{
-	  lgrib = (GRIBPACK*) malloc(jlenc*sizeof(GRIBPACK));
+	  lgrib = (GRIBPACK*) Malloc(jlenc*sizeof(GRIBPACK));
 	  if ( lgrib == NULL ) SysError("No Memory!");
 
 	  (void) UNPACK_GRIB(igrib, lgrib, jlenc, -1L);
@@ -15088,7 +15249,7 @@ void TEMPLATE(decode_array,T)(const unsigned char *restrict igrib, long jlend, i
       Error("Unimplemented packing factor %d!", numBits);
     }
 
-  if ( lgrib ) free(lgrib);
+  if ( lgrib ) Free(lgrib);
 
 #else
   if ( numBits ==  0 )
@@ -15399,7 +15560,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
 	}
 #if defined (SX)
       lGribLen = 4*ISEC2_NumVCP;	      
-      lgrib    = (GRIBPACK*) malloc(lGribLen*sizeof(GRIBPACK));
+      lgrib    = (GRIBPACK*) Malloc(lGribLen*sizeof(GRIBPACK));
 
       igrib = &gds[locnv];
       if ( ISEC2_NumVCP > 0 ) (void) UNPACK_GRIB(igrib, lgrib, lGribLen, -1L);
@@ -15412,7 +15573,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
 	  fsec2[10+i] = POW_2_M24 * imant * pow(16.0, (double)(iexp - 64));
 	}
 
-      free(lgrib);
+      Free(lgrib);
 #else
       for ( i = 0; i < ISEC2_NumVCP; i++ )
 	{
@@ -15545,7 +15706,7 @@ int TEMPLATE(decodeBDS,T)(int decscale, unsigned char *bds, int *isec2, int *ise
 	{
 	  /*    no unpacked binary data present */
 
-	  jup = kup = mup = 0;
+	  //jup = kup = mup = 0;
 
 	  /*    octet number of start of packed data */
 	  /*    calculated from start of block 4 - 1 */
@@ -15946,7 +16107,7 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 	    }
 	  */
 
-	  imask = (GRIBPACK*) malloc(imaskSize*sizeof(GRIBPACK));
+	  imask = (GRIBPACK*) Malloc(imaskSize*sizeof(GRIBPACK));
 
 #if defined (VECTORCODE)
 	  (void) UNPACK_GRIB(BMS_Bitmap, imask, imaskSize/8, -1L);
@@ -16005,17 +16166,16 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 		fsec4[i] = imask[i] ? fsec4[--j] : FSEC3_MissVal;
 	    }
 
-	  free(imask);
+	  Free(imask);
 	}
     }
 
   if ( ISEC2_Reduced )
     {
       int nlon, nlat;
-      int lsect3, lperio = 1, lveggy;
+      int lperio = 1, lveggy;
       int ilat;
       int nvalues = 0;
-      int dlon;
 
       nlat = ISEC2_NumLat;
       nlon = ISEC2_RowLonPtr[0];
@@ -16023,8 +16183,8 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
       for ( ilat = 1; ilat < nlat; ++ilat )
 	if ( ISEC2_RowLon(ilat) > nlon ) nlon = ISEC2_RowLon(ilat);
 
-      dlon = ISEC2_LastLon-ISEC2_FirstLon;
-      if ( dlon < 0 ) dlon += 360000;
+      // int dlon = ISEC2_LastLon-ISEC2_FirstLon;
+      // if ( dlon < 0 ) dlon += 360000;
 	  
       if ( nvalues != ISEC4_NumValues )
 	{
@@ -16332,7 +16492,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
 	}
 #if defined (SX)
       lGribLen = 4*ISEC2_NumVCP;	      
-      lgrib    = (GRIBPACK*) malloc(lGribLen*sizeof(GRIBPACK));
+      lgrib    = (GRIBPACK*) Malloc(lGribLen*sizeof(GRIBPACK));
 
       igrib = &gds[locnv];
       if ( ISEC2_NumVCP > 0 ) (void) UNPACK_GRIB(igrib, lgrib, lGribLen, -1L);
@@ -16345,7 +16505,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
 	  fsec2[10+i] = POW_2_M24 * imant * pow(16.0, (double)(iexp - 64));
 	}
 
-      free(lgrib);
+      Free(lgrib);
 #else
       for ( i = 0; i < ISEC2_NumVCP; i++ )
 	{
@@ -16478,7 +16638,7 @@ int TEMPLATE(decodeBDS,T)(int decscale, unsigned char *bds, int *isec2, int *ise
 	{
 	  /*    no unpacked binary data present */
 
-	  jup = kup = mup = 0;
+	  //jup = kup = mup = 0;
 
 	  /*    octet number of start of packed data */
 	  /*    calculated from start of block 4 - 1 */
@@ -16879,7 +17039,7 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 	    }
 	  */
 
-	  imask = (GRIBPACK*) malloc(imaskSize*sizeof(GRIBPACK));
+	  imask = (GRIBPACK*) Malloc(imaskSize*sizeof(GRIBPACK));
 
 #if defined (VECTORCODE)
 	  (void) UNPACK_GRIB(BMS_Bitmap, imask, imaskSize/8, -1L);
@@ -16938,17 +17098,16 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 		fsec4[i] = imask[i] ? fsec4[--j] : FSEC3_MissVal;
 	    }
 
-	  free(imask);
+	  Free(imask);
 	}
     }
 
   if ( ISEC2_Reduced )
     {
       int nlon, nlat;
-      int lsect3, lperio = 1, lveggy;
+      int lperio = 1, lveggy;
       int ilat;
       int nvalues = 0;
-      int dlon;
 
       nlat = ISEC2_NumLat;
       nlon = ISEC2_RowLonPtr[0];
@@ -16956,8 +17115,8 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
       for ( ilat = 1; ilat < nlat; ++ilat )
 	if ( ISEC2_RowLon(ilat) > nlon ) nlon = ISEC2_RowLon(ilat);
 
-      dlon = ISEC2_LastLon-ISEC2_FirstLon;
-      if ( dlon < 0 ) dlon += 360000;
+      // int dlon = ISEC2_LastLon-ISEC2_FirstLon;
+      // if ( dlon < 0 ) dlon += 360000;
 	  
       if ( nvalues != ISEC4_NumValues )
 	{
@@ -17058,7 +17217,8 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 static
 void encodeIS(GRIBPACK *lGrib, long *gribLen)
 {
-  long z = *gribLen;
+  long z;
+  // z = *gribLen;
 
   lGrib[0] = 'G';
   lGrib[1] = 'R';
@@ -18503,7 +18663,7 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
   fsec4size = 0;
 
 #if defined (VECTORCODE)
-  imask = (unsigned int*) malloc(imaskSize*sizeof(unsigned int));
+  imask = (unsigned int*) Malloc(imaskSize*sizeof(unsigned int));
   memset(imask, 0, imaskSize*sizeof(int));
 
 #if defined (CRAY)
@@ -18541,7 +18701,7 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
 	          (imask[i*8+6] << 1) | (imask[i*8+7]);
     }
 
-  free(imask);
+  Free(imask);
 #else
   for ( i = 0; i < imaskSize/8; i++ ) bitmap[i] = 0;
 
@@ -18880,7 +19040,7 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
   if ( bmsIncluded ) len += (klenp+7)>>3;
 
 #if defined (VECTORCODE)
-  lGrib = (GRIBPACK*) malloc(len*sizeof(GRIBPACK));
+  lGrib = (GRIBPACK*) Malloc(len*sizeof(GRIBPACK));
   if ( lGrib == NULL ) SysError("No Memory!");
 #else
   lGrib = CGrib;
@@ -18942,7 +19102,7 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 
   (void) PACK_GRIB(lGrib, (unsigned char *)CGrib, gribLen, -1L);
 
-  free(lGrib);
+  Free(lGrib);
 #endif
 
   ISEC0_GRIB_Len     = gribLen;
@@ -19122,7 +19282,7 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
   fsec4size = 0;
 
 #if defined (VECTORCODE)
-  imask = (unsigned int*) malloc(imaskSize*sizeof(unsigned int));
+  imask = (unsigned int*) Malloc(imaskSize*sizeof(unsigned int));
   memset(imask, 0, imaskSize*sizeof(int));
 
 #if defined (CRAY)
@@ -19160,7 +19320,7 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
 	          (imask[i*8+6] << 1) | (imask[i*8+7]);
     }
 
-  free(imask);
+  Free(imask);
 #else
   for ( i = 0; i < imaskSize/8; i++ ) bitmap[i] = 0;
 
@@ -19499,7 +19659,7 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
   if ( bmsIncluded ) len += (klenp+7)>>3;
 
 #if defined (VECTORCODE)
-  lGrib = (GRIBPACK*) malloc(len*sizeof(GRIBPACK));
+  lGrib = (GRIBPACK*) Malloc(len*sizeof(GRIBPACK));
   if ( lGrib == NULL ) SysError("No Memory!");
 #else
   lGrib = CGrib;
@@ -19561,7 +19721,7 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 
   (void) PACK_GRIB(lGrib, (unsigned char *)CGrib, gribLen, -1L);
 
-  free(lGrib);
+  Free(lGrib);
 #endif
 
   ISEC0_GRIB_Len     = gribLen;
@@ -19580,7 +19740,7 @@ void encode_dummy(void)
   (void) encode_array_unrolled_double(0, 0, 0, NULL, NULL, 0, 0, NULL);
   (void) encode_array_unrolled_float(0, 0, 0, NULL, NULL, 0, 0, NULL);
 }
-static const char grb_libvers[] = "1.7.2" " of ""Apr 22 2015"" ""13:44:04";
+static const char grb_libvers[] = "1.7.3" " of ""Sep 14 2015"" ""10:58:44";
 const char *
 cgribexLibraryVersion(void)
 {
@@ -19703,6 +19863,7 @@ memcrc_r(uint32_t *state, const unsigned char *block, size_t block_len)
   *state = s;
 }
 
+#ifdef WORDS_BIGENDIAN
 #define SWAP_CSUM(BITWIDTH,BYTEWIDTH,NACC)                              \
   do {                                                                  \
     register const uint##BITWIDTH##_t *b = (uint##BITWIDTH##_t *)elems; \
@@ -19717,7 +19878,7 @@ memcrc_r(uint32_t *state, const unsigned char *block, size_t block_len)
       }                                                                 \
     }                                                                   \
   } while (0)
-
+#endif
 
 
 /**
@@ -19794,7 +19955,6 @@ memcrc_finish(uint32_t *state, off_t total_size)
 #include <stdarg.h>
 #include <errno.h>
 
-
 #if !defined(HAVE_CONFIG_H) && !defined(HAVE_MALLOC_H) && defined(SX)
 #  define  HAVE_MALLOC_H
 #endif
@@ -19803,38 +19963,27 @@ memcrc_finish(uint32_t *state, off_t total_size)
 #  include <malloc.h>
 #endif
 
-//There is no point in avoiding to include our own header, it is likely to be included before this file in the backed cdilib.c.
-//As such, we may as well always include it and let the compiler check our function signatures.
 
-//However, we need to avoid clobbering our own `malloc()` calls, so we ensure that our own malloc calls cannot be interpreted as macro calls.
-#define protected_realloc (realloc)
-#define protected_calloc (calloc)
-#define protected_malloc (malloc)
-#define protected_free (free)
+enum             {MALLOC_FUNC=0, CALLOC_FUNC, REALLOC_FUNC, FREE_FUNC};
+static const char *memfunc[] = {"Malloc", "Calloc", "Realloc", "Free"};
 
+#undef   MEM_UNDEFID
+#define  MEM_UNDEFID  -1
 
-#define  MALLOC_FUNC   0
-#define  CALLOC_FUNC   1
-#define  REALLOC_FUNC  2
-#define  FREE_FUNC     3
+#define  MEM_MAXNAME  32   /* Min = 8, for  "unknown" ! */
 
-#undef   UNDEFID
-#define  UNDEFID  -1
-
-#define  MAXNAME  32   /* Min = 8, for  "unknown" ! */
-
-int dmemory_ExitOnError = 0;
+static int dmemory_ExitOnError = 1;
 
 typedef struct
 {
   void     *ptr;
-  int       item;
   size_t    size;
   size_t    nobj;
+  int       item;
   int       mtype;
   int       line;
-  char      file[MAXNAME];
-  char      caller[MAXNAME];
+  char      filename[MEM_MAXNAME];
+  char      functionname[MEM_MAXNAME];
 }
 MemTable_t;
 
@@ -19848,21 +19997,45 @@ static size_t  MemUsed       = 0;
 static size_t  MaxMemUsed    = 0;
 
 static int     MEM_Debug     = 0;   /* If set to 1, debugging */
+static int     MEM_Info      = 0;   /* If set to 1, print mem table at exit */
+
+static
+const char *get_filename(const char *file)
+{
+  const char *fnptr = strrchr(file, '/');
+  if ( fnptr ) fnptr++;
+  else         fnptr = (char *) file;
+
+  return fnptr;
+}
+
 
 void memDebug(int debug)
 {
   MEM_Debug = debug;
 }
 
+/* If we're not using GNU C, elide __attribute__ */
+#if ! defined __GNUC__ && ! defined __attribute__
+#  define  __attribute__(x)  /*NOTHING*/
+#endif
+
 static
 void memInternalProblem(const char *caller, const char *fmt, ...)
+  __attribute__((noreturn));
+static
+void memError(const char *caller, const char *file, int line, size_t size)
+  __attribute__((noreturn));
+
+static
+void memInternalProblem(const char *functionname, const char *fmt, ...)
 {
   va_list args;
 
   va_start(args, fmt);
 
   printf("\n");
-   fprintf(stderr, "Internal problem (%s) : ", caller);
+   fprintf(stderr, "Internal problem (%s) : ", functionname);
   vfprintf(stderr, fmt, args);
    fprintf(stderr, "\n");
 
@@ -19872,11 +20045,11 @@ void memInternalProblem(const char *caller, const char *fmt, ...)
 }
 
 static
-void memError(const char *caller, const char *file, int line, size_t size)
+void memError(const char *functionname, const char *file, int line, size_t size)
 {
-  printf("\n");
+  fputs("\n", stdout);
   fprintf(stderr, "Error (%s) : Allocation of %zu bytes failed. [ line %d file %s ]\n",
-	  caller, size, line, file);
+	  functionname, size, line, get_filename(file));
 
   if ( errno ) perror("System error message ");
 
@@ -19885,64 +20058,36 @@ void memError(const char *caller, const char *file, int line, size_t size)
 
 static
 void memListPrintEntry(int mtype, int item, size_t size, void *ptr,
-		       const char *caller, const char *file, int line)
+		       const char *functionname, const char *file, int line)
 {
-  switch (mtype)
+  fprintf(stderr, "[%-7s ", memfunc[mtype]);
+
+  fprintf(stderr, "memory item %3d ", item);
+  fprintf(stderr, "(%6zu byte) ", size);
+  fprintf(stderr, "at %p", ptr);
+  if ( file != NULL )
     {
-    case MALLOC_FUNC:
-      fprintf(stderr, "[%-7s ", "Malloc");
-      break;
-    case CALLOC_FUNC:
-      fprintf(stderr, "[%-7s ", "Calloc");
-      break;
-    case REALLOC_FUNC:
-      fprintf(stderr, "[%-7s ", "Realloc");
-      break;
-    case FREE_FUNC:
-      fprintf(stderr, "[%-7s ", "Free");
-      break;
+      fprintf(stderr, " line %4d", line);
+      fprintf(stderr, " file %s", get_filename(file));
     }
-
-   fprintf(stderr, "memory item %3d ", item);
-   fprintf(stderr, "(%6zu byte) ", size);
-   fprintf(stderr, "at %p", ptr);
-   if ( file != NULL )
-     {
-       fprintf(stderr, " line %4d", line);
-       fprintf(stderr, " file %s", file);
-     }
-   if ( caller != NULL )
-     fprintf(stderr, " (%s)", caller);
-   fprintf(stderr, "]\n");
+  if ( functionname != NULL )
+    fprintf(stderr, " (%s)", functionname);
+  fprintf(stderr, "]\n");
 }
 
 static
 void memListPrintTable(void)
 {
-  int item, item1, item2 = 0;
-
   if ( MemObjs ) fprintf(stderr, "\nMemory table:\n");
 
-  /* find maximum item */
-  for (size_t memID = 0; memID < memTableSize; memID++)
-    if ( memTable[memID].item != UNDEFID )
-      if ( memTable[memID].item > item2 ) item2 = memTable[memID].item;
-
-  /* find minimum item */
-  item1 = item2;
-  for (size_t memID = 0; memID < memTableSize; memID++)
-    if ( memTable[memID].item != UNDEFID )
-      if ( memTable[memID].item < item1 ) item1 = memTable[memID].item;
-
-  for ( item = item1; item <= item2; item++ )
-    for (size_t memID = 0; memID < memTableSize; memID++)
-      {
-	if ( memTable[memID].item == item )
-	  memListPrintEntry(memTable[memID].mtype, memTable[memID].item,
-			    memTable[memID].size*memTable[memID].nobj,
-			    memTable[memID].ptr, memTable[memID].caller,
-			    memTable[memID].file, memTable[memID].line);
-      }
+  for ( size_t memID = 0; memID < memTableSize; memID++ )
+    {
+      if ( memTable[memID].item != MEM_UNDEFID )
+        memListPrintEntry(memTable[memID].mtype, memTable[memID].item,
+                          memTable[memID].size*memTable[memID].nobj,
+                          memTable[memID].ptr, memTable[memID].functionname,
+                          memTable[memID].filename, memTable[memID].line);
+    }
 
   if ( MemObjs )
     {
@@ -19978,18 +20123,17 @@ void memListPrintTable(void)
 static
 void memGetDebugLevel(void)
 {
-  char *debugLevel;
+  const char *envstr;
 
-  debugLevel = getenv("MEMORY_DEBUG");
+  envstr = getenv("MEMORY_INFO");
+  if ( envstr && isdigit((int) envstr[0]) ) MEM_Info = atoi(envstr);
 
-  if ( debugLevel )
-    {
-      if ( isdigit((int) debugLevel[0]) )
-	MEM_Debug = atoi(debugLevel);
+  envstr = getenv("MEMORY_DEBUG");
+  if ( envstr && isdigit((int) envstr[0]) ) MEM_Debug = atoi(envstr);
 
-      if ( MEM_Debug )
-	atexit(memListPrintTable);
-    }
+  if ( MEM_Debug && !MEM_Info ) MEM_Info = 1;
+
+  if ( MEM_Info ) atexit(memListPrintTable);
 }
 
 static
@@ -20007,12 +20151,12 @@ void memInit(void)
 static
 int memListDeleteEntry(void *ptr, size_t *size)
 {
-  int item = UNDEFID;
+  int item = MEM_UNDEFID;
   size_t memID;
 
-  for (memID = 0; memID < memTableSize; memID++ )
+  for ( memID = 0; memID < memTableSize; memID++ )
     {
-      if ( memTable[memID].item == UNDEFID ) continue;
+      if ( memTable[memID].item == MEM_UNDEFID ) continue;
       if ( memTable[memID].ptr == ptr ) break;
     }
 
@@ -20021,11 +20165,11 @@ int memListDeleteEntry(void *ptr, size_t *size)
       MemObjs--;
       MemUsed -= memTable[memID].size * memTable[memID].nobj;
       *size = memTable[memID].size * memTable[memID].nobj;
-       item = memTable[memID].item;
-       memTable[memID].item   = UNDEFID;
+      item = memTable[memID].item;
+      memTable[memID].item = MEM_UNDEFID;
     }
 
-  return (item);
+  return item;
 }
 
 static
@@ -20035,16 +20179,16 @@ void memTableInitEntry(size_t memID)
     memInternalProblem(__func__, "memID %d undefined!", memID);
 
   memTable[memID].ptr    = NULL;
-  memTable[memID].item   = UNDEFID;
+  memTable[memID].item   = MEM_UNDEFID;
   memTable[memID].size   = 0;
   memTable[memID].nobj   = 0;
-  memTable[memID].mtype  = UNDEFID;
-  memTable[memID].line   = UNDEFID;
+  memTable[memID].mtype  = MEM_UNDEFID;
+  memTable[memID].line   = MEM_UNDEFID;
 }
 
 static
 int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
-		    const char *caller, const char *file, int line)
+		    const char *functionname, const char *file, int line)
 {
   static int item = 0;
   size_t memSize = 0;
@@ -20058,17 +20202,17 @@ int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
     {
       memTableSize = 8;
       memSize  = memTableSize * sizeof(MemTable_t);
-      memTable = (MemTable_t *) protected_malloc(memSize);
+      memTable = (MemTable_t *) malloc(memSize);
       if( memTable == NULL ) memError(__func__, __FILE__, __LINE__, memSize);
 
-      for(size_t i = 0; i < memTableSize; i++)
+      for ( size_t i = 0; i < memTableSize; i++ )
 	memTableInitEntry(i);
     }
   else
     {
-      while( memID < memTableSize )
+      while ( memID < memTableSize )
 	{
-	  if ( memTable[memID].item == UNDEFID ) break;
+	  if ( memTable[memID].item == MEM_UNDEFID ) break;
 	  memID++;
 	}
     }
@@ -20079,10 +20223,10 @@ int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
     {
       memTableSize = 2*memTableSize;
       memSize  = memTableSize*sizeof(MemTable_t);
-      memTable = (MemTable_t*) protected_realloc(memTable, memSize);
-      if( memTable == NULL ) memError(__func__, __FILE__, __LINE__, memSize);
+      memTable = (MemTable_t*) realloc(memTable, memSize);
+      if ( memTable == NULL ) memError(__func__, __FILE__, __LINE__, memSize);
 
-      for (size_t i = memID; i < memTableSize; i++)
+      for ( size_t i = memID; i < memTableSize; i++ )
 	memTableInitEntry(i);
     }
 
@@ -20095,28 +20239,29 @@ int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
 
   if ( file )
     {
-      size_t len = strlen(file);
-      if ( len > MAXNAME-1 ) len = MAXNAME-1;
+      const char *filename = get_filename(file);
+      size_t len = strlen(filename);
+      if ( len > MEM_MAXNAME-1 ) len = MEM_MAXNAME-1;
 
-      (void) memcpy(memTable[memID].file, file, len);
-      memTable[memID].file[len] = '\0';
+      (void) memcpy(memTable[memID].filename, filename, len);
+      memTable[memID].filename[len] = '\0';
     }
   else
     {
-      (void) strcpy(memTable[memID].file, "unknown");
+      (void) strcpy(memTable[memID].filename, "unknown");
     }
 
-  if ( caller )
+  if ( functionname )
     {
-      size_t len = strlen(caller);
-      if ( len > MAXNAME-1 ) len = MAXNAME-1;
+      size_t len = strlen(functionname);
+      if ( len > MEM_MAXNAME-1 ) len = MEM_MAXNAME-1;
 
-      (void) memcpy(memTable[memID].caller, caller, len);
-      memTable[memID].caller[len] = '\0';
+      (void) memcpy(memTable[memID].functionname, functionname, len);
+      memTable[memID].functionname[len] = '\0';
     }
   else
     {
-      (void) strcpy(memTable[memID].caller, "unknown");
+      (void) strcpy(memTable[memID].functionname, "unknown");
     }
 
   MaxMemObjs++;
@@ -20124,20 +20269,19 @@ int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
   MemUsed += size*nobj;
   if ( MemUsed > MaxMemUsed ) MaxMemUsed = MemUsed;
 
-  return (item++);
+  return item++;
 }
 
 static
 int memListChangeEntry(void *ptrold, void *ptr, size_t size,
-		       const char *caller, const char *file, int line)
+		       const char *functionname, const char *file, int line)
 {
-  int item = UNDEFID;
+  int item = MEM_UNDEFID;
   size_t memID = 0;
-  size_t sizeold;
 
   while( memID < memTableSize )
     {
-      if ( memTable[memID].item != UNDEFID )
+      if ( memTable[memID].item != MEM_UNDEFID )
 	if ( memTable[memID].ptr == ptrold ) break;
       memID++;
     }
@@ -20151,7 +20295,7 @@ int memListChangeEntry(void *ptrold, void *ptr, size_t size,
     {
       item = memTable[memID].item;
 
-      sizeold = memTable[memID].size*memTable[memID].nobj;
+      size_t sizeold = memTable[memID].size*memTable[memID].nobj;
 
       memTable[memID].ptr   = ptr;
       memTable[memID].size  = size;
@@ -20161,28 +20305,29 @@ int memListChangeEntry(void *ptrold, void *ptr, size_t size,
 
       if ( file )
 	{
-	  size_t len = strlen(file);
-	  if ( len > MAXNAME-1 ) len = MAXNAME-1;
+          const char *filename = get_filename(file);
+	  size_t len = strlen(filename);
+	  if ( len > MEM_MAXNAME-1 ) len = MEM_MAXNAME-1;
 
-	  (void) memcpy(memTable[memID].file, file, len);
-	  memTable[memID].file[len] = '\0';
+	  (void) memcpy(memTable[memID].filename, filename, len);
+	  memTable[memID].filename[len] = '\0';
 	}
       else
 	{
-	  (void) strcpy(memTable[memID].file, "unknown");
+	  (void) strcpy(memTable[memID].filename, "unknown");
 	}
 
-      if ( caller )
+      if ( functionname )
 	{
-	  size_t len = strlen(caller);
-	  if ( len > MAXNAME-1 ) len = MAXNAME-1;
+	  size_t len = strlen(functionname);
+	  if ( len > MEM_MAXNAME-1 ) len = MEM_MAXNAME-1;
 
-	  (void) memcpy(memTable[memID].caller, caller, len);
-	  memTable[memID].caller[len] = '\0';
+	  (void) memcpy(memTable[memID].functionname, functionname, len);
+	  memTable[memID].functionname[len] = '\0';
 	}
       else
 	{
-	  (void) strcpy(memTable[memID].caller, "unknown");
+	  (void) strcpy(memTable[memID].functionname, "unknown");
 	}
 
       MemUsed -= sizeold;
@@ -20190,155 +20335,129 @@ int memListChangeEntry(void *ptrold, void *ptr, size_t size,
       if ( MemUsed > MaxMemUsed ) MaxMemUsed = MemUsed;
     }
 
-  return (item);
+  return item;
 }
 
 
-void *Calloc(const char *caller, const char *file, int line, size_t nobjs, size_t size)
+void *memCalloc(size_t nobjs, size_t size, const char *file, const char *functionname, int line)
 {
   void *ptr = NULL;
-  int item = UNDEFID;
 
   memInit();
 
   if ( nobjs*size > 0 )
     {
-      ptr = protected_calloc(nobjs, size);
+      ptr = calloc(nobjs, size);
 
-      if ( MEM_Debug )
+      if ( MEM_Info )
 	{
 	  memAccess++;
 
-	  if ( ptr ) item = memListNewEntry(CALLOC_FUNC, ptr, size, nobjs, caller, file, line);
+          int item = MEM_UNDEFID;
+	  if ( ptr ) item = memListNewEntry(CALLOC_FUNC, ptr, size, nobjs, functionname, file, line);
 
-	  memListPrintEntry(CALLOC_FUNC, item, size*nobjs, ptr, caller, file, line);
+	  if ( MEM_Debug ) memListPrintEntry(CALLOC_FUNC, item, size*nobjs, ptr, functionname, file, line);
 	}
 
       if ( ptr == NULL && dmemory_ExitOnError )
-	memError(caller, file, line, size*nobjs);
+	memError(functionname, file, line, size*nobjs);
     }
   else
-    fprintf(stderr, "Warning (%s) : Allocation of 0 bytes! [ line %d file %s ]\n", caller, line, file);
+    fprintf(stderr, "Warning (%s) : Allocation of 0 bytes! [ line %d file %s ]\n", functionname, line, file);
 
-  return(ptr);
+  return ptr;
 }
 
 
-void *Malloc(const char *caller, const char *file, int line, size_t size)
+void *memMalloc(size_t size, const char *file, const char *functionname, int line)
 {
   void *ptr = NULL;
-  int item = UNDEFID;
 
   memInit();
 
   if ( size > 0 )
     {
-      ptr = protected_malloc(size);
+      ptr = malloc(size);
 
-      if ( MEM_Debug )
+      if ( MEM_Info )
 	{
 	  memAccess++;
 
-	  if ( ptr ) item = memListNewEntry(MALLOC_FUNC, ptr, size, 1, caller, file, line);
+          int item = MEM_UNDEFID;
+	  if ( ptr ) item = memListNewEntry(MALLOC_FUNC, ptr, size, 1, functionname, file, line);
 
-	  memListPrintEntry(MALLOC_FUNC, item, size, ptr, caller, file, line);
+	  if ( MEM_Debug ) memListPrintEntry(MALLOC_FUNC, item, size, ptr, functionname, file, line);
 	}
 
       if ( ptr == NULL && dmemory_ExitOnError )
-	memError(caller, file, line, size);
+	memError(functionname, file, line, size);
     }
   else
-    fprintf(stderr, "Warning (%s) : Allocation of 0 bytes! [ line %d file %s ]\n", caller, line, file);
+    fprintf(stderr, "Warning (%s) : Allocation of 0 bytes! [ line %d file %s ]\n", functionname, line, file);
 
-  return (ptr);
+  return ptr;
 }
 
 
-void *Realloc(const char *caller, const char *file, int line, void *ptrold, size_t size)
+void *memRealloc(void *ptrold, size_t size, const char *file, const char *functionname, int line)
 {
   void *ptr = NULL;
-  int item = UNDEFID;
 
   memInit();
 
   if ( size > 0 )
     {
-      ptr = protected_realloc(ptrold, size);
+      ptr = realloc(ptrold, size);
 
-      if ( MEM_Debug )
+      if ( MEM_Info )
 	{
 	  memAccess++;
 
+          int item = MEM_UNDEFID;
 	  if ( ptr )
 	    {
-	      item = memListChangeEntry(ptrold, ptr, size, caller, file, line);
+	      item = memListChangeEntry(ptrold, ptr, size, functionname, file, line);
 
-	      if ( item == UNDEFID ) item = memListNewEntry(REALLOC_FUNC, ptr, size, 1, caller, file, line);
+	      if ( item == MEM_UNDEFID ) item = memListNewEntry(REALLOC_FUNC, ptr, size, 1, functionname, file, line);
 	    }
 
-	  memListPrintEntry(REALLOC_FUNC, item, size, ptr, caller, file, line);
+	  if ( MEM_Debug ) memListPrintEntry(REALLOC_FUNC, item, size, ptr, functionname, file, line);
 	}
 
       if ( ptr == NULL && dmemory_ExitOnError )
-	memError(caller, file, line, size);
+	memError(functionname, file, line, size);
     }
   else
-    fprintf(stderr, "Warning (%s) : Allocation of 0 bytes! [ line %d file %s ]\n", caller, line, file);
+    fprintf(stderr, "Warning (%s) : Allocation of 0 bytes! [ line %d file %s ]\n", functionname, line, get_filename(file));
 
-  return (ptr);
+  return ptr;
 }
 
 
-void Free(const char *caller, const char *file, int line, void *ptr)
+void memFree(void *ptr, const char *file, const char *functionname, int line)
 {
-  int item;
-  size_t size;
-
   memInit();
 
-  if ( MEM_Debug )
+  if ( MEM_Info )
     {
+      int item;
+      size_t size;
+
       if ( (item = memListDeleteEntry(ptr, &size)) >= 0 )
 	{
-	  memListPrintEntry(FREE_FUNC, item, size, ptr, caller, file, line);
+	  if ( MEM_Debug ) memListPrintEntry(FREE_FUNC, item, size, ptr, functionname, file, line);
 	}
       else
 	{
-	  if ( ptr )
+	  if ( ptr && MEM_Debug  )
 	    fprintf(stderr, "%s info: memory entry at %p not found. [line %4d file %s (%s)]\n",
-		    __func__, ptr, line, file, caller);
+		    __func__, ptr, line, get_filename(file), functionname);
 	}
     }
 
-  protected_free(ptr);
+  free(ptr);
 }
 
-void *cdiXmalloc(size_t size, const char *filename, const char *functionname,
-                 int line)
-{
-  void *value = protected_malloc(size);
-  if (size == 0 || value != NULL) ; else
-    cdiAbort(filename, functionname, line, "malloc failed: %s", strerror(errno));
-  return value;
-}
-
-void *cdiXcalloc(size_t nmemb, size_t size, const char *filename,
-                 const char *functionname, int line)
-{
-  void *value = protected_calloc(nmemb, size);
-  if (size == 0 || value != NULL) ; else
-    cdiAbort(filename, functionname, line, "calloc failed: %s", strerror(errno) );
-  return value;
-}
-
-void *cdiXrealloc(void *p, size_t size, const char *functionname,
-                  const char *filename, int line)
-{
-  void *value = protected_realloc(p, size);
-  if (size == 0 || value != NULL) ; else
-    cdiAbort(filename, functionname, line, "realloc failed: %s", strerror(errno));
-  return value;
-}
 
 size_t memTotal(void)
 {
@@ -20364,7 +20483,7 @@ size_t memTotal(void)
   memtotal = (size_t)meminfo.arena;
 #endif
 
-  return (memtotal);
+  return memtotal;
 }
 
 
@@ -20396,6 +20515,13 @@ int _ExitOnError   = 1;	/* If set to 1, exit on error       */
 int _Verbose = 1;	/* If set to 1, errors are reported */
 int _Debug   = 0;       /* If set to 1, debugging           */
 
+/* If we're not using GNU C, elide __attribute__ */
+#if ! defined __GNUC__ && ! defined __attribute__
+#  define  __attribute__(x)  /*NOTHING*/
+#endif
+
+void SysError_(const char *caller, const char *fmt, ...)
+  __attribute__((noreturn));
 
 void SysError_(const char *caller, const char *fmt, ...)
 {
@@ -20514,41 +20640,26 @@ void Message_(const char *caller, const char *fmt, ...)
  * require-trailing-newline: t
  * End:
  */
-#ifndef STREAM_FCOMMON_H
-#define STREAM_FCOMMON_H
-
-#ifndef  _CDI_INT_H
-#endif
+#ifndef EXSE_H
+#define EXSE_H
 
 enum {
-  SINGLE_PRECISION = 4,
-  DOUBLE_PRECISION = 8,
+  EXSE_SINGLE_PRECISION = 4,
+  EXSE_DOUBLE_PRECISION = 8,
 };
 
-void streamFCopyRecord(stream_t *streamptr2, stream_t *streamptr1,
-                       const char *container_name);
-
 #endif
-/*
- * Local Variables:
- * c-file-style: "Java"
- * c-basic-offset: 2
- * indent-tabs-mode: nil
- * show-trailing-whitespace: t
- * require-trailing-newline: t
- * End:
- */
 #if defined (HAVE_CONFIG_H)
 #endif
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
 #include <ctype.h>
 
 
 
-
 enum {
   EXT_HEADER_LEN = 4,
 };
@@ -20562,16 +20673,15 @@ static int extDefaultNumber = EXT_REAL;
 /*
  * A version string.
  */
-
 #undef  LIBVERSION
-#define LIBVERSION      1.3.2
+#define LIBVERSION      1.4.0
 #define XSTRING(x)	#x
 #define STRING(x)	XSTRING(x)
-static const char ext_libvers[] = STRING(LIBVERSION) " of "__DATE__" "__TIME__;
+static const char ext_libvers[] = STRING(LIBVERSION) " of " __DATE__ " " __TIME__ ;
 
 const char *extLibraryVersion(void)
 {
-  return (ext_libvers);
+  return ext_libvers;
 }
 
 
@@ -20587,13 +20697,12 @@ void extDebug(int debug)
 }
 
 
-static void extLibInit()
+static
+void extLibInit()
 {
-  char *envString;
-  char *envName = "EXT_PRECISION";
+  const char *envName = "EXT_PRECISION";
 
-
-  envString = getenv(envName);
+  char *envString = getenv(envName);
   if ( envString )
     {
       int pos = 0;
@@ -20607,8 +20716,8 @@ static void extLibInit()
 		extDefaultNumber = EXT_REAL;
 		switch ( (int) envString[pos+1] )
 		  {
-		  case '4': extDefaultPrec = SINGLE_PRECISION; break;
-		  case '8': extDefaultPrec = DOUBLE_PRECISION; break;
+		  case '4': extDefaultPrec = EXSE_SINGLE_PRECISION; break;
+		  case '8': extDefaultPrec = EXSE_DOUBLE_PRECISION; break;
 		  default:
 		    Message("Invalid digit in %s: %s", envName, envString);
 		  }
@@ -20619,8 +20728,8 @@ static void extLibInit()
 		extDefaultNumber = EXT_COMP;
 		switch ( (int) envString[pos+1] )
 		  {
-		  case '4': extDefaultPrec = SINGLE_PRECISION; break;
-		  case '8': extDefaultPrec = DOUBLE_PRECISION; break;
+		  case '4': extDefaultPrec = EXSE_SINGLE_PRECISION; break;
+		  case '8': extDefaultPrec = EXSE_DOUBLE_PRECISION; break;
 		  default:
 		    Message("Invalid digit in %s: %s", envName, envString);
 		  }
@@ -20653,15 +20762,13 @@ void extInit(extrec_t *extp)
 
 void *extNew(void)
 {
-  extrec_t *extp;
-
   if ( ! initExtLib ) extLibInit();
 
-  extp = (extrec_t *) malloc(sizeof(extrec_t));
+  extrec_t *extp = (extrec_t *) Malloc(sizeof(extrec_t));
 
   extInit(extp);
 
-  return ((void*)extp);
+  return (void*)extp;
 }
 
 
@@ -20671,25 +20778,24 @@ void extDelete(void *ext)
 
   if ( extp )
     {
-      if ( extp->buffer ) free(extp->buffer);
-      free(extp);
+      if ( extp->buffer ) Free(extp->buffer);
+      Free(extp);
     }
 }
 
 
 int extCheckFiletype(int fileID, int *swap)
 {
-  size_t blocklen = 0, fact = 0;
-  size_t sblocklen = 0;
+  size_t fact = 0;
   size_t data =  0;
   size_t dimxy = 0;
   int found = 0;
   unsigned char buffer[40], *pbuf;
 
-  if ( fileRead(fileID, buffer, 4) != 4 ) return (found);
+  if ( fileRead(fileID, buffer, 4) != 4 ) return found;
 
-  blocklen  = (size_t) get_UINT32(buffer);
-  sblocklen = (size_t) get_SUINT32(buffer);
+  size_t blocklen  = (size_t) get_UINT32(buffer);
+  size_t sblocklen = (size_t) get_SUINT32(buffer);
 
   if ( EXT_Debug )
     Message("blocklen = %d sblocklen = %d", blocklen, sblocklen);
@@ -20698,7 +20804,7 @@ int extCheckFiletype(int fileID, int *swap)
     {
      *swap = 0;
       fact = blocklen/4;
-      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return found;
       pbuf = buffer+3*fact;      dimxy = (size_t) get_UINT32(pbuf);
       pbuf = buffer+blocklen+4;  data  = (size_t) get_UINT32(pbuf);
     }
@@ -20706,7 +20812,7 @@ int extCheckFiletype(int fileID, int *swap)
     {
      *swap = 0;
       fact = blocklen/4;
-      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return found;
       pbuf = buffer+3*fact;      dimxy = (size_t) get_UINT64(pbuf);
       pbuf = buffer+blocklen+4;  data  = (size_t) get_UINT32(pbuf);
     }
@@ -20714,7 +20820,7 @@ int extCheckFiletype(int fileID, int *swap)
     {
      *swap = 1;
       fact = sblocklen/4;
-      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return found;
       pbuf = buffer+3*fact;       dimxy = (size_t) get_SUINT32(pbuf);
       pbuf = buffer+sblocklen+4;  data  = (size_t) get_SUINT32(pbuf);
     }
@@ -20722,7 +20828,7 @@ int extCheckFiletype(int fileID, int *swap)
     {
      *swap = 1;
       fact = sblocklen/4;
-      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return found;
       pbuf = buffer+3*fact;       dimxy = (size_t) get_SUINT64(pbuf);
       pbuf = buffer+sblocklen+4;  data  = (size_t) get_SUINT32(pbuf);
     }
@@ -20738,30 +20844,28 @@ int extCheckFiletype(int fileID, int *swap)
       Message("dimxy = %lu data = %lu", dimxy, data);
     }
 
-  return (found);
+  return found;
 }
 
 
 int extInqHeader(void *ext, int *header)
 {
   extrec_t *extp = (extrec_t *) ext;
-  size_t i;
 
-  for ( i = 0; i < EXT_HEADER_LEN; i++ )
+  for ( size_t i = 0; i < EXT_HEADER_LEN; i++ )
     header[i] = extp->header[i];
 
   if ( EXT_Debug ) Message("datasize = %lu", extp->datasize);
 
-  return (0);
+  return 0;
 }
 
 
 int extDefHeader(void *ext, const int *header)
 {
   extrec_t *extp = (extrec_t *) ext;
-  size_t i;
 
-  for ( i = 0; i < EXT_HEADER_LEN; i++ )
+  for ( size_t i = 0; i < EXT_HEADER_LEN; i++ )
     extp->header[i] = header[i];
 
   extp->datasize = (size_t)header[3];
@@ -20769,26 +20873,22 @@ int extDefHeader(void *ext, const int *header)
 
   if ( EXT_Debug ) Message("datasize = %lu", extp->datasize);
 
-  return (0);
+  return 0;
 }
 
-
-static int extInqData(extrec_t *extp, int prec, void *data)
+static
+int extInqData(extrec_t *extp, int prec, void *data)
 {
-  size_t datasize;
   size_t i;
   int ierr = 0;
-  int rprec;
-  void *buffer;
   int byteswap = extp->byteswap;
-
-  datasize = extp->datasize;
-  buffer   = extp->buffer;
-  rprec    = extp->prec;
+  size_t datasize = extp->datasize;
+  void *buffer   = extp->buffer;
+  int rprec    = extp->prec;
 
   switch ( rprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	if ( sizeof(FLT32) == 4 )
 	  {
@@ -20806,7 +20906,7 @@ static int extInqData(extrec_t *extp, int prec, void *data)
 	  }
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
 	if ( sizeof(FLT64) == 8 )
 	  {
 	    if ( byteswap ) swap8byte(buffer, datasize);
@@ -20829,31 +20929,27 @@ static int extInqData(extrec_t *extp, int prec, void *data)
       }
     }
 
-  return (ierr);
+  return ierr;
 }
 
 
 int extInqDataSP(void *ext, float *data)
 {
-  return (extInqData(ext, SINGLE_PRECISION, (void *) data));
+  return extInqData((extrec_t *)ext, EXSE_SINGLE_PRECISION, (void *) data);
 }
 
 
 int extInqDataDP(void *ext, double *data)
 {
-  return (extInqData(ext, DOUBLE_PRECISION, (void *) data));
+  return extInqData((extrec_t *)ext, EXSE_DOUBLE_PRECISION, (void *) data);
 }
 
 
-int extDefData(void *ext, int prec, const void *data)
+static int extDefData(void *ext, int prec, const void *data)
 {
   extrec_t *extp = (extrec_t *) ext;
-  size_t datasize;
-  size_t blocklen;
-  size_t buffersize;
   size_t i;
   int rprec;
-  int *header;
   void *buffer;
 
   if ( extDefaultPrec ) rprec = extDefaultPrec;
@@ -20863,21 +20959,21 @@ int extDefData(void *ext, int prec, const void *data)
 
   extp->prec = rprec;
 
-  header = extp->header;
+  int *header = extp->header;
 
-  datasize = (size_t)header[3];
+  size_t datasize = (size_t)header[3];
   if ( extp->number == EXT_COMP ) datasize *= 2;
-  blocklen = datasize * (size_t)rprec;
+  size_t blocklen = datasize * (size_t)rprec;
 
   extp->datasize = datasize;
 
-  buffersize = extp->buffersize;
+  size_t buffersize = extp->buffersize;
 
   if ( buffersize != blocklen )
     {
       buffersize = blocklen;
       buffer = extp->buffer;
-      buffer = realloc(buffer, buffersize);
+      buffer = Realloc(buffer, buffersize);
       extp->buffer = buffer;
       extp->buffersize = buffersize;
     }
@@ -20886,22 +20982,22 @@ int extDefData(void *ext, int prec, const void *data)
 
   switch ( rprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	if ( rprec == prec )
 	  memcpy(buffer, data, datasize*sizeof(FLT32));
 	else
-	  for (i = 0; i < datasize; i++)
+	  for ( i = 0; i < datasize; i++ )
 	    ((float *) buffer)[i] = (float) ((double *) data)[i];
 
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
 	if ( rprec == prec )
 	  memcpy(buffer, data, datasize*sizeof(FLT64));
 	else
-	  for (i = 0; i < datasize; i++)
+	  for ( i = 0; i < datasize; i++ )
 	    ((double *) buffer)[i] = (double) ((float *) data)[i];
 
 	break;
@@ -20913,29 +21009,27 @@ int extDefData(void *ext, int prec, const void *data)
       }
     }
 
-  return (0);
+  return 0;
 }
 
 
 int extDefDataSP(void *ext, const float *data)
 {
-  return (extDefData(ext, SINGLE_PRECISION, (void *) data));
+  return extDefData(ext, EXSE_SINGLE_PRECISION, (void *) data);
 }
 
 
 int extDefDataDP(void *ext, const double *data)
 {
-  return (extDefData(ext, DOUBLE_PRECISION, (void *) data));
+  return extDefData(ext, EXSE_DOUBLE_PRECISION, (void *) data);
 }
 
 
 int extRead(int fileID, void *ext)
 {
   extrec_t *extp = (extrec_t *) ext;
-  size_t blocklen, blocklen2;
   size_t i;
   void *buffer;
-  int byteswap;
   int status;
 
   if ( ! extp->checked )
@@ -20945,12 +21039,12 @@ int extRead(int fileID, void *ext)
       extp->checked = 1;
     }
 
-  byteswap = extp->byteswap;
+  int byteswap = extp->byteswap;
 
   /* read header record */
-  blocklen = binReadF77Block(fileID, byteswap);
+  size_t blocklen = binReadF77Block(fileID, byteswap);
 
-  if ( fileEOF(fileID) ) return (-1);
+  if ( fileEOF(fileID) ) return -1;
 
   if ( EXT_Debug )
     Message("blocklen = %lu", blocklen);
@@ -20961,7 +21055,7 @@ int extRead(int fileID, void *ext)
 
   switch ( hprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
         INT32 tempheader[4];
 	binReadInt32(fileID, byteswap, EXT_HEADER_LEN, tempheader);
@@ -20971,7 +21065,7 @@ int extRead(int fileID, void *ext)
 
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
         INT64 tempheader[4];
 	binReadInt64(fileID, byteswap, EXT_HEADER_LEN, tempheader);
@@ -20988,12 +21082,12 @@ int extRead(int fileID, void *ext)
       }
     }
 
-  blocklen2 = binReadF77Block(fileID, byteswap);
+  size_t blocklen2 = binReadF77Block(fileID, byteswap);
 
   if ( blocklen2 != blocklen )
     {
       Warning("Header blocklen differ (blocklen1=%d; blocklen2=%d)!", blocklen, blocklen2);
-      if ( blocklen2 != 0 ) return (-1);
+      if ( blocklen2 != 0 ) return -1;
     }
 
   extp->datasize = (size_t)extp->header[3];
@@ -21008,7 +21102,7 @@ int extRead(int fileID, void *ext)
     {
       buffersize = blocklen;
       buffer = extp->buffer;
-      buffer = realloc(buffer, buffersize);
+      buffer = Realloc(buffer, buffersize);
       extp->buffer = buffer;
       extp->buffersize = buffersize;
     }
@@ -21028,10 +21122,10 @@ int extRead(int fileID, void *ext)
       extp->number = EXT_COMP;
     }
 
-  if ( dprec != SINGLE_PRECISION && dprec != DOUBLE_PRECISION )
+  if ( dprec != EXSE_SINGLE_PRECISION && dprec != EXSE_DOUBLE_PRECISION )
     {
       Warning("Unexpected data precision %d", dprec);
-      return (-1);
+      return -1;
     }
 
   fileRead(fileID, buffer, blocklen);
@@ -21041,52 +21135,45 @@ int extRead(int fileID, void *ext)
   if ( blocklen2 != blocklen )
     {
       Warning("Data blocklen differ (blocklen1=%d; blocklen2=%d)!", blocklen, blocklen2);
-      if ( blocklen2 != 0 ) return (-1);
+      if ( blocklen2 != 0 ) return -1;
     }
 
-  return (0);
+  return 0;
 }
 
 
 int extWrite(int fileID, void *ext)
 {
   extrec_t *extp = (extrec_t *) ext;
-  size_t datasize;
-  size_t blocklen;
   size_t i;
-  int rprec, number;
-  char tempheader[32];
-  int *header;
-  void *buffer;
+  union { INT32 i32[EXT_HEADER_LEN]; INT64 i64[EXT_HEADER_LEN]; } tempheader;
   int byteswap = extp->byteswap;
-
-
-  rprec  = extp->prec;
-  number = extp->number;
-  header = extp->header;
+  int rprec  = extp->prec;
+  int number = extp->number;
+  int *header = extp->header;
 
   /* write header record */
-  blocklen = EXT_HEADER_LEN * (size_t)rprec;
+  size_t blocklen = EXT_HEADER_LEN * (size_t)rprec;
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
   switch ( rprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
-	for (i = 0; i < EXT_HEADER_LEN; i++)
-          ((INT32 *) tempheader)[i] = (INT32) header[i];
+	for ( i = 0; i < EXT_HEADER_LEN; i++ )
+          tempheader.i32[i] = (INT32) header[i];
 
-	binWriteInt32(fileID, byteswap, EXT_HEADER_LEN, (INT32 *) tempheader);
+	binWriteInt32(fileID, byteswap, EXT_HEADER_LEN, tempheader.i32);
 
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
-	for (i = 0; i < EXT_HEADER_LEN; i++)
-          ((INT64 *) tempheader)[i] = (INT64) header[i];
+	for ( i = 0; i < EXT_HEADER_LEN; i++ )
+          tempheader.i64[i] = (INT64) header[i];
 
-	binWriteInt64(fileID, byteswap, EXT_HEADER_LEN, (INT64 *) tempheader);
+	binWriteInt64(fileID, byteswap, EXT_HEADER_LEN, tempheader.i64);
 
 	break;
       }
@@ -21099,7 +21186,7 @@ int extWrite(int fileID, void *ext)
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
-  datasize = (size_t)header[3];
+  size_t datasize = (size_t)header[3];
   if ( number == EXT_COMP ) datasize *= 2;
   blocklen = datasize * (size_t)rprec;
 
@@ -21107,16 +21194,16 @@ int extWrite(int fileID, void *ext)
 
   extp->datasize = datasize;
 
-  buffer = extp->buffer;
+  void *buffer = extp->buffer;
 
   switch ( rprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	binWriteFlt32(fileID, byteswap, datasize, (FLT32 *) buffer);
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
 	binWriteFlt64(fileID, byteswap, datasize, (FLT64 *) buffer);
 	break;
@@ -21130,7 +21217,7 @@ int extWrite(int fileID, void *ext)
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
-  return (0);
+  return 0;
 }
 /*
  * Local Variables:
@@ -21173,7 +21260,7 @@ char *strdup(const char *s);
 ({                                                \
    const char *__old = (s);                       \
    size_t __len = strlen(__old) + 1;              \
-   char *__new = (char *) malloc(__len);          \
+   char *__new = (char *) Malloc(__len);          \
    (char *) memcpy(__new, __old, __len);          \
 })
 */
@@ -21230,15 +21317,15 @@ typedef struct
   int        eof;            /* end of file flag              */
   int        fd;             /* file descriptor used for read */
   FILE      *fp;             /* FILE pointer used for write   */
-  int        mode;           /* file access mode              */
   char      *name;           /* file name                     */
   off_t      size;           /* file size                     */
   off_t      position;       /* file position                 */
   long       access;         /* file access                   */
   off_t      byteTrans;      /*                               */
   size_t     blockSize;      /* file block size               */
-  int        type;           /* file type ( 1:open 2:fopen )  */
-  int        bufferType;     /* buffer type ( 1:std 2:mmap )  */
+  int        mode;           /* file access mode              */
+  short      type;           /* file type ( 1:open 2:fopen )  */
+  short      bufferType;     /* buffer type ( 1:std 2:mmap )  */
   size_t     bufferSize;     /* file buffer size              */
   size_t     mappedSize;     /* mmap buffer size              */
   char      *buffer;         /* file buffer                   */
@@ -21273,10 +21360,10 @@ static int FileInfo  = FALSE;
 
 static size_t FileBufferSizeMin = MIN_BUF_SIZE;
 static long   FileBufferSizeEnv = -1;
-static int    FileBufferTypeEnv =  0;
+static short  FileBufferTypeEnv =  0;
 
-static int    FileTypeRead  = FILE_TYPE_OPEN;
-static int    FileTypeWrite = FILE_TYPE_FOPEN;
+static short  FileTypeRead  = FILE_TYPE_OPEN;
+static short  FileTypeWrite = FILE_TYPE_FOPEN;
 static int    FileFlagWrite = 0;
 
 static int    FILE_Debug = 0;   /* If set to 1, debugging */
@@ -21291,7 +21378,7 @@ static void file_table_print(void);
 #define  LIBVERSION      1.8.2
 #define  XSTRING(x)	 #x
 #define  STRING(x) 	 XSTRING(x)
-const char file_libvers[] = STRING(LIBVERSION) " of "__DATE__" "__TIME__;
+static const char file_libvers[] = STRING(LIBVERSION) " of " __DATE__ " " __TIME__;
 
 /*
   21/05/2004  1.3.2 set min I/O Buffersize to 128k
@@ -21328,7 +21415,7 @@ void file_list_new(void)
 {
   assert(_fileList == NULL);
 
-  _fileList = (filePtrToIdx *)xmalloc((size_t)_file_max * sizeof (filePtrToIdx));
+  _fileList = (filePtrToIdx *) Malloc((size_t)_file_max * sizeof (filePtrToIdx));
 }
 
 static
@@ -21336,7 +21423,7 @@ void file_list_delete(void)
 {
   if ( _fileList )
     {
-      free(_fileList);
+      Free(_fileList);
       _fileList = NULL;
     }
 }
@@ -21445,7 +21532,7 @@ bfile_t *file_new_entry(void)
 {
   bfile_t *fileptr;
 
-  fileptr = (bfile_t *) malloc(sizeof(bfile_t));
+  fileptr = (bfile_t *) Malloc(sizeof(bfile_t));
 
   if ( fileptr ) file_init_entry(fileptr);
 
@@ -21461,7 +21548,7 @@ void file_delete_entry(bfile_t *fileptr)
 
   FILE_LOCK();
 
-  free(fileptr);
+  Free(fileptr);
 
   _fileList[idx].next = _fileAvail;
   _fileList[idx].ptr  = 0;
@@ -21480,16 +21567,15 @@ const char *fileLibraryVersion(void)
 }
 
 
-#ifndef POSIXIO_DEFAULT_PAGESIZE
-#define POSIXIO_DEFAULT_PAGESIZE 4096
-#endif
-
 static
 int pagesize(void)
 {
 #if defined(_SC_PAGESIZE)
   return ((int) sysconf(_SC_PAGESIZE));
 #else
+#ifndef POSIXIO_DEFAULT_PAGESIZE
+#define POSIXIO_DEFAULT_PAGESIZE 4096
+#endif
   return ((int) POSIXIO_DEFAULT_PAGESIZE);
 #endif
 }
@@ -21547,7 +21633,7 @@ int fileSetBufferType(int fileID, int type)
 	{
 	case FILE_BUFTYPE_STD:
 	case FILE_BUFTYPE_MMAP:
-	  fileptr->bufferType = type;
+	  fileptr->bufferType = (short)type;
 	  break;
 	default:
 	  Error("File type %d not implemented!", type);
@@ -21561,20 +21647,6 @@ int fileSetBufferType(int fileID, int type)
   return (ret);
 }
 
-
-int fileGetBufferType(int fileID)
-{
-  bfile_t *fileptr;
-  int bufferType = 0;
-
-  fileptr = file_to_pointer(fileID);
-
-  if ( fileptr ) bufferType = fileptr->bufferType;
-
-  return (bufferType);
-}
-
-
 int fileFlush(int fileID)
 {
   bfile_t *fileptr;
@@ -21625,20 +21697,6 @@ int fileEOF(int fileID)
   return (retval);
 }
 
-
-int fileError(int fileID)
-{
-  bfile_t *fileptr;
-  int retval = 0;
-
-  fileptr = file_to_pointer(fileID);
-
-  if ( fileptr ) retval = (fileptr->flag & FILE_ERROR) != 0;
-
-  return (retval);
-}
-
-
 void fileRewind(int fileID)
 {
   fileSetPos(fileID, (off_t) 0, SEEK_SET);
@@ -21918,7 +21976,7 @@ void file_initialize(void)
 	{
 	case FILE_TYPE_OPEN:
 	case FILE_TYPE_FOPEN:
-	  FileTypeRead = (int)value;
+	  FileTypeRead = (short)value;
 	  break;
 	default:
 	  Warning("File type %d not implemented!", value);
@@ -21932,7 +21990,7 @@ void file_initialize(void)
 	{
 	case FILE_TYPE_OPEN:
 	case FILE_TYPE_FOPEN:
-	  FileTypeWrite = (int)value;
+	  FileTypeWrite = (short)value;
 	  break;
 	default:
 	  Warning("File type %d not implemented!", value);
@@ -21964,7 +22022,7 @@ void file_initialize(void)
 	{
 	case FILE_BUFTYPE_STD:
 	case FILE_BUFTYPE_MMAP:
-	  FileBufferTypeEnv = (int)value;
+	  FileBufferTypeEnv = (short)value;
 	  break;
 	default:
 	  Warning("File buffer type %d not implemented!", value);
@@ -22041,7 +22099,7 @@ void file_set_buffer(bfile_t *fileptr)
     {
       if ( buffersize > 0 )
         {
-          fileptr->buffer = (char *) malloc(buffersize);
+          fileptr->buffer = (char *) Malloc(buffersize);
           if ( fileptr->buffer == NULL )
             SysError("Allocation of file buffer failed!");
         }
@@ -22344,8 +22402,8 @@ int fileClose_serial(int fileID)
 {
   char *name;
   int ret;
-  char *fbtname[] = {"unknown", "standard", "mmap"};
-  char *ftname[] = {"unknown", "open", "fopen"};
+  const char *fbtname[] = {"unknown", "standard", "mmap"};
+  const char *ftname[] = {"unknown", "open", "fopen"};
   bfile_t *fileptr = file_to_pointer(fileID);
   double rout = 0;
 
@@ -22439,8 +22497,8 @@ int fileClose_serial(int fileID)
 	SysError("EOF returned for close of %s!", name);
     }
 
-  if ( fileptr->name )    free((void*) fileptr->name);
-  if ( fileptr->buffer )  free((void*) fileptr->buffer);
+  if ( fileptr->name )    Free((void*) fileptr->name);
+  if ( fileptr->buffer )  Free((void*) fileptr->buffer);
 
   file_delete_entry(fileptr);
 
@@ -22619,12 +22677,31 @@ size_t fileWrite(int fileID, const void *restrict ptr, size_t size)
  * require-trailing-newline: t
  * End:
  */
+#ifndef _GAUSSGRID_H
+#define _GAUSSGRID_H
+
+void   gaussaw(double *restrict pa, double *restrict pw, size_t nlat);
+
+#endif  /* _GAUSSGRID_H */
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
+#ifdef HAVE_CONFIG_H
+#endif
+
 #include <math.h>
 #include <float.h>
 #include <stdio.h>
 #include <stdlib.h>
 
 
+
 #ifndef  M_PI
 #define  M_PI        3.14159265358979323846  /* pi */
 #endif
@@ -22644,7 +22721,7 @@ void cpledn(size_t kn, size_t kodd, double *pfn, double pdx, int kflag,
   double zdlmod;
   double zdlxn;
 
-  size_t ik, jn;
+  size_t ik;
 
   /* 1.0 Newton iteration step */
 
@@ -22680,7 +22757,7 @@ void cpledn(size_t kn, size_t kodd, double *pfn, double pdx, int kflag,
 
   if (kflag == 1) 
     {
-      for(jn = 2-kodd; jn <= kn; jn += 2) 
+      for(size_t jn = 2-kodd; jn <= kn; jn += 2) 
 	{
 	  /* normalised derivative */
 	  zdlldn = zdlldn - pfn[ik]*(double)(jn)*sin((double)(jn)*zdlx);
@@ -22728,7 +22805,7 @@ void gawl(double *pfn, double *pl, double *pw, size_t kn)
 }
 
 static
-void gauaw(size_t kn, double *restrict pl, double *restrict pw)
+void gauaw(size_t kn, double *__restrict__ pl, double *__restrict__ pw)
 {
   /*
    * 1.0 Initialize Fourier coefficients for ordinary Legendre polynomials
@@ -22740,8 +22817,8 @@ void gauaw(size_t kn, double *restrict pl, double *restrict pw)
 
   double z, zfnn;
 
-  zfn    = (double *) malloc((kn+1) * (kn+1) * sizeof(double));
-  zfnlat = (double *) malloc((kn/2+1+1)*sizeof(double));
+  zfn    = (double *) Malloc((kn+1) * (kn+1) * sizeof(double));
+  zfnlat = (double *) Malloc((kn/2+1+1)*sizeof(double));
 
   zfn[0] = M_SQRT2;
   for (size_t jn = 1; jn <= kn; jn++)
@@ -22809,8 +22886,8 @@ void gauaw(size_t kn, double *restrict pl, double *restrict pw)
       pw[isym] =  pw[jglm1];
     }
 
-  free(zfnlat);
-  free(zfn);
+  Free(zfnlat);
+  Free(zfn);
 
   return;
 }
@@ -22960,9 +23037,6 @@ int main (int rgc, char *argv[])
 #include <stdio.h>
 
 
-#define XSTRING(x)	#x
-#define STRING(x)	XSTRING(x)
-
 static char gribapi_libvers[64] = "";
 #if  defined  (HAVE_LIBGRIB_API)
 static int gribapi_libvers_init;
@@ -22973,9 +23047,9 @@ void gribapiLibraryVersion(int* major_version, int* minor_version, int* revision
 {
 #if  defined  (HAVE_LIBGRIB_API)
   long version = grib_get_api_version();
-  (*major_version)    = version/10000;
-  (*minor_version)    = (version-(*major_version)*10000)/100;
-  (*revision_version) = (version-(*major_version)*10000-(*minor_version)*100);
+  (*major_version)    = (int)(version/10000);
+  (*minor_version)    = (int)((version-(*major_version)*10000)/100);
+  (*revision_version) = (int)(version-(*major_version)*10000-(*minor_version)*100);
 #else
   (*major_version)    = 0;
   (*minor_version)    = 0;
@@ -23018,12 +23092,12 @@ void gribContainersNew(stream_t * streamptr)
 
 #if defined (GRIBCONTAINER2D)
       gribContainer_t **gribContainers;
-      gribContainers = (gribContainer_t **) malloc(nvars*sizeof(gribContainer_t *));
+      gribContainers = (gribContainer_t **) Malloc(nvars*sizeof(gribContainer_t *));
 
       for ( int varID = 0; varID < nvars; ++varID )
         {
           int nlevs = streamptr->vars[varID].nlevs;
-          gribContainers[varID] = (gribContainer_t *) malloc(nlevs*sizeof(gribContainer_t));
+          gribContainers[varID] = (gribContainer_t *) Malloc(nlevs*sizeof(gribContainer_t));
 
           for ( int levelID = 0; levelID < nlevs; ++levelID )
             {
@@ -23035,7 +23109,7 @@ void gribContainersNew(stream_t * streamptr)
       streamptr->gribContainers = (void **) gribContainers;
 #else
       gribContainer_t *gribContainers
-        = (gribContainer_t *)xmalloc((size_t)nvars*sizeof(gribContainer_t));
+        = (gribContainer_t *) Malloc((size_t)nvars*sizeof(gribContainer_t));
 
       for ( int varID = 0; varID < nvars; ++varID )
         {
@@ -23065,7 +23139,7 @@ void gribContainersDelete(stream_t * streamptr)
             {
               gribHandleDelete(gribContainers[varID][levelID].gribHandle);
             }
-          free(gribContainers[varID]);
+          Free(gribContainers[varID]);
 	}
 #else
       gribContainer_t *gribContainers = (gribContainer_t *) streamptr->gribContainers;
@@ -23076,7 +23150,7 @@ void gribContainersDelete(stream_t * streamptr)
 	}
 #endif
 
-      free(gribContainers);
+      Free(gribContainers);
 
       streamptr->gribContainers = NULL;
     }
@@ -23093,8 +23167,6 @@ void gribContainersDelete(stream_t * streamptr)
 #ifndef _GRID_H
 #define _GRID_H
 
-#ifndef RESOURCE_HANDLE_H
-#endif
 
 typedef unsigned char mask_t;
 
@@ -23122,28 +23194,28 @@ typedef struct {
   double  lcc_yinc;
   int     lcc_projflag;
   int     lcc_scanflag;
-  int     lcc_defined;
+  short   lcc_defined;
+  short   lcc2_defined;
+  int     laea_defined;
   double  lcc2_lon_0;             /* Lambert Conformal Conic 2      */
   double  lcc2_lat_0;
   double  lcc2_lat_1;
   double  lcc2_lat_2;
   double  lcc2_a;
-  int     lcc2_defined;
   double  laea_lon_0;             /* Lambert Azimuthal Equal Area   */
   double  laea_lat_0;
   double  laea_a;
-  int     laea_defined;
   double  xpole, ypole, angle;    /* rotated north pole             */
-  int     isCyclic;               /* TRUE for global cyclic grids   */
-  int     isRotated;              /* TRUE for rotated grids         */
-  int     xdef;                   /* 0: undefined 1:xvals 2:x0+xinc */
-  int     ydef;                   /* 0: undefined 1:yvals 2:y0+yinc */
+  short   isCyclic;               /* TRUE for global cyclic grids   */
+  short   isRotated;              /* TRUE for rotated grids         */
+  short   xdef;                   /* 0: undefined 1:xvals 2:x0+xinc */
+  short   ydef;                   /* 0: undefined 1:yvals 2:y0+yinc */
   int     nd, ni, ni2, ni3;       /* parameter for GRID_GME         */
   int     number, position;       /* parameter for GRID_REFERENCE   */
-  char   *reference;
-  unsigned char uuid[CDI_UUID_SIZE]; /* uuid for grid reference        */
   int     trunc;                  /* parameter for GRID_SPECTEAL    */
   int     nvertex;
+  char   *reference;
+  unsigned char uuid[CDI_UUID_SIZE]; /* uuid for grid reference        */
   int    *rowlon;
   int     nrowlon;
   int     size;
@@ -23188,7 +23260,16 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
            int * unpackBufferPos, int originNamespace, void *context,
            int force_id);
 
-extern const resOps gridOps;
+int  varDefGrid(int vlistID, const grid_t *grid, int mode);
+
+/* These are used by CDO. */
+void gridGenXvals(int xsize, double xfirst, double xlast,
+                  double xinc, double *xvals);
+void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast,
+                  double yinc, double *yvals);
+
+
+
 
 #endif
 /*
@@ -23236,19 +23317,19 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid);
 #endif
 
 #endif
-#ifndef INCLUDE_GUARD_CDI_PROPRIETARY_SYSTEM_WORKAROUNDS_H
-#define INCLUDE_GUARD_CDI_PROPRIETARY_SYSTEM_WORKAROUNDS_H
-
-char* myStrDup(const char* string);      //This exactly implements the standardized behavior of strdup().
-
-char* myAsprintf(char* format, ...) __attribute__((format(printf, 1, 2)));       //This implementation differs from standard asprintf() function in the way the resulting string pointer is returned.
 
-#endif
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #if defined (HAVE_CONFIG_H)
 #endif
 
-static int dummy;
-
 #ifdef HAVE_LIBGRIB_API
 
 
@@ -23258,7 +23339,7 @@ static int dummy;
 
 #define FAIL_ON_GRIB_ERROR(function, gribHandle, key, ...) do\
 {\
-  int errorCode = function(gribHandle, key, __VA_ARGS__);\
+  int errorCode = (int)function(gribHandle, key, __VA_ARGS__);  \
   if(errorCode)\
     {\
       fprintf(stderr, "%s:%d: Error in function `%s`: `%s` returned error code %d for key \"%s\"", __FILE__, __LINE__, __func__, #function, errorCode, key);\
@@ -23269,24 +23350,77 @@ static int dummy;
 //A simple wrapper for grib_get_string() that returns a newly allocated string.
 char* gribCopyString(grib_handle* gribHandle, const char* key)
 {
+  char* result = NULL;
   size_t length;
-  if(grib_get_length(gribHandle, key, &length)) return NULL;
-  char* result = xmalloc(length);
-  if(!grib_get_string(gribHandle, key, result, &length)) return result;
-  free(result);
-  return NULL;
+#ifdef HAVE_GRIB_GET_LENGTH
+  if(!grib_get_length(gribHandle, key, &length))
+    {
+    char* result = (char *) Malloc(length);
+    if(!grib_get_string(gribHandle, key, result, &length))
+    result = (char *) Realloc(result, length);
+
+    else
+      {
+          Free(result);
+          result = NULL;
+      }
+    }
+#else
+  length = 1024;         /* there's an implementation limit
+                          * that makes strings longer than
+                          * this unlikely in grib_api versions
+                          * not providing grib_get_length */
+  int rc;
+  result = (char *) Malloc(length);
+  while ((rc = grib_get_string(gribHandle, key, result, &length))
+         == GRIB_BUFFER_TOO_SMALL || rc == GRIB_ARRAY_TOO_SMALL)
+    {
+      if (length <= 1024UL * 1024UL)
+        {
+          length *= 2;
+          result = Realloc(result, length);
+        }
+      else
+        break;
+    }
+  if (!rc)
+    result = Realloc(result, length);
+  else
+    {
+      Free(result);
+      result = NULL;
+    }
+#endif
+  return result;
 }
 
 //A simple wrapper for grib_get_string() for the usecase that the result is only compared to a given constant string.
 //Returns true if the key exists and the value is equal to the given string.
 bool gribCheckString(grib_handle* gribHandle, const char* key, const char* expectedValue)
 {
-  size_t expectedLength = strlen(expectedValue) + 1, length;
+  size_t expectedLength = strlen(expectedValue) + 1;
+#ifdef HAVE_GRIB_GET_LENGTH
+  size_t length;
   if(grib_get_length(gribHandle, key, &length)) return false;
   if(length != expectedLength) return false;
-  char value[length];
+  char *value = (char *) Malloc(length);
   if(grib_get_string(gribHandle, key, value, &length)) return false;
-  return !strcmp(value, expectedValue);
+  int rc = !strcmp(value, expectedValue);
+  Free(value);
+#else
+  char *value = gribCopyString(gribHandle, key);
+  int rc;
+  if (value)
+  {
+    rc = strlen(value) + 1 == expectedLength ?
+      !strcmp(value, expectedValue)
+      : false;
+  }
+  else
+    rc = false;
+  Free(value);
+#endif
+  return rc;
 }
 
 //A simple wrapper for grib_get_long() for the usecase that the result is only compared to a given constant value.
@@ -23365,7 +23499,7 @@ long gribEditionNumber(grib_handle* gh)
 static char* setUtc()
 {
   char* temp = getenv("TZ"), *result = NULL;
-  if(temp) result = myStrDup(temp);
+  if(temp) result = strdup(temp);
   setenv("TZ", "UTC", 1);
   return result;
 }
@@ -23376,7 +23510,7 @@ static void resetTz(char* savedTz)
   if(savedTz)
     {
       setenv("TZ", savedTz, 1);
-      free(savedTz);
+      Free(savedTz);
     }
   else
     {
@@ -23402,13 +23536,13 @@ static int addSecondsToDate(struct tm* me, long long amount)
   //It is irrelevant here whether days are zero or one based, the correction would have be undone again so that it is effectless.
   long long seconds = ((me->tm_mday*24ll + me->tm_hour)*60 + me->tm_min)*60 + me->tm_sec;    //The portion of the date that uses fixed increments.
   seconds += amount;
-  me->tm_mday = seconds/24/60/60;
-  seconds -= me->tm_mday*24*60*60;
-  me->tm_hour = seconds/60/60;
-  seconds -= me->tm_hour*60*60;
-  me->tm_min = seconds/60;
-  seconds -= me->tm_min*60;
-  me->tm_sec = seconds;
+  me->tm_mday = (int)(seconds / 24 / 60 / 60);
+  seconds -= (long long)me->tm_mday * 24 * 60 * 60;
+  me->tm_hour = (int)(seconds / 60 / 60);
+  seconds -= (long long)me->tm_hour * 60 * 60;
+  me->tm_min = (int)(seconds / 60);
+  seconds -= (long long)(me->tm_min * 60);
+  me->tm_sec = (int)seconds;
   return normalizeDays(me);
 }
 
@@ -23416,9 +23550,9 @@ static void addMonthsToDate(struct tm* me, long long amount)
 {
   long long months = me->tm_year*12ll + me->tm_mon;
   months += amount;
-  me->tm_year = months/12;
-  months -= me->tm_year*12;
-  me->tm_mon = months;
+  me->tm_year = (int)(months/12);
+  months -= (long long)me->tm_year*12;
+  me->tm_mon = (int)months;
 }
 
 //unit is a value according to code table 4.4 of the GRIB2 specification, returns non-zero on error
@@ -23447,7 +23581,10 @@ static int addToDate(struct tm* me, long long amount, long unit)
 
 static char* makeDateString(struct tm* me)
 {
-  return myAsprintf("%04d-%02d-%02dT%02d:%02d:%02d.000", me->tm_year + 1900, me->tm_mon + 1, me->tm_mday, me->tm_hour, me->tm_min, me->tm_sec);
+  char *result
+    = (char *) Malloc(       4+1+ 2+1+ 2+1+ 2+1+ 2+1+ 2+ 4+ 1);
+  sprintf(result, "%04d-%02d-%02dT%02d:%02d:%02d.000", me->tm_year + 1900, me->tm_mon + 1, me->tm_mday, me->tm_hour, me->tm_min, me->tm_sec);
+  return result;
 }
 
 //FIXME: This ignores any calendar definition that might be present.
@@ -23476,20 +23613,29 @@ static int getAvailabilityOfRelativeTimes(grib_handle* gh, bool* outHaveForecast
 char* gribMakeTimeString(grib_handle* gh, bool getEndTime)
 {
   //Get the parts of the reference date.
+#ifdef __cplusplus
+    struct tm date;
+    date.tm_mon = (int) gribGetLong(gh, "month") - 1;   //months are zero based in struct tm and one based in GRIBy
+
+    date.tm_mday = (int)gribGetLong(gh, "day");
+    date.tm_hour = (int)gribGetLong(gh, "hour");
+    date.tm_min = (int)gribGetLong(gh, "minute");
+#else
   struct tm date = {
-      .tm_mon = gribGetLong(gh, "month") - 1,   //months are zero based in struct tm and one based in GRIB
-      .tm_mday = gribGetLong(gh, "day"),
-      .tm_hour = gribGetLong(gh, "hour"),
-      .tm_min = gribGetLong(gh, "minute")
+    .tm_mon = (int)gribGetLong(gh, "month") - 1,   //months are zero based in struct tm and one based in GRIBy
+    .tm_mday = (int)gribGetLong(gh, "day"),
+    .tm_hour = (int)gribGetLong(gh, "hour"),
+    .tm_min = (int)gribGetLong(gh, "minute")
   };
+#endif
   if(gribEditionNumber(gh) == 1)
     {
-      date.tm_year = gribGetLong(gh, "yearOfCentury");  //years are -1900 based both in struct tm and GRIB1
+      date.tm_year = (int)gribGetLong(gh, "yearOfCentury");  //years are -1900 based both in struct tm and GRIB1
     }
   else
     {
-      date.tm_year = gribGetLong(gh, "year") - 1900;   //years are -1900 based in struct tm and zero based in GRIB2
-      date.tm_sec = gribGetLong(gh, "second");
+      date.tm_year = (int)gribGetLong(gh, "year") - 1900;   //years are -1900 based in struct tm and zero based in GRIB2
+      date.tm_sec = (int)gribGetLong(gh, "second");
 
       //Determine whether we have a forecast time and a time range.
       bool haveForecastTime, haveTimeRange;
@@ -23738,13 +23884,13 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
         /* FIXME: assert(numberOfPoints <= INT_MAX && numberOfPoints >= INT_MIN) */
         grid->size   = (int)numberOfPoints;
 
-        grid->rowlon = (int *) malloc((size_t)nlat * sizeof (int));
-        pl          = (long *) malloc((size_t)nlat * sizeof (long));
+        grid->rowlon = (int *) Malloc((size_t)nlat * sizeof (int));
+        pl          = (long *) Malloc((size_t)nlat * sizeof (long));
         dummy       = (size_t)nlat;
         FAIL_ON_GRIB_ERROR(grib_get_long_array, gh, "pl", pl, &dummy);
         /* FIXME: assert(pl[i] >= INT_MIN && pl[i] <= INT_MIN) */
         for (int i = 0; i < nlat; ++i ) grid->rowlon[i] = (int)pl[i];
-        free(pl);
+        Free(pl);
 
         grid->ysize  = nlat;
         grid->xinc   = 0;
@@ -23800,14 +23946,14 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
         long lpar;
 
         FAIL_ON_GRIB_ERROR(grib_get_long, gh, "Nx", &lpar);
-        nlon = lpar;
+        nlon = (int)lpar;
         FAIL_ON_GRIB_ERROR(grib_get_long, gh, "Ny", &lpar);
-        nlat = lpar;
+        nlat = (int)lpar;
 
         if ( numberOfPoints != nlon*nlat )
           Error("numberOfPoints (%d) and gridSize (%d) differ!", (int)numberOfPoints, nlon*nlat);
 
-        grid->size  = numberOfPoints;
+        grid->size  = (int)numberOfPoints;
         grid->xsize = nlon;
         grid->ysize = nlat;
 
@@ -23939,8 +24085,9 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
       FAIL_ON_GRIB_ERROR(grib_get_double, gh, "longitudeOfSouthernPoleInDegrees", &grid->xpole);
       FAIL_ON_GRIB_ERROR(grib_get_double, gh, "angleOfRotation", &grid->angle);
       /* change from south to north pole */
-      grid->ypole = -grid->ypole;
+      if ( fabs(grid->ypole) > 0 ) grid->ypole = -grid->ypole;
       grid->xpole =  grid->xpole - 180;
+      if ( fabs(grid->angle) > 0 ) grid->angle = -grid->angle;
     }
 
   grid->xvals = NULL;
@@ -23948,12 +24095,6 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
   grid->type  = gridtype;
 }
 #endif
-#ifndef _GAUSSGRID_H
-#define _GAUSSGRID_H
-
-void   gaussaw(double *restrict pa, double *restrict pw, size_t nlat);
-
-#endif  /* _GAUSSGRID_H */
 /*
  * Local Variables:
  * c-file-style: "Java"
@@ -23982,26 +24123,274 @@ enum
   END       = 99999999
 };
 
-void reshUnpackResources(char * unpackBuffer, int unpackBufferSize,
-                         void *context);
+int reshUnpackResources(char * unpackBuffer, int unpackBufferSize,
+                        void *context);
 
 #endif
-#if defined (HAVE_CONFIG_H)
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
+#ifndef _VLIST_H
+#define _VLIST_H
+
+#ifdef HAVE_CONFIG_H
 #endif
 
-#include <string.h>
-#include <float.h>  /* FLT_EPSILON */
-#include <limits.h> /* INT_MAX     */
+#ifndef  _ERROR_H
+#endif
 
+#include <stddef.h>  /* size_t */
 
-#ifndef  RAD2DEG
-#define  RAD2DEG  (180./M_PI)   /* conversion for rad to deg */
+#ifndef _CDI_LIMITS_H
 #endif
 
-#ifndef  DEG2RAD
-#define  DEG2RAD  (M_PI/180.)   /* conversion for deg to rad */
+#define VALIDMISS 1.e+303
+
+/*
+ * CDI attribute
+ */
+typedef struct {
+  size_t    xsz;	  /* amount of space at xvalue                      */
+  size_t    namesz;       /* size of name                                   */
+  char     *name;         /* attribute name                                 */
+  int       indtype;	  /* internal data type of xvalue (INT, FLT or TXT) */
+  int       exdtype;      /* external data type                             */
+                          /* indtype    exdtype                             */
+                          /* TXT        TXT                                 */
+                          /* INT        INT16, INT32                        */
+                          /* FLT        FLT32, FLT64                        */
+  size_t    nelems;    	  /* number of elements                             */
+  void     *xvalue;       /* the actual data                                */
+} cdi_att_t;
+
+
+typedef struct {
+  size_t     nalloc;		/* number allocated >= nelems */
+  size_t     nelems;		/* length of the array */
+  cdi_att_t  value[MAX_ATTRIBUTES];
+} cdi_atts_t;
+
+
+typedef struct
+{
+  int      flag;
+  int      index;
+  int      mlevelID;
+  int      flevelID;
+}
+levinfo_t;
+
+#define DEFAULT_LEVINFO(levID) \
+  (levinfo_t){ 0, -1, levID, levID}
+/*
+#define DEFAULT_LEVINFO(levID) \
+  (levinfo_t){ .flag = 0, .index = -1, .flevelID = levID, .mlevelID = levID}
+*/
+typedef struct
+{
+  int ens_index;
+  int ens_count;
+  int forecast_init_type;
+}
+ensinfo_t;
+
+
+
+typedef struct
+{
+  int         flag;
+  int         isUsed;
+  int         mvarID;
+  int         fvarID;
+  int         param;
+  int         gridID;
+  int         zaxisID;
+  int         tsteptype; /* TSTEP_* */
+  int         datatype;  /* DATATYPE_PACKX for GRIB data, else DATATYPE_FLT32 or DATATYPE_FLT64 */
+  int         instID;
+  int         modelID;
+  int         tableID;
+  int         timave;
+  int         timaccu;
+  int         typeOfGeneratingProcess;
+  int         productDefinitionTemplate;
+  int         chunktype;
+  int         xyz;
+  int         missvalused; /* TRUE if missval is defined */
+  int         lvalidrange;
+  char       *name;
+  char       *longname;
+  char       *stdname;
+  char       *units;
+  char       *extra;
+  double      missval;
+  double      scalefactor;
+  double      addoffset;
+  double      validrange[2];
+  levinfo_t  *levinfo;
+  int         comptype;     // compression type
+  int         complevel;    // compression level
+  ensinfo_t  *ensdata;      /* Ensemble information */
+  cdi_atts_t  atts;
+  int         iorank;
+
+  int         subtypeID;   /* subtype ID for tile-related meta-data, currently for GRIB-API only. */
+
+  int                 opt_grib_nentries;       /* current no. key-value pairs            */
+  int                 opt_grib_kvpair_size;    /* current allocated size                 */
+  opt_key_val_pair_t *opt_grib_kvpair;         /* (optional) list of keyword/value pairs */
+}
+var_t;
+
+
+typedef struct
+{
+  int         locked;
+  int         self;
+  int         nvars;        /* number of variables                */
+  int         ngrids;
+  int         nzaxis;
+  int         nsubtypes;    /* no. of variable subtypes (e.g. sets of tiles) */
+  long        ntsteps;
+  int         taxisID;
+  int         tableID;
+  int         instID;
+  int         modelID;
+  int         varsAllocated;
+  int         gridIDs[MAX_GRIDS_PS];
+  int         zaxisIDs[MAX_ZAXES_PS];
+  int         subtypeIDs[MAX_SUBTYPES_PS];
+  var_t      *vars;
+  cdi_atts_t  atts;
+}
+vlist_t;
+
+
+vlist_t *vlist_to_pointer(int vlistID);
+void vlistCheckVarID(const char *caller, int vlistID, int varID);
+const char *vlistInqVarNamePtr(int vlistID, int varID);
+const char *vlistInqVarLongnamePtr(int vlistID, int varID);
+const char *vlistInqVarStdnamePtr(int vlistID, int varID);
+const char *vlistInqVarUnitsPtr(int vlistID, int varID);
+void     vlistDestroyVarName(int vlistID, int varID);
+void     vlistDestroyVarLongname(int vlistID, int varID);
+void     vlistDestroyVarStdname(int vlistID, int varID);
+void     vlistDestroyVarUnits(int vlistID, int varID);
+void     vlistDefVarTsteptype(int vlistID, int varID, int tsteptype);
+int      vlistInqVarMissvalUsed(int vlistID, int varID);
+int      vlistHasTime(int vlistID);
+
+int      vlistDelAtts(int vlistID, int varID);
+int      vlistCopyVarAtts(int vlistID1, int varID_1, int vlistID2, int varID_2);
+
+void     vlistUnpack(char * buffer, int bufferSize, int * pos,
+                     int originNamespace, void *context, int force_id);
+
+/*      vlistDefVarValidrange: Define the valid range of a Variable */
+void    vlistDefVarValidrange(int vlistID, int varID, const double *validrange);
+
+/*      vlistInqVarValidrange: Get the valid range of a Variable */
+int     vlistInqVarValidrange(int vlistID, int varID, double *validrange);
+
+void vlistInqVarDimorder(int vlistID, int varID, int (*outDimorder)[3]);
+
+int vlist_att_compare(vlist_t *a, int varIDA, vlist_t *b, int varIDB, int attnum);
+
+void vlist_lock(int vlistID);
+void vlist_unlock(int vlistID);
+
+void resize_opt_grib_entries(var_t *var, int nentries);
+
+
+
+static inline void
+vlistAdd2GridIDs(vlist_t *vlistptr, int gridID)
+{
+  int index, ngrids = vlistptr->ngrids;
+  for ( index = 0; index < ngrids; index++ )
+    if (vlistptr->gridIDs[index] == gridID ) break;
+  if ( index == ngrids )
+    {
+      if (ngrids >= MAX_GRIDS_PS)
+        Error("Internal limit exceeded: more than %d grids.", MAX_GRIDS_PS);
+      ++(vlistptr->ngrids);
+      vlistptr->gridIDs[ngrids] = gridID;
+    }
+}
+
+static inline void
+vlistAdd2ZaxisIDs(vlist_t *vlistptr, int zaxisID)
+{
+  int index, nzaxis = vlistptr->nzaxis;
+  for ( index = 0; index < nzaxis; index++ )
+    if ( zaxisID == vlistptr->zaxisIDs[index] ) break;
+
+  if ( index == nzaxis )
+    {
+      if ( nzaxis >= MAX_ZAXES_PS )
+	Error("Internal limit exceeded: more than %d zaxis.", MAX_ZAXES_PS);
+      vlistptr->zaxisIDs[nzaxis] = zaxisID;
+      vlistptr->nzaxis++;
+    }
+}
+
+static inline void
+vlistAdd2SubtypeIDs(vlist_t *vlistptr, int subtypeID)
+{
+  if ( subtypeID == CDI_UNDEFID ) return;
+
+  int index, nsubs = vlistptr->nsubtypes;
+  for ( index = 0; index < nsubs; index++ )
+    if (vlistptr->subtypeIDs[index] == subtypeID ) break;
+  if ( index == nsubs )
+    {
+      if (nsubs >= MAX_SUBTYPES_PS)
+        Error("Internal limit exceeded: more than %d subs.", MAX_SUBTYPES_PS);
+      ++(vlistptr->nsubtypes);
+      vlistptr->subtypeIDs[nsubs] = subtypeID;
+    }
+}
+
+
+
+#if  defined  (HAVE_LIBGRIB_API)
+extern int   cdiNAdditionalGRIBKeys;
+extern char* cdiAdditionalGRIBKeys[];
 #endif
 
+extern
+#ifndef __cplusplus
+const
+#endif
+resOps vlistOps;
+
+#endif  /* _VLIST_H */
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
+#if defined (HAVE_CONFIG_H)
+#endif
+
+#include <string.h>
+#include <float.h>  /* FLT_EPSILON */
+#include <limits.h> /* INT_MAX     */
+
+
+#undef  UNDEFID
+#define UNDEFID -1
 
 /* the value in the second pair of brackets must match the length of
  * the longest string (including terminating NUL) */
@@ -24033,7 +24422,7 @@ static void   gridPack        ( void * gridptr, void * buff, int size,
 				int *position, void *context);
 static int    gridTxCode      ( void );
 
-const resOps gridOps = {
+static const resOps gridOps = {
   gridCompareP,
   gridDestroyP,
   gridPrintP,
@@ -24125,16 +24514,16 @@ void grid_init(grid_t *gridptr)
 
 void grid_free(grid_t *gridptr)
 {
-  if ( gridptr->mask      ) free(gridptr->mask);
-  if ( gridptr->mask_gme  ) free(gridptr->mask_gme);
-  if ( gridptr->xvals     ) free(gridptr->xvals);
-  if ( gridptr->yvals     ) free(gridptr->yvals);
-  if ( gridptr->area      ) free(gridptr->area);
-  if ( gridptr->xbounds   ) free(gridptr->xbounds);
-  if ( gridptr->ybounds   ) free(gridptr->ybounds);
-  if ( gridptr->rowlon    ) free(gridptr->rowlon);
-  if ( gridptr->reference ) free(gridptr->reference);
-  if ( gridptr->name      ) free(gridptr->name);
+  if ( gridptr->mask      ) Free(gridptr->mask);
+  if ( gridptr->mask_gme  ) Free(gridptr->mask_gme);
+  if ( gridptr->xvals     ) Free(gridptr->xvals);
+  if ( gridptr->yvals     ) Free(gridptr->yvals);
+  if ( gridptr->area      ) Free(gridptr->area);
+  if ( gridptr->xbounds   ) Free(gridptr->xbounds);
+  if ( gridptr->ybounds   ) Free(gridptr->ybounds);
+  if ( gridptr->rowlon    ) Free(gridptr->rowlon);
+  if ( gridptr->reference ) Free(gridptr->reference);
+  if ( gridptr->name      ) Free(gridptr->name);
 
   grid_init(gridptr);
 }
@@ -24142,7 +24531,7 @@ void grid_free(grid_t *gridptr)
 static grid_t *
 gridNewEntry(cdiResH resH)
 {
-  grid_t *gridptr = (grid_t*) xmalloc(sizeof(grid_t));
+  grid_t *gridptr = (grid_t*) Malloc(sizeof(grid_t));
   grid_init(gridptr);
   if (resH == CDI_UNDEFID)
     gridptr->self = reshPut(gridptr, &gridOps);
@@ -24206,9 +24595,9 @@ void gridGenXvals(int xsize, double xfirst, double xlast, double xinc, double *x
 static
 void calc_gaussgrid(double *yvals, int ysize, double yfirst, double ylast)
 {
-  double *restrict yw = (double *)xmalloc((size_t)ysize * sizeof(double));
+  double *restrict yw = (double *) Malloc((size_t)ysize * sizeof(double));
   gaussaw(yvals, yw, (size_t)ysize);
-  free(yw);
+  Free(yw);
   for (int i = 0; i < ysize; i++ )
     yvals[i] = asin(yvals[i])/M_PI*180.0;
 
@@ -24238,31 +24627,30 @@ void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast, double y
 	  if ( ! (IS_EQUAL(yfirst, 0) && IS_EQUAL(ylast, 0)) )
 	    if ( fabs(yvals[0] - yfirst) > deleps || fabs(yvals[ysize-1] - ylast) > deleps )
 	      {
-		double yinc = fabs(ylast-yfirst)/(ysize-1);
 		double *restrict ytmp = NULL;
 		int nstart, lfound = 0;
-		int ny = (int) (180./yinc + 0.5);
+		int ny = (int) (180./fabs(ylast-yfirst)/(ysize-1) + 0.5);
 		ny -= ny%2;
-		/* printf("%g %g %g %g %g %d\n", ylast, yfirst, ylast-yfirst,yinc, 180/yinc, ny); */
 		if ( ny > ysize && ny < 4096 )
 		  {
-		    ytmp = (double *)xmalloc((size_t)ny * sizeof (double));
+		    ytmp = (double *) Malloc((size_t)ny * sizeof (double));
 		    calc_gaussgrid(ytmp, ny, yfirst, ylast);
-                    int i;
-		    for ( i = 0; i < (ny-ysize); i++ )
-		      if ( fabs(ytmp[i] - yfirst) < deleps ) break;
-
-		    nstart = i;
+                    {
+                      int i;
+                      for ( i = 0; i < (ny-ysize); i++ )
+                        if ( fabs(ytmp[i] - yfirst) < deleps ) break;
+                      nstart = i;
+                    }
 
 		    lfound = (nstart+ysize-1) < ny
                       && fabs(ytmp[nstart+ysize-1] - ylast) < deleps;
+                    if ( lfound )
+                      {
+                        for (int i = 0; i < ysize; i++) yvals[i] = ytmp[i+nstart];
+                      }
 		  }
 
-		if ( lfound )
-		  {
-		    for (int i = 0; i < ysize; i++) yvals[i] = ytmp[i+nstart];
-		  }
-		else
+		if ( !lfound )
 		  {
 		    Warning("Cannot calculate gaussian latitudes for lat1 = %g latn = %g!", yfirst, ylast);
 		    for (int i = 0; i < ysize; i++ ) yvals[i] = 0;
@@ -24270,7 +24658,7 @@ void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast, double y
 		    yvals[ysize-1] = ylast;
 		  }
 
-		if ( ytmp ) free(ytmp);
+		if ( ytmp ) Free(ytmp);
 	      }
 	}
       else
@@ -24466,17 +24854,17 @@ void gridDestroyKernel( grid_t * gridptr )
 
   id = gridptr->self;
 
-  if ( gridptr->mask      ) free(gridptr->mask);
-  if ( gridptr->mask_gme  ) free(gridptr->mask_gme);
-  if ( gridptr->xvals     ) free(gridptr->xvals);
-  if ( gridptr->yvals     ) free(gridptr->yvals);
-  if ( gridptr->area      ) free(gridptr->area);
-  if ( gridptr->xbounds   ) free(gridptr->xbounds);
-  if ( gridptr->ybounds   ) free(gridptr->ybounds);
-  if ( gridptr->rowlon    ) free(gridptr->rowlon);
-  if ( gridptr->reference ) free(gridptr->reference);
+  if ( gridptr->mask      ) Free(gridptr->mask);
+  if ( gridptr->mask_gme  ) Free(gridptr->mask_gme);
+  if ( gridptr->xvals     ) Free(gridptr->xvals);
+  if ( gridptr->yvals     ) Free(gridptr->yvals);
+  if ( gridptr->area      ) Free(gridptr->area);
+  if ( gridptr->xbounds   ) Free(gridptr->xbounds);
+  if ( gridptr->ybounds   ) Free(gridptr->ybounds);
+  if ( gridptr->rowlon    ) Free(gridptr->rowlon);
+  if ( gridptr->reference ) Free(gridptr->reference);
 
-  free ( gridptr );
+  Free( gridptr );
 
   reshRemove ( id, &gridOps );
 }
@@ -24506,10 +24894,9 @@ void gridDestroyP ( void * gridptr )
 
 const char *gridNamePtr(int gridtype)
 {
-  const char *name;
-  int size = (int) (sizeof(Grids)/sizeof(char *));
+  int size = (int) (sizeof(Grids)/sizeof(Grids[0]));
 
-  name = gridtype >= 0 && gridtype < size ? Grids[gridtype] : Grids[GRID_GENERIC];
+  const char *name = gridtype >= 0 && gridtype < size ? Grids[gridtype] : Grids[GRID_GENERIC];
 
   return (name);
 }
@@ -25186,7 +25573,7 @@ void gridDefRowlon(int gridID, int nrowlon, const int rowlon[])
 {
   grid_t *gridptr = gridID2Ptr(gridID);
 
-  gridptr->rowlon = (int *)xmalloc((size_t)nrowlon * sizeof(int));
+  gridptr->rowlon = (int *) Malloc((size_t)nrowlon * sizeof(int));
   gridptr->nrowlon = nrowlon;
   memcpy(gridptr->rowlon, rowlon, (size_t)nrowlon * sizeof(int));
   reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
@@ -25244,14 +25631,14 @@ void gridDefMask(int gridID, const int *mask)
     {
       if ( gridptr->mask )
 	{
-	  free(gridptr->mask);
+	  Free(gridptr->mask);
 	  gridptr->mask = NULL;
 	}
     }
   else
     {
       if ( gridptr->mask == NULL )
-	gridptr->mask = (mask_t *)xmalloc((size_t)size*sizeof(mask_t));
+	gridptr->mask = (mask_t *) Malloc((size_t)size*sizeof(mask_t));
       else if ( CDI_Debug )
 	Warning("grid mask already defined!");
 
@@ -25290,7 +25677,7 @@ void gridDefMaskGME(int gridID, const int *mask)
     Error("Size undefined for gridID = %d", gridID);
 
   if ( gridptr->mask_gme == NULL )
-    gridptr->mask_gme = (mask_t *)xmalloc((size_t)size * sizeof (mask_t));
+    gridptr->mask_gme = (mask_t *) Malloc((size_t)size * sizeof (mask_t));
   else if ( CDI_Debug )
     Warning("mask already defined!");
 
@@ -25358,12 +25745,10 @@ The function @func{gridDefXvals} defines all values of the X-axis.
 void gridDefXvals(int gridID, const double *xvals)
 {
   grid_t *gridptr = gridID2Ptr(gridID);
+  int gridtype = gridptr->type;
 
-  int gridtype;
   long size;
 
-  gridtype = gridptr->type;
-
   if ( gridtype == GRID_UNSTRUCTURED || gridtype == GRID_CURVILINEAR )
     size = gridptr->size;
   else if ( gridtype == GRID_GAUSSIAN_REDUCED )
@@ -25376,7 +25761,7 @@ void gridDefXvals(int gridID, const double *xvals)
 
   if (gridptr->xvals && CDI_Debug)
     Warning("values already defined!");
-  gridptr->xvals = (double *)xrealloc(gridptr->xvals,
+  gridptr->xvals = (double *) Realloc(gridptr->xvals,
                                       (size_t)size * sizeof(double));
   memcpy(gridptr->xvals, xvals, (size_t)size * sizeof (double));
   reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
@@ -25451,7 +25836,7 @@ void gridDefYvals(int gridID, const double *yvals)
   if (gridptr->yvals && CDI_Debug)
     Warning("Values already defined!");
 
-  gridptr->yvals = (double *)xrealloc(gridptr->yvals, (size_t)size * sizeof (double));
+  gridptr->yvals = (double *) Realloc(gridptr->yvals, (size_t)size * sizeof (double));
   memcpy(gridptr->yvals, yvals, (size_t)size * sizeof (double));
   reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
 }
@@ -25462,10 +25847,9 @@ double gridInqXval(int gridID, int index)
   double xval = 0;
   grid_t *gridptr = gridID2Ptr(gridID);
 
-  if ( gridptr->xvals )
-    xval = gridptr->xvals[index];
+  if ( gridptr->xvals ) xval = gridptr->xvals[index];
 
-  return (xval);
+  return xval;
 }
 
 /*
@@ -25483,10 +25867,9 @@ double gridInqYval(int gridID, int index)
   double yval = 0;
   grid_t *gridptr = gridID2Ptr(gridID);
 
-  if ( gridptr->yvals )
-    yval = gridptr->yvals[index];
+  if ( gridptr->yvals ) yval = gridptr->yvals[index];
 
-  return (yval);
+  return yval;
 }
 
 /*
@@ -25502,25 +25885,27 @@ double gridInqYval(int gridID, int index)
 double gridInqXinc(int gridID)
 {
   grid_t *gridptr = gridID2Ptr(gridID);
-
   double xinc = gridptr->xinc;
+  const double *restrict xvals = gridptr->xvals;
 
-  if ( (! (fabs(xinc) > 0)) && gridptr->xvals )
+  if ( (! (fabs(xinc) > 0)) && xvals )
     {
       int xsize = gridptr->xsize;
       if ( xsize > 1 )
         {
-          double *xvals = gridptr->xvals;
           xinc = fabs(xvals[xsize-1] - xvals[0])/(xsize-1);
-          int i;
-          for (i = 2; i < xsize; i++ )
-            if ( fabs(fabs(xvals[i-1] - xvals[i]) - xinc) > 0.01*xinc ) break;
+          for ( size_t i = 2; i < (size_t)xsize; i++ )
+            if ( fabs(fabs(xvals[i-1] - xvals[i]) - xinc) > 0.01*xinc )
+              {
+                xinc = 0;
+                break;
+              }
 
-          if ( i < xsize ) xinc = 0;
+          gridptr->xinc = xinc;
         }
     }
 
-  return (xinc);
+  return xinc;
 }
 
 /*
@@ -25536,30 +25921,28 @@ double gridInqXinc(int gridID)
 double gridInqYinc(int gridID)
 {
   grid_t *gridptr = gridID2Ptr(gridID);
-
   double yinc = gridptr->yinc;
+  const double *yvals = gridptr->yvals;
 
-  if ( (! (fabs(yinc) > 0)) && gridptr->yvals )
+  if ( (! (fabs(yinc) > 0)) && yvals )
     {
-      int ysize;
-      double *yvals;
-
-      ysize = gridptr->ysize;
-      yvals = gridptr->yvals;
-
+      int ysize = gridptr->ysize;
       if ( ysize > 1 )
         {
-          yinc = fabs(yvals[1] - yvals[0]);
-          int i;
-          for ( i = 2; i < ysize; i++ )
-            if ( fabs(fabs(yvals[i] - yvals[i-1]) - yinc) > (yinc/1000) ) break;
+          yinc = yvals[1] - yvals[0];
+          double abs_yinc = fabs(yinc);
+          for ( size_t i = 2; i < (size_t)ysize; i++ )
+            if ( fabs(fabs(yvals[i] - yvals[i-1]) - abs_yinc) > (0.01*abs_yinc))
+              {
+                yinc = 0;
+                break;
+              }
 
-          if ( i < ysize ) yinc = 0;
-          else             yinc = yvals[1] - yvals[0];
+          gridptr->yinc = yinc;
         }
     }
 
-  return (yinc);
+  return yinc;
 }
 
 /*
@@ -25574,9 +25957,10 @@ double gridInqYinc(int gridID)
 */
 double gridInqXpole(int gridID)
 {
+  // Xpole -> grid_north_pole_longitude
   grid_t *gridptr = gridID2Ptr(gridID);
 
-  return (gridptr->xpole);
+  return gridptr->xpole;
 }
 
 /*
@@ -25591,6 +25975,7 @@ double gridInqXpole(int gridID)
 */
 void gridDefXpole(int gridID, double xpole)
 {
+  // Xpole -> grid_north_pole_longitude
   grid_t *gridptr = gridID2Ptr(gridID);
 
   if ( memcmp(gridptr->xstdname, "grid", 4) != 0 )
@@ -25616,6 +26001,7 @@ void gridDefXpole(int gridID, double xpole)
 */
 double gridInqYpole(int gridID)
 {
+  // Ypole -> grid_north_pole_latitude
   grid_t *gridptr = gridID2Ptr(gridID);
 
   return (gridptr->ypole);
@@ -25633,6 +26019,7 @@ double gridInqYpole(int gridID)
 */
 void gridDefYpole(int gridID, double ypole)
 {
+  // Ypole -> grid_north_pole_latitude
   grid_t *gridptr = gridID2Ptr(gridID);
 
   if ( memcmp(gridptr->ystdname, "grid", 4) != 0 )
@@ -25658,6 +26045,7 @@ void gridDefYpole(int gridID, double ypole)
 */
 double gridInqAngle(int gridID)
 {
+  // Angle -> north_pole_grid_longitude
   grid_t *gridptr = gridID2Ptr(gridID);
 
   return (gridptr->angle);
@@ -25671,10 +26059,11 @@ double gridInqAngle(int gridID)
 @Parameter
     @Item  Grid identifier
 
- at EndFunction
+ at EndFunction<
 */
 void gridDefAngle(int gridID, double angle)
 {
+  // Angle -> north_pole_grid_longitude
   grid_t *gridptr = gridID2Ptr(gridID);
 
   if ( gridptr->isRotated != TRUE || IS_NOT_EQUAL(gridptr->angle, angle) )
@@ -25854,26 +26243,21 @@ void gridChangeType(int gridID, int gridtype)
 static
 void grid_check_cyclic(grid_t *gridptr)
 {
-  int xsize, ysize;
-  long i1, i2, in, j, k1, k2, nc;
-  double xinc, x0;
-  const double *xvals, *xbounds;
-
   gridptr->isCyclic = FALSE;
 
-  xsize = gridptr->xsize;
-  ysize = gridptr->ysize;
-  xvals = gridptr->xvals;
-  xbounds = gridptr->xbounds;
+  int xsize = gridptr->xsize,
+    ysize = gridptr->ysize;
+  const double *xvals = gridptr->xvals,
+    *xbounds = gridptr->xbounds;
 
   if ( gridptr->type == GRID_GAUSSIAN || gridptr->type == GRID_LONLAT )
     {
       if ( xvals && xsize > 1 )
         {
-          xinc = xvals[1] - xvals[0];
+          double xinc = xvals[1] - xvals[0];
           if ( IS_EQUAL(xinc, 0) ) xinc = (xvals[xsize-1] - xvals[0])/(xsize-1);
 
-          x0 = 2*xvals[xsize-1]-xvals[xsize-2]-360;
+          double x0 = 2*xvals[xsize-1]-xvals[xsize-2]-360;
 
           if ( IS_NOT_EQUAL(xvals[0], xvals[xsize-1]) )
             if ( fabs(x0 - xvals[0]) < 0.01*xinc ) gridptr->isCyclic = TRUE;
@@ -25883,20 +26267,17 @@ void grid_check_cyclic(grid_t *gridptr)
     {
       if ( xvals && xsize > 1 )
         {
-          double val1, val2, valn;
-
-          nc = 0;
-          gridptr->isCyclic = FALSE;
-          for ( j = 0; j < ysize; ++j )
+          long nc = 0;
+          for ( int j = 0; j < ysize; ++j )
             {
-              i1 = j*xsize;
-              i2 = j*xsize+1;
-              in = j*xsize+(xsize-1);
-              val1 = xvals[i1];
-              val2 = xvals[i2];
-              valn = xvals[in];
+              long i1 = j*xsize,
+                i2 = j*xsize+1,
+                in = j*xsize+(xsize-1);
+              double val1 = xvals[i1],
+                val2 = xvals[i2],
+                valn = xvals[in];
 
-              xinc = fabs(val2-val1);
+              double xinc = fabs(val2-val1);
 
 	      if ( val1 <    1 && valn > 300 ) val1 += 360;
 	      if ( valn <    1 && val1 > 300 ) valn += 360;
@@ -25904,31 +26285,27 @@ void grid_check_cyclic(grid_t *gridptr)
 	      if ( valn < -179 && val1 > 120 ) valn += 360;
               if ( fabs(valn-val1) > 180 ) val1 += 360;
 
-              if ( valn > val1 ) x0 = valn - xinc;
-              else               x0 = valn + xinc;
+              double x0 = valn + copysign(xinc, val1 - valn);
 
-              if ( fabs(x0-val1) < 0.5*xinc ) nc++;
+              nc += fabs(x0-val1) < 0.5*xinc;
             }
-
-          if ( nc > 0.5*ysize ) gridptr->isCyclic = TRUE;
+          gridptr->isCyclic = nc > 0.5*ysize ? TRUE : FALSE;
         }
 
       if ( xbounds && xsize > 1 )
 	{
-	  double val1, val2;
-
-	  gridptr->isCyclic = TRUE;
-	  for ( j = 0; j < ysize; ++j )
+          gridptr->isCyclic = TRUE;
+	  for ( int j = 0; j < ysize; ++j )
 	    {
-	      i1 = j*xsize*4;
-	      i2 = j*xsize*4+(xsize-1)*4;
-	      nc = 0;
-	      for ( k1 = 0; k1 < 4; ++k1 )
+	      long i1 = j*xsize*4,
+                i2 = j*xsize*4+(xsize-1)*4;
+	      long nc = 0;
+	      for (unsigned k1 = 0; k1 < 4; ++k1 )
 		{
-		  val1 = xbounds[i1+k1];
-		  for ( k2 = 0; k2 < 4; ++k2 )
+		  double val1 = xbounds[i1+k1];
+		  for (unsigned k2 = 0; k2 < 4; ++k2 )
 		    {
-		      val2 = xbounds[i2+k2];
+		      double val2 = xbounds[i2+k2];
 
 		      if ( val1 <    1 && val2 > 300 ) val1 += 360;
 		      if ( val2 <    1 && val1 > 300 ) val2 += 360;
@@ -25980,7 +26357,7 @@ int compareXYvals(int gridID, long xsize, long ysize, double *xvals0, double *yv
 
   if ( !differ && xsize == gridInqXvals(gridID, NULL) )
     {
-      double *xvals = (double *)xmalloc((size_t)xsize * sizeof (double));
+      double *xvals = (double *) Malloc((size_t)xsize * sizeof (double));
 
       gridInqXvals(gridID, xvals);
 
@@ -25991,12 +26368,12 @@ int compareXYvals(int gridID, long xsize, long ysize, double *xvals0, double *yv
 	    break;
 	  }
 
-      free(xvals);
+      Free(xvals);
     }
 
   if ( !differ && ysize == gridInqYvals(gridID, NULL) )
     {
-      double *yvals = (double *)xmalloc((size_t)ysize * sizeof (double));
+      double *yvals = (double *) Malloc((size_t)ysize * sizeof (double));
 
       gridInqYvals(gridID, yvals);
 
@@ -26007,7 +26384,7 @@ int compareXYvals(int gridID, long xsize, long ysize, double *xvals0, double *yv
 	    break;
 	  }
 
-      free(yvals);
+      Free(yvals);
     }
 
   return (differ);
@@ -26035,7 +26412,7 @@ int compareXYvals2(int gridID, int gridsize, double *xvals, double *yvals)
 	differ = 1;
     }
 
-  return (differ);
+  return differ;
 }
 
 
@@ -26165,23 +26542,29 @@ int gridCompare(int gridID, const grid_t *grid)
               unsigned char uuidOfHGrid[CDI_UUID_SIZE];
               gridInqUUID(gridID, uuidOfHGrid);
 
-              if ( !differ && memcmp(uuidOfHGrid, grid->uuid, CDI_UUID_SIZE) != 0 ) differ = 1;
-
-              if ( !differ && grid->nvertex != gridInqNvertex(gridID) ) differ = 1;
-
-              if ( !differ && grid->number != gridInqNumber(gridID) ) differ = 1;
-              if ( !differ && grid->position != gridInqPosition(gridID) ) differ = 1;
+              if ( !differ && uuidOfHGrid[0] && grid->uuid[0] && memcmp(uuidOfHGrid, grid->uuid, CDI_UUID_SIZE) != 0 ) differ = 1;
 
-              if ( !differ && grid->nvertex != gridInqNvertex(gridID) ) differ = 1;
-              if ( !differ && grid->number != gridInqNumber(gridID) ) differ = 1;
-              if ( !differ && grid->number > 0 && grid->position != gridInqPosition(gridID) ) differ = 1;
-	      if ( !differ )
-		differ = compareXYvals2(gridID, grid->size, grid->xvals, grid->yvals);
-	    }
+              if ( !differ &&
+                   ((grid->xvals == NULL && gridInqXvalsPtr(gridID) != NULL) || (grid->xvals != NULL && gridInqXvalsPtr(gridID) == NULL)) &&
+                   ((grid->yvals == NULL && gridInqYvalsPtr(gridID) != NULL) || (grid->yvals != NULL && gridInqYvalsPtr(gridID) == NULL)) )
+                {
+                  if ( !differ && grid->nvertex && gridInqNvertex(gridID) && grid->nvertex != gridInqNvertex(gridID) ) differ = 1;
+                  if ( !differ && grid->number && gridInqNumber(gridID) && grid->number != gridInqNumber(gridID) ) differ = 1;
+                  if ( !differ && grid->number && gridInqNumber(gridID) && grid->position != gridInqPosition(gridID) ) differ = 1;
+                }
+              else
+                {
+                  if ( !differ && grid->nvertex != gridInqNvertex(gridID) ) differ = 1;
+                  if ( !differ && grid->number != gridInqNumber(gridID) ) differ = 1;
+                  if ( !differ && grid->number > 0 && grid->position != gridInqPosition(gridID) ) differ = 1;
+                  if ( !differ )
+                    differ = compareXYvals2(gridID, grid->size, grid->xvals, grid->yvals);
+                }
+              }
 	}
     }
 
-  return (differ);
+  return differ;
 }
 
 
@@ -26413,10 +26796,10 @@ int gridGenerate(const grid_t *grid)
 	else if ( grid->xdef == 2 )
 	  {
 	    double *xvals
-              = (double *)xmalloc((size_t)grid->xsize * sizeof (double));
+              = (double *) Malloc((size_t)grid->xsize * sizeof (double));
 	    gridGenXvals(grid->xsize, grid->xfirst, grid->xlast, grid->xinc, xvals);
 	    gridDefXvals(gridID, xvals);
-	    free(xvals);
+	    Free(xvals);
 	    /*
 	    gridDefXinc(gridID, grid->xinc);
 	    */
@@ -26431,10 +26814,10 @@ int gridGenerate(const grid_t *grid)
 	else if ( grid->ydef == 2 )
 	  {
 	    double *yvals
-              = (double *)xmalloc((size_t)grid->ysize * sizeof (double));
+              = (double *) Malloc((size_t)grid->ysize * sizeof (double));
 	    gridGenYvals(grid->type, grid->ysize, grid->yfirst, grid->ylast, grid->yinc, yvals);
 	    gridDefYvals(gridID, yvals);
-	    free(yvals);
+	    Free(yvals);
 	    /*
 	    gridDefYinc(gridID, grid->yinc);
 	    */
@@ -26516,10 +26899,10 @@ int gridGenerate(const grid_t *grid)
 	else if ( grid->ydef == 2 )
 	  {
 	    double *yvals
-              = (double *)xmalloc((size_t)grid->ysize * sizeof (double));
+              = (double *) Malloc((size_t)grid->ysize * sizeof (double));
 	    gridGenYvals(grid->type, grid->ysize, grid->yfirst, grid->ylast, grid->yinc, yvals);
 	    gridDefYvals(gridID, yvals);
-	    free(yvals);
+	    Free(yvals);
 	    /*
 	    gridDefYinc(gridID, grid->yinc);
 	    */
@@ -26599,13 +26982,13 @@ The function @func{gridDuplicate} duplicates a horizontal Grid.
 */
 int gridDuplicate(int gridID)
 {
-  grid_t *gridptr = reshGetVal(gridID, &gridOps);
+  grid_t *gridptr = (grid_t *)reshGetVal(gridID, &gridOps);
 
   int gridtype = gridInqType(gridID);
   int gridsize = gridInqSize(gridID);
 
   int gridIDnew = gridCreate(gridtype, gridsize);
-  grid_t *gridptrnew = reshGetVal(gridIDnew, &gridOps);
+  grid_t *gridptrnew = (grid_t *)reshGetVal(gridIDnew, &gridOps);
 
   grid_copy(gridptrnew, gridptr);
 
@@ -26625,7 +27008,7 @@ int gridDuplicate(int gridID)
   int irregular = gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED;
   if ( nrowlon )
     {
-      gridptrnew->rowlon = (int *)xmalloc(nrowlon * sizeof (int));
+      gridptrnew->rowlon = (int *) Malloc(nrowlon * sizeof (int));
       memcpy(gridptrnew->rowlon, gridptr->rowlon, nrowlon * sizeof(int));
     }
 
@@ -26633,7 +27016,7 @@ int gridDuplicate(int gridID)
     {
       size_t size  = (size_t)(irregular ? gridsize : gridptr->xsize);
 
-      gridptrnew->xvals = (double *)xmalloc(size * sizeof (double));
+      gridptrnew->xvals = (double *) Malloc(size * sizeof (double));
       memcpy(gridptrnew->xvals, gridptr->xvals, size * sizeof (double));
     }
 
@@ -26641,7 +27024,7 @@ int gridDuplicate(int gridID)
     {
       size_t size  = (size_t)(irregular ? gridsize : gridptr->ysize);
 
-      gridptrnew->yvals = xmalloc(size * sizeof (double));
+      gridptrnew->yvals = (double *) Malloc(size * sizeof (double));
       memcpy(gridptrnew->yvals, gridptr->yvals, size * sizeof (double));
     }
 
@@ -26650,7 +27033,7 @@ int gridDuplicate(int gridID)
       size_t size  = (size_t)(irregular ? gridsize : gridptr->xsize)
         * (size_t)gridptr->nvertex;
 
-      gridptrnew->xbounds = xmalloc(size * sizeof (double));
+      gridptrnew->xbounds = (double *) Malloc(size * sizeof (double));
       memcpy(gridptrnew->xbounds, gridptr->xbounds, size * sizeof (double));
     }
 
@@ -26659,7 +27042,7 @@ int gridDuplicate(int gridID)
       size_t size = (size_t)(irregular ? gridsize : gridptr->ysize)
         * (size_t)gridptr->nvertex;
 
-      gridptrnew->ybounds = xmalloc(size * sizeof (double));
+      gridptrnew->ybounds = (double *) Malloc(size * sizeof (double));
       memcpy(gridptrnew->ybounds, gridptr->ybounds, size * sizeof (double));
     }
 
@@ -26667,7 +27050,7 @@ int gridDuplicate(int gridID)
     {
       size_t size = (size_t)gridsize;
 
-      gridptrnew->area = xmalloc(size * sizeof (double));
+      gridptrnew->area = (double *) Malloc(size * sizeof (double));
       memcpy(gridptrnew->area, gridptr->area, size * sizeof (double));
     }
 
@@ -26675,7 +27058,7 @@ int gridDuplicate(int gridID)
     {
       size_t size = (size_t)gridsize;
 
-      gridptrnew->mask = xmalloc(size * sizeof(mask_t));
+      gridptrnew->mask = (mask_t *) Malloc(size * sizeof(mask_t));
       memcpy(gridptrnew->mask, gridptr->mask, size * sizeof (mask_t));
     }
 
@@ -26683,7 +27066,7 @@ int gridDuplicate(int gridID)
     {
       size_t size = (size_t)gridsize;
 
-      gridptrnew->mask_gme = xmalloc(size * sizeof (mask_t));
+      gridptrnew->mask_gme = (mask_t *) Malloc(size * sizeof (mask_t));
       memcpy(gridptrnew->mask_gme, gridptr->mask_gme, size * sizeof(mask_t));
     }
 
@@ -26735,21 +27118,21 @@ void gridCompress(int gridID)
 	  gridptr->ysize = (int)gridsize;
 
 	  if ( gridptr->xvals )
-	    gridptr->xvals = (double *)xrealloc(gridptr->xvals, gridsize*sizeof(double));
+	    gridptr->xvals = (double *) Realloc(gridptr->xvals, gridsize*sizeof(double));
 
 	  if ( gridptr->yvals )
-	    gridptr->yvals = (double *)xrealloc(gridptr->yvals, gridsize*sizeof(double));
+	    gridptr->yvals = (double *) Realloc(gridptr->yvals, gridsize*sizeof(double));
 
 	  if ( gridptr->area )
-	    gridptr->area  = (double *)xrealloc(gridptr->area, gridsize*sizeof(double));
+	    gridptr->area  = (double *) Realloc(gridptr->area, gridsize*sizeof(double));
 
 	  if ( gridptr->xbounds )
-	    gridptr->xbounds = (double *)xrealloc(gridptr->xbounds, nv*gridsize*sizeof(double));
+	    gridptr->xbounds = (double *) Realloc(gridptr->xbounds, nv*gridsize*sizeof(double));
 
 	  if ( gridptr->ybounds )
-	    gridptr->ybounds = (double *)xrealloc(gridptr->ybounds, nv*gridsize*sizeof(double));
+	    gridptr->ybounds = (double *) Realloc(gridptr->ybounds, nv*gridsize*sizeof(double));
 
-	  free(gridptr->mask_gme);
+	  Free(gridptr->mask_gme);
 	  gridptr->mask_gme = NULL;
           reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
 	}
@@ -26769,7 +27152,7 @@ void gridDefArea(int gridID, const double *area)
     Error("size undefined for gridID = %d", gridID);
 
   if ( gridptr->area == NULL )
-    gridptr->area = (double *)xmalloc(size*sizeof(double));
+    gridptr->area = (double *) Malloc(size*sizeof(double));
   else if ( CDI_Debug )
     Warning("values already defined!");
 
@@ -26857,7 +27240,7 @@ void gridDefXbounds(int gridID, const double *xbounds)
     Error("size undefined for gridID = %d", gridID);
 
   if (gridptr->xbounds == NULL)
-    gridptr->xbounds = xmalloc(size * sizeof (double));
+    gridptr->xbounds = (double *) Malloc(size * sizeof (double));
   else if ( CDI_Debug )
     Warning("values already defined!");
 
@@ -26944,7 +27327,7 @@ void gridDefYbounds(int gridID, const double *ybounds)
     Error("size undefined for gridID = %d", gridID);
 
   if ( gridptr->ybounds == NULL )
-    gridptr->ybounds = xmalloc(size * sizeof (double));
+    gridptr->ybounds = (double *) Malloc(size * sizeof (double));
   else if ( CDI_Debug )
     Warning("values already defined!");
 
@@ -26999,7 +27382,7 @@ const double *gridInqYboundsPtr(int gridID)
 }
 
 
-void gridPrintKernel(grid_t * gridptr, int index, int opt, FILE *fp)
+static void gridPrintKernel(grid_t * gridptr, int index, int opt, FILE *fp)
 {
   int xdim, ydim;
   int nbyte;
@@ -27248,7 +27631,7 @@ void gridPrintKernel(grid_t * gridptr, int index, int opt, FILE *fp)
             int *rowlon;
             nbyte0 = fprintf(fp, "rowlon    = ");
             nbyte  = nbyte0;
-            rowlon = (int *)xmalloc((size_t)ysize*sizeof(int));
+            rowlon = (int *) Malloc((size_t)ysize*sizeof(int));
             gridInqRowlon(gridID, rowlon);
             for ( i = 0; i < ysize; i++ )
               {
@@ -27261,7 +27644,7 @@ void gridPrintKernel(grid_t * gridptr, int index, int opt, FILE *fp)
                 nbyte += fprintf(fp, "%d ", rowlon[i]);
               }
             fprintf(fp, "\n");
-            free(rowlon);
+            Free(rowlon);
           }
 
 	break;
@@ -27754,7 +28137,7 @@ void gridDefReference(int gridID, const char *reference)
     {
       if ( gridptr->reference )
         {
-          free(gridptr->reference);
+          Free(gridptr->reference);
           gridptr->reference = NULL;
         }
 
@@ -28022,13 +28405,13 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
     gridP->prec          =   intBuffer[2];
     gridP->lcc_projflag  =   intBuffer[3];
     gridP->lcc_scanflag  =   intBuffer[4];
-    gridP->lcc_defined   =   intBuffer[5];
-    gridP->lcc2_defined  =   intBuffer[6];
+    gridP->lcc_defined   =   (short)intBuffer[5];
+    gridP->lcc2_defined  =   (short)intBuffer[6];
     gridP->laea_defined  =   intBuffer[7];
-    gridP->isCyclic      =   intBuffer[8];
-    gridP->isRotated     =   intBuffer[9];
-    gridP->xdef          =   intBuffer[10];
-    gridP->ydef          =   intBuffer[11];
+    gridP->isCyclic      =   (short)intBuffer[8];
+    gridP->isRotated     =   (short)intBuffer[9];
+    gridP->xdef          =   (short)intBuffer[10];
+    gridP->ydef          =   (short)intBuffer[11];
     gridP->nd            =   intBuffer[12];
     gridP->ni            =   intBuffer[13];
     gridP->ni2           =   intBuffer[14];
@@ -28049,7 +28432,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
   if (memberMask & gridHasRowLonFlag)
     {
       xassert(gridP->nrowlon);
-      gridP->rowlon = (int *)xmalloc((size_t)gridP->nrowlon * sizeof (int));
+      gridP->rowlon = (int *) Malloc((size_t)gridP->nrowlon * sizeof (int));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->rowlon, gridP->nrowlon , DATATYPE_INT, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -28097,7 +28480,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
     {
       size = irregular ? gridP->size : gridP->xsize;
 
-      gridP->xvals = (double *)xmalloc((size_t)size * sizeof (double));
+      gridP->xvals = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->xvals, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -28109,7 +28492,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
     {
       size = irregular ? gridP->size : gridP->ysize;
 
-      gridP->yvals = (double *)xmalloc((size_t)size * sizeof (double));
+      gridP->yvals = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->yvals, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -28121,7 +28504,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
     {
       size = gridP->size;
       xassert(size);
-      gridP->area = (double *)xmalloc((size_t)size * sizeof (double));
+      gridP->area = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->area, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -28134,7 +28517,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
       size = gridP->nvertex * (irregular ? gridP->size : gridP->xsize);
       xassert(size);
 
-      gridP->xbounds = (double *)xmalloc((size_t)size * sizeof (double));
+      gridP->xbounds = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->xbounds, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -28147,7 +28530,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
       size = gridP->nvertex * (irregular ? gridP->size : gridP->ysize);
       xassert(size);
 
-      gridP->ybounds = (double *)xmalloc((size_t)size * sizeof (double));
+      gridP->ybounds = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
 			  gridP->ybounds, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -28167,7 +28550,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
       int referenceSize;
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       &referenceSize, 1, DATATYPE_INT, context);
-      gridP->reference = (char *)xmalloc((size_t)referenceSize);
+      gridP->reference = (char *) Malloc((size_t)referenceSize);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->reference, referenceSize, DATATYPE_TXT, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -28178,7 +28561,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
   if (memberMask & gridHasMaskFlag)
     {
       xassert((size = gridP->size));
-      gridP->mask = (mask_t *)xmalloc((size_t)size * sizeof (mask_t));
+      gridP->mask = (mask_t *) Malloc((size_t)size * sizeof (mask_t));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->mask, gridP->size, DATATYPE_UCHAR, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -28189,7 +28572,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
   if (memberMask & gridHasGMEMaskFlag)
     {
       xassert((size = gridP->size));
-      gridP->mask_gme = (mask_t *)xmalloc((size_t)size * sizeof (mask_t));
+      gridP->mask_gme = (mask_t *) Malloc((size_t)size * sizeof (mask_t));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->mask_gme, gridP->size, DATATYPE_UCHAR, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -28201,6 +28584,9 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->uuid, CDI_UUID_SIZE, DATATYPE_UCHAR, context);
     }
+
+  reshSetStatus(gridP->self, &gridOps,
+                reshGetStatus(gridP->self, &gridOps) & ~RESH_SYNC_BIT);
 }
 
 
@@ -28416,6 +28802,84 @@ gridPack(void * voidP, void * packBuffer, int packBufferSize,
 
 #undef GRID_STR_SERIALIZE
 
+
+struct varDefGridSearchState
+{
+  int resIDValue;
+  const grid_t *queryKey;
+};
+
+static enum cdiApplyRet
+varDefGridSearch(int id, void *res, void *data)
+{
+  struct varDefGridSearchState *state = (struct varDefGridSearchState*)data;
+  (void)res;
+  if (gridCompare(id, state->queryKey) == 0)
+    {
+      state->resIDValue = id;
+      return CDI_APPLY_STOP;
+    }
+  else
+    return CDI_APPLY_GO_ON;
+}
+
+int varDefGrid(int vlistID, const grid_t *grid, int mode)
+{
+  /*
+    mode: 0 search in vlist and grid table
+          1 search in grid table
+   */
+  int gridglobdefined = FALSE;
+  int griddefined;
+  int gridID = CDI_UNDEFID;
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+
+  griddefined = FALSE;
+  unsigned ngrids = (unsigned)vlistptr->ngrids;
+
+  if ( mode == 0 )
+    for (unsigned index = 0; index < ngrids; index++ )
+      {
+	gridID = vlistptr->gridIDs[index];
+	if ( gridID == UNDEFID )
+	  Error("Internal problem: undefined gridID %d!", gridID);
+
+	if ( gridCompare(gridID, grid) == 0 )
+	  {
+	    griddefined = TRUE;
+	    break;
+	  }
+      }
+
+  if ( ! griddefined )
+    {
+      struct varDefGridSearchState query;
+      query.queryKey = grid;// = { .queryKey = grid };
+      if ((gridglobdefined
+           = (cdiResHFilterApply(&gridOps, varDefGridSearch, &query)
+              == CDI_APPLY_STOP)))
+        gridID = query.resIDValue;
+
+      if ( mode == 1 && gridglobdefined)
+	for (unsigned index = 0; index < ngrids; index++ )
+	  if ( vlistptr->gridIDs[index] == gridID )
+	    {
+	      gridglobdefined = FALSE;
+	      break;
+	    }
+    }
+
+  if ( ! griddefined )
+    {
+      if ( ! gridglobdefined ) gridID = gridGenerate(grid);
+      ngrids = (unsigned)vlistptr->ngrids;
+      vlistptr->gridIDs[ngrids] = gridID;
+      vlistptr->ngrids++;
+    }
+
+  return (gridID);
+}
+
 /*
  * Local Variables:
  * c-file-style: "Java"
@@ -28429,13 +28893,13 @@ gridPack(void * voidP, void * packBuffer, int packBufferSize,
 #endif
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
 #include <ctype.h>
 
 
 
-
 static int initIegLib      = 0;
 static int iegDefaultDprec = 0;
 
@@ -28443,30 +28907,26 @@ static int iegDefaultDprec = 0;
 /*
  * A version string.
  */
-
 #undef  LIBVERSION
-#define LIBVERSION      1.3.3
+#define LIBVERSION      1.4.0
 #define XSTRING(x)	#x
 #define STRING(x)	XSTRING(x)
-static const char ieg_libvers[] = STRING(LIBVERSION) " of "__DATE__" "__TIME__;
+static const char ieg_libvers[] = STRING(LIBVERSION) " of " __DATE__ " " __TIME__;
 
 const char *iegLibraryVersion(void)
 {
-  return (ieg_libvers);
+  return ieg_libvers;
 }
 
 
-int IEG_Debug = 0;    /* If set to 1, debugging */
-
-
+static int IEG_Debug = 0;    /* If set to 1, debugging */
 
-void iegLibInit()
+static
+void iegLibInit(void)
 {
-  char *envString;
-  char *envName = "IEG_PRECISION";
+  const char *envName = "IEG_PRECISION";
 
-
-  envString = getenv(envName);
+  char *envString = getenv(envName);
   if ( envString )
     {
       int pos;
@@ -28483,8 +28943,8 @@ void iegLibInit()
 	      {
 		switch ( (int) envString[pos+1] )
 		  {
-		  case '4': iegDefaultDprec = SINGLE_PRECISION; break;
-		  case '8': iegDefaultDprec = DOUBLE_PRECISION; break;
+		  case '4': iegDefaultDprec = EXSE_SINGLE_PRECISION; break;
+		  case '8': iegDefaultDprec = EXSE_DOUBLE_PRECISION; break;
 		  default:
 		    Message("Invalid digit in %s: %s", envName, envString);
 		  }
@@ -28512,7 +28972,7 @@ void iegDebug(int debug)
     Message("debug level %d", debug);
 }
 
-
+static
 void iegInit(iegrec_t *iegp)
 {
   iegp->checked    = 0;
@@ -28525,52 +28985,52 @@ void iegInit(iegrec_t *iegp)
 }
 
 
-void iegInitMem(iegrec_t *iegp)
+void iegInitMem(void *ieg)
 {
+  iegrec_t *iegp = (iegrec_t *) ieg;
+
   memset(iegp->ipdb, 0, sizeof(iegp->ipdb));
   memset(iegp->igdb, 0, sizeof(iegp->igdb));
   memset(iegp->vct,  0, sizeof(iegp->vct));
 }
 
 
-iegrec_t *iegNew(void)
+void *iegNew(void)
 {
-  iegrec_t *iegp;
-
   if ( ! initIegLib ) iegLibInit();
 
-  iegp = (iegrec_t *) malloc(sizeof(iegrec_t));
+  iegrec_t *iegp = (iegrec_t *) Malloc(sizeof(iegrec_t));
 
   iegInit(iegp);
   iegInitMem(iegp);
 
-  return (iegp);
+  return (void*)iegp;
 }
 
 
-void iegDelete(iegrec_t *iegp)
+void iegDelete(void *ieg)
 {
+  iegrec_t *iegp = (iegrec_t *) ieg;
+
   if ( iegp )
     {
-      if ( iegp->buffer ) free(iegp->buffer);
-      free(iegp);
+      if ( iegp->buffer ) Free(iegp->buffer);
+      Free(iegp);
     }
 }
 
 
 int iegCheckFiletype(int fileID, int *swap)
 {
-  size_t blocklen = 0;
-  size_t sblocklen = 0;
   size_t data = 0;
   size_t dimx = 0, dimy = 0;
   size_t fact = 0;
   unsigned char buffer[1048], *pbuf;
 
-  if ( fileRead(fileID, buffer, 4) != 4 ) return (0);
+  if ( fileRead(fileID, buffer, 4) != 4 ) return 0;
 
-  blocklen  = get_UINT32(buffer);
-  sblocklen = get_SUINT32(buffer);
+  size_t blocklen  = get_UINT32(buffer);
+  size_t sblocklen = get_SUINT32(buffer);
 
   if ( IEG_Debug )
     Message("blocklen = %d sblocklen = %d", blocklen, sblocklen);
@@ -28579,7 +29039,7 @@ int iegCheckFiletype(int fileID, int *swap)
     {
      *swap = 0;
       fact = 4;
-      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return (0);
+      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return 0;
       pbuf = buffer+(37+4)*4;    dimx = (size_t) get_UINT32(pbuf);
       pbuf = buffer+(37+5)*4;    dimy = (size_t) get_UINT32(pbuf);
       pbuf = buffer+blocklen+4;  data = (size_t) get_UINT32(pbuf);
@@ -28588,7 +29048,7 @@ int iegCheckFiletype(int fileID, int *swap)
     {
      *swap = 0;
       fact = 8;
-      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return (0);
+      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return 0;
       pbuf = buffer+(37+4)*4;    dimx = (size_t) get_UINT32(pbuf);
       pbuf = buffer+(37+5)*4;    dimy = (size_t) get_UINT32(pbuf);
       pbuf = buffer+blocklen+4;  data = (size_t) get_UINT32(pbuf);
@@ -28597,7 +29057,7 @@ int iegCheckFiletype(int fileID, int *swap)
     {
      *swap = 1;
       fact = 4;
-      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return (0);
+      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return 0;
       pbuf = buffer+(37+4)*4;     dimx = (size_t) get_SUINT32(pbuf);
       pbuf = buffer+(37+5)*4;     dimy = (size_t) get_SUINT32(pbuf);
       pbuf = buffer+sblocklen+4;  data = (size_t) get_SUINT32(pbuf);
@@ -28606,7 +29066,7 @@ int iegCheckFiletype(int fileID, int *swap)
     {
      *swap = 1;
       fact = 8;
-      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return (0);
+      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return 0;
       pbuf = buffer+(37+4)*4;     dimx = (size_t) get_SUINT32(pbuf);
       pbuf = buffer+(37+5)*4;     dimy = (size_t) get_SUINT32(pbuf);
       pbuf = buffer+sblocklen+4;  data = (size_t) get_SUINT32(pbuf);
@@ -28622,12 +29082,15 @@ int iegCheckFiletype(int fileID, int *swap)
       Message("dimx = %lu dimy = %lu data = %lu", dimx, dimy, data);
     }
 
-  return (found);
+  return found;
 }
 
 
-void iegCopyMeta(iegrec_t *diegp, iegrec_t *siegp)
+void iegCopyMeta(void *dieg, void *sieg)
 {
+  iegrec_t *diegp = (iegrec_t *) dieg;
+  iegrec_t *siegp = (iegrec_t *) sieg;
+
   /*  diegp->byteswap = siegp->byteswap; */
   diegp->dprec    = siegp->dprec;
   diegp->refval   = siegp->refval;
@@ -28637,26 +29100,19 @@ void iegCopyMeta(iegrec_t *diegp, iegrec_t *siegp)
   memcpy(diegp->vct,  siegp->vct,  sizeof(siegp->vct));
 }
 
-
-int iegInqData(iegrec_t *iegp, int prec, void *data)
+static
+int iegInqData(void *ieg, int prec, void *data)
 {
-  size_t datasize;
-  size_t i;
+  iegrec_t *iegp = (iegrec_t *) ieg;
   int ierr = 0;
-  int dprec;
-  void *buffer;
   int byteswap = iegp->byteswap;
-
-
-  datasize = iegp->datasize;
-
-  buffer = iegp->buffer;
-
-  dprec = iegp->dprec;
+  size_t datasize = iegp->datasize;
+  void *buffer = iegp->buffer;
+  int dprec = iegp->dprec;
 
   switch ( dprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	if ( sizeof(FLT32) == 4 )
 	  {
@@ -28665,8 +29121,12 @@ int iegInqData(iegrec_t *iegp, int prec, void *data)
 	    if ( dprec == prec )
 	      memcpy(data, buffer, datasize*sizeof(FLT32));
 	    else
-	      for (i = 0; i < datasize; i++)
-		((double *) data)[i] = (double) ((float *) buffer)[i];
+              {
+                const float *restrict p = (float *)buffer;
+                double *restrict q = (double *)data;
+                for ( size_t i = 0; i < datasize; i++)
+                  q[i] = p[i];
+              }
 	  }
 	else
 	  {
@@ -28674,7 +29134,7 @@ int iegInqData(iegrec_t *iegp, int prec, void *data)
 	  }
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
 	if ( sizeof(FLT64) == 8 )
 	  {
 	    if ( byteswap ) swap8byte(buffer, datasize);
@@ -28682,8 +29142,12 @@ int iegInqData(iegrec_t *iegp, int prec, void *data)
 	    if ( dprec == prec )
 	      memcpy(data, buffer, datasize*sizeof(FLT64));
 	    else
-	      for (i = 0; i < datasize; i++)
-		((float *) data)[i] = (float) ((double *) buffer)[i];
+              {
+                const double *restrict p = (double *)buffer;
+                float *restrict q = (float *)data;
+                for ( size_t i = 0; i < datasize; i++)
+                  q[i] = (float)p[i];
+              }
 	  }
 	else
 	  {
@@ -28697,32 +29161,28 @@ int iegInqData(iegrec_t *iegp, int prec, void *data)
       }
     }
 
-  return (ierr);
+  return ierr;
 }
 
 
-int iegInqDataSP(iegrec_t *iegp, float *data)
+int iegInqDataSP(void *ieg, float *data)
 {
-  return (iegInqData(iegp, SINGLE_PRECISION, (void *) data));
+  return iegInqData(ieg, EXSE_SINGLE_PRECISION, (void *) data);
 }
 
 
-int iegInqDataDP(iegrec_t *iegp, double *data)
+int iegInqDataDP(void *ieg, double *data)
 {
-  return (iegInqData(iegp, DOUBLE_PRECISION, (void *) data));
+  return iegInqData(ieg, EXSE_DOUBLE_PRECISION, (void *) data);
 }
 
 
-int iegDefData(iegrec_t *iegp, int prec, const void *data)
+static int
+iegDefData(iegrec_t *iegp, int prec, const void *data)
 {
-  size_t datasize;
-  size_t blocklen;
-  size_t buffersize;
-  size_t i;
   int dprec;
   void *buffer;
 
-
   if ( iegDefaultDprec ) dprec = iegDefaultDprec;
   else                   dprec = iegp->dprec;
 
@@ -28730,18 +29190,18 @@ int iegDefData(iegrec_t *iegp, int prec, const void *data)
 
   iegp->dprec = dprec;
 
-  datasize = (size_t)IEG_G_NumLon(iegp->igdb) * (size_t)IEG_G_NumLat(iegp->igdb);
-  blocklen = datasize * (size_t)dprec;
+  size_t datasize = (size_t)IEG_G_NumLon(iegp->igdb) * (size_t)IEG_G_NumLat(iegp->igdb);
+  size_t blocklen = datasize * (size_t)dprec;
 
   iegp->datasize = datasize;
 
-  buffersize = iegp->buffersize;
+  size_t buffersize = iegp->buffersize;
 
   if ( buffersize != blocklen )
     {
       buffersize = blocklen;
       buffer = iegp->buffer;
-      buffer = realloc(buffer, buffersize);
+      buffer = Realloc(buffer, buffersize);
       iegp->buffer = buffer;
       iegp->buffersize = buffersize;
     }
@@ -28750,24 +29210,30 @@ int iegDefData(iegrec_t *iegp, int prec, const void *data)
 
   switch ( dprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	if ( dprec == prec )
 	  memcpy(buffer, data, datasize*sizeof(FLT32));
 	else
-	  for (i = 0; i < datasize; i++)
-	    ((float *) buffer)[i] = (float) ((double *) data)[i];
-
+          {
+            const double *restrict p = (const double *)data;
+            float *restrict q = (float *)buffer;
+            for (size_t i = 0; i < datasize; i++)
+              q[i] = (float)p[i];
+          }
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
 	if ( dprec == prec )
 	  memcpy(buffer, data, datasize*sizeof(FLT64));
 	else
-	  for (i = 0; i < datasize; i++)
-	    ((double *) buffer)[i] = (double) ((float *) data)[i];
-
+          {
+            const float *restrict p = (const float *)data;
+            double *restrict q = (double *)buffer;
+            for ( size_t i = 0; i < datasize; i++)
+              q[i] = p[i];
+          }
 	break;
       }
     default:
@@ -28777,50 +29243,45 @@ int iegDefData(iegrec_t *iegp, int prec, const void *data)
       }
     }
 
-  return (0);
+  return 0;
 }
 
 
-int iegDefDataSP(iegrec_t *iegp, const float *data)
+int iegDefDataSP(void *ieg, const float *data)
 {
-  return (iegDefData(iegp, SINGLE_PRECISION, (void *) data));
+  return iegDefData((iegrec_t *)ieg, EXSE_SINGLE_PRECISION, (void *) data);
 }
 
 
-int iegDefDataDP(iegrec_t *iegp, const double *data)
+int iegDefDataDP(void *ieg, const double *data)
 {
-  return (iegDefData(iegp, DOUBLE_PRECISION, (void *) data));
+  return iegDefData((iegrec_t *)ieg, EXSE_DOUBLE_PRECISION, (void *) data);
 }
 
 
-int iegRead(int fileID, iegrec_t *iegp)
+int iegRead(int fileID, void *ieg)
 {
-  size_t datasize;
-  size_t blocklen, blocklen2;
-  size_t i;
-  char tmpbuffer[800], *tmpbuf = tmpbuffer;
-  int dprec = 0;
-  void *buffer;
-  int byteswap;
-  int status;
+  iegrec_t *iegp = (iegrec_t *) ieg;
+  union { double d[200]; float f[200]; int32_t i32[200]; } buf;
 
   if ( ! iegp->checked )
     {
-      status = iegCheckFiletype(fileID, &iegp->byteswap);
+      int status = iegCheckFiletype(fileID, &iegp->byteswap);
       if ( status == 0 ) Error("Not a IEG file!");
       iegp->checked = 1;
     }
 
-  byteswap = iegp->byteswap;
+  int byteswap = iegp->byteswap;
 
   /* read header record */
-  blocklen = binReadF77Block(fileID, byteswap);
+  size_t blocklen = binReadF77Block(fileID, byteswap);
 
-  if ( fileEOF(fileID) ) return (-1);
+  if ( fileEOF(fileID) ) return -1;
 
   if ( IEG_Debug )
     Message("blocklen = %lu", blocklen);
 
+  int dprec = 0;
   if ( blocklen == 636 || blocklen == 640 )
     dprec = 4;
   else if ( blocklen == 1040 || blocklen == 1036 )
@@ -28828,98 +29289,91 @@ int iegRead(int fileID, iegrec_t *iegp)
   else
     {
       Warning("unexpecteted header size %d!", (int) blocklen);
-      return (-1);
+      return -1;
     }
 
   iegp->dprec = dprec;
 
-  binReadInt32(fileID, byteswap, 37, (INT32 *) tmpbuf);
-  for ( i = 0; i < 37; i++ ) iegp->ipdb[i] = (int) ((INT32 *) tmpbuf)[i];
+  binReadInt32(fileID, byteswap, 37, buf.i32);
+  for ( size_t i = 0; i < 37; i++ ) iegp->ipdb[i] = (int)buf.i32[i];
 
-  binReadInt32(fileID, byteswap, 18, (INT32 *) tmpbuf);
-  for ( i = 0; i < 18; i++ ) iegp->igdb[i] = (int) ((INT32 *) tmpbuf)[i];
+  binReadInt32(fileID, byteswap, 18, buf.i32);
+  for ( size_t i = 0; i < 18; i++ ) iegp->igdb[i] = (int)buf.i32[i];
 
   if ( blocklen == 636 || blocklen == 1036 )
     {
-      fileRead(fileID, tmpbuf, 4);
-      if ( byteswap ) swap4byte(tmpbuf, 1);
-      iegp->refval = (double) ((float *) tmpbuf)[0];
+      fileRead(fileID, buf.f, 4);
+      if ( byteswap ) swap4byte(buf.f, 1);
+      iegp->refval = (double)buf.f[0];
     }
   else
     {
-      fileRead(fileID, tmpbuf, 8);
-      if ( byteswap ) swap8byte(tmpbuf, 1);
-      iegp->refval = (double) ((double *) tmpbuf)[0];
+      fileRead(fileID, buf.d, 8);
+      if ( byteswap ) swap8byte(buf.d, 1);
+      iegp->refval = (double)buf.d[0];
     }
 
-  binReadInt32(fileID, byteswap, 3, (INT32 *) tmpbuf);
-  for ( i = 0; i < 3; i++ ) iegp->igdb[18+i] = (int) ((INT32 *) tmpbuf)[i];
+  binReadInt32(fileID, byteswap, 3, buf.i32);
+  for ( size_t i = 0; i < 3; i++ ) iegp->igdb[18+i] = (int)buf.i32[i];
 
-  if ( dprec == SINGLE_PRECISION )
+  if ( dprec == EXSE_SINGLE_PRECISION )
     {
-      fileRead(fileID, tmpbuf, 400);
-      if ( byteswap ) swap4byte(tmpbuf, 100);
-      for ( i = 0; i < 100; i++ )
-	iegp->vct[i] = (double) ((float *) tmpbuf)[i];
+      fileRead(fileID, buf.f, 400);
+      if ( byteswap ) swap4byte(buf.f, 100);
+      for ( size_t i = 0; i < 100; i++ )
+	iegp->vct[i] = (double)buf.f[i];
     }
   else
     {
-      fileRead(fileID, tmpbuf, 800);
-      if ( byteswap ) swap8byte(tmpbuf, 100);
-      for ( i = 0; i < 100; i++ )
-	iegp->vct[i] = (double) ((double *) tmpbuf)[i];
+      fileRead(fileID, buf.d, 800);
+      if ( byteswap ) swap8byte(buf.d, 100);
+      for ( size_t i = 0; i < 100; i++ )
+	iegp->vct[i] = buf.d[i];
     }
 
   /*
   fprintf(stderr, "refval %g\n", iegp->refval);
 
-  for ( i = 0; i < 100; i++ )
+  for ( size_t i = 0; i < 100; i++ )
     fprintf(stderr, "%3d %g\n", i, iegp->vct[i]);
 
   {
     int i;
-    for ( i = 0; i < 37; i++ )
+    for ( size_t i = 0; i < 37; i++ )
       fprintf(stderr, "pdb: %d %d\n", i, iegp->ipdb[i]);
-    for ( i = 0; i < 22; i++ )
+    for ( size_t i = 0; i < 22; i++ )
       fprintf(stderr, "gdb: %d %d\n", i, iegp->igdb[i]);
   }
   */
-  blocklen2 = binReadF77Block(fileID, byteswap);
+  size_t blocklen2 = binReadF77Block(fileID, byteswap);
 
   if ( blocklen2 != blocklen )
     {
       Warning("header blocklen differ!");
-      return (-1);
+      return -1;
     }
 
-  iegp->datasize = (size_t)IEG_G_NumLon(iegp->igdb)
-    * (size_t)IEG_G_NumLat(iegp->igdb);
+  size_t datasize = iegp->datasize
+    = (size_t)IEG_G_NumLon(iegp->igdb) * (size_t)IEG_G_NumLat(iegp->igdb);
 
   if ( IEG_Debug )
     Message("datasize = %lu", iegp->datasize);
 
   blocklen = binReadF77Block(fileID, byteswap);
 
-  size_t buffersize = iegp->buffersize;
 
-  if ( buffersize < blocklen )
+  void *buffer = iegp->buffer;
+  if ( iegp->buffersize < blocklen )
     {
-      buffersize = blocklen;
-      buffer = iegp->buffer;
-      buffer = realloc(buffer, buffersize);
-      iegp->buffer = buffer;
-      iegp->buffersize = buffersize;
+      iegp->buffer = buffer = Realloc(buffer, blocklen);
+      iegp->buffersize = blocklen;
     }
-  else
-    buffer = iegp->buffer;
-
-  datasize = iegp->datasize;
 
   if ( dprec != (int) (blocklen/datasize) )
     {
       Warning("data precision differ! (h = %d; d = %d)",
 	      (int) dprec, (int) (blocklen/datasize));
-      return (-1);
+      return -1;
     }
 
   fileRead(fileID, buffer, blocklen);
@@ -28929,57 +29383,45 @@ int iegRead(int fileID, iegrec_t *iegp)
   if ( blocklen2 != blocklen )
     {
       Warning("data blocklen differ!");
-      return (-1);
+      return -1;
     }
 
-  return (0);
+  return 0;
 }
 
 
-int iegWrite(int fileID, iegrec_t *iegp)
+int iegWrite(int fileID, void *ieg)
 {
-  size_t datasize;
-  size_t blocklen;
-  size_t i;
-  int dprec;
-  float refvalf;
-  double refval;
-  char tmpbuf[800];
-  float fvct[100];
-  void *buffer;
+  iegrec_t *iegp = (iegrec_t *) ieg;
+  union { INT32 i32[200]; float fvct[100]; } buf;
+  int dprec  = iegp->dprec;
   int byteswap = iegp->byteswap;
 
-
-  dprec  = iegp->dprec;
-
   /* write header record */
-  if ( dprec == SINGLE_PRECISION )
-    blocklen = 636;
-  else
-    blocklen = 1040;
+  size_t blocklen = ( dprec == EXSE_SINGLE_PRECISION ) ? 636 : 1040;
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
-  for ( i = 0; i < 37; i++ ) ((INT32 *) tmpbuf)[i] = (INT32) iegp->ipdb[i];
-  binWriteInt32(fileID, byteswap, 37, (INT32 *) tmpbuf);
+  for ( size_t i = 0; i < 37; i++ ) buf.i32[i] = (INT32) iegp->ipdb[i];
+  binWriteInt32(fileID, byteswap, 37, buf.i32);
 
-  for ( i = 0; i < 18; i++ ) ((INT32 *) tmpbuf)[i] = (INT32) iegp->igdb[i];
-  binWriteInt32(fileID, byteswap, 18, (INT32 *) tmpbuf);
+  for ( size_t i = 0; i < 18; i++ ) buf.i32[i] = (INT32) iegp->igdb[i];
+  binWriteInt32(fileID, byteswap, 18, buf.i32);
 
-  refval = iegp->refval;
-  refvalf = (float) refval;
-  if ( dprec == SINGLE_PRECISION )
-    binWriteFlt32(fileID, byteswap, 1, (FLT32 *) &refvalf);
+  FLT64 refval = (FLT64)iegp->refval;
+  FLT32 refvalf = (FLT32)iegp->refval;
+  if ( dprec == EXSE_SINGLE_PRECISION )
+    binWriteFlt32(fileID, byteswap, 1, &refvalf);
   else
-    binWriteFlt64(fileID, byteswap, 1, (FLT64 *) &refval);
+    binWriteFlt64(fileID, byteswap, 1, &refval);
 
-  for ( i = 0; i < 3; i++ ) ((INT32 *) tmpbuf)[i] = (INT32) iegp->igdb[18+i];
-  binWriteInt32(fileID, byteswap, 3, (INT32 *) tmpbuf);
+  for ( size_t i = 0; i < 3; i++ ) buf.i32[i] = (INT32) iegp->igdb[18+i];
+  binWriteInt32(fileID, byteswap, 3, buf.i32);
 
-  if ( dprec == SINGLE_PRECISION )
+  if ( dprec == EXSE_SINGLE_PRECISION )
     {
-      for ( i = 0; i < 100; i++ ) fvct[i] = (float) iegp->vct[i];
-      binWriteFlt32(fileID, byteswap, 100, fvct);
+      for ( size_t i = 0; i < 100; i++ ) buf.fvct[i] = (float) iegp->vct[i];
+      binWriteFlt32(fileID, byteswap, 100, buf.fvct);
     }
   else
     {
@@ -28988,23 +29430,23 @@ int iegWrite(int fileID, iegrec_t *iegp)
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
-  datasize = (size_t)iegp->igdb[4] * (size_t)iegp->igdb[5];
+  size_t datasize = (size_t)iegp->igdb[4] * (size_t)iegp->igdb[5];
   blocklen = datasize * (size_t)dprec;
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
   iegp->datasize = datasize;
 
-  buffer = iegp->buffer;
+  void *buffer = iegp->buffer;
 
   switch ( dprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	binWriteFlt32(fileID, byteswap, datasize, (FLT32 *) buffer);
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
 	binWriteFlt64(fileID, byteswap, datasize, (FLT64 *) buffer);
 	break;
@@ -29018,7 +29460,7 @@ int iegWrite(int fileID, iegrec_t *iegp)
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
-  return (0);
+  return 0;
 }
 /*
  * Local Variables:
@@ -29039,7 +29481,7 @@ int iegWrite(int fileID, iegrec_t *iegp)
 /*
 This is a base class for all objects that need reference counting.
 A CdiReferencedObject has a reference count of one when it is constructed, refObjectRetain() increments the reference count, refObject Release() decrements it.
-When the reference count reaches zero, the destructor function is called before the memory of the object is deallocated with free().
+When the reference count reaches zero, the destructor function is called before the memory of the object is deallocated with Free().
 
 >>> Warning <<<
 This code is currently not thread-safe.
@@ -29066,6 +29508,16 @@ void cdiRefObject_release(CdiReferencedObject* me);
 void cdiRefObject_destruct(CdiReferencedObject* me);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #ifndef INCLUDE_GUARD_CDI_GRIB_FILE_H
 #define INCLUDE_GUARD_CDI_GRIB_FILE_H
 
@@ -29088,11 +29540,24 @@ typedef struct CdiInputFile {
 //Final class, the constructor is private and not defined here.
 CdiInputFile* cdiInputFile_make(const char* path);   //The caller is responsible to call cdiRefObject_release() on the returned object.
 int cdiInputFile_read(const CdiInputFile* me, off_t readPosition, size_t readSize, size_t* outActualReadSize, void* buffer);       //Returns one of CDI_EINVAL, CDI_ESYSTEM, CDI_EEOF, OR CDI_NOERR.
-char* cdiInputFile_copyPath(const CdiInputFile* me);    //Returns a malloc'ed string, don't forget to free() it.
+/* Returns path string, don't use after destruction of CdiInputFile
+ * object */
+const char* cdiInputFile_getPath(const CdiInputFile* me);
 //Destructor is private as well.
 
 #endif
 
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
+#define _XOPEN_SOURCE 600
+
 
 #include <errno.h>
 #include <fcntl.h>
@@ -29110,7 +29575,7 @@ static CdiInputFile* cdiInputFile_condestruct(CdiInputFile* me, const char* path
   #define super() (&me->super)
   if(!path) goto destruct;
   cdiRefObject_construct(super());
-  me->path = myStrDup(path);
+  me->path = strdup(path);
   if(!me->path) goto destructSuper;
   do
     {
@@ -29129,7 +29594,7 @@ static CdiInputFile* cdiInputFile_condestruct(CdiInputFile* me, const char* path
 destruct:
   close(me->fileDescriptor);
 freePath:
-  free(me->path);
+  Free(me->path);
 destructSuper:
   cdiRefObject_destruct(super());
   me = NULL;
@@ -29139,7 +29604,7 @@ success:
   #undef super
 }
 
-static CdiInputFile** openFileList = NULL;
+static CdiInputFile **openFileList = NULL;
 static size_t openFileCount = 0, openFileListSize = 0;
 static pthread_mutex_t openFileListLock = PTHREAD_MUTEX_INITIALIZER;
 
@@ -29163,11 +29628,11 @@ CdiInputFile* cdiInputFile_make(const char* path)
         }
       else
         {
-          result = xmalloc(sizeof(*result));
+          result = (CdiInputFile *) Malloc(sizeof(*result));
           if(!cdiInputFile_condestruct(result, path))
             {
               //An error occured during construction, avoid a memory leak.
-              free(result);
+              Free(result);
               result = NULL;
             }
           else
@@ -29177,7 +29642,7 @@ CdiInputFile* cdiInputFile_make(const char* path)
                 {
                   openFileListSize *= 2;
                   if(openFileListSize < 16) openFileListSize = 16;
-                  openFileList = xrealloc(openFileList, openFileListSize);
+                  openFileList = (CdiInputFile **) Realloc(openFileList, openFileListSize);
                 }
               xassert(openFileCount < openFileListSize);
               openFileList[openFileCount++] = result;
@@ -29191,7 +29656,7 @@ CdiInputFile* cdiInputFile_make(const char* path)
 
 int cdiInputFile_read(const CdiInputFile* me, off_t readPosition, size_t readSize, size_t* outActualReadSize, void* buffer)
 {
-  char* byteBuffer = buffer;
+  char* byteBuffer = (char *)buffer;
   size_t trash;
   if(!outActualReadSize) outActualReadSize = &trash;
   *outActualReadSize = 0;
@@ -29202,15 +29667,15 @@ int cdiInputFile_read(const CdiInputFile* me, off_t readPosition, size_t readSiz
       if(bytesRead == 0) return CDI_EEOF;
       byteBuffer += bytesRead;
       readPosition += bytesRead;
-      readSize -= bytesRead;
-      *outActualReadSize += bytesRead;
+      readSize -= (size_t)bytesRead;
+      *outActualReadSize += (size_t)bytesRead;
     }
   return CDI_NOERR;
 }
 
-char* cdiInputFile_copyPath(const CdiInputFile* me)
+const char* cdiInputFile_getPath(const CdiInputFile* me)
 {
-  return myStrDup(me->path);
+  return me->path;
 }
 
 void cdiInputFile_destruct(CdiInputFile* me)
@@ -29219,9 +29684,8 @@ void cdiInputFile_destruct(CdiInputFile* me)
   xassert(!error);
     {
       //Find the position of me in the list of open files.
-      ssize_t position;
-      for(position = openFileCount; position--; ) if(openFileList[position] == me) break;
-      xassert(position != -1);
+      ssize_t position = (ssize_t)openFileCount;
+      while (position > 0 && openFileList[--position] != me);
       //Remove me from the list
       openFileList[position] = openFileList[--openFileCount];
     }
@@ -29229,6 +29693,16 @@ void cdiInputFile_destruct(CdiInputFile* me)
   xassert(!error);
   cdiInputFile_condestruct(me, NULL);
 }
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #ifndef INSTITUTION_H
 #define INSTITUTION_H
 
@@ -29259,10 +29733,9 @@ void instituteDefaultEntries(void);
 #undef  UNDEFID
 #define UNDEFID  -1
 
-int ECMWF  = UNDEFID;
-int MPIMET = UNDEFID;
-int DWD    = UNDEFID;
-int MCH    = UNDEFID;
+static int ECMWF  = UNDEFID,
+  MPIMET = UNDEFID,
+  MCH    = UNDEFID;
 
 typedef struct
 {
@@ -29392,7 +29865,7 @@ findInstitute(int id, void *res, void *data)
 
 int institutInq(int center, int subcenter, const char *name, const char *longname)
 {
-  institute_t * ip_ref = (institute_t *)xmalloc(sizeof (*ip_ref));
+  institute_t * ip_ref = (institute_t *) Malloc(sizeof (*ip_ref));
   ip_ref->self       = UNDEFID;
   ip_ref->used       = 0;
   ip_ref->center     = center;
@@ -29403,7 +29876,7 @@ int institutInq(int center, int subcenter, const char *name, const char *longnam
   struct instLoc state = { .ip = ip_ref, .id = UNDEFID };
   cdiResHFilterApply(&instituteOps, findInstitute, &state);
 
-  free(ip_ref);
+  Free(ip_ref);
 
   return state.id;
 }
@@ -29412,7 +29885,7 @@ static
 institute_t *instituteNewEntry(cdiResH resH, int center, int subcenter,
                                const char *name, const char *longname)
 {
-  institute_t *instituteptr = (institute_t*) xmalloc(sizeof(institute_t));
+  institute_t *instituteptr = (institute_t*) Malloc(sizeof(institute_t));
   instituteDefaultValue(instituteptr);
   if (resH == CDI_UNDEFID)
     instituteptr->self = reshPut(instituteptr, &instituteOps);
@@ -29507,10 +29980,10 @@ instituteDestroyP(institute_t *instituteptr)
   xassert(instituteptr);
 
   int instituteID = instituteptr->self;
-  free(instituteptr->name);
-  free(instituteptr->longname);
+  Free(instituteptr->name);
+  Free(instituteptr->longname);
   reshRemove(instituteID, &instituteOps);
-  free(instituteptr);
+  Free(instituteptr);
 }
 
 
@@ -29574,7 +30047,7 @@ int instituteUnpack(void *buf, int size, int *position, int originNamespace,
   int instituteID;
   char *name, *longname;
   serializeUnpack(buf, size, position, tempbuf, institute_nints, DATATYPE_INT, context);
-  name = (char *)xmalloc((size_t)tempbuf[3] + (size_t)tempbuf[4]);
+  name = (char *) Malloc((size_t)tempbuf[3] + (size_t)tempbuf[4]);
   longname = name + tempbuf[3];
   serializeUnpack(buf, size, position, name, tempbuf[3], DATATYPE_TXT, context);
   serializeUnpack(buf, size, position, longname, tempbuf[4], DATATYPE_TXT, context);
@@ -29583,7 +30056,9 @@ int instituteUnpack(void *buf, int size, int *position, int originNamespace,
                                       tempbuf[1], tempbuf[2], name, longname);
   instituteID = ip->self;
   xassert(!force_id || instituteID == targetID);
-  free(name);
+  Free(name);
+  reshSetStatus(instituteID, &instituteOps,
+                reshGetStatus(instituteID, &instituteOps) & ~RESH_SYNC_BIT);
   return instituteID;
 }
 
@@ -29638,11 +30113,21 @@ struct CdiIterator {
   //The status information for reading/advancing is added in the subclasses.
 };
 
-void baseIterConstruct(CdiIterator* me, int filetype);
-const char* baseIter_constructFromString(CdiIterator* me, const char* description);     //Returns a pointer past the end of the parsed portion of the description string.
-void baseIterDestruct(CdiIterator* me);
+void baseIterConstruct(CdiIterator *me, int filetype);
+const char* baseIter_constructFromString(CdiIterator *me, const char *description);     //Returns a pointer past the end of the parsed portion of the description string.
+void baseIterDestruct(CdiIterator *me);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 /*
  * A fallback implementation of the iterator interface that opens a stream under the hood.
  *
@@ -29654,35 +30139,38 @@ void baseIterDestruct(CdiIterator* me);
 #define INCLUDE_GUARD_CDI_ITERATOR_FALLBACK_H
 
 
-typedef struct CdiFallbackIterator {
-  CdiIterator super;
-  int streamId, vlistId;
-  char* path;   //needed for clone() & serialize()
-
-  int variableCount, curVariable;
-  int curLevelCount, curLevel;
-  int curTimestep;
-} CdiFallbackIterator;
+typedef struct CdiFallbackIterator CdiFallbackIterator;
 
-CdiIterator* cdiFallbackIterator_new(const char* path, int filetype);
-CdiFallbackIterator* cdiFallbackIterator_clone(CdiIterator* me);
-char* cdiFallbackIterator_serialize(CdiIterator* me);
-CdiFallbackIterator* cdiFallbackIterator_deserialize(const char* me);
+CdiIterator *cdiFallbackIterator_new(const char *path, int filetype);
+CdiFallbackIterator *cdiFallbackIterator_clone(CdiIterator *me);
+CdiIterator *cdiFallbackIterator_getSuper(CdiFallbackIterator *me);
+char *cdiFallbackIterator_serialize(CdiIterator *me);
+CdiFallbackIterator *cdiFallbackIterator_deserialize(const char *me);
 
-int cdiFallbackIterator_nextField(CdiIterator* me);
+int cdiFallbackIterator_nextField(CdiIterator *me);
 
-char* cdiFallbackIterator_inqTime(CdiIterator* me, bool getEndTime);
-int cdiFallbackIterator_levelType(CdiIterator* me, int levelSelector, char** outName, char** outLongName, char** outStdName, char** outUnit);
-int cdiFallbackIterator_level(CdiIterator* me, int levelSelector, double* outValue1, double* outValue2);
-int cdiFallbackIterator_zaxisUuid(CdiIterator* me, int* outVgridNumber, int* outLevelCount, unsigned char (*outUuid)[16]);
-char* cdiFallbackIterator_copyVariableName(CdiIterator* me);
+char *cdiFallbackIterator_inqTime(CdiIterator *me, bool getEndTime);
+int cdiFallbackIterator_levelType(CdiIterator *me, int levelSelector, char **outName, char **outLongName, char **outStdName, char **outUnit);
+int cdiFallbackIterator_level(CdiIterator *me, int levelSelector, double *outValue1, double *outValue2);
+int cdiFallbackIterator_zaxisUuid(CdiIterator *me, int *outVgridNumber, int *outLevelCount, unsigned char outUuid[CDI_UUID_SIZE]);
+char *cdiFallbackIterator_copyVariableName(CdiIterator *me);
 
-void cdiFallbackIterator_readField(CdiIterator* me, double* buffer, size_t* nmiss);
-void cdiFallbackIterator_readFieldF(CdiIterator* me, float* buffer, size_t* nmiss);
+void cdiFallbackIterator_readField(CdiIterator *me, double *buffer, size_t *nmiss);
+void cdiFallbackIterator_readFieldF(CdiIterator *me, float *buffer, size_t *nmiss);
 
-void cdiFallbackIterator_delete(CdiIterator* super);
+void cdiFallbackIterator_delete(CdiIterator *super);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 /*
  * An implementation of the iterator interface for GRIB files.
  * Since GRIB files do not contain an index, this avoids scanning the entire file to generate an in-memory index as streamOpenRead() does.
@@ -29698,78 +30186,79 @@ void cdiFallbackIterator_delete(CdiIterator* super);
 #endif
 
 typedef struct recordList recordList;
-struct CdiGribIterator {
-  CdiIterator super;
-
-  CdiInputFile* file;
-  off_t fileOffset;
-  unsigned char* gribBuffer;
-  size_t bufferSize, curRecordSize;
-#ifdef HAVE_LIBGRIB_API
-  grib_handle* gribHandle;
-#else
-  void* gribHandle;
-#endif
-};
 
-CdiIterator* cdiGribIterator_new(const char* path, int filetype);
-CdiGribIterator* cdiGribIterator_makeClone(CdiIterator* me);
-char* cdiGribIterator_serialize(CdiIterator* me);
-CdiGribIterator* cdiGribIterator_deserialize(const char* me);
+CdiIterator *cdiGribIterator_new(const char *path, int filetype);
+CdiGribIterator *cdiGribIterator_makeClone(CdiIterator *me);
+CdiIterator *cdiGribIterator_getSuper(CdiGribIterator *me);
+char *cdiGribIterator_serialize(CdiIterator *me);
+CdiGribIterator *cdiGribIterator_deserialize(const char *me);
 
-int cdiGribIterator_nextField(CdiIterator* me);
+int cdiGribIterator_nextField(CdiIterator *me);
 
-char* cdiGribIterator_inqTime(CdiIterator* me, bool getEndTime);
-int cdiGribIterator_levelType(CdiIterator* me, int levelSelector, char** outName, char** outLongName, char** outStdName, char** outUnit);
-int cdiGribIterator_level(CdiIterator* me, int levelSelector, double* outValue1, double* outValue2);
-int cdiGribIterator_zaxisUuid(CdiIterator* me, int* outVgridNumber, int* outLevelCount, unsigned char (*outUuid)[16]);
-char* cdiGribIterator_copyVariableName(CdiIterator* me);
+char *cdiGribIterator_inqTime(CdiIterator *me, bool getEndTime);
+int cdiGribIterator_levelType(CdiIterator *me, int levelSelector, char **outName, char **outLongName, char **outStdName, char **outUnit);
+int cdiGribIterator_level(CdiIterator *me, int levelSelector, double *outValue1, double *outValue2);
+int cdiGribIterator_zaxisUuid(CdiIterator *me, int *outVgridNumber, int *outLevelCount, unsigned char outUuid[CDI_UUID_SIZE]);
+char *cdiGribIterator_copyVariableName(CdiIterator *me);
 
-void cdiGribIterator_readField(CdiIterator* me, double* buffer, size_t* nmiss);
-void cdiGribIterator_readFieldF(CdiIterator* me, float* buffer, size_t* nmiss);
+void cdiGribIterator_readField(CdiIterator *me, double *buffer, size_t *nmiss);
+void cdiGribIterator_readFieldF(CdiIterator *me, float *buffer, size_t *nmiss);
 
 #endif
 
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
+
 #include <assert.h>
 #include <ctype.h>
 
-const char* const kUnexpectedFileTypeMessage = "Internal error: Unexpected file type encountered in iterator.\nThis is either due to an illegal memory access by the application or an internal logical error in CDI (unlikely, but possible).";
-const char* const kAdvancedString = "advanced";
-const char* const kUnadvancedString = "unadvanced";
+static const char kUnexpectedFileTypeMessage[]
+  = "Internal error: Unexpected file type encountered in iterator.\n"
+  "This is either due to an illegal memory access by the application\n"
+  " or an internal logical error in CDI (unlikely, but possible).";
+static const char kAdvancedString[] = "advanced";
+static const char kUnadvancedString[] = "unadvanced";
 
 //Returns a static string.
 static const char* fileType2String(int fileType)
 {
   switch(fileType)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB: return "CDI::Iterator::GRIB1";
         case FILETYPE_GRB2: return "CDI::Iterator::GRIB2";
-      #endif
-      #ifdef HAVE_LIBNETCDF
+#endif
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC: return "CDI::Iterator::NetCDF";
         case FILETYPE_NC2: return "CDI::Iterator::NetCDF2";
         case FILETYPE_NC4: return "CDI::Iterator::NetCDF4";
         case FILETYPE_NC4C: return "CDI::Iterator::NetCDF4C";
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV: return "CDI::Iterator::SRV";
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT: return "CDI::Iterator::EXT";
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG: return "CDI::Iterator::IEG";
-      #endif
+#endif
 
       default: return NULL;
     }
 }
 
-static int string2FileType(const char* fileType, const char** outRestString)
+static int string2FileType(const char* fileType, const char **outRestString)
 {
   //This first part unconditionally checks all known type strings, and only if the given string matches one of these strings, we use fileType2string() to check whether support for this type has been compiled in. This is to avoid throwing "invalid type string" errors when we just have a library version mismatch.
-  #define check(givenString, typeString, typeConstant) do \
+#define check(givenString, typeString, typeConstant) do \
     { \
       if(givenString == strstr(givenString, typeString)) \
         { \
@@ -29788,7 +30277,7 @@ static int string2FileType(const char* fileType, const char** outRestString)
   check(fileType, "CDI::Iterator::SRV", FILETYPE_SRV);
   check(fileType, "CDI::Iterator::EXT", FILETYPE_EXT);
   check(fileType, "CDI::Iterator::IEG", FILETYPE_IEG);
-  #undef check
+#undef check
 
   //If this point is reached, the given string does not seem to be produced by a cdiIterator_serialize() call.
   Error("The string \"%s\" does not start with a valid iterator type. Please check the source of this string.", fileType);
@@ -29796,7 +30285,7 @@ static int string2FileType(const char* fileType, const char** outRestString)
   return FILETYPE_UNDEF;
 }
 
-/**
+/*
 @Function cdiIterator_new
 @Title Create an iterator for an input file
 
@@ -29825,27 +30314,27 @@ CdiIterator* cdiIterator_new(const char* path)
         Warning("Can't open file \"%s\": unknown format\n", path);
         return NULL;
 
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_new(path, filetype);
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           return cdiFallbackIterator_new(path, filetype);
 
       default:
@@ -29869,12 +30358,12 @@ const char* baseIter_constructFromString(CdiIterator* me, const char* descriptio
   if(result == strstr(result, kAdvancedString))
     {
       me->isAdvanced = true;
-      result += strlen(kAdvancedString);
+      result += sizeof (kAdvancedString) - 1;
     }
   else if(result == strstr(result, kUnadvancedString))
     {
       me->isAdvanced = false;
-      result += strlen(kUnadvancedString);
+      result += sizeof (kUnadvancedString) - 1;
     }
   else
     {
@@ -29889,7 +30378,7 @@ const char* baseIter_constructFromString(CdiIterator* me, const char* descriptio
     if(!me->isAdvanced) xabort("Calling %s is not allowed without calling cdiIterator_nextField() first.", __func__); \
 } while(0)
 
-/**
+/*
 @Function cdiIterator_clone
 @Title Make a copy of an iterator
 
@@ -29914,28 +30403,28 @@ CdiIterator* cdiIterator_clone(CdiIterator* me)
   sanityCheck(me);
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
-          return &cdiGribIterator_clone(me)->super;
-      #endif
+          return cdiGribIterator_getSuper(cdiGribIterator_clone(me));
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
-          return &cdiFallbackIterator_clone(me)->super;
+#endif
+          return cdiFallbackIterator_getSuper(cdiFallbackIterator_clone(me));
 
       default:
         Error(kUnexpectedFileTypeMessage);
@@ -29943,7 +30432,7 @@ CdiIterator* cdiIterator_clone(CdiIterator* me)
     }
 }
 
-/**
+/*
 @Function cdiGribIterator_clone
 @Title Gain access to GRIB specific functionality
 
@@ -29964,18 +30453,18 @@ CdiGribIterator* cdiGribIterator_clone(CdiIterator* me)
   sanityCheck(me);
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_makeClone(me);
-      #endif
+#endif
 
       default:
         return NULL;
     }
 }
 
-/**
+/*
 @Function cdiIterator_serialize
 @Title Serialize an iterator for sending it to another process
 
@@ -29986,7 +30475,7 @@ CdiGribIterator* cdiGribIterator_clone(CdiIterator* me)
 @Result A malloc'ed string that contains the full description of the iterator.
 
 @Description
-    Make sure to call free() on the resulting string.
+    Make sure to call Free() on the resulting string.
 */
 char* cdiIterator_serialize(CdiIterator* me)
 {
@@ -29994,28 +30483,28 @@ char* cdiIterator_serialize(CdiIterator* me)
   char* subclassDescription = NULL;
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           subclassDescription = cdiGribIterator_serialize(me);
           break;
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           subclassDescription = cdiFallbackIterator_serialize(me);
           break;
 
@@ -30024,12 +30513,16 @@ char* cdiIterator_serialize(CdiIterator* me)
         return NULL;
     }
 
-  char* result = myAsprintf("%s %s %s", fileType2String(me->filetype), (me->isAdvanced ? kAdvancedString : kUnadvancedString), subclassDescription);
-  free(subclassDescription);
+  const char *ftypeStr = fileType2String(me->filetype),
+    *advStr = me->isAdvanced ? kAdvancedString : kUnadvancedString;
+  char* result = (char *) Malloc(strlen(ftypeStr) + 1 + strlen(advStr) + 1
+                         + strlen(subclassDescription) + 1);
+  sprintf(result, "%s %s %s", ftypeStr, advStr, subclassDescription);
+  Free(subclassDescription);
   return result;
 }
 
-/**
+/*
 @Function cdiIterator_deserialize
 @Title Recreate an iterator from its textual description
 
@@ -30050,28 +30543,28 @@ CdiIterator* cdiIterator_deserialize(const char* description)
 {
   switch(string2FileType(description, NULL))
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
-          return &cdiGribIterator_deserialize(description)->super;
-      #endif
+          return cdiGribIterator_getSuper(cdiGribIterator_deserialize(description));
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
-          return &cdiFallbackIterator_deserialize(description)->super;
+#endif
+          return cdiFallbackIterator_getSuper(cdiFallbackIterator_deserialize(description));
 
       default:
         Error(kUnexpectedFileTypeMessage);
@@ -30080,7 +30573,7 @@ CdiIterator* cdiIterator_deserialize(const char* description)
 }
 
 
-/**
+/*
 @Function cdiIterator_print
 @Title Print a textual description of the iterator to a stream
 
@@ -30096,11 +30589,11 @@ void cdiIterator_print(CdiIterator* me, FILE* stream)
 {
   char* description = cdiIterator_serialize(me);
   fprintf(stream, "%s\n", description);
-  free(description);
+  Free(description);
 }
 
 
-/**
+/*
 @Function cdiIterator_nextField
 @Title Advance an iterator to the next field in the file
 
@@ -30122,27 +30615,27 @@ int cdiIterator_nextField(CdiIterator* me)
   me->isAdvanced = true;
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_nextField(me);
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           return cdiFallbackIterator_nextField(me);
 
       default:
@@ -30156,27 +30649,27 @@ static char* cdiIterator_inqTime(CdiIterator* me, bool getEndTime)
   sanityCheck(me);
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_inqTime(me, getEndTime);
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           return cdiFallbackIterator_inqTime(me, getEndTime);
 
       default:
@@ -30185,7 +30678,7 @@ static char* cdiIterator_inqTime(CdiIterator* me, bool getEndTime)
     }
 }
 
-/**
+/*
 @Function cdiIterator_inqStartTime
 @Title Get the start time of a measurement
 
@@ -30200,7 +30693,7 @@ The returned time is either the time of the data (fields defined at a time point
 or the start time of an integration time range (statistical fields).
 
 Converts the time to the ISO-8601 format and returns it in a newly allocated buffer.
-The caller is responsible to free() the resulting string.
+The caller is responsible to Free() the resulting string.
 
 If the file is a GRIB file, the calendar that is used to resolve the relative times is the proleptic calendar
 as it is implemented by the standard C mktime() function.
@@ -30211,7 +30704,7 @@ char* cdiIterator_inqStartTime(CdiIterator* me)
   return cdiIterator_inqTime(me, false);
 }
 
-/**
+/*
 @Function cdiIterator_inqEndTime
 @Title Get the end time of a measurement
 
@@ -30226,7 +30719,7 @@ The returned time is the end time of an integration period if such a time exists
 Otherwise, NULL is returned.
 
 Converts the time to the ISO-8601 format and returns it in a newly allocated buffer.
-The caller is responsible to free() the resulting string.
+The caller is responsible to Free() the resulting string.
 
 If the file is a GRIB file, the calendar that is used to resolve the relative times is the proleptic calendar
 as it is implemented by the standard C mktime() function.
@@ -30237,7 +30730,7 @@ char* cdiIterator_inqEndTime(CdiIterator* me)
   return cdiIterator_inqTime(me, true);
 }
 
-/**
+/*
 @Function cdiIterator_inqVTime
 @Title Get the validity time of the current field
 
@@ -30253,7 +30746,7 @@ That is, if the field is a time point, its time is returned,
 if it is a statistical field with an integration period, the end time of the integration period is returned.
 
 Converts the time to the ISO-8601 format and returns it in a newly allocated buffer.
-The caller is responsible to free() the resulting string.
+The caller is responsible to Free() the resulting string.
 
 If the file is a GRIB file, the calendar that is used to resolve the relative times is the proleptic calendar
 as it is implemented by the standard C mktime() function.
@@ -30265,18 +30758,18 @@ char* cdiIterator_inqVTime(CdiIterator* me)
   return (result) ? result : cdiIterator_inqStartTime(me);
 }
 
-/**
+/*
 @Function cdiIterator_inqLevelType
 @Title Get the type of a level
 
- at Prototype int cdiIterator_inqLevelType(CdiIterator* me, int levelSelector, char** outName = NULL, char** outLongName = NULL, char** outStdName = NULL, char** outUnit = NULL)
+ at Prototype int cdiIterator_inqLevelType(CdiIterator* me, int levelSelector, char **outName = NULL, char **outLongName = NULL, char **outStdName = NULL, char **outUnit = NULL)
 @Parameter
     @item iterator The iterator to operate on.
     @item levelSelector Zero for the top level, one for the bottom level
-    @item outName Will be set to a malloc()'ed string with the name of the level if not NULL.
-    @item outLongName Will be set to a malloc()'ed string with the long name of the level if not NULL.
-    @item outStdName Will be set to a malloc()'ed string with the standard name of the level if not NULL.
-    @item outUnit Will be set to a malloc()'ed string with the unit of the level if not NULL.
+    @item outName Will be set to a Malloc()'ed string with the name of the level if not NULL.
+    @item outLongName Will be set to a Malloc()'ed string with the long name of the level if not NULL.
+    @item outStdName Will be set to a Malloc()'ed string with the standard name of the level if not NULL.
+    @item outUnit Will be set to a Malloc()'ed string with the unit of the level if not NULL.
 
 @Result An integer indicating the type of the level.
 
@@ -30284,32 +30777,32 @@ char* cdiIterator_inqVTime(CdiIterator* me)
 Find out some basic information about the given level, the levelSelector selects the function of the requested level.
 If the requested level does not exist, this returns CDI_UNDEFID.
 */
-int cdiIterator_inqLevelType(CdiIterator* me, int levelSelector, char** outName, char** outLongName, char** outStdName, char** outUnit)
+int cdiIterator_inqLevelType(CdiIterator* me, int levelSelector, char **outName, char **outLongName, char **outStdName, char **outUnit)
 {
   sanityCheck(me);
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_levelType(me, levelSelector, outName, outLongName, outStdName, outUnit);
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           return cdiFallbackIterator_levelType(me, levelSelector, outName, outLongName, outStdName, outUnit);
 
       default:
@@ -30318,7 +30811,7 @@ int cdiIterator_inqLevelType(CdiIterator* me, int levelSelector, char** outName,
     }
 }
 
-/**
+/*
 @Function cdiIterator_inqLevel
 @Title Get the value of the z-coordinate
 
@@ -30339,27 +30832,27 @@ int cdiIterator_inqLevel(CdiIterator* me, int levelSelector, double* outValue1,
   sanityCheck(me);
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_level(me, levelSelector, outValue1, outValue2);
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           return cdiFallbackIterator_level(me, levelSelector, outValue1, outValue2);
 
       default:
@@ -30368,7 +30861,7 @@ int cdiIterator_inqLevel(CdiIterator* me, int levelSelector, double* outValue1,
     }
 }
 
-/**
+/*
 @Function cdiIterator_inqLevelUuid
 @Title Get the UUID of the z-axis used by this field
 
@@ -30384,32 +30877,32 @@ int cdiIterator_inqLevel(CdiIterator* me, int levelSelector, double* outValue1,
 @Description
 Returns identifying information for the external z-axis description. May only be called for generalized levels.
 */
-int cdiIterator_inqLevelUuid(CdiIterator* me, int* outVgridNumber, int* outLevelCount, unsigned char (*outUuid)[16])
+int cdiIterator_inqLevelUuid(CdiIterator* me, int* outVgridNumber, int* outLevelCount, unsigned char outUuid[CDI_UUID_SIZE])
 {
   sanityCheck(me);
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_zaxisUuid(me, outVgridNumber, outLevelCount, outUuid);
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           return cdiFallbackIterator_zaxisUuid(me, outVgridNumber, outLevelCount, outUuid);
 
       default:
@@ -30418,7 +30911,7 @@ int cdiIterator_inqLevelUuid(CdiIterator* me, int* outVgridNumber, int* outLevel
     }
 }
 
-/**
+/*
 @Function cdiIterator_inqParam
 @Title Get discipline, category, and number
 
@@ -30437,7 +30930,7 @@ CdiParam cdiIterator_inqParam(CdiIterator* me)
   return me->param;
 }
 
-/**
+/*
 @Function cdiIterator_inqDatatype
 @Title Get the datatype of the current field
 
@@ -30456,7 +30949,7 @@ int cdiIterator_inqDatatype(CdiIterator* me)
   return me->datatype;
 }
 
-/**
+/*
 @Function cdiIterator_inqTsteptype
 @Title Get the timestep type
 
@@ -30475,7 +30968,7 @@ int cdiIterator_inqTsteptype(CdiIterator* me)
   return me->timesteptype;
 }
 
-/**
+/*
 @Function cdiIterator_inqVariableName
 @Title Get the variable name of the current field
 
@@ -30483,38 +30976,38 @@ int cdiIterator_inqTsteptype(CdiIterator* me)
 @Parameter
     @item iterator The iterator to operate on.
 
- at Result A pointer to a C-string containing the name. The storage for this string is allocated with malloc(), and it is the responsibility of the caller to free() it.
+ at Result A pointer to a C-string containing the name. The storage for this string is allocated with Malloc(), and it is the responsibility of the caller to Free() it.
 
 @Description
     Allocates a buffer to hold the string, copies the current variable name into this buffer, and returns the buffer.
-    The caller is responsible to make the corresponding free() call.
+    The caller is responsible to make the corresponding Free() call.
 */
 char* cdiIterator_inqVariableName(CdiIterator* me)
 {
   sanityCheck(me);
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_copyVariableName(me);
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           return cdiFallbackIterator_copyVariableName(me);
 
       default:
@@ -30523,7 +31016,7 @@ char* cdiIterator_inqVariableName(CdiIterator* me)
     }
 }
 
-/**
+/*
 @Function cdiIterator_inqGridId
 @Title Get the ID of the current grid
 
@@ -30543,7 +31036,7 @@ int cdiIterator_inqGridId(CdiIterator* me)
   return me->gridId;
 }
 
-/**
+/*
 @Function cdiIterator_readField
 @Title Read the whole field into a double buffer
 
@@ -30563,28 +31056,28 @@ void cdiIterator_readField(CdiIterator* me, double* buffer, size_t* nmiss)
   if(!buffer) xabort("NULL was passed in a buffer. Please provide a suitable buffer.");
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           cdiGribIterator_readField(me, buffer, nmiss);
 	  return;
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           cdiFallbackIterator_readField(me, buffer, nmiss);
           return;
       default:
@@ -30592,7 +31085,7 @@ void cdiIterator_readField(CdiIterator* me, double* buffer, size_t* nmiss)
     }
 }
 
-/**
+/*
 @Function cdiIterator_readFieldF
 @Title Read the whole field into a double buffer
 
@@ -30612,28 +31105,28 @@ void cdiIterator_readFieldF(CdiIterator* me, float* buffer, size_t* nmiss)
   if(!buffer) xabort("NULL was passed in a buffer. Please provide a suitable buffer.");
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           cdiGribIterator_readFieldF(me, buffer, nmiss);
 	  return;
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           cdiFallbackIterator_readFieldF(me, buffer, nmiss);
           return; 
       default:
@@ -30641,7 +31134,7 @@ void cdiIterator_readFieldF(CdiIterator* me, float* buffer, size_t* nmiss)
     }
 }
 
-/**
+/*
 @Function cdiIterator_delete
 @Title Destroy an iterator
 
@@ -30657,28 +31150,28 @@ void cdiIterator_delete(CdiIterator* me)
   if(!me) xabort("NULL was passed in as an iterator. Please check the return value of cdiIterator_new().");
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           cdiGribIterator_delete((CdiGribIterator*)me);
           break;
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           cdiFallbackIterator_delete(me);
           break;
 
@@ -30687,233 +31180,12 @@ void cdiIterator_delete(CdiIterator* me)
     }
 }
 
-void baseIterDestruct(CdiIterator* me) { /*currently empty, but that's no reason not to call it*/ }
-#ifndef _VLIST_H
-#define _VLIST_H
-
-#ifdef HAVE_CONFIG_H
-#endif
-
-#ifndef  _ERROR_H
-#endif
-
-#include <stddef.h>  /* size_t */
-
-#ifndef _CDI_LIMITS_H
-#endif
-
-#define VALIDMISS 1.e+303
-
-/*
- * CDI attribute
- */
-typedef struct {
-  size_t    xsz;	  /* amount of space at xvalue                      */
-  size_t    namesz;       /* size of name                                   */
-  char     *name;         /* attribute name                                 */
-  int       indtype;	  /* internal data type of xvalue (INT, FLT or TXT) */
-  int       exdtype;      /* external data type                             */
-                          /* indtype    exdtype                             */
-                          /* TXT        TXT                                 */
-                          /* INT        INT16, INT32                        */
-                          /* FLT        FLT32, FLT64                        */
-  size_t    nelems;    	  /* number of elements                             */
-  void     *xvalue;       /* the actual data                                */
-} cdi_att_t;
-
-
-typedef struct {
-  size_t     nalloc;		/* number allocated >= nelems */
-  size_t     nelems;		/* length of the array */
-  cdi_att_t  value[MAX_ATTRIBUTES];
-} cdi_atts_t;
-
-
-typedef struct
-{
-  int      flag;
-  int      index;
-  int      mlevelID;
-  int      flevelID;
-}
-levinfo_t;
-
-#define DEFAULT_LEVINFO(levID) \
-  (levinfo_t){ 0, -1, levID, levID}
-/*
-#define DEFAULT_LEVINFO(levID) \
-  (levinfo_t){ .flag = 0, .index = -1, .flevelID = levID, .mlevelID = levID}
-*/
-typedef struct
-{
-  int ens_index;
-  int ens_count;
-  int forecast_init_type;
-}
-ensinfo_t;
-
-/* ---------------------------------- */
-/* Local change: 2013-01-28, FP (DWD) */
-/* ---------------------------------- */
-
-/* Length of optional keyword/value pair list */
-#define MAX_OPT_GRIB_ENTRIES 50
-
-
-typedef struct
-{
-  int         flag;
-  int         isUsed;
-  int         mvarID;
-  int         fvarID;
-  int         param;
-  int         gridID;
-  int         zaxisID;
-  int         tsteptype; /* TSTEP_* */
-  int         datatype;  /* DATATYPE_PACKX for GRIB data, else DATATYPE_FLT32 or DATATYPE_FLT64 */
-  int         instID;
-  int         modelID;
-  int         tableID;
-  int         timave;
-  int         timaccu;
-  int         typeOfGeneratingProcess;
-  int         productDefinitionTemplate;
-  int         chunktype;
-  int         xyz;
-  int         missvalused; /* TRUE if missval is defined */
-  int         lvalidrange;
-  char       *name;
-  char       *longname;
-  char       *stdname;
-  char       *units;
-  char       *extra;
-  double      missval;
-  double      scalefactor;
-  double      addoffset;
-  double      validrange[2];
-  levinfo_t  *levinfo;
-  int         comptype;     // compression type
-  int         complevel;    // compression level
-  ensinfo_t  *ensdata;      /* Ensemble information */
-  cdi_atts_t  atts;
-  int         iorank;
-#if  defined  (HAVE_LIBGRIB_API)
-  /* ---------------------------------- */
-  /* Local change: 2013-01-28, FP (DWD) */
-  /* ---------------------------------- */
-
-  /* (Optional) list of keyword/double value pairs */
-  int    opt_grib_dbl_nentries;
-  char*  opt_grib_dbl_keyword[MAX_OPT_GRIB_ENTRIES];
-  int    opt_grib_dbl_update[MAX_OPT_GRIB_ENTRIES];
-  double opt_grib_dbl_val[MAX_OPT_GRIB_ENTRIES];
-  /* (Optional) list of keyword/integer value pairs */
-  int    opt_grib_int_nentries;
-  char*  opt_grib_int_keyword[MAX_OPT_GRIB_ENTRIES];
-  int    opt_grib_int_update[MAX_OPT_GRIB_ENTRIES];
-  int    opt_grib_int_val[MAX_OPT_GRIB_ENTRIES];
-#endif
-}
-var_t;
-
-
-typedef struct
-{
-  int         locked;
-  int         self;
-  int         nvars;        /* number of variables                */
-  int         ngrids;
-  int         nzaxis;
-  long        ntsteps;
-  int         taxisID;
-  int         tableID;
-  int         instID;
-  int         modelID;
-  int         varsAllocated;
-  int         gridIDs[MAX_GRIDS_PS];
-  int         zaxisIDs[MAX_ZAXES_PS];
-  var_t      *vars;
-  cdi_atts_t  atts;
-}
-vlist_t;
-
-
-vlist_t *vlist_to_pointer(int vlistID);
-void vlistCheckVarID(const char *caller, int vlistID, int varID);
-const char *vlistInqVarNamePtr(int vlistID, int varID);
-const char *vlistInqVarLongnamePtr(int vlistID, int varID);
-const char *vlistInqVarStdnamePtr(int vlistID, int varID);
-const char *vlistInqVarUnitsPtr(int vlistID, int varID);
-void     vlistDestroyVarName(int vlistID, int varID);
-void     vlistDestroyVarLongname(int vlistID, int varID);
-void     vlistDestroyVarUnits(int vlistID, int varID);
-void     vlistDefVarTsteptype(int vlistID, int varID, int tsteptype);
-int      vlistInqVarMissvalUsed(int vlistID, int varID);
-int      vlistHasTime(int vlistID);
-
-int      vlistDelAtts(int vlistID, int varID);
-int      vlistCopyVarAtts(int vlistID1, int varID_1, int vlistID2, int varID_2);
-
-void     vlistUnpack(char * buffer, int bufferSize, int * pos,
-                     int originNamespace, void *context, int force_id);
-
-/*      vlistDefVarValidrange: Define the valid range of a Variable */
-void    vlistDefVarValidrange(int vlistID, int varID, const double *validrange);
-
-/*      vlistInqVarValidrange: Get the valid range of a Variable */
-int     vlistInqVarValidrange(int vlistID, int varID, double *validrange);
-
-void vlistInqVarDimorder(int vlistID, int varID, int (*outDimorder)[3]);
-
-int vlist_att_compare(vlist_t *a, int varIDA, vlist_t *b, int varIDB, int attnum);
-
-void vlist_lock(int vlistID);
-void vlist_unlock(int vlistID);
-
-static inline void
-vlistAdd2GridIDs(vlist_t *vlistptr, int gridID)
-{
-  int index, ngrids = vlistptr->ngrids;
-  for ( index = 0; index < ngrids; index++ )
-    if (vlistptr->gridIDs[index] == gridID ) break;
-  if ( index == ngrids )
-    {
-      if (ngrids >= MAX_GRIDS_PS)
-        Error("Internal limit exceeded: more than %d grids.", MAX_GRIDS_PS);
-      ++(vlistptr->ngrids);
-      vlistptr->gridIDs[ngrids] = gridID;
-    }
-}
-
-static inline void
-vlistAdd2ZaxisIDs(vlist_t *vlistptr, int zaxisID)
+void baseIterDestruct(CdiIterator* me)
 {
-  int index, nzaxis = vlistptr->nzaxis;
-  for ( index = 0; index < nzaxis; index++ )
-    if ( zaxisID == vlistptr->zaxisIDs[index] ) break;
-
-  if ( index == nzaxis )
-    {
-      if ( nzaxis >= MAX_ZAXES_PS )
-	Error("Internal limit exceeded: more than %d zaxis.", MAX_ZAXES_PS);
-      vlistptr->zaxisIDs[nzaxis] = zaxisID;
-      vlistptr->nzaxis++;
-    }
+  /*currently empty, but that's no reason not to call it*/
+  (void)me;
 }
 
-
-#if  defined  (HAVE_LIBGRIB_API)
-extern int   cdiNAdditionalGRIBKeys;
-extern char* cdiAdditionalGRIBKeys[];
-#endif
-
-extern
-#ifndef __cplusplus
-const
-#endif
-resOps vlistOps;
-
-#endif  /* _VLIST_H */
 /*
  * Local Variables:
  * c-file-style: "Java"
@@ -30926,14 +31198,31 @@ resOps vlistOps;
 
 
 #include <assert.h>
+#include <limits.h>
 #include <stdlib.h>
 
+struct CdiFallbackIterator {
+  CdiIterator super;
+  int streamId, vlistId;
+  char *path;   //needed for clone() & serialize()
+
+  int variableCount, curVariable;
+  int curLevelCount, curLevel;
+  int curTimestep;
+};
+
+CdiIterator *cdiFallbackIterator_getSuper(CdiFallbackIterator *me)
+{
+  return &me->super;
+}
+
+
 //For more information on the condestruct() pattern, see comment in src/iterator_grib.c
-static CdiFallbackIterator* cdiFallbackIterator_condestruct(CdiFallbackIterator* me, const char* path, int filetype)
+static CdiFallbackIterator *cdiFallbackIterator_condestruct(CdiFallbackIterator *me, const char *path, int filetype)
 {
   if(me) goto destruct;
 
-  me = xmalloc(sizeof(*me));
+  me = (CdiFallbackIterator *) Malloc(sizeof(*me));
   baseIterConstruct(&me->super, filetype);
 
   me->streamId = streamOpenRead(path);
@@ -30949,7 +31238,7 @@ static CdiFallbackIterator* cdiFallbackIterator_condestruct(CdiFallbackIterator*
   if(streamInqTimestep(me->streamId, me->curTimestep) <= 0) goto closeStream;
   me->curVariable = 0;
   me->curLevel = -1;
-  me->path = myStrDup(path);
+  me->path = strdup(path);
   if(!me->path) goto closeStream;
 
   return me;
@@ -30959,22 +31248,22 @@ static CdiFallbackIterator* cdiFallbackIterator_condestruct(CdiFallbackIterator*
 // v destructor/error-cleanup code  v
 
 destruct:
-  free(me->path);
+  Free(me->path);
 closeStream:
   streamClose(me->streamId);
 destructSuper:
   baseIterDestruct(&me->super);
-  free(me);
+  Free(me);
   return NULL;
 }
 
-CdiIterator* cdiFallbackIterator_new(const char* path, int filetype)
+CdiIterator *cdiFallbackIterator_new(const char *path, int filetype)
 {
   return &cdiFallbackIterator_condestruct(NULL, path, filetype)->super;
 }
 
 //Fetches the info that is published by the variables in the base class from the current field.
-static void fetchSuperInfo(CdiFallbackIterator* me)
+static void fetchSuperInfo(CdiFallbackIterator *me)
 {
   me->super.datatype = vlistInqVarDatatype(me->vlistId, me->curVariable);
   me->super.timesteptype = vlistInqVarTsteptype(me->vlistId, me->curVariable);
@@ -30983,12 +31272,12 @@ static void fetchSuperInfo(CdiFallbackIterator* me)
   cdiDecodeParam(param, &me->super.param.number, &me->super.param.category, &me->super.param.discipline);
 }
 
-CdiFallbackIterator* cdiFallbackIterator_clone(CdiIterator* super)
+CdiFallbackIterator *cdiFallbackIterator_clone(CdiIterator *super)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
 
   //Make another stream for this file. This yields an unadvanced iterator.
-  CdiFallbackIterator* clone = cdiFallbackIterator_condestruct(NULL, me->path, me->super.filetype);
+  CdiFallbackIterator *clone = cdiFallbackIterator_condestruct(NULL, me->path, me->super.filetype);
   if(!clone) return NULL;
 
   //Point the clone to the same position in the file.
@@ -31004,19 +31293,21 @@ CdiFallbackIterator* cdiFallbackIterator_clone(CdiIterator* super)
   return clone;
 }
 
-char* cdiFallbackIterator_serialize(CdiIterator* super)
+char *cdiFallbackIterator_serialize(CdiIterator *super)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
 
-  char* escapedPath = cdiEscapeSpaces(me->path);
-  char* result = myAsprintf("%s %d %d %d %d %d", escapedPath, me->variableCount, me->curVariable, me->curLevelCount, me->curLevel, me->curTimestep);
-  free(escapedPath);
+  char *escapedPath = cdiEscapeSpaces(me->path);
+  char *result = (char *) Malloc(strlen(escapedPath)
+                         + 5 * (3 * sizeof (int) * CHAR_BIT / 8 + 1) + 1);
+  sprintf(result, "%s %d %d %d %d %d", escapedPath, me->variableCount, me->curVariable, me->curLevelCount, me->curLevel, me->curTimestep);
+  Free(escapedPath);
   return result;
 }
 
-CdiFallbackIterator* cdiFallbackIterator_deserialize(const char* description)
+CdiFallbackIterator *cdiFallbackIterator_deserialize(const char *description)
 {
-  CdiFallbackIterator* me = xmalloc(sizeof(*me));
+  CdiFallbackIterator *me = (CdiFallbackIterator *) Malloc(sizeof(*me));
   if(!me) goto fail;
 
   description = baseIter_constructFromString(&me->super, description);
@@ -31031,9 +31322,9 @@ CdiFallbackIterator* cdiFallbackIterator_deserialize(const char* description)
   if(me->vlistId == CDI_UNDEFID) goto closeStream;
 
   //This reads one variable from the description string, does error checking, and advances the given string pointer.
-  #define decodeValue(variable, description) do \
+#define decodeValue(variable, description) do \
     { \
-      const char* savedStart = description; \
+      const char *savedStart = description; \
       long long decodedValue = strtoll(description, (char**)&description, 0);   /*The cast is a workaround for the wrong signature of strtoll().*/ \
       variable = (int)decodedValue; \
       if(savedStart == description) goto closeStream; \
@@ -31044,7 +31335,7 @@ CdiFallbackIterator* cdiFallbackIterator_deserialize(const char* description)
   decodeValue(me->curLevelCount, description);
   decodeValue(me->curLevel, description);
   decodeValue(me->curTimestep, description);
-  #undef decodeValue
+#undef decodeValue
 
   if(streamInqTimestep(me->streamId, me->curTimestep) <= 0) goto closeStream;
   if(me->super.isAdvanced) fetchSuperInfo(me);
@@ -31054,15 +31345,15 @@ CdiFallbackIterator* cdiFallbackIterator_deserialize(const char* description)
 closeStream:
   streamClose(me->streamId);
 freePath:
-  free(me->path);
+  Free(me->path);
 destructSuper:
   baseIterDestruct(&me->super);
-  free(me);
+  Free(me);
 fail:
   return NULL;
 }
 
-static int advance(CdiFallbackIterator* me)
+static int advance(CdiFallbackIterator *me)
 {
   me->curLevel++;
   if(me->curLevel == me->curLevelCount)
@@ -31079,9 +31370,9 @@ static int advance(CdiFallbackIterator* me)
   return CDI_NOERR;
 }
 
-int cdiFallbackIterator_nextField(CdiIterator* super)
+int cdiFallbackIterator_nextField(CdiIterator *super)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   int result = advance(me);
   if(result) return result;
 
@@ -31093,9 +31384,9 @@ int cdiFallbackIterator_nextField(CdiIterator* super)
   return CDI_NOERR;
 }
 
-char* cdiFallbackIterator_inqTime(CdiIterator* super, bool getEndTime)
+char *cdiFallbackIterator_inqTime(CdiIterator *super, bool getEndTime)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator *)(void *)super;
   if(getEndTime) return NULL;   //The stream interface does not export the start/end times of statistical fields, so we treat all data as point of time data, returning the validity time as the start time.
   int taxisId = vlistInqTaxis(me->vlistId);
   int date = taxisInqVdate(taxisId);
@@ -31103,20 +31394,24 @@ char* cdiFallbackIterator_inqTime(CdiIterator* super, bool getEndTime)
   int year, month, day, hour, minute, second;
   cdiDecodeDate(date, &year, &month, &day);
   cdiDecodeTime(time, &hour, &minute, &second);
-  return myAsprintf("%04d-%02d-%02dT%02d:%02d:%02d.000", year, month, day, hour, minute, second);
+  char *result
+    = (char *) Malloc(   4+1 +2+1 +2+1 +2+1 +2+1 +2+4+1);
+  sprintf(result,     "%04d-%02d-%02dT%02d:%02d:%02d.000", year, month, day, hour, minute, second);
+  return result;
 }
 
-int cdiFallbackIterator_levelType(CdiIterator* super, int levelSelector, char** outName, char** outLongName, char** outStdName, char** outUnit)
+int cdiFallbackIterator_levelType(CdiIterator *super, int levelSelector, char **outName, char **outLongName, char **outStdName, char **outUnit)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   int zaxisId = vlistInqVarZaxis(me->vlistId, me->curVariable);
-  #define copyString(outPointer, function) do \
+  (void)levelSelector;
+#define copyString(outPointer, function) do \
     { \
       if(outPointer) \
         { \
           char tempBuffer[CDI_MAX_NAME]; \
           function(zaxisId, tempBuffer); \
-          *outPointer = myStrDup(tempBuffer); \
+          *outPointer = strdup(tempBuffer); \
         } \
     } \
   while(0)
@@ -31124,13 +31419,13 @@ int cdiFallbackIterator_levelType(CdiIterator* super, int levelSelector, char**
   copyString(outLongName, zaxisInqLongname);    //FIXME: zaxisInqLongname is unsafe.
   copyString(outStdName, zaxisInqStdname);    //FIXME: zaxisInqStdname is unsafe.
   copyString(outUnit, zaxisInqUnits);    //FIXME: zaxisInqUnits is unsafe.
-  #undef copyString
+#undef copyString
   return zaxisInqLtype(zaxisId);
 }
 
-int cdiFallbackIterator_level(CdiIterator* super, int levelSelector, double* outValue1, double* outValue2)
+int cdiFallbackIterator_level(CdiIterator *super, int levelSelector, double *outValue1, double *outValue2)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   int zaxisId = vlistInqVarZaxis(me->vlistId, me->curVariable);
 
   //handle NULL pointers once and for all
@@ -31157,51 +31452,61 @@ int cdiFallbackIterator_level(CdiIterator* super, int levelSelector, double* out
   ssize_t intLevel = (ssize_t)(2**outValue1);
   if(0 <= intLevel && intLevel < zaxisInqVctSize(zaxisId) - 1)
     {
-      const double* coordinateTable = zaxisInqVctPtr(zaxisId);
+      const double *coordinateTable = zaxisInqVctPtr(zaxisId);
       *outValue1 = coordinateTable[intLevel];
       *outValue2 = coordinateTable[intLevel + 1];
     }
   return CDI_NOERR;
 }
 
-int cdiFallbackIterator_zaxisUuid(CdiIterator* super, int* outVgridNumber, int* outLevelCount, unsigned char (*outUuid)[16])
+int cdiFallbackIterator_zaxisUuid(CdiIterator *super, int *outVgridNumber, int *outLevelCount, unsigned char outUuid[CDI_UUID_SIZE])
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   int zaxisId = vlistInqVarZaxis(me->vlistId, me->curVariable);
   if(zaxisInqLtype(zaxisId) != ZAXIS_HYBRID) return CDI_EINVAL;
   if(outVgridNumber) *outVgridNumber = zaxisInqNumber(zaxisId);
   if(outLevelCount) *outLevelCount = zaxisInqNlevRef(zaxisId);
-  if(outUuid) zaxisInqUUID(zaxisId, *outUuid);
+  if(outUuid) zaxisInqUUID(zaxisId, outUuid);
   return CDI_NOERR;
 }
 
-char* cdiFallbackIterator_copyVariableName(CdiIterator* super)
+char *cdiFallbackIterator_copyVariableName(CdiIterator *super)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   return vlistCopyVarName(me->vlistId, me->curVariable);
 }
 
-void cdiFallbackIterator_readField(CdiIterator* super, double* buffer, size_t* nmiss)
+void cdiFallbackIterator_readField(CdiIterator *super, double *buffer, size_t *nmiss)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   int missingValues = 0;
   streamReadVarSlice(me->streamId, me->curVariable, me->curLevel, buffer, &missingValues);
-  if(nmiss) *nmiss = missingValues;
+  if(nmiss) *nmiss = (size_t)missingValues;
 }
 
-void cdiFallbackIterator_readFieldF(CdiIterator* super, float* buffer, size_t* nmiss)
+void cdiFallbackIterator_readFieldF(CdiIterator *super, float *buffer, size_t *nmiss)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   int missingValues = 0;
   streamReadVarSliceF(me->streamId, me->curVariable, me->curLevel, buffer, &missingValues);
-  if(nmiss) *nmiss = missingValues;
+  if(nmiss) *nmiss = (size_t)missingValues;
 }
 
-void cdiFallbackIterator_delete(CdiIterator* super)
+void cdiFallbackIterator_delete(CdiIterator *super)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   cdiFallbackIterator_condestruct(me, NULL, 0);
 }
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #ifndef _STREAM_GRB_H
 #define _STREAM_GRB_H
 
@@ -31243,11 +31548,9 @@ int   zaxisTypeToGrib2ltype(int zaxistype);
 
 void zaxisGetTypeDescription(int zaxisType, int* outPositive, const char** outName, const char** outLongName, const char** outStdName, const char** outUnit);  //The returned const char* point to static storage. Don't free or modify them.
 
-int zaxisSize(void);
-
 unsigned cdiZaxisCount(void);
 
-void cdiZaxisGetIndexList(unsigned numIDs, int IDs[numIDs]);
+void cdiZaxisGetIndexList(unsigned numIDs, int *IDs);
 
 void
 zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
@@ -31256,28 +31559,58 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
 
 void zaxisDefLtype2(int zaxisID, int ltype2);
 
-extern const resOps zaxisOps;
+const resOps *getZaxisOps(void);
 
 #endif
 
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
+
 
 #include <assert.h>
+#include <limits.h>
 #include <stdlib.h>
 #include <string.h>
 
 
 #ifdef HAVE_LIBGRIB_API
 
+struct CdiGribIterator {
+  CdiIterator super;
+
+  CdiInputFile* file;
+  off_t fileOffset;
+  unsigned char* gribBuffer;
+  size_t bufferSize, curRecordSize;
+#ifdef HAVE_LIBGRIB_API
+  grib_handle* gribHandle;
+#else
+  void* gribHandle;
+#endif
+};
+
+CdiIterator *cdiGribIterator_getSuper(CdiGribIterator *me)
+{
+  return &me->super;
+}
+
 //Since the error handling in constructors is usually very closely related to the workings of a destructor,
 //this function combines both functions in one, using a centralized exit.
 //The mode of operation depends on whether me is a NULL pointer on entry:
 //If it is NULL, a new object is allocated and constructed, which is returned if construction is successful.
 //If a non-NULL pointer is passed in, the object is destructed and NULL is returned. In this case, the other arguments are ignored.
-static CdiGribIterator* cdiGribIterator_condestruct(CdiGribIterator* me, const char* path, int filetype)
+static CdiGribIterator *cdiGribIterator_condestruct(CdiGribIterator *me, const char *path, int filetype)
 {
-  #define super() (&me->super)
+#define super() (&me->super)
   if(me) goto destruct;
-  me = xmalloc(sizeof(*me));
+  me = (CdiGribIterator *) Malloc(sizeof(*me));
   baseIterConstruct(super(), filetype);
 
   me->file = cdiInputFile_make(path);
@@ -31296,43 +31629,42 @@ static CdiGribIterator* cdiGribIterator_condestruct(CdiGribIterator* me, const c
 
 destruct:
   if(me->super.gridId != CDI_UNDEFID) gridDestroy(me->super.gridId);
-  if(me->gribHandle) grib_handle_delete(me->gribHandle);
-  free(me->gribBuffer);
+  if(me->gribHandle) grib_handle_delete((struct grib_handle *)me->gribHandle);
+  Free(me->gribBuffer);
   cdiRefObject_release(&me->file->super);
 destructSuper:
   baseIterDestruct(super());
-  free(me);
+  Free(me);
   me = NULL;
 
 success:
   return me;
-  #undef super
+#undef super
 }
 
-CdiIterator* cdiGribIterator_new(const char* path, int filetype)
+CdiIterator *cdiGribIterator_new(const char *path, int filetype)
 {
   return &cdiGribIterator_condestruct(NULL, path, filetype)->super;
 }
 
-CdiGribIterator* cdiGribIterator_makeClone(CdiIterator* super)
+CdiGribIterator *cdiGribIterator_makeClone(CdiIterator *super)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
 
   //Allocate memory and copy data. (operations that may fail)
-  CdiGribIterator* result = xmalloc(sizeof(*result));
+  CdiGribIterator* result = (struct CdiGribIterator *) Malloc(sizeof(*result));
   if(!result) goto fail;
-  *result = (CdiGribIterator)
-    {
-      .file = me->file,
-      .fileOffset = me->fileOffset,
-      .gribBuffer = NULL,
-      .bufferSize = me->bufferSize,
-      .curRecordSize = me->curRecordSize,
-      .gribHandle = NULL
-    };
+
+  result->file = me->file;
+  result->fileOffset = me->fileOffset;
+  result->gribBuffer = NULL;
+  result->bufferSize = me->bufferSize;
+  result->curRecordSize = me->curRecordSize;
+  result->gribHandle = NULL;
+
   if(me->gribBuffer)
     {
-      result->gribBuffer = xmalloc(me->bufferSize);
+      result->gribBuffer = (unsigned char *) Malloc(me->bufferSize);
       if(!result->gribBuffer) goto freeResult;
       memcpy(result->gribBuffer, me->gribBuffer, me->curRecordSize);
     }
@@ -31360,30 +31692,30 @@ CdiGribIterator* cdiGribIterator_makeClone(CdiIterator* super)
 deleteGribHandle:
   if(result->gribHandle) grib_handle_delete(result->gribHandle);
 freeBuffer:
-  free(result->gribBuffer);
+  Free(result->gribBuffer);
 freeResult:
-  free(result);
+  Free(result);
 fail:
   return NULL;
 }
 
-char* cdiGribIterator_serialize(CdiIterator* super)
+char *cdiGribIterator_serialize(CdiIterator *super)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
 
-  char* path = cdiInputFile_copyPath(me->file);
+  const char* path = cdiInputFile_getPath(me->file);
   char* escapedPath = cdiEscapeSpaces(path);
-  free(path);
-  char* result = myAsprintf("%s %zu", escapedPath, me->fileOffset);
-  free(escapedPath);
+  char* result = (char *) Malloc(strlen(escapedPath) + 3 * sizeof(int) * CHAR_BIT/8);
+  sprintf(result, "%s %zu", escapedPath, me->fileOffset);
+  Free(escapedPath);
   return result;
 }
 
 
-CdiGribIterator* cdiGribIterator_deserialize(const char* description)
+CdiGribIterator *cdiGribIterator_deserialize(const char *description)
 {
   char* path;
-  CdiGribIterator* me = xmalloc(sizeof(*me));
+  CdiGribIterator* me = (CdiGribIterator *) Malloc(sizeof(*me));
   if(!me) goto fail;
 
   description = baseIter_constructFromString(&me->super, description);
@@ -31393,11 +31725,11 @@ CdiGribIterator* cdiGribIterator_deserialize(const char* description)
   if(!path) goto destructSuper;
 
   me->file = cdiInputFile_make(path);
-  free(path);
+  Free(path);
   if(!me->file) goto destructSuper;
 
   {
-    const char* savedStart = description;
+    const char *savedStart = description;
     long long decodedOffset = strtoll(description, (char**)&description, 0);    //The cast is a workaround for the wrong signature of strtoll() (it should have been `long long strtoll(const char*, const char**, int)`, not `long long strtoll(const char*, char**, int)`.
     me->fileOffset = (off_t)decodedOffset;
     if(savedStart == description) goto closeFile;
@@ -31417,20 +31749,18 @@ closeFile:
   cdiRefObject_release(&me->file->super);
 destructSuper:
   baseIterDestruct(&me->super);
-  free(me);
+  Free(me);
 fail:
   return NULL;
 }
-#endif
 
-#ifdef HAVE_LIBGRIB_API
-static void cdiGribIterator_ensureBuffer(CdiGribIterator* me, size_t requiredSize)
+static void cdiGribIterator_ensureBuffer(CdiGribIterator *me, size_t requiredSize)
 {
   if(me->bufferSize < requiredSize)
     {
       me->bufferSize *= 2;
       if(me->bufferSize < requiredSize) me->bufferSize = requiredSize;
-      me->gribBuffer = xrealloc(me->gribBuffer, me->bufferSize);
+      me->gribBuffer = (unsigned char *) Realloc(me->gribBuffer, me->bufferSize);
     }
 }
 
@@ -31446,11 +31776,11 @@ static bool isGrib1DualLevel(int levelType)
     }
 }
 
-static const unsigned char* positionOfGribMarker(const unsigned char* data, size_t size)
+static const unsigned char *positionOfGribMarker(const unsigned char *data, size_t size)
 {
-  for(const unsigned char* currentPosition = data, *end = data + size; currentPosition < end; currentPosition++)
+  for(const unsigned char *currentPosition = data, *end = data + size; currentPosition < end; currentPosition++)
     {
-      currentPosition = memchr(currentPosition, 'G', size - (currentPosition - data) - 3);      //-3 to ensure that we don't overrun the buffer during the strncmp() call.
+      currentPosition = (unsigned char *)memchr(currentPosition, 'G', size - (size_t)(currentPosition - data) - 3);      //-3 to ensure that we don't overrun the buffer during the strncmp() call.
       if(!currentPosition) return NULL;
       if(!strncmp((const char*)currentPosition, "GRIB", 4)) return currentPosition;
     }
@@ -31459,7 +31789,7 @@ static const unsigned char* positionOfGribMarker(const unsigned char* data, size
 
 //This clobbers the contents of the gribBuffer!
 //Returns the file offset of the next 'GRIB' marker.
-static ssize_t scanToGribMarker(CdiGribIterator* me)
+static ssize_t scanToGribMarker(CdiGribIterator *me)
 {
   cdiGribIterator_ensureBuffer(me, 8*1024);
   const size_t kMaxScanSize = 16*1024*1024;
@@ -31469,39 +31799,39 @@ static ssize_t scanToGribMarker(CdiGribIterator* me)
       scanSize = me->bufferSize;
       if(scannedBytes + scanSize > kMaxScanSize) scanSize = kMaxScanSize - scannedBytes;
       assert(scanSize <= me->bufferSize);
-      int status = cdiInputFile_read(me->file, me->fileOffset + scannedBytes, scanSize, &scanSize, me->gribBuffer);
+      int status = cdiInputFile_read(me->file, me->fileOffset + (off_t)scannedBytes, scanSize, &scanSize, me->gribBuffer);
       if(status != CDI_NOERR && status != CDI_EEOF) return status;
 
-      const unsigned char* startPosition = positionOfGribMarker(me->gribBuffer, scanSize);
+      const unsigned char *startPosition = positionOfGribMarker(me->gribBuffer, scanSize);
       if(startPosition)
         {
-          return me->fileOffset + scannedBytes + (startPosition - me->gribBuffer);
+          return (ssize_t)(me->fileOffset + (off_t)scannedBytes + (off_t)(startPosition - me->gribBuffer));
         }
 
       //Get the offset for the next iteration if there is a next iteration.
       scanSize -= 3;        //so that we won't miss a 'GRIB' sequence that happens to be cut off
       scannedBytes += scanSize;
-      scannedBytes &= ~0xf; //make 16 bytes aligned
+      scannedBytes &= ~(size_t)0xf; //make 16 bytes aligned
     }
   return -1;
 }
 
-static unsigned decode24(void* beData)
+static unsigned decode24(void *beData)
 {
-  unsigned char* bytes = beData;
+  unsigned char* bytes = (unsigned char *)beData;
   return ((unsigned)bytes[0] << 16) + ((unsigned)bytes[1] << 8) + (unsigned)bytes[2];
 }
 
-static uint64_t decode64(void* beData)
+static uint64_t decode64(void *beData)
 {
-  unsigned char* bytes = beData;
+  unsigned char* bytes = (unsigned char *)beData;
   uint64_t result = 0;
   for(size_t i = 0; i < 8; i++) result = (result << 8) + bytes[i];
   return result;
 }
 
 //Determine the size of the GRIB record that begins at the given file offset.
-static int getRecordSize(CdiGribIterator* me, off_t gribFileOffset, size_t* outRecordSize)
+static int getRecordSize(CdiGribIterator *me, off_t gribFileOffset, size_t *outRecordSize)
 {
   char buffer[16];
   size_t readSize;
@@ -31533,9 +31863,9 @@ static int getRecordSize(CdiGribIterator* me, off_t gribFileOffset, size_t* outR
 }
 
 #if 0
-static void hexdump(void* data, size_t size)
+static void hexdump(void *data, size_t size)
 {
-  unsigned char* charData = data;
+  unsigned char *charData = data;
   for(size_t offset = 0; offset < size; )
     {
       printf("%016zx:", offset);
@@ -31552,11 +31882,11 @@ static void hexdump(void* data, size_t size)
 
 //Read a record into memory and wrap it in a grib_handle.
 //XXX: I have omitted checking for szip compression as it is done in grbReadVarDP() & friends since that appears to be a non-standard extension of the GRIB1 standard: bit 1 in octet 14 of the binary data section which is used to signal szip compressio is defined to be reserved in the standard. As such, it seems prudent not to support this and to encourage people with such szip compressed files to switch to the GRIB2/JPEG2000 format. However, in the case that this reasoning is wrong, this [...]
-static int readMessage(CdiGribIterator* me)
+static int readMessage(CdiGribIterator *me)
 {
   //Destroy the old grib_handle.
   if(me->gribHandle) grib_handle_delete(me->gribHandle), me->gribHandle = NULL;
-  me->fileOffset += me->curRecordSize;
+  me->fileOffset += (off_t)me->curRecordSize;
 
   //Find the next record and determine its size.
   ssize_t gribFileOffset = scanToGribMarker(me);
@@ -31580,9 +31910,9 @@ fail:
   return result;
 }
 
-int cdiGribIterator_nextField(CdiIterator* super)
+int cdiGribIterator_nextField(CdiIterator *super)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
 
   if(super->gridId != CDI_UNDEFID) gridDestroy(super->gridId), super->gridId = CDI_UNDEFID;
 
@@ -31601,15 +31931,15 @@ int cdiGribIterator_nextField(CdiIterator* super)
   return CDI_NOERR;
 }
 
-char* cdiGribIterator_inqTime(CdiIterator* super, bool getEndTime)
+char *cdiGribIterator_inqTime(CdiIterator *super, bool getEndTime)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
   return gribMakeTimeString(me->gribHandle, getEndTime);
 }
 
-int cdiGribIterator_levelType(CdiIterator* super, int levelSelector, char** outName, char** outLongName, char** outStdName, char** outUnit)
+int cdiGribIterator_levelType(CdiIterator *super, int levelSelector, char **outName, char **outLongName, char **outStdName, char **outUnit)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
 
   //First determine the zaxis type corresponding to the given level.
   int zaxisType = ZAXIS_GENERIC;
@@ -31626,12 +31956,12 @@ int cdiGribIterator_levelType(CdiIterator* super, int levelSelector, char** outN
     }
 
   //Then lookup the requested names.
-  const char* name, *longName, *stdName, *unit;
+  const char *name, *longName, *stdName, *unit;
   zaxisGetTypeDescription(zaxisType, NULL, &name, &longName, &stdName, &unit);
-  if(outName) *outName = myStrDup(name);
-  if(outLongName) *outLongName = myStrDup(longName);
-  if(outStdName) *outStdName = myStrDup(stdName);
-  if(outUnit) *outUnit = myStrDup(unit);
+  if(outName) *outName = strdup(name);
+  if(outLongName) *outLongName = strdup(longName);
+  if(outStdName) *outStdName = strdup(stdName);
+  if(outUnit) *outUnit = strdup(unit);
 
   return zaxisType;
 }
@@ -31645,18 +31975,18 @@ static double logicalLevelValue2(long gribType, long storedValue, long power)
       case GRIB2_LTYPE_LANDDEPTH:
       case GRIB2_LTYPE_ISOBARIC:
       case GRIB2_LTYPE_SIGMA:
-        return storedValue*(1000/factor);      //The evaluation order allows the factors of ten to cancel out before rounding.
+        return (double)storedValue * (1000.0/factor);      //The evaluation order allows the factors of ten to cancel out before rounding.
 
       case 255:
         return 0;
 
       default:
-        return storedValue/factor;
+        return (double)storedValue/factor;
     }
 }
 
 //The output values must be preinitialized, this function does not always write them.
-static int readLevel2(grib_handle* gribHandle, const char* levelTypeKey, const char* powerKey, const char* valueKey, double* outValue1, double* outValue2)
+static int readLevel2(grib_handle *gribHandle, const char *levelTypeKey, const char *powerKey, const char *valueKey, double *outValue1, double *outValue2)
 {
   assert(levelTypeKey && powerKey && valueKey && outValue1 && outValue2);
 
@@ -31677,8 +32007,8 @@ static int readLevel2(grib_handle* gribHandle, const char* levelTypeKey, const c
           int status;
           //XXX: I'm not 100% sure about how the coordinate pairs are stored in the file.
           //     I'm assuming an array of pairs due to the example code in grib_api-1.12.3/examples/F90/set_pv.f90, but that may be wrong.
-          if((status = grib_get_double_element(gribHandle, "pv", value*2    , outValue1))) return status;
-          if((status = grib_get_double_element(gribHandle, "pv", value*2 + 1, outValue2))) return status;
+          if((status = grib_get_double_element(gribHandle, "pv", (int)value*2    , outValue1))) return status;
+          if((status = grib_get_double_element(gribHandle, "pv", (int)value*2 + 1, outValue2))) return status;
           break;
         }
 
@@ -31693,9 +32023,9 @@ static int readLevel2(grib_handle* gribHandle, const char* levelTypeKey, const c
   return CDI_NOERR;
 }
 
-int cdiGribIterator_level(CdiIterator* super, int levelSelector, double* outValue1, double* outValue2)
+int cdiGribIterator_level(CdiIterator *super, int levelSelector, double *outValue1, double *outValue2)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
   double trash;
   if(!outValue1) outValue1 = &trash;
   if(!outValue2) outValue2 = &trash;
@@ -31717,25 +32047,25 @@ int cdiGribIterator_level(CdiIterator* super, int levelSelector, double* outValu
       long levelType = (uint8_t)gribGetLongDefault(me->gribHandle, "indicatorOfTypeOfLevel", -1);    //1 byte
       if(levelType == 255)
         {}
-      else if(isGrib1DualLevel(levelType))
+      else if(isGrib1DualLevel((int)levelType))
         {
-          *outValue1 = gribGetLongDefault(me->gribHandle, (levelSelector ? "bottomLevel" : "topLevel"), 0);
+          *outValue1 = (double)gribGetLongDefault(me->gribHandle, (levelSelector ? "bottomLevel" : "topLevel"), 0);
         }
       else if(levelType == 100)
         {
-          *outValue1 = 100*gribGetLongDefault(me->gribHandle, "level", 0);        //2 bytes
+          *outValue1 = 100 * (double)gribGetLongDefault(me->gribHandle, "level", 0);        //2 bytes
         }
       else
         {
-          *outValue1 = gribGetLongDefault(me->gribHandle, "level", 0);        //2 bytes
+          *outValue1 = (double)gribGetLongDefault(me->gribHandle, "level", 0);        //2 bytes
         }
     }
   return CDI_NOERR;
 }
 
-int cdiGribIterator_zaxisUuid(CdiIterator* super, int* outVgridNumber, int* outLevelCount, unsigned char (*outUuid)[16])
+int cdiGribIterator_zaxisUuid(CdiIterator *super, int *outVgridNumber, int *outLevelCount, unsigned char outUuid[CDI_UUID_SIZE])
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
 
   if(outVgridNumber)
     {
@@ -31751,57 +32081,64 @@ int cdiGribIterator_zaxisUuid(CdiIterator* super, int* outVgridNumber, int* outL
     }
   if(outUuid)
     {
-      size_t size = sizeof(*outUuid);
-      if(grib_get_bytes(me->gribHandle, "uuidOfVGrid", *outUuid, &size)) return CDI_EINVAL;
-      if(size != sizeof(*outUuid)) return CDI_EUFSTRUCT;
+      size_t size = CDI_UUID_SIZE;
+      if(grib_get_bytes(me->gribHandle, "uuidOfVGrid", outUuid, &size)) return CDI_EINVAL;
+      if(size != CDI_UUID_SIZE) return CDI_EUFSTRUCT;
     }
 
   return CDI_NOERR;
 }
 
-char* cdiGribIterator_copyVariableName(CdiIterator* super)
+char *cdiGribIterator_copyVariableName(CdiIterator *super)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
   return gribCopyString(me->gribHandle, "shortName");
 }
 
-void cdiGribIterator_readField(CdiIterator* super, double* buffer, size_t* nmiss)
+void cdiGribIterator_readField(CdiIterator *super, double *buffer, size_t *nmiss)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
 
+  GRIB_CHECK(my_grib_set_double(me->gribHandle, "missingValue", cdiDefaultMissval), 0);
   gribGetDoubleArray(me->gribHandle, "values", buffer);
   long gridType = gribGetLong(me->gribHandle, "gridDefinitionTemplateNumber");
   if(nmiss)
     {
-      *nmiss = (gridType >= 50 && gridType <= 53) ? 0 : (int)gribGetLong(me->gribHandle, "numberOfMissing");        //The condition excludes harmonic data.
+      *nmiss = (gridType >= 50 && gridType <= 53) ? (size_t)0 : (size_t)gribGetLong(me->gribHandle, "numberOfMissing");        //The condition excludes harmonic data.
     }
 }
 
-void cdiGribIterator_readFieldF(CdiIterator* super, float* buffer, size_t* nmiss)
+void cdiGribIterator_readFieldF(CdiIterator *super, float *buffer, size_t *nmiss)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
 
   size_t valueCount = gribGetArraySize(me->gribHandle, "values");
-  double* temp = malloc(valueCount*sizeof(*temp));
+  double* temp = (double *) Malloc(valueCount*sizeof(*temp));
   cdiGribIterator_readField(super, temp, nmiss);
-  for(size_t i = valueCount; i--; ) buffer[i] = temp[i];
-  free(temp);
+  for(size_t i = valueCount; i--; ) buffer[i] = (float)temp[i];
+  Free(temp);
 }
+#endif
 
-/**
+/*
 @Function cdiGribIterator_delete
 @Title Dispose off a CdiGribIterator instance.
 
- at Prototype void cdiGribIterator_delete(CdiGribIterator* me)
+ at Prototype void cdiGribIterator_delete(CdiGribIterator *me)
 @Parameter
     @item me The iterator to delete.
 
 @Description
     Combined destructor and deallocator. Make sure to match every call to cdiGribIterator_clone() with a call to this function.
 */
-void cdiGribIterator_delete(CdiGribIterator* me)
+void cdiGribIterator_delete(CdiGribIterator *me)
 {
+#ifdef HAVE_LIBGRIB_API
   if(me) cdiGribIterator_condestruct(me, NULL, 0);
+#else
+  (void)me;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
 
@@ -31809,11 +32146,11 @@ void cdiGribIterator_delete(CdiGribIterator* me)
 // callthroughs to provide direct access to the grib keys //////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
-/**
+/*
 @Function cdiGribIterator_inqEdition
 @Title Get the version of the GRIB standard that is used
 
- at Prototype int cdiGribIterator_inqEdition(CdiGribIterator* me)
+ at Prototype int cdiGribIterator_inqEdition(CdiGribIterator *me)
 @Parameter
     @item me The iterator to operate on.
 
@@ -31822,16 +32159,21 @@ void cdiGribIterator_delete(CdiGribIterator* me)
 @Description
     Returns the version of the file format.
 */
-int cdiGribIterator_inqEdition(CdiGribIterator* me)
+int cdiGribIterator_inqEdition(CdiGribIterator *me)
 {
-  return gribEditionNumber(me->gribHandle);
+#ifdef HAVE_LIBGRIB_API
+  return (int)gribEditionNumber(me->gribHandle);
+#else
+  (void)me;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_getLong
 @Title Access to grib_get_long()
 
- at Prototype int cdiGribIterator_getLong(CdiGribIterator* me, const char* key, long* result)
+ at Prototype int cdiGribIterator_getLong(CdiGribIterator *me, const char *key, long *result)
 @Parameter
     @item me The iterator to operate on.
     @item ... The arguments to the underlying GRIB-API function.
@@ -31841,16 +32183,23 @@ int cdiGribIterator_inqEdition(CdiGribIterator* me)
 @Description
     Callthrough to grib_get_long().
 */
-int cdiGribIterator_getLong(CdiGribIterator* me, const char* key, long* result)
+int cdiGribIterator_getLong(CdiGribIterator *me, const char *key, long *result)
 {
+#ifdef HAVE_LIBGRIB_API
   return grib_get_long(me->gribHandle, key, result);
+#else
+  (void)me;
+  (void)key;
+  (void)result;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_getLength
 @Title Access to grib_get_length()
 
- at Prototype int cdiGribIterator_getLength(CdiGribIterator* me, const char* key, size_t* result)
+ at Prototype int cdiGribIterator_getLength(CdiGribIterator *me, const char *key, size_t *result)
 @Parameter
     @item me The iterator to operate on.
     @item ... The arguments to the underlying GRIB-API function.
@@ -31860,16 +32209,29 @@ int cdiGribIterator_getLong(CdiGribIterator* me, const char* key, long* result)
 @Description
     Callthrough to grib_get_length().
 */
-int cdiGribIterator_getLength(CdiGribIterator* me, const char* key, size_t* result)
+int cdiGribIterator_getLength(CdiGribIterator *me, const char *key, size_t *result)
 {
+#ifdef HAVE_GRIB_GET_LENGTH
   return grib_get_length(me->gribHandle, key, result);
+#elif defined(HAVE_LIBGRIB_API)
+  (void)me;
+  (void)key;
+  (void)result;
+  Error("grib_get_length() is not available, so cdiGribIterator_getLength() can't be used");
+  return -1;
+#else
+  (void)me;
+  (void)key;
+  (void)result;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_getString
 @Title Access to grib_get_string()
 
- at Prototype int cdiGribIterator_getString(CdiGribIterator* me, const char* key, char* result, size_t* length)
+ at Prototype int cdiGribIterator_getString(CdiGribIterator *me, const char *key, char *result, size_t *length)
 @Parameter
     @item me The iterator to operate on.
     @item ... The arguments to the underlying GRIB-API function.
@@ -31879,16 +32241,24 @@ int cdiGribIterator_getLength(CdiGribIterator* me, const char* key, size_t* resu
 @Description
     Callthrough to grib_get_string().
 */
-int cdiGribIterator_getString(CdiGribIterator* me, const char* key, char* result, size_t* length)
+int cdiGribIterator_getString(CdiGribIterator *me, const char *key, char *result, size_t *length)
 {
+#ifdef HAVE_LIBGRIB_API
   return grib_get_string(me->gribHandle, key, result, length);
+#else
+  (void)me;
+  (void)key;
+  (void)result;
+  (void)length;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_inqLongValue
 @Title Get the value of a GRIB-API key as a long
 
- at Prototype long cdiGribIterator_inqLongValue(CdiGribIterator* me, const char* key)
+ at Prototype long cdiGribIterator_inqLongValue(CdiGribIterator *me, const char *key)
 @Parameter
     @item me The iterator to operate on.
     @item key The GRIB-API key to retrieve.
@@ -31899,16 +32269,22 @@ int cdiGribIterator_getString(CdiGribIterator* me, const char* key, char* result
     Use this to fetch a grib value if you are certain that the given key must be present.
     This will abort the process if the key cannot be retrieved.
 */
-long cdiGribIterator_inqLongValue(CdiGribIterator* me, const char* key)
+long cdiGribIterator_inqLongValue(CdiGribIterator *me, const char *key)
 {
+#ifdef HAVE_LIBGRIB_API
   return gribGetLong(me->gribHandle, key);
+#else
+  (void)me;
+  (void)key;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_inqLongDefaultValue
 @Title Get the value of a GRIB-API key as a long
 
- at Prototype long cdiGribIterator_inqLongDefaultValue(CdiGribIterator* me, const char* key, long defaultValue)
+ at Prototype long cdiGribIterator_inqLongDefaultValue(CdiGribIterator *me, const char *key, long defaultValue)
 @Parameter
     @item me The iterator to operate on.
     @item key The GRIB-API key to retrieve.
@@ -31920,16 +32296,23 @@ long cdiGribIterator_inqLongValue(CdiGribIterator* me, const char* key)
     Use this if you can handle failure to fetch the key by supplying a default value.
     This function cannot fail.
 */
-long cdiGribIterator_inqLongDefaultValue(CdiGribIterator* me, const char* key, long defaultValue)
+long cdiGribIterator_inqLongDefaultValue(CdiGribIterator *me, const char *key, long defaultValue)
 {
+#ifdef HAVE_LIBGRIB_API
   return gribGetLongDefault(me->gribHandle, key, defaultValue);
+#else
+  (void)me;
+  (void)key;
+  (void)defaultValue;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_inqStringValue
 @Title Safely retrieve a GRIB-API key with a string value
 
- at Prototype char* cdiGribIterator_inqStringValue(CdiGribIterator* me, const char* key)
+ at Prototype char *cdiGribIterator_inqStringValue(CdiGribIterator *me, const char *key)
 @Parameter
     @item me The iterator to operate on.
     @item key The GRIB-API key to retrieve.
@@ -31941,16 +32324,22 @@ long cdiGribIterator_inqLongDefaultValue(CdiGribIterator* me, const char* key, l
     allocate memory accordingly, call grib_get_string(), and return the pointer to the new string.
     Returns NULL on failure.
 */
-char* cdiGribIterator_inqStringValue(CdiGribIterator* me, const char* key)
+char *cdiGribIterator_inqStringValue(CdiGribIterator *me, const char *key)
 {
+#ifdef HAVE_LIBGRIB_API
   return gribCopyString(me->gribHandle, key);
+#else
+  (void)me;
+  (void)key;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_getDouble
 @Title Access to grib_get_double()
 
- at Prototype int cdiGribIterator_getDouble(CdiGribIterator* me, const char* key, double* result)
+ at Prototype int cdiGribIterator_getDouble(CdiGribIterator *me, const char *key, double *result)
 @Parameter
     @item me The iterator to operate on.
     @item ... The arguments to the underlying GRIB-API function.
@@ -31960,16 +32349,23 @@ char* cdiGribIterator_inqStringValue(CdiGribIterator* me, const char* key)
 @Description
     Callthrough to grib_get_double().
 */
-int cdiGribIterator_getDouble(CdiGribIterator* me, const char* key, double* result)
+int cdiGribIterator_getDouble(CdiGribIterator *me, const char *key, double *result)
 {
+#ifdef HAVE_LIBGRIB_API
   return grib_get_double(me->gribHandle, key, result);
+#else
+  (void)me;
+  (void)key;
+  (void)result;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_getSize
 @Title Access to grib_get_size()
 
- at Prototype int cdiGribIterator_getSize(CdiGribIterator* me, const char* key, size_t* result)
+ at Prototype int cdiGribIterator_getSize(CdiGribIterator *me, const char *key, size_t *result)
 @Parameter
     @item me The iterator to operate on.
     @item ... The arguments to the underlying GRIB-API function.
@@ -31979,16 +32375,23 @@ int cdiGribIterator_getDouble(CdiGribIterator* me, const char* key, double* resu
 @Description
     Callthrough to grib_get_size().
 */
-int cdiGribIterator_getSize(CdiGribIterator* me, const char* key, size_t* result)
+int cdiGribIterator_getSize(CdiGribIterator *me, const char *key, size_t *result)
 {
+#ifdef HAVE_LIBGRIB_API
   return grib_get_size(me->gribHandle, key, result);
+#else
+  (void)me;
+  (void)key;
+  (void)result;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_getLongArray
 @Title Access to grib_get_long_array()
 
- at Prototype int cdiGribIterator_getLongArray(CdiGribIterator* me, const char* key, long* result, size_t* size)
+ at Prototype int cdiGribIterator_getLongArray(CdiGribIterator *me, const char *key, long *result, size_t *size)
 @Parameter
     @item me The iterator to operate on.
     @item ... The arguments to the underlying GRIB-API function.
@@ -31998,16 +32401,24 @@ int cdiGribIterator_getSize(CdiGribIterator* me, const char* key, size_t* result
 @Description
     Callthrough to grib_get_long_array().
 */
-int cdiGribIterator_getLongArray(CdiGribIterator* me, const char* key, long* result, size_t* size)
+int cdiGribIterator_getLongArray(CdiGribIterator *me, const char *key, long *result, size_t *size)
 {
+#ifdef HAVE_LIBGRIB_API
   return grib_get_long_array(me->gribHandle, key, result, size);
+#else
+  (void)me;
+  (void)key;
+  (void)result;
+  (void)size;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_getDoubleArray
 @Title Access to grib_get_double_array()
 
- at Prototype int cdiGribIterator_getDoubleArray(CdiGribIterator* me, const char* key, double* result, size_t* size)
+ at Prototype int cdiGribIterator_getDoubleArray(CdiGribIterator *me, const char *key, double *result, size_t *size)
 @Parameter
     @item me The iterator to operate on.
     @item ... The arguments to the underlying GRIB-API function.
@@ -32017,16 +32428,24 @@ int cdiGribIterator_getLongArray(CdiGribIterator* me, const char* key, long* res
 @Description
     Callthrough to grib_get_double_array().
 */
-int cdiGribIterator_getDoubleArray(CdiGribIterator* me, const char* key, double* result, size_t* size)
+int cdiGribIterator_getDoubleArray(CdiGribIterator *me, const char *key, double *result, size_t *size)
 {
+#ifdef HAVE_LIBGRIB_API
   return grib_get_double_array(me->gribHandle, key, result, size);
+#else
+  (void)me;
+  (void)key;
+  (void)result;
+  (void)size;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_inqDoubleValue
 @Title Get the value of a GRIB-API key as a double
 
- at Prototype double cdiGribIterator_inqDoubleValue(CdiGribIterator* me, const char* key)
+ at Prototype double cdiGribIterator_inqDoubleValue(CdiGribIterator *me, const char *key)
 @Parameter
     @item me The iterator to operate on.
     @item key The GRIB-API key to retrieve.
@@ -32037,16 +32456,22 @@ int cdiGribIterator_getDoubleArray(CdiGribIterator* me, const char* key, double*
     Use this to fetch a grib value if you are certain that the given key must be present.
     This will abort the process if the key cannot be retrieved.
 */
-double cdiGribIterator_inqDoubleValue(CdiGribIterator* me, const char* key)
+double cdiGribIterator_inqDoubleValue(CdiGribIterator *me, const char *key)
 {
+#ifdef HAVE_LIBGRIB_API
   return gribGetDouble(me->gribHandle, key);
+#else
+  (void)me;
+  (void)key;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_inqDoubleDefaultValue
 @Title Get the value of a GRIB-API key as a double
 
- at Prototype double cdiGribIterator_inqDoubleDefaultValue(CdiGribIterator* me, const char* key, double defaultValue)
+ at Prototype double cdiGribIterator_inqDoubleDefaultValue(CdiGribIterator *me, const char *key, double defaultValue)
 @Parameter
     @item me The iterator to operate on.
     @item key The GRIB-API key to retrieve.
@@ -32058,12 +32483,46 @@ double cdiGribIterator_inqDoubleValue(CdiGribIterator* me, const char* key)
     Use this if you can handle failure to fetch the key by supplying a default value.
     This function cannot fail.
 */
-double cdiGribIterator_inqDoubleDefaultValue(CdiGribIterator* me, const char* key, double defaultValue)
+double cdiGribIterator_inqDoubleDefaultValue(CdiGribIterator *me, const char *key, double defaultValue)
 {
+#ifdef HAVE_LIBGRIB_API
   return gribGetDoubleDefault(me->gribHandle, key, defaultValue);
+#else
+  (void)me;
+  (void)key;
+  (void)defaultValue;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
+#ifndef MODEL_H
+#define MODEL_H
+
+int
+modelUnpack(void *buf, int size, int *position,
+            int originNamespace, void *context, int force_id);
+
+void modelDefaultEntries(void);
+
 #endif
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #if defined (HAVE_CONFIG_H)
 #endif
 
@@ -32073,9 +32532,9 @@ double cdiGribIterator_inqDoubleDefaultValue(CdiGribIterator* me, const char* ke
 #undef  UNDEFID
 #define UNDEFID -1
 
-int ECHAM4 = UNDEFID;
-int ECHAM5 = UNDEFID;
-int COSMO  = UNDEFID;
+static int ECHAM4 = UNDEFID,
+  ECHAM5 = UNDEFID,
+  COSMO  = UNDEFID;
 
 typedef struct
 {
@@ -32125,7 +32584,7 @@ modelNewEntry(cdiResH resH, int instID, int modelgribID, const char *name)
 {
   model_t *modelptr;
 
-  modelptr = (model_t *) xmalloc(sizeof(model_t));
+  modelptr = (model_t *) Malloc(sizeof(model_t));
   modelDefaultValue ( modelptr );
   if (resH == CDI_UNDEFID)
     modelptr->self = reshPut(modelptr, &modelOps);
@@ -32192,7 +32651,7 @@ void modelInit(void)
 
 struct modelLoc
 {
-  char *name;
+  const char *name;
   int instID, modelgribID, resID;
 };
 
@@ -32237,7 +32696,7 @@ findModelByName(int resID, void *res, void *data)
   return CDI_APPLY_GO_ON;
 }
 
-int modelInq(int instID, int modelgribID, char *name)
+int modelInq(int instID, int modelgribID, const char *name)
 {
   modelInit ();
 
@@ -32306,7 +32765,7 @@ const char *modelInqNamePtr(int modelID)
 static int
 modelCompareP(void *modelptr1, void *modelptr2)
 {
-  model_t *model1 = modelptr1, *model2 = modelptr2;
+  model_t *model1 = (model_t *)modelptr1, *model2 = (model_t *)modelptr2;
   int diff = (namespaceResHDecode(model1->instID).idx
               != namespaceResHDecode(model2->instID).idx)
     | (model1->modelgribID != model2->modelgribID)
@@ -32319,8 +32778,8 @@ void modelDestroyP ( void * modelptr )
 {
   model_t *mp = (model_t*) modelptr;
   if (mp->name)
-    free(mp->name);
-  free(mp);
+    Free(mp->name);
+  Free(mp);
 }
 
 
@@ -32384,22 +32843,24 @@ modelUnpack(void *buf, int size, int *position, int originNamespace, void *conte
   serializeUnpack(buf, size, position, tempbuf, model_nints, DATATYPE_INT, context);
   if (tempbuf[3] != 0)
     {
-      name = (char *)xmalloc((size_t)tempbuf[3]);
+      name = (char *) Malloc((size_t)tempbuf[3]);
       serializeUnpack(buf, size, position,
                       name, tempbuf[3], DATATYPE_TXT, context);
     }
   else
     {
-      name = "";
+      name = (char*)"";
     }
   int targetID = namespaceAdaptKey(tempbuf[0], originNamespace);
   model_t *mp = modelNewEntry(force_id?targetID:CDI_UNDEFID,
                               namespaceAdaptKey(tempbuf[1], originNamespace),
                               tempbuf[2], name);
   if (tempbuf[3] != 0)
-    free(name);
+    Free(name);
   xassert(!force_id
           || (mp->self == namespaceAdaptKey(tempbuf[0], originNamespace)));
+  reshSetStatus(mp->self, &modelOps,
+                reshGetStatus(mp->self, &modelOps) & ~RESH_SYNC_BIT);
   return mp->self;
 }
 
@@ -32449,8 +32910,9 @@ static int activeNamespace = 0;
     { .func = (void (*)()) fileClose_serial },              \
     { .func = (void (*)()) cdiStreamOpenDefaultDelegate },  \
     { .func = (void (*)()) cdiStreamDefVlist_ },            \
+    { .func = (void (*)()) cdiStreamSetupVlist_ },          \
     { .func = (void (*)()) cdiStreamWriteVar_ },            \
-    { .func = (void (*)()) cdiStreamwriteVarChunk_ },       \
+    { .func = (void (*)()) cdiStreamWriteVarChunk_ },       \
     { .func = (void (*)()) 0 },                             \
     { .func = (void (*)()) 0 },                             \
     { .func = (void (*)()) cdiStreamCloseDefaultDelegate }, \
@@ -32459,17 +32921,22 @@ static int activeNamespace = 0;
     CDI_NETCDF_SWITCHES                        \
     }
 
-#if defined (SX)
+#if defined (SX) || defined (__cplusplus)
 static const union namespaceSwitchValue
   defaultSwitches_[NUM_NAMESPACE_SWITCH] = defaultSwitches;
 #endif
 
+enum namespaceStatus {
+  NAMESPACE_STATUS_INUSE,
+  NAMESPACE_STATUS_UNUSED,
+};
+
 static struct Namespace
 {
-  statusCode resStage;
+  enum namespaceStatus resStage;
   union namespaceSwitchValue switches[NUM_NAMESPACE_SWITCH];
 } initialNamespace = {
-  .resStage = STAGE_DEFINITION,
+  .resStage = NAMESPACE_STATUS_INUSE,
   .switches = defaultSwitches
 };
 
@@ -32512,7 +32979,7 @@ enum {
   intbits = sizeof(int) * CHAR_BIT,
   nspbits = 4,
   idxbits = intbits - nspbits,
-  nspmask = (( 1 << nspbits ) - 1) << idxbits,
+  nspmask = (int)((( (unsigned)1 << nspbits ) - 1) << idxbits),
   idxmask = ( 1 << idxbits ) - 1,
 };
 
@@ -32555,7 +33022,7 @@ namespaceNew()
     {
       /* namespace is already available and only needs reinitialization */
       for (unsigned i = 0; i < namespacesSize; ++i)
-        if (namespaces[i].resStage == STAGE_UNUSED)
+        if (namespaces[i].resStage == NAMESPACE_STATUS_UNUSED)
           {
             newNamespaceID = (int)i;
             break;
@@ -32565,7 +33032,7 @@ namespaceNew()
     {
       /* make room for additional namespace */
       struct Namespace *newNameSpaces
-        = (struct Namespace *)xmalloc(((size_t)namespacesSize + 1) * sizeof (namespaces[0]));
+        = (struct Namespace *) Malloc(((size_t)namespacesSize + 1) * sizeof (namespaces[0]));
       memcpy(newNameSpaces, namespaces, sizeof (namespaces[0]));
       namespaces = newNameSpaces;
       ++namespacesSize;
@@ -32576,7 +33043,7 @@ namespaceNew()
       /* make room for additional namespace */
       newNamespaceID = (int)namespacesSize;
       namespaces
-        = (struct Namespace *)xrealloc(namespaces, ((size_t)namespacesSize + 1) * sizeof (namespaces[0]));
+        = (struct Namespace *) Realloc(namespaces, ((size_t)namespacesSize + 1) * sizeof (namespaces[0]));
       ++namespacesSize;
     }
   else /* implicit: namespacesSize >= NUM_NAMESPACES */
@@ -32586,15 +33053,15 @@ namespaceNew()
     }
   xassert(newNamespaceID >= 0 && newNamespaceID < NUM_NAMESPACES);
   ++nNamespaces;
-  namespaces[newNamespaceID].resStage = STAGE_DEFINITION;
-#if defined (SX)
+  namespaces[newNamespaceID].resStage = NAMESPACE_STATUS_INUSE;
+#if defined (SX) || defined (__cplusplus)
   memcpy(namespaces[newNamespaceID].switches,
          defaultSwitches_,
          sizeof (namespaces[newNamespaceID].switches));
 #else
-  memcpy(namespaces[newNamespaceID].switches,
-         (union namespaceSwitchValue[NUM_NAMESPACE_SWITCH])defaultSwitches,
-         sizeof (namespaces[newNamespaceID].switches));
+    memcpy(namespaces[newNamespaceID].switches,
+           (union namespaceSwitchValue[NUM_NAMESPACE_SWITCH])defaultSwitches,
+           sizeof (namespaces[newNamespaceID].switches));
 #endif
   reshListCreate(newNamespaceID);
   NAMESPACE_UNLOCK();
@@ -32609,7 +33076,7 @@ namespaceDelete(int namespaceID)
   xassert(namespaceID >= 0 && (unsigned)namespaceID < namespacesSize
           && nNamespaces);
   reshListDestruct(namespaceID);
-  namespaces[namespaceID].resStage = STAGE_UNUSED;
+  namespaces[namespaceID].resStage = NAMESPACE_STATUS_UNUSED;
   --nNamespaces;
   NAMESPACE_UNLOCK();
 }
@@ -32623,7 +33090,7 @@ int namespaceGetNumber ()
 void namespaceSetActive ( int nId )
 {
   xassert((unsigned)nId < namespacesSize
-          && namespaces[nId].resStage != STAGE_UNUSED);
+          && namespaces[nId].resStage != NAMESPACE_STATUS_UNUSED);
   activeNamespace = nId;
 }
 
@@ -32666,20 +33133,6 @@ int namespaceAdaptKey2 ( int originResH )
   return namespaceIdxEncode2 ( nsp, tin.idx );
 }
 
-
-void namespaceDefResStatus ( statusCode argResStatus )
-{
-  int nsp = namespaceGetActive ();
-  namespaces[nsp].resStage = argResStatus;
-}
-
-
-statusCode namespaceInqResStatus ( void )
-{
-  int nsp = namespaceGetActive ();
-  return namespaces[nsp].resStage;
-}
-
 void namespaceSwitchSet(enum namespaceSwitch sw, union namespaceSwitchValue value)
 {
   xassert(sw > NSSWITCH_NO_SUCH_SWITCH && sw < NUM_NAMESPACE_SWITCH);
@@ -32699,16 +33152,16 @@ void cdiReset(void)
   NAMESPACE_INIT();
   NAMESPACE_LOCK();
   for (unsigned namespaceID = 0; namespaceID < namespacesSize; ++namespaceID)
-    if (namespaces[namespaceID].resStage != STAGE_UNUSED)
+    if (namespaces[namespaceID].resStage != NAMESPACE_STATUS_UNUSED)
       namespaceDelete((int)namespaceID);
   if (namespaces != &initialNamespace)
     {
-      free(namespaces);
+      Free(namespaces);
       namespaces = &initialNamespace;
+      namespaces[0].resStage = NAMESPACE_STATUS_UNUSED;
     }
   namespacesSize = 1;
-  nNamespaces = 1;
-  activeNamespace = 0;
+  nNamespaces = 0;
   NAMESPACE_UNLOCK();
 }
 
@@ -32722,49 +33175,6 @@ void cdiReset(void)
  * End:
  */
 
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <errno.h>
-
-char* myStrDup(const char* string)
-{
-  char* result = xmalloc(strlen(string) + 1);
-  if(result)
-    {
-      strcpy(result, string);
-    }
-  else
-    {
-      errno = ENOMEM;
-    }
-  return result;
-}
-
-char* myAsprintf(char* format, ...)
-{
-  va_list args;
-  int size = 64;
-  char *buffer = xmalloc(size);
-  int nchars;
-  //Try to print in the allocated space.
-  va_start(args, format);
-  nchars = vsnprintf(buffer, size, format, args);
-  va_end(args);
-  if (nchars >= size)
-    {
-      //Reallocate buffer now that we know how much space is needed.
-      size = nchars + 1;
-      buffer = xrealloc(buffer, size);
-      va_start(args, format);
-      vsnprintf(buffer, size, format, args);
-      va_end(args);
-    }
-  return buffer;
-}
-
-
 
 void cdiRefObject_construct(CdiReferencedObject* me)
 {
@@ -32785,21 +33195,16 @@ void cdiRefObject_release(CdiReferencedObject* me)
   if(oldCount == 1)
     {
       me->destructor(me);
-      free(me);
+      Free(me);
     }
 }
 
-void cdiRefObject_destruct(CdiReferencedObject* me) { /* Empty for now, but that's no reason not to call it! */ }
-#ifndef MODEL_H
-#define MODEL_H
-
-int
-modelUnpack(void *buf, int size, int *position,
-            int originNamespace, void *context, int force_id);
-
-void modelDefaultEntries(void);
+void cdiRefObject_destruct(CdiReferencedObject* me)
+{
+  (void)me;
+  /* Empty for now, but that's no reason not to call it! */
+}
 
-#endif
 /*
  * Local Variables:
  * c-file-style: "Java"
@@ -32918,7 +33323,7 @@ listInitResources(int nsp)
   xassert(nsp < resHListSize && nsp >= 0);
   int size = resHList[nsp].size = MIN_LIST_SIZE;
   xassert(resHList[nsp].resources == NULL);
-  resHList[nsp].resources = (listElem_t*) xcalloc(MIN_LIST_SIZE, sizeof(listElem_t));
+  resHList[nsp].resources = (listElem_t*) Calloc(MIN_LIST_SIZE, sizeof(listElem_t));
   listElem_t *p = resHList[nsp].resources;
 
   for (int i = 0; i < size; i++ )
@@ -32952,7 +33357,7 @@ reshListCreate(int namespaceID)
   LIST_LOCK();
   if (resHListSize <= namespaceID)
     {
-      resHList = (struct resHList_t *)xrealloc(resHList, (size_t)(namespaceID + 1) * sizeof (resHList[0]));
+      resHList = (struct resHList_t *) Realloc(resHList, (size_t)(namespaceID + 1) * sizeof (resHList[0]));
       for (int i = resHListSize; i <= namespaceID; ++i)
         reshListClearEntry(i);
       resHListSize = namespaceID + 1;
@@ -32979,7 +33384,7 @@ reshListDestruct(int namespaceID)
           if (listElem->status & RESH_IN_USE_BIT)
             listElem->res.v.ops->valDestroy(listElem->res.v.val);
         }
-      free(resHList[namespaceID].resources);
+      Free(resHList[namespaceID].resources);
       resHList[namespaceID].resources = NULL;
       reshListClearEntry(namespaceID);
     }
@@ -32996,7 +33401,7 @@ static void listDestroy ( void )
     if (resHList[i-1].resources)
       namespaceDelete(i-1);
   resHListSize = 0;
-  free(resHList);
+  Free(resHList);
   resHList = NULL;
   cdiReset();
   LIST_UNLOCK();
@@ -33035,7 +33440,7 @@ void listSizeExtend()
   int oldSize = resHList[nsp].size;
   size_t newListSize = (size_t)oldSize + MIN_LIST_SIZE;
 
-  resHList[nsp].resources = (listElem_t*) xrealloc(resHList[nsp].resources,
+  resHList[nsp].resources = (listElem_t*) Realloc(resHList[nsp].resources,
                                                    newListSize * sizeof(listElem_t));
 
   listElem_t *r = resHList[nsp].resources;
@@ -33223,7 +33628,6 @@ reshGetElem(const char *caller, const char* expressionString, cdiResH resH, cons
   return listElem;
 }
 
-
 void *reshGetValue(const char * caller, const char* expressionString, cdiResH resH, const resOps * ops)
 {
   return reshGetElem(caller, expressionString, resH, ops)->res.v.val;
@@ -33231,7 +33635,7 @@ void *reshGetValue(const char * caller, const char* expressionString, cdiResH re
 
 /**************************************************************/
 
-void reshGetResHListOfType(unsigned numIDs, int resHs[numIDs], const resOps *ops)
+void reshGetResHListOfType(unsigned numIDs, int resHs[], const resOps *ops)
 {
   xassert ( resHs && ops );
 
@@ -33384,7 +33788,7 @@ void reshPackBufferDestroy ( char ** buffer )
 
 /**************************************************************/
 
-void reshPackBufferCreate(char **packBuffer, int *packBufferSize, void *context)
+int reshPackBufferCreate(char **packBuffer, int *packBufferSize, void *context)
 {
   int i, packBufferPos = 0;
   int end = END;
@@ -33396,7 +33800,7 @@ void reshPackBufferCreate(char **packBuffer, int *packBufferSize, void *context)
   int nsp = namespaceGetActive ();
 
   int pBSize = *packBufferSize = getPackBufferSize(context);
-  char *pB = *packBuffer = (char *)xcalloc(1, (size_t)pBSize);
+  char *pB = *packBuffer = (char *) Malloc((size_t)pBSize);
 
   {
     int header[resHPackHeaderNInt] = { START, nsp };
@@ -33431,6 +33835,7 @@ void reshPackBufferCreate(char **packBuffer, int *packBufferSize, void *context)
   LIST_UNLOCK();
 
   serializePack(&end, 1,  DATATYPE_INT, pB, pBSize, &packBufferPos, context);
+  return packBufferPos;
 }
 
 /**************************************************************/
@@ -33443,7 +33848,7 @@ void reshSetStatus ( cdiResH resH, const resOps * ops, int status )
   namespaceTuple_t nspT;
   listElem_t * listElem;
 
-  xassert(ops && (status & RESH_IN_USE_BIT));
+  xassert((ops != NULL) ^ !(status & RESH_IN_USE_BIT));
 
   LIST_INIT(1);
 
@@ -33460,7 +33865,8 @@ void reshSetStatus ( cdiResH resH, const resOps * ops, int status )
   xassert ( resHList[nsp].resources );
   listElem = resHList[nsp].resources + nspT.idx;
 
-  xassert ( listElem->res.v.ops == ops );
+  xassert((!ops || (listElem->res.v.ops == ops))
+          && (listElem->status & RESH_IN_USE_BIT) == (status & RESH_IN_USE_BIT));
 
   listElem->status = status;
 
@@ -33474,8 +33880,6 @@ int reshGetStatus ( cdiResH resH, const resOps * ops )
   int nsp;
   namespaceTuple_t nspT;
 
-  xassert ( ops );
-
   LIST_INIT(1);
 
   LIST_LOCK();
@@ -33494,7 +33898,7 @@ int reshGetStatus ( cdiResH resH, const resOps * ops )
 
   LIST_UNLOCK();
 
-  xassert(listElem && elemOps == ops);
+  xassert(listElem && (!(listElem->status & RESH_IN_USE_BIT) || elemOps == ops));
 
   return listElem->status;
 }
@@ -33712,19 +34116,27 @@ void serializeUnpackInCore(const void *buf, int buf_size, int *position,
   pos += size;
   *position = pos;
 }
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #if defined (HAVE_CONFIG_H)
 #endif
 
-#ifdef HAVE_LIBSERVICE
-
 #include <stdio.h>
+#include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
 #include <ctype.h>
 
 
 
-
 enum {
   SRV_HEADER_LEN = 8,
 };
@@ -33738,20 +34150,19 @@ static int srvDefaultDprec = 0;
 /*
  * A version string.
  */
-
 #undef  LIBVERSION
-#define LIBVERSION      1.3.2
+#define LIBVERSION      1.4.0
 #define XSTRING(x)	#x
 #define STRING(x)	XSTRING(x)
-static const char srv_libvers[] = STRING(LIBVERSION) " of "__DATE__" "__TIME__;
+static const char srv_libvers[] = STRING(LIBVERSION) " of " __DATE__" " __TIME__;
 
 const char *srvLibraryVersion(void)
 {
-  return (srv_libvers);
+  return srv_libvers;
 }
 
 
-int SRV_Debug = 0;    /* If set to 1, debugging */
+static int SRV_Debug = 0;    /* If set to 1, debugging */
 
 
 void srvDebug(int debug)
@@ -33762,22 +34173,19 @@ void srvDebug(int debug)
     Message("debug level %d", debug);
 }
 
-
+static
 void srvLibInit()
 {
-  char *envString;
-  char *envName = "SRV_PRECISION";
+  const char *envName = "SRV_PRECISION";
 
-
-  envString = getenv(envName);
+  char *envString = getenv(envName);
   if ( envString )
     {
-      int pos;
       int nrun;
       if ( strlen(envString) == 2 ) nrun = 1;
       else                          nrun = 2;
 
-      pos = 0;
+      int pos = 0;
       while ( nrun-- )
 	{
 	  switch ( tolower((int) envString[pos]) )
@@ -33786,8 +34194,8 @@ void srvLibInit()
 	      {
 		switch ( (int) envString[pos+1] )
 		  {
-		  case '4': srvDefaultHprec = SINGLE_PRECISION; break;
-		  case '8': srvDefaultHprec = DOUBLE_PRECISION; break;
+		  case '4': srvDefaultHprec = EXSE_SINGLE_PRECISION; break;
+		  case '8': srvDefaultHprec = EXSE_DOUBLE_PRECISION; break;
 		  default:
 		    Message("Invalid digit in %s: %s", envName, envString);
 		  }
@@ -33797,8 +34205,8 @@ void srvLibInit()
 	      {
 		switch ( (int) envString[pos+1] )
 		  {
-		  case '4': srvDefaultDprec = SINGLE_PRECISION; break;
-		  case '8': srvDefaultDprec = DOUBLE_PRECISION; break;
+		  case '4': srvDefaultDprec = EXSE_SINGLE_PRECISION; break;
+		  case '8': srvDefaultDprec = EXSE_DOUBLE_PRECISION; break;
 		  default:
 		    Message("Invalid digit in %s: %s", envName, envString);
 		  }
@@ -33817,7 +34225,7 @@ void srvLibInit()
   initSrvLib = 1;
 }
 
-
+static
 void srvInit(srvrec_t *srvp)
 {
   srvp->checked    = 0;
@@ -33830,44 +34238,42 @@ void srvInit(srvrec_t *srvp)
 }
 
 
-srvrec_t *srvNew(void)
+void *srvNew(void)
 {
-  srvrec_t *srvp;
-
   if ( ! initSrvLib ) srvLibInit();
 
-  srvp = (srvrec_t *) malloc(sizeof(srvrec_t));
+  srvrec_t *srvp = (srvrec_t *) Malloc(sizeof(srvrec_t));
 
   srvInit(srvp);
 
-  return (srvp);
+  return (void*)srvp;
 }
 
 
-void srvDelete(srvrec_t *srvp)
+void srvDelete(void *srv)
 {
+  srvrec_t *srvp = (srvrec_t *) srv;
+
   if ( srvp )
     {
-      if ( srvp->buffer ) free(srvp->buffer);
-      free(srvp);
+      if ( srvp->buffer ) Free(srvp->buffer);
+      Free(srvp);
     }
 }
 
 
 int srvCheckFiletype(int fileID, int *swap)
 {
-  size_t blocklen = 0;
-  size_t sblocklen = 0;
   size_t data = 0;
   size_t dimx = 0, dimy = 0;
   size_t fact = 0;
   int found = 0;
   unsigned char buffer[72], *pbuf;
 
-  if ( fileRead(fileID, buffer, 4) != 4 ) return (found);
+  if ( fileRead(fileID, buffer, 4) != 4 ) return found;
 
-  blocklen  = (size_t) get_UINT32(buffer);
-  sblocklen = (size_t) get_SUINT32(buffer);
+  size_t blocklen  = (size_t) get_UINT32(buffer);
+  size_t sblocklen = (size_t) get_SUINT32(buffer);
 
   if ( SRV_Debug )
     Message("blocklen = %d sblocklen = %d", blocklen, sblocklen);
@@ -33876,7 +34282,7 @@ int srvCheckFiletype(int fileID, int *swap)
     {
      *swap = 0;
       fact = blocklen>>3;
-      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return found;
       pbuf = buffer+4*fact;      dimx = (size_t) get_UINT32(pbuf);
       pbuf = buffer+5*fact;      dimy = (size_t) get_UINT32(pbuf);
       pbuf = buffer+blocklen+4;  data = (size_t) get_UINT32(pbuf);
@@ -33885,7 +34291,7 @@ int srvCheckFiletype(int fileID, int *swap)
     {
      *swap = 0;
       fact = blocklen>>3;
-      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return found;
       pbuf = buffer+4*fact;      dimx = (size_t) get_UINT64(pbuf);
       pbuf = buffer+5*fact;      dimy = (size_t) get_UINT64(pbuf);
       pbuf = buffer+blocklen+4;  data = (size_t) get_UINT32(pbuf);
@@ -33894,7 +34300,7 @@ int srvCheckFiletype(int fileID, int *swap)
     {
      *swap = 1;
       fact = sblocklen>>3;
-      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return found;
       pbuf = buffer+4*fact;       dimx = (size_t) get_SUINT32(pbuf);
       pbuf = buffer+5*fact;       dimy = (size_t) get_SUINT32(pbuf);
       pbuf = buffer+sblocklen+4;  data = (size_t) get_SUINT32(pbuf);
@@ -33903,7 +34309,7 @@ int srvCheckFiletype(int fileID, int *swap)
     {
      *swap = 1;
       fact = sblocklen>>3;
-      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return found;
       pbuf = buffer+4*fact;       dimx = (size_t) get_SUINT64(pbuf);
       pbuf = buffer+5*fact;       dimy = (size_t) get_SUINT64(pbuf);
       pbuf = buffer+sblocklen+4;  data = (size_t) get_SUINT32(pbuf);
@@ -33920,29 +34326,29 @@ int srvCheckFiletype(int fileID, int *swap)
       Message("dimx = %lu dimy = %lu data = %lu", dimx, dimy, data);
     }
 
-  return (found);
+  return found;
 }
 
 
-int srvInqHeader(srvrec_t *srvp, int *header)
+int srvInqHeader(void *srv, int *header)
 {
-  size_t i;
+  srvrec_t *srvp = (srvrec_t *) srv;
 
-  for ( i = 0; i < SRV_HEADER_LEN; i++ )
+  for ( size_t i = 0; i < SRV_HEADER_LEN; i++ )
     header[i] = srvp->header[i];
-  
+
   if ( SRV_Debug )
     Message("datasize = %lu", srvp->datasize);
 
-  return (0);
+  return 0;
 }
 
 
-int srvDefHeader(srvrec_t *srvp, const int *header)
+int srvDefHeader(void *srv, const int *header)
 {
-  size_t i;
+  srvrec_t *srvp = (srvrec_t *) srv;
 
-  for ( i = 0; i < SRV_HEADER_LEN; i++ )
+  for ( size_t i = 0; i < SRV_HEADER_LEN; i++ )
     srvp->header[i] = header[i];
 
   srvp->datasize = (size_t)(header[4] * header[5]);
@@ -33950,28 +34356,22 @@ int srvDefHeader(srvrec_t *srvp, const int *header)
   if ( SRV_Debug )
     Message("datasize = %lu", srvp->datasize);
 
-  return (0);
+  return 0;
 }
 
-
+static
 int srvInqData(srvrec_t *srvp, int prec, void *data)
 {
-  size_t datasize;
   size_t i;
   int ierr = 0;
-  int dprec;
-  void *buffer;
   int byteswap = srvp->byteswap;
-
-  datasize = srvp->datasize;
-
-  buffer = srvp->buffer;
-
-  dprec = srvp->dprec;
+  size_t datasize = srvp->datasize;
+  void *buffer = srvp->buffer;
+  int dprec = srvp->dprec;
 
   switch ( dprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	if ( sizeof(FLT32) == 4 )
 	  {
@@ -33980,7 +34380,7 @@ int srvInqData(srvrec_t *srvp, int prec, void *data)
 	    if ( dprec == prec )
 	      memcpy(data, buffer, datasize*sizeof(FLT32));
 	    else
-	      for (i = 0; i < datasize; i++)
+	      for ( i = 0; i < datasize; i++ )
 		((double *) data)[i] = (double) ((float *) buffer)[i];
 	  }
 	else
@@ -33989,7 +34389,7 @@ int srvInqData(srvrec_t *srvp, int prec, void *data)
 	  }
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
 	if ( sizeof(FLT64) == 8 )
 	  {
 	    if ( byteswap ) swap8byte(buffer, datasize);
@@ -33997,7 +34397,7 @@ int srvInqData(srvrec_t *srvp, int prec, void *data)
 	    if ( dprec == prec )
 	      memcpy(data, buffer, datasize*sizeof(FLT64));
 	    else
-	      for (i = 0; i < datasize; i++)
+	      for ( i = 0; i < datasize; i++ )
 		((float *) data)[i] = (float) ((double *) buffer)[i];
 	  }
 	else
@@ -34012,30 +34412,28 @@ int srvInqData(srvrec_t *srvp, int prec, void *data)
       }
     }
 
-  return (ierr);
+  return ierr;
 }
 
 
-int srvInqDataSP(srvrec_t *srvp, float *data)
+int srvInqDataSP(void *srv, float *data)
 {
-  return (srvInqData(srvp, SINGLE_PRECISION, (void *) data));
+  return srvInqData((srvrec_t *)srv, EXSE_SINGLE_PRECISION, (void *) data);
 }
 
 
-int srvInqDataDP(srvrec_t *srvp, double *data)
+int srvInqDataDP(void *srv, double *data)
 {
-  return (srvInqData(srvp, DOUBLE_PRECISION, (void *) data));
+  return srvInqData((srvrec_t *)srv, EXSE_DOUBLE_PRECISION, (void *) data);
 }
 
 
-int srvDefData(srvrec_t *srvp, int prec, const void *data)
+static int
+srvDefData(void *srv, int prec, const void *data)
 {
-  size_t datasize;
-  size_t blocklen;
-  size_t buffersize;
+  srvrec_t *srvp = (srvrec_t *) srv;
   size_t i;
   int dprec, hprec;
-  int *header;
   void *buffer;
 
   if ( srvDefaultDprec ) dprec = srvDefaultDprec;
@@ -34052,20 +34450,20 @@ int srvDefData(srvrec_t *srvp, int prec, const void *data)
 
   srvp->hprec = hprec;
 
-  header = srvp->header;
+  int *header = srvp->header;
 
-  datasize = (size_t)(header[4] * header[5]);
-  blocklen = datasize * (size_t)dprec;
+  size_t datasize = (size_t)(header[4] * header[5]);
+  size_t blocklen = datasize * (size_t)dprec;
 
   srvp->datasize = datasize;
 
-  buffersize = srvp->buffersize;
+  size_t buffersize = srvp->buffersize;
 
   if ( buffersize != blocklen )
     {
       buffersize = blocklen;
       buffer = srvp->buffer;
-      buffer = realloc(buffer, buffersize);
+      buffer = Realloc(buffer, buffersize);
       srvp->buffer = buffer;
       srvp->buffersize = buffersize;
     }
@@ -34074,22 +34472,22 @@ int srvDefData(srvrec_t *srvp, int prec, const void *data)
 
   switch ( dprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	if ( dprec == prec )
 	  memcpy(buffer, data, datasize*sizeof(FLT32));
 	else
-	  for (i = 0; i < datasize; i++)
+	  for ( i = 0; i < datasize; i++ )
 	    ((float *) buffer)[i] = (float) ((double *) data)[i];
 
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
 	if ( dprec == prec )
 	  memcpy(buffer, data, datasize*sizeof(FLT64));
 	else
-	  for (i = 0; i < datasize; i++)
+	  for ( i = 0; i < datasize; i++ )
 	    ((double *) buffer)[i] = (double) ((float *) data)[i];
 
 	break;
@@ -34101,30 +34499,31 @@ int srvDefData(srvrec_t *srvp, int prec, const void *data)
       }
     }
 
-  return (0);
+  return 0;
 }
 
 
-int srvDefDataSP(srvrec_t *srvp, const float *data)
+int srvDefDataSP(void *srv, const float *data)
 {
-  return (srvDefData(srvp, SINGLE_PRECISION, (void *) data));
+  return srvDefData(srv, EXSE_SINGLE_PRECISION, (void *) data);
 }
 
 
-int srvDefDataDP(srvrec_t *srvp, const double *data)
+int srvDefDataDP(void *srv, const double *data)
 {
-  return (srvDefData(srvp, DOUBLE_PRECISION, (void *) data));
+  return srvDefData(srv, EXSE_DOUBLE_PRECISION, (void *) data);
 }
 
 
-int srvRead(int fileID, srvrec_t *srvp)
+int srvRead(int fileID, void *srv)
 {
-  size_t datasize;
-  size_t blocklen, blocklen2;
+  srvrec_t *srvp = (srvrec_t *) srv;
   size_t i;
-  char tempheader[64];
+  union {
+    INT32 i32[SRV_HEADER_LEN];
+    INT64 i64[SRV_HEADER_LEN];
+  } tempheader;
   void *buffer;
-  int byteswap;
   int status;
 
   if ( ! srvp->checked )
@@ -34134,12 +34533,12 @@ int srvRead(int fileID, srvrec_t *srvp)
       srvp->checked = 1;
     }
 
-  byteswap = srvp->byteswap;
+  int byteswap = srvp->byteswap;
 
   /* read header record */
-  blocklen = binReadF77Block(fileID, byteswap);
+  size_t blocklen = binReadF77Block(fileID, byteswap);
 
-  if ( fileEOF(fileID) ) return (-1);
+  if ( fileEOF(fileID) ) return -1;
 
   if ( SRV_Debug )
     Message("blocklen = %lu", blocklen);
@@ -34150,21 +34549,21 @@ int srvRead(int fileID, srvrec_t *srvp)
 
   switch ( hprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
-	binReadInt32(fileID, byteswap, SRV_HEADER_LEN, (INT32 *) tempheader);
+	binReadInt32(fileID, byteswap, SRV_HEADER_LEN, tempheader.i32);
 
 	for ( i = 0; i < SRV_HEADER_LEN; i++ )
-          srvp->header[i] = (int) ((INT32 *) tempheader)[i];
+          srvp->header[i] = (int)tempheader.i32[i];
 
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
-	binReadInt64(fileID, byteswap, SRV_HEADER_LEN, (INT64 *) tempheader);
+	binReadInt64(fileID, byteswap, SRV_HEADER_LEN, tempheader.i64);
 
 	for ( i = 0; i < SRV_HEADER_LEN; i++ )
-          srvp->header[i] = (int) ((INT64 *) tempheader)[i];
+          srvp->header[i] = (int)tempheader.i64[i];
 
 	break;
       }
@@ -34175,12 +34574,12 @@ int srvRead(int fileID, srvrec_t *srvp)
       }
     }
 
-  blocklen2 = binReadF77Block(fileID, byteswap);
+  size_t blocklen2 = binReadF77Block(fileID, byteswap);
 
   if ( blocklen2 != blocklen )
     {
       Warning("Header blocklen differ (blocklen1=%d; blocklen2=%d)!", blocklen, blocklen2);
-      if ( blocklen2 != 0 ) return (-1);
+      if ( blocklen2 != 0 ) return -1;
     }
 
   srvp->datasize = (size_t)(srvp->header[4] * srvp->header[5]);
@@ -34196,23 +34595,23 @@ int srvRead(int fileID, srvrec_t *srvp)
     {
       buffersize = blocklen;
       buffer = srvp->buffer;
-      buffer = realloc(buffer, buffersize);
+      buffer = Realloc(buffer, buffersize);
       srvp->buffer = buffer;
       srvp->buffersize = buffersize;
     }
   else
     buffer = srvp->buffer;
 
-  datasize = srvp->datasize;
+  size_t datasize = srvp->datasize;
 
   size_t dprec = blocklen / datasize;
 
   srvp->dprec = (int)dprec;
 
-  if ( dprec != SINGLE_PRECISION && dprec != DOUBLE_PRECISION )
+  if ( dprec != EXSE_SINGLE_PRECISION && dprec != EXSE_DOUBLE_PRECISION )
     {
       Warning("Unexpected data precision %d", dprec);
-      return (-1);
+      return -1;
     }
 
   fileRead(fileID, buffer, blocklen);
@@ -34222,50 +34621,49 @@ int srvRead(int fileID, srvrec_t *srvp)
   if ( blocklen2 != blocklen )
     {
       Warning("Data blocklen differ (blocklen1=%d; blocklen2=%d)!", blocklen, blocklen2);
-      if ( blocklen2 != 0 ) return (-1);
+      if ( blocklen2 != 0 ) return -1;
     }
 
-  return (0);
+  return 0;
 }
 
 
-void srvWrite(int fileID, srvrec_t *srvp)
+void srvWrite(int fileID, void *srv)
 {
-  size_t datasize;
-  size_t blocklen;
+  srvrec_t *srvp = (srvrec_t *) srv;
   size_t i;
-  int dprec, hprec;
-  char tempheader[64];
-  int *header;
-  void *buffer;
+  union
+  {
+    INT32 i32[SRV_HEADER_LEN];
+    INT64 i64[SRV_HEADER_LEN];
+  } tempheader;
   int byteswap = srvp->byteswap;
-
-  dprec  = srvp->dprec;
-  hprec  = srvp->hprec;
-  header = srvp->header;
+  int dprec  = srvp->dprec;
+  int hprec  = srvp->hprec;
+  int *restrict header = srvp->header;
 
   /* write header record */
-  blocklen = SRV_HEADER_LEN * (size_t)hprec;
+  size_t blocklen = SRV_HEADER_LEN * (size_t)hprec;
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
   switch ( hprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	for (i = 0; i < SRV_HEADER_LEN; i++)
-          ((INT32 *) tempheader)[i] = (INT32) header[i];
+          tempheader.i32[i] = (INT32) header[i];
 
-	binWriteInt32(fileID, byteswap, SRV_HEADER_LEN, (INT32 *) tempheader);
+	binWriteInt32(fileID, byteswap, SRV_HEADER_LEN, tempheader.i32);
 
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
 	for (i = 0; i < SRV_HEADER_LEN; i++)
-          ((INT64 *) tempheader)[i] = (INT64) header[i];
+          tempheader.i64[i] = (INT64) header[i];
 
-	binWriteInt64(fileID, byteswap, SRV_HEADER_LEN, (INT64 *) tempheader);
+	binWriteInt64(fileID, byteswap, SRV_HEADER_LEN, tempheader.i64);
 
 	break;
       }
@@ -34278,23 +34676,23 @@ void srvWrite(int fileID, srvrec_t *srvp)
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
-  datasize = (size_t)(header[4] * header[5]);
+  size_t datasize = (size_t)(header[4] * header[5]);
   blocklen = datasize * (size_t)dprec;
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
   srvp->datasize = datasize;
 
-  buffer = srvp->buffer;
+  void *buffer = srvp->buffer;
 
   switch ( dprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	binWriteFlt32(fileID, byteswap, datasize, (FLT32 *) buffer);
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
 	binWriteFlt64(fileID, byteswap, datasize, (FLT64 *) buffer);
 	break;
@@ -34317,7 +34715,6 @@ void srvWrite(int fileID, srvrec_t *srvp)
  * require-trailing-newline: t
  * End:
  */
-#endif  /* HAVE_LIBSERVICE */
 #ifndef _STREAM_SRV_H
 #define _STREAM_SRV_H
 
@@ -34445,29 +34842,25 @@ const resOps streamOps = {
 
 
 
-
-#undef  IsBigendian
-#define IsBigendian()  ( u_byteorder.c[sizeof(long) - 1] )
-
-
 static
 int getByteorder(int byteswap)
 {
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
   int byteorder = -1;
 
-  if ( IsBigendian() )
+  switch (HOST_ENDIANNESS)
     {
-      if ( byteswap ) byteorder = CDI_LITTLEENDIAN;
-      else            byteorder = CDI_BIGENDIAN;
-    }
-  else
-    {
-      if ( byteswap ) byteorder = CDI_BIGENDIAN;
-      else            byteorder = CDI_LITTLEENDIAN;
+    case CDI_BIGENDIAN:
+      byteorder = byteswap ? CDI_LITTLEENDIAN : CDI_BIGENDIAN;
+      break;
+    case CDI_LITTLEENDIAN:
+      byteorder = byteswap ? CDI_BIGENDIAN : CDI_LITTLEENDIAN;
+      break;
+    /* FIXME: does not currently adjust for PDP endianness */
+    case CDI_PDPENDIAN:
+    default:
+      Error("unhandled endianness");
     }
-
-  return (byteorder);
+  return byteorder;
 }
 
 // used also in CDO
@@ -34595,16 +34988,19 @@ int streamInqFiletype(int streamID)
 
 int getByteswap(int byteorder)
 {
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
-  int byteswap = 0;
+  int byteswap = -1;
 
-  if ( IsBigendian() )
-    {
-      if ( byteorder == CDI_LITTLEENDIAN ) byteswap = TRUE;
-    }
-  else
+  switch (byteorder)
     {
-      if ( byteorder == CDI_BIGENDIAN ) byteswap = TRUE;
+    case CDI_BIGENDIAN:
+    case CDI_LITTLEENDIAN:
+    case CDI_PDPENDIAN:
+      byteswap = (HOST_ENDIANNESS != byteorder);
+      break;
+    case -1:
+      break;
+    default:
+      Error("unexpected byteorder %d query!", byteorder);
     }
 
   return (byteswap);
@@ -34628,13 +35024,12 @@ with the file format type @func{FILETYPE_SRV}, @func{FILETYPE_EXT} or @func{FILE
 */
 void streamDefByteorder(int streamID, int byteorder)
 {
-  int filetype;
   stream_t *streamptr = stream_to_pointer(streamID);
 
   stream_check_ptr(__func__, streamptr);
 
   streamptr->byteorder = byteorder;
-  filetype = streamptr->filetype;
+  int filetype = streamptr->filetype;
 
   switch (filetype)
     {
@@ -34812,7 +35207,7 @@ int cdiInqContents(stream_t * streamptr)
   return (status);
 }
 
-int cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
+int cdiStreamOpenDefaultDelegate(const char *filename, char filemode,
                                  int filetype, stream_t *streamptr,
                                  int recordBufIsToBeCreated)
 {
@@ -34823,11 +35218,11 @@ int cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
     case FILETYPE_GRB:
     case FILETYPE_GRB2:
       {
-        fileID = gribOpen(filename, filemode);
+        fileID = gribOpen(filename, (char [2]){filemode, 0});
         if ( fileID < 0 ) fileID = CDI_ESYSTEM;
         if (recordBufIsToBeCreated)
           {
-            streamptr->record = (Record *) malloc(sizeof(Record));
+            streamptr->record = (Record *) Malloc(sizeof(Record));
             streamptr->record->buffer = NULL;
           }
         break;
@@ -34836,11 +35231,11 @@ int cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
 #if  defined  (HAVE_LIBSERVICE)
     case FILETYPE_SRV:
       {
-        fileID = fileOpen(filename, filemode);
+        fileID = fileOpen(filename, (char [2]){filemode, 0});
         if ( fileID < 0 ) fileID = CDI_ESYSTEM;
         if (recordBufIsToBeCreated)
           {
-            streamptr->record = (Record *) malloc(sizeof(Record));
+            streamptr->record = (Record *) Malloc(sizeof(Record));
             streamptr->record->buffer = NULL;
             streamptr->record->exsep  = srvNew();
           }
@@ -34850,11 +35245,11 @@ int cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
 #if  defined  (HAVE_LIBEXTRA)
     case FILETYPE_EXT:
       {
-        fileID = fileOpen(filename, filemode);
+        fileID = fileOpen(filename, (char [2]){filemode, 0});
         if ( fileID < 0 ) fileID = CDI_ESYSTEM;
         if (recordBufIsToBeCreated)
           {
-            streamptr->record = (Record *) malloc(sizeof(Record));
+            streamptr->record = (Record *) Malloc(sizeof(Record));
             streamptr->record->buffer = NULL;
             streamptr->record->exsep  = extNew();
           }
@@ -34864,11 +35259,11 @@ int cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
 #if  defined  (HAVE_LIBIEG)
     case FILETYPE_IEG:
       {
-        fileID = fileOpen(filename, filemode);
+        fileID = fileOpen(filename, (char [2]){filemode, 0});
         if ( fileID < 0 ) fileID = CDI_ESYSTEM;
         if (recordBufIsToBeCreated)
           {
-            streamptr->record = (Record *) malloc(sizeof(Record));
+            streamptr->record = (Record *) Malloc(sizeof(Record));
             streamptr->record->buffer = NULL;
             streamptr->record->exsep   = iegNew();
           }
@@ -34878,18 +35273,18 @@ int cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
 #if  defined  (HAVE_LIBNETCDF)
     case FILETYPE_NC:
       {
-        fileID = cdfOpen(filename, filemode);
+        fileID = cdfOpen(filename, (char [2]){filemode, 0});
         break;
       }
     case FILETYPE_NC2:
       {
-        fileID = cdfOpen64(filename, filemode);
+        fileID = cdfOpen64(filename, (char [2]){filemode, 0});
         break;
       }
     case FILETYPE_NC4:
     case FILETYPE_NC4C:
       {
-        fileID = cdf4Open(filename, filemode, &filetype);
+        fileID = cdf4Open(filename, (char [2]){filemode, 0}, &filetype);
         break;
       }
 #endif
@@ -34906,26 +35301,26 @@ int cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
 }
 
 
-static int
-streamOpenID(const char *filename, const char *filemode, int filetype,
+int
+streamOpenID(const char *filename, char filemode, int filetype,
              int resH)
 {
   int fileID = CDI_UNDEFID;
   int status;
 
   if ( CDI_Debug )
-    Message("Open %s mode %c file %s", strfiletype(filetype), (int) *filemode,
+    Message("Open %s mode %c file %s", strfiletype(filetype), filemode,
             filename?filename:"(NUL)");
 
-  if ( ! filename || ! filemode || filetype < 0 ) return (CDI_EINVAL);
+  if ( ! filename || filetype < 0 ) return (CDI_EINVAL);
 
   stream_t *streamptr = stream_new_entry(resH);
   int streamID = CDI_ESYSTEM;
 
   {
-    int (*streamOpenDelegate)(const char *filename, const char *filemode,
+    int (*streamOpenDelegate)(const char *filename, char filemode,
                               int filetype, stream_t *streamptr, int recordBufIsToBeCreated)
-      = (int (*)(const char *, const char *, int, stream_t *, int))
+      = (int (*)(const char *, char, int, stream_t *, int))
       namespaceSwitchGet(NSSWITCH_STREAM_OPEN_BACKEND).func;
 
     fileID = streamOpenDelegate(filename, filemode, filetype, streamptr, 1);
@@ -34933,7 +35328,7 @@ streamOpenID(const char *filename, const char *filemode, int filetype,
 
   if (fileID < 0)
     {
-      free(streamptr->record);
+      Free(streamptr->record);
       stream_delete_entry(streamptr);
       streamID = fileID;
     }
@@ -34943,11 +35338,11 @@ streamOpenID(const char *filename, const char *filemode, int filetype,
 
       if ( streamID < 0 ) return (CDI_ELIMIT);
 
-      streamptr->filemode = tolower(*filemode);
+      streamptr->filemode = filemode;
       streamptr->filename = strdupx(filename);
       streamptr->fileID   = fileID;
 
-      if ( streamptr->filemode == 'r' )
+      if ( filemode == 'r' )
 	{
 	  int vlistID = vlistCreate();
 	  if ( vlistID < 0 ) return(CDI_ELIMIT);
@@ -34964,9 +35359,11 @@ streamOpenID(const char *filename, const char *filemode, int filetype,
   return (streamID);
 }
 
-int streamOpen(const char *filename, const char *filemode, int filetype)
+static int streamOpen(const char *filename, const char *filemode, int filetype)
 {
-  return streamOpenID(filename, filemode, filetype, CDI_UNDEFID);
+  if (!filemode || strlen(filemode) != 1) return CDI_EINVAL;
+  return streamOpenID(filename, (char)tolower(filemode[0]),
+                      filetype, CDI_UNDEFID);
 }
 
 static int streamOpenA(const char *filename, const char *filemode, int filetype)
@@ -34984,12 +35381,12 @@ static int streamOpenA(const char *filename, const char *filemode, int filetype)
   if ( ! filename || ! filemode || filetype < 0 ) return (CDI_EINVAL);
 
   {
-    int (*streamOpenDelegate)(const char *filename, const char *filemode,
+    int (*streamOpenDelegate)(const char *filename, char filemode,
                               int filetype, stream_t *streamptr, int recordBufIsToBeCreated)
-      = (int (*)(const char *, const char *, int, stream_t *, int))
+      = (int (*)(const char *, char, int, stream_t *, int))
       namespaceSwitchGet(NSSWITCH_STREAM_OPEN_BACKEND).func;
 
-    fileID = streamOpenDelegate(filename, "r", filetype, streamptr, 1);
+    fileID = streamOpenDelegate(filename, 'r', filetype, streamptr, 1);
   }
 
   if ( fileID == CDI_UNDEFID || fileID == CDI_ELIBNAVAIL || fileID == CDI_ESYSTEM ) return (fileID);
@@ -35209,8 +35606,6 @@ int streamOpenWrite(const char *filename, int filetype)
 static
 void streamDefaultValue ( stream_t * streamptr )
 {
-  int i;
-
   streamptr->self              = CDI_UNDEFID;
   streamptr->accesstype        = CDI_UNDEFID;
   streamptr->accessmode        = 0;
@@ -35248,15 +35643,16 @@ void streamDefaultValue ( stream_t * streamptr )
 
   basetimeInit(&streamptr->basetime);
 
+  int i;
   for ( i = 0; i < MAX_GRIDS_PS; i++ ) streamptr->xdimID[i]   = CDI_UNDEFID;
   for ( i = 0; i < MAX_GRIDS_PS; i++ ) streamptr->ydimID[i]   = CDI_UNDEFID;
   for ( i = 0; i < MAX_ZAXES_PS; i++ ) streamptr->zaxisID[i]  = CDI_UNDEFID;
+  for ( i = 0; i < MAX_ZAXES_PS; i++ ) streamptr->nczvarID[i] = CDI_UNDEFID;
   for ( i = 0; i < MAX_GRIDS_PS; i++ ) streamptr->ncxvarID[i] = CDI_UNDEFID;
   for ( i = 0; i < MAX_GRIDS_PS; i++ ) streamptr->ncyvarID[i] = CDI_UNDEFID;
   for ( i = 0; i < MAX_GRIDS_PS; i++ ) streamptr->ncavarID[i] = CDI_UNDEFID;
 
   streamptr->gribContainers    = NULL;
-  streamptr->vlistIDorig       = CDI_UNDEFID;
 }
 
 
@@ -35266,7 +35662,7 @@ static stream_t *stream_new_entry(int resH)
 
   cdiInitialize(); /* ***************** make MT version !!! */
 
-  streamptr = (stream_t *) xmalloc(sizeof(stream_t));
+  streamptr = (stream_t *) Malloc(sizeof(stream_t));
   streamDefaultValue ( streamptr );
   if (resH == CDI_UNDEFID)
     streamptr->self = reshPut(streamptr, &streamOps);
@@ -35346,6 +35742,15 @@ cdiStreamCloseDefaultDelegate(stream_t *streamptr, int recordBufIsToBeDeleted)
 }
 
 
+static void deallocate_sleveltable_t(sleveltable_t *entry)
+{
+  if (entry->recordID) Free(entry->recordID);
+  if (entry->lindex)   Free(entry->lindex);
+  entry->recordID = NULL;
+  entry->lindex   = NULL;
+}
+
+
 /*
 @Function  streamClose
 @Title     Close an open dataset
@@ -35362,7 +35767,6 @@ The function @func{streamClose} closes an open dataset.
 void streamClose(int streamID)
 {
   int index;
-  int vlistID;
   stream_t *streamptr = stream_to_pointer(streamID);
 
   stream_check_ptr(__func__, streamptr);
@@ -35370,7 +35774,7 @@ void streamClose(int streamID)
   if ( CDI_Debug )
     Message("streamID = %d filename = %s", streamID, streamptr->filename);
 
-  vlistID  = streamptr->vlistID;
+  int vlistID  = streamptr->vlistID;
 
   void (*streamCloseDelegate)(stream_t *streamptr, int recordBufIsToBeDeleted)
     = (void (*)(stream_t *, int))
@@ -35381,35 +35785,40 @@ void streamClose(int streamID)
   if ( streamptr->record )
     {
       if ( streamptr->record->buffer )
-        free(streamptr->record->buffer);
+        Free(streamptr->record->buffer);
 
-      free(streamptr->record);
+      Free(streamptr->record);
     }
 
   streamptr->filetype = 0;
-  if ( streamptr->filename ) free(streamptr->filename);
+  if ( streamptr->filename ) Free(streamptr->filename);
 
   for ( index = 0; index < streamptr->nvars; index++ )
     {
-      if ( streamptr->vars[index].level )
-	free(streamptr->vars[index].level);
-      if ( streamptr->vars[index].lindex )
-	free(streamptr->vars[index].lindex);
+      sleveltable_t *pslev = streamptr->vars[index].recordTable;
+      unsigned nsub = streamptr->vars[index].subtypeSize >= 0
+        ? (unsigned)streamptr->vars[index].subtypeSize : 0U;
+      for (size_t isub=0; isub < nsub; isub++)
+        {
+          deallocate_sleveltable_t(pslev + isub);
+        }
+      if (pslev) Free(pslev);
     }
-  free(streamptr->vars);
+  Free(streamptr->vars);
+  streamptr->vars = NULL;
 
   for ( index = 0; index < streamptr->ntsteps; ++index )
     {
       if ( streamptr->tsteps[index].records )
-	free(streamptr->tsteps[index].records);
+        Free(streamptr->tsteps[index].records);
       if ( streamptr->tsteps[index].recIDs )
-	free(streamptr->tsteps[index].recIDs);
+        Free(streamptr->tsteps[index].recIDs);
       taxisDestroyKernel(&streamptr->tsteps[index].taxis);
     }
 
-  if ( streamptr->tsteps ) free(streamptr->tsteps);
+  if ( streamptr->tsteps ) Free(streamptr->tsteps);
 
-  if ( streamptr->basetime.timevar_cache ) free(streamptr->basetime.timevar_cache);
+  if ( streamptr->basetime.timevar_cache ) Free(streamptr->basetime.timevar_cache);
 
   if ( vlistID != -1 )
     {
@@ -35433,7 +35842,7 @@ static void stream_delete_entry(stream_t *streamptr)
   xassert ( streamptr );
 
   idx = streamptr->self;
-  free ( streamptr );
+  Free( streamptr );
   reshRemove ( idx, &streamOps );
 
   if ( CDI_Debug )
@@ -35508,7 +35917,7 @@ void streamSync(int streamID)
 
 int cdiStreamDefTimestep_(stream_t *streamptr, int tsID)
 {
-  int taxisID;
+  int taxisID = 0;
 
   if ( CDI_Debug )
     Message("streamID = %d  tsID = %d", streamptr->self, tsID);
@@ -35729,7 +36138,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
     case FILETYPE_GRB2:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("grbReadVar not implemented for memtype float!");
-        grbReadVarDP(streamptr, varID, data, nmiss);
+        grbReadVarDP(streamptr, varID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -35737,7 +36146,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
     case FILETYPE_SRV:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("srvReadVar not implemented for memtype float!");
-        srvReadVarDP(streamptr, varID, data, nmiss);
+        srvReadVarDP(streamptr, varID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -35745,7 +36154,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
     case FILETYPE_EXT:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("extReadVar not implemented for memtype float!");
-        extReadVarDP(streamptr, varID, data, nmiss);
+        extReadVarDP(streamptr, varID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -35753,7 +36162,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
     case FILETYPE_IEG:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("iegReadVar not implemented for memtype float!");
-        iegReadVarDP(streamptr, varID, data, nmiss);
+        iegReadVarDP(streamptr, varID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -35764,9 +36173,9 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
     case FILETYPE_NC4C:
       {
         if ( memtype == MEMTYPE_FLOAT )
-          cdfReadVarSP(streamptr, varID, data, nmiss);
+          cdfReadVarSP(streamptr, varID, (float *)data, nmiss);
         else
-          cdfReadVarDP(streamptr, varID, data, nmiss);
+          cdfReadVarDP(streamptr, varID, (double *)data, nmiss);
 
 	break;
       }
@@ -35831,6 +36240,8 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
   check_parg(data);
 
   stream_t *streamptr = stream_to_pointer(streamID);
+  if (subtypeInqActiveIndex(streamptr->vars[varID].subtypeID) != 0)
+    Error("Writing of non-trivial subtypes not yet implemented!");
 
   stream_check_ptr(__func__, streamptr);
 
@@ -35853,7 +36264,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
     case FILETYPE_SRV:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("srvWriteVar not implemented for memtype float!");
-        srvWriteVarDP(streamptr, varID, data);
+        srvWriteVarDP(streamptr, varID, (double *)data);
 	break;
       }
 #endif
@@ -35861,7 +36272,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
     case FILETYPE_EXT:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("extWriteVar not implemented for memtype float!");
-        extWriteVarDP(streamptr, varID, data);
+        extWriteVarDP(streamptr, varID, (double *)data);
 	break;
       }
 #endif
@@ -35869,7 +36280,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
     case FILETYPE_IEG:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("iegWriteVar not implemented for memtype float!");
-        iegWriteVarDP(streamptr, varID, data);
+        iegWriteVarDP(streamptr, varID, (double *)data);
 	break;
       }
 #endif
@@ -35880,7 +36291,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
     case FILETYPE_NC4C:
       {
 	if ( streamptr->accessmode == 0 ) cdfEndDef(streamptr);
-        cdf_write_var(streamptr, varID, memtype, data, nmiss);
+        cdf_write_var(streamptr, varID, memtype, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -35970,7 +36381,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
     case FILETYPE_GRB2:
       {
         if ( memtype == MEMTYPE_FLOAT ) return 1;
-        grbReadVarSliceDP(streamptr, varID, levelID, data, nmiss);
+        grbReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -35978,7 +36389,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
     case FILETYPE_SRV:
       {
         if ( memtype == MEMTYPE_FLOAT ) return 1;
-        srvReadVarSliceDP(streamptr, varID, levelID, data, nmiss);
+        srvReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -35986,7 +36397,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
     case FILETYPE_EXT:
       {
         if ( memtype == MEMTYPE_FLOAT ) return 1;
-        extReadVarSliceDP(streamptr, varID, levelID, data, nmiss);
+        extReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -35994,7 +36405,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
     case FILETYPE_IEG:
       {
         if ( memtype == MEMTYPE_FLOAT ) return 1;
-        iegReadVarSliceDP(streamptr, varID, levelID, data, nmiss);
+        iegReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -36005,9 +36416,9 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
     case FILETYPE_NC4C:
       {
         if ( memtype == MEMTYPE_FLOAT )
-          cdfReadVarSliceSP(streamptr, varID, levelID, data, nmiss);
+          cdfReadVarSliceSP(streamptr, varID, levelID, (float *)data, nmiss);
         else
-          cdfReadVarSliceDP(streamptr, varID, levelID, data, nmiss);
+          cdfReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
         break;
       }
 #endif
@@ -36070,15 +36481,15 @@ from an open dataset.
 */
 void streamReadVarSliceF(int streamID, int varID, int levelID, float *data, int *nmiss)
 {
-  if ( cdiStreamReadVarSlice(streamID, varID,levelID, MEMTYPE_FLOAT, data, nmiss) )
+  if ( cdiStreamReadVarSlice(streamID, varID, levelID, MEMTYPE_FLOAT, data, nmiss) )
     {
       // In case the file format does not support single precision reading,
       // we fall back to double precision reading, converting the data on the fly.
       size_t elementCount = (size_t)gridInqSize(vlistInqVarGrid(streamInqVlist(streamID), varID));
-      double* conversionBuffer = malloc(elementCount * sizeof(*conversionBuffer));
+      double *conversionBuffer = (double *) Malloc(elementCount * sizeof(*conversionBuffer));
       streamReadVarSlice(streamID, varID, levelID, conversionBuffer, nmiss);
       for (size_t i = elementCount; i--; ) data[i] = (float)conversionBuffer[i];
-      free(conversionBuffer);
+      Free(conversionBuffer);
     }
 }
 
@@ -36090,6 +36501,8 @@ void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, c
   check_parg(data);
 
   stream_t *streamptr = stream_to_pointer(streamID);
+  if (subtypeInqActiveIndex(streamptr->vars[varID].subtypeID) != 0)
+    Error("Writing of non-trivial subtypes not yet implemented!");
 
   stream_check_ptr(__func__, streamptr);
 
@@ -36112,7 +36525,7 @@ void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, c
     case FILETYPE_SRV:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("srvWriteVarSlice not implemented for memtype float!");
-        srvWriteVarSliceDP(streamptr, varID, levelID, data);
+        srvWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
 	break;
       }
 #endif
@@ -36120,7 +36533,7 @@ void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, c
     case FILETYPE_EXT:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("extWriteVarSlice not implemented for memtype float!");
-        extWriteVarSliceDP(streamptr, varID, levelID, data);
+        extWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
 	break;
       }
 #endif
@@ -36128,7 +36541,7 @@ void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, c
     case FILETYPE_IEG:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("iegWriteVarSlice not implemented for memtype float!");
-        iegWriteVarSliceDP(streamptr, varID, levelID, data);
+        iegWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
 	break;
       }
 #endif
@@ -36209,7 +36622,7 @@ streamWriteVarChunk(int streamID, int varID,
 
 /* single image implementation */
 void
-cdiStreamwriteVarChunk_(int streamID, int varID, int memtype,
+cdiStreamWriteVarChunk_(int streamID, int varID, int memtype,
                         const int rect[][2], const void *data, int nmiss)
 {
   if ( CDI_Debug ) Message("streamID = %d varID = %d", streamID, varID);
@@ -36258,6 +36671,7 @@ cdiStreamwriteVarChunk_(int streamID, int varID, int memtype,
     }
 }
 
+#if 0
 void streamWriteContents(int streamID, char *cname)
 {
   stream_t *streamptr = stream_to_pointer(streamID);
@@ -36353,6 +36767,7 @@ void streamWriteContents(int streamID, char *cname)
 
   fclose(cnp);
 }
+#endif
 
 // This function is used in CDO!
 off_t streamNvals(int streamID)
@@ -36394,7 +36809,7 @@ cdiStreamDefVlist_(int streamID, int vlistID)
   stream_check_ptr(__func__, streamptr);
 
   if ( streamptr->vlistID == CDI_UNDEFID )
-    cdiStreamSetupVlist(streamptr, vlistDuplicate(vlistID), vlistID);
+    cdiStreamSetupVlist(streamptr, vlistDuplicate(vlistID));
   else
     Warning("vlist already defined for %s!", streamptr->filename);
 }
@@ -36425,16 +36840,6 @@ int streamInqVlist(int streamID)
 }
 
 
-int streamInqVlistIDorig(int streamID)
-{
-  stream_t *streamptr = stream_to_pointer(streamID);
-
-  stream_check_ptr(__func__, streamptr);
-
-  return (streamptr->vlistIDorig);
-}
-
-
 void streamDefCompType(int streamID, int comptype)
 {
   stream_t *streamptr = stream_to_pointer(streamID);
@@ -36491,9 +36896,10 @@ int streamInqFileID(int streamID)
   return (streamptr->fileID);
 }
 
+
 void cdiDefAccesstype(int streamID, int type)
 {
-  stream_t *streamptr = reshGetVal(streamID, &streamOps);
+  stream_t *streamptr = (stream_t *)reshGetVal(streamID, &streamOps);
 
   if ( streamptr->accesstype == CDI_UNDEFID )
     {
@@ -36507,9 +36913,7 @@ void cdiDefAccesstype(int streamID, int type)
 
 int cdiInqAccesstype(int streamID)
 {
-  stream_t *streamptr;
-
-  streamptr = ( stream_t *) reshGetVal ( streamID, &streamOps );
+  stream_t *streamptr = (stream_t *) reshGetVal ( streamID, &streamOps );
 
   return (streamptr->accesstype);
 }
@@ -36520,24 +36924,33 @@ int streamTxCode(void)
   return STREAM;
 }
 
+void
+cdiStreamSetupVlist(stream_t *streamptr, int vlistID)
+{
+  void (*myStreamSetupVlist)(stream_t *streamptr, int vlistID)
+    = (void (*)(stream_t *, int))
+    namespaceSwitchGet(NSSWITCH_STREAM_SETUP_VLIST).func;
+  myStreamSetupVlist(streamptr, vlistID);
+}
 
-void cdiStreamSetupVlist(stream_t *streamptr, int vlistID, int vlistIDorig)
+void
+cdiStreamSetupVlist_(stream_t *streamptr, int vlistID)
 {
   vlist_lock(vlistID);
   int nvars = vlistNvars(vlistID);
   streamptr->vlistID = vlistID;
-  streamptr->vlistIDorig = vlistIDorig;
   for (int varID = 0; varID < nvars; varID++ )
     {
-      int gridID  = vlistInqVarGrid(vlistID, varID);
-      int zaxisID = vlistInqVarZaxis(vlistID, varID);
-      stream_new_var(streamptr, gridID, zaxisID);
+      int gridID    = vlistInqVarGrid(vlistID, varID);
+      int zaxisID   = vlistInqVarZaxis(vlistID, varID);
+      int tilesetID = vlistInqVarSubtype(vlistID, varID);
+      stream_new_var(streamptr, gridID, zaxisID, tilesetID);
       if ( streamptr->have_missval )
         vlistDefVarMissval(vlistID, varID,
                            vlistInqVarMissval(vlistID, varID));
     }
 
-  if (streamptr->filemode == 'w' )
+  if (streamptr->filemode == 'w')
     switch (streamptr->filetype)
       {
 #ifdef HAVE_LIBNETCDF
@@ -36561,14 +36974,14 @@ void cdiStreamSetupVlist(stream_t *streamptr, int vlistID, int vlistIDorig)
 }
 
 
-void cdiStreamGetIndexList(unsigned numIDs, int IDs[numIDs])
+void cdiStreamGetIndexList(unsigned numIDs, int *IDs)
 {
   reshGetResHListOfType(numIDs, IDs, &streamOps);
 }
 
 int streamInqNvars ( int streamID )
 {
-  stream_t *streamptr = reshGetVal(streamID, &streamOps);
+  stream_t *streamptr = (stream_t *)reshGetVal(streamID, &streamOps);
   return streamptr->nvars;
 }
 
@@ -36586,8 +36999,6 @@ static int streamCompareP(void * streamptr1, void * streamptr2)
   xassert ( s2 );
 
   if ( s1->filetype  != s2->filetype  ) return differ;
-  if (  namespaceAdaptKey2 ( s1->vlistIDorig ) !=
-	namespaceAdaptKey2 ( s2->vlistIDorig )) return differ;
   if ( s1->byteorder != s2->byteorder ) return differ;
   if ( s1->comptype  != s2->comptype  ) return differ;
   if ( s1->complevel != s2->complevel ) return differ;
@@ -36621,53 +37032,46 @@ void streamPrintP   ( void * streamptr, FILE * fp )
 
   if ( !sp ) return;
 
-  fprintf ( fp, "#\n");
-  fprintf ( fp, "# streamID %d\n", sp->self);
-  fprintf ( fp, "#\n");
-  fprintf ( fp, "self          = %d\n", sp->self );
-  fprintf ( fp, "accesstype    = %d\n", sp->accesstype );
-  fprintf ( fp, "accessmode    = %d\n", sp->accessmode );
-  fprintf ( fp, "filetype      = %d\n", sp->filetype );
-  fprintf ( fp, "byteorder     = %d\n", sp->byteorder );
-  fprintf ( fp, "fileID        = %d\n", sp->fileID );
-  fprintf ( fp, "filemode      = %d\n", sp->filemode );
-  fprintf ( fp, "//off_t numvals;\n" );
-  fprintf ( fp, "filename      = %s\n", sp->filename );
-  fprintf ( fp, "//Record   *record;\n" );
-  fprintf ( fp, "nrecs         = %d\n", sp->nrecs );
-  fprintf ( fp, "nvars         = %d\n", sp->nvars );
-  fprintf ( fp, "//svarinfo_t *vars;\n" );
-  fprintf ( fp, "varsAllocated = %d\n", sp->varsAllocated );
-  fprintf ( fp, "curTsID       = %d\n", sp->curTsID );
-  fprintf ( fp, "rtsteps       = %d\n", sp->rtsteps );
-  fprintf ( fp, "//long ntsteps;\n" );
-  fprintf ( fp, "//  tsteps_t   *tsteps;\n" );
-  fprintf ( fp, "tstepsTableSize= %d\n", sp->tstepsTableSize );
-  fprintf ( fp, "tstepsNextID  = %d\n", sp->tstepsNextID );
-  fprintf ( fp, "//basetime_t  basetime;\n" );
-  fprintf ( fp, "ncmode        = %d\n", sp->ncmode );
-  fprintf ( fp, "vlistID       = %d\n", sp->vlistID );
-  fprintf ( fp, "//  int       xdimID[MAX_GRIDS_PS];\n" );
-  fprintf ( fp, "//  int       ydimID[MAX_GRIDS_PS];\n" );
-  fprintf ( fp, "//  int       zaxisID[MAX_ZAXES_PS];\n" );
-  fprintf ( fp, "//  int       ncxvarID[MAX_GRIDS_PS];\n" );
-  fprintf ( fp, "//  int       ncyvarID[MAX_GRIDS_PS];\n" );
-  fprintf ( fp, "//  int       ncavarID[MAX_GRIDS_PS];\n" );
-  fprintf ( fp, "historyID     = %d\n", sp->historyID );
-  fprintf ( fp, "globalatts    = %d\n", sp->globalatts );
-  fprintf ( fp, "localatts     = %d\n", sp->localatts );
-  fprintf ( fp, "//  VCT       vct;\n" );
-  fprintf ( fp, "unreduced     = %d\n", sp->unreduced );
-  fprintf ( fp, "sortname      = %d\n", sp->sortname );
-  fprintf ( fp, "have_missval  = %d\n", sp->have_missval );
-  fprintf ( fp, "ztype         = %d\n", sp->comptype );
-  fprintf ( fp, "zlevel        = %d\n", sp->complevel );
-  fprintf ( fp, "//  void    **gribContainers;\n" );
-  fprintf ( fp, "vlistIDorig   = %d\n", sp->vlistIDorig );
+  fprintf(fp, "#\n"
+          "# streamID %d\n"
+          "#\n"
+          "self          = %d\n"
+          "accesstype    = %d\n"
+          "accessmode    = %d\n"
+          "filetype      = %d\n"
+          "byteorder     = %d\n"
+          "fileID        = %d\n"
+          "filemode      = %d\n"
+          "filename      = %s\n"
+          "nrecs         = %d\n"
+          "nvars         = %d\n"
+          "varsAllocated = %d\n"
+          "curTsID       = %d\n"
+          "rtsteps       = %d\n"
+          "ntsteps       = %ld\n"
+          "tstepsTableSize= %d\n"
+          "tstepsNextID  = %d\n"
+          "ncmode        = %d\n"
+          "vlistID       = %d\n"
+          "historyID     = %d\n"
+          "globalatts    = %d\n"
+          "localatts     = %d\n"
+          "unreduced     = %d\n"
+          "sortname      = %d\n"
+          "have_missval  = %d\n"
+          "ztype         = %d\n"
+          "zlevel        = %d\n",
+          sp->self, sp->self, sp->accesstype, sp->accessmode,
+          sp->filetype, sp->byteorder, sp->fileID, sp->filemode,
+          sp->filename, sp->nrecs, sp->nvars, sp->varsAllocated,
+          sp->curTsID, sp->rtsteps, sp->ntsteps, sp->tstepsTableSize,
+          sp->tstepsNextID, sp->ncmode, sp->vlistID, sp->historyID,
+          sp->globalatts, sp->localatts, sp->unreduced, sp->sortname,
+          sp->have_missval, sp->comptype, sp->complevel);
 }
 
 enum {
-  streamNint = 11,
+  streamNint = 10,
 };
 
 static int
@@ -36691,17 +37095,16 @@ streamPack(void * streamptr, void * packBuffer, int packBufferSize,
   stream_t * streamP = ( stream_t * ) streamptr;
   int intBuffer[streamNint];
 
-  intBuffer[0]  = streamP->self;
-  intBuffer[1]  = streamP->filetype;
-  intBuffer[2]  = (int)strlen(streamP->filename) + 1;
-  intBuffer[3]  = streamP->vlistID;
-  intBuffer[4]  = streamP->vlistIDorig;
-  intBuffer[5]  = streamP->byteorder;
-  intBuffer[6]  = streamP->comptype;
-  intBuffer[7]  = streamP->complevel;
-  intBuffer[8]  = streamP->unreduced;
-  intBuffer[9]  = streamP->sortname;
-  intBuffer[10] = streamP->have_missval;
+  intBuffer[0] = streamP->self;
+  intBuffer[1] = streamP->filetype;
+  intBuffer[2] = (int)strlen(streamP->filename) + 1;
+  intBuffer[3] = streamP->vlistID;
+  intBuffer[4] = streamP->byteorder;
+  intBuffer[5] = streamP->comptype;
+  intBuffer[6] = streamP->complevel;
+  intBuffer[7] = streamP->unreduced;
+  intBuffer[8] = streamP->sortname;
+  intBuffer[9] = streamP->have_missval;
 
   serializePack(intBuffer, streamNint, DATATYPE_INT, packBuffer, packBufferSize, packBufferPos, context);
   uint32_t d = cdiCheckSum(DATATYPE_INT, streamNint, intBuffer);
@@ -36717,7 +37120,7 @@ struct streamAssoc
 streamUnpack(char * unpackBuffer, int unpackBufferSize,
              int * unpackBufferPos, int originNamespace, void *context)
 {
-  int intBuffer[streamNint], streamID;
+  int intBuffer[streamNint];
   uint32_t d;
   char filename[CDI_MAX_NAME];
 
@@ -36734,19 +37137,22 @@ streamUnpack(char * unpackBuffer, int unpackBufferSize,
   serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                   &d, 1, DATATYPE_UINT32, context);
   xassert(d == cdiCheckSum(DATATYPE_TXT, intBuffer[2], filename));
-  int targetStreamID = namespaceAdaptKey(intBuffer[0], originNamespace);
-  streamID = streamOpenID(filename, "w", intBuffer[1], targetStreamID);
+  int targetStreamID = namespaceAdaptKey(intBuffer[0], originNamespace),
+    streamID = streamOpenID(filename, 'w', intBuffer[1], targetStreamID);
   xassert(streamID >= 0 && targetStreamID == streamID);
-  streamDefByteorder(streamID, intBuffer[5]);
-  streamDefCompType(streamID, intBuffer[6]);
-  streamDefCompLevel(streamID, intBuffer[7]);
+  streamDefByteorder(streamID, intBuffer[4]);
+  streamDefCompType(streamID, intBuffer[5]);
+  streamDefCompLevel(streamID, intBuffer[6]);
   stream_t *streamptr = stream_to_pointer(streamID);
-  streamptr->unreduced = intBuffer[8];
-  streamptr->sortname = intBuffer[9];
-  streamptr->have_missval = intBuffer[10];
-  struct streamAssoc retval = { streamID, intBuffer[3], intBuffer[4] };
+  streamptr->unreduced = intBuffer[7];
+  streamptr->sortname = intBuffer[8];
+  streamptr->have_missval = intBuffer[9];
+  struct streamAssoc retval = { streamID, intBuffer[3] };
   return retval;
 }
+
+
+
 /*
  * Local Variables:
  * c-file-style: "Java"
@@ -36766,18 +37172,19 @@ streamUnpack(char * unpackBuffer, int unpackBufferSize,
 void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
 		  int level1, int level2, int level_sf, int level_unit, int prec,
 		  int *pvarID, int *plevelID, int tsteptype, int numavg, int ltype1, int ltype2,
-		  const char *name, const char *stdname, const char *longname, const char *units);
+		  const char *name, const char *stdname, const char *longname, const char *units,
+                  const var_tile_t *tiles, int *tile_index);
 
 void varDefVCT(size_t vctsize, double *vctptr);
 void varDefZAxisReference(int nlev, int nvgrid, unsigned char uuid[CDI_UUID_SIZE]);
 
-int  varDefGrid(int vlistID, const grid_t *grid, int mode);
 int  varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbounds,
 		 double *levels1, double *levels2, int vctsize, double *vct, char *name,
-		 char *longname, char *units, int prec, int mode, int ltype);
+		 char *longname, const char *units, int prec, int mode, int ltype);
 
 void varDefMissval(int varID, double missval);
 void varDefCompType(int varID, int comptype);
+void varDefCompLevel(int varID, int complevel);
 void varDefInst(int varID, int instID);
 int  varInqInst(int varID);
 void varDefModel(int varID, int modelID);
@@ -36790,11 +37197,11 @@ void varDefTypeOfGeneratingProcess(int varID, int typeOfGeneratingProcess);
 void varDefProductDefinitionTemplate(int varID, int productDefinitionTemplate);
 
 
-void varDefOptGribInt(int varID, long lval, const char *keyword);
-void varDefOptGribDbl(int varID, double dval, const char *keyword);
+void varDefOptGribInt(int varID, int tile_index, long lval, const char *keyword);
+void varDefOptGribDbl(int varID, int tile_index, double dval, const char *keyword);
 int varOptGribNentries(int varID);
 
-int  zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, const double *levels, char *longname, char *units, int ltype);
+int  zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, const double *levels, const char *longname, const char *units, int ltype);
 
 #endif
 /*
@@ -36824,6 +37231,7 @@ int  zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, const do
 
 
 //#define PROJECTION_TEST
+extern int CDI_cmor_mode;
 
 #undef  UNDEFID
 #define UNDEFID  CDI_UNDEFID
@@ -36834,6 +37242,8 @@ static void cdfDefGlobalAtts(stream_t *streamptr);
 static void cdfDefLocalAtts(stream_t *streamptr);
 #endif
 
+#define  BNDS_NAME  "bnds"
+
 #define  X_AXIS  1
 #define  Y_AXIS  2
 #define  Z_AXIS  3
@@ -36856,8 +37266,8 @@ ncdim_t;
 typedef struct {
   int      ncid;
   int      ignore;
-  int      isvar;
-  int      islon;
+  short    isvar;
+  short    islon;
   int      islat;
   int      islev;
   int      istime;
@@ -36868,6 +37278,8 @@ typedef struct {
   int      tabnum;
   int      climatology;
   int      bounds;
+  int      lformula;
+  int      lformulaterms;
   int      gridID;
   int      zaxisID;
   int      gridtype;
@@ -36879,6 +37291,7 @@ typedef struct {
   int      yvarid;
   int      zvarid;
   int      tvarid;
+  int      psvarid;
   int      ncoordvars;
   int      coordvarids[MAX_COORDVARS];
   int      nauxvars;
@@ -36900,12 +37313,12 @@ typedef struct {
   int      chunked;
   int      chunktype;
   int      natts;
-  int     *atts;
   int      deflate;
   int      lunsigned;
   int      lvalidrange;
-  size_t   vlen;
-  double  *vdata;
+  int     *atts;
+  size_t   vctsize;
+  double  *vct;
   double   missval;
   double   fillval;
   double   addoffset;
@@ -36974,7 +37387,7 @@ int isTimeAxisUnits(const char *timeunits)
   int status = FALSE;
 
   size_t len = strlen(timeunits);
-  tu = xmalloc((len+1)*sizeof(char));
+  tu = (char *) Malloc((len+1)*sizeof(char));
   memcpy(tu, timeunits, (len+1) * sizeof(char));
   ptu = tu;
 
@@ -36998,7 +37411,7 @@ int isTimeAxisUnits(const char *timeunits)
         }
     }
 
-  free(tu);
+  Free(tu);
 
   return (status);
 }
@@ -37099,7 +37512,7 @@ int setBaseTime(const char *timeunits, taxis_t *taxis)
   int timeunit;
 
   size_t len = strlen(timeunits);
-  tu = xmalloc((len+1) * sizeof (char));
+  tu = (char *) Malloc((len+1) * sizeof (char));
   memcpy(tu, timeunits, (len+1) * sizeof (char));
   ptu = tu;
 
@@ -37156,7 +37569,7 @@ int setBaseTime(const char *timeunits, taxis_t *taxis)
   (*taxis).type = timetype;
   (*taxis).unit = timeunit;
 
-  free(tu);
+  Free(tu);
 
   if ( CDI_Debug )
     Message("timetype = %d  unit = %d", timetype, timeunit);
@@ -37165,7 +37578,7 @@ int setBaseTime(const char *timeunits, taxis_t *taxis)
 }
 
 static
-void cdfGetAttInt(int fileID, int ncvarid, char *attname, int attlen, int *attint)
+void cdfGetAttInt(int fileID, int ncvarid, const char *attname, int attlen, int *attint)
 {
   nc_type atttype;
   size_t nc_attlen;
@@ -37180,7 +37593,7 @@ void cdfGetAttInt(int fileID, int ncvarid, char *attname, int attlen, int *attin
       int *pintatt = NULL;
 
       if ( (int)nc_attlen > attlen )
-        pintatt = (int *) malloc(nc_attlen * sizeof (int));
+        pintatt = (int *) Malloc(nc_attlen * sizeof (int));
       else
         pintatt = attint;
 
@@ -37189,7 +37602,7 @@ void cdfGetAttInt(int fileID, int ncvarid, char *attname, int attlen, int *attin
       if ( (int)nc_attlen > attlen )
         {
           memcpy(attint, pintatt, (size_t)attlen * sizeof (int));
-          free(pintatt);
+          Free(pintatt);
         }
     }
 }
@@ -37210,7 +37623,7 @@ void cdfGetAttDouble(int fileID, int ncvarid, char *attname, int attlen, double
       double *pdoubleatt = NULL;
 
       if ( (int)nc_attlen > attlen )
-        pdoubleatt = (double *) malloc(nc_attlen * sizeof (double));
+        pdoubleatt = (double *) Malloc(nc_attlen * sizeof (double));
       else
         pdoubleatt = attdouble;
 
@@ -37219,13 +37632,13 @@ void cdfGetAttDouble(int fileID, int ncvarid, char *attname, int attlen, double
       if ( (int)nc_attlen > attlen )
         {
           memcpy(attdouble, pdoubleatt, (size_t)attlen * sizeof (double));
-          free(pdoubleatt);
+          Free(pdoubleatt);
         }
     }
 }
 
 static
-void cdfGetAttText(int fileID, int ncvarid, char *attname, int attlen, char *atttext)
+void cdfGetAttText(int fileID, int ncvarid,const char *attname, int attlen, char *atttext)
 {
   nc_type atttype;
   size_t nc_attlen;
@@ -37263,7 +37676,7 @@ void cdfGetAttText(int fileID, int ncvarid, char *attname, int attlen, char *att
           if ( ssize > (size_t)attlen ) ssize = (size_t)attlen;
           memcpy(atttext, attbuf, ssize);
           atttext[ssize - 1] = 0;
-          free(attbuf);
+          Free(attbuf);
         }
       else
         {
@@ -37285,7 +37698,7 @@ int xtypeIsText(int xtype)
     isText = TRUE;
 #endif
 
-  return (isText);
+  return isText;
 }
 
 static
@@ -37370,7 +37783,7 @@ resizeBuf(void **buf, size_t *bufSize, size_t reqSize)
 {
   if (reqSize > *bufSize)
     {
-      *buf = xrealloc(*buf, reqSize);
+      *buf = Realloc(*buf, reqSize);
       *bufSize = reqSize;
     }
   return *buf;
@@ -37416,10 +37829,17 @@ void defineAttributes(int vlistID, int varID, int fileID, int ncvarID)
           double *attflt = (double *)resizeBuf(&attBuf, &attBufSize, attSize);
           vlistInqAttFlt(vlistID, varID, attname, attlen, attflt);
           len = (size_t)attlen;
-          cdf_put_att_double(fileID, ncvarID, attname, atttype == DATATYPE_FLT32 ? NC_FLOAT : NC_DOUBLE, len, attflt);
+          if ( atttype == DATATYPE_FLT32 )
+            {
+              float attflt_sp[len];
+              for ( size_t i = 0; i < len; ++i ) attflt_sp[i] = (float)attflt[i];
+              cdf_put_att_float(fileID, ncvarID, attname, NC_FLOAT, len, attflt_sp);
+            }
+          else
+            cdf_put_att_double(fileID, ncvarID, attname, NC_DOUBLE, len, attflt);
         }
     }
-  free(attBuf);
+  Free(attBuf);
 }
 
 
@@ -37434,13 +37854,13 @@ void cdfCopyRecord(stream_t *streamptr2, stream_t *streamptr1)
   int gridID   = vlistInqVarGrid(vlistID1, ivarID);
   int datasize = gridInqSize(gridID);
 
-  double *data = xmalloc((size_t)datasize * sizeof (double));
+  double *data = (double *) Malloc((size_t)datasize * sizeof (double));
 
   int nmiss;
   cdfReadRecord(streamptr1, data, &nmiss);
   cdf_write_record(streamptr2, memtype, data, nmiss);
 
-  free(data);
+  Free(data);
 }
 
 /* not used
@@ -37692,13 +38112,13 @@ int cdfDefTimeBounds(int fileID, int nctimevarid, int nctimedimid, char* taxis_n
 
   /* fprintf(stderr, "time has bounds\n"); */
 
-  if ( nc_inq_dimid(fileID, "bnds", &dims[1]) != NC_NOERR )
-    cdf_def_dim(fileID, "bnds", 2, &dims[1]);
+  if ( nc_inq_dimid(fileID, BNDS_NAME, &dims[1]) != NC_NOERR )
+    cdf_def_dim(fileID, BNDS_NAME, 2, &dims[1]);
 
   if ( taxis->climatology )
     {
-      strcpy(tmpstr, "climatology");
-      strcat(tmpstr, "_bnds");
+      strcpy(tmpstr, "climatology_");
+      strcat(tmpstr, BNDS_NAME);
       cdf_def_var(fileID, tmpstr, NC_DOUBLE, 2, dims, &time_bndsid);
 
       cdf_put_att_text(fileID, nctimevarid, "climatology", strlen(tmpstr), tmpstr);
@@ -37706,7 +38126,8 @@ int cdfDefTimeBounds(int fileID, int nctimevarid, int nctimedimid, char* taxis_n
   else
     {
       strcpy(tmpstr, taxis_name);
-      strcat(tmpstr, "_bnds");
+      strcat(tmpstr, "_");
+      strcat(tmpstr, BNDS_NAME);
       cdf_def_var(fileID, tmpstr, NC_DOUBLE, 2, dims, &time_bndsid);
 
       cdf_put_att_text(fileID, nctimevarid, "bounds", strlen(tmpstr), tmpstr);
@@ -37731,20 +38152,17 @@ void cdfDefTimeUnits(char *unitstr, taxis_t* taxis0, taxis_t* taxis)
     }
   else
     {
-      int year, month, day, hour, minute, second;
-      int rdate, rtime;
-      int timeunit;
-
-      timeunit = taxis->unit;
+      int timeunit = taxis->unit;
       if ( timeunit == -1 ) timeunit = TUNIT_HOUR;
-      rdate    = taxis->rdate;
-      rtime    = taxis->rtime;
+      int rdate    = taxis->rdate;
+      int rtime    = taxis->rtime;
       if ( rdate == -1 )
         {
           rdate  = taxis->vdate;
           rtime  = taxis->vtime;
         }
 
+      int year, month, day, hour, minute, second;
       cdiDecodeDate(rdate, &year, &month, &day);
       cdiDecodeTime(rtime, &hour, &minute, &second);
 
@@ -37754,7 +38172,7 @@ void cdfDefTimeUnits(char *unitstr, taxis_t* taxis0, taxis_t* taxis)
 	   timeunit == TUNIT_6HOURS  ||
 	   timeunit == TUNIT_12HOURS ) timeunit = TUNIT_HOUR;
 
-      sprintf(unitstr, "%s since %d-%02d-%02d %02d:%02d:%02d",
+      sprintf(unitstr, "%s since %d-%d-%d %02d:%02d:%02d",
               tunitNamePtr(timeunit), year, month, day, hour, minute, second);
     }
 }
@@ -37798,7 +38216,6 @@ void cdfDefCalendar(int fileID, int ncvarid, int calendar)
 static
 void cdfDefTime(stream_t* streamptr)
 {
-  int fileID;
   int time_varid;
   int time_dimid;
   int time_bndsid = -1;
@@ -37806,18 +38223,15 @@ void cdfDefTime(stream_t* streamptr)
   char tmpstr[CDI_MAX_NAME];
   char default_name[] = "time";
   char* taxis_name = default_name;
-  size_t len;
-  taxis_t* taxis;
 
   if ( streamptr->basetime.ncvarid != UNDEFID ) return;
 
-  fileID = streamptr->fileID;
+  int fileID = streamptr->fileID;
 
   if ( streamptr->ncmode == 0 ) streamptr->ncmode = 1;
-
   if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
 
-  taxis = &streamptr->tsteps[0].taxis;
+  taxis_t *taxis = &streamptr->tsteps[0].taxis;
 
   if ( taxis->name && taxis->name[0] ) taxis_name = taxis->name;
 
@@ -37842,7 +38256,7 @@ void cdfDefTime(stream_t* streamptr)
 
   cdfDefTimeUnits(unitstr, &streamptr->tsteps[0].taxis, taxis);
 
-  len = strlen(unitstr);
+  size_t len = strlen(unitstr);
   if ( len )
     {
       cdf_put_att_text(fileID, time_varid, "units", len, unitstr);
@@ -37881,6 +38295,8 @@ void cdfDefTime(stream_t* streamptr)
       if ( len ) cdf_put_att_text(fileID, leadtimeid, "units", len, unitstr);
     }
 
+  cdf_put_att_text(fileID, time_varid, "axis", 1, "T");
+
   if ( streamptr->ncmode == 2 ) cdf_enddef(fileID);
 }
 
@@ -38308,8 +38724,8 @@ void cdfDefXaxis(stream_t *streamptr, int gridID, int ndims)
           if ( gridInqXboundsPtr(gridID) || gridInqYboundsPtr(gridID) )
             {
               size_t nvertex = 2;
-              if ( nc_inq_dimid(fileID, "bnds", &nvdimID) != NC_NOERR )
-                cdf_def_dim(fileID, "bnds", nvertex, &nvdimID);
+              if ( nc_inq_dimid(fileID, BNDS_NAME, &nvdimID) != NC_NOERR )
+                cdf_def_dim(fileID, BNDS_NAME, nvertex, &nvdimID);
             }
         }
 
@@ -38328,7 +38744,8 @@ void cdfDefXaxis(stream_t *streamptr, int gridID, int ndims)
 
           if ( gridInqXboundsPtr(gridID) && nvdimID != UNDEFID )
             {
-              strcat(axisname, "_bnds");
+              strcat(axisname, "_");
+              strcat(axisname, BNDS_NAME);
               dimIDs[0] = dimID;
               dimIDs[1] = nvdimID;
               cdf_def_var(fileID, axisname, (nc_type) xtype, 2, dimIDs, &ncbvarid);
@@ -38438,8 +38855,8 @@ void cdfDefYaxis(stream_t *streamptr, int gridID, int ndims)
           if ( gridInqXboundsPtr(gridID) || gridInqYboundsPtr(gridID) )
             {
               size_t nvertex = 2;
-              if ( nc_inq_dimid(fileID, "bnds", &nvdimID) != NC_NOERR )
-                cdf_def_dim(fileID, "bnds", nvertex, &nvdimID);
+              if ( nc_inq_dimid(fileID, BNDS_NAME, &nvdimID) != NC_NOERR )
+                cdf_def_dim(fileID, BNDS_NAME, nvertex, &nvdimID);
             }
         }
 
@@ -38458,7 +38875,8 @@ void cdfDefYaxis(stream_t *streamptr, int gridID, int ndims)
 
           if ( gridInqYboundsPtr(gridID) && nvdimID != UNDEFID )
             {
-              strcat(axisname, "_bnds");
+              strcat(axisname, "_");
+              strcat(axisname, BNDS_NAME);
               dimIDs[0] = dimID;
               dimIDs[1] = nvdimID;
               cdf_def_var(fileID, axisname, (nc_type) xtype, 2, dimIDs, &ncbvarid);
@@ -38594,8 +39012,8 @@ void cdfDefCurvilinear(stream_t *streamptr, int gridID)
       if ( gridInqXboundsPtr(gridID) || gridInqYboundsPtr(gridID) )
         {
           size_t nvertex = 4;
-          if ( nc_inq_dimid(fileID, "vertices", &nvdimID) != NC_NOERR )
-            cdf_def_dim(fileID, "vertices", nvertex, &nvdimID);
+          if ( nc_inq_dimid(fileID, "nv4", &nvdimID) != NC_NOERR )
+            cdf_def_dim(fileID, "nv4", nvertex, &nvdimID);
         }
 
       dimIDs[0] = ydimID;
@@ -38618,7 +39036,8 @@ void cdfDefCurvilinear(stream_t *streamptr, int gridID)
 
           if ( gridInqXboundsPtr(gridID) && nvdimID != UNDEFID )
             {
-              strcat(xaxisname, "_vertices");
+              strcat(xaxisname, "_");
+              strcat(xaxisname, BNDS_NAME);
               dimIDs[0] = ydimID;
               dimIDs[1] = xdimID;
               dimIDs[2] = nvdimID;
@@ -38646,7 +39065,8 @@ void cdfDefCurvilinear(stream_t *streamptr, int gridID)
 
           if ( gridInqYboundsPtr(gridID) && nvdimID != UNDEFID )
             {
-              strcat(yaxisname, "_vertices");
+              strcat(yaxisname, "_");
+              strcat(yaxisname, BNDS_NAME);
               dimIDs[0] = ydimID;
               dimIDs[1] = xdimID;
               dimIDs[2] = nvdimID;
@@ -38659,16 +39079,16 @@ void cdfDefCurvilinear(stream_t *streamptr, int gridID)
 
       if ( gridInqAreaPtr(gridID) )
         {
-          char yaxisname[] = "cell_area";
-          char units[] = "m2";
-          char longname[] = "area of grid cell";
-          char stdname[] = "cell_area";
+          static const char yaxisname_[] = "cell_area";
+          static const char units[] = "m2";
+          static const char longname[] = "area of grid cell";
+          static const char stdname[] = "cell_area";
 
-          cdf_def_var(fileID, yaxisname, (nc_type) xtype, 2, dimIDs, &ncavarid);
+          cdf_def_var(fileID, yaxisname_, (nc_type) xtype, 2, dimIDs, &ncavarid);
 
-          cdf_put_att_text(fileID, ncavarid, "standard_name", strlen(stdname), stdname);
-          cdf_put_att_text(fileID, ncavarid, "long_name", strlen(longname), longname);
-          cdf_put_att_text(fileID, ncavarid, "units", strlen(units), units);
+          cdf_put_att_text(fileID, ncavarid, "standard_name", sizeof (stdname) - 1, stdname);
+          cdf_put_att_text(fileID, ncavarid, "long_name", sizeof (longname) - 1, longname);
+          cdf_put_att_text(fileID, ncavarid, "units", sizeof (units) - 1, units);
         }
 
       cdf_enddef(fileID);
@@ -39004,7 +39424,8 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID)
               int dimIDs[2];
               dimIDs[0] = dimID;
               dimIDs[1] = nvdimID;
-              strcat(xaxisname, "_vertices");
+              strcat(xaxisname, "_");
+              strcat(xaxisname, BNDS_NAME);
               cdf_def_var(fileID, xaxisname, (nc_type) xtype, 2, dimIDs, &ncbxvarid);
               cdfGridCompress(fileID, ncbxvarid, (int)dimlen, streamptr->filetype, streamptr->comptype);
 
@@ -39029,7 +39450,8 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID)
               int dimIDs[2];
               dimIDs[0] = dimID;
               dimIDs[1] = nvdimID;
-              strcat(yaxisname, "_vertices");
+              strcat(yaxisname, "_");
+              strcat(yaxisname, BNDS_NAME);
               cdf_def_var(fileID, yaxisname, (nc_type) xtype, 2, dimIDs, &ncbyvarid);
               cdfGridCompress(fileID, ncbyvarid, (int)dimlen, streamptr->filetype, streamptr->comptype);
 
@@ -39039,16 +39461,16 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID)
 
       if ( gridInqAreaPtr(gridID) )
         {
-          char yaxisname[] = "cell_area";
-          char units[] = "m2";
-          char longname[] = "area of grid cell";
-          char stdname[] = "cell_area";
+          static const char yaxisname_[] = "cell_area";
+          static const char units[] = "m2";
+          static const char longname[] = "area of grid cell";
+          static const char stdname[] = "cell_area";
 
-          cdf_def_var(fileID, yaxisname, (nc_type) xtype, 1, &dimID, &ncavarid);
+          cdf_def_var(fileID, yaxisname_, (nc_type) xtype, 1, &dimID, &ncavarid);
 
-          cdf_put_att_text(fileID, ncavarid, "standard_name", strlen(stdname), stdname);
-          cdf_put_att_text(fileID, ncavarid, "long_name", strlen(longname), longname);
-          cdf_put_att_text(fileID, ncavarid, "units", strlen(units), units);
+          cdf_put_att_text(fileID, ncavarid, "standard_name", sizeof (stdname) - 1, stdname);
+          cdf_put_att_text(fileID, ncavarid, "long_name", sizeof (longname) - 1, longname);
+          cdf_put_att_text(fileID, ncavarid, "units", sizeof (units) - 1, units);
         }
 
       cdf_enddef(fileID);
@@ -39067,17 +39489,13 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID)
   streamptr->ncavarID[gridindex] = ncavarid;
 }
 
-
 static
-void cdfDefVCT(stream_t *streamptr, int zaxisID)
+void cdf_def_vct_echam(stream_t *streamptr, int zaxisID)
 {
-  int type;
+  int type = zaxisInqType(zaxisID);
 
-  type = zaxisInqType(zaxisID);
   if ( type == ZAXIS_HYBRID || type == ZAXIS_HYBRID_HALF )
     {
-      int i;
-      int fileID;
       int ilev = zaxisInqVctSize(zaxisID)/2;
       int mlev = ilev - 1;
       size_t start;
@@ -39100,7 +39518,7 @@ void cdfDefVCT(stream_t *streamptr, int zaxisID)
           return;
         }
 
-      fileID = streamptr->fileID;
+      int fileID = streamptr->fileID;
 
       if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
 
@@ -39142,7 +39560,7 @@ void cdfDefVCT(stream_t *streamptr, int zaxisID)
       cdf_put_var_double(fileID, hyaiid, vctptr);
       cdf_put_var_double(fileID, hybiid, vctptr+ilev);
 
-      for ( i = 0; i < mlev; i++ )
+      for ( int i = 0; i < mlev; i++ )
         {
           start = (size_t)i;
           mval = (vctptr[i] + vctptr[i+1]) * 0.5;
@@ -39153,6 +39571,277 @@ void cdfDefVCT(stream_t *streamptr, int zaxisID)
     }
 }
 
+static
+void cdf_def_vct_cf(stream_t *streamptr, int zaxisID, int nclevID, int ncbndsID)
+{
+  int type = zaxisInqType(zaxisID);
+
+  if ( type == ZAXIS_HYBRID || type == ZAXIS_HYBRID_HALF )
+    {
+      int ilev = zaxisInqVctSize(zaxisID)/2;
+      int mlev = ilev - 1;
+      int hyaiid = 0, hybiid = 0, hyamid, hybmid;
+      char tmpname[CDI_MAX_NAME];
+
+      if ( streamptr->vct.ilev > 0 )
+        {
+          if ( streamptr->vct.ilev != ilev )
+            Error("more than one VCT for each file unsupported!");
+          return;
+        }
+
+      if ( ilev == 0 )
+        {
+          Warning("VCT missing");
+          return;
+        }
+
+      int fileID = streamptr->fileID;
+
+      if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
+
+      int dimIDs[2];
+      dimIDs[0] = nclevID;
+      dimIDs[1] = ncbndsID;
+
+      streamptr->vct.mlev   = mlev;
+      streamptr->vct.ilev   = ilev;
+      streamptr->vct.mlevID = nclevID;
+      streamptr->vct.ilevID = nclevID;
+
+      cdf_def_var(fileID, "ap", NC_DOUBLE, 1, dimIDs,  &hyamid);
+      cdf_def_var(fileID, "b",  NC_DOUBLE, 1, dimIDs,  &hybmid);
+
+      strcpy(tmpname, "vertical coordinate formula term: ap(k)");
+      cdf_put_att_text(fileID, hyamid, "long_name", strlen(tmpname), tmpname);
+      strcpy(tmpname, "Pa");
+      cdf_put_att_text(fileID, hyamid, "units", strlen(tmpname), tmpname);
+      strcpy(tmpname, "vertical coordinate formula term: b(k)");
+      cdf_put_att_text(fileID, hybmid, "long_name", strlen(tmpname), tmpname);
+      strcpy(tmpname, "1");
+      cdf_put_att_text(fileID, hybmid, "units", strlen(tmpname), tmpname);
+
+      if ( ncbndsID != -1 )
+        {
+          cdf_def_var(fileID, "ap_bnds", NC_DOUBLE, 2, dimIDs, &hyaiid);
+          cdf_def_var(fileID, "b_bnds",  NC_DOUBLE, 2, dimIDs, &hybiid);
+
+          strcpy(tmpname, "vertical coordinate formula term: ap(k+1/2)");
+          cdf_put_att_text(fileID, hyaiid, "long_name", strlen(tmpname), tmpname);
+          strcpy(tmpname, "Pa");
+          cdf_put_att_text(fileID, hyaiid, "units", strlen(tmpname), tmpname);
+          strcpy(tmpname, "vertical coordinate formula term: b(k+1/2)");
+          cdf_put_att_text(fileID, hybiid, "long_name", strlen(tmpname), tmpname);
+          strcpy(tmpname, "1");
+          cdf_put_att_text(fileID, hybiid, "units", strlen(tmpname), tmpname);
+        }
+
+      cdf_enddef(fileID);
+      streamptr->ncmode = 2;
+
+      const double *vctptr = zaxisInqVctPtr(zaxisID);
+      double tarray[ilev*2];
+
+      if ( ncbndsID != -1 )
+        {
+          for ( int i = 0; i < mlev; ++i )
+            {
+              tarray[2*i  ] = vctptr[i];
+              tarray[2*i+1] = vctptr[i+1];
+            }
+          cdf_put_var_double(fileID, hyaiid, tarray);
+
+          for ( int i = 0; i < mlev; ++i )
+            {
+              tarray[2*i  ] = vctptr[ilev+i];
+              tarray[2*i+1] = vctptr[ilev+i+1];
+            }
+          cdf_put_var_double(fileID, hybiid, tarray);
+        }
+
+      for ( int i = 0; i < mlev; ++i )
+        tarray[i] = (vctptr[i] + vctptr[i+1]) * 0.5;
+      cdf_put_var_double(fileID, hyamid, tarray);
+
+      for ( int i = 0; i < mlev; ++i )
+        tarray[i] = (vctptr[ilev+i] + vctptr[ilev+i+1]) * 0.5;
+      cdf_put_var_double(fileID, hybmid, tarray);
+    }
+}
+
+static
+void cdf_def_zaxis_hybrid_echam(stream_t *streamptr, int type, int ncvarid, int zaxisID, int zaxisindex, int xtype, size_t dimlen, int *dimID, char *axisname)
+{
+  char tmpname[CDI_MAX_NAME];
+  int fileID  = streamptr->fileID;
+
+  if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
+
+  cdf_def_dim(fileID, axisname, dimlen, dimID);
+  cdf_def_var(fileID, axisname, (nc_type) xtype, 1, dimID,  &ncvarid);
+
+  strcpy(tmpname, "hybrid_sigma_pressure");
+  cdf_put_att_text(fileID, ncvarid, "standard_name", strlen(tmpname), tmpname);
+
+  if ( type == ZAXIS_HYBRID )
+    {
+      strcpy(tmpname, "hybrid level at layer midpoints");
+      cdf_put_att_text(fileID, ncvarid, "long_name", strlen(tmpname), tmpname);
+      strcpy(tmpname, "hyam hybm (mlev=hyam+hybm*aps)");
+      cdf_put_att_text(fileID, ncvarid, "formula", strlen(tmpname), tmpname);
+      strcpy(tmpname, "ap: hyam b: hybm ps: aps");
+      cdf_put_att_text(fileID, ncvarid, "formula_terms", strlen(tmpname), tmpname);
+    }
+  else
+    {
+      strcpy(tmpname, "hybrid level at layer interfaces");
+      cdf_put_att_text(fileID, ncvarid, "long_name", strlen(tmpname), tmpname);
+      strcpy(tmpname, "hyai hybi (ilev=hyai+hybi*aps)");
+      cdf_put_att_text(fileID, ncvarid, "formula", strlen(tmpname), tmpname);
+      strcpy(tmpname, "ap: hyai b: hybi ps: aps");
+      cdf_put_att_text(fileID, ncvarid, "formula_terms", strlen(tmpname), tmpname);
+    }
+
+  strcpy(tmpname, "level");
+  cdf_put_att_text(fileID, ncvarid, "units", strlen(tmpname), tmpname);
+  strcpy(tmpname, "down");
+  cdf_put_att_text(fileID, ncvarid, "positive", strlen(tmpname), tmpname);
+
+  cdf_enddef(fileID);
+  streamptr->ncmode = 2;
+
+  cdf_put_var_double(fileID, ncvarid, zaxisInqLevelsPtr(zaxisID));
+
+  cdf_def_vct_echam(streamptr, zaxisID);
+
+  if ( *dimID == UNDEFID )
+    {
+      if ( type == ZAXIS_HYBRID )
+        streamptr->zaxisID[zaxisindex] = streamptr->vct.mlevID;
+      else
+        streamptr->zaxisID[zaxisindex] = streamptr->vct.ilevID;
+    }
+}
+
+static
+void cdf_def_zaxis_hybrid_cf(stream_t *streamptr, int type, int ncvarid, int zaxisID, int zaxisindex, int xtype, size_t dimlen, int *dimID, char *axisname)
+{
+  char psname[CDI_MAX_NAME];
+  psname[0] = 0;
+  zaxisInqPsName(zaxisID, psname);
+  if ( psname[0] == 0 ) strcpy(psname, "ps");
+
+  int fileID = streamptr->fileID;
+  if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
+
+  strcpy(axisname, "lev");
+
+  cdf_def_dim(fileID, axisname, dimlen, dimID);
+  cdf_def_var(fileID, axisname, (nc_type) xtype, 1, dimID,  &ncvarid);
+
+  char tmpname[CDI_MAX_NAME];
+  strcpy(tmpname, "atmosphere_hybrid_sigma_pressure_coordinate");
+  cdf_put_att_text(fileID, ncvarid, "standard_name", strlen(tmpname), tmpname);
+
+  strcpy(tmpname, "hybrid sigma pressure coordinate");
+  cdf_put_att_text(fileID, ncvarid, "long_name", strlen(tmpname), tmpname);
+  strcpy(tmpname, "p = ap + b*ps");
+  cdf_put_att_text(fileID, ncvarid, "formula", strlen(tmpname), tmpname);
+  strcpy(tmpname, "ap: ap b: b ps: ");
+  strcat(tmpname, psname);
+  cdf_put_att_text(fileID, ncvarid, "formula_terms", strlen(tmpname), tmpname);
+
+  strcpy(tmpname, "1");
+  cdf_put_att_text(fileID, ncvarid, "units", strlen(tmpname), tmpname);
+  strcpy(tmpname, "Z");
+  cdf_put_att_text(fileID, ncvarid, "axis", strlen(tmpname), tmpname);
+  strcpy(tmpname, "down");
+  cdf_put_att_text(fileID, ncvarid, "positive", strlen(tmpname), tmpname);
+
+  int ncbvarid = UNDEFID;
+  int nvdimID = UNDEFID;
+
+  double lbounds[dimlen], ubounds[dimlen], levels[dimlen];
+
+  zaxisInqLevels(zaxisID, levels);
+
+  if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
+    {
+      zaxisInqLbounds(zaxisID, lbounds);
+      zaxisInqUbounds(zaxisID, ubounds);
+    }
+  else
+    {
+      for ( size_t i = 0; i < dimlen; ++i ) lbounds[i] = levels[i];
+      for ( size_t i = 0; i < dimlen-1; ++i ) ubounds[i] = levels[i+1];
+      ubounds[dimlen-1] = levels[dimlen-1] + 1;
+    }
+
+  //if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
+    {
+      int dimIDs[2];
+      size_t nvertex = 2;
+      if ( nc_inq_dimid(fileID, BNDS_NAME, &nvdimID) != NC_NOERR )
+        cdf_def_dim(fileID, BNDS_NAME, nvertex, &nvdimID);
+
+      if ( nvdimID != UNDEFID )
+        {
+          strcat(axisname, "_");
+          strcat(axisname, BNDS_NAME);
+          dimIDs[0] = *dimID;
+          dimIDs[1] = nvdimID;
+          cdf_def_var(fileID, axisname, (nc_type) xtype, 2, dimIDs, &ncbvarid);
+          cdf_put_att_text(fileID, ncvarid, "bounds", strlen(axisname), axisname);
+
+          strcpy(tmpname, "atmosphere_hybrid_sigma_pressure_coordinate");
+          cdf_put_att_text(fileID, ncbvarid, "standard_name", strlen(tmpname), tmpname);
+
+          strcpy(tmpname, "p = ap + b*ps");
+          cdf_put_att_text(fileID, ncbvarid, "formula", strlen(tmpname), tmpname);
+          strcpy(tmpname, "ap: ap_bnds b: b_bnds ps: ");
+          strcat(tmpname, psname);
+          cdf_put_att_text(fileID, ncbvarid, "formula_terms", strlen(tmpname), tmpname);
+
+          strcpy(tmpname, "1");
+          cdf_put_att_text(fileID, ncbvarid, "units", strlen(tmpname), tmpname);
+        }
+    }
+
+  cdf_enddef(fileID);
+  streamptr->ncmode = 2;
+
+  cdf_put_var_double(fileID, ncvarid, levels);
+
+  if ( ncbvarid != UNDEFID )
+    {
+      double zbounds[2*dimlen];
+      for ( size_t i = 0; i < dimlen; ++i )
+        {
+          zbounds[2*i  ] = lbounds[i];
+          zbounds[2*i+1] = ubounds[i];
+        }
+      cdf_put_var_double(fileID, ncbvarid, zbounds);
+    }
+
+  cdf_def_vct_cf(streamptr, zaxisID, *dimID, nvdimID);
+
+  if ( *dimID == UNDEFID )
+    {
+      if ( type == ZAXIS_HYBRID )
+        streamptr->zaxisID[zaxisindex] = streamptr->vct.mlevID;
+      else
+        streamptr->zaxisID[zaxisindex] = streamptr->vct.ilevID;
+    }
+}
+
+static
+void cdf_def_zaxis_hybrid(stream_t *streamptr, int type, int ncvarid, int zaxisID, int zaxisindex, int xtype, size_t dimlen, int *dimID, char *axisname)
+{
+  if ( (!CDI_cmor_mode && cdiConvention == CDI_CONVENTION_ECHAM) || type == ZAXIS_HYBRID_HALF )
+    cdf_def_zaxis_hybrid_echam(streamptr, type, ncvarid, zaxisID, zaxisindex, xtype, dimlen, dimID, axisname);
+  else
+    cdf_def_zaxis_hybrid_cf(streamptr, type, ncvarid, zaxisID, zaxisindex, xtype, dimlen, dimID, axisname);
+}
 
 static
 void cdfDefZaxis(stream_t *streamptr, int zaxisID)
@@ -39167,31 +39856,40 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
   int zaxisID0;
   int dimID = UNDEFID;
   int dimIDs[2];
-  int fileID;
   size_t len;
   int ncvarid = UNDEFID, ncbvarid = UNDEFID;
   int nvdimID = UNDEFID;
-  int type;
-  int nzaxis;
   int ilevel = 0;
-  int vlistID;
-  int zaxisindex;
   int xtype = NC_DOUBLE;
   int positive;
 
   if ( zaxisInqPrec(zaxisID) == DATATYPE_FLT32 ) xtype = NC_FLOAT;
 
-  vlistID = streamptr->vlistID;
-  fileID  = streamptr->fileID;
+  int vlistID = streamptr->vlistID;
+  int fileID  = streamptr->fileID;
 
-  zaxisindex = vlistZaxisIndex(vlistID, zaxisID);
+  int zaxisindex = vlistZaxisIndex(vlistID, zaxisID);
 
-  nzaxis = vlistNzaxis(vlistID);
+  int nzaxis = vlistNzaxis(vlistID);
 
   size_t dimlen = (size_t)zaxisInqSize(zaxisID);
-  type   = zaxisInqType(zaxisID);
+  int type   = zaxisInqType(zaxisID);
 
-  if (dimlen == 1)
+  int is_scalar = FALSE;
+  if ( dimlen == 1 )
+    {
+      is_scalar = zaxisInqScalar(zaxisID);
+      if ( !is_scalar && CDI_cmor_mode )
+        {
+          is_scalar = TRUE;
+          zaxisDefScalar(zaxisID);
+        }
+    }
+
+  int ndims = 1;
+  if ( is_scalar ) ndims = 0;
+
+  if ( dimlen == 1 )
     switch (type)
       {
       case ZAXIS_SURFACE:
@@ -39243,7 +39941,7 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
             {
               if ( ilevel )
                 {
-                  /* check that the name does not exist for other grids */
+                  /* check that the name does not exist for other zaxes */
                   for ( index = 0; index < nzaxis; index++ )
                     {
                       zaxisID0 = vlistZaxis(vlistID, index);
@@ -39273,82 +39971,19 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
 
       if ( type == ZAXIS_HYBRID || type == ZAXIS_HYBRID_HALF )
         {
-          if ( type == ZAXIS_HYBRID )
-            {
-	      if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
-
-	      cdf_def_dim(fileID, axisname, dimlen, &dimID);
-	      cdf_def_var(fileID, axisname, (nc_type) xtype, 1, &dimID,  &ncvarid);
-
-	      strcpy(tmpname, "hybrid_sigma_pressure");
-	      cdf_put_att_text(fileID, ncvarid, "standard_name", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "hybrid level at layer midpoints");
-	      cdf_put_att_text(fileID, ncvarid, "long_name", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "level");
-	      cdf_put_att_text(fileID, ncvarid, "units", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "down");
-	      cdf_put_att_text(fileID, ncvarid, "positive", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "hyam hybm (mlev=hyam+hybm*aps)");
-	      cdf_put_att_text(fileID, ncvarid, "formula", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "ap: hyam b: hybm ps: aps");
-	      cdf_put_att_text(fileID, ncvarid, "formula_terms", strlen(tmpname), tmpname);
-	      /*
-	      strcpy(tmpname, "ilev");
-	      cdf_put_att_text(fileID, ncvarid, "borders", strlen(tmpname), tmpname);
-	      */
-	      cdf_enddef(fileID);
-	      streamptr->ncmode = 2;
-
-	      cdf_put_var_double(fileID, ncvarid, zaxisInqLevelsPtr(zaxisID));
-            }
-
-          if ( type == ZAXIS_HYBRID_HALF )
-            {
-	      if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
-
-	      cdf_def_dim(fileID, axisname, dimlen, &dimID);
-	      cdf_def_var(fileID, axisname, (nc_type) xtype, 1, &dimID,  &ncvarid);
-
-	      strcpy(tmpname, "hybrid_sigma_pressure");
-	      cdf_put_att_text(fileID, ncvarid, "standard_name", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "hybrid level at layer interfaces");
-	      cdf_put_att_text(fileID, ncvarid, "long_name", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "level");
-	      cdf_put_att_text(fileID, ncvarid, "units", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "down");
-	      cdf_put_att_text(fileID, ncvarid, "positive", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "hyai hybi (ilev=hyai+hybi*aps)");
-	      cdf_put_att_text(fileID, ncvarid, "formula", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "ap: hyai b: hybi ps: aps");
-	      cdf_put_att_text(fileID, ncvarid, "formula_terms", strlen(tmpname), tmpname);
-
-	      cdf_enddef(fileID);
-	      streamptr->ncmode = 2;
-
-	      cdf_put_var_double(fileID, ncvarid, zaxisInqLevelsPtr(zaxisID));
-            }
-
-          cdfDefVCT(streamptr, zaxisID);
-
-          if ( dimID == UNDEFID )
-            {
-              if ( type == ZAXIS_HYBRID )
-                streamptr->zaxisID[zaxisindex] = streamptr->vct.mlevID;
-              else
-                streamptr->zaxisID[zaxisindex] = streamptr->vct.ilevID;
-            }
+          cdf_def_zaxis_hybrid(streamptr, type, ncvarid, zaxisID, zaxisindex, xtype, dimlen, &dimID, axisname);
         }
       else
         {
           if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
 
-          cdf_def_dim(fileID, axisname, dimlen, &dimID);
+          if ( ndims ) cdf_def_dim(fileID, axisname, dimlen, &dimID);
 
           zaxisInqLongname(zaxisID, longname);
           zaxisInqUnits(zaxisID, units);
           zaxisInqStdname(zaxisID, stdname);
 
-          cdf_def_var(fileID, axisname, (nc_type) xtype, 1, &dimID, &ncvarid);
+          cdf_def_var(fileID, axisname, (nc_type) xtype, ndims, &dimID, &ncvarid);
 
           if ( (len = strlen(stdname)) )
             cdf_put_att_text(fileID, ncvarid, "standard_name", len, stdname);
@@ -39374,15 +40009,16 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
 	  if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
             {
               size_t nvertex = 2;
-	      if ( nc_inq_dimid(fileID, "bnds", &nvdimID) != NC_NOERR )
-		cdf_def_dim(fileID, "bnds", nvertex, &nvdimID);
+	      if ( nc_inq_dimid(fileID, BNDS_NAME, &nvdimID) != NC_NOERR )
+		cdf_def_dim(fileID, BNDS_NAME, nvertex, &nvdimID);
 
 	      if ( nvdimID != UNDEFID )
 		{
-		  strcat(axisname, "_bnds");
-		  dimIDs[0] = dimID;
-		  dimIDs[1] = nvdimID;
-		  cdf_def_var(fileID, axisname, (nc_type) xtype, 2, dimIDs, &ncbvarid);
+		  strcat(axisname, "_");
+		  strcat(axisname, BNDS_NAME);
+		  if ( ndims ) dimIDs[0] = dimID;
+		  dimIDs[ndims] = nvdimID;
+		  cdf_def_var(fileID, axisname, (nc_type) xtype, ndims+1, dimIDs, &ncbvarid);
 		  cdf_put_att_text(fileID, ncvarid, "bounds", strlen(axisname), axisname);
 		}
 	    }
@@ -39394,27 +40030,19 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
 
           if ( ncbvarid != UNDEFID )
 	    {
-	      double *zbounds, *lbounds, *ubounds;
-
-	      lbounds = (double *) malloc(dimlen*sizeof(double));
-	      ubounds = (double *) malloc(dimlen*sizeof(double));
-	      zbounds = (double *) malloc(2*dimlen*sizeof(double));
-
+              double lbounds[dimlen], ubounds[dimlen], zbounds[2*dimlen];
 	      zaxisInqLbounds(zaxisID, lbounds);
 	      zaxisInqUbounds(zaxisID, ubounds);
-
-	      for (size_t i = 0; i < dimlen; ++i )
+	      for ( size_t i = 0; i < dimlen; ++i )
 		{
 		  zbounds[2*i  ] = lbounds[i];
 		  zbounds[2*i+1] = ubounds[i];
 		}
 
 	      cdf_put_var_double(fileID, ncbvarid, zbounds);
-
-	      free(zbounds);
-	      free(ubounds);
-	      free(lbounds);
 	    }
+
+          if ( ndims == 0 ) streamptr->nczvarID[zaxisindex] = ncvarid;
         }
     }
 
@@ -39422,27 +40050,23 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
     streamptr->zaxisID[zaxisindex] = dimID;
 }
 
-
 static
 void cdfDefPole(stream_t *streamptr, int gridID)
 {
-  int fileID;
   int ncvarid = UNDEFID;
-  int ncerr;
-  double xpole, ypole, angle;
   char varname[] = "rotated_pole";
   char mapname[] = "rotated_latitude_longitude";
 
-  fileID  = streamptr->fileID;
+  int fileID  = streamptr->fileID;
 
-  ypole = gridInqYpole(gridID);
-  xpole = gridInqXpole(gridID);
-  angle = gridInqAngle(gridID);
+  double ypole = gridInqYpole(gridID);
+  double xpole = gridInqXpole(gridID);
+  double angle = gridInqAngle(gridID);
 
   cdf_redef(fileID);
 
-  ncerr = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
-  if ( ncerr == NC_NOERR )
+  int ncerrcode = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
+  if ( ncerrcode == NC_NOERR )
     {
       cdf_put_att_text(fileID, ncvarid, "grid_mapping_name", strlen(mapname), mapname);
       cdf_put_att_double(fileID, ncvarid, "grid_north_pole_latitude", NC_DOUBLE, 1, &ypole);
@@ -39458,21 +40082,18 @@ void cdfDefPole(stream_t *streamptr, int gridID)
 static
 void cdfDefMapping(stream_t *streamptr, int gridID)
 {
-  int fileID;
   int ncvarid = UNDEFID;
-  int ncerr;
+  int fileID  = streamptr->fileID;
 
   if ( gridInqType(gridID) == GRID_SINUSOIDAL )
     {
       char varname[] = "sinusoidal";
       char mapname[] = "sinusoidal";
 
-      fileID  = streamptr->fileID;
-
       cdf_redef(fileID);
 
-      ncerr = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
-      if ( ncerr == NC_NOERR )
+      int ncerrcode = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
+      if ( ncerrcode == NC_NOERR )
         {
           cdf_put_att_text(fileID, ncvarid, "grid_mapping_name", strlen(mapname), mapname);
           /*
@@ -39488,12 +40109,10 @@ void cdfDefMapping(stream_t *streamptr, int gridID)
       char varname[] = "laea";
       char mapname[] = "lambert_azimuthal_equal_area";
 
-      fileID  = streamptr->fileID;
-
       cdf_redef(fileID);
 
-      ncerr = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
-      if ( ncerr == NC_NOERR )
+      int ncerrcode = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
+      if ( ncerrcode == NC_NOERR )
         {
           double a, lon_0, lat_0;
 
@@ -39512,12 +40131,10 @@ void cdfDefMapping(stream_t *streamptr, int gridID)
       char varname[] = "Lambert_Conformal";
       char mapname[] = "lambert_conformal_conic";
 
-      fileID  = streamptr->fileID;
-
       cdf_redef(fileID);
 
-      ncerr = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
-      if ( ncerr == NC_NOERR )
+      int ncerrcode = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
+      if ( ncerrcode == NC_NOERR )
         {
           double radius, lon_0, lat_0, lat_1, lat_2;
 
@@ -39547,16 +40164,12 @@ void cdfDefMapping(stream_t *streamptr, int gridID)
 static
 void cdfDefGrid(stream_t *streamptr, int gridID)
 {
-  int gridtype, size;
-  int gridindex;
-  int vlistID;
-
-  vlistID = streamptr->vlistID;
-  gridindex = vlistGridIndex(vlistID, gridID);
+  int vlistID = streamptr->vlistID;
+  int gridindex = vlistGridIndex(vlistID, gridID);
   if ( streamptr->xdimID[gridindex] != UNDEFID ) return;
 
-  gridtype = gridInqType(gridID);
-  size     = gridInqSize(gridID);
+  int gridtype = gridInqType(gridID);
+  int size     = gridInqSize(gridID);
 
   if ( CDI_Debug )
     Message("gridtype = %d  size = %d", gridtype, size);
@@ -39647,63 +40260,49 @@ void cdfDefGrid(stream_t *streamptr, int gridID)
     }
 }
 
-
 static
 int cdfDefVar(stream_t *streamptr, int varID)
 {
   int ncvarid = -1;
-  int fileID;
-  int xid = UNDEFID, yid = UNDEFID, zid = UNDEFID, tid = UNDEFID;
+  int xid = UNDEFID, yid = UNDEFID;
   size_t xsize = 0, ysize = 0;
-  int code, param, gridID, zaxisID;
-  int pnum, pcat, pdis;
   char varname[CDI_MAX_NAME];
-  const char *name = NULL;
-  const char *longname = NULL;
-  const char *stdname = NULL;
-  const char *units = NULL;
   int dims[4];
   int lchunk = FALSE;
-  int chunktype;
   size_t chunks[4] = {0,0,0,0};
-  int tableID;
   int ndims = 0;
-  int tsteptype;
-  int xtype, dtype;
-  int gridtype, gridsize;
-  int gridindex, zaxisindex;
   int tablenum;
-  int vlistID;
   int dimorder[3];
   size_t iax = 0;
   char axis[5];
   int ensID, ensCount, forecast_type;
   int retval;
 
-  fileID  = streamptr->fileID;
+  int fileID  = streamptr->fileID;
 
   if ( CDI_Debug )
     Message("streamID = %d, fileID = %d, varID = %d", streamptr->self, fileID, varID);
 
   if ( streamptr->vars[varID].ncvarid != UNDEFID )
-    return (streamptr->vars[varID].ncvarid);
+    return streamptr->vars[varID].ncvarid;
 
-  vlistID   = streamptr->vlistID;
-  gridID    = vlistInqVarGrid(vlistID, varID);
-  zaxisID   = vlistInqVarZaxis(vlistID, varID);
-  tsteptype = vlistInqVarTsteptype(vlistID, varID);
-  code      = vlistInqVarCode(vlistID, varID);
-  param     = vlistInqVarParam(vlistID, varID);
+  int vlistID   = streamptr->vlistID;
+  int gridID    = vlistInqVarGrid(vlistID, varID);
+  int zaxisID   = vlistInqVarZaxis(vlistID, varID);
+  int tsteptype = vlistInqVarTsteptype(vlistID, varID);
+  int code      = vlistInqVarCode(vlistID, varID);
+  int param     = vlistInqVarParam(vlistID, varID);
+  int pnum, pcat, pdis;
   cdiDecodeParam(param, &pnum, &pcat, &pdis);
 
-  chunktype = vlistInqVarChunkType(vlistID, varID);
+  int chunktype = vlistInqVarChunkType(vlistID, varID);
 
   vlistInqVarDimorder(vlistID, varID, &dimorder);
 
-  gridsize  = gridInqSize(gridID);
+  int gridsize  = gridInqSize(gridID);
   if ( gridsize > 1 ) lchunk = TRUE;
-  gridtype  = gridInqType(gridID);
-  gridindex = vlistGridIndex(vlistID, gridID);
+  int gridtype  = gridInqType(gridID);
+  int gridindex = vlistGridIndex(vlistID, gridID);
   if ( gridtype != GRID_TRAJECTORY )
     {
       xid = streamptr->xdimID[gridindex];
@@ -39712,8 +40311,10 @@ int cdfDefVar(stream_t *streamptr, int varID)
       if ( yid != UNDEFID ) cdf_inq_dimlen(fileID, yid, &ysize);
     }
 
-  zaxisindex = vlistZaxisIndex(vlistID, zaxisID);
-  zid = streamptr->zaxisID[zaxisindex];
+  int zaxisindex = vlistZaxisIndex(vlistID, zaxisID);
+  int zid = streamptr->zaxisID[zaxisindex];
+  int zaxis_is_scalar = FALSE;
+  if ( zid == UNDEFID ) zaxis_is_scalar = zaxisInqScalar(zaxisID);
 
   if ( dimorder[0] != 3 ) lchunk = FALSE; /* ZYX and ZXY */
 
@@ -39723,7 +40324,7 @@ int cdfDefVar(stream_t *streamptr, int varID)
       Error("Internal problem, dimension order missing!");
     }
 
-  tid = streamptr->basetime.ncdimid;
+  int tid = streamptr->basetime.ncdimid;
 
   if ( tsteptype != TSTEP_CONSTANT )
     {
@@ -39772,12 +40373,12 @@ int cdfDefVar(stream_t *streamptr, int varID)
   if ( CDI_Debug )
     fprintf(stderr, "chunktype %d  chunks %d %d %d %d\n", chunktype, (int)chunks[0], (int)chunks[1], (int)chunks[2], (int)chunks[3]);
 
-  tableID  = vlistInqVarTable(vlistID, varID);
+  int tableID  = vlistInqVarTable(vlistID, varID);
 
-  name     = vlistInqVarNamePtr(vlistID, varID);
-  longname = vlistInqVarLongnamePtr(vlistID, varID);
-  stdname  = vlistInqVarStdnamePtr(vlistID, varID);
-  units    = vlistInqVarUnitsPtr(vlistID, varID);
+  const char *name     = vlistInqVarNamePtr(vlistID, varID);
+  const char *longname = vlistInqVarLongnamePtr(vlistID, varID);
+  const char *stdname  = vlistInqVarStdnamePtr(vlistID, varID);
+  const char *units    = vlistInqVarUnitsPtr(vlistID, varID);
 
   if ( name     == NULL )     name = tableInqParNamePtr(tableID, code);
   if ( longname == NULL ) longname = tableInqParLongnamePtr(tableID, code);
@@ -39820,11 +40421,6 @@ int cdfDefVar(stream_t *streamptr, int varID)
     }
   else
     {
-      int checkname;
-      int iz;
-      int status;
-      char *varname2;
-
       if ( code < 0 ) code = -code;
       if ( pnum < 0 ) pnum = -pnum;
 
@@ -39833,16 +40429,16 @@ int cdfDefVar(stream_t *streamptr, int varID)
       else
 	sprintf(varname, "param%d.%d.%d", pnum, pcat, pdis);
 
-      varname2 = varname+strlen(varname);
+      char *varname2 = varname+strlen(varname);
 
-      checkname = TRUE;
-      iz = 0;
+      int checkname = TRUE;
+      int iz = 0;
 
       while ( checkname )
         {
           if ( iz ) sprintf(varname2, "_%d", iz+1);
 
-          status = nc_inq_varid(fileID, varname, &ncvarid);
+          int status = nc_inq_varid(fileID, varname, &ncvarid);
           if ( status != NC_NOERR ) checkname = FALSE;
 
           if ( checkname ) iz++;
@@ -39857,8 +40453,8 @@ int cdfDefVar(stream_t *streamptr, int varID)
 
   /* if ( streamptr->ncmode == 2 ) cdf_redef(fileID); */
 
-  dtype = vlistInqVarDatatype(vlistID, varID);
-  xtype = cdfDefDatatype(dtype, streamptr->filetype);
+  int dtype = vlistInqVarDatatype(vlistID, varID);
+  int xtype = cdfDefDatatype(dtype, streamptr->filetype);
 
   cdf_def_var(fileID, name, (nc_type) xtype, ndims, dims, &ncvarid);
 
@@ -39949,6 +40545,20 @@ int cdfDefVar(stream_t *streamptr, int varID)
         cdf_put_att_int(fileID, ncvarid, "table", NC_INT, 1, &tablenum);
     }
 
+  char coordinates[CDI_MAX_NAME];
+  coordinates[0] = 0;
+
+  if ( zaxis_is_scalar )
+    {
+      int nczvarID = streamptr->nczvarID[zaxisindex];
+      if ( nczvarID != CDI_UNDEFID )
+        {
+          size_t len = strlen(coordinates);
+          if ( len ) coordinates[len++] = ' ';
+          cdf_inq_varname(fileID, nczvarID, coordinates+len);
+        }
+    }
+
   if ( gridtype != GRID_GENERIC && gridtype != GRID_LONLAT  && gridtype != GRID_CURVILINEAR )
     {
       size_t len = strlen(gridNamePtr(gridtype));
@@ -39983,53 +40593,43 @@ int cdfDefVar(stream_t *streamptr, int varID)
     }
   else if ( gridtype == GRID_LONLAT && xid == UNDEFID && yid == UNDEFID && gridsize == 1 )
     {
-      char coordinates[CDI_MAX_NAME] = "";
-      int ncxvarID, ncyvarID;
-      int gridindex;
-      size_t len;
-
-      gridindex = vlistGridIndex(vlistID, gridID);
-      ncxvarID = streamptr->ncxvarID[gridindex];
-      ncyvarID = streamptr->ncyvarID[gridindex];
-      if ( ncxvarID != CDI_UNDEFID )
-        cdf_inq_varname(fileID, ncxvarID, coordinates);
-      len = strlen(coordinates);
+      int ncxvarID = streamptr->ncxvarID[gridindex];
+      int ncyvarID = streamptr->ncyvarID[gridindex];
       if ( ncyvarID != CDI_UNDEFID )
         {
+          size_t len = strlen(coordinates);
           if ( len ) coordinates[len++] = ' ';
           cdf_inq_varname(fileID, ncyvarID, coordinates+len);
         }
-      len = strlen(coordinates);
-      if ( len )
-        cdf_put_att_text(fileID, ncvarid, "coordinates", len, coordinates);
+      if ( ncxvarID != CDI_UNDEFID )
+        {
+          size_t len = strlen(coordinates);
+          if ( len ) coordinates[len++] = ' ';
+          cdf_inq_varname(fileID, ncxvarID, coordinates+len);
+        }
     }
   else if ( gridtype == GRID_UNSTRUCTURED || gridtype == GRID_CURVILINEAR )
     {
-      char coordinates[CDI_MAX_NAME] = "";
       char cellarea[CDI_MAX_NAME] = "area: ";
-      int ncxvarID, ncyvarID, ncavarID;
-      int gridindex;
-      size_t len;
-
-      gridindex = vlistGridIndex(vlistID, gridID);
-      ncxvarID = streamptr->ncxvarID[gridindex];
-      ncyvarID = streamptr->ncyvarID[gridindex];
-      ncavarID = streamptr->ncavarID[gridindex];
-      if ( ncxvarID != CDI_UNDEFID )
-        cdf_inq_varname(fileID, ncxvarID, coordinates);
-      len = strlen(coordinates);
+      int ncxvarID = streamptr->ncxvarID[gridindex];
+      int ncyvarID = streamptr->ncyvarID[gridindex];
+      int ncavarID = streamptr->ncavarID[gridindex];
       if ( ncyvarID != CDI_UNDEFID )
         {
+          size_t len = strlen(coordinates);
           if ( len ) coordinates[len++] = ' ';
           cdf_inq_varname(fileID, ncyvarID, coordinates+len);
         }
-      len = strlen(coordinates);
-      if ( len )
-        cdf_put_att_text(fileID, ncvarid, "coordinates", len, coordinates);
+      if ( ncxvarID != CDI_UNDEFID )
+        {
+          size_t len = strlen(coordinates);
+          if ( len ) coordinates[len++] = ' ';
+          cdf_inq_varname(fileID, ncxvarID, coordinates+len);
+        }
 
       if ( ncavarID != CDI_UNDEFID )
         {
-          len = strlen(cellarea);
+          size_t len = strlen(cellarea);
           cdf_inq_varname(fileID, ncavarID, cellarea+len);
           len = strlen(cellarea);
           cdf_put_att_text(fileID, ncvarid, "cell_measures", len, cellarea);
@@ -40045,13 +40645,15 @@ int cdfDefVar(stream_t *streamptr, int varID)
   else if ( gridtype == GRID_SPECTRAL || gridtype == GRID_FOURIER )
     {
       int gridTruncation = gridInqTrunc(gridID);
-
       axis[iax++] = '-';
       axis[iax++] = '-';
       cdf_put_att_text(fileID, ncvarid, "axis", iax, axis);
       cdf_put_att_int(fileID, ncvarid, "truncation", NC_INT, 1, &gridTruncation);
     }
 
+  size_t len = strlen(coordinates);
+  if ( len ) cdf_put_att_text(fileID, ncvarid, "coordinates", len, coordinates);
+
   /*  if ( xtype == NC_BYTE || xtype == NC_SHORT || xtype == NC_INT ) */
     {
       int laddoffset, lscalefactor;
@@ -40132,7 +40734,7 @@ int cdfDefVar(stream_t *streamptr, int varID)
 
   /* if ( streamptr->ncmode == 2 ) cdf_enddef(fileID); */
 
-  return (ncvarid);
+  return ncvarid;
 }
 
 static
@@ -40405,7 +41007,6 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
   const float *pdata_sp = (const float *) data;
   float *mdata_sp = NULL;
   float *sdata_sp = NULL;
-  extern int CDF_Debug;
 
   /*  if ( dtype == DATATYPE_INT8 || dtype == DATATYPE_INT16 || dtype == DATATYPE_INT32 ) */
     {
@@ -40424,7 +41025,7 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
         {
           if ( memtype == MEMTYPE_FLOAT )
             {
-              mdata_sp = (float *) malloc((size_t)nvals*sizeof(float));
+              mdata_sp = (float *) Malloc((size_t)nvals*sizeof(float));
               memcpy(mdata_sp, pdata_sp, (size_t)nvals * sizeof (float));
               pdata_sp = mdata_sp;
 
@@ -40454,7 +41055,7 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
             }
           else
             {
-              mdata_dp = (double *) malloc((size_t)nvals * sizeof(double));
+              mdata_dp = (double *) Malloc((size_t)nvals * sizeof(double));
               memcpy(mdata_dp, pdata_dp, (size_t)nvals * sizeof(double));
               pdata_dp = mdata_dp;
 
@@ -40487,7 +41088,7 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
             {
               if ( mdata_sp == NULL )
                 {
-                  mdata_sp = (float *) malloc((size_t)nvals * sizeof(float));
+                  mdata_sp = (float *) Malloc((size_t)nvals * sizeof(float));
                   memcpy(mdata_sp, pdata_sp, (size_t)nvals * sizeof(float));
                   pdata_sp = mdata_sp;
                 }
@@ -40509,7 +41110,7 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
             {
               if ( mdata_dp == NULL )
                 {
-                  mdata_dp = (double *) malloc((size_t)nvals * sizeof (double));
+                  mdata_dp = (double *) Malloc((size_t)nvals * sizeof (double));
                   memcpy(mdata_dp, pdata_dp, (size_t)nvals * sizeof (double));
                   pdata_dp = mdata_dp;
                 }
@@ -40553,7 +41154,7 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
         {
           /* malloc and the loop imply nvals >= ysize * xsize,
            * but that is not checked and the types don't match */
-          sdata_sp = (float *)xmalloc((size_t)nvals * sizeof (float));
+          sdata_sp = (float *) Malloc((size_t)nvals * sizeof (float));
           for ( size_t j = 0; j < ysize; ++j )
             for ( size_t i = 0; i < xsize; ++i )
               sdata_sp[i*ysize+j] = pdata_sp[j*xsize+i];
@@ -40561,7 +41162,7 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
         }
       else
         {
-          sdata_dp = (double *)xmalloc((size_t)nvals * sizeof (double));
+          sdata_dp = (double *) Malloc((size_t)nvals * sizeof (double));
           for ( size_t j = 0; j < ysize; ++j )
             for ( size_t i = 0; i < xsize; ++i )
               sdata_dp[i*ysize+j] = pdata_dp[j*xsize+i];
@@ -40574,10 +41175,10 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
   else
     cdf_put_vara_double(fileID, ncvarid, start, count, pdata_dp);
 
-  if ( mdata_dp ) free(mdata_dp);
-  if ( sdata_dp ) free(sdata_dp);
-  if ( mdata_sp ) free(mdata_sp);
-  if ( sdata_sp ) free(sdata_sp);
+  if ( mdata_dp ) Free(mdata_dp);
+  if ( sdata_dp ) Free(sdata_dp);
+  if ( mdata_sp ) Free(mdata_sp);
+  if ( sdata_sp ) Free(sdata_sp);
 }
 
 
@@ -40801,14 +41402,36 @@ void transpose2dArrayDP(size_t inWidth, size_t inHeight, double* data)
 {
   const size_t cacheBlockSize = 256;    // Purely an optimization parameter. Current value of 32 means we are handling 8kB blocks,
                                        // which should be a decent compromise on many architectures.
-  double (*temp)[inWidth] = malloc(inHeight*sizeof(*temp));
+  
+#ifdef __cplusplus
+  double *temp[inHeight];
+  double *out[inWidth];
+  
+  temp[0] =  (double *) Malloc(inHeight * inWidth * sizeof(double));
+  out[0] = data;
+  
+  for(int i = 0; i < inWidth; i++)
+  {
+    out[i] = out[0] + (inHeight * i);
+  }
+
+  for(int i = 1; i < inHeight; i++)
+  {
+    temp[i] = temp[0] + (inWidth * i);
+  }
+  memcpy(temp[0], data, inHeight * inWidth * sizeof(double));
+#else
+  double (*temp)[inWidth] = (double (*)[inWidth]) Malloc(inHeight*sizeof(*temp));
   double (*out)[inHeight] = (double (*)[inHeight])data;
   memcpy(temp, data, inHeight*sizeof(*temp));
+#endif
+  
   /*
   for ( size_t y = 0; y < inHeight; ++y )
     for ( size_t x = 0; x < inWidth; ++x )
       out[x][y] = temp[y][x];
   */
+
   for ( size_t yBlock = 0; yBlock < inHeight; yBlock += cacheBlockSize )
     {
       for ( size_t xBlock = 0; xBlock < inWidth; xBlock += cacheBlockSize )
@@ -40823,7 +41446,7 @@ void transpose2dArrayDP(size_t inWidth, size_t inHeight, double* data)
         }
     }
 
-  free(temp);
+  Free(temp[0]);
 }
 
 static
@@ -40831,14 +41454,28 @@ void transpose2dArraySP(size_t inWidth, size_t inHeight, float* data)
 {
   const size_t cacheBlockSize = 256;    // Purely an optimization parameter. Current value of 32 means we are handling 8kB blocks,
                                        // which should be a decent compromise on many architectures.
-  float (*temp)[inWidth] = malloc(inHeight*sizeof(*temp));
+  
+#ifndef __cplusplus 
+  float (*temp)[inWidth] = (float (*)[inWidth]) Malloc(inHeight*sizeof(*temp));
   float (*out)[inHeight] = (float (*)[inHeight])data;
   memcpy(temp, data, inHeight*sizeof(*temp));
+  #else
+  float *temp[inWidth];
+  temp[0] =  (float *) Malloc(inWidth * inHeight * sizeof(float));
+  for(int i = 1; i < inHeight; i++)
+  {
+    temp[i] = temp[0] + (inWidth * i);
+  }
+
+  float **out = (float **)data;
+#endif
+  
   /*
   for ( size_t y = 0; y < inHeight; ++y )
     for ( size_t x = 0; x < inWidth; ++x )
       out[x][y] = temp[y][x];
   */
+  
   for ( size_t yBlock = 0; yBlock < inHeight; yBlock += cacheBlockSize )
     {
       for ( size_t xBlock = 0; xBlock < inWidth; xBlock += cacheBlockSize )
@@ -40853,7 +41490,7 @@ void transpose2dArraySP(size_t inWidth, size_t inHeight, float* data)
         }
     }
 
-  free(temp);
+  Free(temp);
 }
 
 static
@@ -40988,6 +41625,7 @@ void cdfGetSliceSlapDescription(stream_t *streamptr, int varId, int levelId, boo
     Error("Internal error, variable %s has an unsupported array structure!", vlistInqVarNamePtr(vlistId, varId));
 }
 
+
 void cdfReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
 {
   if ( CDI_Debug ) Message("streamID = %d  varID = %d", streamptr->self, varID);
@@ -41019,6 +41657,7 @@ void cdfReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
   *nmiss = (int)nmiss_;
 }
 
+
 void cdfReadVarSP(stream_t *streamptr, int varID, float *data, int *nmiss)
 {
   if ( CDI_Debug ) Message("streamID = %d  varID = %d", streamptr->self, varID);
@@ -41050,6 +41689,7 @@ void cdfReadVarSP(stream_t *streamptr, int varID, float *data, int *nmiss)
   *nmiss = (int)nmiss_;
 }
 
+
 void cdfReadVarSliceDP(stream_t *streamptr, int varID, int levelID, double *data, int *nmiss)
 {
   size_t start[4];
@@ -41072,11 +41712,11 @@ void cdfReadVarSliceDP(stream_t *streamptr, int varID, int levelID, double *data
 
   if ( vlistInqVarDatatype(vlistID, varID) == DATATYPE_FLT32 )
     {
-      float *data_fp = (float *)xmalloc(gridsize*sizeof(*data_fp));
+      float *data_fp = (float *) Malloc(gridsize*sizeof(*data_fp));
       cdf_get_vara_float(fileID, ncvarid, start, count, data_fp);
       for ( size_t i = 0; i < gridsize; i++ )
         data[i] = (double) data_fp[i];
-      free(data_fp);
+      Free(data_fp);
     }
   else if ( vlistInqVarDatatype(vlistID, varID) == DATATYPE_UINT8 )
     {
@@ -41130,11 +41770,11 @@ void cdfReadVarSliceSP(stream_t *streamptr, int varID, int levelID, float *data,
 
   if ( vlistInqVarDatatype(vlistID, varID) == DATATYPE_FLT64 )
     {
-      double *data_dp = (double *)xmalloc(gridsize*sizeof(*data_dp));
+      double *data_dp = (double *) Malloc(gridsize*sizeof(*data_dp));
       cdf_get_vara_double(fileID, ncvarid, start, count, data_dp);
       for ( size_t i = 0; i < gridsize; i++ )
         data[i] = (float) data_dp[i];
-      free(data_dp);
+      Free(data_dp);
     }
   else if ( vlistInqVarDatatype(vlistID, varID) == DATATYPE_UINT8 )
     {
@@ -41286,12 +41926,12 @@ void cdfCreateRecords(stream_t *streamptr, int tsID)
 
       streamptr->nrecs += nrecs;
 
-      destTstep->records    = (record_t *)xmalloc((size_t)nrecs*sizeof(record_t));
+      destTstep->records    = (record_t *) Malloc((size_t)nrecs*sizeof(record_t));
       destTstep->nrecs      = nrecs;
       destTstep->nallrecs   = nrecs;
       destTstep->recordSize = nrecs;
       destTstep->curRecID   = UNDEFID;
-      destTstep->recIDs     = (int *)xmalloc((size_t)nvrecs*sizeof (int));;
+      destTstep->recIDs     = (int *) Malloc((size_t)nvrecs*sizeof (int));;
       for ( recID = 0; recID < nvrecs; recID++ ) destTstep->recIDs[recID] = recID;
 
       record_t *records = destTstep->records;
@@ -41324,7 +41964,7 @@ void cdfCreateRecords(stream_t *streamptr, int tsID)
 
       streamptr->nrecs += nvrecs;
 
-      destTstep->records    = (record_t *) xmalloc((size_t)nrecs*sizeof(record_t));
+      destTstep->records    = (record_t *) Malloc((size_t)nrecs*sizeof(record_t));
       destTstep->nrecs      = nvrecs;
       destTstep->nallrecs   = nrecs;
       destTstep->recordSize = nrecs;
@@ -41334,7 +41974,7 @@ void cdfCreateRecords(stream_t *streamptr, int tsID)
 
       if ( nvrecs )
         {
-          destTstep->recIDs = (int *) xmalloc((size_t)nvrecs * sizeof (int));
+          destTstep->recIDs = (int *) Malloc((size_t)nvrecs * sizeof (int));
           vrecID = 0;
           for ( recID = 0; recID < nrecs; recID++ )
             {
@@ -41354,7 +41994,7 @@ void cdfCreateRecords(stream_t *streamptr, int tsID)
 
       streamptr->nrecs += nvrecs;
 
-      destTstep->records    = (record_t *) xmalloc((size_t)nrecs*sizeof(record_t));
+      destTstep->records    = (record_t *) Malloc((size_t)nrecs*sizeof(record_t));
       destTstep->nrecs      = nvrecs;
       destTstep->nallrecs   = nrecs;
       destTstep->recordSize = nrecs;
@@ -41362,7 +42002,7 @@ void cdfCreateRecords(stream_t *streamptr, int tsID)
 
       memcpy(destTstep->records, sourceTstep->records, (size_t)nrecs*sizeof(record_t));
 
-      destTstep->recIDs     = (int *) xmalloc((size_t)nvrecs * sizeof(int));
+      destTstep->recIDs     = (int *) Malloc((size_t)nvrecs * sizeof(int));
 
       memcpy(destTstep->recIDs, streamptr->tsteps[1].recIDs, (size_t)nvrecs*sizeof(int));
     }
@@ -41425,9 +42065,7 @@ int cdfTimeDimID(int fileID, int ndims, int nvars)
 static
 void init_ncdims(long ndims, ncdim_t *ncdims)
 {
-  long ncdimid;
-
-  for ( ncdimid = 0; ncdimid < ndims; ncdimid++ )
+  for ( long ncdimid = 0; ncdimid < ndims; ncdimid++ )
     {
       ncdims[ncdimid].ncvarid      = UNDEFID;
       ncdims[ncdimid].dimtype      = UNDEFID;
@@ -41439,9 +42077,7 @@ void init_ncdims(long ndims, ncdim_t *ncdims)
 static
 void init_ncvars(long nvars, ncvar_t *ncvars)
 {
-  long ncvarid;
-
-  for ( ncvarid = 0; ncvarid < nvars; ++ncvarid )
+  for ( long ncvarid = 0; ncvarid < nvars; ++ncvarid )
     {
       ncvars[ncvarid].ncid            = UNDEFID;
       ncvars[ncvarid].ignore          = FALSE;
@@ -41458,6 +42094,8 @@ void init_ncvars(long nvars, ncvar_t *ncvars)
       ncvars[ncvarid].calendar        = FALSE;
       ncvars[ncvarid].climatology     = FALSE;
       ncvars[ncvarid].bounds          = UNDEFID;
+      ncvars[ncvarid].lformula        = FALSE;
+      ncvars[ncvarid].lformulaterms   = FALSE;
       ncvars[ncvarid].gridID          = UNDEFID;
       ncvars[ncvarid].zaxisID         = UNDEFID;
       ncvars[ncvarid].gridtype        = UNDEFID;
@@ -41469,6 +42107,7 @@ void init_ncvars(long nvars, ncvar_t *ncvars)
       ncvars[ncvarid].yvarid          = UNDEFID;
       ncvars[ncvarid].zvarid          = UNDEFID;
       ncvars[ncvarid].tvarid          = UNDEFID;
+      ncvars[ncvarid].psvarid         = UNDEFID;
       ncvars[ncvarid].ncoordvars      = 0;
       for ( int i = 0; i < MAX_COORDVARS; ++i )
         ncvars[ncvarid].coordvarids[i]  = UNDEFID;
@@ -41480,8 +42119,8 @@ void init_ncvars(long nvars, ncvar_t *ncvars)
       ncvars[ncvarid].xtype           = 0;
       ncvars[ncvarid].ndims           = 0;
       ncvars[ncvarid].gmapid          = UNDEFID;
-      ncvars[ncvarid].vlen            = 0;
-      ncvars[ncvarid].vdata           = NULL;
+      ncvars[ncvarid].vctsize         = 0;
+      ncvars[ncvarid].vct             = NULL;
       ncvars[ncvarid].truncation      = 0;
       ncvars[ncvarid].position        = 0;
       ncvars[ncvarid].positive        = 0;
@@ -41510,6 +42149,36 @@ void init_ncvars(long nvars, ncvar_t *ncvars)
 }
 
 static
+void cdfSetVar(ncvar_t *ncvars, int ncvarid, short isvar)
+{
+  if ( ncvars[ncvarid].isvar != UNDEFID &&
+       ncvars[ncvarid].isvar != isvar   &&
+       ncvars[ncvarid].warn  == FALSE )
+    {
+      if ( ! ncvars[ncvarid].ignore )
+        Warning("Inconsistent variable definition for %s!", ncvars[ncvarid].name);
+
+      ncvars[ncvarid].warn = TRUE;
+      isvar = FALSE;
+    }
+
+  ncvars[ncvarid].isvar = isvar;
+}
+
+static
+void cdfSetDim(ncvar_t *ncvars, int ncvarid, int dimid, int dimtype)
+{
+  if ( ncvars[ncvarid].dimtype[dimid] != UNDEFID &&
+       ncvars[ncvarid].dimtype[dimid] != dimtype )
+    {
+      Warning("Inconsistent dimension definition for %s! dimid = %d;  type = %d;  newtype = %d",
+              ncvars[ncvarid].name, dimid, ncvars[ncvarid].dimtype[dimid], dimtype);
+    }
+
+  ncvars[ncvarid].dimtype[dimid] = dimtype;
+}
+
+static
 int isLonAxis(const char *units, const char *stdname)
 {
   int status = FALSE;
@@ -41561,7 +42230,7 @@ int isLatAxis(const char *units, const char *stdname)
       int ioff = 6;
       if ( lc_units[ioff] == 's' ) ioff++;
       if ( lc_units[ioff] == '_' ) ioff++;
-      if ( lc_units[ioff] == 'n' ) status = TRUE;
+      if ( lc_units[ioff] == 'n' || lc_units[ioff] == 's' ) status = TRUE;
     }
 
   return (status);
@@ -41590,7 +42259,7 @@ int isDBLAxis(/*const char *units,*/ const char *longname)
 static
 int unitsIsMeter(const char *units)
 {
-  return (*units == 'm' && (strcmp(units, "m") == 0 || strncmp(units, "meter", 5) == 0));
+  return (units[0] == 'm' && (!units[1] || strncmp(units, "meter", 5) == 0));
 }
 
 static
@@ -41641,11 +42310,123 @@ int unitsIsPressure(const char *units)
       status = TRUE;
     }
 
-  return (status);
+  return status;
 }
 
 static
-int isGaussGrid(size_t ysize, double yinc, double *yvals)
+void scan_hybrid_formula(int ncid, int ncfvarid, int *apvarid, int *bvarid, int *psvarid)
+{
+  *apvarid = -1;
+  *bvarid  = -1;
+  *psvarid = -1;
+  const int attstringlen = 8192; char attstring[8192];
+  cdfGetAttText(ncid, ncfvarid, "formula", attstringlen, attstring);
+  if ( strcmp(attstring, "p = ap + b*ps") == 0 )
+    {
+      int lstop = FALSE;
+      int dimvarid;
+      cdfGetAttText(ncid, ncfvarid, "formula_terms", attstringlen, attstring);
+      char *pstring = attstring;
+
+      for ( int i = 0; i < 3; i++ )
+        {
+          while ( isspace((int) *pstring) ) pstring++;
+          if ( *pstring == 0 ) break;
+          char *tagname = pstring;
+          while ( !isspace((int) *pstring) && *pstring != 0 ) pstring++;
+          if ( *pstring == 0 ) lstop = TRUE;
+          *pstring++ = 0;
+
+          while ( isspace((int) *pstring) ) pstring++;
+          if ( *pstring == 0 ) break;
+          char *varname = pstring;
+          while ( !isspace((int) *pstring) && *pstring != 0 ) pstring++;
+          if ( *pstring == 0 ) lstop = TRUE;
+          *pstring++ = 0;
+
+          int status = nc_inq_varid(ncid, varname, &dimvarid);
+          if ( status == NC_NOERR )
+            {
+              if      ( strcmp(tagname, "ap:") == 0 ) *apvarid = dimvarid;
+              else if ( strcmp(tagname, "b:")  == 0 ) *bvarid  = dimvarid;
+              else if ( strcmp(tagname, "ps:") == 0 ) *psvarid = dimvarid;
+            }
+          else if ( strcmp(tagname, "ps:") != 0 )
+            {
+              Warning("%s - %s", nc_strerror(status), varname);
+            }
+
+          if ( lstop ) break;
+        }
+    }
+}
+
+static
+int isHybridSigmaPressureCoordinate(int ncid, int ncvarid, ncvar_t *ncvars, const ncdim_t *ncdims)
+{
+  int status = FALSE;
+  int ncfvarid = ncvarid;
+  ncvar_t *ncvar = &ncvars[ncvarid];
+
+  if ( strcmp(ncvar->stdname, "atmosphere_hybrid_sigma_pressure_coordinate") == 0 )
+    {
+      cdiConvention = CDI_CONVENTION_CF;
+
+      status = TRUE;
+      ncvar->zaxistype = ZAXIS_HYBRID;
+      int dimid = ncvar->dimids[0];
+      size_t dimlen = ncdims[dimid].len;
+
+      int apvarid1 = -1, bvarid1 = -1, psvarid1 = -1;
+      if ( ncvars[ncfvarid].lformula && ncvars[ncfvarid].lformulaterms )
+        scan_hybrid_formula(ncid, ncfvarid, &apvarid1, &bvarid1, &psvarid1);
+      if ( apvarid1 != -1 ) ncvars[apvarid1].isvar = FALSE;
+      if ( bvarid1  != -1 ) ncvars[bvarid1].isvar  = FALSE;
+      if ( psvarid1 != -1 ) ncvar->psvarid = psvarid1;
+
+      if ( ncvar->bounds != UNDEFID && ncvars[ncvar->bounds].lformula && ncvars[ncvar->bounds].lformulaterms )
+        {
+          ncfvarid = ncvar->bounds;
+          int apvarid2 = -1, bvarid2 = -1, psvarid2 = -1;
+          if ( ncvars[ncfvarid].lformula && ncvars[ncfvarid].lformulaterms )
+            scan_hybrid_formula(ncid, ncfvarid, &apvarid2, &bvarid2, &psvarid2);
+          if ( apvarid2 != -1 && bvarid2 != -1 )
+            {
+              ncvars[apvarid2].isvar = FALSE;
+              ncvars[bvarid2].isvar  = FALSE;
+
+              if ( dimid == ncvars[apvarid2].dimids[0] && ncdims[ncvars[apvarid2].dimids[1]].len == 2 )
+                {
+                  double abuf[dimlen*2], bbuf[dimlen*2];
+                  cdf_get_var_double(ncid, apvarid2, abuf);
+                  cdf_get_var_double(ncid, bvarid2, bbuf);
+                  /*
+                  for ( int i = 0; i < dimlen; ++i )
+                    printf("%d  %g %g    %g %g\n", i, abuf[i*2], abuf[i*2+1], bbuf[i*2], bbuf[i*2+1]);
+                  */
+                  size_t vctsize = (dimlen+1)*2;
+                  double *vct = (double *) Malloc(vctsize * sizeof(double));
+                  for ( size_t i = 0; i < dimlen; ++i )
+                    {
+                      vct[i] = abuf[i*2];
+                      vct[i+dimlen+1] = bbuf[i*2];
+                    }
+                  vct[dimlen]     = abuf[dimlen*2-1];
+                  vct[dimlen*2+1] = bbuf[dimlen*2-1];
+
+                  ncvar->vct = vct;
+                  ncvar->vctsize = vctsize;
+                }
+            }
+        }
+    }
+
+  return status;
+}
+
+
+static
+int isGaussGrid(size_t ysize, double yinc, const double *yvals)
 {
   int lgauss = FALSE;
   double *yv, *yw;
@@ -41653,10 +42434,10 @@ int isGaussGrid(size_t ysize, double yinc, double *yvals)
   if ( IS_EQUAL(yinc, 0) && ysize > 2 ) /* check if gaussian */
     {
       size_t i;
-      yv = (double *) malloc(ysize*sizeof(double));
-      yw = (double *) malloc(ysize*sizeof(double));
+      yv = (double *) Malloc(ysize*sizeof(double));
+      yw = (double *) Malloc(ysize*sizeof(double));
       gaussaw(yv, yw, ysize);
-      free(yw);
+      Free(yw);
       for ( i = 0; i < ysize; i++ )
         yv[i] = asin(yv[i])/M_PI*180.0;
 
@@ -41676,47 +42457,14 @@ int isGaussGrid(size_t ysize, double yinc, double *yvals)
           if ( i == ysize ) lgauss = TRUE;
         }
 
-      free(yv);
+      Free(yv);
     }
 
   return (lgauss);
 }
 
 static
-void cdfSetVar(ncvar_t *ncvars, int ncvarid, int isvar)
-{
-  if ( isvar != TRUE && isvar != FALSE )
-    Error("Internal problem! var %s undefined", ncvars[ncvarid].name);
-
-  if ( ncvars[ncvarid].isvar != UNDEFID &&
-       ncvars[ncvarid].isvar != isvar   &&
-       ncvars[ncvarid].warn  == FALSE )
-    {
-      if ( ! ncvars[ncvarid].ignore )
-        Warning("Inconsistent variable definition for %s!", ncvars[ncvarid].name);
-
-      ncvars[ncvarid].warn = TRUE;
-      isvar = FALSE;
-    }
-
-  ncvars[ncvarid].isvar = isvar;
-}
-
-static
-void cdfSetDim(ncvar_t *ncvars, int ncvarid, int dimid, int dimtype)
-{
-  if ( ncvars[ncvarid].dimtype[dimid] != UNDEFID &&
-       ncvars[ncvarid].dimtype[dimid] != dimtype )
-    {
-      Warning("Inconsistent dimension definition for %s! dimid = %d;  type = %d;  newtype = %d",
-              ncvars[ncvarid].name, dimid, ncvars[ncvarid].dimtype[dimid], dimtype);
-    }
-
-  ncvars[ncvarid].dimtype[dimid] = dimtype;
-}
-
-static
-void printNCvars(ncvar_t *ncvars, int nvars, const char *oname)
+void printNCvars(const ncvar_t *ncvars, int nvars, const char *oname)
 {
   char axis[7];
   int ncvarid, i;
@@ -41773,8 +42521,6 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
   int nvdims, nvatts;
   int *dimidsp;
   int iatt;
-  int i;
-  int tablenum;
   nc_type xtype, atttype;
   size_t attlen;
   char name[CDI_MAX_NAME];
@@ -41782,8 +42528,9 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
   const int attstringlen = 8192; char attstring[8192];
 
   int nchecked_vars = 0;
-  char *checked_vars[9];
-  for ( i = 0; i < 9; ++i ) checked_vars[i] = NULL;
+  enum { max_check_vars = 9 };
+  char *checked_vars[max_check_vars];
+  for ( int i = 0; i < max_check_vars; ++i ) checked_vars[i] = NULL;
 
   for ( int ncvarid = 0; ncvarid < nvars; ncvarid++ )
     {
@@ -41892,6 +42639,7 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
             }
           else if ( strcmp(attname, "table") == 0 && !xtypeIsText(atttype) )
             {
+              int tablenum;
               cdfGetAttInt(ncid, ncvarid, attname, 1, &tablenum);
               if ( tablenum > 0 )
                 {
@@ -42024,12 +42772,9 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
             }
           else if ( strcmp(attname, "climatology") == 0 && xtypeIsText(atttype) )
             {
-              int status, ncboundsid;
-
               cdfGetAttText(ncid, ncvarid, attname, attstringlen, attstring);
-
-              status = nc_inq_varid(ncid, attstring, &ncboundsid);
-
+              int ncboundsid;
+              int status = nc_inq_varid(ncid, attstring, &ncboundsid);
               if ( status == NC_NOERR )
                 {
                   ncvars[ncvarid].climatology = TRUE;
@@ -42040,14 +42785,11 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
               else
                 Warning("%s - %s", nc_strerror(status), attstring);
             }
-          else if ( strcmp(attname, "bounds") == 0 && xtypeIsText(atttype) )
+          else if ( xtypeIsText(atttype) && strcmp(attname, "bounds") == 0 )
             {
-              int status, ncboundsid;
-
               cdfGetAttText(ncid, ncvarid, attname, attstringlen, attstring);
-
-              status = nc_inq_varid(ncid, attstring, &ncboundsid);
-
+              int ncboundsid;
+              int status = nc_inq_varid(ncid, attstring, &ncboundsid);
               if ( status == NC_NOERR )
                 {
                   ncvars[ncvarid].bounds = ncboundsid;
@@ -42057,12 +42799,20 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
               else
                 Warning("%s - %s", nc_strerror(status), attstring);
             }
+          else if ( xtypeIsText(atttype) && strcmp(attname, "formula_terms") == 0 )
+            {
+              ncvars[ncvarid].lformulaterms = TRUE;
+            }
+          else if ( xtypeIsText(atttype) && strcmp(attname, "formula") == 0 )
+            {
+              ncvars[ncvarid].lformula = TRUE;
+            }
           else if ( strcmp(attname, "cell_measures") == 0 && xtypeIsText(atttype) )
             {
-              char *pstring, *cell_measures = NULL, *cell_var = NULL;
+              char *cell_measures = NULL, *cell_var = NULL;
 
               cdfGetAttText(ncid, ncvarid, attname, attstringlen, attstring);
-              pstring = attstring;
+              char *pstring = attstring;
 
               while ( isspace((int) *pstring) ) pstring++;
               cell_measures = pstring;
@@ -42078,10 +42828,8 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
               */
               if ( memcmp(cell_measures, "area", 4) == 0 )
                 {
-                  int status;
                   int nc_cell_id;
-
-                  status = nc_inq_varid(ncid, cell_var, &nc_cell_id);
+                  int status = nc_inq_varid(ncid, cell_var, &nc_cell_id);
                   if ( status == NC_NOERR )
                     {
                       ncvars[ncvarid].cellarea = nc_cell_id;
@@ -42125,15 +42873,14 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
           else if ( (strcmp(attname, "associate")  == 0 || strcmp(attname, "coordinates") == 0) && xtypeIsText(atttype) )
             {
               int status;
-              char *pstring, *varname = NULL;
+              char *varname = NULL;
               int lstop = FALSE;
               int dimvarid;
-              extern int cdiIgnoreAttCoordinates;
 
               cdfGetAttText(ncid, ncvarid, attname, attstringlen, attstring);
-              pstring = attstring;
+              char *pstring = attstring;
 
-              for ( i = 0; i < MAX_COORDVARS; i++ )
+              for ( int i = 0; i < MAX_COORDVARS; i++ )
                 {
                   while ( isspace((int) *pstring) ) pstring++;
                   if ( *pstring == 0 ) break;
@@ -42160,7 +42907,7 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
 
                       if ( k == nchecked_vars )
                         {
-                          if ( nchecked_vars < 9 ) checked_vars[nchecked_vars++] = strdup(varname);
+                          if ( nchecked_vars < max_check_vars ) checked_vars[nchecked_vars++] = strdup(varname);
                           Warning("%s - %s", nc_strerror(status), varname);
                         }
                     }
@@ -42173,15 +42920,14 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
           else if ( (strcmp(attname, "auxiliary_variable") == 0) && xtypeIsText(atttype) )
             {
               int status;
-              char *pstring, *varname = NULL;
+              char *varname = NULL;
               int lstop = FALSE;
               int dimvarid;
-              extern int cdiIgnoreAttCoordinates;
 
               cdfGetAttText(ncid, ncvarid, attname, attstringlen, attstring);
-              pstring = attstring;
+              char *pstring = attstring;
 
-              for ( i = 0; i < MAX_AUXVARS; i++ )
+              for ( int i = 0; i < MAX_AUXVARS; i++ )
                 {
                   while ( isspace((int) *pstring) ) pstring++;
                   if ( *pstring == 0 ) break;
@@ -42210,12 +42956,9 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
             }
           else if ( strcmp(attname, "grid_mapping") == 0 && xtypeIsText(atttype) )
             {
-              int status;
-              int nc_gmap_id;
-
               cdfGetAttText(ncid, ncvarid, attname, attstringlen, attstring);
-
-              status = nc_inq_varid(ncid, attstring, &nc_gmap_id);
+              int nc_gmap_id;
+              int status = nc_inq_varid(ncid, attstring, &nc_gmap_id);
               if ( status == NC_NOERR )
                 {
                   ncvars[ncvarid].gmapid = nc_gmap_id;
@@ -42342,14 +43085,22 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
               cdfGetAttText(ncid, ncvarid, attname, attstringlen, attstring);
 	      attlen = strlen(attstring);
 
-	      if ( (int) attlen > nvdims )
+	      if ( (int) attlen > nvdims && nvdims > 0 && attlen > 1 )
 		{
-		  if ( nvdims > 0 )
 		    Warning("Unexpected axis attribute length for %s, ignored!", name);
 		}
+              else if ( nvdims == 0 && attlen == 1 )
+                {
+                  if ( attstring[0] == 'z' || attstring[0] == 'Z' )
+                    {
+                      cdfSetVar(ncvars, ncvarid, FALSE);
+                      ncvars[ncvarid].islev = TRUE;
+                    }
+                }
 	      else
 		{
 		  strtolower(attstring);
+                  int i;
 		  for ( i = 0; i < (int)attlen; ++i )
 		    {
 		      if ( attstring[i] != '-' && attstring[i] != 't' && attstring[i] != 'z' &&
@@ -42360,7 +43111,7 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
 			}
 		    }
 
-		  if ( i == (int) attlen && (int) attlen == nvdims)
+		  if ( i == (int) attlen && (int) attlen == nvdims )
 		    {
 		      while ( attlen-- )
 			{
@@ -42371,14 +43122,14 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
 			    }
 			  else if ( (int) attstring[attlen] == 'z' )
 			    {
-			      ncvars[ncvarid].zdim = dimidsp[attlen];
-			      cdfSetDim(ncvars, ncvarid, (int)attlen, Z_AXIS);
-
-			      if ( ncvars[ncvarid].ndims == 1 )
-				{
-				  cdfSetVar(ncvars, ncvarid, FALSE);
-				  ncdims[ncvars[ncvarid].dimids[0]].dimtype = Z_AXIS;
-				}
+                              ncvars[ncvarid].zdim = dimidsp[attlen];
+                              cdfSetDim(ncvars, ncvarid, (int)attlen, Z_AXIS);
+
+                              if ( ncvars[ncvarid].ndims == 1 )
+                                {
+                                  cdfSetVar(ncvars, ncvarid, FALSE);
+                                  ncdims[ncvars[ncvarid].dimids[0]].dimtype = Z_AXIS;
+                                }
 			    }
 			  else if ( (int) attstring[attlen] == 'y' )
 			    {
@@ -42413,7 +43164,7 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
 	      int temp;
 
 	      if( ncvars[ncvarid].ensdata == NULL )
-		ncvars[ncvarid].ensdata = (ensinfo_t *) malloc( sizeof( ensinfo_t ) );
+		ncvars[ncvarid].ensdata = (ensinfo_t *) Malloc( sizeof( ensinfo_t ) );
 
 	      cdfGetAttInt(ncid, ncvarid, attname, 1, &temp);
 
@@ -42430,7 +43181,7 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
 	    {
 	      if ( ncvars[ncvarid].natts == 0 )
 		ncvars[ncvarid].atts
-                  = (int *)xmalloc((size_t)nvatts * sizeof (int));
+                  = (int *) Malloc((size_t)nvatts * sizeof (int));
 
 	      ncvars[ncvarid].atts[ncvars[ncvarid].natts++] = iatt;
 	      /*
@@ -42462,7 +43213,7 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
 	}
     }
 
-  for ( i = 0; i < 9; ++i ) if ( checked_vars[i] ) free(checked_vars[i]);
+  for ( int i = 0; i < max_check_vars; ++i ) if ( checked_vars[i] ) Free(checked_vars[i]);
 }
 
 static
@@ -42541,7 +43292,7 @@ void setDimType(int nvars, ncvar_t *ncvars, ncdim_t *ncdims)
 
 /* verify coordinate vars - first scan (dimname == varname) */
 static
-void verify_coordinate_vars_1(int ndims, ncdim_t *ncdims, ncvar_t *ncvars, int timedimid)
+void verify_coordinate_vars_1(int ncid, int ndims, ncdim_t *ncdims, ncvar_t *ncvars, int timedimid)
 {
   int ncdimid, ncvarid;
 
@@ -42557,6 +43308,8 @@ void verify_coordinate_vars_1(int ndims, ncdim_t *ncdims, ncvar_t *ncvars, int t
 	      continue;
 	    }
 
+          if ( isHybridSigmaPressureCoordinate(ncid, ncvarid, ncvars, ncdims) ) continue;
+
 	  if ( ncvars[ncvarid].units[0] != 0 )
 	    {
 	      if ( isLonAxis(ncvars[ncvarid].units, ncvars[ncvarid].stdname) )
@@ -42602,6 +43355,13 @@ void verify_coordinate_vars_1(int ndims, ncdim_t *ncdims, ncvar_t *ncvars, int t
 		    ncvars[ncvarid].zaxistype = ZAXIS_HEIGHT;
 		}
 	    }
+          else
+            {
+              if ( (strcmp(ncvars[ncvarid].longname, "generalized_height") == 0 ||
+                    strcmp(ncvars[ncvarid].longname, "generalized height") == 0) &&
+                   strcmp(ncvars[ncvarid].stdname, "height") == 0 )
+                  ncvars[ncvarid].zaxistype = ZAXIS_REFERENCE;
+            }
 
 	  if ( ncvars[ncvarid].islon == FALSE && ncvars[ncvarid].longname[0] != 0 &&
                ncvars[ncvarid].islat == FALSE && ncvars[ncvarid].longname[1] != 0 )
@@ -42766,7 +43526,6 @@ static
 void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nvars, ncvar_t *ncvars, int timedimid, unsigned char *uuidOfHGrid, char *gridfile, int number_of_grid_used)
 {
   int ncvarid, ncvarid2;
-  int ndims;
   int nbdims;
   int i;
   int nvatts;
@@ -42775,7 +43534,6 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
   grid_t grid;
   grid_t proj;
   int gridindex;
-  size_t size = 0, xsize, ysize, np;
   char name[CDI_MAX_NAME];
   int iatt;
   int ltwarn = TRUE;
@@ -42792,13 +43550,11 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 	  int xvarid = -1, yvarid = -1;
 	  int islon = 0, islat = 0;
 	  int nxdims = 0, nydims = 0;
+          size_t size = 0, np = 0;
+          size_t xsize = 0, ysize = 0;
 	  double xinc = 0, yinc = 0;
 
-	  xsize = 0;
-	  ysize = 0;
-          np    = 0;
-
-	  ndims = ncvars[ncvarid].ndims;
+	  int ndims = ncvars[ncvarid].ndims;
 	  for ( i = 0; i < ndims; i++ )
 	    {
 	      if ( ncvars[ncvarid].dimtype[i] == X_AXIS && nxdims < 2 )
@@ -42864,7 +43620,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 	    }
 
 	  if ( ncvars[ncvarid].gridtype == UNDEFID || ncvars[ncvarid].gridtype == GRID_GENERIC )
-	    if ( xdimid != UNDEFID && xdimid == ydimid ) ncvars[ncvarid].gridtype = GRID_UNSTRUCTURED;
+	    if ( xdimid != UNDEFID && xdimid == ydimid && nydims == 0 ) ncvars[ncvarid].gridtype = GRID_UNSTRUCTURED;
 
 	  grid_init(&grid);
 	  grid_init(&proj);
@@ -42949,12 +43705,10 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 		      size = xsize*ysize;
 		      /* Check size of 2 dimensional coordinate variables */
 		      {
-			int dimid;
-			size_t dimsize1, dimsize2;
-			dimid = ncvars[xvarid].dimids[ndims-2];
-			dimsize1 = ncdims[dimid].len;
+			int dimid = ncvars[xvarid].dimids[ndims-2];
+			size_t dimsize1 = ncdims[dimid].len;
 			dimid = ncvars[xvarid].dimids[ndims-1];
-			dimsize2 = ncdims[dimid].len;
+			size_t dimsize2 = ncdims[dimid].len;
 			if ( dimsize1*dimsize2 == size ) skipvar = FALSE;
 		      }
 		    }
@@ -42963,10 +43717,8 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 		      size = xsize;
 		      /* Check size of 1 dimensional coordinate variables */
 		      {
-			int dimid;
-			size_t dimsize;
-			dimid = ncvars[xvarid].dimids[0];
-			dimsize = ncdims[dimid].len;
+			int dimid = ncvars[xvarid].dimids[0];
+			size_t dimsize = ncdims[dimid].len;
 			if ( dimsize == size ) skipvar = FALSE;
 		      }
 		    }
@@ -42985,7 +43737,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
                     }
 
 		  if ( ncvars[xvarid].xtype == NC_FLOAT ) grid.prec = DATATYPE_FLT32;
-		  grid.xvals = (double *) malloc(size*sizeof(double));
+		  grid.xvals = (double *) Malloc(size*sizeof(double));
 
 		  if ( ltgrid )
 		    cdf_get_vara_double(ncvars[xvarid].ncid, xvarid, start, count, grid.xvals);
@@ -43062,7 +43814,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
                     }
 
 		  if ( ncvars[yvarid].xtype == NC_FLOAT ) grid.prec = DATATYPE_FLT32;
-		  grid.yvals = (double *) malloc(size*sizeof(double));
+		  grid.yvals = (double *) Malloc(size*sizeof(double));
 
 		  if ( ltgrid )
 		    cdf_get_vara_double(ncvars[yvarid].ncid, yvarid, start, count, grid.yvals);
@@ -43149,7 +43901,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 			  {
 			    nvertex = ncdims[ncvars[ncvars[xvarid].bounds].dimids[nbdims-1]].len;
 			    grid.nvertex = (int) nvertex;
-			    grid.xbounds = (double *) malloc(nvertex*size*sizeof(double));
+			    grid.xbounds = (double *) Malloc(nvertex*size*sizeof(double));
 			    cdf_get_var_double(ncvars[xvarid].ncid, ncvars[xvarid].bounds, grid.xbounds);
 			  }
 		      }
@@ -43168,7 +43920,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 			      Warning("nvertex problem! nvertex x %d, nvertex y %d",
 				      grid.nvertex, (int) nvertex);
 			    */
-			    grid.ybounds = (double *) malloc(nvertex*size*sizeof(double));
+			    grid.ybounds = (double *) Malloc(nvertex*size*sizeof(double));
 			    cdf_get_var_double(ncvars[yvarid].ncid, ncvars[yvarid].bounds, grid.ybounds);
 			  }
 		      }
@@ -43176,7 +43928,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 
 		if ( ncvars[ncvarid].cellarea != UNDEFID )
 		  {
-		    grid.area = (double *) malloc(size*sizeof(double));
+		    grid.area = (double *) Malloc(size*sizeof(double));
 		    cdf_get_var_double(ncvars[ncvarid].ncid, ncvars[ncvarid].cellarea, grid.area);
 		  }
 
@@ -43475,54 +44227,61 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 /* define all input zaxes */
 static
 void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nvars, ncvar_t *ncvars,
-		      size_t vctsize, double *vct, unsigned char *uuidOfVGrid)
+		      size_t vctsize_echam, double *vct_echam, unsigned char *uuidOfVGrid)
 {
   int ncvarid, ncvarid2;
-  int i, ilev, ndims;
+  int i, ilev;
   int zaxisindex;
-  int zprec;
   int nbdims, nvertex, nlevel;
-  int positive = 0;
+  int psvarid = -1;
   char *pname, *plongname, *punits;
+  size_t vctsize = vctsize_echam;
+  double *vct = vct_echam;
 
   for ( ncvarid = 0; ncvarid < nvars; ncvarid++ )
     {
       if ( ncvars[ncvarid].isvar == TRUE && ncvars[ncvarid].zaxisID == UNDEFID )
 	{
+          int is_scalar = FALSE;
 	  int with_bounds = FALSE;
 	  int zdimid = UNDEFID;
 	  int zvarid = UNDEFID;
 	  int zsize = 1;
 	  double *lbounds = NULL;
 	  double *ubounds = NULL;
-	  int zaxisType;
 
-          positive = 0;
+          int positive = 0;
+	  int ndims = ncvars[ncvarid].ndims;
 
-	  ndims = ncvars[ncvarid].ndims;
-	  for ( i = 0; i < ndims; i++ )
-	    {
-	      if ( ncvars[ncvarid].dimtype[i] == Z_AXIS )
-		zdimid = ncvars[ncvarid].dimids[i];
-	    }
+          if ( ncvars[ncvarid].zvarid != -1 && ncvars[ncvars[ncvarid].zvarid].ndims == 0 )
+            {
+              zvarid = ncvars[ncvarid].zvarid;
+              is_scalar = TRUE;
+            }
+          else
+            {
+              for ( i = 0; i < ndims; i++ )
+                {
+                  if ( ncvars[ncvarid].dimtype[i] == Z_AXIS )
+                    zdimid = ncvars[ncvarid].dimids[i];
+                }
 
-	  if ( zdimid != UNDEFID )
-	    {
-	      zvarid = ncdims[zdimid].ncvarid;
-	      zsize  = (int)ncdims[zdimid].len;
-	    }
+              if ( zdimid != UNDEFID )
+                {
+                  zvarid = ncdims[zdimid].ncvarid;
+                  zsize  = (int)ncdims[zdimid].len;
+                }
+            }
 
 	  if ( CDI_Debug ) Message("nlevs = %d", zsize);
 
-	  double *zvar = (double *)xmalloc((size_t)zsize * sizeof (double));
-
-	  zaxisType = UNDEFID;
+	  double *zvar = (double *) Malloc((size_t)zsize * sizeof (double));
 
+	  int zaxisType = UNDEFID;
 	  if ( zvarid != UNDEFID ) zaxisType = ncvars[zvarid].zaxistype;
-
 	  if ( zaxisType == UNDEFID )  zaxisType = ZAXIS_GENERIC;
 
-	  zprec = DATATYPE_FLT64;
+	  int zprec = DATATYPE_FLT64;
 
 	  if ( zvarid != UNDEFID )
 	    {
@@ -43537,6 +44296,15 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 		if ( pname[len-2] == '_' && isdigit((int) pname[len-1]) )
 		  pname[len-2] = 0;
 	      */
+              psvarid = -1;
+              if ( zaxisType == ZAXIS_HYBRID && ncvars[zvarid].vct )
+                {
+                  vct = ncvars[zvarid].vct;
+                  vctsize = ncvars[zvarid].vctsize;
+
+                  if ( ncvars[zvarid].psvarid != -1 ) psvarid = ncvars[zvarid].psvarid;
+                }
+
 	      cdf_get_var_double(ncvars[zvarid].ncid, zvarid, zvar);
 
 	      if ( ncvars[zvarid].bounds != UNDEFID )
@@ -43548,18 +44316,16 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 		      nvertex = (int)ncdims[ncvars[ncvars[zvarid].bounds].dimids[1]].len;
 		      if ( nlevel == zsize && nvertex == 2 )
 			{
-			  double *zbounds;
 			  with_bounds = TRUE;
-			  zbounds = (double *) malloc(2*(size_t)nlevel*sizeof(double));
-			  lbounds = (double *) malloc((size_t)nlevel*sizeof(double));
-			  ubounds = (double *) malloc((size_t)nlevel*sizeof(double));
+			  lbounds = (double *) Malloc((size_t)nlevel*sizeof(double));
+			  ubounds = (double *) Malloc((size_t)nlevel*sizeof(double));
+			  double zbounds[2*nlevel];
 			  cdf_get_var_double(ncvars[zvarid].ncid, ncvars[zvarid].bounds, zbounds);
 			  for ( i = 0; i < nlevel; ++i )
 			    {
 			      lbounds[i] = zbounds[i*2];
 			      ubounds[i] = zbounds[i*2+1];
 			    }
-			  free(zbounds);
 			}
 		    }
 		}
@@ -43600,11 +44366,14 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
               zaxisDefUUID(ncvars[ncvarid].zaxisID, uuidOfVGrid);
             }
 
+          if ( zaxisType == ZAXIS_HYBRID && psvarid != -1 ) zaxisDefPsName(ncvars[ncvarid].zaxisID, ncvars[psvarid].name);
+
           if ( positive > 0 ) zaxisDefPositive(ncvars[ncvarid].zaxisID, positive);
+          if ( is_scalar ) zaxisDefScalar(ncvars[ncvarid].zaxisID);
 
-	  free(zvar);
-	  free(lbounds);
-	  free(ubounds);
+	  Free(zvar);
+	  Free(lbounds);
+	  Free(ubounds);
 
 	  zaxisindex = vlistZaxisIndex(vlistID, ncvars[ncvarid].zaxisID);
 	  streamptr->zaxisID[zaxisindex]  = zdimid;
@@ -43613,22 +44382,32 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 	    Message("zaxisID %d %d %s", ncvars[ncvarid].zaxisID, ncvarid, ncvars[ncvarid].name);
 
 	  for ( ncvarid2 = ncvarid+1; ncvarid2 < nvars; ncvarid2++ )
-	    if ( ncvars[ncvarid2].isvar == TRUE && ncvars[ncvarid2].zaxisID == UNDEFID && ncvars[ncvarid2].zaxistype == UNDEFID )
+	    if ( ncvars[ncvarid2].isvar == TRUE && ncvars[ncvarid2].zaxisID == UNDEFID /*&& ncvars[ncvarid2].zaxistype == UNDEFID*/ )
 	      {
-		int zdimid2 = -1;
+                int zvarid2 = UNDEFID;
+                if ( ncvars[ncvarid2].zvarid != UNDEFID && ncvars[ncvars[ncvarid2].zvarid].ndims == 0 )
+                  zvarid2 = ncvars[ncvarid2].zvarid;
+
+		int zdimid2 = UNDEFID;
 		ndims = ncvars[ncvarid2].ndims;
 		for ( i = 0; i < ndims; i++ )
 		  {
 		    if ( ncvars[ncvarid2].dimtype[i] == Z_AXIS )
 		      zdimid2 = ncvars[ncvarid2].dimids[i];
 		  }
-		if ( zdimid == zdimid2 )
+
+		if ( zdimid == zdimid2 /* && zvarid == zvarid2 */)
 		  {
-		    if ( CDI_Debug )
-		      Message("zaxisID %d %d %s",
-			      ncvars[ncvarid].zaxisID, ncvarid2, ncvars[ncvarid2].name);
-		    ncvars[ncvarid2].zaxisID = ncvars[ncvarid].zaxisID;
-		  }
+                    if ( (zdimid != UNDEFID && ncvars[ncvarid2].zaxistype == UNDEFID) ||
+                         (zdimid == UNDEFID && zvarid != UNDEFID && zvarid == zvarid2) ||
+                         (zdimid == UNDEFID && zaxisType == ncvars[ncvarid2].zaxistype) ||
+                         (zdimid == UNDEFID && zvarid2 == UNDEFID && ncvars[ncvarid2].zaxistype == UNDEFID) )
+                      {
+                        if ( CDI_Debug )
+                          Message("zaxisID %d %d %s", ncvars[ncvarid].zaxisID, ncvarid2, ncvars[ncvarid2].name);
+                        ncvars[ncvarid2].zaxisID = ncvars[ncvarid].zaxisID;
+                      }
+                  }
 	      }
 	}
     }
@@ -43655,7 +44434,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
   if ( streamptr->sortname )
     {
       struct varinfo *varInfo
-        = (struct varinfo *)xmalloc((size_t)nvars * sizeof (struct varinfo));
+        = (struct varinfo *) Malloc((size_t)nvars * sizeof (struct varinfo));
 
       for ( int varID = 0; varID < nvars; varID++ )
 	{
@@ -43668,18 +44447,16 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 	{
 	  varids[varID] = varInfo[varID].ncvarid;
 	}
-      free(varInfo);
+      Free(varInfo);
     }
 
   for ( int varID1 = 0; varID1 < nvars; varID1++ )
     {
-      int gridID, zaxisID;
-
       int ncvarid = varids[varID1];
-      gridID  = ncvars[ncvarid].gridID;
-      zaxisID = ncvars[ncvarid].zaxisID;
+      int gridID  = ncvars[ncvarid].gridID;
+      int zaxisID = ncvars[ncvarid].zaxisID;
 
-      stream_new_var(streamptr, gridID, zaxisID);
+      stream_new_var(streamptr, gridID, zaxisID, CDI_UNDEFID);
       int varID = vlistDefVar(vlistID, gridID, zaxisID, ncvars[ncvarid].tsteptype);
 
 #if  defined  (HAVE_NETCDF4)
@@ -43698,8 +44475,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
       if ( ncvars[ncvarid].code != UNDEFID )  vlistDefVarCode(vlistID, varID, ncvars[ncvarid].code);
       if ( ncvars[ncvarid].code != UNDEFID )
 	{
-	  int param;
-	  param = cdiEncodeParam(ncvars[ncvarid].code, ncvars[ncvarid].tabnum, 255);
+	  int param = cdiEncodeParam(ncvars[ncvarid].code, ncvars[ncvarid].tabnum, 255);
 	  vlistDefVarParam(vlistID, varID, param);
 	}
       if ( ncvars[ncvarid].longname[0] )  vlistDefVarLongname(vlistID, varID, ncvars[ncvarid].longname);
@@ -43785,7 +44561,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
           vlistDefVarEnsemble( vlistID, varID, ncvars[ncvarid].ensdata->ens_index,
                                ncvars[ncvarid].ensdata->ens_count,
                                ncvars[ncvarid].ensdata->forecast_init_type );
-          free(ncvars[ncvarid].ensdata);
+          Free(ncvars[ncvarid].ensdata);
           ncvars[ncvarid].ensdata = NULL;
         }
 
@@ -43819,23 +44595,21 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 
 	      if ( attrtype == NC_SHORT || attrtype == NC_INT )
 		{
-		  int *attint = (int *) malloc(attlen*sizeof(int));
+		  int attint[attlen];
 		  cdfGetAttInt(ncid, ncvarid, attname, (int)attlen, attint);
 		  if ( attrtype == NC_SHORT )
 		    vlistDefAttInt(vlistID, varID, attname, DATATYPE_INT16, (int)attlen, attint);
 		  else
 		    vlistDefAttInt(vlistID, varID, attname, DATATYPE_INT32, (int)attlen, attint);
-		  free(attint);
 		}
 	      else if ( attrtype == NC_FLOAT || attrtype == NC_DOUBLE )
 		{
-		  double *attflt = (double *) malloc(attlen*sizeof(double));
+		  double attflt[attlen];
 		  cdfGetAttDouble(ncid, ncvarid, attname, (int)attlen, attflt);
 		  if ( attrtype == NC_FLOAT )
 		    vlistDefAttFlt(vlistID, varID, attname, DATATYPE_FLT32, (int)attlen, attflt);
 		  else
 		    vlistDefAttFlt(vlistID, varID, attname, DATATYPE_FLT64, (int)attlen, attflt);
-		  free(attflt);
 		}
 	      else if ( xtypeIsText(attrtype) )
 		{
@@ -43848,16 +44622,18 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 		}
 	    }
 
-	  free(ncvars[ncvarid].atts);
+	  if (ncvars[ncvarid].vct) Free(ncvars[ncvarid].vct);
+	  if (ncvars[ncvarid].atts) Free(ncvars[ncvarid].atts);
+          ncvars[ncvarid].vct = NULL;
           ncvars[ncvarid].atts = NULL;
 	}
     }
 
   /* release mem of not freed attributes */
   for ( int ncvarid = 0; ncvarid < num_ncvars; ncvarid++ )
-    if ( ncvars[ncvarid].atts ) free(ncvars[ncvarid].atts);
+    if ( ncvars[ncvarid].atts ) Free(ncvars[ncvarid].atts);
 
-  if ( varids ) free(varids);
+  if ( varids ) Free(varids);
 
   for ( int varID = 0; varID < nvars; varID++ )
     {
@@ -43870,7 +44646,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 	      if ( memcmp("var", pname, 3) == 0 )
 		{
 		  vlistDefVarCode(vlistID, varID, atoi(pname+3));
-		  vlistDestroyVarName(vlistID, varID);
+                  // vlistDestroyVarName(vlistID, varID);
 		}
 	    }
 	  else if ( len > 4 && isdigit((int) pname[4]) )
@@ -43878,7 +44654,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 	      if ( memcmp("code", pname, 4) == 0 )
 		{
 		  vlistDefVarCode(vlistID, varID, atoi(pname+4));
-		  vlistDestroyVarName(vlistID, varID);
+		  // vlistDestroyVarName(vlistID, varID);
 		}
 	    }
 	  else if ( len > 5 && isdigit((int) pname[5]) )
@@ -43888,7 +44664,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 		  int pnum = -1, pcat = 255, pdis = 255;
 		  sscanf(pname+5, "%d.%d.%d", &pnum, &pcat, &pdis);
 		  vlistDefVarParam(vlistID, varID, cdiEncodeParam(pnum, pcat, pdis));
-		  vlistDestroyVarName(vlistID, varID);
+                  // vlistDestroyVarName(vlistID, varID);
 		}
 	    }
 	}
@@ -43896,9 +44672,9 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 
   for ( int varID = 0; varID < nvars; varID++ )
     {
-      int instID  = vlistInqVarInstitut(vlistID, varID);
-      int modelID = vlistInqVarModel(vlistID, varID);
-      int tableID = vlistInqVarTable(vlistID, varID);
+      int varInstID  = vlistInqVarInstitut(vlistID, varID);
+      int varModelID = vlistInqVarModel(vlistID, varID);
+      int varTableID = vlistInqVarTable(vlistID, varID);
       int code = vlistInqVarCode(vlistID, varID);
       if ( cdiDefaultTableID != UNDEFID )
 	{
@@ -43908,7 +44684,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 	      vlistDestroyVarLongname(vlistID, varID);
 	      vlistDestroyVarUnits(vlistID, varID);
 
-	      if ( tableID != UNDEFID )
+	      if ( varTableID != UNDEFID )
 		{
 		  vlistDefVarName(vlistID, varID, tableInqParNamePtr(cdiDefaultTableID, code));
 		  if ( tableInqParLongnamePtr(cdiDefaultTableID, code) )
@@ -43918,16 +44694,16 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 		}
 	      else
 		{
-		  tableID = cdiDefaultTableID;
+		  varTableID = cdiDefaultTableID;
 		}
 	    }
 
-	  if ( cdiDefaultModelID != UNDEFID ) modelID = cdiDefaultModelID;
-	  if ( cdiDefaultInstID  != UNDEFID ) instID  = cdiDefaultInstID;
+	  if ( cdiDefaultModelID != UNDEFID ) varModelID = cdiDefaultModelID;
+	  if ( cdiDefaultInstID  != UNDEFID ) varInstID  = cdiDefaultInstID;
 	}
-      if ( instID  != UNDEFID ) vlistDefVarInstitut(vlistID, varID, instID);
-      if ( modelID != UNDEFID ) vlistDefVarModel(vlistID, varID, modelID);
-      if ( tableID != UNDEFID ) vlistDefVarTable(vlistID, varID, tableID);
+      if ( varInstID  != UNDEFID ) vlistDefVarInstitut(vlistID, varID, varInstID);
+      if ( varModelID != UNDEFID ) vlistDefVarModel(vlistID, varID, varModelID);
+      if ( varTableID != UNDEFID ) vlistDefVarTable(vlistID, varID, varTableID);
     }
 }
 
@@ -44028,26 +44804,22 @@ void scan_global_attributes(int fileID, int vlistID, stream_t *streamptr, int ng
 	    }
  	  else
             {
-              int *attint;
-              attint = (int *) malloc(attlen*sizeof(int));
+              int attint[attlen];
               cdfGetAttInt(fileID, NC_GLOBAL, attname, (int)attlen, attint);
               if ( xtype == NC_SHORT )
                 vlistDefAttInt(vlistID, CDI_GLOBAL, attname, DATATYPE_INT16, (int)attlen, attint);
               else
                 vlistDefAttInt(vlistID, CDI_GLOBAL, attname, DATATYPE_INT32, (int)attlen, attint);
-              free(attint);
             }
         }
       else if ( xtype == NC_FLOAT || xtype == NC_DOUBLE )
 	{
-	  double *attflt;
-	  attflt = (double *) malloc(attlen*sizeof(double));
+	  double attflt[attlen];
 	  cdfGetAttDouble(fileID, NC_GLOBAL, attname, (int)attlen, attflt);
 	  if ( xtype == NC_FLOAT )
 	    vlistDefAttFlt(vlistID, CDI_GLOBAL, attname, DATATYPE_FLT32, (int)attlen, attflt);
 	  else
 	    vlistDefAttFlt(vlistID, CDI_GLOBAL, attname, DATATYPE_FLT64, (int)attlen, attflt);
-	  free(attflt);
 	}
     }
 }
@@ -44138,7 +44910,7 @@ void find_time_vars(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimid,
             if ( ncvarid != streamptr->basetime.ncvarid &&
                  ncvars[ncvarid].ndims == 2 &&
                  timedimid == ncvars[ncvarid].dimids[0] &&
-                 !xtypeIsText(ncvars[ncvarid].xtype) &&
+                 xtypeIsText(ncvars[ncvarid].xtype) &&
                  ncdims[ncvars[ncvarid].dimids[1]].len == 19 )
               {
                 streamptr->basetime.ncvarid = ncvarid;
@@ -44180,6 +44952,52 @@ void find_time_vars(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimid,
     }
 }
 
+static
+void read_vct_echam(int fileID, int nvars, ncvar_t *ncvars, ncdim_t *ncdims, double **vct, size_t *pvctsize)
+{
+  /* find ECHAM VCT */
+  int nvcth_id = UNDEFID, vcta_id = UNDEFID, vctb_id = UNDEFID;
+
+  for ( int ncvarid = 0; ncvarid < nvars; ncvarid++ )
+    {
+      if ( ncvars[ncvarid].ndims == 1 )
+        {
+          size_t len = strlen(ncvars[ncvarid].name);
+          if ( len == 4 && ncvars[ncvarid].name[0] == 'h' && ncvars[ncvarid].name[1] == 'y' )
+            {
+              if ( ncvars[ncvarid].name[2] == 'a' && ncvars[ncvarid].name[3] == 'i' ) // hyai
+                {
+                  vcta_id = ncvarid;
+                  nvcth_id = ncvars[ncvarid].dimids[0];
+                  ncvars[ncvarid].isvar = FALSE;
+                }
+              else if ( ncvars[ncvarid].name[2] == 'b' && ncvars[ncvarid].name[3] == 'i' ) //hybi
+                {
+                  vctb_id = ncvarid;
+                  nvcth_id = ncvars[ncvarid].dimids[0];
+                  ncvars[ncvarid].isvar = FALSE;
+                }
+              else if ( (ncvars[ncvarid].name[2] == 'a' || ncvars[ncvarid].name[2] == 'b') && ncvars[ncvarid].name[3] == 'm' )
+                {
+                  ncvars[ncvarid].isvar = FALSE; // hyam or hybm
+                }
+            }
+	}
+    }
+
+  /* read VCT */
+  if ( nvcth_id != UNDEFID && vcta_id != UNDEFID && vctb_id != UNDEFID )
+    {
+      size_t vctsize = ncdims[nvcth_id].len;
+      vctsize *= 2;
+      *vct = (double *) Malloc(vctsize*sizeof(double));
+      cdf_get_var_double(fileID, vcta_id, *vct);
+      cdf_get_var_double(fileID, vctb_id, *vct+vctsize/2);
+      *pvctsize = vctsize;
+    }
+}
+
+
 int cdfInqContents(stream_t *streamptr)
 {
   int ndims, nvars, ngatts, unlimdimid;
@@ -44194,9 +45012,6 @@ int cdfInqContents(stream_t *streamptr)
   int time_climatology = FALSE;
   int leadtime_id = UNDEFID;
   int nvars_data;
-  int nvcth_id = UNDEFID, vcta_id = UNDEFID, vctb_id = UNDEFID;
-  size_t vctsize = 0;
-  double *vct = NULL;
   int instID  = UNDEFID;
   int modelID = UNDEFID;
   int taxisID;
@@ -44238,13 +45053,13 @@ int cdfInqContents(stream_t *streamptr)
     }
 
   /* alloc ncdims */
-  ncdims = (ncdim_t *)xmalloc((size_t)ndims * sizeof (ncdim_t));
+  ncdims = (ncdim_t *) Malloc((size_t)ndims * sizeof (ncdim_t));
   init_ncdims(ndims, ncdims);
 
   if ( nvars > 0 )
     {
       /* alloc ncvars */
-      ncvars = (ncvar_t *)xmalloc((size_t)nvars * sizeof (ncvar_t));
+      ncvars = (ncvar_t *) Malloc((size_t)nvars * sizeof (ncvar_t));
       init_ncvars(nvars, ncvars);
 
       for ( ncvarid = 0; ncvarid < nvars; ++ncvarid )
@@ -44285,7 +45100,7 @@ int cdfInqContents(stream_t *streamptr)
     }
 
   /* scan global attributes */
-  scan_global_attributes(fileID, vlistID, streamptr, ngatts, &instID, &modelID, &ucla_les, 
+  scan_global_attributes(fileID, vlistID, streamptr, ngatts, &instID, &modelID, &ucla_les,
                          uuidOfHGrid, uuidOfVGrid, gridfile, &number_of_grid_used);
 
   /* find time dim */
@@ -44418,7 +45233,7 @@ int cdfInqContents(stream_t *streamptr)
     }
 
   /* verify coordinate vars - first scan (dimname == varname) */
-  verify_coordinate_vars_1(ndims, ncdims, ncvars, timedimid);
+  verify_coordinate_vars_1(fileID, ndims, ncdims, ncvars, timedimid);
 
   /* verify coordinate vars - second scan (all other variables) */
   verify_coordinate_vars_2(nvars, ncvars);
@@ -44489,57 +45304,25 @@ int cdfInqContents(stream_t *streamptr)
   /* set dim type */
   setDimType(nvars, ncvars, ncdims);
 
-  /* find VCT */
-  for ( ncvarid = 0; ncvarid < nvars; ncvarid++ )
-    {
-      if ( ncvars[ncvarid].ndims == 1 )
-	{
-	  if ( memcmp(ncvars[ncvarid].name, "hyai", 4) == 0 )
-	    {
-	      vcta_id = ncvarid;
-	      nvcth_id = ncvars[ncvarid].dimids[0];
-              ncvars[ncvarid].isvar = FALSE;
-	      continue;
-	    }
-	  if ( memcmp(ncvars[ncvarid].name, "hybi", 4) == 0 )
-	    {
-	      vctb_id = ncvarid;
-	      nvcth_id = ncvars[ncvarid].dimids[0];
-              ncvars[ncvarid].isvar = FALSE;
-	      continue;
-	    }
+  /* read ECHAM VCT if present */
+  size_t vctsize = 0;
+  double *vct = NULL;
+  read_vct_echam(fileID, nvars, ncvars, ncdims, &vct, &vctsize);
 
-	  if      ( memcmp(ncvars[ncvarid].name, "hyam", 4) == 0 ) ncvars[ncvarid].isvar = FALSE;
-	  else if ( memcmp(ncvars[ncvarid].name, "hybm", 4) == 0 ) ncvars[ncvarid].isvar = FALSE;
-	}
-    }
 
   if ( CDI_Debug ) printNCvars(ncvars, nvars, "define_all_grids");
 
-
   /* define all grids */
   define_all_grids(streamptr, vlistID, ncdims, nvars, ncvars, timedimid, uuidOfHGrid, gridfile, number_of_grid_used);
 
 
-  /* read VCT */
-  if ( nvcth_id != UNDEFID && vcta_id != UNDEFID && vctb_id != UNDEFID )
-    {
-      vctsize = ncdims[nvcth_id].len;
-      vctsize *= 2;
-      vct = (double *) malloc(vctsize*sizeof(double));
-      cdf_get_var_double(fileID, vcta_id, vct);
-      cdf_get_var_double(fileID, vctb_id, vct+vctsize/2);
-    }
-
-
   /* define all zaxes */
   define_all_zaxes(streamptr, vlistID, ncdims, nvars, ncvars, vctsize, vct, uuidOfVGrid);
+  if ( vct ) Free(vct);
 
 
-  if ( vct ) free(vct);
-
   /* select vars */
-  varids = (int *)xmalloc((size_t)nvars * sizeof (int));
+  varids = (int *) Malloc((size_t)nvars * sizeof (int));
   nvarids = 0;
   for ( ncvarid = 0; ncvarid < nvars; ncvarid++ )
     if ( ncvars[ncvarid].isvar == TRUE ) varids[nvarids++] = ncvarid;
@@ -44569,15 +45352,15 @@ int cdfInqContents(stream_t *streamptr)
   cdiCreateTimesteps(streamptr);
 
   /* time varID */
-  ncvarid = streamptr->basetime.ncvarid;
+  int nctimevarid = streamptr->basetime.ncvarid;
 
   if ( time_has_units )
     {
       taxis_t *taxis = &streamptr->tsteps[0].taxis;
 
-      if ( setBaseTime(ncvars[ncvarid].units, taxis) == 1 )
+      if ( setBaseTime(ncvars[nctimevarid].units, taxis) == 1 )
         {
-          ncvarid = UNDEFID;
+          nctimevarid = UNDEFID;
           streamptr->basetime.ncvarid = UNDEFID;
         }
 
@@ -44601,23 +45384,21 @@ int cdfInqContents(stream_t *streamptr)
       if ( time_climatology ) streamptr->tsteps[0].taxis.climatology = TRUE;
     }
 
-  if ( ncvarid != UNDEFID )
+  if ( nctimevarid != UNDEFID )
     {
       taxis_t *taxis = &streamptr->tsteps[0].taxis;
-      ptaxisDefName(taxis, ncvars[ncvarid].name);
-      if ( ncvars[ncvarid].longname[0] )
-        ptaxisDefLongname(taxis, ncvars[ncvarid].longname);
+      ptaxisDefName(taxis, ncvars[nctimevarid].name);
+      if ( ncvars[nctimevarid].longname[0] )
+        ptaxisDefLongname(taxis, ncvars[nctimevarid].longname);
     }
 
-  if ( ncvarid != UNDEFID )
-    if ( ncvars[ncvarid].calendar == TRUE )
+  if ( nctimevarid != UNDEFID )
+    if ( ncvars[nctimevarid].calendar == TRUE )
       {
-        enum {
-          attstringlen = 8192,
-        };
+        enum {attstringlen = 8192};
         char attstring[attstringlen];
 
-	cdfGetAttText(fileID, ncvarid, "calendar", attstringlen, attstring);
+	cdfGetAttText(fileID, nctimevarid, "calendar", attstringlen, attstring);
 	strtolower(attstring);
 
 	if ( memcmp(attstring, "standard", 8)  == 0 ||
@@ -44663,12 +45444,19 @@ int cdfInqContents(stream_t *streamptr)
       calendar = CALENDAR_STANDARD;
     }
 
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic warning "-Wstrict-overflow"
+#endif
   if ( calendar != UNDEFID )
     {
       taxis_t *taxis = &streamptr->tsteps[0].taxis;
       taxis->calendar = calendar;
       taxisDefCalendar(taxisID, calendar);
     }
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
+#pragma GCC diagnostic pop
+#endif
 
   vlistDefTaxis(vlistID, taxisID);
 
@@ -44680,10 +45468,10 @@ int cdfInqContents(stream_t *streamptr)
   cdfCreateRecords(streamptr, 0);
 
   /* free ncdims */
-  free(ncdims);
+  Free(ncdims);
 
   /* free ncvars */
-  free(ncvars);
+  Free(ncvars);
 
   return (0);
 }
@@ -44744,6 +45532,7 @@ double get_timevalue(int fileID, int nctimevarid, int tsID, timecache_t *tcache)
   return timevalue;
 }
 
+
 int cdfInqTimestep(stream_t * streamptr, int tsID)
 {
   long nrecs = 0;
@@ -44780,7 +45569,7 @@ int cdfInqTimestep(stream_t * streamptr, int tsID)
 #if defined (USE_TIMECACHE)
               if ( streamptr->basetime.timevar_cache == NULL )
                 {
-                  streamptr->basetime.timevar_cache = (timecache_t *) malloc(MAX_TIMECACHE_SIZE*sizeof(timecache_t));
+                  streamptr->basetime.timevar_cache = (timecache_t *) Malloc(MAX_TIMECACHE_SIZE*sizeof(timecache_t));
                   streamptr->basetime.timevar_cache->size = 0;
                   streamptr->basetime.timevar_cache->maxvals = streamptr->ntsteps;
                 }
@@ -44844,8 +45633,6 @@ void cdfEndDef(stream_t *streamptr)
 
       if ( streamptr->ncmode == 2 )
         {
-          extern size_t CDI_netcdf_hdr_pad;
-
           if ( CDI_netcdf_hdr_pad == 0UL )
             cdf_enddef(fileID);
           else
@@ -44990,36 +45777,34 @@ void cdfInqHistoryString(stream_t *streamptr, char *history)
 
 void cdfDefVars(stream_t *streamptr)
 {
-  /* int  nvars, ncvarid; */
-
   int vlistID = streamptr->vlistID;
   if ( vlistID == UNDEFID )
     Error("Internal problem! vlist undefined for streamptr %p", streamptr);
 
-  /* nvars  = vlistNvars(vlistID); */
   int ngrids = vlistNgrids(vlistID);
   int nzaxis = vlistNzaxis(vlistID);
   /*
   if ( vlistHasTime(vlistID) ) cdfDefTime(streamptr);
   */
-  if (ngrids > 0)
-    for (size_t index = 0; index < (size_t)ngrids; index++ )
+  if ( ngrids > 0 )
+    for ( int index = 0; index < ngrids; index++ )
       {
-        int gridID = vlistGrid(vlistID, (int)index);
+        int gridID = vlistGrid(vlistID, index);
         cdfDefGrid(streamptr, gridID);
       }
 
-  if (nzaxis > 0)
-    for (size_t index = 0; index < (size_t)nzaxis; index++ )
+  if ( nzaxis > 0 )
+    for ( int index = 0; index < nzaxis; index++ )
       {
-        int zaxisID = vlistZaxis(vlistID, (int)index);
+        int zaxisID = vlistZaxis(vlistID, index);
         if ( streamptr->zaxisID[index] == UNDEFID ) cdfDefZaxis(streamptr, zaxisID);
       }
-  /*
-    define time first!!!
-  for (varID = 0; varID < nvars; varID++ )
+
+  /* define time first!!!
+    int nvars  = vlistNvars(vlistID);
+  for ( int varID = 0; varID < nvars; varID++ )
     {
-      ncvarid = cdfDefVar(streamptr, varID);
+      int ncvarid = cdfDefVar(streamptr, varID);
     }
   */
 }
@@ -45033,12 +45818,49 @@ void cdfDefVars(stream_t *streamptr)
  * require-trailing-newline: t
  * End:
  */
+#ifndef CDI_DATETIME_H
+#define CDI_DATETIME_H
+
 typedef struct
 {
   long date;
   long time;
 }
 DateTime;
+
+static inline int
+datetimeCmp(DateTime dt1, DateTime dt2)
+{
+  return 2 * ((dt1.date > dt2.date) - (dt1.date < dt2.date))
+    + (dt1.time > dt2.time) - (dt1.time < dt2.time);
+}
+
+
+#endif
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
+#ifndef _STREAM_CGRIBEX_H
+#define _STREAM_CGRIBEX_H
+
+int cgribexScanTimestep1(stream_t * streamptr);
+int cgribexScanTimestep2(stream_t * streamptr);
+int cgribexScanTimestep(stream_t * streamptr);
+
+int cgribexDecode(unsigned char *gribbuffer, int gribsize, double *data, int gridsize,
+		  int unreduced, int *nmiss, double missval);
+
+size_t cgribexEncode(int memtype, int varID, int levelID, int vlistID, int gridID, int zaxisID,
+		     int vdate, int vtime, int tsteptype, int numavg, 
+		     long datasize, const double *data, int nmiss, unsigned char *gribbuffer, size_t gribbuffersize);
+
+#endif  /* _STREAM_CGRIBEX_H */
 /*
  * Local Variables:
  * c-file-style: "Java"
@@ -45051,6 +45873,7 @@ DateTime;
 #if defined (HAVE_CONFIG_H)
 #endif
 
+#include <limits.h>
 #include <stdio.h>
 // #include <float.h>  /* FLT_EPSILON */
 
@@ -45058,8 +45881,6 @@ DateTime;
 #if  defined  (HAVE_LIBCGRIBEX)
 #endif
 
-extern int cdiInventoryMode;
-
 typedef struct {
   int param;
   int level1;
@@ -45388,7 +46209,7 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
       grid->isRotated = TRUE;
       grid->ypole     = - ISEC2_LatSP*0.001;
       grid->xpole     =   ISEC2_LonSP*0.001 - 180;
-      grid->angle     = FSEC2_RotAngle;
+      grid->angle     = - FSEC2_RotAngle;
     }
 
   grid->xvals = NULL;
@@ -45445,10 +46266,11 @@ void cgribexAddRecord(stream_t * streamptr, int param, int *isec1, int *isec2, d
   if ( datatype <  0 ) datatype = DATATYPE_PACK;
 
   varAddRecord(recID, param, gridID, zaxistype, lbounds, level1, level2, 0, 0,
-	       datatype, &varID, &levelID, tsteptype, numavg, ISEC1_LevelType, -1, NULL, NULL, NULL, NULL);
+	       datatype, &varID, &levelID, tsteptype, numavg, ISEC1_LevelType, -1,
+               NULL, NULL, NULL, NULL, NULL, NULL);
 
-  (*record).varID   = (short)varID;
-  (*record).levelID = (short)levelID;
+  record->varID   = (short)varID;
+  record->levelID = (short)levelID;
 
   varDefCompType(varID, comptype);
 
@@ -45617,18 +46439,15 @@ cgribexScanTsConstAdjust(stream_t *streamptr, taxis_t *taxis)
 
 int cgribexScanTimestep1(stream_t * streamptr)
 {
-  int *isec0, *isec1, *isec2, *isec3, *isec4;
   double fsec2[512], fsec3[2], *fsec4 = NULL;
   int lmv = 0, iret = 0;
   off_t recpos = 0;
-  unsigned char *gribbuffer = NULL;
+  void *gribbuffer = NULL;
   size_t buffersize = 0;
   int rstatus;
-  int fileID;
   int param = 0;
   int level1 = 0, level2 = 0, vdate = 0, vtime = 0;
-  DateTime datetime, datetime0;
-  int tsID;
+  DateTime datetime, datetime0 = { LONG_MIN, LONG_MIN };
   size_t readsize;
   unsigned nrecords, recID;
   int nrecs_scanned = 0;
@@ -45638,29 +46457,27 @@ int cgribexScanTimestep1(stream_t * streamptr)
   int warn_numavg = TRUE;
   int taxisID = -1;
   int rdate = 0, rtime = 0, tunit = 0, fcast = 0;
-  taxis_t *taxis;
   int vlistID;
   int comptype;
   long unzipsize;
   char paramstr[32];
-  extern int cdiSkipRecords;
   int nskip = cdiSkipRecords;
 
   streamptr->curTsID = 0;
 
-  isec0 = streamptr->record->sec0;
-  isec1 = streamptr->record->sec1;
-  isec2 = streamptr->record->sec2;
-  isec3 = streamptr->record->sec3;
-  isec4 = streamptr->record->sec4;
+  int *isec0 = streamptr->record->sec0;
+  int *isec1 = streamptr->record->sec1;
+  int *isec2 = streamptr->record->sec2;
+  int *isec3 = streamptr->record->sec3;
+  int *isec4 = streamptr->record->sec4;
 
-  tsID  = tstepsNewEntry(streamptr);
-  taxis = &streamptr->tsteps[tsID].taxis;
+  int tsID  = tstepsNewEntry(streamptr);
+  taxis_t *taxis = &streamptr->tsteps[tsID].taxis;
 
   if ( tsID != 0 )
     Error("Internal problem! tstepsNewEntry returns %d", tsID);
 
-  fileID = streamptr->fileID;
+  int fileID = streamptr->fileID;
 
   while ( nskip-- > 0 )
     {
@@ -45689,22 +46506,22 @@ int cgribexScanTimestep1(stream_t * streamptr)
       if ( (size_t)recsize > buffersize )
 	{
 	  buffersize = (size_t)recsize;
-	  gribbuffer = (unsigned char *)xrealloc(gribbuffer, buffersize);
+	  gribbuffer = Realloc(gribbuffer, buffersize);
 	}
 
       readsize = (size_t)recsize;
-      rstatus = gribRead(fileID, gribbuffer, &readsize);
+      rstatus = gribRead(fileID, (unsigned char *)gribbuffer, &readsize);
       if ( rstatus ) break;
 
       comptype = COMPRESS_NONE;
-      if ( gribGetZip(recsize, gribbuffer, &unzipsize) > 0 )
+      if ( gribGetZip(recsize, (unsigned char *)gribbuffer, &unzipsize) > 0 )
 	{
 	  comptype = COMPRESS_SZIP;
 	  unzipsize += 100; /* need 0 to 1 bytes for rounding of bds */
 	  if ( buffersize < (size_t)unzipsize )
 	    {
 	      buffersize = (size_t)unzipsize;
-	      gribbuffer = (unsigned char *) realloc(gribbuffer, buffersize);
+	      gribbuffer = Realloc(gribbuffer, buffersize);
 	    }
 	}
 
@@ -45740,9 +46557,7 @@ int cgribexScanTimestep1(stream_t * streamptr)
 	{
 	  datetime.date  = vdate;
 	  datetime.time  = vtime;
-
 	  compvar_t compVar = cgribexVarSet(param, level1, level2, ISEC1_LevelType, ISEC1_TimeRange);
-
 	  for ( recID = 0; recID < nrecs; recID++ )
 	    {
 	      if ( cgribexVarCompare(compVar, streamptr->tsteps[0].records[recID], 0) == 0 ) break;
@@ -45752,7 +46567,7 @@ int cgribexScanTimestep1(stream_t * streamptr)
 	    {
 	      if ( recID < nrecs ) break;
 	      if ( warn_time )
-		if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) != 0 )
+		if ( datetimeCmp(datetime, datetime0) != 0 )
 		  {
                     gribWarning("Inconsistent verification time!", nrecs_scanned, tsID+1, paramstr, level1, level2);
 		    warn_time = FALSE;
@@ -45760,7 +46575,7 @@ int cgribexScanTimestep1(stream_t * streamptr)
 	    }
 	  else
 	    {
-	      if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) != 0 ) break;
+	      if ( datetimeCmp(datetime, datetime0) != 0 ) break;
 
 	      if ( recID < nrecs )
 		{
@@ -45824,10 +46639,10 @@ int cgribexScanTimestep1(stream_t * streamptr)
     {
       streamptr->tsteps[0].recordSize = (int)nrecords;
       streamptr->tsteps[0].records =
-      (record_t *) realloc(streamptr->tsteps[0].records, nrecords*sizeof(record_t));
+      (record_t *) Realloc(streamptr->tsteps[0].records, nrecords*sizeof(record_t));
     }
 
-  streamptr->tsteps[0].recIDs = (int *) malloc(nrecords*sizeof(int));
+  streamptr->tsteps[0].recIDs = (int *) Malloc(nrecords*sizeof(int));
   streamptr->tsteps[0].nrecs = (int)nrecords;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[0].recIDs[recID] = (int)recID;
@@ -45845,57 +46660,48 @@ int cgribexScanTimestep1(stream_t * streamptr)
 int cgribexScanTimestep2(stream_t * streamptr)
 {
   int rstatus = 0;
-  int *isec0, *isec1, *isec2, *isec3, *isec4;
   double fsec2[512], fsec3[2], *fsec4 = NULL;
   int lmv = 0, iret = 0;
   off_t recpos = 0;
-  unsigned char *gribbuffer = NULL;
-  size_t buffersize = 0;
-  int fileID;
   int param = 0;
   int level1 = 0, level2 = 0, vdate = 0, vtime = 0;
-  DateTime datetime, datetime0;
-  int tsID;
+  DateTime datetime, datetime0 = { LONG_MIN, LONG_MIN };
   int varID, gridID;
   size_t readsize;
-  int nrecords, nrecs, recID, rindex;
-  int nrecs_scanned = 0;
+  int nrecs, recID;
   long recsize = 0;
   int warn_numavg = TRUE;
   int tsteptype;
-  int taxisID = -1;
-  taxis_t *taxis;
-  int vlistID;
   long unzipsize;
   char paramstr[32];
 
   streamptr->curTsID = 1;
 
-  isec0 = streamptr->record->sec0;
-  isec1 = streamptr->record->sec1;
-  isec2 = streamptr->record->sec2;
-  isec3 = streamptr->record->sec3;
-  isec4 = streamptr->record->sec4;
+  int *isec0 = streamptr->record->sec0;
+  int *isec1 = streamptr->record->sec1;
+  int *isec2 = streamptr->record->sec2;
+  int *isec3 = streamptr->record->sec3;
+  int *isec4 = streamptr->record->sec4;
 
-  fileID  = streamptr->fileID;
-  vlistID = streamptr->vlistID;
-  taxisID = vlistInqTaxis(vlistID);
+  int fileID  = streamptr->fileID;
+  int vlistID = streamptr->vlistID;
+  int taxisID = vlistInqTaxis(vlistID);
 
-  gribbuffer = (unsigned char *) streamptr->record->buffer;
-  buffersize = streamptr->record->buffersize;
+  void *gribbuffer = streamptr->record->buffer;
+  size_t buffersize = streamptr->record->buffersize;
 
-  tsID = streamptr->rtsteps;
+  int tsID = streamptr->rtsteps;
   if ( tsID != 1 )
     Error("Internal problem! unexpected timestep %d", tsID+1);
 
-  taxis = &streamptr->tsteps[tsID].taxis;
+  taxis_t *taxis = &streamptr->tsteps[tsID].taxis;
 
   fileSetPos(fileID, streamptr->tsteps[tsID].position, SEEK_SET);
 
   cdi_create_records(streamptr, tsID);
 
-  nrecords = streamptr->tsteps[tsID].nallrecs;
-  if ( nrecords ) streamptr->tsteps[1].recIDs = (int *)xmalloc((size_t)nrecords * sizeof(int));
+  int nrecords = streamptr->tsteps[tsID].nallrecs;
+  if ( nrecords ) streamptr->tsteps[1].recIDs = (int *) Malloc((size_t)nrecords * sizeof(int));
   streamptr->tsteps[1].nrecs = 0;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[1].recIDs[recID] = -1;
@@ -45907,8 +46713,8 @@ int cgribexScanTimestep2(stream_t * streamptr)
       streamptr->tsteps[tsID].records[recID].size     =	streamptr->tsteps[0].records[recID].size;
     }
 
-  nrecs_scanned = nrecords;
-  rindex = 0;
+  int nrecs_scanned = nrecords;
+  int rindex = 0;
   while ( TRUE )
     {
       if ( rindex > nrecords ) break;
@@ -45923,20 +46729,20 @@ int cgribexScanTimestep2(stream_t * streamptr)
       if ( (size_t)recsize > buffersize )
 	{
 	  buffersize = (size_t)recsize;
-	  gribbuffer = (unsigned char *)xrealloc(gribbuffer, buffersize);
+	  gribbuffer = Realloc(gribbuffer, buffersize);
 	}
 
       readsize = (size_t)recsize;
-      rstatus = gribRead(fileID, gribbuffer, &readsize);
+      rstatus = gribRead(fileID, (unsigned char *)gribbuffer, &readsize);
       if ( rstatus ) break;
 
-      if ( gribGetZip(recsize, gribbuffer, &unzipsize) > 0 )
+      if ( gribGetZip(recsize, (unsigned char *)gribbuffer, &unzipsize) > 0 )
 	{
 	  unzipsize += 100; /* need 0 to 1 bytes for rounding of bds */
 	  if ( buffersize < (size_t)unzipsize )
 	    {
 	      buffersize = (size_t)unzipsize;
-	      gribbuffer = (unsigned char *) realloc(gribbuffer, buffersize);
+	      gribbuffer = Realloc(gribbuffer, buffersize);
 	    }
 	}
 
@@ -46025,7 +46831,7 @@ int cgribexScanTimestep2(stream_t * streamptr)
 	{
 	  if ( streamptr->tsteps[tsID].records[recID].used )
 	    {
-	      if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) != 0 ) break;
+	      if ( datetimeCmp(datetime, datetime0) != 0 ) break;
 
               gribWarning("Parameter already exist, skipped!", nrecs_scanned, tsID+1, paramstr, level1, level2);
 	      continue;
@@ -46102,12 +46908,12 @@ int cgribexScanTimestep(stream_t * streamptr)
   int lmv = 0, iret = 0;
   long recsize = 0;
   off_t recpos = 0;
-  unsigned char *gribbuffer;
+  void *gribbuffer;
   size_t buffersize = 0;
   int fileID;
   int param = 0;
   int level1 = 0, level2 = 0, vdate = 0, vtime = 0;
-  DateTime datetime, datetime0;
+  DateTime datetime, datetime0 = { LONG_MIN, LONG_MIN };
   int vrecID, recID;
   int warn_numavg = TRUE;
   size_t readsize;
@@ -46137,7 +46943,7 @@ int cgribexScanTimestep(stream_t * streamptr)
 
   if ( streamptr->tsteps[tsID].recordSize == 0 )
     {
-      gribbuffer = (unsigned char *) streamptr->record->buffer;
+      gribbuffer = streamptr->record->buffer;
       buffersize = streamptr->record->buffersize;
 
       cdi_create_records(streamptr, tsID);
@@ -46145,7 +46951,7 @@ int cgribexScanTimestep(stream_t * streamptr)
       nrecs = streamptr->tsteps[1].nrecs;
 
       streamptr->tsteps[tsID].nrecs = nrecs;
-      streamptr->tsteps[tsID].recIDs = (int *)xmalloc((size_t)nrecs * sizeof (int));
+      streamptr->tsteps[tsID].recIDs = (int *) Malloc((size_t)nrecs * sizeof (int));
       for ( recID = 0; recID < nrecs; recID++ )
 	streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
 
@@ -46169,13 +46975,13 @@ int cgribexScanTimestep(stream_t * streamptr)
 	  if ( recsize > 0 && (size_t)recsize > buffersize )
 	    {
 	      buffersize = (size_t)recsize;
-	      gribbuffer = (unsigned char *) realloc(gribbuffer, buffersize);
+	      gribbuffer = Realloc(gribbuffer, buffersize);
 	    }
 
 	  if ( rindex >= nrecs ) break;
 
 	  readsize = (size_t)recsize;
-	  rstatus = gribRead(fileID, gribbuffer, &readsize);
+	  rstatus = gribRead(fileID, (unsigned char *)gribbuffer, &readsize);
 	  if ( rstatus )
 	    {
 	      Warning("Inconsistent timestep %d (GRIB record %d/%d)!", tsID+1, rindex+1,
@@ -46183,13 +46989,13 @@ int cgribexScanTimestep(stream_t * streamptr)
 	      break;
 	    }
 
-	  if ( gribGetZip(recsize, gribbuffer, &unzipsize) > 0 )
+	  if ( gribGetZip(recsize, (unsigned char *)gribbuffer, &unzipsize) > 0 )
 	    {
 	      unzipsize += 100; /* need 0 to 1 bytes for rounding of bds */
 	      if ( buffersize < (size_t)unzipsize )
 		{
 		  buffersize = (size_t)unzipsize;
-		  gribbuffer = (unsigned char *) realloc(gribbuffer, buffersize);
+		  gribbuffer = Realloc(gribbuffer, buffersize);
 		}
 	    }
 
@@ -46278,13 +47084,13 @@ int cgribexScanTimestep(stream_t * streamptr)
 	    {
 	      if ( streamptr->tsteps[tsID].records[recID].used )
 		{
-		  char paramstr[32];
-		  cdiParamToString(param, paramstr, sizeof(paramstr));
+		  char paramstr_[32];
+		  cdiParamToString(param, paramstr_, sizeof(paramstr_));
 
-		  if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) != 0 ) break;
+		  if ( datetimeCmp(datetime, datetime0) != 0 ) break;
 
 		  if ( CDI_Debug )
-                    gribWarning("Parameter already exist, skipped!", nrecs_scanned, tsID+1, paramstr, level1, level2);
+                    gribWarning("Parameter already exist, skipped!", nrecs_scanned, tsID+1, paramstr_, level1, level2);
 
 		  continue;
 		}
@@ -46378,7 +47184,7 @@ int cgribexDecode(unsigned char *gribbuffer, int gribsize, double *data, int gri
   FSEC3_MissVal = missval;
 
   gribExDP(isec0, isec1, isec2, fsec2, isec3, fsec3, isec4, data,
-	   gridsize, (int *) gribbuffer, gribsize, &iword, hoper, &iret);
+	   gridsize, (int *)(void *)gribbuffer, gribsize, &iword, hoper, &iret);
 
   if ( ISEC1_Sec2Or3Flag & 64 )
     *nmiss = ISEC4_NumValues - ISEC4_NumNonMissValues;
@@ -46461,7 +47267,7 @@ void cgribexDefParam(int *isec1, int param)
   static bool lwarn_pnum = true;
   if ( pnum > 255 && lwarn_pnum )
     {
-      Warning("Parameter number %d out of bounds (1-255), set to %d!", pnum, pnum%256);
+      Warning("Parameter number %d out of range (1-255), set to %d!", pnum, pnum%256);
       lwarn_pnum = false;
       pnum = pnum%256;
     }
@@ -46489,7 +47295,7 @@ int cgribexDefTimerange(int tsteptype, int factor, int calendar,
 
   (void) julday_sub(julday1, secofday1, julday2, secofday2, &days, &secs);
 
-  if ( !(int) fmod(days*86400.0 + secs, factor) )
+  if ( !(int)(fmod(days*86400.0 + secs, factor)) )
     {
       ip = (int) ((days*86400.0 + secs)/factor);
 
@@ -46800,7 +47606,9 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI
 	  {
 	    ISEC2_LatSP = - (int)lround(gridInqYpole(gridID) * 1000);
 	    ISEC2_LonSP =   (int)lround((gridInqXpole(gridID) + 180) * 1000);
-            FSEC2_RotAngle = gridInqAngle(gridID);
+            double angle = gridInqAngle(gridID);
+            if ( fabs(angle) > 0 ) angle = -angle;
+            FSEC2_RotAngle = angle;
 	  }
 
 	/* East -> West */
@@ -46915,7 +47723,7 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
     case ZAXIS_SURFACE:
       {
 	ISEC1_LevelType = GRIB1_LTYPE_SURFACE;
-	ISEC1_Level1    = (int) zaxisInqLevel(zaxisID, levelID);
+	ISEC1_Level1    = (int)(zaxisInqLevel(zaxisID, levelID));
 	ISEC1_Level2    = 0;
 	break;
       }
@@ -46964,7 +47772,7 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
     case ZAXIS_MEANSEA:
       {
 	ISEC1_LevelType = GRIB1_LTYPE_MEANSEA;
-	ISEC1_Level1    = (int) zaxisInqLevel(zaxisID, levelID);
+	ISEC1_Level1    = (int)(zaxisInqLevel(zaxisID, levelID));
 	ISEC1_Level2    = 0;
 	break;
       }
@@ -46976,13 +47784,13 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
 	if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
 	  {
 	    ISEC1_LevelType = GRIB1_LTYPE_HYBRID_LAYER;
-	    ISEC1_Level1    = (int) zaxisInqLbound(zaxisID, levelID);
-	    ISEC1_Level2    = (int) zaxisInqUbound(zaxisID, levelID);
+	    ISEC1_Level1    = (int)(zaxisInqLbound(zaxisID, levelID));
+	    ISEC1_Level2    = (int)(zaxisInqUbound(zaxisID, levelID));
 	  }
 	else
 	  {
 	    ISEC1_LevelType = GRIB1_LTYPE_HYBRID;
-	    ISEC1_Level1    = (int) zaxisInqLevel(zaxisID, levelID);
+	    ISEC1_Level1    = (int)(zaxisInqLevel(zaxisID, levelID));
 	    ISEC1_Level2    = 0;
 	  }
 
@@ -47018,7 +47826,7 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
 	  Warning("Pressure level of %f Pa is below zero!", level);
 
 	zaxisInqUnits(zaxisID, units);
-	if ( memcmp(units, "Pa", 2) != 0 ) level *= 100;
+	if ( (units[0] != 'P') | (units[1] != 'a') ) level *= 100;
 
 	ilevel = (int) level;
 	if ( level < 32768 && (level < 100 || modf(level/100, &dum) > 0) )
@@ -47062,8 +47870,8 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
 	if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
 	  {
 	    ISEC1_LevelType = GRIB1_LTYPE_SIGMA_LAYER;
-	    ISEC1_Level1    = (int) zaxisInqLbound(zaxisID, levelID);
-	    ISEC1_Level2    = (int) zaxisInqUbound(zaxisID, levelID);
+	    ISEC1_Level1    = (int)(zaxisInqLbound(zaxisID, levelID));
+	    ISEC1_Level2    = (int)(zaxisInqUbound(zaxisID, levelID));
 	  }
 	else
 	  {
@@ -47084,10 +47892,10 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
 
 	zaxisInqUnits(zaxisID, units);
 
-        if      ( memcmp(units, "mm", 2) == 0 ) factor =   0.1;
-        else if ( memcmp(units, "cm", 2) == 0 ) factor =   1;
-        else if ( memcmp(units, "dm", 2) == 0 ) factor =  10;
-        else                                    factor = 100; // meter
+        if      ( units[0] == 'm' && units[1] == 'm' ) factor =   0.1;
+        else if ( units[0] == 'c' && units[1] == 'm' ) factor =   1;
+        else if ( units[0] == 'd' && units[1] == 'm' ) factor =  10;
+        else                                           factor = 100; // meter
 
 	if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
 	  {
@@ -47266,10 +48074,10 @@ size_t cgribexEncode(int memtype, int varID, int levelID, int vlistID, int gridI
 
   if ( memtype == MEMTYPE_FLOAT )
     gribExSP(isec0, isec1, isec2, fsec2f, isec3, fsec3f, isec4, (float*) data,
-             (int)datasize, (int *) gribbuffer, gribsize, &iword, "C", &iret);
+             (int)datasize, (int *)(void *)gribbuffer, gribsize, &iword, "C", &iret);
   else
     gribExDP(isec0, isec1, isec2, fsec2, isec3, fsec3, isec4, (double*) data,
-             (int)datasize, (int *) gribbuffer, gribsize, &iword, "C", &iret);
+             (int)datasize, (int *)(void *)gribbuffer, gribsize, &iword, "C", &iret);
 
   if ( iret ) Error("Problem during GRIB encode (errno = %d)!", iret);
 
@@ -47286,9 +48094,29 @@ size_t cgribexEncode(int memtype, int varID, int levelID, int vlistID, int gridI
  * require-trailing-newline: t
  * End:
  */
+#ifndef STREAM_FCOMMON_H
+#define STREAM_FCOMMON_H
+
+#ifndef  _CDI_INT_H
+#endif
+
+void streamFCopyRecord(stream_t *streamptr2, stream_t *streamptr1,
+                       const char *container_name);
+
+#endif
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #if defined (HAVE_CONFIG_H)
 #endif
 
+#include <limits.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -47356,7 +48184,7 @@ int extInqRecord(stream_t *streamptr, int *varID, int *levelID)
   int zaxisID = -1;
   int header[4];
   int vlistID;
-  extrec_t *extp = (extrec_t*) streamptr->record->exsep;
+  void *extp = streamptr->record->exsep;
 
   vlistID = streamptr->vlistID;
   fileID  = streamptr->fileID;
@@ -47394,7 +48222,7 @@ void extReadRecord(stream_t *streamptr, double *data, int *nmiss)
   int varID, gridID;
   int i, size;
   double missval;
-  extrec_t *extp = (extrec_t*) streamptr->record->exsep;
+  void *extp = streamptr->record->exsep;
 
   vlistID = streamptr->vlistID;
   fileID  = streamptr->fileID;
@@ -47471,7 +48299,7 @@ void extDefRecord(stream_t *streamptr)
 void extWriteRecord(stream_t *streamptr, const double *data)
 {
   int fileID = streamptr->fileID;
-  extrec_t *extp = (extrec_t*) streamptr->record->exsep;
+  void *extp = streamptr->record->exsep;
 
   extDefDataDP(extp, data);
   extWrite(fileID, extp);
@@ -47514,7 +48342,8 @@ void extAddRecord(stream_t *streamptr, int param, int level, int xysize,
   leveltype = ZAXIS_GENERIC;
 
   varAddRecord(recID, param, gridID, leveltype, 0, level, 0, 0, 0,
-	       extInqDatatype(prec, number), &varID, &levelID, TSTEP_INSTANT, 0, 0, -1, NULL, NULL, NULL, NULL);
+	       extInqDatatype(prec, number), &varID, &levelID, TSTEP_INSTANT, 0, 0, -1,
+               NULL, NULL, NULL, NULL, NULL, NULL);
 
   (*record).varID   = (short)varID;
   (*record).levelID = (short)levelID;
@@ -47536,7 +48365,7 @@ void extScanTimestep1(stream_t *streamptr)
   int rxysize = 0;
   int param = 0;
   int rcode = 0, rlevel = 0, vdate = 0, vtime = 0;
-  DateTime datetime, datetime0;
+  DateTime datetime0 = { LONG_MIN, LONG_MIN };
   int tsID;
   int varID;
   long recsize;
@@ -47587,8 +48416,6 @@ void extScanTimestep1(stream_t *streamptr)
 	}
       else
 	{
-	  datetime.date = vdate;
-	  datetime.time = vtime;
 	  compVar.param = param;
           compVar.level = rlevel;
 	  for ( recID = 0; recID < nrecs; recID++ )
@@ -47599,7 +48426,8 @@ void extScanTimestep1(stream_t *streamptr)
 	      if ( memcmp(&compVar0, &compVar, sizeof(extcompvar_t)) == 0 ) break;
 	    }
 	  if ( recID < nrecs ) break;
-	  if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) )
+	  DateTime datetime = { .date = vdate, .time = vtime};
+	  if ( datetimeCmp(datetime, datetime0) )
 	    Warning("Inconsistent verification time for code %d level %d", rcode, rlevel);
 	}
 
@@ -47630,10 +48458,10 @@ void extScanTimestep1(stream_t *streamptr)
     {
       streamptr->tsteps[0].recordSize = nrecords;
       streamptr->tsteps[0].records =
-        (record_t *)xrealloc(streamptr->tsteps[0].records, (size_t)nrecords * sizeof (record_t));
+        (record_t *) Realloc(streamptr->tsteps[0].records, (size_t)nrecords * sizeof (record_t));
     }
 
-  streamptr->tsteps[0].recIDs = (int *)xmalloc((size_t)nrecords * sizeof (int));
+  streamptr->tsteps[0].recIDs = (int *) Malloc((size_t)nrecords * sizeof (int));
   streamptr->tsteps[0].nrecs = nrecords;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[0].recIDs[recID] = recID;
@@ -47678,7 +48506,7 @@ int extScanTimestep2(stream_t *streamptr)
   taxis_t *taxis;
   int vlistID;
   extcompvar_t compVar, compVar0;
-  extrec_t *extp = (extrec_t*) streamptr->record->exsep;
+  void *extp = streamptr->record->exsep;
 
   streamptr->curTsID = 1;
 
@@ -47696,7 +48524,7 @@ int extScanTimestep2(stream_t *streamptr)
   cdi_create_records(streamptr, tsID);
 
   nrecords = streamptr->tsteps[0].nallrecs;
-  streamptr->tsteps[1].recIDs = xmalloc((size_t)nrecords * sizeof (int));
+  streamptr->tsteps[1].recIDs = (int *) Malloc((size_t)nrecords * sizeof (int));
   streamptr->tsteps[1].nrecs = 0;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[1].recIDs[recID] = -1;
@@ -47850,7 +48678,7 @@ long extScanTimestep(stream_t *streamptr)
   int recID;
   int rindex, nrecs = 0;
   extcompvar_t compVar, compVar0;
-  extrec_t *extp = (extrec_t*) streamptr->record->exsep;
+  void *extp = streamptr->record->exsep;
   /*
   if ( CDI_Debug )
     {
@@ -47871,7 +48699,7 @@ long extScanTimestep(stream_t *streamptr)
       nrecs = streamptr->tsteps[1].nrecs;
 
       streamptr->tsteps[tsID].nrecs = nrecs;
-      streamptr->tsteps[tsID].recIDs = (int *)xmalloc((size_t)nrecs * sizeof (int));
+      streamptr->tsteps[tsID].recIDs = (int *) Malloc((size_t)nrecs * sizeof (int));
       for ( recID = 0; recID < nrecs; recID++ )
 	streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
 
@@ -47997,11 +48825,12 @@ void extReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
   int recID;
   int i;
   double missval;
-  extrec_t *extp = (extrec_t*) streamptr->record->exsep;
+  void *extp = streamptr->record->exsep;
 
   vlistID  = streamptr->vlistID;
   fileID   = streamptr->fileID;
-  nlevs    = streamptr->vars[varID].nlevs;
+  /* NOTE: tiles are not supported here! */
+  nlevs    = streamptr->vars[varID].recordTable[0].nlevs;
   missval  = vlistInqVarMissval(vlistID, varID);
   gridID   = vlistInqVarGrid(vlistID, varID);
   gridsize = gridInqSize(gridID);
@@ -48014,7 +48843,8 @@ void extReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
 
   for (levID = 0; levID < nlevs; levID++)
     {
-      recID = streamptr->vars[varID].level[levID];
+      /* NOTE: tiles are not supported here! */
+      recID = streamptr->vars[varID].recordTable[0].recordID[levID];
       recpos = streamptr->tsteps[tsid].records[recID].position;
       fileSetPos(fileID, recpos, SEEK_SET);
       extRead(fileID, extp);
@@ -48055,11 +48885,12 @@ void extReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data,
   int recID;
   int i;
   double missval;
-  extrec_t *extp = (extrec_t*) streamptr->record->exsep;
+  void *extp = streamptr->record->exsep;
 
   vlistID  = streamptr->vlistID;
   fileID   = streamptr->fileID;
-  nlevs    = streamptr->vars[varID].nlevs;
+  /* NOTE: tiles are not supported here! */
+  nlevs    = streamptr->vars[varID].recordTable[0].nlevs;
   missval  = vlistInqVarMissval(vlistID, varID);
   gridID   = vlistInqVarGrid(vlistID, varID);
   gridsize = gridInqSize(gridID);
@@ -48071,7 +48902,8 @@ void extReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data,
 
   currentfilepos = fileGetPos(fileID);
 
-  recID = streamptr->vars[varID].level[levID];
+  /* NOTE: tiles are not supported here! */
+  recID = streamptr->vars[varID].recordTable[0].recordID[levID];
   recpos = streamptr->tsteps[tsid].records[recID].position;
   fileSetPos(fileID, recpos, SEEK_SET);
   extRead(fileID, extp);
@@ -48212,7 +49044,7 @@ void streamFCopyRecord(stream_t *streamptr2, stream_t *streamptr1,
   if (fileSetPos(fileID1, recpos, SEEK_SET) != 0)
     Error("Cannot seek input file for %s record copy!", container_name);
 
-  char *buffer = xmalloc(recsize);
+  char *buffer = (char *) Malloc(recsize);
 
   if (fileRead(fileID1, buffer, recsize) != recsize)
     Error("Failed to read record from %s file for copying!", container_name);
@@ -48220,7 +49052,7 @@ void streamFCopyRecord(stream_t *streamptr2, stream_t *streamptr1,
   if (fileWrite(fileID2, buffer, recsize) != recsize)
     Error("Failed to write record to %s file when copying!", container_name);
 
-  free(buffer);
+  Free(buffer);
 }
 
 /*
@@ -48232,36 +49064,9 @@ void streamFCopyRecord(stream_t *streamptr2, stream_t *streamptr1,
  * require-trailing-newline: t
  * End:
  */
-#ifndef _STREAM_CGRIBEX_H
-#define _STREAM_CGRIBEX_H
-
-int cgribexScanTimestep1(stream_t * streamptr);
-int cgribexScanTimestep2(stream_t * streamptr);
-int cgribexScanTimestep(stream_t * streamptr);
-
-int cgribexDecode(unsigned char *gribbuffer, int gribsize, double *data, int gridsize,
-		  int unreduced, int *nmiss, double missval);
-
-size_t cgribexEncode(int memtype, int varID, int levelID, int vlistID, int gridID, int zaxisID,
-		     int vdate, int vtime, int tsteptype, int numavg, 
-		     long datasize, const double *data, int nmiss, unsigned char *gribbuffer, size_t gribbuffersize);
-
-#endif  /* _STREAM_CGRIBEX_H */
-/*
- * Local Variables:
- * c-file-style: "Java"
- * c-basic-offset: 2
- * indent-tabs-mode: nil
- * show-trailing-whitespace: t
- * require-trailing-newline: t
- * End:
- */
 #ifndef _STREAM_GRIBAPI_H
 #define _STREAM_GRIBAPI_H
 
-#ifndef  _CDI_INT_H
-#endif
-
 int gribapiScanTimestep1(stream_t * streamptr);
 int gribapiScanTimestep2(stream_t * streamptr);
 int gribapiScanTimestep(stream_t * streamptr);
@@ -48292,6 +49097,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
 
 
 
+
 int grib1ltypeToZaxisType(int grib_ltype)
 {
   int zaxistype = ZAXIS_GENERIC;
@@ -48494,7 +49300,7 @@ int grbDecode(int filetype, unsigned char *gribbuffer, int gribsize, double *dat
 }
 
 
-int grbUnzipRecord(unsigned char *gribbuffer, size_t *gribsize)
+static int grbUnzipRecord(unsigned char *gribbuffer, size_t *gribsize)
 {
   int zip = 0;
   int izip;
@@ -48522,7 +49328,7 @@ int grbUnzipRecord(unsigned char *gribbuffer, size_t *gribsize)
 	  if ( itmpbuffersize < igribsize )
 	    {
 	      itmpbuffersize = igribsize;
-	      itmpbuffer = (unsigned char *) realloc(itmpbuffer, itmpbuffersize);
+	      itmpbuffer = (unsigned char *) Realloc(itmpbuffer, itmpbuffersize);
 	    }
 
 	  memcpy(itmpbuffer, gribbuffer, itmpbuffersize);
@@ -48531,7 +49337,7 @@ int grbUnzipRecord(unsigned char *gribbuffer, size_t *gribsize)
 
 	  ogribsize = (size_t)gribUnzip(gribbuffer, unzipsize, itmpbuffer, (long)igribsize);
 
-	  free(itmpbuffer);
+	  Free(itmpbuffer);
 
 	  if ( ogribsize <= 0 ) Error("Decompression problem!");
 	}
@@ -48582,21 +49388,20 @@ void grbReadRecord(stream_t * streamptr, double *data, int *nmiss)
 static
 int grbScanTimestep1(stream_t * streamptr)
 {
-  int status;
-  int filetype;
-
-  filetype  = streamptr->filetype;
+  int status = CDI_EUFTYPE;
 
 #if  defined  (HAVE_LIBCGRIBEX)
+  int filetype  = streamptr->filetype;
+
   if ( filetype == FILETYPE_GRB )
-    {
-      status = cgribexScanTimestep1(streamptr);
-    }
+    status = cgribexScanTimestep1(streamptr);
+#endif
+#if defined(HAVE_LIBCGRIBEX) && defined (HAVE_LIBGRIB_API)
   else
 #endif
-    {
-      status = gribapiScanTimestep1(streamptr);
-    }
+#ifdef HAVE_LIBGRIB_API
+    status = gribapiScanTimestep1(streamptr);
+#endif
 
   return (status);
 }
@@ -48604,12 +49409,11 @@ int grbScanTimestep1(stream_t * streamptr)
 static
 int grbScanTimestep2(stream_t * streamptr)
 {
-  int status = 0;
-  int filetype;
-
-  filetype  = streamptr->filetype;
+  int status = CDI_EUFTYPE;
 
 #if  defined  (HAVE_LIBCGRIBEX)
+  int filetype = streamptr->filetype;
+
   if ( filetype == FILETYPE_GRB )
     {
       status = cgribexScanTimestep2(streamptr);
@@ -48650,6 +49454,7 @@ int grbScanTimestep(stream_t * streamptr)
 }
 
 
+#if  defined  (HAVE_LIBGRIB)
 int grbInqContents(stream_t * streamptr)
 {
   int fileID;
@@ -48667,7 +49472,7 @@ int grbInqContents(stream_t * streamptr)
 
   return (status);
 }
-
+#endif
 
 int grbInqTimestep(stream_t * streamptr, int tsID)
 {
@@ -48714,20 +49519,21 @@ void grbReadVarDP(stream_t * streamptr, int varID, double *data, int *nmiss)
   int fileID  = streamptr->fileID;
   int tsID    = streamptr->curTsID;
 
-  int nlevs    = streamptr->vars[varID].nlevs;
   int gridID   = vlistInqVarGrid(vlistID, varID);
   int gridsize = gridInqSize(gridID);
 
-  if ( CDI_Debug )
-    Message("nlevs = %d gridID = %d gridsize = %d", nlevs, gridID, gridsize);
-
   off_t currentfilepos = fileGetPos(fileID);
 
+
+  int isub     = subtypeInqActiveIndex(streamptr->vars[varID].subtypeID);
+  int nlevs    = streamptr->vars[varID].recordTable[0].nlevs;
+  if ( CDI_Debug )
+    Message("nlevs = %d gridID = %d gridsize = %d", nlevs, gridID, gridsize);
   *nmiss = 0;
   for (int levelID = 0; levelID < nlevs; levelID++ )
     {
-      int recID   = streamptr->vars[varID].level[levelID];
-      off_t recpos  = streamptr->tsteps[tsID].records[recID].position;
+      int    recID   = streamptr->vars[varID].recordTable[isub].recordID[levelID];
+      off_t  recpos  = streamptr->tsteps[tsID].records[recID].position;
       size_t recsize = streamptr->tsteps[tsID].records[recID].size;
 
       fileSetPos(fileID, recpos, SEEK_SET);
@@ -48741,7 +49547,7 @@ void grbReadVarDP(stream_t * streamptr, int varID, double *data, int *nmiss)
       streamptr->tsteps[tsID].records[recID].zip = grbUnzipRecord(gribbuffer, &recsize);
 
       grbDecode(filetype, gribbuffer, (int)recsize, &data[levelID*gridsize], gridsize,
-		streamptr->unreduced, &imiss, missval, vlistID, varID);
+                streamptr->unreduced, &imiss, missval, vlistID, varID);
 
       *nmiss += imiss;
     }
@@ -48768,8 +49574,11 @@ void grbReadVarSliceDP(stream_t * streamptr, int varID, int levelID, double *dat
 
   off_t currentfilepos = fileGetPos(fileID);
 
-  int recID   = streamptr->vars[varID].level[levelID];
-  off_t recpos  = streamptr->tsteps[tsID].records[recID].position;
+  int    isub    = subtypeInqActiveIndex(streamptr->vars[varID].subtypeID);
+
+
+  int    recID   = streamptr->vars[varID].recordTable[isub].recordID[levelID];
+  off_t  recpos  = streamptr->tsteps[tsID].records[recID].position;
   size_t recsize = streamptr->tsteps[tsID].records[recID].size;
 
   if ( recsize == 0 )
@@ -48801,7 +49610,7 @@ size_t grbEncode(int filetype, int memtype, int varID, int levelID, int vlistID,
   if ( filetype == FILETYPE_GRB )
     {
       size_t gribbuffersize = datasize*4+3000;
-      *gribbuffer = (unsigned char *) malloc(gribbuffersize);
+      *gribbuffer = (unsigned char *) Malloc(gribbuffersize);
 
       nbytes = cgribexEncode(memtype, varID, levelID, vlistID, gridID, zaxisID,
 			     date, time, tsteptype, numavg,
@@ -48838,7 +49647,7 @@ size_t grbSzip(int filetype, unsigned char *gribbuffer, size_t gribbuffersize)
   static int lszip_warn = 1;
 
   buffersize = gribbuffersize + 1000; /* compressed record can be greater than source record */
-  buffer = (unsigned char *) malloc(buffersize);
+  buffer = (unsigned char *) Malloc(buffersize);
 
   /*  memcpy(buffer, gribbuffer, gribbuffersize); */
 
@@ -48853,7 +49662,7 @@ size_t grbSzip(int filetype, unsigned char *gribbuffer, size_t gribbuffersize)
       nbytes = gribbuffersize;
     }
 
-  free(buffer);
+  Free(buffer);
 
   return (nbytes);
 }
@@ -48896,7 +49705,7 @@ void grb_write_var_slice(stream_t *streamptr, int varID, int levelID, int memtyp
   size_t datasize = (size_t)gridInqSize(gridID);
   /*
   gribbuffersize = datasize*4+3000;
-  gribbuffer = (unsigned char *) malloc(gribbuffersize);
+  gribbuffer = (unsigned char *) Malloc(gribbuffersize);
   */
 #if  defined  (HAVE_LIBCGRIBEX)
   if ( filetype == FILETYPE_GRB )
@@ -48943,7 +49752,7 @@ void grb_write_var_slice(stream_t *streamptr, int varID, int levelID, int memtyp
       Error("Failed to write GRIB slice!");
     }
 
-  if ( gribbuffer ) free(gribbuffer);
+  if ( gribbuffer ) Free(gribbuffer);
 }
 
 
@@ -48986,7 +49795,7 @@ void grbCopyRecord(stream_t * streamptr2, stream_t * streamptr1)
   /* round up recsize to next multiple of 8 */
   size_t gribbuffersize = ((recsize + 7U) & ~7U);
 
-  unsigned char *gribbuffer = xmalloc(gribbuffersize);
+  unsigned char *gribbuffer = (unsigned char *) Malloc(gribbuffersize);
 
   if (fileRead(fileID1, gribbuffer, recsize) != recsize)
     Error("Could not read GRIB record for copying!");
@@ -49012,7 +49821,7 @@ void grbCopyRecord(stream_t * streamptr2, stream_t * streamptr1)
       Error("Could not write record for copying!");
     }
 
-  free(gribbuffer);
+  Free(gribbuffer);
 }
 
 
@@ -49061,9 +49870,115 @@ void streamInqGRIBinfo(int streamID, int *intnum, float *fltnum, off_t *bignum)
  * require-trailing-newline: t
  * End:
  */
+#ifndef _SUBTYPE_H
+#define _SUBTYPE_H
+
+
+enum {
+  /* subtype attributes wrt. TILES */
+  SUBTYPE_ATT_TILEINDEX                 = 0,
+  SUBTYPE_ATT_TOTALNO_OF_TILEATTR_PAIRS = 1,
+  SUBTYPE_ATT_TILE_CLASSIFICATION       = 2,
+  SUBTYPE_ATT_NUMBER_OF_TILES           = 3,
+  SUBTYPE_ATT_NUMBER_OF_ATTR            = 4,
+  SUBTYPE_ATT_TILEATTRIBUTE             = 5,
+/* No. of different constants in the enumeration
+   "subtype_attributes" */
+  nSubtypeAttributes
+};
+
+
+/* Literal constants corresponding to the different constants of the
+   enumeration "subtype_attributes". */
+extern const char * const cdiSubtypeAttributeName[];
+
+/* Data type specifying an attribute of a subtype (for example an
+   attribute of a set of TILES) or an attribute of a subtype entry
+   (for example an attribute of a single TILE). This data type is part
+   of a linked list. */
+struct subtype_attr_t {
+  int   key, val;                                /* key/value pair */
+  struct subtype_attr_t* next;                   /* next element in linked list */
+};
+
+
+/* Data type specifying a single entry of a subtype, for example a
+   single TILE in a set of TILES. */
+struct subtype_entry_t {
+  int                     self;                  /* list entry index (0,...,nentries-1) */
+  struct subtype_entry_t *next;                  /* next node in linked list */
+
+  /* linked list with attributes for this subtype entry, ordered by its key values*/
+  struct subtype_attr_t  *atts;
+};
+
+
+/* Data type specifying a variable subtype, for example a list of
+   TILES. This can be interpreted as an additional axis like the
+   vertical axis. */
+typedef struct  {
+  int                     self;                  /* resource handler ID */
+  int                     subtype;               /* subtype kind: TILES, ... */
+  int                     nentries;              /* counter: total no. of entries in list */
+
+  struct subtype_entry_t  globals;               /* global attributes */
+
+  /* list of subtype entries, e.g. the list of tiles, ordered by entry->self. */
+  struct subtype_entry_t *entries;
+  /* currently active subtype, e.g. GRIB2 tile index (for example for
+     stream/vlist accesses): */
+  int                     active_subtype_index;
+} subtype_t;
+
+
+
+
+/* prototypes: allocation and destruction */
+void  subtypeAllocate(subtype_t **subtype_ptr2, int subtype);
+int   subtypePush(subtype_t *subtype_ptr);
+void  subtypeDestroyPtr(void *ptr);
+void  subtypeDuplicate(subtype_t *subtype_ptr, subtype_t **dst);
+struct subtype_entry_t* subtypeEntryInsert(subtype_t* head);
+
+/* prototypes: accessing global attributes */
+void  subtypePrint(int subtypeID);
+void  subtypePrintPtr(subtype_t* subtype_ptr);
+void  subtypeDefGlobalDataP(subtype_t *subtype_ptr, int key, int val);
+void  subtypeDefGlobalData(int subtypeID, int key, int val);
+int   subtypeGetGlobalData(int subtypeID, int key);
+int   subtypeGetGlobalDataP(subtype_t *subtype_ptr, int key);
+int   subtypeComparePtr(int s1_ID, subtype_t *s2);
+
+/* prototypes: accessing subtype entries */
+void  subtypeDefEntryDataP(struct subtype_entry_t *subtype_entry_ptr, int key, int val);
+
+
+/* prototypes: tile implementations */
+void  tilesetInsertP(subtype_t *s1, subtype_t *s2);
+
+/* Construct a new subtype for a tile set. If a corresponding subtype
+ * already exists, then we return this subtype ID instead. */
+int vlistDefTileSubtype(int vlistID, subtype_t *tiles);
+
+/* Insert a trivial one-tile-subtype */
+int vlistInsertTrivialTileSubtype(int vlistID);
+
+
+#endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #if defined (HAVE_CONFIG_H)
 #endif
 
+#include <limits.h>
 #include <stdio.h>
 
 
@@ -49075,6 +49990,10 @@ void streamInqGRIBinfo(int streamID, int *intnum, float *fltnum, off_t *bignum)
 
 extern int cdiInventoryMode;
 
+#if  defined  (HAVE_LIBGRIB_API)
+static const var_tile_t dummy_tiles = { -1, -1, -1, -1, -1, -1 };
+#endif
+
 typedef struct {
   int param;
   int level1;
@@ -49082,37 +50001,13 @@ typedef struct {
   int ltype;
   int tsteptype;
   char name[32];
-} compvar2_t;
 
+  var_tile_t tiles;
 
-#if  defined  (HAVE_LIBGRIB_API)
-static
-int my_grib_set_double(grib_handle* h, const char* key, double val)
-{
-  if ( cdiGribApiDebug )
-    fprintf(stderr, "grib_set_double(\tgrib_handle* h, \"%s\", %f)\n", key, val);
-
-  return grib_set_double(h, key, val);
-}
-
-static
-int my_grib_set_long(grib_handle* h, const char* key, long val)
-{
-  if ( cdiGribApiDebug )
-    fprintf(stderr, "grib_set_long(  \tgrib_handle* h, \"%s\", %ld)\n", key, val);
-
-  return grib_set_long(h, key, val);
-}
-
-static
-int my_grib_set_string(grib_handle* h, const char* key, const char* val, size_t* length)
-{
-  if ( cdiGribApiDebug )
-    fprintf(stderr, "grib_set_string(\tgrib_handle* h, \"%s\", \"%s\")\n", key, val);
+} compvar2_t;
 
-  return grib_set_string(h, key, val, length);
-}
 
+#if  defined  (HAVE_LIBGRIB_API)
 static
 int gribapiGetZaxisType(long editionNumber, int grib_ltype)
 {
@@ -49188,24 +50083,29 @@ int gribapiGetTimeUnits(grib_handle *gh)
 }
 
 static
-int gribapiGetEndStep(grib_handle *gh, int startStep, int timeunits)
+void gribapiGetSteps(grib_handle *gh, int timeunits, int *startStep, int *endStep)
 {
-  int endStep = startStep;
   int timeunits2 = timeunits;
-
   long unitsOfTime;
   int status = grib_get_long(gh, "stepUnits", &unitsOfTime);
   if ( status == 0 ) timeunits2 = getTimeunits(unitsOfTime);
   //timeunits2 = gribapiGetTimeUnits(gh);
 
   long lpar;
-  status = grib_get_long(gh, "endStep", &lpar);
+  status = grib_get_long(gh, "forecastTime", &lpar);
+  if ( status == 0 ) *startStep = (int) lpar;
+  else
+    {
+      status = grib_get_long(gh, "startStep", &lpar);
+      if ( status == 0 )
+        *startStep = (int) (((double)lpar * timeunit_factor(timeunits, timeunits2)) + 0.5);
+    }
 
+  *endStep = *startStep;
+  status = grib_get_long(gh, "endStep", &lpar);
   if ( status == 0 )
-    endStep = (int) (((double)lpar * timeunit_factor(timeunits, timeunits2)) + 0.5);
-  // printf("%d %d %d %d %d %g\n", startStep, endStep, lpar, timeunits, timeunits2, timeunit_factor(timeunits, timeunits2));
-
-  return (endStep);
+    *endStep = (int) (((double)lpar * timeunit_factor(timeunits, timeunits2)) + 0.5);
+  // printf("%d %d %d %d %d %g\n", *startStep, *endStep, lpar, timeunits, timeunits2, timeunit_factor(timeunits, timeunits2));
 }
 
 static
@@ -49233,8 +50133,6 @@ int gribapiGetValidityDateTime(grib_handle *gh, int *vdate, int *vtime)
   int timeUnits, startStep = 0, endStep;
   int tstepRange = 0;
   int range;
-  int status;
-  long lpar;
   long sigofrtime = 3;
 
   if ( gribEditionNumber(gh) > 1 )
@@ -49254,10 +50152,8 @@ int gribapiGetValidityDateTime(grib_handle *gh, int *vdate, int *vtime)
     {
       gribapiGetDataDateTime(gh, &rdate, &rtime);
 
-      status = grib_get_long(gh, "forecastTime", &lpar);
-      if ( status == 0 ) startStep = (int) lpar;
       timeUnits = gribapiGetTimeUnits(gh);
-      endStep = gribapiGetEndStep(gh, startStep, timeUnits);
+      gribapiGetSteps(gh, timeUnits, &startStep, &endStep);
 
       range = endStep - startStep;
 
@@ -49380,7 +50276,7 @@ static
 int calcLevel(int level_sf, long factor, long level)
 {
   double result = 0;
-  if(level != GRIB_MISSING_LONG) result = level*grib2ScaleFactor(factor);
+  if(level != GRIB_MISSING_LONG) result = (double)level*grib2ScaleFactor(factor);
   if(level_sf) result *= level_sf;
   return (int)result;
 }
@@ -49449,7 +50345,7 @@ void grib2GetLevel(grib_handle *gh, int *leveltype1, int *leveltype2, int *lboun
 }
 
 static
-void gribGetLevel(grib_handle *gh, int* leveltype1, int* leveltype2, int* lbounds, int* level1, int* level2, int* level_sf, int* level_unit)
+void gribGetLevel(grib_handle *gh, int* leveltype1, int* leveltype2, int* lbounds, int* level1, int* level2, int* level_sf, int* level_unit, var_tile_t* tiles)
 {
   if ( gribEditionNumber(gh) <= 1 )
     {
@@ -49461,6 +50357,14 @@ void gribGetLevel(grib_handle *gh, int* leveltype1, int* leveltype2, int* lbound
   else
     {
       grib2GetLevel(gh, leveltype1, leveltype2, lbounds, level1, level2, level_sf, level_unit);
+
+      /* read in tiles attributes (if there are any) */
+      tiles->tileindex = (int)gribGetLongDefault(gh, cdiSubtypeAttributeName[SUBTYPE_ATT_TILEINDEX], -1);
+      tiles->totalno_of_tileattr_pairs = (int)gribGetLongDefault(gh, cdiSubtypeAttributeName[SUBTYPE_ATT_TOTALNO_OF_TILEATTR_PAIRS], -1);
+      tiles->tileClassification = (int)gribGetLongDefault(gh, cdiSubtypeAttributeName[SUBTYPE_ATT_TILE_CLASSIFICATION], -1);
+      tiles->numberOfTiles = (int)gribGetLongDefault(gh, cdiSubtypeAttributeName[SUBTYPE_ATT_NUMBER_OF_TILES], -1);
+      tiles->numberOfAttributes = (int)gribGetLongDefault(gh, cdiSubtypeAttributeName[SUBTYPE_ATT_NUMBER_OF_ATTR], -1);
+      tiles->attribute = (int)gribGetLongDefault(gh, cdiSubtypeAttributeName[SUBTYPE_ATT_TILEATTRIBUTE], -1);
     }
 }
 
@@ -49469,7 +50373,12 @@ void gribapiGetString(grib_handle *gh, const char *key, char *string, size_t len
 {
   string[0] = 0;
 
-  GRIB_CHECK(grib_get_string(gh, key, string, &length), 0);
+  int ret = grib_get_string(gh, key, string, &length);
+  if (ret != 0)
+    {
+      fprintf(stderr, "grib_get_string(gh, \"%s\", ...) failed!\n", key);
+      GRIB_CHECK(ret, 0);
+    }
   if      ( length == 8 && memcmp(string, "unknown", length) == 0 ) string[0] = 0;
   else if ( length == 2 && memcmp(string, "~", length)       == 0 ) string[0] = 0;
 }
@@ -49478,31 +50387,26 @@ void gribapiGetString(grib_handle *gh, const char *key, char *string, size_t len
 static
 void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
                       size_t recsize, off_t position, int datatype, int comptype, const char *varname,
-                      int leveltype1, int leveltype2, int lbounds, int level1, int level2, int level_sf, int level_unit)
+                      int leveltype1, int leveltype2, int lbounds, int level1, int level2, int level_sf, int level_unit,
+                      const var_tile_t *tiles, int lread_additional_keys)
 {
-  int zaxistype;
-  int gridID = CDI_UNDEFID, varID;
+  int varID;
   int levelID = 0;
-  int tsID, recID;
-  int numavg;
-  int tsteptype;
-  record_t *record;
   grid_t grid;
-  int vlistID;
   long lpar;
   int status;
   char stdname[CDI_MAX_NAME], longname[CDI_MAX_NAME], units[CDI_MAX_NAME];
   size_t vlen;
   long ens_index = 0, ens_count = 0, ens_forecast_type = 0;
 
-  vlistID = streamptr->vlistID;
-  tsID    = streamptr->curTsID;
-  recID   = recordNewEntry(streamptr, tsID);
-  record  = &streamptr->tsteps[tsID].records[recID];
+  int vlistID = streamptr->vlistID;
+  int tsID    = streamptr->curTsID;
+  int recID   = recordNewEntry(streamptr, tsID);
+  record_t *record  = &streamptr->tsteps[tsID].records[recID];
 
-  tsteptype = gribapiGetTsteptype(gh);
+  int tsteptype = gribapiGetTsteptype(gh);
   // numavg  = ISEC1_AvgNum;
-  numavg  = 0;
+  int numavg  = 0;
 
   // fprintf(stderr, "param %d %d %d %d\n", param, level1, level2, leveltype1);
 
@@ -49513,6 +50417,8 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
   (*record).ilevel2   = level2;
   (*record).ltype     = leveltype1;
   (*record).tsteptype = tsteptype;
+  if ( tiles ) (*record).tiles = *tiles;
+  else         (*record).tiles = dummy_tiles;
 
   //FIXME: This may leave the variable name unterminated (which is the behavior that I found in the code).
   //       I don't know precisely how this field is used, so I did not change this behavior to avoid regressions,
@@ -49528,35 +50434,34 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
 
   gribapiGetGrid(gh, &grid);
 
-  gridID = varDefGrid(vlistID, &grid, 0);
+  int gridID = varDefGrid(vlistID, &grid, 0);
 
-  zaxistype = gribapiGetZaxisType(gribEditionNumber(gh), leveltype1);
+  int zaxistype = gribapiGetZaxisType(gribEditionNumber(gh), leveltype1);
 
   switch (zaxistype)
     {
     case ZAXIS_HYBRID:
     case ZAXIS_HYBRID_HALF:
       {
-        int vctsize;
+        size_t vctsize;
         size_t dummy;
         double *vctptr;
 
         GRIB_CHECK(grib_get_long(gh, "NV", &lpar), 0);
-        /* FIXME: assert(lpar >= INT_MIN && lpar <= INT_MAX) */
-        vctsize = (int)lpar;
+        /* FIXME: assert(lpar >= 0) */
+        vctsize = (size_t)lpar;
         if ( vctsize > 0 )
           {
-            vctptr = (double *) malloc(vctsize*sizeof(double));
-            dummy = (size_t)vctsize;
+            vctptr = (double *) Malloc(vctsize*sizeof(double));
+            dummy = vctsize;
             GRIB_CHECK(grib_get_double_array(gh, "pv", vctptr, &dummy), 0);
-            varDefVCT((size_t)vctsize, vctptr);
-            free(vctptr);
+            varDefVCT(vctsize, vctptr);
+            Free(vctptr);
           }
         break;
       }
     case ZAXIS_REFERENCE:
       {
-        size_t len;
         unsigned char uuid[CDI_UUID_SIZE];
         long ltmp;
         long nhlev, nvgrid;
@@ -49570,7 +50475,7 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
         nhlev = ltmp;
         GRIB_CHECK(grib_get_long(gh, "numberOfVGridUsed", &ltmp), 0);
         nvgrid = ltmp;
-        len = (size_t)CDI_UUID_SIZE;
+        size_t len = (size_t)CDI_UUID_SIZE;
         memset(uuid, 0, CDI_UUID_SIZE);
         GRIB_CHECK(grib_get_bytes(gh, "uuidOfVGrid", uuid, &len), 0);
         varDefZAxisReference((int) nhlev, (int) nvgrid, uuid);
@@ -49601,12 +50506,14 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
     }
   // fprintf(stderr, "param %d name %s %s %s\n", param, name, longname, units);
 
+  /* add the previously read record data to the (intermediate) list of records */
+  int tile_index = -1;
   varAddRecord(recID, param, gridID, zaxistype, lbounds, level1, level2, level_sf, level_unit,
 	       datatype, &varID, &levelID, tsteptype, numavg, leveltype1, leveltype2,
-	       varname, stdname, longname, units);
+	       varname, stdname, longname, units, tiles, &tile_index);
 
-  (*record).varID   = (short)varID;
-  (*record).levelID = (short)levelID;
+  record->varID   = (short)varID;
+  record->levelID = (short)levelID;
 
   varDefCompType(varID, comptype);
 
@@ -49638,23 +50545,15 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
   long   lval;
   double dval;
 
-  /* we read the additional keys for the first variable record only. */
-  int linitial_field = (varOptGribNentries(varID) == 0);
-
-  for ( i = 0; i < cdiNAdditionalGRIBKeys; i++ )
-    {
-      if ( linitial_field )
-	{
-	  if ( grib_get_long(gh, cdiAdditionalGRIBKeys[i], &lval) == 0 )
-            varDefOptGribInt(varID, lval, cdiAdditionalGRIBKeys[i]);
-	}
-      if ( linitial_field )
-	{
-	  if ( grib_get_double(gh, cdiAdditionalGRIBKeys[i], &dval) == 0 )
-            varDefOptGribDbl(varID, dval, cdiAdditionalGRIBKeys[i]);
-	}
-      /* note: if the key is not defined, we do not throw an error! */
-    }
+  if (lread_additional_keys)
+    for ( i = 0; i < cdiNAdditionalGRIBKeys; i++ )
+      {
+        /* note: if the key is not defined, we do not throw an error! */
+        if ( grib_get_long(gh, cdiAdditionalGRIBKeys[i], &lval) == 0 )
+          varDefOptGribInt(varID, tile_index, lval, cdiAdditionalGRIBKeys[i]);
+        if ( grib_get_double(gh, cdiAdditionalGRIBKeys[i], &dval) == 0 )
+          varDefOptGribDbl(varID, tile_index, dval, cdiAdditionalGRIBKeys[i]);
+      }
 
   if ( varInqInst(varID) == CDI_UNDEFID )
     {
@@ -49711,8 +50610,8 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
 }
 #endif
 
-static
-compvar2_t gribapiVarSet(int param, int level1, int level2, int leveltype, int tsteptype, char *name)
+static compvar2_t gribapiVarSet(int param, int level1, int level2, int leveltype, 
+                                int tsteptype, char *name, var_tile_t tiles_data)
 {
   compvar2_t compVar;
   size_t maxlen = sizeof(compVar.name);
@@ -49726,23 +50625,23 @@ compvar2_t gribapiVarSet(int param, int level1, int level2, int leveltype, int t
   compVar.tsteptype = tsteptype;
   memset(compVar.name, 0, maxlen);
   memcpy(compVar.name, name, len);
+  compVar.tiles = tiles_data;
 
   return (compVar);
 }
 #endif
 
+#ifdef HAVE_LIBGRIB_API
 static
 int gribapiVarCompare(compvar2_t compVar, record_t record, int flag)
 {
   compvar2_t compVar0;
-  size_t maxlen = sizeof(compVar.name);
-
   compVar0.param     = record.param;
   compVar0.level1    = record.ilevel;
   compVar0.level2    = record.ilevel2;
   compVar0.ltype     = record.ltype;
   compVar0.tsteptype = record.tsteptype;
-  memcpy(compVar0.name, record.varname, maxlen);
+  memcpy(compVar0.name, record.varname, sizeof(compVar.name));
 
   if ( flag == 0 )
     {
@@ -49750,22 +50649,23 @@ int gribapiVarCompare(compvar2_t compVar, record_t record, int flag)
       if ( compVar0.tsteptype == TSTEP_INSTANT3 && compVar.tsteptype == TSTEP_INSTANT  ) compVar0.tsteptype = TSTEP_INSTANT;
     }
 
+  compVar0.tiles = record.tiles;
+
   int rstatus = memcmp(&compVar0, &compVar, sizeof(compvar2_t));
 
   return (rstatus);
 }
 
-static void ensureBufferSize(size_t requiredSize, size_t* curSize, unsigned char** buffer) {
+static void ensureBufferSize(size_t requiredSize, size_t* curSize, unsigned char **buffer) {
   if ( *curSize < requiredSize )
     {
       *curSize = requiredSize;
-      *buffer = realloc(*buffer, *curSize);
+      *buffer = (unsigned char *) Realloc(*buffer, *curSize);
     }
 }
 
-#if  defined  (HAVE_LIBGRIB_API)
 static
-grib_handle* gribapiGetDiskRepresentation(long recsize, size_t* buffersize, unsigned char** gribbuffer, int* outDatatype, int* outCompressionType, long* outUnzipsize)
+grib_handle* gribapiGetDiskRepresentation(size_t recsize, size_t* buffersize, unsigned char** gribbuffer, int* outDatatype, int* outCompressionType, long* outUnzipsize)
 {
   int lieee = FALSE;
 
@@ -49785,10 +50685,10 @@ grib_handle* gribapiGetDiskRepresentation(long recsize, size_t* buffersize, unsi
     }
   else
     {
-      if( gribGetZip(recsize, *gribbuffer, outUnzipsize) > 0 )
+      if( gribGetZip((long)recsize, *gribbuffer, outUnzipsize) > 0 )
         {
           *outCompressionType = COMPRESS_SZIP;
-          ensureBufferSize(*outUnzipsize + 100, buffersize, gribbuffer);
+          ensureBufferSize((size_t)*outUnzipsize + 100, buffersize, gribbuffer);
         }
       else
         {
@@ -49816,9 +50716,10 @@ grib_handle* gribapiGetDiskRepresentation(long recsize, size_t* buffersize, unsi
 }
 #endif
 
+#if  defined  (HAVE_LIBGRIB_API)
 typedef enum { CHECKTIME_OK, CHECKTIME_SKIP, CHECKTIME_STOP, CHECKTIME_INCONSISTENT } checkTimeResult;
 static checkTimeResult checkTime(stream_t* streamptr, compvar2_t compVar, const DateTime* verificationTime, const DateTime* expectedVTime) {
-  //First determine whether the current record exists already.
+  // First determine whether the current record exists already.
   int recID = 0;
   for ( ; recID < streamptr->nrecs; recID++ )
     {
@@ -49826,10 +50727,10 @@ static checkTimeResult checkTime(stream_t* streamptr, compvar2_t compVar, const
     }
   int recordExists = recID < streamptr->nrecs;
 
-  //Then we need to know whether the verification time is consistent.
+  // Then we need to know whether the verification time is consistent.
   int consistentTime = !memcmp(verificationTime, expectedVTime, sizeof(*verificationTime));
 
-  //Finally, we make a decision.
+  // Finally, we make a decision.
   if ( cdiInventoryMode == 1 )
     {
       if ( recordExists ) return CHECKTIME_STOP;
@@ -49840,8 +50741,10 @@ static checkTimeResult checkTime(stream_t* streamptr, compvar2_t compVar, const
       if ( !consistentTime ) return CHECKTIME_STOP;
       if ( recordExists ) return CHECKTIME_SKIP;
     }
+
   return CHECKTIME_OK;
 }
+#endif
 
 #define gribWarning(text, nrecs, timestep, varname, param, level1, level2) do \
   { \
@@ -49851,9 +50754,9 @@ static checkTimeResult checkTime(stream_t* streamptr, compvar2_t compVar, const
   } \
 while(0)
 
+#if  defined  (HAVE_LIBGRIB_API)
 int gribapiScanTimestep1(stream_t * streamptr)
 {
-#if  defined  (HAVE_LIBGRIB_API)
   off_t recpos = 0;
   unsigned char *gribbuffer = NULL;
   size_t buffersize = 0;
@@ -49874,7 +50777,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
 
   int fileID = streamptr->fileID;
 
-  int nrecs = 0;
+  unsigned nrecs = 0;
   while ( TRUE )
     {
       int level1 = 0, level2 = 0;
@@ -49889,7 +50792,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
       ensureBufferSize(recsize, &buffersize, &gribbuffer);
 
       size_t readsize = recsize;
-      int rstatus = gribRead(fileID, gribbuffer, &readsize);        //Search for next 'GRIB', read the following record, and position file offset after it.
+      int rstatus = gribRead(fileID, gribbuffer, &readsize); //Search for next 'GRIB', read the following record, and position file offset after it.
       if ( rstatus ) break;
 
       int datatype, comptype = 0;
@@ -49901,13 +50804,15 @@ int gribapiScanTimestep1(stream_t * streamptr)
 
       int param = gribapiGetParam(gh);
       int leveltype1 = -1, leveltype2 = -1, lbounds, level_sf, level_unit;
-      gribGetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit);
+      var_tile_t tiles = dummy_tiles;
+      gribGetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit, &tiles);
 
       char varname[256];
       varname[0] = 0;
       gribapiGetString(gh, "shortName", varname, sizeof(varname));
 
       int tsteptype = gribapiGetTsteptype(gh);
+
       int vdate = 0, vtime = 0;
       gribapiGetValidityDateTime(gh, &vdate, &vtime);
       DateTime datetime = { .date = vdate, .time = vtime };
@@ -49915,9 +50820,9 @@ int gribapiScanTimestep1(stream_t * streamptr)
       printf("%d %d %d\n", vdate, vtime, leveltype1);
       */
 
-      if( datetime0.date == 10101 && datetime0.time == 0 )
+      if ( datetime0.date == 10101 && datetime0.time == 0 )
         {
-          if( memcmp(&datetime, &datetime0, sizeof(datetime)) || !nrecs )       //Do we really need this condition? I have included it in order not to change the number of times gribapiGetDataDateTime() etc. get called. But if those are sideeffect-free, this condition should be removed.
+          if( datetimeCmp(datetime, datetime0) || !nrecs )       //Do we really need this condition? I have included it in order not to change the number of times gribapiGetDataDateTime() etc. get called. But if those are sideeffect-free, this condition should be removed.
             {
               datetime0 = datetime;
 
@@ -49928,19 +50833,19 @@ int gribapiScanTimestep1(stream_t * streamptr)
             }
         }
 
-      if(nrecs)
+      if ( nrecs )
         {
-          checkTimeResult result = checkTime(streamptr, gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname), &datetime, &datetime0);
-          if(result == CHECKTIME_STOP)
+          checkTimeResult result = checkTime(streamptr, gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname, tiles), &datetime, &datetime0);
+          if ( result == CHECKTIME_STOP )
             {
               break;
             }
-          else if(result == CHECKTIME_SKIP)
+          else if ( result == CHECKTIME_SKIP )
             {
               gribWarning("Parameter already exist, skipped!", nrecs_scanned, tsID+1, varname, param, level1, level2);
               continue;
             }
-          else if(result == CHECKTIME_INCONSISTENT && warn_time)
+          else if ( result == CHECKTIME_INCONSISTENT && warn_time )
             {
               gribWarning("Inconsistent verification time!", nrecs_scanned, tsID+1, varname, param, level1, level2);
               warn_time = FALSE;
@@ -49968,12 +50873,14 @@ int gribapiScanTimestep1(stream_t * streamptr)
         {
           char paramstr[32];
           cdiParamToString(param, paramstr, sizeof(paramstr));
-          Message("%4d %8d name=%s id=%s ltype=%d lev1=%d lev2=%d vdate=%d vtime=%d",
+          Message("%4u %8d name=%s id=%s ltype=%d lev1=%d lev2=%d vdate=%d vtime=%d",
                 nrecs, (int)recpos, varname, paramstr, leveltype1, level1, level2, vdate, vtime);
         }
 
+      var_tile_t *ptiles = NULL;
+      if ( memcmp(&tiles, &dummy_tiles, sizeof(var_tile_t)) != 0 ) ptiles = &tiles;
       gribapiAddRecord(streamptr, param, gh, recsize, recpos, datatype, comptype, varname,
-                       leveltype1, leveltype2, lbounds, level1, level2, level_sf, level_unit);
+                       leveltype1, leveltype2, lbounds, level1, level2, level_sf, level_unit, ptiles, 1);
 
       grib_handle_delete(gh);
       gh = NULL;
@@ -50013,10 +50920,10 @@ int gribapiScanTimestep1(stream_t * streamptr)
     {
       streamptr->tsteps[0].recordSize = nrecords;
       streamptr->tsteps[0].records =
-      (record_t *) realloc(streamptr->tsteps[0].records, nrecords*sizeof(record_t));
+        (record_t *) Realloc(streamptr->tsteps[0].records, (size_t)nrecords*sizeof(record_t));
     }
 
-  streamptr->tsteps[0].recIDs = (int *) malloc(nrecords*sizeof(int));
+  streamptr->tsteps[0].recIDs = (int *) Malloc((size_t)nrecords*sizeof(int));
   streamptr->tsteps[0].nrecs = nrecords;
   for ( int recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[0].recIDs[recID] = recID;
@@ -50045,13 +50952,10 @@ int gribapiScanTimestep1(stream_t * streamptr)
             }
         }
     }
-#else
-  (void)streamptr;
-  Error("GRIB_API support not compiled in!");
-#endif
 
   return (0);
 }
+#endif
 
 
 #ifdef HAVE_LIBGRIB_API
@@ -50059,10 +50963,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
 {
   int rstatus = 0;
   off_t recpos = 0;
-  unsigned char *gribbuffer = NULL;
-  size_t buffersize = 0;
-  int fileID;
-  DateTime datetime0;
+  DateTime datetime0 = { LONG_MIN, LONG_MIN };
   // int gridID;
   int recID;
   //  int warn_numavg = TRUE;
@@ -50070,12 +50971,12 @@ int gribapiScanTimestep2(stream_t * streamptr)
 
   streamptr->curTsID = 1;
 
-  fileID  = streamptr->fileID;
+  int fileID  = streamptr->fileID;
   int vlistID = streamptr->vlistID;
   int taxisID = vlistInqTaxis(vlistID);
 
-  gribbuffer = (unsigned char *) streamptr->record->buffer;
-  buffersize = streamptr->record->buffersize;
+  unsigned char *gribbuffer = (unsigned char *) streamptr->record->buffer;
+  size_t buffersize = streamptr->record->buffersize;
 
   int tsID = streamptr->rtsteps;
   if ( tsID != 1 )
@@ -50088,7 +50989,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
   cdi_create_records(streamptr, tsID);
 
   int nrecords = streamptr->tsteps[tsID].nallrecs;
-  streamptr->tsteps[1].recIDs = (int *) malloc(nrecords*sizeof(int));
+  streamptr->tsteps[1].recIDs = (int *) Malloc((size_t)nrecords*sizeof(int));
   streamptr->tsteps[1].nrecs = 0;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[1].recIDs[recID] = -1;
@@ -50119,7 +51020,8 @@ int gribapiScanTimestep2(stream_t * streamptr)
       if ( rstatus ) break;
 
       long unzipsize;
-      if ( gribGetZip((long)recsize, gribbuffer, &unzipsize) > 0 ) ensureBufferSize(unzipsize + 100, &buffersize, &gribbuffer);
+      if ( gribGetZip((long)recsize, gribbuffer, &unzipsize) > 0 )
+        ensureBufferSize((size_t)unzipsize + 100, &buffersize, &gribbuffer);
 
       nrecs_scanned++;
       gh = grib_handle_new_from_message(NULL, (void *) gribbuffer, recsize);
@@ -50127,7 +51029,8 @@ int gribapiScanTimestep2(stream_t * streamptr)
 
       int param = gribapiGetParam(gh);
       int level1 = 0, level2 = 0, leveltype1, leveltype2, lbounds, level_sf, level_unit;
-      gribGetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit);
+      var_tile_t tiles = dummy_tiles;
+      gribGetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit, &tiles);
 
       char varname[256];
       varname[0] = 0;
@@ -50177,7 +51080,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
         .time = vtime
       };
 
-      compvar2_t compVar = gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname);
+      compvar2_t compVar = gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname, tiles);
 
       for ( recID = 0; recID < nrecords; recID++ )
         if ( gribapiVarCompare(compVar, streamptr->tsteps[tsID].records[recID], 0) == 0 ) break;
@@ -50193,7 +51096,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
           if ( cdiInventoryMode == 1 ) break;
           else
 	    {
-	      if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) != 0 ) break;
+	      if ( datetimeCmp(datetime, datetime0) != 0 ) break;
 
               gribWarning("Parameter already exist, skipped!", nrecs_scanned, tsID+1, varname, param, level1, level2);
 	      continue;
@@ -50308,7 +51211,7 @@ int gribapiScanTimestep(stream_t * streamptr)
       nrecs = streamptr->tsteps[1].nrecs;
 
       streamptr->tsteps[tsID].nrecs = nrecs;
-      streamptr->tsteps[tsID].recIDs = (int *) malloc(nrecs*sizeof(int));
+      streamptr->tsteps[tsID].recIDs = (int *) Malloc((size_t)nrecs*sizeof(int));
       for ( recID = 0; recID < nrecs; recID++ )
 	streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
 
@@ -50319,7 +51222,7 @@ int gribapiScanTimestep(stream_t * streamptr)
       int nrecs_scanned = streamptr->tsteps[0].nallrecs + streamptr->tsteps[1].nrecs*(tsID-1);    //Only used for debug output.
       int rindex = 0;
       off_t recpos = 0;
-      DateTime datetime0;
+      DateTime datetime0 = { LONG_MIN, LONG_MIN };
       grib_handle *gh = NULL;
       char varname[256];
       while ( TRUE )
@@ -50347,7 +51250,8 @@ int gribapiScanTimestep(stream_t * streamptr)
 	    }
 
           long unzipsize;
-	  if ( gribGetZip((long)recsize, gribbuffer, &unzipsize) > 0 ) ensureBufferSize(unzipsize + 100, &buffersize, &gribbuffer);
+	  if ( gribGetZip((long)recsize, gribbuffer, &unzipsize) > 0 )
+            ensureBufferSize((size_t)unzipsize + 100, &buffersize, &gribbuffer);
 
           nrecs_scanned++;
 	  gh = grib_handle_new_from_message(NULL, (void *) gribbuffer, recsize);
@@ -50355,7 +51259,8 @@ int gribapiScanTimestep(stream_t * streamptr)
 
           int param = gribapiGetParam(gh);
           int level1 = 0, level2 = 0, leveltype1, leveltype2 = -1, lbounds, level_sf, level_unit;
-          gribGetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit);
+          var_tile_t tiles = dummy_tiles;
+          gribGetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit, &tiles);
 
           varname[0] = 0;
 	  gribapiGetString(gh, "shortName", varname, sizeof(varname));
@@ -50407,7 +51312,7 @@ int gribapiScanTimestep(stream_t * streamptr)
 
           int tsteptype = gribapiGetTsteptype(gh);
 
-          compvar2_t compVar = gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname);
+          compvar2_t compVar = gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname, tiles);
 
 	  for ( vrecID = 0; vrecID < nrecs; vrecID++ )
 	    {
@@ -50429,7 +51334,7 @@ int gribapiScanTimestep(stream_t * streamptr)
 	    {
 	      if ( streamptr->tsteps[tsID].records[recID].used )
 		{
-		  if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) != 0 ) break;
+		  if ( datetimeCmp(datetime, datetime0) != 0 ) break;
 
 		  if ( CDI_Debug )
                     gribWarning("Parameter already exist, skipped!", nrecs_scanned, tsID+1, varname, param, level1, level2);
@@ -50520,8 +51425,7 @@ int gribapiDecode(unsigned char *gribbuffer, int gribsize, double *data, int gri
   int status = 0;
   long lpar;
   long numberOfPoints;
-  size_t datasize, dummy, recsize;
-  grib_handle *gh = NULL;
+  size_t datasize;
 
   UNUSED(vlistID);
   UNUSED(varID);
@@ -50537,8 +51441,8 @@ int gribapiDecode(unsigned char *gribbuffer, int gribsize, double *data, int gri
 	}
     }
 
-  recsize = (size_t)gribsize;
-  gh = grib_handle_new_from_message(NULL, (void *) gribbuffer, recsize);
+  size_t recsize = (size_t)gribsize;
+  grib_handle *gh = grib_handle_new_from_message(NULL, (void *) gribbuffer, recsize);
   GRIB_CHECK(my_grib_set_double(gh, "missingValue", missval), 0);
 
   /* get the size of the values array*/
@@ -50549,12 +51453,11 @@ int gribapiDecode(unsigned char *gribbuffer, int gribsize, double *data, int gri
 
   if ( gridsize != (int) datasize )
     Error("Internal problem: gridsize(%d) != datasize(%d)!", gridsize, datasize);
-  dummy = datasize;
+  size_t dummy = datasize;
   GRIB_CHECK(grib_get_double_array(gh, "values", data, &dummy), 0);
 
-  int gridtype;
   GRIB_CHECK(grib_get_long(gh, "gridDefinitionTemplateNumber", &lpar), 0);
-  gridtype = (int) lpar;
+  int gridtype = (int) lpar;
 
   *nmiss = 0;
   if ( gridtype < 50 || gridtype > 53 )
@@ -50646,6 +51549,14 @@ void gribapiDefParam(int editionNumber, grib_handle *gh, int param, const char *
     {
       if ( pnum < 0 ) pnum = -pnum;
 
+      static bool lwarn_pnum = true;
+      if ( pnum > 255 && lwarn_pnum )
+        {
+          Warning("Parameter number %d out of range (1-255), set to %d!", pnum, pnum%256);
+          lwarn_pnum = false;
+          pnum = pnum%256;
+        }
+
       if ( editionNumber <= 1 )
 	{
           static bool lwarn_pdis = true;
@@ -50657,14 +51568,6 @@ void gribapiDefParam(int editionNumber, grib_handle *gh, int param, const char *
               lwarn_pdis = false;
 	    }
 
-          static bool lwarn_pnum = true;
-          if ( pnum > 255 && lwarn_pnum )
-            {
-              Warning("Parameter number %d out of bounds (1-255), set to %d!", pnum, pnum%256);
-              lwarn_pnum = false;
-              pnum = pnum%256;
-            }
-
 	  GRIB_CHECK(my_grib_set_long(gh, "table2Version",        pcat), 0);
 	  GRIB_CHECK(my_grib_set_long(gh, "indicatorOfParameter", pnum), 0);
 	}
@@ -50720,7 +51623,7 @@ void gribapiDefStepUnits(grib_handle *gh, int timeunit, int proDefTempNum, int g
     {
       GRIB_CHECK(my_grib_set_long(gh, "stepUnits", unitsOfTime), 0);
       if ( proDefTempNum == 8 || proDefTempNum == 11 )
-        GRIB_CHECK(my_grib_set_long(gh, "indicatorOfUnitForTimeRange", unitsOfTime), 0);
+        GRIB_CHECK(my_grib_set_long(gh, "indicatorOfUnitOfTimeRange", unitsOfTime), 0);
       GRIB_CHECK(my_grib_set_long(gh, "indicatorOfUnitOfTimeRange", unitsOfTime), 0);
     }
 }
@@ -50730,21 +51633,32 @@ int gribapiDefSteptype(int editionNumber, grib_handle *gh, int productDefinition
 {
   long proDefTempNum = 0;
   size_t len = 64;
-  char stepType[len];
-
-  switch ( tsteptype )
+  const char *stepType;
+
+  static struct {
+    long productionTemplate;
+    const char sname[8];
+  } ts_tab[] = {
+    [TSTEP_INSTANT] = {  0, "instant" },
+    [TSTEP_AVG] = { 8, "avg" },
+    [TSTEP_ACCUM] = {  8, "accum" },
+    [TSTEP_MAX] = {  8, "max" },
+    [TSTEP_MIN] = {  8, "min" },
+    [TSTEP_DIFF] = {  8, "diff" },
+    [TSTEP_RMS] = {  8, "rms" },
+    [TSTEP_SD] = {  8, "sd" },
+    [TSTEP_COV] = { 8, "cov" },
+    [TSTEP_RATIO] = {  8, "ratio" }
+  };
+  if (tsteptype >= TSTEP_INSTANT && tsteptype <= TSTEP_RATIO)
     {
-    case TSTEP_AVG:      strcpy(stepType, "avg");     proDefTempNum = 8; break;
-    case TSTEP_ACCUM:    strcpy(stepType, "accum");   proDefTempNum = 8; break;
-    case TSTEP_MAX:      strcpy(stepType, "max");     proDefTempNum = 8; break;
-    case TSTEP_MIN:      strcpy(stepType, "min");     proDefTempNum = 8; break;
-    case TSTEP_DIFF:     strcpy(stepType, "diff");    proDefTempNum = 8; break;
-    case TSTEP_RMS:      strcpy(stepType, "rms");     proDefTempNum = 8; break;
-    case TSTEP_SD:       strcpy(stepType, "sd");      proDefTempNum = 8; break;
-    case TSTEP_COV:      strcpy(stepType, "cov");     proDefTempNum = 8; break;
-    case TSTEP_RATIO:    strcpy(stepType, "ratio");   proDefTempNum = 8; break;
-    case TSTEP_INSTANT:  strcpy(stepType, "instant"); proDefTempNum = 0; break;
-    default:             strcpy(stepType, "instant"); proDefTempNum = 0; break;
+      stepType = ts_tab[tsteptype].sname;
+      proDefTempNum = ts_tab[tsteptype].productionTemplate;
+    }
+  else
+    {
+      stepType = "instant";
+      proDefTempNum = 0;
     }
 
   if ( typeOfGeneratingProcess == 4 )
@@ -50784,7 +51698,6 @@ int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rti
   int status = -1;
   int year, month, day, hour, minute, second;
   int julday1, secofday1, julday2, secofday2, days, secs;
-  int factor;
   long startStep = 0, endStep;
 
   cdiDecodeDate(rdate, &year, &month, &day);
@@ -50799,7 +51712,7 @@ int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rti
 
   (void) julday_sub(julday1, secofday1, julday2, secofday2, &days, &secs);
 
-  factor = getTimeunitFactor(timeunit);
+  int factor = getTimeunitFactor(timeunit);
 
   if ( !(int) fmod(days*86400.0 + secs, factor) )
     {
@@ -50877,15 +51790,12 @@ void gribapiDefTime(int editionNumber, int productDefinitionTemplate, int typeOf
 static
 void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype, int lieee, int datatype, int nmiss, int gcinit)
 {
-  int gridtype;
   int status;
   static short lwarn = TRUE;
-  size_t len;
-  char *mesg;
 
   UNUSED(nmiss);
 
-  gridtype = gridInqType(gridID);
+  int gridtype = gridInqType(gridID);
 
   if ( editionNumber <= 1 )
     if ( gridtype == GRID_GME || gridtype == GRID_UNSTRUCTURED )
@@ -50937,17 +51847,20 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
         {
           if ( comptype == COMPRESS_JPEG )
             {
-              mesg = "grid_jpeg"; len = strlen(mesg);
+              static const char mesg[] = "grid_jpeg";
+              size_t len = sizeof (mesg) - 1;
               GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
             }
           else if ( comptype == COMPRESS_SZIP )
             {
-              mesg = "grid_ccsds"; len = strlen(mesg);
+              static const char mesg[] = "grid_ccsds";
+              size_t len = sizeof (mesg) - 1;
               GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
             }
           else
             {
-              mesg = "grid_simple"; len = strlen(mesg);
+              static const char mesg[] = "grid_simple";
+              size_t len = sizeof (mesg) - 1;
               GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
             }
         }
@@ -50969,22 +51882,26 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 
 	if ( gridtype == GRID_GAUSSIAN )
 	  {
-	    mesg = "regular_gg"; len = strlen(mesg);
+            static const char mesg[] = "regular_gg";
+            size_t len = sizeof (mesg) -1;
 	    GRIB_CHECK(my_grib_set_string(gh, "gridType", mesg, &len), 0);
 	  }
 	else if ( gridtype == GRID_GAUSSIAN_REDUCED )
 	  {
-	    mesg = "reduced_gg"; len = strlen(mesg);
+            static const char mesg[] = "reduced_gg";
+            size_t len = sizeof (mesg) -1;
 	    GRIB_CHECK(my_grib_set_string(gh, "gridType", mesg, &len), 0);
 	  }
 	else if ( gridtype == GRID_LONLAT && gridIsRotated(gridID) )
 	  {
-	    mesg = "rotated_ll"; len = strlen(mesg);
+            static const char mesg[] = "rotated_ll";
+            size_t len = sizeof (mesg) -1;
 	    GRIB_CHECK(my_grib_set_string(gh, "gridType", mesg, &len), 0);
 	  }
 	else
 	  {
-	    mesg = "regular_ll"; len = strlen(mesg);
+            static const char mesg[] = "regular_ll";
+            size_t len = sizeof (mesg) -1;
 	    GRIB_CHECK(my_grib_set_string(gh, "gridType", mesg, &len), 0);
 	  }
 
@@ -50998,15 +51915,15 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 
 	    nlon = 0;
 
-	    rowlon = (int *) malloc(nlat*sizeof(int));
-	    pl     = (long *) malloc(nlat*sizeof(long));
+	    rowlon = (int *) Malloc((size_t)nlat*sizeof(int));
+	    pl     = (long *) Malloc((size_t)nlat*sizeof(long));
 	    gridInqRowlon(gridID, rowlon);
 	    for ( i = 0; i < nlat; ++i ) pl[i] = rowlon[i];
 
 	    // GRIB_CHECK(my_grib_set_long_array(gh, "pl", pl, nlat), 0);
 
-	    free(pl);
-	    free(rowlon);
+	    Free(pl);
+	    Free(rowlon);
 	  }
 	else
 	  {
@@ -51085,8 +52002,9 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 	    ypole = gridInqYpole(gridID);
 	    angle = gridInqAngle(gridID);
 	    /* change from north to south pole */
-	    ypole = -ypole;
+	    if ( fabs(ypole) > 0 ) ypole = -ypole;
 	    xpole =  xpole + 180;
+            if ( fabs(angle) > 0 ) angle = -angle;
 	    GRIB_CHECK(my_grib_set_double(gh, "latitudeOfSouthernPoleInDegrees",  ypole), 0);
 	    GRIB_CHECK(my_grib_set_double(gh, "longitudeOfSouthernPoleInDegrees", xpole), 0);
 	    GRIB_CHECK(my_grib_set_double(gh, "angleOfRotation", angle), 0);
@@ -51102,7 +52020,8 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 
         if ( lieee )
           {
-            mesg = "grid_ieee"; len = strlen(mesg);
+            static const char mesg[] = "grid_ieee";
+            size_t len = sizeof (mesg) -1;
             GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
 
 	    if ( datatype == DATATYPE_FLT64 )
@@ -51114,17 +52033,20 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 	  {
             if ( comptype == COMPRESS_JPEG )
               {
-                mesg = "grid_jpeg"; len = strlen(mesg);
+                static const char mesg[] = "grid_jpeg";
+                size_t len = sizeof (mesg) -1;
                 GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
               }
             else if ( comptype == COMPRESS_SZIP )
               {
-                mesg = "grid_ccsds"; len = strlen(mesg);
+                static const char mesg[] = "grid_ccsds";
+                size_t len = sizeof (mesg) -1;
                 GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
               }
             else
               {
-                mesg = "grid_simple"; len = strlen(mesg);
+                static const char mesg[] = "grid_simple";
+                size_t len = sizeof (mesg) -1;
                 GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
               }
 	  }
@@ -51143,14 +52065,17 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 	gridInqLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm,
 		   &projflag, &scanflag);
 
-        mesg = "lambert"; len = strlen(mesg);
+        static const char mesg[] = "lambert";
+        size_t len = sizeof (mesg) -1;
         GRIB_CHECK(my_grib_set_string(gh, "gridType", mesg, &len), 0);
 
 	GRIB_CHECK(my_grib_set_long(gh, "Nx", xsize), 0);
 	GRIB_CHECK(my_grib_set_long(gh, "Ny", ysize), 0);
 
-	GRIB_CHECK(my_grib_set_double(gh, "DxInMetres", lround(xincm)), 0);
-	GRIB_CHECK(my_grib_set_double(gh, "DyInMetres", lround(yincm)), 0);
+        /* FIXME: lround should probably be round here */
+	GRIB_CHECK(my_grib_set_double(gh, "DxInMetres", (double)lround(xincm)), 0);
+        /* FIXME: lround should probably be round here */
+	GRIB_CHECK(my_grib_set_double(gh, "DyInMetres", (double)lround(yincm)), 0);
 	GRIB_CHECK(my_grib_set_double(gh, "longitudeOfFirstGridPointInDegrees", originLon), 0);
 	GRIB_CHECK(my_grib_set_double(gh, "latitudeOfFirstGridPointInDegrees", originLat), 0);
 	GRIB_CHECK(my_grib_set_double(gh, "LoVInDegrees", lonParY), 0);
@@ -51172,7 +52097,8 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
       {
 	int trunc = gridInqTrunc(gridID);
 
-	mesg = "sh"; len = strlen(mesg);
+        static const char mesg[] = "sh";
+        size_t len = sizeof (mesg) -1;
 	GRIB_CHECK(my_grib_set_string(gh, "gridType", mesg, &len), 0);
 
 	GRIB_CHECK(my_grib_set_long(gh, "J", trunc), 0);
@@ -51185,13 +52111,15 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
           {
             printf("spectral_ieee\n");
             if ( editionNumber == 2 ) GRIB_CHECK(my_grib_set_long(gh, "numberOfValues", gridInqSize(gridID)), 0);
-            mesg = "spectral_ieee"; len = strlen(mesg);
+            static const char mesg[] = "spectral_ieee";
+            size_t len = sizeof (mesg) -1;
             GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
           }
         else */ if ( gridInqComplexPacking(gridID) )
 	  {
 	    if ( editionNumber == 2 ) GRIB_CHECK(my_grib_set_long(gh, "numberOfValues", gridInqSize(gridID)), 0);
-	    mesg = "spectral_complex"; len = strlen(mesg);
+            static const char mesg[] = "spectral_complex";
+            size_t len = sizeof (mesg) -1;
 	    GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
 
 	    GRIB_CHECK(my_grib_set_long(gh, "JS", 20), 0);
@@ -51200,7 +52128,8 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 	  }
 	else
 	  {
-	    mesg = "spectral_simple"; len = strlen(mesg);
+            static const char mesg[] = "spectral_simple";
+            size_t len = sizeof (mesg) -1;
 	    GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
 	  }
 
@@ -51222,7 +52151,8 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 
         if ( comptype == COMPRESS_SZIP )
           {
-            mesg = "grid_ccsds"; len = strlen(mesg);
+            static const char mesg[] = "grid_ccsds";
+            size_t len = sizeof (mesg) -1;
             GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
           }
 
@@ -51249,7 +52179,7 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
             if ( number < 0 ) number = 0;
 	    GRIB_CHECK(my_grib_set_long(gh, "numberOfGridUsed", number), 0);
 	    GRIB_CHECK(my_grib_set_long(gh, "numberOfGridInReference", position), 0);
-            len = CDI_UUID_SIZE;
+            size_t len = CDI_UUID_SIZE;
             gridInqUUID(gridID, uuid);
 	    if (grib_set_bytes(gh, "uuidOfHGrid", uuid, &len) != 0)
 	      Warning("Can't write UUID!");
@@ -51257,7 +52187,8 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 
         if ( comptype == COMPRESS_SZIP )
           {
-            mesg = "grid_ccsds"; len = strlen(mesg);
+            static const char mesg[] = "grid_ccsds";
+            size_t len = sizeof (mesg) -1;
             GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
           }
 
@@ -51321,7 +52252,7 @@ void grib2DefLevel(grib_handle *gh, int gcinit, long leveltype1, long leveltype2
 }
 
 static
-void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID, int levelID, int gcinit)
+void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID, int levelID, int gcinit, int proddef_template_num)
 {
   int lbounds = 0;
   static int warning = 1;
@@ -51371,7 +52302,15 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
           }
         else
           {
-            grib2DefLevel(gh, gcinit, grib2ltype, grib2ltype, lbounds, level, dlevel1, dlevel2);
+            /* PRODUCT DEFINITION TEMPLATE NUMBER 32:
+
+               "Analysis or forecast at a horizontal level or in a horizontal layer at a point
+                in time for simulate (synthetic) satellite data"
+
+               The key/value pairs that are set in "grib2DefLevel" do not exist for this template.
+            */
+            if ( proddef_template_num != 32 )
+              grib2DefLevel(gh, gcinit, grib2ltype, grib2ltype, lbounds, level, dlevel1, dlevel2);
           }
 
 	break;
@@ -51632,7 +52571,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
 #if defined(GRIBAPIENCODETEST)
   grib_handle *gh = (grib_handle *) gribHandleNew(editionNumber);
 #else
-  grib_handle *gh = gc->gribHandle;
+  grib_handle *gh = (struct grib_handle *)gc->gribHandle;
 #endif
   GRIB_CHECK(grib_get_long(gh, "editionNumber", &editionNumber), 0);
 
@@ -51656,7 +52595,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
   if ( ! gc->init ) gribapiDefInstitut(gh, vlistID, varID);
   if ( ! gc->init ) gribapiDefModel(gh, vlistID, varID);
 
-  if ( ! gc->init ) gribapiDefParam(editionNumber, gh, param, name, stdname);
+  if ( ! gc->init ) gribapiDefParam((int)editionNumber, gh, param, name, stdname);
 
   if ( editionNumber == 2 && (datatype == DATATYPE_FLT32 || datatype == DATATYPE_FLT64) ) lieee = TRUE;
 
@@ -51669,50 +52608,48 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
 
   gribapiDefGrid((int)editionNumber, gh, gridID, comptype, lieee, datatype, nmiss, gc->init);
 
-  gribapiDefLevel((int)editionNumber, gh, param, zaxisID, levelID, gc->init);
-
-  /* ---------------------------------- */
-  /* Local change: 2013-01-28, FP (DWD) */
-  /* ---------------------------------- */
+  gribapiDefLevel((int)editionNumber, gh, param, zaxisID, levelID, gc->init, productDefinitionTemplate);
 
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
   //if (!gc->init)
   {
-    for ( int i=0; i<vlistptr->vars[varID].opt_grib_dbl_nentries; i++ )
-      {
-        if ( vlistptr->vars[varID].opt_grib_dbl_update[i] )
-          {
-            //DR: Fix for multi-level fields (otherwise only the 1st level is correct)
-            if ( zaxisInqSize(zaxisID)==(levelID+1) ) vlistptr->vars[varID].opt_grib_dbl_update[i] = FALSE;
-            int ret = my_grib_set_double(gh, vlistptr->vars[varID].opt_grib_dbl_keyword[i],
-                                         vlistptr->vars[varID].opt_grib_dbl_val[i]);
-            if (ret != 0) {
-              fprintf(stderr, "key \"%s\"  :   value = %g\n",
-                      vlistptr->vars[varID].opt_grib_dbl_keyword[i],
-                      vlistptr->vars[varID].opt_grib_dbl_val[i]);
-            }
-            GRIB_CHECK(ret, 0);
-          }
-      }
-    for ( int i=0; i<vlistptr->vars[varID].opt_grib_int_nentries; i++ )
+    int ret = 0;
+
+    /* NOTE: Optional key/value pairs: Note that we do not distinguish
+     *       between tiles here! */
+
+    for ( int i=0; i<vlistptr->vars[varID].opt_grib_nentries; i++ )
       {
-        if ( vlistptr->vars[varID].opt_grib_int_update[i] )
+        if ( vlistptr->vars[varID].opt_grib_kvpair[i].update )
           {
             //DR: Fix for multi-level fields (otherwise only the 1st level is correct)
-            if ( zaxisInqSize(zaxisID)==(levelID+1) ) vlistptr->vars[varID].opt_grib_int_update[i] = FALSE;
-            int ret = my_grib_set_long(gh, vlistptr->vars[varID].opt_grib_int_keyword[i],
-                                       vlistptr->vars[varID].opt_grib_int_val[i]);
-            if (ret != 0) {
-              fprintf(stderr, "key \"%s\"  :   value = %d\n",
-                      vlistptr->vars[varID].opt_grib_int_keyword[i],
-                      vlistptr->vars[varID].opt_grib_int_val[i]);
-            }
-            GRIB_CHECK(ret, 0);
+            if ( zaxisInqSize(zaxisID)==(levelID+1) )
+              vlistptr->vars[varID].opt_grib_kvpair[i].update = FALSE;
+
+            if (vlistptr->vars[varID].opt_grib_kvpair[i].data_type == t_double)
+              {
+                if ( CDI_Debug )
+                  Message("key \"%s\"  :   double value = %g\n",
+                          vlistptr->vars[varID].opt_grib_kvpair[i].keyword,
+                          vlistptr->vars[varID].opt_grib_kvpair[i].dbl_val);
+                my_grib_set_double(gh, vlistptr->vars[varID].opt_grib_kvpair[i].keyword,
+                                   vlistptr->vars[varID].opt_grib_kvpair[i].dbl_val);
+                GRIB_CHECK(ret, 0);
+                }
+            if (vlistptr->vars[varID].opt_grib_kvpair[i].data_type == t_int)
+              {
+                if ( CDI_Debug )
+                  Message("key \"%s\"  :   integer value = %d\n",
+                          vlistptr->vars[varID].opt_grib_kvpair[i].keyword,
+                          vlistptr->vars[varID].opt_grib_kvpair[i].int_val);
+                my_grib_set_long(gh, vlistptr->vars[varID].opt_grib_kvpair[i].keyword,
+                                 (long) vlistptr->vars[varID].opt_grib_kvpair[i].int_val);
+                GRIB_CHECK(ret, 0);
+              }
           }
       }
   }
 
-
   if ( nmiss > 0 )
     {
       GRIB_CHECK(my_grib_set_long(gh, "bitmapPresent", 1), 0);
@@ -51725,7 +52662,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
   GRIB_CHECK(grib_get_message(gh, (const void **)&dummy, &recsize), 0);
   recsize += 512; /* add some space for possible filling */
   *gribbuffersize = recsize;
-  *gribbuffer = (unsigned char *) malloc(*gribbuffersize);
+  *gribbuffer = (unsigned char *) Malloc(*gribbuffersize);
 
   /* get a copy of the coded message */
   GRIB_CHECK(grib_get_message_copy(gh, *gribbuffer, &recsize), 0);
@@ -51775,7 +52712,7 @@ void streamDefHistory(int streamID, int length, const char *history)
                * history argument directly? */
 	      histstring = strdupx(history);
 	      cdfDefHistory(streamptr, length, histstring);
-	      free(histstring);
+	      Free(histstring);
 	    }
 	}
     }
@@ -51833,6 +52770,8 @@ void streamInqHistoryString(int streamID, char *history)
 #if defined (HAVE_CONFIG_H)
 #endif
 
+#include <limits.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -51857,7 +52796,7 @@ typedef struct {
 } IEGCOMPVAR;
 
 
-int iegInqDatatype(int prec)
+static int iegInqDatatype(int prec)
 {
   int datatype;
 
@@ -51868,7 +52807,7 @@ int iegInqDatatype(int prec)
 }
 
 
-int iegDefDatatype(int datatype)
+static int iegDefDatatype(int datatype)
 {
   int prec;
 
@@ -51930,7 +52869,7 @@ void iegReadRecord(stream_t *streamptr, double *data, int *nmiss)
   int varID, gridID;
   int i, size;
   double missval;
-  iegrec_t *iegp = (iegrec_t*) streamptr->record->exsep;
+  void *iegp = streamptr->record->exsep;
 
   vlistID = streamptr->vlistID;
   fileID  = streamptr->fileID;
@@ -52019,7 +52958,7 @@ int iegGetZaxisType(int iegleveltype)
 }
 
 
-void iegDefTime(int *pdb, int date, int time, int taxisID)
+static void iegDefTime(int *pdb, int date, int time, int taxisID)
 {
   int year, month, day, hour, minute, second;
   int timetype = -1;
@@ -52047,30 +52986,38 @@ void iegDefTime(int *pdb, int date, int time, int taxisID)
   pdb[5] = 128;
 }
 
-static
-int calc_resfac(double xfirst, double xlast, double xinc, double yfirst, double ylast, double yinc)
+/* find smallest power of 10 in [1000,10000000] that upon
+ * multiplication results in fractional part close to zero for all
+ * arguments */
+static double
+calc_resfac(double xfirst, double xlast, double xinc, double yfirst, double ylast, double yinc)
 {
-  int i, j;
-  int iresfac = 1000;
-  int ifact;
-  int ifacarr[5] = {1000, 10000, 100000, 1000000, 10000000};
-  double vals[6] = {xfirst, xlast, xinc, yfirst, ylast, yinc};
+  double resfac = 1000.0;
+  enum {
+    nPwrOf10 = 5,
+    nMultTests = 6,
+  };
+  static const double scaleFactors[nPwrOf10]
+    = { 1000, 10000, 100000, 1000000, 10000000 };
+  double vals[nMultTests] = { xfirst, xlast, xinc, yfirst, ylast, yinc };
 
-  for ( j = 0; j < 5; ++j )
+  for (size_t j = 0; j < nPwrOf10; ++j )
     {
-      ifact = ifacarr[j];
-      for ( i = 0; i < 6; ++i )
+      double scaleBy = scaleFactors[j];
+      bool fractionalScale = false;
+      for (size_t i = 0; i < nMultTests; ++i )
         {
-          if ( fabs(vals[i]*ifact - round(vals[i]*ifact)) > FLT_EPSILON ) break;
+          fractionalScale = fractionalScale
+            || fabs(vals[i]*scaleBy - round(vals[i]*scaleBy)) > FLT_EPSILON;
         }
-      if ( i == 6 )
+      if ( !fractionalScale )
         {
-          iresfac = ifact;
+          resfac = scaleBy;
           break;
         }
     }
 
-  return (iresfac);
+  return (resfac);
 }
 
 static
@@ -52147,8 +53094,8 @@ void iegDefGrid(int *gdb, int gridID)
       else
 	IEG_G_GridType(gdb) = 0;
 
-      int iresfac = calc_resfac(xfirst, xlast, xinc, yfirst, ylast, yinc);
-      double resfac = (double) iresfac;
+      double resfac = calc_resfac(xfirst, xlast, xinc, yfirst, ylast, yinc);
+      int iresfac = (int)resfac;
       if ( iresfac == 1000 ) iresfac = 0;
 
       IEG_G_ResFac(gdb)   = iresfac;
@@ -52232,7 +53179,7 @@ void iegDefLevel(int *pdb, int *gdb, double *vct, int zaxisID, int levelID)
       {
 	IEG_P_LevelType(pdb) = IEG_LTYPE_SURFACE;
 	IEG_P_Level1(pdb)    = 0;
-	IEG_P_Level2(pdb)    = (int) zaxisInqLevel(zaxisID, levelID);
+	IEG_P_Level2(pdb)    = (int)(zaxisInqLevel(zaxisID, levelID));
 	break;
       }
     case ZAXIS_HYBRID:
@@ -52242,14 +53189,14 @@ void iegDefLevel(int *pdb, int *gdb, double *vct, int zaxisID, int levelID)
 	if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
 	  {
 	    IEG_P_LevelType(pdb) = IEG_LTYPE_HYBRID_LAYER;
-	    IEG_P_Level1(pdb)    = (int) zaxisInqLbound(zaxisID, levelID);
-	    IEG_P_Level2(pdb)    = (int) zaxisInqUbound(zaxisID, levelID);
+	    IEG_P_Level1(pdb)    = (int)(zaxisInqLbound(zaxisID, levelID));
+	    IEG_P_Level2(pdb)    = (int)(zaxisInqUbound(zaxisID, levelID));
 	  }
 	else
 	  {
 	    IEG_P_LevelType(pdb) = IEG_LTYPE_HYBRID;
 	    IEG_P_Level1(pdb)    = 0;
-	    IEG_P_Level2(pdb)    = (int) zaxisInqLevel(zaxisID, levelID);
+	    IEG_P_Level2(pdb)    = (int)(zaxisInqLevel(zaxisID, levelID));
 	  }
 
 	vctsize = zaxisInqVctSize(zaxisID);
@@ -52331,8 +53278,8 @@ void iegDefLevel(int *pdb, int *gdb, double *vct, int zaxisID, int levelID)
 	if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
 	  {
 	    IEG_P_LevelType(pdb) = IEG_LTYPE_LANDDEPTH_LAYER;
-	    IEG_P_Level1(pdb)    = (int) zaxisInqLbound(zaxisID, levelID);
-	    IEG_P_Level2(pdb)    = (int) zaxisInqUbound(zaxisID, levelID);
+	    IEG_P_Level1(pdb)    = (int)(zaxisInqLbound(zaxisID, levelID));
+	    IEG_P_Level2(pdb)    = (int)(zaxisInqUbound(zaxisID, levelID));
 	  }
 	else
 	  {
@@ -52591,7 +53538,8 @@ void iegAddRecord(stream_t *streamptr, int param, int *pdb, int *gdb, double *vc
   datatype = iegInqDatatype(prec);
 
   varAddRecord(recID, param, gridID, leveltype, lbounds, level1, level2, 0, 0,
-	       datatype, &varID, &levelID, TSTEP_INSTANT, 0, 0, -1, NULL, NULL, NULL, NULL);
+	       datatype, &varID, &levelID, TSTEP_INSTANT, 0, 0, -1,
+               NULL, NULL, NULL, NULL, NULL, NULL);
 
   record->varID   = (short)varID;
   record->levelID = (short)levelID;
@@ -52633,7 +53581,7 @@ void iegCmpRecord(stream_t *streamptr, int tsID, int recID, off_t position, int
 }
 #endif
 
-void iegDateTime(int *pdb, int *date, int *time)
+static void iegDateTime(int *pdb, int *date, int *time)
 {
   int ryear, rmonth, rday, rhour, rminute;
 
@@ -52660,7 +53608,7 @@ void iegScanTimestep1(stream_t *streamptr)
   int tabnum;
   int param = 0;
   int rcode = 0, rlevel = 0, vdate = 0, vtime = 0;
-  DateTime datetime, datetime0;
+  DateTime datetime0 = { LONG_MIN, LONG_MIN };
   int tsID;
   int varID;
   size_t recsize;
@@ -52715,8 +53663,6 @@ void iegScanTimestep1(stream_t *streamptr)
 	}
       else
 	{
-	  datetime.date = vdate;
-	  datetime.time = vtime;
 	  compVar.param = param;
           compVar.level = rlevel;
 	  for ( recID = 0; recID < nrecs; recID++ )
@@ -52727,7 +53673,8 @@ void iegScanTimestep1(stream_t *streamptr)
 	      if ( memcmp(&compVar0, &compVar, sizeof(IEGCOMPVAR)) == 0 ) break;
 	    }
 	  if ( recID < nrecs ) break;
-	  if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) )
+	  DateTime datetime = { .date = vdate, .time = vtime};
+	  if ( datetimeCmp(datetime, datetime0) )
 	    Warning("Inconsistent verification time for param %d level %d", param, rlevel);
 	}
 
@@ -52758,11 +53705,11 @@ void iegScanTimestep1(stream_t *streamptr)
     {
       streamptr->tsteps[0].recordSize = nrecords;
       streamptr->tsteps[0].records =
-	(record_t *)xrealloc(streamptr->tsteps[0].records,
+	(record_t *) Realloc(streamptr->tsteps[0].records,
                              (size_t)nrecords * sizeof (record_t));
     }
 
-  streamptr->tsteps[0].recIDs = (int *)xmalloc((size_t)nrecords * sizeof (int));
+  streamptr->tsteps[0].recIDs = (int *) Malloc((size_t)nrecords * sizeof (int));
   streamptr->tsteps[0].nrecs = nrecords;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[0].recIDs[recID] = recID;
@@ -52825,7 +53772,7 @@ int iegScanTimestep2(stream_t *streamptr)
   cdi_create_records(streamptr, tsID);
 
   nrecords = streamptr->tsteps[0].nallrecs;
-  streamptr->tsteps[1].recIDs = (int *)xmalloc((size_t)nrecords * sizeof(int));
+  streamptr->tsteps[1].recIDs = (int *) Malloc((size_t)nrecords * sizeof(int));
   streamptr->tsteps[1].nrecs = 0;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[1].recIDs[recID] = -1;
@@ -53010,7 +53957,7 @@ long iegScanTimestep(stream_t *streamptr)
 
       streamptr->tsteps[tsID].nrecs = nrecs;
       streamptr->tsteps[tsID].recIDs
-        = (int *)xmalloc((size_t)nrecs * sizeof (int));
+        = (int *) Malloc((size_t)nrecs * sizeof (int));
       for ( recID = 0; recID < nrecs; recID++ )
 	streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
 
@@ -53137,11 +54084,12 @@ void iegReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
   int recID;
   int i;
   double missval;
-  iegrec_t *iegp = (iegrec_t*) streamptr->record->exsep;
+  void *iegp = streamptr->record->exsep;
 
   vlistID  = streamptr->vlistID;
   fileID   = streamptr->fileID;
-  nlevs    = streamptr->vars[varID].nlevs;
+  /* NOTE: tiles are not supported here! */
+  nlevs    = streamptr->vars[varID].recordTable[0].nlevs;
   missval  = vlistInqVarMissval(vlistID, varID);
   gridID   = vlistInqVarGrid(vlistID, varID);
   gridsize = gridInqSize(gridID);
@@ -53154,7 +54102,8 @@ void iegReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
 
   for (levID = 0; levID < nlevs; levID++)
     {
-      recID = streamptr->vars[varID].level[levID];
+      /* NOTE: tiles are not supported here! */
+      recID = streamptr->vars[varID].recordTable[0].recordID[levID];
       recpos = streamptr->tsteps[tsid].records[recID].position;
       fileSetPos(fileID, recpos, SEEK_SET);
       iegRead(fileID, iegp);
@@ -53181,11 +54130,12 @@ void iegReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data,
   int recID;
   int i;
   double missval;
-  iegrec_t *iegp = (iegrec_t*) streamptr->record->exsep;
+  void *iegp = streamptr->record->exsep;
 
   vlistID  = streamptr->vlistID;
   fileID   = streamptr->fileID;
-  nlevs    = streamptr->vars[varID].nlevs;
+  /* NOTE: tiles are not supported here! */
+  nlevs    = streamptr->vars[varID].recordTable[0].nlevs;
   missval  = vlistInqVarMissval(vlistID, varID);
   gridID   = vlistInqVarGrid(vlistID, varID);
   gridsize = gridInqSize(gridID);
@@ -53197,7 +54147,8 @@ void iegReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data,
 
   currentfilepos = fileGetPos(fileID);
 
-  recID = streamptr->vars[varID].level[levID];
+  /* NOTE: tiles are not supported here! */
+  recID = streamptr->vars[varID].recordTable[0].recordID[levID];
   recpos = streamptr->tsteps[tsid].records[recID].position;
   fileSetPos(fileID, recpos, SEEK_SET);
   iegRead(fileID, iegp);
@@ -53325,6 +54276,7 @@ void iegWriteVarSliceDP(stream_t *streamptr, int varID, int levID, const double
 #if defined (HAVE_CONFIG_H)
 #endif
 
+#include <limits.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -53341,13 +54293,14 @@ void recordInitEntry(record_t *record)
   record->varID    = CDI_UNDEFID;
   record->levelID  = CDI_UNDEFID;
   memset(record->varname, 0, sizeof(record->varname));
+  memset(&record->tiles, 0, sizeof(record->tiles));
 }
 
 
 int recordNewEntry(stream_t *streamptr, int tsID)
 {
-  int recordID = 0;
-  int recordSize = streamptr->tsteps[tsID].recordSize;
+  size_t recordID = 0;
+  size_t recordSize = (size_t)streamptr->tsteps[tsID].recordSize;
   record_t *records = streamptr->tsteps[tsID].records;
   /*
     Look for a free slot in record.
@@ -53355,44 +54308,33 @@ int recordNewEntry(stream_t *streamptr, int tsID)
   */
   if ( ! recordSize )
     {
-      int i;
       recordSize = 1;   /*  <<<<----  */
-      records = (record_t *)xmalloc((size_t)recordSize * sizeof (record_t));
-      if ( records == NULL )
-	{
-          Message("recordSize = %d", recordSize);
-	  SysError("Allocation of records failed");
-	}
+      records = (record_t *) Malloc(recordSize * sizeof (record_t));
 
-      for ( i = 0; i < recordSize; i++ )
+      for ( size_t i = 0; i < recordSize; i++ )
 	records[i].used = CDI_UNDEFID;
     }
   else
     {
-      while ( recordID < recordSize )
-	{
-	  if ( records[recordID].used == CDI_UNDEFID ) break;
-	  recordID++;
-	}
+      while ( recordID < recordSize
+              && records[recordID].used != CDI_UNDEFID )
+        ++recordID;
     }
   /*
     If the table overflows, double its size.
   */
   if ( recordID == recordSize )
     {
-      int i;
-
-      recordSize = 2*recordSize;
-      records    = (record_t *)xrealloc(records,
-                                        (size_t)recordSize * sizeof (record_t));
-      if ( records == NULL )
-	{
-          Message("recordSize = %d", recordSize);
-	  SysError("Reallocation of records failed");
-	}
-      recordID = recordSize/2;
+      if (recordSize <= INT_MAX / 2)
+        recordSize *= 2;
+      else if (recordSize < INT_MAX)
+        recordSize = INT_MAX;
+      else
+        Error("Cannot handle this many records!\n");
+      records = (record_t *) Realloc(records,
+                                     recordSize * sizeof (record_t));
 
-      for ( i = recordID; i < recordSize; i++ )
+      for ( size_t i = recordID; i < recordSize; i++ )
 	records[i].used = CDI_UNDEFID;
     }
 
@@ -53400,16 +54342,16 @@ int recordNewEntry(stream_t *streamptr, int tsID)
 
   records[recordID].used = 1;
 
-  streamptr->tsteps[tsID].recordSize = recordSize;
+  streamptr->tsteps[tsID].recordSize = (int)recordSize;
   streamptr->tsteps[tsID].records    = records;
 
-  return (recordID);
+  return (int)recordID;
 }
 
 static
 void cdiInitRecord(stream_t *streamptr)
 {
-  streamptr->record = (Record *) malloc(sizeof(Record));
+  streamptr->record = (Record *) Malloc(sizeof(Record));
 
   streamptr->record->param      = 0;
   streamptr->record->level      = 0;
@@ -53450,7 +54392,8 @@ void streamInqRecord(int streamID, int *varID, int *levelID)
   *varID   = streamptr->tsteps[tsID].records[recID].varID;
   int lindex = streamptr->tsteps[tsID].records[recID].levelID;
 
-  *levelID = streamptr->vars[*varID].lindex[lindex];
+  int isub = subtypeInqActiveIndex(streamptr->vars[*varID].subtypeID);
+  *levelID = streamptr->vars[*varID].recordTable[isub].lindex[lindex];
 
   if ( CDI_Debug )
     Message("tsID = %d, recID = %d, varID = %d, levelID = %d\n", tsID, recID, *varID, *levelID);
@@ -53492,7 +54435,7 @@ void streamDefRecord(int streamID, int varID, int levelID)
   int gridID  = vlistInqVarGrid(vlistID, varID);
   int zaxisID = vlistInqVarZaxis(vlistID, varID);
   int param   = vlistInqVarParam(vlistID, varID);
-  int level   = (int) zaxisInqLevel(zaxisID, levelID);
+  int level   = (int)(zaxisInqLevel(zaxisID, levelID));
 
   streamptr->record->varID    = varID;
   streamptr->record->levelID  = levelID;
@@ -53752,8 +54695,8 @@ void cdi_create_records(stream_t *streamptr, int tsID)
   unsigned nrecords, maxrecords;
   record_t *records;
 
-  tsteps_t* sourceTstep = streamptr->tsteps;
-  tsteps_t* destTstep = sourceTstep + tsID;
+  tsteps_t *sourceTstep = streamptr->tsteps;
+  tsteps_t *destTstep = sourceTstep + tsID;
 
   if ( destTstep->records ) return;
 
@@ -53764,7 +54707,8 @@ void cdi_create_records(stream_t *streamptr, int tsID)
       maxrecords = 0;
       int nvars = streamptr->nvars;
       for ( int varID = 0; varID < nvars; varID++)
-	maxrecords += (unsigned)streamptr->vars[varID].nlevs;
+        for (int isub=0; isub<streamptr->vars[varID].subtypeSize; isub++)
+          maxrecords += (unsigned)streamptr->vars[varID].recordTable[isub].nlevs;
     }
   else
     {
@@ -53794,7 +54738,7 @@ void cdi_create_records(stream_t *streamptr, int tsID)
   //  printf("tsID, nrecords %d %d\n", tsID, nrecords);
 
   if ( maxrecords > 0 )
-    records = (record_t *) malloc(maxrecords * sizeof(record_t));
+    records = (record_t *) Malloc(maxrecords*sizeof(record_t));
   else
     records = NULL;
 
@@ -53813,7 +54757,7 @@ void cdi_create_records(stream_t *streamptr, int tsID)
 
       for ( unsigned recID = 0; recID < maxrecords; recID++ )
 	{
-          record_t* curRecord = &sourceTstep->records[recID];
+          record_t *curRecord = &sourceTstep->records[recID];
           destTstep->records[recID].used = curRecord->used;
           if ( curRecord->used != CDI_UNDEFID && curRecord->varID != -1 ) /* curRecord->varID = -1 for write mode !!! */
             {
@@ -53862,7 +54806,7 @@ typedef struct {
 } SRVCOMPVAR;
 
 
-int srvInqDatatype(int prec)
+static int srvInqDatatype(int prec)
 {
   int datatype;
 
@@ -53873,7 +54817,7 @@ int srvInqDatatype(int prec)
 }
 
 
-int srvDefDatatype(int datatype)
+static int srvDefDatatype(int datatype)
 {
   int prec;
 
@@ -53898,7 +54842,7 @@ int srvInqRecord(stream_t *streamptr, int *varID, int *levelID)
   int zaxisID = -1;
   int header[8];
   int vlistID;
-  srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
+  void *srvp = streamptr->record->exsep;
 
   vlistID = streamptr->vlistID;
   fileID  = streamptr->fileID;
@@ -53936,7 +54880,7 @@ void srvReadRecord(stream_t *streamptr, double *data, int *nmiss)
   int varID, gridID;
   int i, size;
   double missval;
-  srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
+  void *srvp = streamptr->record->exsep;
 
   vlistID = streamptr->vlistID;
   fileID  = streamptr->fileID;
@@ -54021,10 +54965,9 @@ void srvDefRecord(stream_t *streamptr)
 void srvWriteRecord(stream_t *streamptr, const double *data)
 {
   int fileID = streamptr->fileID;
-  srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
+  void *srvp = streamptr->record->exsep;
 
   srvDefDataDP(srvp, data);
-
   srvWrite(fileID, srvp);
 }
 
@@ -54061,9 +55004,9 @@ void srv_add_record(stream_t *streamptr, int param, int level, int xsize, int ys
 
   int levelID = 0;
   int varID;
-
   varAddRecord(recID, param, gridID, leveltype, 0, level, 0, 0, 0,
-	       datatype, &varID, &levelID, TSTEP_INSTANT, 0, 0, -1, NULL, NULL, NULL, NULL);
+	       datatype, &varID, &levelID, TSTEP_INSTANT, 0, 0, -1,
+               NULL, NULL, NULL, NULL, NULL, NULL);
 
   xassert(varID <= SHRT_MAX && levelID <= SHRT_MAX);
   record->varID   = (short)varID;
@@ -54087,7 +55030,7 @@ void srvScanTimestep1(stream_t *streamptr)
   int rxsize = 0, rysize = 0;
   int param = 0;
   int rcode = 0, rlevel = 0, vdate = 0, vtime = 0;
-  DateTime datetime, datetime0;
+  DateTime datetime0 = { LONG_MIN, LONG_MIN };
   int tsID;
   int varID;
   off_t recpos;
@@ -54095,7 +55038,6 @@ void srvScanTimestep1(stream_t *streamptr)
   int taxisID = -1;
   taxis_t *taxis;
   int vlistID;
-  SRVCOMPVAR compVar, compVar0;
   srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
 
   streamptr->curTsID = 0;
@@ -54139,19 +55081,13 @@ void srvScanTimestep1(stream_t *streamptr)
 	}
       else
 	{
-	  datetime.date = vdate;
-	  datetime.time = vtime;
-	  compVar.param = param;
-          compVar.level = rlevel;
 	  for ( recID = 0; recID < nrecs; recID++ )
-	    {
-	      compVar0.param = streamptr->tsteps[0].records[recID].param;
-	      compVar0.level = streamptr->tsteps[0].records[recID].ilevel;
-
-	      if ( memcmp(&compVar0, &compVar, sizeof(SRVCOMPVAR)) == 0 ) break;
-	    }
+            if (    streamptr->tsteps[0].records[recID].param  == param
+                 && streamptr->tsteps[0].records[recID].ilevel == rlevel )
+              break;
 	  if ( recID < nrecs ) break;
-	  if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) )
+	  DateTime datetime = { .date = vdate, .time = vtime };
+	  if ( datetimeCmp(datetime, datetime0) )
 	    Warning("Inconsistent verification time for code %d level %d", rcode, rlevel);
 	}
 
@@ -54182,11 +55118,11 @@ void srvScanTimestep1(stream_t *streamptr)
     {
       streamptr->tsteps[0].recordSize = nrecords;
       streamptr->tsteps[0].records =
-	(record_t *)xrealloc(streamptr->tsteps[0].records,
+	(record_t *) Realloc(streamptr->tsteps[0].records,
                              (size_t)nrecords * sizeof(record_t));
     }
 
-  streamptr->tsteps[0].recIDs = (int *)xmalloc((size_t)nrecords * sizeof (int));
+  streamptr->tsteps[0].recIDs = (int *) Malloc((size_t)nrecords * sizeof (int));
   streamptr->tsteps[0].nrecs = nrecords;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[0].recIDs[recID] = recID;
@@ -54230,7 +55166,7 @@ int srvScanTimestep2(stream_t *streamptr)
   taxis_t *taxis;
   int vlistID;
   SRVCOMPVAR compVar, compVar0;
-  srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
+  void *srvp = streamptr->record->exsep;
 
   streamptr->curTsID = 1;
 
@@ -54248,7 +55184,7 @@ int srvScanTimestep2(stream_t *streamptr)
   cdi_create_records(streamptr, tsID);
 
   nrecords = streamptr->tsteps[0].nallrecs;
-  streamptr->tsteps[1].recIDs = (int *)xmalloc((size_t)nrecords * sizeof (int));
+  streamptr->tsteps[1].recIDs = (int *) Malloc((size_t)nrecords * sizeof (int));
   streamptr->tsteps[1].nrecs = 0;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[1].recIDs[recID] = -1;
@@ -54400,8 +55336,7 @@ long srvScanTimestep(stream_t *streamptr)
   off_t recpos = 0;
   int recID;
   int rindex, nrecs = 0;
-  SRVCOMPVAR compVar, compVar0;
-  srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
+  void *srvp = streamptr->record->exsep;
   /*
   if ( CDI_Debug )
     {
@@ -54422,7 +55357,7 @@ long srvScanTimestep(stream_t *streamptr)
       nrecs = streamptr->tsteps[1].nrecs;
 
       streamptr->tsteps[tsID].nrecs = nrecs;
-      streamptr->tsteps[tsID].recIDs = (int *)xmalloc((size_t)nrecs * sizeof (int));
+      streamptr->tsteps[tsID].recIDs = (int *) Malloc((size_t)nrecs * sizeof (int));
       for ( recID = 0; recID < nrecs; recID++ )
 	streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
 
@@ -54463,12 +55398,8 @@ long srvScanTimestep(stream_t *streamptr)
 	      taxis->vtime = vtime;
 	    }
 
-	  compVar.param  = param;
-          compVar.level  = rlevel;
-	  compVar0.param = streamptr->tsteps[tsID].records[recID].param;
-	  compVar0.level = streamptr->tsteps[tsID].records[recID].ilevel;
-
-	  if ( memcmp(&compVar0, &compVar, sizeof(SRVCOMPVAR)) != 0 )
+          if (    param  != streamptr->tsteps[tsID].records[recID].param
+               || rlevel != streamptr->tsteps[tsID].records[recID].ilevel )
 	    {
 	      Message("tsID = %d recID = %d param = %3d new %3d  level = %3d new %3d",
 		      tsID, recID,
@@ -54549,11 +55480,12 @@ void srvReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
   int recID;
   int i;
   double missval;
-  srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
+  void *srvp = streamptr->record->exsep;
 
   vlistID  = streamptr->vlistID;
   fileID   = streamptr->fileID;
-  nlevs    = streamptr->vars[varID].nlevs;
+  /* NOTE: tiles are not supported here! */
+  nlevs    = streamptr->vars[varID].recordTable[0].nlevs;
   missval  = vlistInqVarMissval(vlistID, varID);
   gridID   = vlistInqVarGrid(vlistID, varID);
   gridsize = gridInqSize(gridID);
@@ -54566,7 +55498,8 @@ void srvReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
 
   for (levID = 0; levID < nlevs; levID++)
     {
-      recID = streamptr->vars[varID].level[levID];
+      /* NOTE: tiles are not supported here! */
+      recID = streamptr->vars[varID].recordTable[0].recordID[levID];
       recpos = streamptr->tsteps[tsid].records[recID].position;
       fileSetPos(fileID, recpos, SEEK_SET);
       if (srvRead(fileID, srvp) < 0)
@@ -54596,11 +55529,12 @@ void srvReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data,
   int recID;
   int i;
   double missval;
-  srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
+  void *srvp = streamptr->record->exsep;
 
   vlistID  = streamptr->vlistID;
   fileID   = streamptr->fileID;
-  nlevs    = streamptr->vars[varID].nlevs;
+  /* NOTE: tiles are not supported here! */
+  nlevs    = streamptr->vars[varID].recordTable[0].nlevs;
   missval  = vlistInqVarMissval(vlistID, varID);
   gridID   = vlistInqVarGrid(vlistID, varID);
   gridsize = gridInqSize(gridID);
@@ -54612,7 +55546,8 @@ void srvReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data,
 
   currentfilepos = fileGetPos(fileID);
 
-  recID = streamptr->vars[varID].level[levID];
+  /* NOTE: tiles are not supported here! */
+  recID = streamptr->vars[varID].recordTable[0].recordID[levID];
   recpos = streamptr->tsteps[tsid].records[recID].position;
   fileSetPos(fileID, recpos, SEEK_SET);
   if (srvRead(fileID, srvp) < 0)
@@ -54772,18 +55707,27 @@ void srvWriteVarSliceDP(stream_t *streamptr, int varID, int levID, const double
 
 
 
+static void streamvar_init_recordtable(stream_t *streamptr, int varID, int isub)
+{
+  streamptr->vars[varID].recordTable[isub].nlevs    = 0;
+  streamptr->vars[varID].recordTable[isub].recordID = NULL;
+  streamptr->vars[varID].recordTable[isub].lindex   = NULL;
+}
+
+
 static
 void streamvar_init_entry(stream_t *streamptr, int varID)
 {
   streamptr->vars[varID].ncvarid      = CDI_UNDEFID;
   streamptr->vars[varID].defmiss      = 0;
-  streamptr->vars[varID].nlevs        = 0;
-  streamptr->vars[varID].level        = NULL;
-  streamptr->vars[varID].lindex       = NULL;
+
+  streamptr->vars[varID].subtypeSize  = 0;
+  streamptr->vars[varID].recordTable  = NULL;
 
   streamptr->vars[varID].gridID       = CDI_UNDEFID;
   streamptr->vars[varID].zaxisID      = CDI_UNDEFID;
   streamptr->vars[varID].tsteptype    = CDI_UNDEFID;
+  streamptr->vars[varID].subtypeID    = CDI_UNDEFID;
 }
 
 static
@@ -54805,7 +55749,7 @@ int streamvar_new_entry(stream_t *streamptr)
 
       streamvarSize = 2;
       streamvar
-        = (svarinfo_t *)xmalloc((size_t)streamvarSize * sizeof(svarinfo_t));
+        = (svarinfo_t *) Malloc((size_t)streamvarSize * sizeof(svarinfo_t));
       if ( streamvar == NULL )
 	{
           Message("streamvarSize = %d", streamvarSize);
@@ -54832,7 +55776,7 @@ int streamvar_new_entry(stream_t *streamptr)
 
       streamvarSize = 2*streamvarSize;
       streamvar
-        = (svarinfo_t *)xrealloc(streamvar,
+        = (svarinfo_t *) Realloc(streamvar,
                                  (size_t)streamvarSize * sizeof (svarinfo_t));
       if ( streamvar == NULL )
 	{
@@ -54851,46 +55795,925 @@ int streamvar_new_entry(stream_t *streamptr)
   streamvar_init_entry(streamptr, varID);
 
   streamptr->vars[varID].isUsed = TRUE;
-
   return (varID);
 }
 
 
-int stream_new_var(stream_t *streamptr, int gridID, int zaxisID)
+static void
+allocate_record_table_entry(stream_t *streamptr, int varID, int subID, int nlevs)
 {
-  int varID;
-  int *level;
-  int *lindex;
-  int nlevs;
-  int levID;
+  int *level    = (int *) Malloc((size_t)nlevs * sizeof (int));
+  int *lindex   = (int *) Malloc((size_t)nlevs * sizeof (int));
+
+  for (int levID = 0; levID < nlevs; levID++ )
+    {
+      level[levID]    = CDI_UNDEFID;
+      lindex[levID]   = levID;
+    }
 
+  streamptr->vars[varID].recordTable[subID].nlevs    = nlevs;
+  streamptr->vars[varID].recordTable[subID].recordID = level;
+  streamptr->vars[varID].recordTable[subID].lindex   = lindex;
+}
+
+
+int stream_new_var(stream_t *streamptr, int gridID, int zaxisID, int tilesetID)
+{
   if ( CDI_Debug )
     Message("gridID = %d  zaxisID = %d", gridID, zaxisID);
 
-  varID = streamvar_new_entry(streamptr);
+  int varID = streamvar_new_entry(streamptr);
+  int nlevs = zaxisInqSize(zaxisID);
 
   streamptr->nvars++;
 
   streamptr->vars[varID].gridID  = gridID;
   streamptr->vars[varID].zaxisID = zaxisID;
 
-  nlevs = zaxisInqSize(zaxisID);
+  int nsub = 1;
+  if (tilesetID != CDI_UNDEFID)
+    nsub = subtypeInqSize(tilesetID); /* e.g. no of tiles */
+  if ( CDI_Debug )
+    Message("varID %d: create %d tiles with %d level(s), zaxisID=%d", varID, nsub, nlevs,zaxisID);
+  streamptr->vars[varID].recordTable = (sleveltable_t *) Malloc((size_t)nsub * sizeof (sleveltable_t));
+  if( streamptr->vars[varID].recordTable == NULL )
+    SysError("Allocation of leveltable failed!");
+  streamptr->vars[varID].subtypeSize = nsub;
+
+  for (int isub=0; isub<nsub; isub++) {
+    streamvar_init_recordtable(streamptr, varID, isub);
+    allocate_record_table_entry(streamptr, varID, isub, nlevs);
+    if ( CDI_Debug )
+      Message("streamptr->vars[varID].recordTable[isub].recordID[0]=%d",
+              streamptr->vars[varID].recordTable[isub].recordID[0]);
+  }
 
-  level  = (int *)xmalloc((size_t)nlevs * sizeof (int));
-  lindex = (int *)xmalloc((size_t)nlevs * sizeof (int));
+  streamptr->vars[varID].subtypeID = tilesetID;
 
-  for ( levID = 0; levID < nlevs; levID++ )
-    level[levID] = CDI_UNDEFID;
+  return (varID);
+}
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
+/* Subroutines and data structures for storing "subtypes".             */
+/*                                                                     */
+/* A subtype is, for example, a list of TILES. This can be interpreted */
+/* as an additional axis like the vertical axis.                       */
+/*                                                                     */
+/* @author 02/2015 F. Prill, DWD                                       */
+/*                                                                     */
+/*  DATA LAYOUT:                                                       */
+/*                                                                     */
+/*  A subtype contains several "subtype entries", each of which        */
+/*  contains a linked list of subtype attributes.                      */
+/*                                                                     */
+/*  The number of subtype entries is not specified in advance, but the */
+/*  list of entries is itself dynamically growing. There is no         */
+/*  guaranteed ordering of the entries, therefore each entry must be   */
+/*  identifiable by its attributes.                                    */
+/*                                                                     */
+/*  [subtype_t]                                                        */
+/*      |                                                              */
+/*      |------- globals                  [subtype_entry_t]            */
+/*      |          |--- atts              [subtype_attr_t]             */
+/*      |                                                              */
+/*      |------- entries                                               */
+/*                 |- entry #0                                         */
+/*                 |  |--- atts              [subtype_attr_t]          */
+/*                 |- entry #1                                         */
+/*                 |  |--- atts              [subtype_attr_t]          */
+/*                 |- entry #2                                         */
+/*                 .  |--- atts              [subtype_attr_t]          */
+/*                 .                                                   */
 
-  for ( levID = 0; levID < nlevs; levID++ )
-    lindex[levID] = levID;
+#if defined (HAVE_CONFIG_H)
+#endif
 
-  streamptr->vars[varID].nlevs  = nlevs;
-  streamptr->vars[varID].level  = level;
-  streamptr->vars[varID].lindex = lindex;
 
-  return (varID);
+/* Literal constants corresponding to the different subtypes of the
+   enumeration "subtype_kind". */
+static const char* subtypeName[] = {
+  "tileset"
+};
+
+const char * const cdiSubtypeAttributeName[] = {
+  "tileIndex",
+  "totalNumberOfTileAttributePairs",
+  "tileClassification",
+  "numberOfTiles",
+  "numberOfTileAttributes",
+  "tileAttribute"
+};
+
+
+/* prototypes: */
+static int    subtypeCompareP    (subtype_t *z1, subtype_t *z2);
+static void   subtypeDestroyP    ( void * subtype_ptr );
+static void   subtypePrintP      ( void * subtype_ptr, FILE * fp );
+static int    subtypeGetPackSize ( void * subtype_ptr, void *context);
+static void   subtypePack        ( void * subtype_ptr, void * buffer, int size, int *pos, void *context);
+static int    subtypeTxCode      ( void );
+
+static const resOps subtypeOps = {
+  (int (*) (void *, void *)) subtypeCompareP,
+  (void (*)(void *))         subtypeDestroyP,
+  (void (*)(void *, FILE *)) subtypePrintP,
+  (int (*) (void *, void *)) subtypeGetPackSize,
+                             subtypePack,
+                             subtypeTxCode
+};
+
+enum {
+  differ = 1,
+};
+
+
+
+/* ------------------------------------------------------------------- */
+/* SUBROUTINES FOR ATTRIBUTE LISTS				       */
+/* ------------------------------------------------------------------- */
+
+
+static int attribute_to_index(const char *key)
+{
+  if (key == NULL)  Error("Internal error!");
+  for (int i=0; i<nSubtypeAttributes; i++)
+    if ( strcmp(key, cdiSubtypeAttributeName[i]) == 0 ) return i;
+  return -1;
+}
+
+
+
+/*
+  @Function  subtypeAttrNewList
+  @Title     Create new linked list of subtype attributes.
+  @EndFunction
+*/
+static struct subtype_attr_t* subtypeAttrNewList(struct subtype_entry_t* head, int key, int val)
+{
+  if (head == NULL)  Error("Internal error!");
+  struct subtype_attr_t *ptr = (struct subtype_attr_t*) Malloc(sizeof(struct subtype_attr_t));
+  if(NULL == ptr)  Error("Node creation failed");
+  ptr->key   = key;
+  ptr->val   = val;
+  ptr->next  = NULL;
+
+  head->atts = ptr;
+  return ptr;
+}
+
+
+/*
+  @Function  subtypeAttrInsert
+
+  @Title Add subtype attribute to linked list, s.t. the result is a
+         smallest-to-largest ordered list.
+  @EndFunction
+*/
+static struct subtype_attr_t* subtypeAttrInsert(struct subtype_entry_t* head, int key, int val)
+{
+  if (head == NULL)  Error("Internal error!");
+  if (head->atts == NULL)  return (subtypeAttrNewList(head, key, val));
+
+  /* create new attribute */
+  struct subtype_attr_t* ptr = (struct subtype_attr_t*) Malloc(sizeof(struct subtype_attr_t));
+  if(NULL == ptr)    Error("Node creation failed");
+
+  ptr->key   = key;
+  ptr->val   = val;
+  ptr->next  = NULL;
+
+  /* find the right place for insertion: */
+  if (head->atts->key >= key) {
+    /* insert at position 0 */
+    ptr->next = head->atts;
+    head->atts = ptr;
+  } else {
+    struct subtype_attr_t** predec = &head->atts;
+    while (((*predec)->next != NULL) && ((*predec)->next->key < key)) {
+      predec = &((*predec)->next);
+    }
+    ptr->next = (*predec)->next;
+    (*predec)->next = ptr;  
+  }
+  return ptr;
+}
+
+
+/* Recursively free a linked list with attributes. */
+static void subtypeAttrDestroy(struct subtype_attr_t* head)
+{
+  if (head == NULL) return;
+  subtypeAttrDestroy(head->next);
+  Free(head);
+  head = NULL; 
+}
+
+
+/* Find an attribute in linked list by its key or return NULL
+   otherwise. */
+static struct subtype_attr_t* subtypeAttrFind(struct subtype_attr_t* head, int key)
+{
+  if (head == NULL) 
+    return NULL;
+  else if (head->key == key)
+    return head;
+  else
+    return subtypeAttrFind(head->next, key);
+}
+
+
+/* Recursively compares two subtype attribute lists under the implicit
+   assumptions that both lists are ordered by their keys and that keys
+   are unique. */
+static int subtypeAttsCompare(struct subtype_attr_t *a1, struct subtype_attr_t *a2)
+{
+  if ((a1 == NULL) && (a2 == NULL)) 
+    return 0;
+  else if ((a1 == NULL) && (a2 != NULL)) 
+    {
+      return differ;
+    }
+  else if ((a1 != NULL) && (a2 == NULL)) 
+    {
+      return differ;
+    }
+
+  if (a1->key != a2->key) 
+    {
+      return differ;
+    }
+  if (a1->val != a2->val)
+    return differ;
+    
+  return subtypeAttsCompare(a1->next, a2->next);
+}
+
+
+/* (Recursively) duplicate linked list of attributes. */
+static void subtypeAttsDuplicate(struct subtype_attr_t *a1, struct subtype_entry_t* dst)
+{
+  if (a1 == NULL)  return;
+  /* duplicate "a1->key", "a1->val" */
+  subtypeAttsDuplicate(a1->next, dst);
+  (void) subtypeAttrInsert(dst, a1->key, a1->val);
+}
+
+
+
+/* ------------------------------------------------------------------- */
+/* SUBROUTINES FOR LIST OF ENTRIES				       */
+/* ------------------------------------------------------------------- */
+
+
+/*
+  @Function  subtypeEntryNewList
+  @Title     Create new linked list of subtype entries.
+  @EndFunction
+*/
+static struct subtype_entry_t* subtypeEntryNewList(subtype_t* head)
+{
+  struct subtype_entry_t *ptr = (struct subtype_entry_t*) Malloc(sizeof(struct subtype_entry_t));
+  if(NULL == ptr)  Error("Node creation failed");
+  ptr->atts      = NULL;
+  ptr->next      = NULL;
+  head->entries  = ptr;
+  head->nentries = 0;
+  ptr->self      = head->nentries++;
+  return ptr;
+}
+
+
+/*
+  @Function  subtypeEntryInsert
+
+  @Title Add subtype entry to the head of a linked list.
+  @EndFunction
+*/
+struct subtype_entry_t* subtypeEntryInsert(subtype_t* head)
+{
+  if (head == NULL)  Error("Internal error!");
+  if (head->entries == NULL)  return (subtypeEntryNewList(head));
+
+  /* create new entry */
+  struct subtype_entry_t* ptr = (struct subtype_entry_t*) Malloc(sizeof(struct subtype_entry_t));
+  if(NULL == ptr)    Error("Node creation failed");
+
+  ptr->atts     = NULL;
+  ptr->self     = head->nentries++;
+
+  /* find the right place for insertion: */
+  if (head->entries->self >= ptr->self) {
+    /* insert at position 0 */
+    ptr->next     = head->entries;
+    head->entries = ptr;
+  } else {
+    struct subtype_entry_t** predec = &head->entries;
+    while (((*predec)->next != NULL) && ((*predec)->next->self < ptr->self)) {
+      predec = &((*predec)->next);
+    }
+    ptr->next = (*predec)->next;
+    (*predec)->next = ptr;  
+  }
+  return ptr;
+}
+
+
+/*
+  @Function  subtypeEntryAppend
+
+  @Title Append subtype entry to the end of a linked list.
+  @EndFunction
+*/
+static struct subtype_entry_t* subtypeEntryAppend(subtype_t* head)
+{
+  if (head == NULL)  Error("Internal error!");
+  if (head->entries == NULL)  return (subtypeEntryNewList(head));
+
+  /* create new entry */
+  struct subtype_entry_t* ptr = (struct subtype_entry_t*) Malloc(sizeof(struct subtype_entry_t));
+  if(NULL == ptr)    Error("Node creation failed");
+
+  ptr->atts     = NULL;
+  ptr->next     = NULL;
+  ptr->self     = head->nentries++;
+
+  /* find last position of linked list */
+  struct subtype_entry_t* prec_ptr = head->entries;
+  while (prec_ptr->next != NULL)
+    prec_ptr = prec_ptr->next;
+
+  prec_ptr->next  = ptr;
+  return ptr;
+}
+
+
+/* Recursively free a list of subtype entries. */
+static void subtypeEntryDestroy(struct subtype_entry_t *entry)
+{
+  if (entry == NULL) return;
+  subtypeEntryDestroy(entry->next);
+  subtypeAttrDestroy(entry->atts);
+  Free(entry);
+  entry = NULL;
+}
+
+
+/* Compares two subtype entries. */
+static int subtypeEntryCompare(struct subtype_entry_t *e1, struct subtype_entry_t *e2)
+{
+  if (e1 == NULL)  Error("Internal error!");
+  if (e2 == NULL)  Error("Internal error!");
+  return 
+    (e1->self == e2->self) && 
+    subtypeAttsCompare(e1->atts, e2->atts);
 }
+
+
+/* (Recursively) duplicate list of entries. */
+static void subtypeEntryDuplicate(struct subtype_entry_t *a1, subtype_t* dst)
+{
+  if (a1 == NULL) return;
+  /* append entry to dst pointer */
+  struct subtype_entry_t *ptr = subtypeEntryAppend(dst);
+  /* duplicate attributes */
+  subtypeAttsDuplicate(a1->atts, ptr);
+  ptr->self = a1->self;
+  /* call next link in linked list */
+  subtypeEntryDuplicate(a1->next, dst);
+}
+
+
+
+/* ------------------------------------------------------------------- */
+/* SUBROUTINES FOR THE SUBTYPE ITSELF				       */
+/* ------------------------------------------------------------------- */
+
+/* Print-out subtype data structure together with its attributes. */
+static void subtypePrintKernel(subtype_t *subtype_ptr, FILE *fp)
+{
+  if (subtype_ptr == NULL)  Error("Internal error!");
+  fprintf(fp, "# %s (subtype ID %d)\n", subtypeName[subtype_ptr->subtype], subtype_ptr->self);
+  /* print global attributes of this subtype */
+  struct subtype_attr_t* ptr = subtype_ptr->globals.atts;
+  if (ptr != NULL)  fprintf(fp, "#\n# global attributes:\n");
+  while (ptr != NULL) {
+    fprintf(fp, "#   %-40s   (%2d) : %d\n", cdiSubtypeAttributeName[ptr->key], ptr->key, ptr->val);    
+    ptr = ptr->next;
+  } 
+  /* print attributes for each subtype */
+  fprintf(fp, "# %d local entries:\n", subtype_ptr->nentries);
+  struct subtype_entry_t *entry = subtype_ptr->entries;
+  while (entry != NULL) {
+    fprintf(fp, "# subtype entry %d\n", entry->self);
+    ptr = entry->atts;
+    if (ptr != NULL)  fprintf(fp, "#   attributes:\n");
+    while (ptr != NULL) {
+      fprintf(fp, "#     %-40s (%2d) : %d\n", cdiSubtypeAttributeName[ptr->key], ptr->key, ptr->val);    
+      ptr = ptr->next;
+    } 
+    entry = entry->next;
+  }
+  fprintf(fp, "\n");
+}
+
+
+/* Compares two subtype data structures. Pointer version of this
+   method. */
+static int subtypeCompareP(subtype_t *s1, subtype_t *s2)
+{
+  xassert(s1 && s2);
+  if (s1->subtype != s2->subtype) return differ;
+  if (subtypeEntryCompare(&s1->globals, &s2->globals) != 0) return differ;
+
+  struct subtype_entry_t *entry1 = s1->entries;
+  struct subtype_entry_t *entry2 = s2->entries;
+  while ((entry1 != NULL) && (entry2 != NULL)) {
+    if (subtypeEntryCompare(entry1, entry2) != 0)  return differ;
+    entry1 = entry1->next;
+    entry2 = entry2->next;
+  }
+  /* compare list lengths: */
+  if ((entry1 != NULL) || (entry2 != NULL))  return differ;
+  return 0;
+}
+
+
+/* Clean up data structure. */
+static void subtypeDestroyP(void *ptr)
+{
+  subtype_t *subtype_ptr = (subtype_t*) ptr;
+  /* destroy global attributes */
+  subtypeAttrDestroy(subtype_ptr->globals.atts);
+  /* destroy list of subtype entries */
+  subtypeEntryDestroy(subtype_ptr->entries);
+  subtype_ptr->entries = NULL;
+  Free(subtype_ptr);
+  subtype_ptr = NULL;
+}
+
+
+/* Non-static wrapper function for "subtypeDestroyP". */
+void subtypeDestroyPtr(void *ptr)
+{
+  subtypeDestroyP(ptr);
+}
+
+
+/* Non-static wrapper function for "subtypeCompareP". */
+int subtypeComparePtr(int s1_ID, subtype_t *s2)
+{
+  subtype_t *subtype_ptr = (subtype_t *)reshGetVal(s1_ID, &subtypeOps);
+  if (subtype_ptr == NULL)  Error("Internal error");
+  return subtypeCompareP(subtype_ptr,s2);
+}
+
+
+/* Print-out subtype data structure together with its attributes.
+   Pointer version of this method. */
+static void subtypePrintP(void * subtype_ptr, FILE * fp)
+{  subtypePrintKernel((subtype_t *)subtype_ptr, fp); }
+
+
+
+/* Print-out subtype data structure together with its attributes. */
+void subtypePrintPtr(subtype_t* subtype_ptr)
+{
+  subtypePrintKernel(subtype_ptr, stdout);
+}
+
+
+/* Fill subtype data structure with default values. */
+static void subtypeDefaultValue(subtype_t *subtype_ptr)
+{
+  if (subtype_ptr == NULL)  Error("Internal error!");
+  subtype_ptr->self                 = CDI_UNDEFID;
+  subtype_ptr->nentries             = 0;
+  subtype_ptr->entries              = NULL;
+  subtype_ptr->globals.atts         = NULL;
+  subtype_ptr->globals.next         = NULL;
+  subtype_ptr->globals.self         = -1;
+  subtype_ptr->active_subtype_index = 0;
+}
+
+
+void subtypeAllocate(subtype_t **subtype_ptr2, int subtype)
+{
+  /* allocate new subtype */
+  (*subtype_ptr2) = (subtype_t *) Malloc(sizeof(subtype_t));
+  subtype_t* subtype_ptr = *subtype_ptr2;
+  subtypeDefaultValue(subtype_ptr);
+  subtype_ptr->subtype = subtype;
+  subtype_ptr->self    = CDI_UNDEFID;
+}
+
+
+/* Create a copy of an existing subtype data structure. */
+void subtypeDuplicate(subtype_t *subtype_ptr, subtype_t **dst_ptr)
+{
+  if (subtype_ptr == NULL)  Error("Internal error!");
+  subtypeAllocate(dst_ptr, subtype_ptr->subtype);
+  subtype_t *dst = (*dst_ptr);
+  /* create duplicate of subtype globals */
+  subtypeAttsDuplicate(subtype_ptr->globals.atts, &dst->globals);
+  dst->globals.self = subtype_ptr->globals.self;
+  /* create duplicate of subtype entries */
+  subtypeEntryDuplicate( subtype_ptr->entries, dst);
+}
+
+
+/* Register subtype object at resource handler. */
+int subtypePush(subtype_t *subtype_ptr)
+{
+  if (subtype_ptr == NULL)  Error("Internal error!");
+  subtype_ptr->self = reshPut(subtype_ptr, &subtypeOps);
+  return subtype_ptr->self; /* subtypeID */
+}
+
+
+
+/* Sets an attribute for a subtype (for example a set of TILES). If
+   the attribute has already been defined, then its value is
+   overwritten. */
+void subtypeDefGlobalDataP(subtype_t *subtype_ptr, int key, int val)
+{
+  if (subtype_ptr == NULL)  Error("Internal error!");
+  /* find entry in linked list or append otherwise */
+  struct subtype_attr_t* att_ptr = subtypeAttrFind(subtype_ptr->globals.atts, key);
+  if (att_ptr == NULL) 
+    subtypeAttrInsert(&subtype_ptr->globals, key, val);
+  else
+    att_ptr->val = val;
+}
+
+
+/* Sets an attribute for a subtype (for example a set of TILES). If
+   the attribute has already been defined, then its value is
+   overwritten. */
+void subtypeDefGlobalData(int subtypeID, int key, int val)
+{
+  subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
+  subtypeDefGlobalDataP(subtype_ptr, key, val);
+}
+
+
+/* Retrieves an attribute for a subtype (for example a set of TILES).
+   If the attribute has not been defined, then return -1. */
+int subtypeGetGlobalDataP(subtype_t *subtype_ptr, int key)
+{
+  if (subtype_ptr == NULL)  Error("Internal error!");
+  /* find entry in linked list */
+  struct subtype_attr_t* att_ptr = subtypeAttrFind(subtype_ptr->globals.atts, key);
+  if (att_ptr == NULL) 
+    return -1;
+  else
+    return att_ptr->val;
+}
+
+
+/* Retrieves an attribute for a subtype (for example a set of TILES) .
+   If the attribute has not been defined, then return -1. */
+int subtypeGetGlobalData(int subtypeID, int key)
+{
+  subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
+  return subtypeGetGlobalDataP(subtype_ptr, key);
+}
+
+
+/* Sets an attribute for a single subtype entry (e.g. a single TILE).
+   If the attribute has already been defined, then its value is
+   overwritten. */
+void subtypeDefEntryDataP(struct subtype_entry_t *subtype_entry_ptr, int key, int val)
+{
+  if (subtype_entry_ptr == NULL)  Error("Internal error!");
+  /* find entry in linked list or append otherwise */
+  struct subtype_attr_t* att_ptr = subtypeAttrFind(subtype_entry_ptr->atts, key);
+  if (att_ptr == NULL) 
+    subtypeAttrInsert(subtype_entry_ptr, key, val);
+  else
+    att_ptr->val = val;
+}
+
+
+
+/* ------------------------------------------------------------------- */
+/* IMPLEMENTATIONS FOR KEY-VALUE-PAIR QUERIES			       */
+/* ------------------------------------------------------------------- */
+
+
+/* Generate a "query object" out of a key-value pair. */
+subtype_query_t keyValuePair(const char* key, int value)
+{
+  subtype_query_t result;
+  result.nAND = 1;
+  result.key_value_pairs[0][0] = attribute_to_index(key);
+  result.key_value_pairs[1][0] = value;
+  if (CDI_Debug) {
+    Message("key  %s matches %d", key, result.key_value_pairs[0][0]);
+    Message("%d --?-- %d", result.key_value_pairs[0][0], result.key_value_pairs[1][0]);
+  }
+  return result;
+}
+
+
+/* Generate an AND-combined "query object" out of two previous query
+   objects. */
+subtype_query_t matchAND(subtype_query_t q1, subtype_query_t q2)
+{
+  if ((q1.nAND + q2.nAND) > MAX_KV_PAIRS_MATCH)  Error("Internal error");
+  subtype_query_t result;
+  result.nAND = q1.nAND;
+  for (int i=0; i<q1.nAND; i++)
+    {
+      result.key_value_pairs[0][i] = q1.key_value_pairs[0][i];
+      result.key_value_pairs[1][i] = q1.key_value_pairs[1][i];
+    }
+  for (int i=0; i<q2.nAND; i++)
+    {
+      result.key_value_pairs[0][result.nAND] = q2.key_value_pairs[0][i];
+      result.key_value_pairs[1][result.nAND] = q2.key_value_pairs[1][i];
+      result.nAND++;
+    }
+
+  if (CDI_Debug) {
+    Message("combined criterion:");
+    for (int i=0; i<result.nAND; i++)
+      Message("%d --?-- %d", result.key_value_pairs[0][i], result.key_value_pairs[1][i]);
+  }
+  return result;
+}
+
+
+
+/* ------------------------------------------------------------------- */
+/* SPECIFIC IMPLEMENTATIONS FOR TILE SETS			       */
+/* ------------------------------------------------------------------- */
+
+
+/* Integrate tile set "s2" into the tile set "subtype1_ID":
+
+   Insert all entries set 2 to set 1 together with its attributes.
+*/
+void tilesetInsertP(subtype_t *s1, subtype_t *s2)
+{
+  if (s1 == NULL)  Error("Internal error!");
+  if (s2 == NULL)  Error("Internal error!");
+  struct subtype_entry_t 
+    *entry1 = s1->entries,
+    *entry2 = s2->entries;
+  struct subtype_attr_t *att_ptr2;
+
+  /* test all entries of set 2 against set 1, to check if entry
+     already exists: */
+  if (subtypeAttsCompare(s1->globals.atts, s2->globals.atts) != differ) 
+    {
+      while (entry1 != NULL) {
+	int found = 1;
+	entry2 = s2->entries;
+	while (entry2 != NULL) {
+	  found &= (subtypeAttsCompare(entry1->atts, entry2->atts) != differ);
+	  entry2 = entry2->next;
+	}
+	if (found) 
+	  {
+	    return;
+	  }
+	entry1 = entry1->next;
+      }
+    
+      entry2 = s2->entries;
+      while (entry2 != NULL) {
+	entry1 = subtypeEntryInsert(s1);
+	
+	att_ptr2 = entry2->atts;
+	while (att_ptr2 != NULL) {
+	  (void) subtypeAttrInsert(entry1, att_ptr2->key, att_ptr2->val);
+	  att_ptr2 = att_ptr2->next;
+	}
+	entry2 = entry2->next;
+      }
+    }
+  else
+    {
+      fprintf(stderr, "\n# SUBTYPE A:\n");
+      subtypePrintKernel(s1, stderr);
+      fprintf(stderr, "\n# SUBTYPE B:\n");
+      subtypePrintKernel(s2, stderr);
+      Error("Attempting to insert subtype entry into subtype with different global attributes!");
+    }
+}
+
+
+
+/* ------------------------------------------------------------------- */
+/* IMPLEMENTATIONS FOR ROUTINES VISIBLE THROUGH CDI.H		       */
+/* ------------------------------------------------------------------- */
+
+
+/*
+  @Function  subtypeCreate
+  @Title     Create a variable subtype
+  
+  @Prototype int subtypeCreate(int subtype)
+  @Parameter
+  @Item  subtype  The type of the variable subtype, one of the set of predefined CDI variable subtypes.
+  The valid CDI variable subtypes are @func{SUBTYPE_TILES}
+  
+  @Description
+  The function @func{subtypeCreate} creates a variable subtype.
+  
+  @Result
+  @func{subtypeCreate} returns an identifier to the variable subtype.
+  
+  @EndFunction
+*/
+int subtypeCreate(int subtype)
+{
+  if ( CDI_Debug )  Message("subtype: %d ", subtype);
+  Message("subtype: %d ", subtype);
+
+  /* allocate new subtype */
+  subtype_t *subtype_ptr;
+  subtypeAllocate(&subtype_ptr, subtype);
+  /* register object at resource handler */
+  return subtypePush(subtype_ptr);
+}
+
+
+/* Print-out subtype data structure together with its attributes. */
+void subtypePrint(int subtypeID)
+{
+  subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
+  subtypePrintKernel(subtype_ptr, stdout);
+}
+
+
+/* Compares two subtype data structures. */
+int subtypeCompare(int subtypeID1, int subtypeID2)
+{
+  subtype_t *subtype_ptr1 = (subtype_t *)reshGetVal(subtypeID1, &subtypeOps);
+  subtype_t *subtype_ptr2 = (subtype_t *)reshGetVal(subtypeID2, &subtypeOps);
+  return subtypeCompareP(subtype_ptr1,subtype_ptr2);
+}
+
+
+/*  Get the size of a subtype (e.g. no. of tiles). */
+int subtypeInqSize(int subtypeID)
+{
+  if ( subtypeID == CDI_UNDEFID )
+    {
+      return 0;
+    }
+  else
+    {
+      subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
+      return subtype_ptr->nentries;
+    }
+}
+
+
+/* Get the currently active index of a subtype (e.g. current tile index). */
+int subtypeInqActiveIndex(int subtypeID)
+{
+  if (subtypeID == CDI_UNDEFID)  return 0;
+  subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
+  return subtype_ptr->active_subtype_index;
+}
+
+
+/* Set the currently active index of a subtype (e.g. current tile index). */
+void subtypeDefActiveIndex(int subtypeID, int index)
+{
+  subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
+  subtype_ptr->active_subtype_index = index;
+}
+
+
+/* subtypeInqSubEntry: Returns subtype entry ID for a given
+   criterion. */
+int subtypeInqSubEntry(int subtypeID, subtype_query_t criterion)
+{
+  subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
+  struct subtype_entry_t *entry = subtype_ptr->entries;
+  /* loop over all entries of this subtype */
+  while (entry != NULL) {
+    {
+      int match = 1;
+      /* test if this entry matches ALL criteria. */
+      for (int j=0; (j<criterion.nAND) && (match); j++)
+	{
+	  if (CDI_Debug)  Message("check criterion %d :  %d --?-- %d", j,
+				  criterion.key_value_pairs[0][j], criterion.key_value_pairs[1][j]);
+	  struct subtype_attr_t* att_ptr = 
+	    subtypeAttrFind(entry->atts, criterion.key_value_pairs[0][j]);
+	  if (att_ptr == NULL)
+	    {
+	      match = 0;
+	      if (CDI_Debug)  Message("did not find %d", criterion.key_value_pairs[0][j]);
+	    }
+	  else
+	    {
+	      if (CDI_Debug)  Message("found %d", criterion.key_value_pairs[0][j]);
+	      match &= (att_ptr->val == criterion.key_value_pairs[1][j]);
+	    }
+	}
+      if (match) return entry->self;
+    }
+    entry = entry->next;
+  }
+  return CDI_UNDEFID;
+}
+
+
+int subtypeInqTile(int subtypeID, int tileindex, int attribute)
+{
+  return subtypeInqSubEntry(subtypeID, 
+			    matchAND(keyValuePair(cdiSubtypeAttributeName[SUBTYPE_ATT_TILEINDEX], tileindex),
+				     keyValuePair(cdiSubtypeAttributeName[SUBTYPE_ATT_TILEATTRIBUTE], attribute)));
+}
+
+
+/* Construct a new subtype for a tile set. If a corresponding subtype
+ * already exists, then we return this subtype ID instead. 
+ *
+ * See comment on subtype.c::tilesetMatchingPtr for the specification
+ * of the term "corresponding" tile set.
+ */
+int vlistDefTileSubtype(int vlistID, subtype_t *tiles)
+{
+  int subtypeID = CDI_UNDEFID;
+
+  /* loop over subtypes and search for an identical tileset */
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+  int      tileset_defined = 0;
+  for (int isub=0; isub<vlistptr->nsubtypes; isub++)
+    {
+      /* get the ID of the "isub"th subtype */
+      subtypeID = vlistptr->subtypeIDs[isub];
+      if (subtypeComparePtr(subtypeID, tiles) == 0)
+        {
+          tileset_defined = 1;
+          break;
+        }
+    }
+
+  /* tile set seems to be new: register at resource handler. */
+  if (tileset_defined == 0)  {
+    subtype_t *tiles_duplicate = NULL;
+    subtypeDuplicate(tiles, &tiles_duplicate);
+    subtypeID = vlistptr->subtypeIDs[vlistptr->nsubtypes++] = subtypePush(tiles_duplicate);
+  }
+
+  return subtypeID;
+}
+
+
+
+int vlistInsertTrivialTileSubtype(int vlistID)
+{
+  /* first, generate a subtype */
+  subtype_t *subtype_ptr;
+  subtypeAllocate(&subtype_ptr, SUBTYPE_TILES);
+
+  /* create a tile set that contains only one tile/attribute pair. */
+  (void) subtypeEntryInsert(subtype_ptr);
+
+  /* register tile */
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+  int subtypeID = vlistptr->subtypeIDs[vlistptr->nsubtypes++] = subtypePush(subtype_ptr);
+  return subtypeID;
+}
+
+
+
+
+/* ------------------------------------------------------------------- */
+/* NOT YET IMPLEMENTED						       */
+/* ------------------------------------------------------------------- */
+
+static int subtypeGetPackSize( void * subtype_ptr, void *context)
+{
+  (void)subtype_ptr; (void)context;
+  Error("Not yet implemented for subtypes!");
+  return 0;
+}
+
+static void subtypePack( void * subtype_ptr, void * buffer, int size, int *pos, void *context)
+{
+  (void)subtype_ptr; (void)buffer; (void)size; (void)pos; (void)context;
+  Error("Not yet implemented for subtypes!");
+}
+
+static int subtypeTxCode( void )
+{  Error("Not yet implemented for subtypes!");  return 0; }
+
+
 /*
  * Local Variables:
  * c-file-style: "Java"
@@ -54909,28 +56732,22 @@ int stream_new_var(stream_t *streamptr, int gridID, int zaxisID)
 
 void swap4byte(void *ptr, size_t size)
 {
-  int32_t *ptrtmp = ptr;
+  int32_t *ptrtmp = (int32_t *)ptr;
 
-  if (sizeof (int32_t) == 4)
-    for (size_t i = 0; i < size; ++i)
-      ptrtmp[i] = (((ptrtmp[i] >> 24) & 0x00ff) | ((ptrtmp[i] & 0x00ff) << 24) |
-                   ((ptrtmp[i] >>  8) & 0xff00) | ((ptrtmp[i] & 0xff00) <<  8));
-  else
-    Error("not implemented for %d byte data", sizeof(int32_t));
+  for (size_t i = 0; i < size; ++i)
+    ptrtmp[i] = (((ptrtmp[i] >> 24) & 0x00ff) | ((ptrtmp[i] & 0x00ff) << 24) |
+                 ((ptrtmp[i] >>  8) & 0xff00) | ((ptrtmp[i] & 0xff00) <<  8));
 }
 
 void swap8byte(void *ptr, size_t size)
 {
-  int64_t *ptrtmp = ptr;
+  int64_t *ptrtmp = (int64_t *)ptr;
 
-  if (sizeof (int64_t) == 8)
-    for (size_t i = 0; i < size; ++i)
-      ptrtmp[i] = (((ptrtmp[i] >> 56) & 0x000000ff) | ((ptrtmp[i] & 0x000000ff) << 56) |
-                   ((ptrtmp[i] >> 40) & 0x0000ff00) | ((ptrtmp[i] & 0x0000ff00) << 40) |
-                   ((ptrtmp[i] >> 24) & 0x00ff0000) | ((ptrtmp[i] & 0x00ff0000) << 24) |
-                   ((ptrtmp[i] >>  8) & 0xff000000) | ((ptrtmp[i] & 0xff000000) <<  8));
-  else
-    Error("not implemented for %d byte data", sizeof(int64_t));
+  for (size_t i = 0; i < size; ++i)
+    ptrtmp[i] = (((ptrtmp[i] >> 56) & 0x000000ff) | ((ptrtmp[i] & 0x000000ff) << 56) |
+                 ((ptrtmp[i] >> 40) & 0x0000ff00) | ((ptrtmp[i] & 0x0000ff00) << 40) |
+                 ((ptrtmp[i] >> 24) & 0x00ff0000) | ((ptrtmp[i] & 0x00ff0000) << 24) |
+                 ((ptrtmp[i] >>  8) & 0xff000000) | ((ptrtmp[i] & 0xff000000) <<  8));
 }
 /*
  * Local Variables:
@@ -56200,8 +58017,7 @@ static const PAR cosmo250[] = {
 };
 
 
-static void
-tableDefault(void)
+static void tableDefault(void)
 {
   int tableID, instID, modelID;
 
@@ -56400,6 +58216,15 @@ tableDefault(void)
 }
 
 #endif  /* _TABLE_H */
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #if defined (HAVE_CONFIG_H)
 #endif
 
@@ -56421,8 +58246,8 @@ tableDefault(void)
 typedef struct
 {
   int    used;
-  PAR   *pars;
   int    npars;
+  PAR   *pars;
   int    modelID;
   int    number;
   char  *name;
@@ -56454,17 +58279,17 @@ void tableDefEntry(int tableID, int id, const char *name,
   parTable[tableID].pars[item].longname = NULL;
   parTable[tableID].pars[item].units    = NULL;
 
-  if ( name && strlen(name) > 0 )
+  if ( name && name[0] )
     {
       parTable[tableID].pars[item].name     = strdupx(name);
       parTable[tableID].pars[item].dupflags |= TABLE_DUP_NAME;
     }
-  if ( longname && strlen(longname) > 0 )
+  if ( longname && longname[0] )
     {
       parTable[tableID].pars[item].longname = strdupx(longname);
       parTable[tableID].pars[item].dupflags |= TABLE_DUP_LONGNAME;
     }
-  if ( units && strlen(units) > 0 )
+  if ( units && units[0] )
     {
       parTable[tableID].pars[item].units    = strdupx(units);
       parTable[tableID].pars[item].dupflags |= TABLE_DUP_UNITS;
@@ -56518,14 +58343,14 @@ static void parTableFinalize(void)
         for (int item = 0; item < npars; ++item)
           {
             if (parTable[tableID].pars[item].dupflags & TABLE_DUP_NAME)
-              free((void *)parTable[tableID].pars[item].name);
+              Free((void *)parTable[tableID].pars[item].name);
             if (parTable[tableID].pars[item].dupflags & TABLE_DUP_LONGNAME)
-              free((void *)parTable[tableID].pars[item].longname);
+              Free((void *)parTable[tableID].pars[item].longname);
             if (parTable[tableID].pars[item].dupflags & TABLE_DUP_UNITS)
-              free((void *)parTable[tableID].pars[item].units);
+              Free((void *)parTable[tableID].pars[item].units);
           }
-        free(parTable[tableID].pars);
-        free(parTable[tableID].name);
+        Free(parTable[tableID].pars);
+        Free(parTable[tableID].name);
       }
 }
 
@@ -56589,8 +58414,7 @@ decodeForm1(char *pline, char *name, char *longname, char *units)
   else
     return (0);
 
-  len = strlen(pline);
-  if ( len == 0 ) return (0);
+  if ( pline[0] == 0 ) return (0);
 
   /* Format 1 : code name add mult longname [units] */
   /* FIXME: successful parse isn't verified */
@@ -56647,7 +58471,6 @@ decodeForm2(char *pline, char *name, char *longname, char *units)
 {
   /* Format 2 : code | name | longname | units */
   char *pend;
-  size_t len;
 
   pline = strchr(pline, '|');
   pline++;
@@ -56660,7 +58483,7 @@ decodeForm2(char *pline, char *name, char *longname, char *units)
         {
           pend = pline;
           while ( ! isspace((int) *pend) ) pend++;
-          len = (size_t)(pend - pline);
+          size_t len = (size_t)(pend - pline);
           if ( len > 0 )
             {
               memcpy(name, pline, len);
@@ -56672,7 +58495,7 @@ decodeForm2(char *pline, char *name, char *longname, char *units)
         {
           pend--;
           while ( isspace((int) *pend) ) pend--;
-          len = (size_t)(pend - pline + 1);
+          size_t len = (size_t)(pend - pline + 1);
           if ( len > 0 )
             {
               memcpy(name, pline, len);
@@ -56690,12 +58513,14 @@ decodeForm2(char *pline, char *name, char *longname, char *units)
   if ( !pend ) pend = strchr(pline, 0);
   pend--;
   while ( isspace((int) *pend) ) pend--;
-  len = (size_t)(pend - pline + 1);
-  if ( len > 0 )
-    {
-      memcpy(longname, pline, len);
-      longname[len] = 0;
-    }
+  {
+    size_t len = (size_t)(pend - pline + 1);
+    if ( len > 0 )
+      {
+        memcpy(longname, pline, len);
+        longname[len] = 0;
+      }
+  }
 
   pline = strchr(pline, '|');
   if ( pline )
@@ -56729,7 +58554,7 @@ int tableRead(const char *tablefile)
   tablefp = fopen(tablefile, "r");
   if ( tablefp == NULL ) return (tableID);
 
-  tablename = strrchr(tablefile, '/');
+  tablename = (char* )strrchr(tablefile, '/');
   if ( tablename == 0 ) tablename = (char *) tablefile;
   else                  tablename++;
 
@@ -56765,7 +58590,7 @@ int tableRead(const char *tablefile)
 
       if ( err ) continue;
 
-      if ( strlen(name) == 0 ) sprintf(name, "var%d", id);
+      if ( name[0] ) sprintf(name, "var%d", id);
 
       tableDefEntry(tableID, id, name, longname, units);
     }
@@ -56818,7 +58643,7 @@ static int tableFromEnv(int modelID, int tablenum)
       lenf = strlen(tablename);
       /* if (tablePath) printf("tablePath = %s\n", tablePath); */
       /* if (tablename) printf("tableName = %s\n", tablename); */
-      tablefile = (char *) malloc(lenp+lenf+3);
+      tablefile = (char *) Malloc(lenp+lenf+3);
       if ( tablePath )
 	{
 	  strcpy(tablefile, tablePath);
@@ -56837,7 +58662,7 @@ static int tableFromEnv(int modelID, int tablenum)
 	}
       /* printf("tableID = %d %s\n", tableID, tablefile); */
 
-      free(tablefile);
+      Free(tablefile);
     }
 
   return (tableID);
@@ -56941,7 +58766,7 @@ int tableDef(int modelID, int tablenum, const char *tablename)
       if ( tablename )
 	parTable[tableID].name = strdupx(tablename);
 
-      parTable[tableID].pars = (PAR *) malloc(MAX_PARS * sizeof(PAR));
+      parTable[tableID].pars = (PAR *) Malloc(MAX_PARS * sizeof(PAR));
     }
 
   return (tableID);
@@ -57217,7 +59042,7 @@ int tableInqParName(int tableID, int code, char *varname)
 {
   int err = 1;
 
-  if ( tableID != UNDEFID )
+  if ( tableID >= 0 && tableID < MAX_TABLE )
     {
       int npars = parTable[tableID].npars;
       for ( int item = 0; item < npars; item++ )
@@ -57231,6 +59056,10 @@ int tableInqParName(int tableID, int code, char *varname)
 	    }
 	}
     }
+  else if ( tableID == UNDEFID )
+    { }
+  else
+    Error("Invalid table ID %d", tableID);
 
   return (err);
 }
@@ -57397,14 +59226,11 @@ int tableInqNumber(void)
 #include <string.h>
 
 
-
-extern int cdiDefaultCalendar;
-
 static int DefaultTimeType = TAXIS_ABSOLUTE;
 static int DefaultTimeUnit = TUNIT_HOUR;
 
 
-const char *Timeunits[] = {
+static const char *Timeunits[] = {
   "undefined",
   "seconds",
   "minutes",
@@ -57438,7 +59264,7 @@ const resOps taxisOps = {
 };
 
 #define container_of(ptr, type, member) \
-  ((type *)((unsigned char *)ptr - offsetof(type,member)))
+  ((type *)(void*)((unsigned char *)ptr - offsetof(type,member)))
 
 struct refcount_string
 {
@@ -57450,7 +59276,7 @@ static char *
 new_refcount_string(size_t len)
 {
   struct refcount_string *container
-    = xmalloc(sizeof (*container) + len + 1);
+    = (struct refcount_string *) Malloc(sizeof (*container) + len + 1);
   container->ref_count = 1;
   return container->string;
 }
@@ -57463,7 +59289,7 @@ delete_refcount_string(void *p)
       struct refcount_string *container
         = container_of(p, struct refcount_string, string);
       if (!--(container->ref_count))
-        free(container);
+        Free(container);
     }
 }
 
@@ -57559,7 +59385,7 @@ void taxisDefaultValue(taxis_t* taxisptr)
 static taxis_t *
 taxisNewEntry(cdiResH resH)
 {
-  taxis_t *taxisptr = (taxis_t*) xmalloc(sizeof(taxis_t));
+  taxis_t *taxisptr = (taxis_t*) Malloc(sizeof(taxis_t));
 
   taxisDefaultValue(taxisptr);
   if (resH == CDI_UNDEFID)
@@ -57648,11 +59474,8 @@ int taxisCreate(int taxistype)
 
 void taxisDestroyKernel(taxis_t *taxisptr)
 {
-  int id = taxisptr->self;
   delete_refcount_string(taxisptr->name);
   delete_refcount_string(taxisptr->longname);
-  if (id != CDI_UNDEFID)
-    reshRemove(id, &taxisOps);
 }
 
 /*
@@ -57668,15 +59491,16 @@ void taxisDestroyKernel(taxis_t *taxisptr)
 void taxisDestroy(int taxisID)
 {
   taxis_t *taxisptr = (taxis_t *)reshGetVal(taxisID, &taxisOps);
+  reshRemove(taxisID, &taxisOps);
   taxisDestroyKernel(taxisptr);
-  free(taxisptr);
+  Free(taxisptr);
 }
 
 
 void taxisDestroyP( void * taxisptr )
 {
   taxisDestroyKernel((taxis_t *)taxisptr);
-  free(taxisptr);
+  Free(taxisptr);
 }
 
 
@@ -58299,7 +60123,8 @@ ptaxisDefLongname(taxis_t *taxisptr, const char *longname)
 }
 
 
-void cdiDecodeTimevalue(int timeunit, double timevalue, int *days, int *secs)
+static void
+cdiDecodeTimevalue(int timeunit, double timevalue, int *days, int *secs)
 {
   static int lwarn = TRUE;
 
@@ -58321,7 +60146,7 @@ void cdiDecodeTimevalue(int timeunit, double timevalue, int *days, int *secs)
     {
       *days = (int) (timevalue/86400);
       double seconds = timevalue - *days*86400.;
-      *secs = lround(seconds);
+      *secs = (int)lround(seconds);
       if ( *secs < 0 ) { *days -= 1; *secs += 86400; };
       /*
       {
@@ -58335,7 +60160,7 @@ void cdiDecodeTimevalue(int timeunit, double timevalue, int *days, int *secs)
     {
       *days = (int) timevalue;
       double seconds = (timevalue - *days)*86400;
-      *secs = lround(seconds);
+      *secs = (int)lround(seconds);
       if ( *secs < 0 ) { *days -= 1; *secs += 86400; };
       /*
       {
@@ -58391,8 +60216,6 @@ void cdiEncodeTimevalue(int days, int secs, int timeunit, double *timevalue)
     }
 }
 
-int days_per_month(int calendar, int year, int month);
-
 void timeval2vtime(double timevalue, taxis_t *taxis, int *vdate, int *vtime)
 {
   int year, month, day, hour, minute, second;
@@ -58533,7 +60356,7 @@ double vtime2timeval(int vdate, int vtime, taxis_t *taxis)
 }
 
 
-void conv_timeval(double timevalue, int *rvdate, int *rvtime)
+static void conv_timeval(double timevalue, int *rvdate, int *rvtime)
 {
   int vdate = 0, vtime = 0;
   int hour, minute, second;
@@ -58555,7 +60378,8 @@ void conv_timeval(double timevalue, int *rvdate, int *rvtime)
 }
 
 
-void splitTimevalue(double timevalue, int timeunit, int *date, int *time)
+static void
+splitTimevalue(double timevalue, int timeunit, int *date, int *time)
 {
   int vdate = 0, vtime = 0;
   int hour, minute, second;
@@ -58578,8 +60402,7 @@ void splitTimevalue(double timevalue, int timeunit, int *date, int *time)
     }
   else if ( timeunit == TUNIT_MONTH )
     {
-      vdate = (int) timevalue*100;
-      vdate += 1;
+      vdate = (int) timevalue*100 - ((vdate < 0) * 2 - 1);
       vtime = 0;
     }
   else if ( timeunit == TUNIT_YEAR )
@@ -58724,11 +60547,13 @@ double cdiEncodeTimeval(int date, int time, taxis_t *taxis)
 	{
 	  int year, month, day;
 	  cdiDecodeDate(date, &year, &month, &day);
-	  if ( day == 0 )
-	    timevalue = date/100;
-	  else
-	    timevalue = date/100 + 0.5;
-	}
+          timevalue = date/100;
+	  if ( day != 0 )
+            {
+              if ( date < 0 ) timevalue -= 0.5;
+              else            timevalue += 0.5;
+            }
+        }
       else
 	{
 	  int hour, minute, second;
@@ -58823,7 +60648,7 @@ taxisPrintKernel(taxis_t * taxisptr, FILE * fp)
   fprintf ( fp, "\n");
 }
 
-void taxisPrint ( int taxisID )
+static void taxisPrint ( int taxisID )
 {
   taxis_t * taxisptr;
 
@@ -58909,7 +60734,7 @@ taxisUnpack(char * unpackBuffer, int unpackBufferSize, int * unpackBufferPos,
 
   xassert(!force_id || targetID == taxisP->self);
 
-  taxisP->used        = intBuffer[idx++];
+  taxisP->used        = (short)intBuffer[idx++];
   taxisP->type        = intBuffer[idx++];
   taxisP->vdate       = intBuffer[idx++];
   taxisP->vtime       = intBuffer[idx++];
@@ -58922,7 +60747,7 @@ taxisUnpack(char * unpackBuffer, int unpackBufferSize, int * unpackBufferPos,
   taxisP->fc_unit     = intBuffer[idx++];
   taxisP->numavg      = intBuffer[idx++];
   taxisP->climatology = intBuffer[idx++];
-  taxisP->has_bounds  = intBuffer[idx++];
+  taxisP->has_bounds  = (short)intBuffer[idx++];
   taxisP->vdate_lb    = intBuffer[idx++];
   taxisP->vtime_lb    = intBuffer[idx++];
   taxisP->vdate_ub    = intBuffer[idx++];
@@ -58948,6 +60773,9 @@ taxisUnpack(char * unpackBuffer, int unpackBufferSize, int * unpackBufferPos,
       taxisP->longname = longname;
     }
 
+  reshSetStatus(taxisP->self, &taxisOps,
+                reshGetStatus(taxisP->self, &taxisOps) & ~RESH_SYNC_BIT);
+
   return taxisP->self;
 }
 
@@ -59349,14 +61177,25 @@ int main(void)
   return (0);
 }
 #endif
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #if defined (HAVE_CONFIG_H)
 #endif
 
+#include <limits.h>
+
 
 
 
 static
-void tstepsInitEntry(stream_t *streamptr, int tsID)
+void tstepsInitEntry(stream_t *streamptr, size_t tsID)
 {
   streamptr->tsteps[tsID].curRecID     = CDI_UNDEFID;
   streamptr->tsteps[tsID].position     = 0;
@@ -59373,13 +61212,9 @@ void tstepsInitEntry(stream_t *streamptr, int tsID)
 
 int tstepsNewEntry(stream_t *streamptr)
 {
-  int tsID = 0;
-  int tstepsTableSize;
-  tsteps_t *tstepsTable;
-
-  tsID            = streamptr->tstepsNextID++;
-  tstepsTableSize = streamptr->tstepsTableSize;
-  tstepsTable     = streamptr->tsteps;
+  size_t tsID            = (size_t)streamptr->tstepsNextID++;
+  size_t tstepsTableSize = (size_t)streamptr->tstepsTableSize;
+  tsteps_t *tstepsTable  = streamptr->tsteps;
 
   /*
     If the table overflows, double its size.
@@ -59387,24 +61222,24 @@ int tstepsNewEntry(stream_t *streamptr)
   if ( tsID == tstepsTableSize )
     {
       if ( tstepsTableSize == 0 ) tstepsTableSize = 1;
-      tstepsTableSize = 2*tstepsTableSize;
-      tstepsTable = (tsteps_t *)xrealloc(tstepsTable,
-                                         (size_t)tstepsTableSize * sizeof (tsteps_t));
-      if ( tstepsTable == NULL )
-	{
-          Message("tstepsTableSize = %d", tstepsTableSize);
-	  SysError("Reallocation of tsteps_t failed");
-	}
+      if ( tstepsTableSize <= INT_MAX / 2)
+        tstepsTableSize *= 2;
+      else if ( tstepsTableSize < INT_MAX)
+        tstepsTableSize = INT_MAX;
+      else
+        Error("Resizing of tstep table failed!");
+      tstepsTable = (tsteps_t *) Realloc(tstepsTable,
+                                         tstepsTableSize * sizeof (tsteps_t));
     }
 
-  streamptr->tstepsTableSize = tstepsTableSize;
+  streamptr->tstepsTableSize = (int)tstepsTableSize;
   streamptr->tsteps          = tstepsTable;
 
   tstepsInitEntry(streamptr, tsID);
 
   streamptr->tsteps[tsID].taxis.used = TRUE;
 
-  return (tsID);
+  return (int)tsID;
 }
 
 
@@ -59419,14 +61254,14 @@ void cdiCreateTimesteps(stream_t *streamptr)
   if ( streamptr->ntsteps == 0 ) ntsteps = 1;    /* <<<<<-------- */
   else ntsteps = streamptr->ntsteps;
 
-  streamptr->tsteps = (tsteps_t *)xmalloc((size_t)ntsteps*sizeof(tsteps_t));
+  streamptr->tsteps = (tsteps_t *) Malloc((size_t)ntsteps*sizeof(tsteps_t));
 
   streamptr->tstepsTableSize = (int)ntsteps;
   streamptr->tstepsNextID    = (int)ntsteps;
 
   for ( tsID = 0; tsID < ntsteps; tsID++ )
     {
-      tstepsInitEntry(streamptr, (int)tsID);
+      tstepsInitEntry(streamptr, (size_t)tsID);
       streamptr->tsteps[tsID].taxis.used = TRUE;
     }
 }
@@ -59439,61 +61274,83 @@ void cdiCreateTimesteps(stream_t *streamptr)
  * require-trailing-newline: t
  * End:
  */
+#ifndef CREATE_UUID_H
+#define CREATE_UUID_H
+
+#if defined (HAVE_CONFIG_H)
+#endif
+
+
+void
+create_uuid(unsigned char uuid[CDI_UUID_SIZE]);
+
+#endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
 #if defined (HAVE_CONFIG_H)
 #endif
 
 #define _XOPEN_SOURCE 600
 
 #include <errno.h>
+#include <float.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <string.h>
-#include <float.h>
 #include <sys/types.h>
 
 
 
-#undef  IsBigendian
-#define IsBigendian()  ( u_byteorder.c[sizeof(long) - 1] )
-
 void cdiPrintDatatypes(void)
 {
-  /* IsBigendian returns 1 for big endian byte order */
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
-
-  fprintf (stderr, "+-------------+-------+\n");
-  fprintf (stderr, "| types       | bytes |\n");
-  fprintf (stderr, "+-------------+-------+\n");
-  fprintf (stderr, "| void *      |   %3d |\n", (int) sizeof(void *));
-  fprintf (stderr, "+-------------+-------+\n");
-  fprintf (stderr, "| char        |   %3d |\n", (int) sizeof(char));
-  fprintf (stderr, "+-------------+-------+\n");
-  fprintf (stderr, "| short       |   %3d |\n", (int) sizeof(short));
-  fprintf (stderr, "| int         |   %3d |\n", (int) sizeof(int));
-  fprintf (stderr, "| long        |   %3d |\n", (int) sizeof(long));
-  fprintf (stderr, "| long long   |   %3d |\n", (int) sizeof(long long));
-  fprintf (stderr, "| size_t      |   %3d |\n", (int) sizeof(size_t));
-  fprintf (stderr, "| off_t       |   %3d |\n", (int) sizeof(off_t));
-  fprintf (stderr, "+-------------+-------+\n");
-  fprintf (stderr, "| float       |   %3d |\n", (int) sizeof(float));
-  fprintf (stderr, "| double      |   %3d |\n", (int) sizeof(double));
-  fprintf (stderr, "| long double |   %3d |\n", (int) sizeof(long double));
-  fprintf (stderr, "+-------------+-------+\n\n");
 #define XSTRING(x)	#x
 #define STRING(x)	XSTRING(x)
-  fprintf (stderr, "+-------------+-----------+\n");
-  fprintf (stderr, "| INT32       | %-9s |\n", STRING(INT32));
-  fprintf (stderr, "| INT64       | %-9s |\n", STRING(INT64));
-  fprintf (stderr, "| FLT32       | %-9s |\n", STRING(FLT32));
-  fprintf (stderr, "| FLT64       | %-9s |\n", STRING(FLT64));
-  fprintf (stderr, "+-------------+-----------+\n");
-
-  if ( IsBigendian() )
-    fprintf (stderr, "\n  byte ordering is BIGENDIAN\n\n");
-  else
-    fprintf (stderr, "\n  byte ordering is LITTLEENDIAN\n\n");
-}
-
-static char uuidFmt[] = "%02hhx%02hhx%02hhx%02hhx-"
+  fprintf (stderr, "+-------------+-------+\n"
+           "| types       | bytes |\n"
+           "+-------------+-------+\n"
+           "| void *      |   %3d |\n"
+           "+-------------+-------+\n"
+           "| char        |   %3d |\n"
+           "+-------------+-------+\n"
+           "| short       |   %3d |\n"
+           "| int         |   %3d |\n"
+           "| long        |   %3d |\n"
+           "| long long   |   %3d |\n"
+           "| size_t      |   %3d |\n"
+           "| off_t       |   %3d |\n"
+           "+-------------+-------+\n"
+           "| float       |   %3d |\n"
+           "| double      |   %3d |\n"
+           "| long double |   %3d |\n"
+           "+-------------+-------+\n\n"
+           "+-------------+-----------+\n"
+           "| INT32       | %-9s |\n"
+           "| INT64       | %-9s |\n"
+           "| FLT32       | %-9s |\n"
+           "| FLT64       | %-9s |\n"
+           "+-------------+-----------+\n"
+           "\n  byte ordering is %s\n\n",
+           (int) sizeof(void *), (int) sizeof(char),
+           (int) sizeof(short), (int) sizeof(int), (int) sizeof(long), (int) sizeof(long long),
+           (int) sizeof(size_t), (int) sizeof(off_t),
+           (int) sizeof(float), (int) sizeof(double), (int) sizeof(long double),
+           STRING(INT32), STRING(INT64), STRING(FLT32), STRING(FLT64),
+           ((HOST_ENDIANNESS == CDI_BIGENDIAN) ? "BIGENDIAN"
+            : ((HOST_ENDIANNESS == CDI_LITTLEENDIAN) ? "LITTLEENDIAN"
+               : "Unhandled endianness!")));
+#undef STRING
+#undef XSTRING
+}
+
+static const char uuidFmt[] = "%02hhx%02hhx%02hhx%02hhx-"
   "%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-"
   "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx";
 
@@ -59535,20 +61392,17 @@ char* cdiEscapeSpaces(const char* string)
 {
   //How much memory do we need?
   size_t escapeCount = 0, length = 0;
-  for(const char* current = string; *current; current++)
-    {
-      if(strchr(" \\", *current)) escapeCount++;
-      length++;
-    }
+  for(; string[length]; ++length)
+    escapeCount += string[length] == ' ' || string[length] == '\\';
 
-  char* result = malloc(length + escapeCount + 1);
+  char* result = (char *) Malloc(length + escapeCount + 1);
   if(!result) return NULL;
 
   //Do the escaping.
-  for(size_t in = 0, out = 0; in < length;)
+  for(size_t in = 0, out = 0; in < length; ++out, ++in)
     {
-      if(strchr(" \\", string[in])) result[out++] = '\\';
-      result[out++] = string[in++];
+      if(string[in] == ' ' || string[in] == '\\') result[out++] = '\\';
+      result[out] = string[in];
     }
   result[length + escapeCount] = 0;     //termination!
   return result;
@@ -59571,7 +61425,7 @@ char* cdiUnescapeSpaces(const char* string, const char** outStringEnd)
       length++;
     }
 
-  char* result = malloc(length + 1);
+  char* result = (char *) Malloc(length + 1);
   if(!result) return NULL;
 
   //Do the unescaping.
@@ -59621,9 +61475,9 @@ typedef uint32_t u_int32_t;
 void
 create_uuid(unsigned char *uuid)
 {
-  unsigned32 status;
-  uuid_create((uuid_t *)uuid, &status);
-  if (status == -1)
+  uint32_t status;
+  uuid_create((uuid_t *)(void *)uuid, &status);
+  if (status != uuid_s_ok)
     {
       perror("uuid generation failed!");
       exit(1);
@@ -59691,6 +61545,7 @@ static int numberOfVerticalLevels = 0;
 static int numberOfVerticalGrid = 0;
 static unsigned char uuidVGrid[CDI_UUID_SIZE];
 
+
 typedef struct
 {
   int      level1;
@@ -59700,48 +61555,58 @@ typedef struct
 }
 leveltable_t;
 
+
 typedef struct
 {
-  int           param;
-  int           prec;
-  int           tsteptype;
-  int           timave;
-  int           timaccu;
-  int           gridID;
-  int           zaxistype;
-  int           ltype1;     /* GRIB first level type */
-  int           ltype2;     /* GRIB second level type */
-  int           lbounds;
-  int           level_sf;
-  int           level_unit;
-  int           zaxisID;
+  int           subtypeIndex; /* corresponding tile in subtype_t structure (subtype->self) */
+
   unsigned      nlevels;
   int           levelTableSize;
-  leveltable_t *levelTable;
-  int           instID;
-  int           modelID;
-  int           tableID;
-  int           comptype;       // compression type
-  int           complevel;      // compression level
-  int           lmissval;
-  double        missval;
-  char         *name;
-  char         *stdname;
-  char         *longname;
-  char         *units;
-  ensinfo_t    *ensdata;
-  int           typeOfGeneratingProcess;
-  int           productDefinitionTemplate;
-#if  defined  (HAVE_LIBGRIB_API)
-  /* (Optional) list of keyword/double value pairs */
-  int           opt_grib_dbl_nentries;
-  char         *opt_grib_dbl_keyword[MAX_OPT_GRIB_ENTRIES];
-  double        opt_grib_dbl_val[MAX_OPT_GRIB_ENTRIES];
-  /* (Optional) list of keyword/integer value pairs */
-  int           opt_grib_int_nentries;
-  char         *opt_grib_int_keyword[MAX_OPT_GRIB_ENTRIES];
-  int           opt_grib_int_val[MAX_OPT_GRIB_ENTRIES];
-#endif
+  leveltable_t* levelTable;
+} subtypetable_t;
+
+
+typedef struct
+{
+  int            param;
+  int            prec;
+  int            tsteptype;
+  int            timaccu;
+  int            gridID;
+  int            zaxistype;
+  int            ltype1;     /* GRIB first level type */
+  int            ltype2;     /* GRIB second level type */
+  int            lbounds;
+  int            level_sf;
+  int            level_unit;
+  int            zaxisID;
+
+  int            nsubtypes_alloc;
+  int            nsubtypes;
+  subtypetable_t *recordTable;    /* ~ two-dimensional record list [nsubtypes_alloc][levelTableSize] */
+
+  int            instID;
+  int            modelID;
+  int            tableID;
+  int            comptype;       // compression type
+  int            complevel;      // compression level
+  short          timave;
+  short          lmissval;
+  double         missval;
+  char          *name;
+  char          *stdname;
+  char          *longname;
+  char          *units;
+  ensinfo_t     *ensdata;
+  int            typeOfGeneratingProcess;
+  int            productDefinitionTemplate;
+
+  /* meta-data for specification of tiles (currently only GRIB-API: */
+  subtype_t     *tiles;
+
+  int                 opt_grib_nentries;                       /* current no. key-value pairs            */
+  int                 opt_grib_kvpair_size;                    /* current allocated size                 */
+  opt_key_val_pair_t *opt_grib_kvpair;                         /* (optional) list of keyword/value pairs */
 }
 vartable_t;
 
@@ -59766,9 +61631,9 @@ paramInitEntry(unsigned varID, int param)
   vartable[varID].lbounds        = 0;
   vartable[varID].level_sf       = 0;
   vartable[varID].level_unit     = 0;
-  vartable[varID].levelTable     = NULL;
-  vartable[varID].levelTableSize = 0;
-  vartable[varID].nlevels        = 0;
+  vartable[varID].recordTable    = NULL;
+  vartable[varID].nsubtypes_alloc= 0;
+  vartable[varID].nsubtypes      = 0;
   vartable[varID].instID         = UNDEFID;
   vartable[varID].modelID        = UNDEFID;
   vartable[varID].tableID        = UNDEFID;
@@ -59783,25 +61648,39 @@ paramInitEntry(unsigned varID, int param)
   vartable[varID].longname       = NULL;
   vartable[varID].units          = NULL;
   vartable[varID].ensdata        = NULL;
+  vartable[varID].tiles          = NULL;
 }
 
+/* Test if a variable specified by the given meta-data has already
+ * been registered in "vartable". */
 static unsigned
-varGetEntry(int param, int zaxistype, int ltype1, int tsteptype, const char *name)
+varGetEntry(int param, int zaxistype, int ltype1, int tsteptype, const char *name, const var_tile_t *tiles)
 {
   for ( unsigned varID = 0; varID < varTablesize; varID++ )
     {
-      if ( vartable[varID].param      == param       &&
-	   vartable[varID].zaxistype  == zaxistype   &&
-	   vartable[varID].ltype1     == ltype1      &&
-	   vartable[varID].tsteptype  == tsteptype )
+      /* testing for "param" implicitly checks if we are beyond the
+       * current vartable size: */
+      if (vartable[varID].param == param)
         {
-          if ( name && name[0] && vartable[varID].name && vartable[varID].name[0] )
+          int no_of_tiles = -1;
+          if ( tiles ) no_of_tiles = tiles->numberOfTiles;
+          int vt_no_of_tiles = -1;
+          if ( vartable[varID].tiles )
+            vt_no_of_tiles = subtypeGetGlobalDataP(vartable[varID].tiles,
+                                                   SUBTYPE_ATT_NUMBER_OF_TILES);
+          if ( (vartable[varID].zaxistype  == zaxistype)               &&
+               (vartable[varID].ltype1     == ltype1   )               &&
+               (vartable[varID].tsteptype  == tsteptype)               &&
+               (vt_no_of_tiles == no_of_tiles) )
             {
-              if ( strcmp(name, vartable[varID].name) == 0 ) return (varID);
-            }
-          else
-            {
-              return (varID);
+              if ( name && name[0] && vartable[varID].name && vartable[varID].name[0] )
+                {
+                  if ( strcmp(name, vartable[varID].name) == 0 ) return (varID);
+                }
+              else
+                {
+                  return (varID);
+                }
             }
         }
     }
@@ -59812,41 +61691,119 @@ varGetEntry(int param, int zaxistype, int ltype1, int tsteptype, const char *nam
 static
 void varFree(void)
 {
+  if ( CDI_Debug ) Message("call to varFree");
+
   for ( unsigned varID = 0; varID < nvars; varID++ )
     {
-      if ( vartable[varID].levelTable )
-	free(vartable[varID].levelTable);
+      if ( vartable[varID].recordTable )
+        {
+          for (int isub=0; isub<vartable[varID].nsubtypes_alloc; isub++)
+            Free(vartable[varID].recordTable[isub].levelTable);
+          Free(vartable[varID].recordTable);
+        }
+
+      if ( vartable[varID].name )     Free(vartable[varID].name);
+      if ( vartable[varID].stdname )  Free(vartable[varID].stdname);
+      if ( vartable[varID].longname ) Free(vartable[varID].longname);
+      if ( vartable[varID].units )    Free(vartable[varID].units);
+      if ( vartable[varID].ensdata )  Free(vartable[varID].ensdata);
+      if ( vartable[varID].tiles )    subtypeDestroyPtr(vartable[varID].tiles);
 
-      if ( vartable[varID].name )     free(vartable[varID].name);
-      if ( vartable[varID].stdname )  free(vartable[varID].stdname);
-      if ( vartable[varID].longname ) free(vartable[varID].longname);
-      if ( vartable[varID].units )    free(vartable[varID].units);
-      if ( vartable[varID].ensdata )  free(vartable[varID].ensdata);
+      if ( vartable[varID].opt_grib_kvpair )
+        {
+          for (int i=0; i<vartable[varID].opt_grib_nentries; i++) {
+            if ( vartable[varID].opt_grib_kvpair[i].keyword )
+              Free(vartable[varID].opt_grib_kvpair[i].keyword);
+          }
+          Free(vartable[varID].opt_grib_kvpair);
+        }
+      vartable[varID].opt_grib_nentries    = 0;
+      vartable[varID].opt_grib_kvpair_size = 0;
+      vartable[varID].opt_grib_kvpair      = NULL;
     }
 
   if ( vartable )
-    free(vartable);
+    Free(vartable);
 
   vartable = NULL;
   varTablesize = 0;
   nvars = 0;
 
   if ( Vct )
-    free(Vct);
+    Free(Vct);
 
   Vct = NULL;
   Vctsize = 0;
 }
 
-static int
-levelNewEntry(unsigned varID, int level1, int level2)
+/* Search for a tile subtype with subtypeIndex == tile_index. */
+static int tileGetEntry(unsigned varID, int tile_index)
 {
-  int levelID = 0;
-  int levelTableSize;
-  leveltable_t *levelTable;
+  for (int isub=0; isub<vartable[varID].nsubtypes; isub++)
+    if (vartable[varID].recordTable[isub].subtypeIndex == tile_index)
+      return isub;
+  return CDI_UNDEFID;
+}
+
+
+/* Resizes vartable:recordTable data structure, if necessary. */
+static int tileNewEntry(int varID)
+{
+  int tileID = 0;
+  if (vartable[varID].nsubtypes_alloc == 0)
+    {
+      /* create table for the first time. */
+      vartable[varID].nsubtypes_alloc = 2;
+      vartable[varID].nsubtypes       = 0;
+      vartable[varID].recordTable     =
+        (subtypetable_t *) Malloc((size_t)vartable[varID].nsubtypes_alloc * sizeof (subtypetable_t));
+      if( vartable[varID].recordTable == NULL )
+        SysError("Allocation of leveltable failed!");
+
+      for (int isub = 0; isub<vartable[varID].nsubtypes_alloc; isub++) {
+	vartable[varID].recordTable[isub].levelTable     = NULL;
+        vartable[varID].recordTable[isub].levelTableSize = 0;
+        vartable[varID].recordTable[isub].nlevels        = 0;
+        vartable[varID].recordTable[isub].subtypeIndex   = CDI_UNDEFID;
+      }
+    }
+  else
+    {
+      /* data structure large enough; find a free entry. */
+      while(tileID <  vartable[varID].nsubtypes_alloc)
+	{
+	  if (vartable[varID].recordTable[tileID].levelTable == NULL) break;
+	  tileID++;
+	}
+    }
+
+  /* If the table overflows, double its size. */
+  if (tileID == vartable[varID].nsubtypes_alloc)
+    {
+      tileID = vartable[varID].nsubtypes_alloc;
+      vartable[varID].nsubtypes_alloc *= 2;
+      vartable[varID].recordTable   =
+        (subtypetable_t *) Realloc(vartable[varID].recordTable,
+                                   (size_t)vartable[varID].nsubtypes_alloc * sizeof (subtypetable_t));
+      if (vartable[varID].recordTable == NULL)
+        SysError("Reallocation of leveltable failed");
+      for(int isub=tileID; isub<vartable[varID].nsubtypes_alloc; isub++) {
+	vartable[varID].recordTable[isub].levelTable     = NULL;
+        vartable[varID].recordTable[isub].levelTableSize = 0;
+        vartable[varID].recordTable[isub].nlevels        = 0;
+        vartable[varID].recordTable[isub].subtypeIndex   = CDI_UNDEFID;
+      }
+    }
 
-  levelTableSize = vartable[varID].levelTableSize;
-  levelTable     = vartable[varID].levelTable;
+  return tileID;
+}
+
+
+static int levelNewEntry(unsigned varID, int level1, int level2, int tileID)
+{
+  int levelID = 0;
+  int levelTableSize = vartable[varID].recordTable[tileID].levelTableSize;
+  leveltable_t *levelTable = vartable[varID].recordTable[tileID].levelTable;
 
   /*
     Look for a free slot in levelTable.
@@ -59854,56 +61811,37 @@ levelNewEntry(unsigned varID, int level1, int level2)
   */
   if ( ! levelTableSize )
     {
-      int i;
-
       levelTableSize = 2;
-      levelTable = (leveltable_t *)xmalloc((size_t)levelTableSize
+      levelTable = (leveltable_t *) Malloc((size_t)levelTableSize
                                            * sizeof (leveltable_t));
-      if( levelTable == NULL )
-	{
-          Message("levelTableSize = %d", levelTableSize);
-	  SysError("Allocation of leveltable failed!");
-	}
-
-      for( i = 0; i < levelTableSize; i++ )
-	levelTable[i].recID = UNDEFID;
+      for ( int i = 0; i < levelTableSize; i++ )
+        levelTable[i].recID = UNDEFID;
     }
   else
     {
-      while( levelID < levelTableSize )
-	{
-	  if ( levelTable[levelID].recID == UNDEFID ) break;
-	  levelID++;
-	}
+      while( levelID < levelTableSize
+             && levelTable[levelID].recID != UNDEFID )
+        ++levelID;
     }
   /*
     If the table overflows, double its size.
   */
   if( levelID == levelTableSize )
     {
-      int i;
-
-      levelTableSize = 2*levelTableSize;
-      levelTable = (leveltable_t *)xrealloc(levelTable, (size_t)levelTableSize
+      levelTable = (leveltable_t *) Realloc(levelTable,
+                                            (size_t)(levelTableSize *= 2)
                                             * sizeof (leveltable_t));
-      if( levelTable == NULL )
-	{
-          Message("levelTableSize = %d", levelTableSize);
-	  SysError("Reallocation of leveltable failed");
-	}
-      levelID = levelTableSize/2;
-
-      for( i = levelID; i < levelTableSize; i++ )
-	levelTable[i].recID = UNDEFID;
+      for( int i = levelID; i < levelTableSize; i++ )
+        levelTable[i].recID = UNDEFID;
     }
 
   levelTable[levelID].level1   = level1;
   levelTable[levelID].level2   = level2;
   levelTable[levelID].lindex   = levelID;
 
-  vartable[varID].nlevels = (unsigned)levelID+1;
-  vartable[varID].levelTableSize = levelTableSize;
-  vartable[varID].levelTable = levelTable;
+  vartable[varID].recordTable[tileID].nlevels        = (unsigned)levelID+1;
+  vartable[varID].recordTable[tileID].levelTableSize = levelTableSize;
+  vartable[varID].recordTable[tileID].levelTable     = levelTable;
 
   return (levelID);
 }
@@ -59922,7 +61860,7 @@ paramNewEntry(int param)
   if ( ! varTablesize )
     {
       varTablesize = 2;
-      vartable = (vartable_t *)xmalloc((size_t)varTablesize
+      vartable = (vartable_t *) Malloc((size_t)varTablesize
                                        * sizeof (vartable_t));
       if( vartable == NULL )
 	{
@@ -59931,13 +61869,12 @@ paramNewEntry(int param)
 	}
 
       for( unsigned i = 0; i < varTablesize; i++ )
-	{
-	  vartable[i].param = UNDEF_PARAM;
-#if  defined  (HAVE_LIBGRIB_API)
-	  vartable[i].opt_grib_int_nentries = 0;
-	  vartable[i].opt_grib_dbl_nentries = 0;
-#endif
-	}
+        {
+          vartable[i].param = UNDEF_PARAM;
+          vartable[i].opt_grib_kvpair      = NULL;
+          vartable[i].opt_grib_kvpair_size = 0;
+          vartable[i].opt_grib_nentries    = 0;
+        }
     }
   else
     {
@@ -59952,25 +61889,15 @@ paramNewEntry(int param)
   */
   if ( varID == varTablesize )
     {
-
-      varTablesize = 2 * varTablesize;
-      vartable = (vartable_t *)xrealloc(vartable, (size_t)varTablesize
+      vartable = (vartable_t *) Realloc(vartable, (size_t)(varTablesize *= 2)
                                         * sizeof (vartable_t));
-      if( vartable == NULL )
-	{
-          Message("varTablesize = %d", varTablesize);
-	  SysError("Reallocation of vartable failed!");
-	}
-      varID = varTablesize/2;
-
       for( unsigned i = varID; i < varTablesize; i++ )
-	{
-	  vartable[i].param = UNDEF_PARAM;
-#if  defined  (HAVE_LIBGRIB_API)
-	  vartable[i].opt_grib_int_nentries = 0;
-	  vartable[i].opt_grib_dbl_nentries = 0;
-#endif
-	}
+        {
+          vartable[i].param = UNDEF_PARAM;
+          vartable[i].opt_grib_kvpair      = NULL;
+          vartable[i].opt_grib_kvpair_size = 0;
+          vartable[i].opt_grib_nentries    = 0;
+        }
     }
 
   paramInitEntry(varID, param);
@@ -59979,13 +61906,68 @@ paramNewEntry(int param)
 }
 
 
+/* Append tile set to a subtype. Return index of the new tile (i.e.
+ * the "entry->self" value). */
+static
+int varInsertTileSubtype(vartable_t *vptr, const var_tile_t *tiles)
+{
+  if ( tiles == NULL ) return -1;
+
+  int totalno_of_tileattr_pairs = -1;
+  int tileClassification = -1;
+  int numberOfTiles = -1;
+  int numberOfAttributes = -1;
+  int tileindex = -1;
+  int attribute = -1;
+
+  if ( tiles )
+    {
+      totalno_of_tileattr_pairs = tiles->totalno_of_tileattr_pairs;
+      tileClassification =  tiles->tileClassification;
+      numberOfTiles = tiles->numberOfTiles;
+      numberOfAttributes = tiles->numberOfAttributes;
+      tileindex = tiles->tileindex;
+      attribute = tiles->attribute;
+    }
+
+  /* first, generate a subtype based on the info in "tiles". */
+
+  subtype_t *subtype_ptr;
+  subtypeAllocate(&subtype_ptr, SUBTYPE_TILES);
+  subtypeDefGlobalDataP(subtype_ptr, SUBTYPE_ATT_TOTALNO_OF_TILEATTR_PAIRS, totalno_of_tileattr_pairs);
+  subtypeDefGlobalDataP(subtype_ptr, SUBTYPE_ATT_TILE_CLASSIFICATION      , tileClassification);
+  subtypeDefGlobalDataP(subtype_ptr, SUBTYPE_ATT_NUMBER_OF_TILES          , numberOfTiles);
+
+  /*
+   * Here, we create a tile set for comparison that contains only one
+   * tile/attribute pair (based on "tiles").
+   */
+  struct subtype_entry_t *entry = subtypeEntryInsert(subtype_ptr);
+  subtypeDefEntryDataP(entry, SUBTYPE_ATT_NUMBER_OF_ATTR,            numberOfAttributes);
+  subtypeDefEntryDataP(entry, SUBTYPE_ATT_TILEINDEX,                 tileindex);
+  subtypeDefEntryDataP(entry, SUBTYPE_ATT_TILEATTRIBUTE,             attribute);
+
+  if (vptr->tiles == NULL) {
+    vptr->tiles = subtype_ptr;
+    return 0;
+  }
+  else {
+    tilesetInsertP(vptr->tiles, subtype_ptr);
+    subtypeDestroyPtr(subtype_ptr);
+    return vptr->tiles->nentries - 1;
+  }
+  return CDI_UNDEFID;
+}
+
+
 void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
 		  int level1, int level2, int level_sf, int level_unit, int prec,
 		  int *pvarID, int *plevelID, int tsteptype, int numavg, int ltype1, int ltype2,
-		  const char *name, const char *stdname, const char *longname, const char *units)
+		  const char *name, const char *stdname, const char *longname, const char *units,
+                  const var_tile_t *tiles, int *tile_index)
 {
   unsigned varID = (cdiSplitLtype105 != 1 || zaxistype != ZAXIS_HEIGHT) ?
-    varGetEntry(param, zaxistype, ltype1, tsteptype, name) : (unsigned)UNDEFID;
+    varGetEntry(param, zaxistype, ltype1, tsteptype, name, tiles) : (unsigned)UNDEFID;
 
   if ( varID == (unsigned)UNDEFID )
     {
@@ -59999,6 +61981,7 @@ void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
       vartable[varID].level_sf   = level_sf;
       vartable[varID].level_unit = level_unit;
       vartable[varID].tsteptype  = tsteptype;
+
       if ( numavg ) vartable[varID].timave = 1;
 
       if ( name )     if ( name[0] )     vartable[varID].name     = strdup(name);
@@ -60025,12 +62008,28 @@ void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
 
   if ( prec > vartable[varID].prec ) vartable[varID].prec = prec;
 
-  int levelID = levelNewEntry(varID, level1, level2);
-  vartable[varID].levelTable[levelID].recID = recID;
+  /* append current tile to tile subtype info. */
+  int this_tile = varInsertTileSubtype(&vartable[varID], tiles);
+  int tileID = tileGetEntry(varID, this_tile);
+  if ( tile_index ) (*tile_index) = this_tile;
+  if (tileID == CDI_UNDEFID) {
+    tileID = tileNewEntry((int)varID);
+    vartable[varID].recordTable[tileID].subtypeIndex = this_tile;
+    vartable[varID].nsubtypes++;
+  }
+
+  /* append current level to level table info */
+  int levelID = levelNewEntry(varID, level1, level2, tileID);
+  if (CDI_Debug)
+    Message("vartable[%d].recordTable[%d].levelTable[%d].recID = %d; level1,2=%d,%d",
+            varID, tileID, levelID, recID, level1, level2);
+  vartable[varID].recordTable[tileID].levelTable[levelID].recID = recID;
 
-  *pvarID   = (int)varID;
+  *pvarID   = (int) varID;
   *plevelID = levelID;
 }
+
+
 /*
 static
 int dblcmp(const void *s1, const void *s2)
@@ -60099,6 +62098,7 @@ int cmpparam(const void* s1, const void* s2)
 void cdi_generate_vars(stream_t *streamptr)
 {
   int gridID, zaxisID;
+
   int instID, modelID, tableID;
   int param, zaxistype, ltype1, ltype2;
   int prec;
@@ -60113,12 +62113,12 @@ void cdi_generate_vars(stream_t *streamptr)
   double level_sf = 1;
   int vlistID = streamptr->vlistID;
 
-  int *varids = (int *)xmalloc(nvars*sizeof(int));
+  int *varids = (int *) Malloc(nvars*sizeof(int));
   for ( unsigned varID = 0; varID < nvars; varID++ ) varids[varID] = (int)varID;
 
   if ( streamptr->sortname )
     {
-      param_t *varInfo = (param_t *)xmalloc((size_t)nvars * sizeof (param_t));
+      param_t *varInfo = (param_t *) Malloc((size_t)nvars * sizeof (param_t));
 
       for ( unsigned varID = 0; varID < nvars; varID++ )
 	{
@@ -60131,7 +62131,7 @@ void cdi_generate_vars(stream_t *streamptr)
 	{
 	  varids[varID] = varInfo[varID].varid;
 	}
-      free(varInfo);
+      Free(varInfo);
     }
 
   for ( unsigned index = 0; index < nvars; index++ )
@@ -60140,7 +62140,6 @@ void cdi_generate_vars(stream_t *streamptr)
 
       gridID     = vartable[varid].gridID;
       param      = vartable[varid].param;
-      unsigned nlevels = vartable[varid].nlevels;
       ltype1     = vartable[varid].ltype1;
       ltype2     = vartable[varid].ltype2;
       zaxistype = vartable[varid].zaxistype;
@@ -60161,19 +62160,50 @@ void cdi_generate_vars(stream_t *streamptr)
 
       zaxisID = UNDEFID;
 
+      /* consistency check: test if all subtypes have the same levels: */
+      unsigned nlevels = vartable[varid].recordTable[0].nlevels;
+      for (int isub=1; isub<vartable[varid].nsubtypes; isub++) {
+        if (vartable[varid].recordTable[isub].nlevels != nlevels)
+          {
+            fprintf(stderr, "var \"%s\": isub = %d / %d :: "
+                    "nlevels = %d, vartable[varid].recordTable[isub].nlevels = %d\n",
+                    vartable[varid].name, isub, vartable[varid].nsubtypes,
+                    nlevels, vartable[varid].recordTable[isub].nlevels);
+            Error("zaxis size must not change for same parameter!");
+          }
+
+        leveltable_t *t1 = vartable[varid].recordTable[isub-1].levelTable;
+        leveltable_t *t2 = vartable[varid].recordTable[isub  ].levelTable;
+        for (unsigned ilev=0; ilev<nlevels; ilev++)
+          if ((t1[ilev].level1 != t2[ilev].level1)  ||
+              (t1[ilev].level2 != t2[ilev].level2)  ||
+              (t1[ilev].lindex != t2[ilev].lindex))
+            {
+              fprintf(stderr, "var \"%s\", varID=%d: isub = %d / %d :: "
+                      "nlevels = %d, vartable[varid].recordTable[isub].nlevels = %d\n",
+                      vartable[varid].name, varid, isub, vartable[varid].nsubtypes,
+                      nlevels, vartable[varid].recordTable[isub].nlevels);
+              Message("t1[ilev].level1=%d / t2[ilev].level1=%d",t1[ilev].level1, t2[ilev].level1);
+              Message("t1[ilev].level2=%d / t2[ilev].level2=%d",t1[ilev].level2, t2[ilev].level2);
+              Message("t1[ilev].lindex=%d / t2[ilev].lindex=%d",t1[ilev].lindex, t2[ilev].lindex);
+              Error("zaxis type must not change for same parameter!");
+            }
+      }
+      leveltable_t *levelTable = vartable[varid].recordTable[0].levelTable;
+
       if ( ltype1 == 0 && zaxistype == ZAXIS_GENERIC && nlevels == 1 &&
-	   vartable[varid].levelTable[0].level1 == 0 )
+	   levelTable[0].level1 == 0 )
 	zaxistype = ZAXIS_SURFACE;
 
-      dlevels = (double *) malloc(nlevels*sizeof(double));
+      dlevels = (double *) Malloc(nlevels*sizeof(double));
 
       if ( lbounds && zaxistype != ZAXIS_HYBRID && zaxistype != ZAXIS_HYBRID_HALF )
 	for (unsigned levelID = 0; levelID < nlevels; levelID++ )
-	  dlevels[levelID] = (level_sf*vartable[varid].levelTable[levelID].level1 +
-	                      level_sf*vartable[varid].levelTable[levelID].level2)/2;
+	  dlevels[levelID] = (level_sf*levelTable[levelID].level1 +
+	                      level_sf*levelTable[levelID].level2)/2;
       else
 	for (unsigned levelID = 0; levelID < nlevels; levelID++ )
-	  dlevels[levelID] = level_sf*vartable[varid].levelTable[levelID].level1;
+	  dlevels[levelID] = level_sf*levelTable[levelID].level1;
 
       if ( nlevels > 1 )
 	{
@@ -60187,24 +62217,24 @@ void cdi_generate_vars(stream_t *streamptr)
             }
           /*
            * always sort pressure z-axis to ensure
-           * vartable[varid].levelTable[levelID1].level1 < vartable[varid].levelTable[levelID2].level1 <=> levelID1 > levelID2
+           * levelTable[levelID1].level1 < levelTable[levelID2].level1 <=> levelID1 > levelID2
            * unless already sorted in decreasing order
            */
           if ( !ldec && zaxistype == ZAXIS_PRESSURE )
             {
-              qsort(vartable[varid].levelTable, nlevels, sizeof(leveltable_t), cmpLevelTableInv);
+              qsort(levelTable, nlevels, sizeof(leveltable_t), cmpLevelTableInv);
               lsort = true;
             }
           /*
            * always sort hybrid and depth-below-land z-axis to ensure
-           * vartable[varid].levelTable[levelID1].level1 < vartable[varid].levelTable[levelID2].level1 <=> levelID1 < levelID2
+           * levelTable[levelID1].level1 < levelTable[levelID2].level1 <=> levelID1 < levelID2
            * unless already sorted in increasing order
            */
           else if ( (!linc && !ldec) ||
                     zaxistype == ZAXIS_HYBRID ||
                     zaxistype == ZAXIS_DEPTH_BELOW_LAND )
             {
-              qsort(vartable[varid].levelTable, nlevels, sizeof(leveltable_t), cmpLevelTable);
+              qsort(levelTable, nlevels, sizeof(leveltable_t), cmpLevelTable);
               lsort = true;
             }
 
@@ -60212,25 +62242,25 @@ void cdi_generate_vars(stream_t *streamptr)
             {
               if ( lbounds && zaxistype != ZAXIS_HYBRID && zaxistype != ZAXIS_HYBRID_HALF )
                 for (unsigned levelID = 0; levelID < nlevels; levelID++ )
-                  dlevels[levelID] = (level_sf*vartable[varid].levelTable[levelID].level1 +
-                                      level_sf*vartable[varid].levelTable[levelID].level2)/2.;
+                  dlevels[levelID] = (level_sf*levelTable[levelID].level1 +
+                                      level_sf*levelTable[levelID].level2)/2.;
               else
                 for (unsigned levelID = 0; levelID < nlevels; levelID++ )
-                  dlevels[levelID] = level_sf*vartable[varid].levelTable[levelID].level1;
+                  dlevels[levelID] = level_sf*levelTable[levelID].level1;
             }
 	}
 
       if ( lbounds )
 	{
-	  dlevels1 = (double *) malloc(nlevels*sizeof(double));
+	  dlevels1 = (double *) Malloc(nlevels*sizeof(double));
 	  for (unsigned levelID = 0; levelID < nlevels; levelID++)
-	    dlevels1[levelID] = level_sf*vartable[varid].levelTable[levelID].level1;
-	  dlevels2 = (double *) malloc(nlevels*sizeof(double));
+	    dlevels1[levelID] = level_sf*levelTable[levelID].level1;
+	  dlevels2 = (double *) Malloc(nlevels*sizeof(double));
 	  for (unsigned levelID = 0; levelID < nlevels; levelID++)
-	    dlevels2[levelID] = level_sf*vartable[varid].levelTable[levelID].level2;
+	    dlevels2[levelID] = level_sf*levelTable[levelID].level2;
         }
 
-      char *unitptr = cdiUnitNamePtr(vartable[varid].level_unit);
+      const char *unitptr = cdiUnitNamePtr(vartable[varid].level_unit);
       zaxisID = varDefZaxis(vlistID, zaxistype, (int)nlevels, dlevels, lbounds, dlevels1, dlevels2,
                             (int)Vctsize, Vct, NULL, NULL, unitptr, 0, 0, ltype1);
 
@@ -60246,12 +62276,17 @@ void cdi_generate_vars(stream_t *streamptr)
           if ( !cdiUUIDIsNull(uuidVGrid) ) zaxisDefUUID(zaxisID, uuidVGrid);
         }
 
-      if ( lbounds ) free(dlevels1);
-      if ( lbounds ) free(dlevels2);
-      free(dlevels);
+      if ( lbounds ) Free(dlevels1);
+      if ( lbounds ) Free(dlevels2);
+      Free(dlevels);
 
-      int varID = stream_new_var(streamptr, gridID, zaxisID);
-      varID = vlistDefVar(vlistID, gridID, zaxisID, tsteptype);
+      /* define new subtype for tile set */
+      int tilesetID = CDI_UNDEFID;
+      if ( vartable[varid].tiles ) tilesetID = vlistDefTileSubtype(vlistID, vartable[varid].tiles);
+
+      /* generate new variable */
+      int varID = stream_new_var(streamptr, gridID, zaxisID, tilesetID);
+      varID = vlistDefVarTiles(vlistID, gridID, zaxisID, tsteptype, tilesetID);
 
       vlistDefVarParam(vlistID, varID, param);
       vlistDefVarDatatype(vlistID, varID, prec);
@@ -60266,7 +62301,6 @@ void cdi_generate_vars(stream_t *streamptr)
         vlistDefVarProductDefinitionTemplate(vlistID, varID, vartable[varid].productDefinitionTemplate);
 
       if ( vartable[varid].lmissval ) vlistDefVarMissval(vlistID, varID, vartable[varid].missval);
-
       if ( vartable[varid].name )     vlistDefVarName(vlistID, varID, vartable[varid].name);
       if ( vartable[varid].stdname )  vlistDefVarStdname(vlistID, varID, vartable[varid].stdname);
       if ( vartable[varid].longname ) vlistDefVarLongname(vlistID, varID, vartable[varid].longname);
@@ -60276,34 +62310,23 @@ void cdi_generate_vars(stream_t *streamptr)
 	                                                  vartable[varid].ensdata->ens_count,
 							  vartable[varid].ensdata->forecast_init_type);
 
-#if  defined  (HAVE_LIBGRIB_API)
-      /* ---------------------------------- */
-      /* Local change: 2013-04-23, FP (DWD) */
-      /* ---------------------------------- */
-
       int    i;
       vlist_t *vlistptr;
       vlistptr = vlist_to_pointer(vlistID);
-      for (i=0; i<vartable[varid].opt_grib_int_nentries; i++)
+      for (i=0; i<vartable[varid].opt_grib_nentries; i++)
         {
-          int idx = vlistptr->vars[varID].opt_grib_int_nentries;
-          vlistptr->vars[varID].opt_grib_int_nentries++;
-          if ( idx >= MAX_OPT_GRIB_ENTRIES ) Error("Too many optional keyword/integer value pairs!");
-          vlistptr->vars[varID].opt_grib_int_update[idx] = TRUE;
-          vlistptr->vars[varID].opt_grib_int_val[idx] = vartable[varid].opt_grib_int_val[idx];
-          vlistptr->vars[varID].opt_grib_int_keyword[idx] = strdupx(vartable[varid].opt_grib_int_keyword[idx]);
-        }
-      for (i=0; i<vartable[varid].opt_grib_dbl_nentries; i++)
-        {
-          int idx = vlistptr->vars[varID].opt_grib_dbl_nentries;
-          vlistptr->vars[varID].opt_grib_dbl_nentries++;
-          if ( idx >= MAX_OPT_GRIB_ENTRIES ) Error("Too many optional keyword/double value pairs!");
-          vlistptr->vars[varID].opt_grib_dbl_update[idx] = TRUE;
-          vlistptr->vars[varID].opt_grib_dbl_val[idx] = vartable[varid].opt_grib_dbl_val[idx];
-          vlistptr->vars[varID].opt_grib_dbl_keyword[idx] = strdupx(vartable[varid].opt_grib_dbl_keyword[idx]);
+          resize_opt_grib_entries(&vlistptr->vars[varID], vlistptr->vars[varID].opt_grib_nentries+1);
+          vlistptr->vars[varID].opt_grib_nentries += 1;
+          int idx = vlistptr->vars[varID].opt_grib_nentries-1;
+
+          vlistptr->vars[varID].opt_grib_kvpair[idx] = vartable[varid].opt_grib_kvpair[i];
+          vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = NULL;
+	  if (vartable[varid].opt_grib_kvpair[i].keyword) 
+	    vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = 
+	      strdupx(vartable[varid].opt_grib_kvpair[i].keyword);
+          vlistptr->vars[varID].opt_grib_kvpair[i].update = TRUE;
         }
       /* note: if the key is not defined, we do not throw an error! */
-#endif
 
       if ( cdiDefaultTableID != UNDEFID )
 	{
@@ -60340,34 +62363,42 @@ void cdi_generate_vars(stream_t *streamptr)
 
   for ( unsigned index = 0; index < nvars; index++ )
     {
-      int varID = (int)index;
       int varid = varids[index];
+      unsigned nlevels = vartable[varid].recordTable[0].nlevels;
 
-      unsigned nlevels = vartable[varid].nlevels;
       /*
       for ( levelID = 0; levelID < nlevels; levelID++ )
 	{
-	  printf("%d %d %d %d %d\n", varID, levelID,
+	  printf("%d %d %d %d %d\n", varid, levelID,
 		 vartable[varid].levelTable[levelID].lindex,
 		 vartable[varid].levelTable[levelID].recID,
 		 vartable[varid].levelTable[levelID].level1);
 	}
       */
-      for (unsigned levelID = 0; levelID < nlevels; levelID++)
-	{
-	  streamptr->vars[varID].level[levelID] = vartable[varid].levelTable[levelID].recID;
-          unsigned lindex;
-	  for (lindex = 0; lindex < nlevels; lindex++ )
-	    if ( levelID == (unsigned)vartable[varid].levelTable[lindex].lindex ) break;
-
-	  if ( lindex == nlevels )
-	    Error("Internal problem! lindex not found.");
-
-	  streamptr->vars[varID].lindex[levelID] = (int)lindex;
-	}
+      unsigned nsub = vartable[varid].nsubtypes >= 0
+        ? (unsigned)vartable[varid].nsubtypes : 0U;
+      for (size_t isub=0; isub < nsub; isub++)
+        {
+          sleveltable_t *restrict streamRecordTable
+            = streamptr->vars[index].recordTable + isub;
+          leveltable_t *restrict vartableLevelTable
+            = vartable[varid].recordTable[isub].levelTable;
+          for (unsigned levelID = 0; levelID < nlevels; levelID++)
+            {
+              streamRecordTable->recordID[levelID]
+                = vartableLevelTable[levelID].recID;
+              unsigned lindex;
+              for (lindex = 0; lindex < nlevels; lindex++ )
+                if ( levelID == (unsigned)vartableLevelTable[lindex].lindex )
+                  break;
+              if ( lindex == nlevels )
+                Error("Internal problem! lindex not found.");
+              streamRecordTable->lindex[levelID] = (int)lindex;
+            }
+        }
     }
 
-  free(varids);
+  Free(varids);
 
   varFree();
 }
@@ -60378,7 +62409,7 @@ void varDefVCT(size_t vctsize, double *vctptr)
   if ( Vct == NULL && vctptr != NULL && vctsize > 0 )
     {
       Vctsize = vctsize;
-      Vct = (double *) malloc(vctsize*sizeof(double));
+      Vct = (double *) Malloc(vctsize*sizeof(double));
       memcpy(Vct, vctptr, vctsize*sizeof(double));
     }
 }
@@ -60391,84 +62422,8 @@ void varDefZAxisReference(int nhlev, int nvgrid, unsigned char uuid[CDI_UUID_SIZ
   memcpy(uuidVGrid, uuid, CDI_UUID_SIZE);
 }
 
-struct varDefGridSearchState
-{
-  int resIDValue;
-  const grid_t *queryKey;
-};
-
-static enum cdiApplyRet
-varDefGridSearch(int id, void *res, void *data)
-{
-  struct varDefGridSearchState *state = data;
-  (void)res;
-  if (gridCompare(id, state->queryKey) == 0)
-    {
-      state->resIDValue = id;
-      return CDI_APPLY_STOP;
-    }
-  else
-    return CDI_APPLY_GO_ON;
-}
-
-int varDefGrid(int vlistID, const grid_t *grid, int mode)
-{
-  /*
-    mode: 0 search in vlist and grid table
-          1 search in grid table
-   */
-  int gridglobdefined = FALSE;
-  int griddefined;
-  int gridID = CDI_UNDEFID;
-  vlist_t *vlistptr = vlist_to_pointer(vlistID);
-
-  griddefined = FALSE;
-  unsigned ngrids = (unsigned)vlistptr->ngrids;
-
-  if ( mode == 0 )
-    for (unsigned index = 0; index < ngrids; index++ )
-      {
-	gridID = vlistptr->gridIDs[index];
-	if ( gridID == UNDEFID )
-	  Error("Internal problem: undefined gridID %d!", gridID);
-
-	if ( gridCompare(gridID, grid) == 0 )
-	  {
-	    griddefined = TRUE;
-	    break;
-	  }
-      }
-
-  if ( ! griddefined )
-    {
-      struct varDefGridSearchState query = { .queryKey = grid };
-      if ((gridglobdefined
-           = (cdiResHFilterApply(&gridOps, varDefGridSearch, &query)
-              == CDI_APPLY_STOP)))
-        gridID = query.resIDValue;
-
-      if ( mode == 1 && gridglobdefined)
-	for (unsigned index = 0; index < ngrids; index++ )
-	  if ( vlistptr->gridIDs[index] == gridID )
-	    {
-	      gridglobdefined = FALSE;
-	      break;
-	    }
-    }
-
-  if ( ! griddefined )
-    {
-      if ( ! gridglobdefined ) gridID = gridGenerate(grid);
-      ngrids = (unsigned)vlistptr->ngrids;
-      vlistptr->gridIDs[ngrids] = gridID;
-      vlistptr->ngrids++;
-    }
-
-  return (gridID);
-}
-
 
-int zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, const double *levels, char *longname, char *units, int ltype1)
+int zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, const double *levels, const char *longname, const char *units, int ltype1)
 {
   int differ = 1;
   int levelID;
@@ -60519,16 +62474,17 @@ struct varDefZAxisSearchState
   int resIDValue;
   int zaxistype;
   int nlevels;
-  double *levels;
   int lbounds;
-  char *longname, *units;
+  double *levels;
+  const char *longname;
+  const char *units;
   int ltype;
 };
 
 static enum cdiApplyRet
 varDefZAxisSearch(int id, void *res, void *data)
 {
-  struct varDefZAxisSearchState *state = data;
+  struct varDefZAxisSearchState *state = (struct varDefZAxisSearchState *)data;
   (void)res;
   if (zaxisCompare(id, state->zaxistype, state->nlevels, state->lbounds,
                    state->levels, state->longname, state->units, state->ltype)
@@ -60544,7 +62500,7 @@ varDefZAxisSearch(int id, void *res, void *data)
 
 int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbounds,
 		double *levels1, double *levels2, int vctsize, double *vct, char *name,
-		char *longname, char *units, int prec, int mode, int ltype1)
+		char *longname, const char *units, int prec, int mode, int ltype1)
 {
   /*
     mode: 0 search in vlist and zaxis table
@@ -60553,7 +62509,6 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbo
   int zaxisdefined = 0;
   int nzaxis;
   int zaxisID = UNDEFID;
-  int index;
   int zaxisglobdefined = 0;
   vlist_t *vlistptr;
 
@@ -60562,7 +62517,7 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbo
   nzaxis = vlistptr->nzaxis;
 
   if ( mode == 0 )
-    for ( index = 0; index < nzaxis; index++ )
+    for ( int index = 0; index < nzaxis; index++ )
       {
 	zaxisID = vlistptr->zaxisIDs[index];
 
@@ -60575,17 +62530,17 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbo
 
   if ( ! zaxisdefined )
     {
-      struct varDefZAxisSearchState query = {
-        .zaxistype = zaxistype,
-        .nlevels = nlevels,
-        .levels = levels,
-        .lbounds = lbounds,
-        .longname = longname,
-        .units = units,
-        .ltype = ltype1,
-      };
+      struct varDefZAxisSearchState query;
+      query.zaxistype = zaxistype;
+      query.nlevels = nlevels;
+      query.levels = levels;
+      query.lbounds = lbounds;
+      query.longname = longname;
+      query.units = units;
+      query.ltype = ltype1;
+
       if ((zaxisglobdefined
-           = (cdiResHFilterApply(&zaxisOps, varDefZAxisSearch, &query)
+           = (cdiResHFilterApply(getZaxisOps(), varDefZAxisSearch, &query)
               == CDI_APPLY_STOP)))
         zaxisID = query.resIDValue;
 
@@ -60694,7 +62649,7 @@ void varDefTable(int varID, int tableID)
 void varDefEnsembleInfo(int varID, int ens_idx, int ens_count, int forecast_type)
 {
   if ( vartable[varID].ensdata == NULL )
-      vartable[varID].ensdata = (ensinfo_t *)xmalloc( sizeof( ensinfo_t ) );
+      vartable[varID].ensdata = (ensinfo_t *) Malloc( sizeof( ensinfo_t ) );
 
   vartable[varID].ensdata->ens_index = ens_idx;
   vartable[varID].ensdata->ens_count = ens_count;
@@ -60713,27 +62668,99 @@ void varDefProductDefinitionTemplate(int varID, int productDefinitionTemplate)
   vartable[varID].productDefinitionTemplate = productDefinitionTemplate;
 }
 
+#if  defined  (HAVE_LIBGRIB_API)
+/* Resizes and initializes opt_grib_kvpair data structure. */
+static 
+void resize_vartable_opt_grib_entries(vartable_t *var, int nentries)
+{
+  if (var->opt_grib_kvpair_size >= nentries) 
+    {
+      return;   /* nothing to do; array is still large enough */
+    }
+  else
+    {
+      if ( CDI_Debug )
+        Message("resize data structure, %d -> %d", var->opt_grib_kvpair_size, nentries);
+
+      int i, new_size;
+      new_size = (2*var->opt_grib_kvpair_size) > nentries ? (2*var->opt_grib_kvpair_size) : nentries;
+      if (CDI_Debug)
+        Message("resize vartable opt_grib_entries array to size %d", new_size);
+      opt_key_val_pair_t *tmp = (opt_key_val_pair_t *) Malloc((size_t)new_size * sizeof (opt_key_val_pair_t));
+      for (i=0; i<var->opt_grib_kvpair_size; i++) {
+        tmp[i] = var->opt_grib_kvpair[i];
+      }
+      for (i=var->opt_grib_kvpair_size; i<new_size; i++) {
+        tmp[i].int_val =     0;
+        tmp[i].dbl_val =     0;
+        tmp[i].update  = FALSE;
+        tmp[i].keyword =  NULL;
+      } // for
+      var->opt_grib_kvpair_size = new_size;
+      Free(var->opt_grib_kvpair);
+      var->opt_grib_kvpair = tmp;
+    }
+}
+#endif
 
 #if  defined  (HAVE_LIBGRIB_API)
-void varDefOptGribInt(int varID, long lval, const char *keyword)
+void varDefOptGribInt(int varID, int tile_index, long lval, const char *keyword)
 {
-  int idx = vartable[varID].opt_grib_int_nentries;
-  vartable[varID].opt_grib_int_nentries++;
-  if ( idx >= MAX_OPT_GRIB_ENTRIES ) Error("Too many optional keyword/integer value pairs!");
-  vartable[varID].opt_grib_int_val[idx] = (int) lval;
-  vartable[varID].opt_grib_int_keyword[idx] = strdupx(keyword);
+  int idx = -1;
+  for (int i=0; i<vartable[varID].opt_grib_nentries; i++)
+    {
+      if ( (strcmp(keyword, vartable[varID].opt_grib_kvpair[i].keyword) == 0 ) &&
+           (vartable[varID].opt_grib_kvpair[i].data_type == t_int)             &&
+           (vartable[varID].opt_grib_kvpair[i].subtype_index == tile_index) )
+        idx = i;
+    }
+
+  if (idx == -1)
+    {
+      resize_vartable_opt_grib_entries(&vartable[varID], vartable[varID].opt_grib_nentries+1);
+      vartable[varID].opt_grib_nentries += 1;
+      idx = vartable[varID].opt_grib_nentries -1;
+    }
+  else
+    {
+      if (vartable[varID].opt_grib_kvpair[idx].keyword)
+        Free(vartable[varID].opt_grib_kvpair[idx].keyword);
+    }
+  vartable[varID].opt_grib_kvpair[idx].data_type     = t_int;
+  vartable[varID].opt_grib_kvpair[idx].int_val       = (int) lval;
+  vartable[varID].opt_grib_kvpair[idx].keyword       = strdupx(keyword);
+  vartable[varID].opt_grib_kvpair[idx].subtype_index = tile_index;
 }
 #endif
 
 
 #if  defined  (HAVE_LIBGRIB_API)
-void varDefOptGribDbl(int varID, double dval, const char *keyword)
+void varDefOptGribDbl(int varID, int tile_index, double dval, const char *keyword)
 {
-  int idx = vartable[varID].opt_grib_dbl_nentries;
-  vartable[varID].opt_grib_dbl_nentries++;
-  if ( idx >= MAX_OPT_GRIB_ENTRIES ) Error("Too many optional keyword/double value pairs!");
-  vartable[varID].opt_grib_dbl_val[idx] = dval;
-  vartable[varID].opt_grib_dbl_keyword[idx] = strdupx(keyword);
+  int idx = -1;
+  for (int i=0; i<vartable[varID].opt_grib_nentries; i++)
+    {
+      if ( (strcmp(keyword, vartable[varID].opt_grib_kvpair[i].keyword) == 0 ) &&
+           (vartable[varID].opt_grib_kvpair[i].data_type == t_double)          &&
+           (vartable[varID].opt_grib_kvpair[i].subtype_index == tile_index) )
+        idx = i;
+    }
+
+  if (idx == -1) 
+    {
+      resize_vartable_opt_grib_entries(&vartable[varID], vartable[varID].opt_grib_nentries+1);
+      vartable[varID].opt_grib_nentries += 1;
+      idx = vartable[varID].opt_grib_nentries -1;
+    }
+  else
+    {
+      if (vartable[varID].opt_grib_kvpair[idx].keyword)
+        Free(vartable[varID].opt_grib_kvpair[idx].keyword);
+    }
+  vartable[varID].opt_grib_kvpair[idx].data_type     = t_double;
+  vartable[varID].opt_grib_kvpair[idx].dbl_val       = dval;
+  vartable[varID].opt_grib_kvpair[idx].keyword       = strdupx(keyword);
+  vartable[varID].opt_grib_kvpair[idx].subtype_index = tile_index;
 }
 #endif
 
@@ -60742,7 +62769,7 @@ void varDefOptGribDbl(int varID, double dval, const char *keyword)
 int varOptGribNentries(int varID)
 {
   int nentries = 0;
-  nentries = vartable[varID].opt_grib_int_nentries + vartable[varID].opt_grib_dbl_nentries;
+  nentries = vartable[varID].opt_grib_nentries;
   return (nentries);
 }
 #endif
@@ -60910,12 +62937,15 @@ void vlist_init_entry(vlist_t *vlistptr)
   vlistptr->ntsteps        = CDI_UNDEFID;
   vlistptr->atts.nalloc    = MAX_ATTRIBUTES;
   vlistptr->atts.nelems    = 0;
+  vlistptr->nsubtypes      = 0;
+  for (int i=0; i<MAX_SUBTYPES_PS; i++)
+    vlistptr->subtypeIDs[i] = CDI_UNDEFID;
 }
 
 static
 vlist_t *vlist_new_entry(cdiResH resH)
 {
-  vlist_t *vlistptr = (vlist_t*) xmalloc(sizeof(vlist_t));
+  vlist_t *vlistptr = (vlist_t*) Malloc(sizeof(vlist_t));
   vlist_init_entry(vlistptr);
   if (resH == CDI_UNDEFID)
     vlistptr->self = reshPut(vlistptr, &vlistOps);
@@ -60936,7 +62966,7 @@ void vlist_delete_entry(vlist_t *vlistptr)
 
   reshRemove(idx, &vlistOps );
 
-  free(vlistptr);
+  Free(vlistptr);
 
   if ( VLIST_Debug )
     Message("Removed idx %d from vlist list", idx);
@@ -60969,7 +62999,7 @@ void vlist_lock(int vlistID)
 
   if ( !vlistptr->locked )
     {
-      vlistptr->locked = 1;
+      vlistptr->locked += 1;
       reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
     }
 }
@@ -60981,7 +63011,7 @@ void vlist_unlock(int vlistID)
 
   if ( vlistptr->locked )
     {
-      vlistptr->locked = 0;
+      vlistptr->locked -= 1;
       reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
     }
 }
@@ -61017,6 +63047,7 @@ int vlistCreate(void)
   VLIST_INIT();
 
   vlist_t *vlistptr = vlist_new_entry(CDI_UNDEFID);
+  if ( CDI_Debug ) Message("create vlistID = %d", vlistptr->self);
   return (vlistptr->self);
 }
 
@@ -61024,6 +63055,7 @@ static void
 vlist_delete(vlist_t *vlistptr)
 {
   int vlistID = vlistptr->self;
+  if ( CDI_Debug ) Message("call to vlist_delete, vlistID = %d", vlistID);
 
   vlistDelAtts(vlistID, CDI_GLOBAL);
 
@@ -61032,30 +63064,29 @@ vlist_delete(vlist_t *vlistptr)
 
   for ( int varID = 0; varID < nvars; varID++ )
     {
-      if ( vars[varID].levinfo )  free(vars[varID].levinfo);
-      if ( vars[varID].name )     free(vars[varID].name);
-      if ( vars[varID].longname ) free(vars[varID].longname);
-      if ( vars[varID].stdname )  free(vars[varID].stdname);
-      if ( vars[varID].units )    free(vars[varID].units);
-      if ( vars[varID].ensdata )  free(vars[varID].ensdata);
+      if ( vars[varID].levinfo )  Free(vars[varID].levinfo);
+      if ( vars[varID].name )     Free(vars[varID].name);
+      if ( vars[varID].longname ) Free(vars[varID].longname);
+      if ( vars[varID].stdname )  Free(vars[varID].stdname);
+      if ( vars[varID].units )    Free(vars[varID].units);
+      if ( vars[varID].ensdata )  Free(vars[varID].ensdata);
 
-#if  defined  (HAVE_LIBGRIB_API)
-      for ( int i=0; i<vars[varID].opt_grib_int_nentries; i++ )
-        {
-          if ( vars[varID].opt_grib_int_keyword[i] )
-            free(vars[varID].opt_grib_int_keyword[i]);
-        }
-      for ( int i=0; i<vars[varID].opt_grib_dbl_nentries; i++ )
+      if ( vlistptr->vars[varID].opt_grib_kvpair )
         {
-          if ( vars[varID].opt_grib_dbl_keyword[i] )
-            free(vars[varID].opt_grib_dbl_keyword[i]);
+          for (int i=0; i<vlistptr->vars[varID].opt_grib_nentries; i++) {
+            if ( vlistptr->vars[varID].opt_grib_kvpair[i].keyword )
+              Free(vlistptr->vars[varID].opt_grib_kvpair[i].keyword);
+          }
+          Free(vlistptr->vars[varID].opt_grib_kvpair);
         }
-#endif
+      vlistptr->vars[varID].opt_grib_nentries    = 0;
+      vlistptr->vars[varID].opt_grib_kvpair_size = 0;
+      vlistptr->vars[varID].opt_grib_kvpair      = NULL;
 
       vlistDelAtts(vlistID, varID);
     }
 
-  if ( vars ) free(vars);
+  if ( vars ) Free(vars);
 
   vlist_delete_entry(vlistptr);
 }
@@ -61075,7 +63106,7 @@ void vlistDestroy(int vlistID)
 {
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
 
-  if ( vlistptr->locked )
+  if ( vlistptr->locked != 0 )
     Warning("Destroying of a locked object (vlistID=%d) failed!", vlistID);
   else
     vlist_delete(vlistptr);
@@ -61090,34 +63121,32 @@ void var_copy_entries(var_t *var2, var_t *var1)
   if ( var1->units )    var2->units    = strdupx(var1->units);
   if ( var1->ensdata )
     {
-      var2->ensdata = (ensinfo_t *)xmalloc(sizeof(ensinfo_t));
+      var2->ensdata = (ensinfo_t *) Malloc(sizeof(ensinfo_t));
       memcpy(var2->ensdata, var1->ensdata, sizeof(ensinfo_t));
     }
-#if  defined  (HAVE_LIBGRIB_API)
-  /* ---------------------------------- */
-  /* Local change: 2013-01-28, FP (DWD) */
-  /* ---------------------------------- */
-  var2->opt_grib_int_nentries = var1->opt_grib_int_nentries;
-  for ( int i = 0; i < var1->opt_grib_int_nentries; i++ )
-    {
-      if ( var1->opt_grib_int_keyword[i] )
-        {
-          var2->opt_grib_int_keyword[i] = strdupx(var1->opt_grib_int_keyword[i]);
-          var2->opt_grib_int_val[i]     = var1->opt_grib_int_val[i];
-          var2->opt_grib_int_update[i]  = TRUE;
-        }
+
+  var2->opt_grib_kvpair_size = 0;
+  var2->opt_grib_kvpair      = NULL;
+  var2->opt_grib_nentries    = 0;
+
+  resize_opt_grib_entries(var2, var1->opt_grib_nentries);
+  var2->opt_grib_nentries = var1->opt_grib_nentries;
+  if ((var2->opt_grib_nentries > 0) && CDI_Debug )
+    Message("copy %d optional GRIB keywords", var2->opt_grib_nentries);
+
+  for (int i=0; i<var1->opt_grib_nentries; i++) {
+    if ( CDI_Debug )  Message("copy entry \"%s\" ...", var1->opt_grib_kvpair[i].keyword);
+    var2->opt_grib_kvpair[i].keyword = NULL;
+    if ( var1->opt_grib_kvpair[i].keyword != NULL ) {
+      var2->opt_grib_kvpair[i]         = var1->opt_grib_kvpair[i];
+      var2->opt_grib_kvpair[i].keyword = strdupx(var1->opt_grib_kvpair[i].keyword);
+      var2->opt_grib_kvpair[i].update  = TRUE;
+      if ( CDI_Debug )  Message("done.");
     }
-  var2->opt_grib_dbl_nentries = var1->opt_grib_dbl_nentries;
-  for ( int i = 0; i < var1->opt_grib_dbl_nentries; i++ )
-    {
-      if ( var1->opt_grib_dbl_keyword[i] )
-        {
-          var2->opt_grib_dbl_keyword[i] = strdupx(var1->opt_grib_dbl_keyword[i]);
-          var2->opt_grib_dbl_val[i]     = var1->opt_grib_dbl_val[i];
-          var2->opt_grib_dbl_update[i]  = TRUE;
-        }
+    else {
+      if ( CDI_Debug )  Message("not done.");
     }
-#endif
+  }
 }
 
 /*
@@ -61138,6 +63167,7 @@ void vlistCopy(int vlistID2, int vlistID1)
 {
   vlist_t *vlistptr1 = vlist_to_pointer(vlistID1);
   vlist_t *vlistptr2 = vlist_to_pointer(vlistID2);
+  if ( CDI_Debug ) Message("call to vlistCopy, vlistIDs %d -> %d", vlistID1, vlistID2);
 
   var_t *vars1 = vlistptr1->vars;
   var_t *vars2 = vlistptr2->vars;
@@ -61151,7 +63181,7 @@ void vlistCopy(int vlistID2, int vlistID1)
       //vlistptr2->varsAllocated = nvars;
 
       size_t n = (size_t)vlistptr2->varsAllocated;
-      vars2 = xrealloc(vars2, n*sizeof(var_t));
+      vars2 = (var_t *) Realloc(vars2, n*sizeof(var_t));
       memcpy(vars2, vars1, n*sizeof(var_t));
       vlistptr2->vars = vars2;
 
@@ -61159,13 +63189,13 @@ void vlistCopy(int vlistID2, int vlistID1)
         {
           var_copy_entries(&vars2[varID], &vars1[varID]);
 
-	  vars2[varID].atts.nelems = 0;
+          vlistptr2->vars[varID].atts.nelems = 0;
 	  vlistCopyVarAtts(vlistID1, varID, vlistID2, varID);
 
           if ( vars1[varID].levinfo )
             {
               n = (size_t)zaxisInqSize(vars1[varID].zaxisID);
-              vars2[varID].levinfo = xmalloc(n*sizeof(levinfo_t));
+              vars2[varID].levinfo = (levinfo_t *) Malloc(n*sizeof(levinfo_t));
               memcpy(vars2[varID].levinfo, vars1[varID].levinfo, n*sizeof(levinfo_t));
             }
 	}
@@ -61190,6 +63220,8 @@ The function @func{vlistDuplicate} duplicates the variable list from vlistID1.
 */
 int vlistDuplicate(int vlistID)
 {
+  if ( CDI_Debug ) Message("call to vlistDuplicate");
+
   int vlistIDnew = vlistCreate();
   vlistCopy(vlistIDnew, vlistID);
   return (vlistIDnew);
@@ -61213,6 +63245,33 @@ void vlistClearFlag(int vlistID)
     }
 }
 
+
+struct vgzSearchState
+{
+  int resIDValue;
+  int zaxistype;
+  int nlevels;
+  int lbounds;
+  const double *levels;
+};
+
+static enum cdiApplyRet
+vgzZAxisSearch(int id, void *res, void *data)
+{
+  struct vgzSearchState *state = (struct vgzSearchState *)data;
+  (void)res;
+  if (zaxisCompare(id, state->zaxistype, state->nlevels, state->lbounds,
+                   state->levels, NULL, NULL, 0)
+      == 0)
+    {
+      state->resIDValue = id;
+      return CDI_APPLY_STOP;
+    }
+  else
+    return CDI_APPLY_GO_ON;
+}
+
+
 static
 int vlist_generate_zaxis(int vlistID, int zaxistype, int nlevels, const double *levels,
                          const double *lbounds, const double *ubounds, int vctsize, const double *vct)
@@ -61239,24 +63298,16 @@ int vlist_generate_zaxis(int vlistID, int zaxistype, int nlevels, const double *
 
   if ( ! zaxisdefined )
     {
-      unsigned nzaxis = cdiZaxisCount();
-      if ( nzaxis > 0 )
-        {
-          int *zaxisIndexList = (int *)xmalloc((size_t)nzaxis * sizeof (int));
-          reshLock();
-          cdiZaxisGetIndexList(nzaxis, zaxisIndexList);
-          for (unsigned index = 0; index < nzaxis; ++index)
-            {
-              zaxisID = zaxisIndexList[index];
-              if ( zaxisCompare(zaxisID, zaxistype, nlevels, has_bounds, levels, NULL, NULL, 0) == 0 )
-                {
-                  zaxisglobdefined = 1;
-                  break;
-                }
-            }
-          reshUnlock();
-          free(zaxisIndexList);
-        }
+      struct vgzSearchState query;
+      query.zaxistype = zaxistype;
+      query.nlevels = nlevels;
+      query.levels = levels;
+      query.lbounds = has_bounds;
+
+      if ((zaxisglobdefined
+           = (cdiResHFilterApply(getZaxisOps(), vgzZAxisSearch, &query)
+              == CDI_APPLY_STOP)))
+        zaxisID = query.resIDValue;
     }
 
   if ( ! zaxisdefined )
@@ -61328,7 +63379,7 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
       vlistptr2->nvars = nvars2;
       vlistptr2->varsAllocated = nvars2;
       if ( nvars2 > 0 )
-        vars2 = (var_t *)xmalloc((size_t)nvars2*sizeof(var_t));
+        vars2 = (var_t *) Malloc((size_t)nvars2*sizeof(var_t));
       else
         vars2 = NULL;
 
@@ -61338,9 +63389,10 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
       for ( int varID = 0; varID < nvars; varID++ )
 	if ( vars1[varID].flag )
 	  {
-	    vars2[varID2].flag = FALSE;
-	    int zaxisID = vars1[varID].zaxisID;
-	    int gridID  = vars1[varID].gridID;
+	    vlistptr2->vars[varID2].flag = FALSE;
+	    int zaxisID   = vlistptr1->vars[varID].zaxisID;
+	    int gridID    = vlistptr1->vars[varID].gridID;
+	    int subtypeID = vlistptr1->vars[varID].subtypeID;
 
 	    memcpy(&vars2[varID2], &vars1[varID], sizeof(var_t));
 
@@ -61351,7 +63403,7 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
 
             var_copy_entries(&vars2[varID2], &vars1[varID]);
 
-	    vars2[varID2].atts.nelems = 0;
+	    vlistptr2->vars[varID2].atts.nelems = 0;
 	    vlistCopyVarAtts(vlistID1, varID, vlistID2, varID2);
 
 	    int nlevs  = zaxisInqSize(vars1[varID].zaxisID);
@@ -61360,7 +63412,7 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
               for ( int levID = 0; levID < nlevs; levID++ )
                 nlevs2 += (vars1[varID].levinfo[levID].flag != 0);
 
-	    vars2[varID2].levinfo = (levinfo_t *)xmalloc((size_t)nlevs2 * sizeof(levinfo_t));
+	    vars2[varID2].levinfo = (levinfo_t *) Malloc((size_t)nlevs2 * sizeof(levinfo_t));
 
 	    if ( nlevs != nlevs2 )
 	      {
@@ -61370,17 +63422,21 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
                 char ctemp[CDI_MAX_NAME];
 
 		zaxisID = vars1[varID].zaxisID;
-		double *levels = (double *)xmalloc((size_t)nlevs2 * sizeof (double));
-                int levID2 = 0;
+		double *levels = (double *) Malloc((size_t)nlevs2 * sizeof (double));
                 if ( !vars1[varID].levinfo )
                   cdiVlistCreateVarLevInfo(vlistptr1, varID);
-                for ( int levID = 0; levID < nlevs; ++levID )
-                  if ( vars1[varID].levinfo[levID].flag )
-                    {
-                      vars1[varID].levinfo[levID].flevelID = levID2;
-                      vars1[varID].levinfo[levID].mlevelID = levID2;
-                      levels[levID2++] = zaxisInqLevel(zaxisID, levID);
-                    }
+
+                {
+                  int levID2 = 0;
+                  for ( int levID = 0; levID < nlevs; ++levID )
+                    if ( vars1[varID].levinfo[levID].flag )
+                      {
+                        vars1[varID].levinfo[levID].flevelID = levID2;
+                        vars1[varID].levinfo[levID].mlevelID = levID2;
+                        levels[levID2++] = zaxisInqLevel(zaxisID, levID);
+                      }
+                }
+
 		int zaxisType = zaxisInqType(zaxisID);
 
 		if ( zaxisType == ZAXIS_HYBRID )
@@ -61391,10 +63447,10 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
 
                 if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
                   {
-                    lbounds = (double *)xmalloc(2 * (size_t)nlevs2 * sizeof (double));
+                    lbounds = (double *) Malloc(2 * (size_t)nlevs2 * sizeof (double));
                     ubounds = lbounds + nlevs2;
 
-                    double *lbounds1 = (double *)xmalloc(2 * (size_t)nlevs * sizeof (double)),
+                    double *lbounds1 = (double *) Malloc(2 * (size_t)nlevs * sizeof (double)),
                       *ubounds1 = lbounds1 + nlevs;
 
                     zaxisInqLbounds(zaxisID, lbounds1);
@@ -61409,12 +63465,12 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
                           levID2++;
                         }
 
-                    free(lbounds1);
+                    Free(lbounds1);
                   }
 
 		int zaxisID2 = vlist_generate_zaxis(vlistID2, zaxisType, nlevs2, levels, lbounds, ubounds, nvct, vct);
 		free(levels);
-                free(lbounds);
+                Free(lbounds);
 
                 zaxisInqName(zaxisID, ctemp);
                 zaxisDefName(zaxisID2, ctemp);
@@ -61444,6 +63500,7 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
 
             vlistAdd2GridIDs(vlistptr2, gridID);
             vlistAdd2ZaxisIDs(vlistptr2, zaxisID);
+            vlistAdd2SubtypeIDs(vlistptr2, subtypeID);
 
 	    varID2++;
 	  }
@@ -61478,7 +63535,7 @@ void vlistCat(int vlistID2, int vlistID1)
   if ( nvars > vlistptr2->varsAllocated )
     {
       vlistptr2->varsAllocated = nvars;
-      vars2 = xrealloc(vars2, (size_t)nvars*sizeof(var_t));
+      vars2 = (var_t *) Realloc(vars2, (size_t)nvars*sizeof(var_t));
       vlistptr2->vars = vars2;
     }
   memcpy(vars2+nvars2, vars1, (size_t)nvars1 * sizeof(var_t));
@@ -61505,7 +63562,7 @@ void vlistCat(int vlistID2, int vlistID1)
       int nlevs = zaxisInqSize(vars1[varID].zaxisID);
       if ( vars1[varID].levinfo )
         {
-          vars2[varID2].levinfo = (levinfo_t *)xmalloc((size_t)nlevs * sizeof(levinfo_t));
+          vars2[varID2].levinfo = (levinfo_t *) Malloc((size_t)nlevs * sizeof(levinfo_t));
           memcpy(vars2[varID2].levinfo, vars1[varID].levinfo,
                  (size_t)nlevs * sizeof(levinfo_t));
         }
@@ -61515,6 +63572,7 @@ void vlistCat(int vlistID2, int vlistID1)
 
       vlistAdd2GridIDs(vlistptr2, vars1[varID].gridID);
       vlistAdd2ZaxisIDs(vlistptr2, vars1[varID].zaxisID);
+      vlistAdd2SubtypeIDs(vlistptr2, vars1[varID].subtypeID);
     }
 }
 
@@ -61581,7 +63639,7 @@ void vlistMerge(int vlistID2, int vlistID1)
           */
           if ( vars1[varID].levinfo )
             {
-              vars2[varID].levinfo = (levinfo_t*)xrealloc(vars2[varID].levinfo,
+              vars2[varID].levinfo = (levinfo_t*) Realloc(vars2[varID].levinfo,
                                      (size_t)nlevs * sizeof(levinfo_t));
 
               memcpy(vars2[varID].levinfo+nlevs2, vars1[varID].levinfo,
@@ -61594,7 +63652,7 @@ void vlistMerge(int vlistID2, int vlistID1)
             vars1[varID].levinfo[levID].mlevelID = nlevs2 + levID;
 	}
 
-      int *lvar = (int *)xcalloc((size_t)nvars2, sizeof(int));
+      int *lvar = (int *) Calloc((size_t)nvars2, sizeof(int));
 
       for ( varID = 0; varID < nvars2; varID++ )
         {
@@ -61617,7 +63675,7 @@ void vlistMerge(int vlistID2, int vlistID1)
 
           zaxisResize(zaxisID, nlevs);
 
-          double *levels = (double *)xmalloc((size_t)nlevs1 * sizeof(double));
+          double *levels = (double *) Malloc((size_t)nlevs1 * sizeof(double));
 
           zaxisInqLevels(zaxisID1, levels);
           /*
@@ -61627,7 +63685,7 @@ void vlistMerge(int vlistID2, int vlistID1)
           for ( int levID = 0; levID < nlevs1; levID++ )
             zaxisDefLevel(zaxisID, nlevs2+levID, levels[levID]);
 
-          free(levels);
+          Free(levels);
 
           for ( int index = 0; index < vlistptr2->nzaxis; index++ )
             if ( vlistptr2->zaxisIDs[index] == zaxisID2 )
@@ -61641,7 +63699,7 @@ void vlistMerge(int vlistID2, int vlistID1)
               }
         }
 
-      free(lvar);
+      Free(lvar);
     }
   else
     {
@@ -61760,6 +63818,14 @@ int vlistNzaxis(int vlistID)
 }
 
 
+int vlistNsubtypes(int vlistID)
+{
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+
+  return (vlistptr->nsubtypes);
+}
+
+
 void vlistDefNtsteps(int vlistID, int nts)
 {
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
@@ -61779,8 +63845,8 @@ int vlistNtsteps(int vlistID)
   return (int)vlistptr->ntsteps;
 }
 
-static void
-vlistPrintKernel(vlist_t *vlistptr, FILE * fp )
+static
+void vlistPrintKernel(vlist_t *vlistptr, FILE *fp)
 {
   char paramstr[32];
 
@@ -61788,25 +63854,27 @@ vlistPrintKernel(vlist_t *vlistptr, FILE * fp )
 
   int nvars = vlistptr->nvars;
 
-  fprintf(fp, "nvars   %d\n"
-          "ngrids  %d\n"
-          "nzaxis  %d\n"
-          "taxisID %d\n"
-          "instID  %d\n"
-          "modelID %d\n"
-          "tableID %d\n",
-          nvars, vlistptr->ngrids, vlistptr->nzaxis, vlistptr->taxisID,
+  fprintf(fp, "nvars    : %d\n"
+          "ngrids   : %d\n"
+          "nzaxis   : %d\n"
+          "nsubtypes: %d\n"
+          "taxisID  : %d\n"
+          "instID   : %d\n"
+          "modelID  : %d\n"
+          "tableID  : %d\n",
+          nvars, vlistptr->ngrids, vlistptr->nzaxis, vlistptr->nsubtypes, vlistptr->taxisID,
           vlistptr->instID, vlistptr->modelID, vlistptr->tableID);
 
   if ( nvars > 0 )
     {
-      fprintf(fp, " varID param    gridID zaxisID tsteptype flag "
-              " name     longname iorank\n");
+      fprintf(fp, " varID param    gridID zaxisID stypeID tsteptype flag iorank"
+              " name     longname         units\n");
       for ( int varID = 0; varID < nvars; varID++ )
         {
           int param = vlistptr->vars[varID].param;
           int gridID = vlistptr->vars[varID].gridID;
           int zaxisID = vlistptr->vars[varID].zaxisID;
+          int subtypeID = vlistptr->vars[varID].subtypeID;
 	  int tsteptype = vlistptr->vars[varID].tsteptype;
           const char *name = vlistptr->vars[varID].name;
           const char *longname = vlistptr->vars[varID].longname;
@@ -61815,14 +63883,9 @@ vlistPrintKernel(vlist_t *vlistptr, FILE * fp )
           int iorank = vlistptr->vars[varID].iorank;
 
           cdiParamToString(param, paramstr, sizeof(paramstr));
-          fprintf(fp, "%6d %-8s %6d %6d %6d %5d %-8s"
-                  " %s %6d",
-                  varID, paramstr, gridID, zaxisID, tsteptype, flag,
-                  name ? name : "", longname ? longname : "",
-                  iorank);
-
-          if ( units ) fprintf(fp, "   [%s]", units);
-          fputs("\n", fp);
+          fprintf(fp, "%6d %-8s %6d  %6d  %6d  %6d  %5d %6d %-8s %s [%s]\n",
+                  varID, paramstr, gridID, zaxisID, subtypeID, tsteptype, flag, iorank,
+                  name?name:"", longname?longname:"", units?units:"");
         }
 
       fputs("\n"
@@ -62107,6 +64170,7 @@ int vlistZaxis(int vlistID, int index)
   return (zaxisID);
 }
 
+
 int vlistZaxisIndex(int vlistID, int zaxisID)
 {
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
@@ -62139,7 +64203,7 @@ void vlistChangeZaxisIndex(int vlistID, int index, int zaxisID)
             vlistptr->vars[varID].zaxisID = zaxisID;
             if ( vlistptr->vars[varID].levinfo && nlevs != nlevsOld )
               {
-                vlistptr->vars[varID].levinfo = (levinfo_t *)xrealloc(vlistptr->vars[varID].levinfo, (size_t)nlevs * sizeof (levinfo_t));
+                vlistptr->vars[varID].levinfo = (levinfo_t *) Realloc(vlistptr->vars[varID].levinfo, (size_t)nlevs * sizeof (levinfo_t));
 
                 for ( int levID = 0; levID < nlevs; levID++ )
                   vlistptr->vars[varID].levinfo[levID] = DEFAULT_LEVINFO(levID);
@@ -62174,7 +64238,7 @@ void vlistChangeZaxis(int vlistID, int zaxisID1, int zaxisID2)
         if ( vlistptr->vars[varID].levinfo && nlevs2 != nlevs1 )
           {
             vlistptr->vars[varID].levinfo
-              = (levinfo_t *)xrealloc(vlistptr->vars[varID].levinfo,
+              = (levinfo_t *) Realloc(vlistptr->vars[varID].levinfo,
                                       (size_t)nlevs2 * sizeof(levinfo_t));
 
             for ( int levID = 0; levID < nlevs2; levID++ )
@@ -62185,6 +64249,32 @@ void vlistChangeZaxis(int vlistID, int zaxisID1, int zaxisID2)
 }
 
 
+int vlistSubtype(int vlistID, int index)
+{
+  int subtypeID = CDI_UNDEFID;
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+
+  if ( index < vlistptr->nsubtypes && index >= 0 )
+    subtypeID = vlistptr->subtypeIDs[index];
+
+  return subtypeID;
+}
+
+
+int vlistSubtypeIndex(int vlistID, int subtypeID)
+{
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+
+  int index;
+  for ( index = 0 ; index < vlistptr->nsubtypes ; index++ )
+    if ( subtypeID == vlistptr->subtypeIDs[index] ) break;
+
+  if ( index == vlistptr->nsubtypes ) index = -1;
+
+  return (index);
+}
+
+
 int vlistHasTime(int vlistID)
 {
   int hastime = FALSE;
@@ -62243,7 +64333,7 @@ void vlistPackP ( void * vlistptr, void * buf, int size, int *position,
   vlistAttsPack(p, CDI_GLOBAL, buf, size, position, context);
   for ( varID = 0; varID < p->nvars; varID++ )
     {
-      vlistVarPack(p, varID, buf, size, position, context);
+      vlistVarPack(p, varID, (char *)buf, size, position, context);
     }
 }
 
@@ -62266,6 +64356,8 @@ void vlistUnpack(char * buf, int size, int *position, int originNamespace,
   vlistAttsUnpack(targetID, CDI_GLOBAL, buf, size, position, context);
   for (int varID = 0; varID < nvars; varID++ )
     vlistVarUnpack(targetID, buf, size, position, originNamespace, context);
+  reshSetStatus(targetID, &vlistOps,
+                reshGetStatus(targetID, &vlistOps) & ~RESH_SYNC_BIT);
 }
 
 
@@ -62282,6 +64374,40 @@ void vlist_check_contents(int vlistID)
 	cdiCheckZaxis(zaxisID);
     }
 }
+
+
+/* Resizes and initializes opt_grib_kvpair data structure. */
+void resize_opt_grib_entries(var_t *var, int nentries)
+{
+  if (var->opt_grib_kvpair_size >= nentries) 
+    {
+      if ( CDI_Debug )
+        Message("data structure has size %d, no resize to %d needed.", var->opt_grib_kvpair_size, nentries);
+      return;   /* nothing to do; array is still large enough */
+    }
+  else
+    {
+      if ( CDI_Debug )
+        Message("resize data structure, %d -> %d", var->opt_grib_kvpair_size, nentries);
+
+      int i, new_size;
+      new_size = (2*var->opt_grib_kvpair_size) > nentries ? (2*var->opt_grib_kvpair_size) : nentries;
+      opt_key_val_pair_t *tmp = (opt_key_val_pair_t *) Malloc((size_t)new_size * sizeof (opt_key_val_pair_t));
+      for (i=0; i<var->opt_grib_kvpair_size; i++) {
+        tmp[i] = var->opt_grib_kvpair[i];
+      }
+      for (i=var->opt_grib_kvpair_size; i<new_size; i++) {
+        tmp[i].int_val =     0;
+        tmp[i].dbl_val =     0;
+        tmp[i].update  = FALSE;
+        tmp[i].keyword =  NULL;
+      } // for
+      var->opt_grib_kvpair_size = new_size;
+      Free(var->opt_grib_kvpair);
+      var->opt_grib_kvpair = tmp;
+    }
+}
+
 /*
  * Local Variables:
  * c-file-style: "Java"
@@ -62357,7 +64483,7 @@ cdi_att_t *new_att(cdi_atts_t *attsp, const char *name)
   slen = strlen(name);
   if ( slen > CDI_MAX_NAME ) slen = CDI_MAX_NAME;
 
-  attp->name = (char *) malloc(slen+1);
+  attp->name = (char *) Malloc(slen+1);
   memcpy(attp->name, name, slen+1);
   attp->namesz = slen;
   attp->xvalue = NULL;
@@ -62377,7 +64503,7 @@ void fill_att(cdi_att_t *attp, int indtype, int exdtype, size_t nelems, size_t x
 
   if ( xsz > 0 )
     {
-      attp->xvalue = xrealloc(attp->xvalue, xsz);
+      attp->xvalue = Realloc(attp->xvalue, xsz);
       memcpy(attp->xvalue, xvalue, xsz);
     }
 }
@@ -62482,8 +64608,8 @@ int vlistDelAtts(int vlistID, int varID)
   for ( attid = 0; attid < (int)attsp->nelems; attid++ )
     {
       attp = &(attsp->value[attid]);
-      if ( attp->name   ) free(attp->name);
-      if ( attp->xvalue ) free(attp->xvalue);
+      if ( attp->name   ) Free(attp->name);
+      if ( attp->xvalue ) Free(attp->xvalue);
     }
 
   attsp->nelems = 0;
@@ -62855,7 +64981,7 @@ vlistAttUnpack(int vlistID, int varID,
 
   serializeUnpack(buf, size, position,
                   tempbuf, vlist_att_nints, DATATYPE_INT, context);
-  char *attName = (char *)xmalloc((size_t)tempbuf[0] + 1);
+  char *attName = (char *) Malloc((size_t)tempbuf[0] + 1);
   serializeUnpack(buf, size, position, attName, tempbuf[0], DATATYPE_TXT, context);
   attName[tempbuf[0]] = '\0';
   int attVDt;
@@ -62878,12 +65004,12 @@ vlistAttUnpack(int vlistID, int varID,
     xabort("Unknown datatype encountered in attribute %s: %d\n",
            attName, tempbuf[2]);
   }
-  void *attData = (void *)xmalloc(elemSize * (size_t)tempbuf[3]);
+  void *attData = (void *) Malloc(elemSize * (size_t)tempbuf[3]);
   serializeUnpack(buf, size, position, attData, tempbuf[3], attVDt, context);
   vlist_def_att(tempbuf[2], tempbuf[1], vlistID, varID, attName,
                 (size_t)tempbuf[3], (size_t)tempbuf[3] * elemSize, attData);
-  free(attName);
-  free(attData);
+  Free(attName);
+  Free(attData);
 }
 
 void
@@ -62938,6 +65064,7 @@ void vlistvarInitEntry(int vlistID, int varID)
   vlistptr->vars[varID].xyz           = 321;
   vlistptr->vars[varID].gridID        = CDI_UNDEFID;
   vlistptr->vars[varID].zaxisID       = CDI_UNDEFID;
+  vlistptr->vars[varID].subtypeID     = CDI_UNDEFID;
   vlistptr->vars[varID].instID        = CDI_UNDEFID;
   vlistptr->vars[varID].modelID       = CDI_UNDEFID;
   vlistptr->vars[varID].tableID       = CDI_UNDEFID;
@@ -62960,25 +65087,12 @@ void vlistvarInitEntry(int vlistID, int varID)
   vlistptr->vars[varID].validrange[1] = VALIDMISS;
   vlistptr->vars[varID].ensdata       = NULL;
   vlistptr->vars[varID].iorank        = CDI_UNDEFID;
+  vlistptr->vars[varID].opt_grib_kvpair_size = 0;
+  vlistptr->vars[varID].opt_grib_kvpair      = NULL;
+  vlistptr->vars[varID].opt_grib_nentries    = 0;
+}
 
-#if  defined  (HAVE_LIBGRIB_API)
-  /* ---------------------------------- */
-  /* Local change: 2013-01-28, FP (DWD) */
-  /* ---------------------------------- */
 
-  vlistptr->vars[varID].opt_grib_dbl_nentries = 0;
-  vlistptr->vars[varID].opt_grib_int_nentries = 0;
-  int i;
-  for (i=0; i<MAX_OPT_GRIB_ENTRIES; i++) {
-    vlistptr->vars[varID].opt_grib_int_val[i] =   0;
-    vlistptr->vars[varID].opt_grib_dbl_val[i] = 0.0;
-    vlistptr->vars[varID].opt_grib_int_update[i] = FALSE;
-    vlistptr->vars[varID].opt_grib_dbl_update[i] = FALSE;
-    vlistptr->vars[varID].opt_grib_int_keyword[i] = NULL;
-    vlistptr->vars[varID].opt_grib_dbl_keyword[i] = NULL;
-  } // for
-#endif
-}
 
 static
 int vlistvarNewEntry(int vlistID)
@@ -62997,7 +65111,7 @@ int vlistvarNewEntry(int vlistID)
   if ( ! vlistvarSize )
     {
       vlistvarSize = 2;
-      vlistvar = (var_t *)xmalloc((size_t)vlistvarSize * sizeof (var_t));
+      vlistvar = (var_t *) Malloc((size_t)vlistvarSize * sizeof (var_t));
       for (int i = 0; i < vlistvarSize; i++ )
 	vlistvar[i].isUsed = FALSE;
     }
@@ -63011,14 +65125,9 @@ int vlistvarNewEntry(int vlistID)
   */
   if ( varID == vlistvarSize )
     {
-      int i;
-
-      vlistvarSize = 2*vlistvarSize;
-      vlistvar = (var_t *)xrealloc(vlistvar,
-                                   (size_t)vlistvarSize * sizeof(var_t));
-      varID = vlistvarSize/2;
-
-      for ( i = varID; i < vlistvarSize; i++ )
+      vlistvar = (var_t *) Realloc(vlistvar,
+                                   (size_t)(vlistvarSize *= 2) * sizeof(var_t));
+      for ( int i = varID; i < vlistvarSize; i++ )
 	vlistvar[i].isUsed = FALSE;
     }
 
@@ -63046,6 +65155,36 @@ void vlistCheckVarID(const char *caller, int vlistID, int varID)
     Errorc("varID %d undefined!", varID);
 }
 
+
+int vlistDefVarTiles(int vlistID, int gridID, int zaxisID, int tsteptype, int tilesetID)
+{
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+  if ( CDI_Debug )
+    Message("gridID = %d  zaxisID = %d  tsteptype = %d", gridID, zaxisID, tsteptype);
+
+  int varID = vlistvarNewEntry(vlistID);
+
+  vlistptr->nvars++;
+  vlistptr->vars[varID].gridID    = gridID;
+  vlistptr->vars[varID].zaxisID   = zaxisID;
+  vlistptr->vars[varID].tsteptype = tsteptype;
+  vlistptr->vars[varID].subtypeID = tilesetID;
+
+  if ( tsteptype < 0 )
+    {
+      Message("Unexpected tstep type %d, set to TSTEP_INSTANT!", tsteptype);
+      vlistptr->vars[varID].tsteptype = TSTEP_INSTANT;
+    }
+
+  vlistAdd2GridIDs(vlistptr, gridID);
+  vlistAdd2ZaxisIDs(vlistptr, zaxisID);
+  vlistAdd2SubtypeIDs(vlistptr, tilesetID);
+
+  vlistptr->vars[varID].param = cdiEncodeParam(-(varID + 1), 255, 255);
+  reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
+  return (varID);
+}
+
 /*
 @Function  vlistDefVar
 @Title     Define a Variable
@@ -63084,30 +65223,8 @@ vlistDestroy(vlistID);
 */
 int vlistDefVar(int vlistID, int gridID, int zaxisID, int tsteptype)
 {
-  vlist_t *vlistptr = vlist_to_pointer(vlistID);
-  if ( CDI_Debug )
-    Message("gridID = %d  zaxisID = %d  tsteptype = %d", gridID, zaxisID, tsteptype);
-
-  int varID = vlistvarNewEntry(vlistID);
-
-  vlistptr->nvars++;
-
-  vlistptr->vars[varID].gridID  = gridID;
-  vlistptr->vars[varID].zaxisID = zaxisID;
-  vlistptr->vars[varID].tsteptype = tsteptype;
-
-  if ( tsteptype < 0 )
-    {
-      Message("Unexpected tstep type %d, set to TSTEP_INSTANT!", tsteptype);
-      vlistptr->vars[varID].tsteptype = TSTEP_INSTANT;
-    }
-
-  vlistAdd2GridIDs(vlistptr, gridID);
-  vlistAdd2ZaxisIDs(vlistptr, zaxisID);
-
-  vlistptr->vars[varID].param = cdiEncodeParam(-(varID + 1), 255, 255);
-  reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
-  return (varID);
+  /* call "vlistDefVarTiles" with a trivial tile index: */
+  return vlistDefVarTiles(vlistID, gridID, zaxisID, tsteptype, CDI_UNDEFID);
 }
 
 void
@@ -63119,7 +65236,7 @@ cdiVlistCreateVarLevInfo(vlist_t *vlistptr, int varID)
   size_t nlevs = (size_t)zaxisInqSize(zaxisID);
 
   vlistptr->vars[varID].levinfo
-    = (levinfo_t*)xmalloc((size_t)nlevs * sizeof(levinfo_t));
+    = (levinfo_t*) Malloc((size_t)nlevs * sizeof(levinfo_t));
 
   for (size_t levID = 0; levID < nlevs; levID++ )
     vlistptr->vars[varID].levinfo[levID] = DEFAULT_LEVINFO((int)levID);
@@ -63251,6 +65368,28 @@ int vlistInqVarZaxis(int vlistID, int varID)
   return (vlistptr->vars[varID].zaxisID);
 }
 
+
+/*
+ at Function  vlistInqVarSubtype
+ at Title     Get the Subtype ID of a Variable
+
+ at Description
+The function @func{vlistInqVarSubtype} returns the subtype ID of a variable.
+
+ at Result
+ at func{vlistInqVarSubtype} returns the subtype ID of the variable.
+
+ at EndFunction
+*/
+int vlistInqVarSubtype(int vlistID, int varID)
+{
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+
+  vlistCheckVarID(__func__, vlistID, varID);
+  return (vlistptr->vars[varID].subtypeID);
+}
+
+
 /*
 @Function  vlistInqVarParam
 @Title     Get the parameter number of a Variable
@@ -63303,7 +65442,8 @@ int vlistInqVarCode(int vlistID, int varID)
   int param = vlistptr->vars[varID].param;
   int pdis, pcat, pnum;
   cdiDecodeParam(param, &pnum, &pcat, &pdis);
-  int code = pdis == 255 ? pnum : -varID-1;
+  int code = pnum;
+  if ( pdis != 255 ) code = -varID-1; // GRIB2 Parameter
 
   if ( code < 0 && vlistptr->vars[varID].tableID != -1 && vlistptr->vars[varID].name != NULL )
     {
@@ -63412,11 +65552,11 @@ void vlistInqVarName(int vlistID, int varID, char *name)
     @Item  vlistID  Variable list ID, from a previous call to @fref{vlistCreate} or @fref{streamInqVlist}.
     @Item  varID    Variable identifier.
 
- at Return A pointer to a malloc'ed string. Must be cleaned up with free().
+ at Return A pointer to a malloc'ed string. Must be cleaned up with Free().
 
 @Description
 This is the buffer overflow immune version of vlistInqVarName().
-The memory for the returned string is allocated to fit the string via malloc().
+The memory for the returned string is allocated to fit the string via Malloc().
 
 @EndFunction
 */
@@ -63427,23 +65567,31 @@ char* vlistCopyVarName(int vlistId, int varId)
 
   //If a name is set in the variable description, use that.
   const char* name = vlistptr->vars[varId].name;
-  if(name) return myStrDup(name);
+  if(name) return strdup(name);
 
   //Otherwise we check if we should use the table of parameter descriptions.
   int param = vlistptr->vars[varId].param;
   int discipline, category, number;
   cdiDecodeParam(param, &number, &category, &discipline);
+  char *result = NULL;
   if(discipline == 255)
     {
       int tableId = vlistptr->vars[varId].tableID;
-      if(( name = tableInqParNamePtr(tableId, number) )) return myStrDup(name);
-
-      //No luck, fall back to outputting a name of the format "var<num>".
-      return myAsprintf("var%d", number);
+      if(( name = tableInqParNamePtr(tableId, number) ))
+        result = strdup(name);
+      {
+        //No luck, fall back to outputting a name of the format "var<num>".
+        result = (char *) Malloc(3 + 3 * sizeof (int) * CHAR_BIT / 8 + 2);
+        sprintf(result, "var%d", number);
+      }
+    }
+  else
+    {
+      result = (char *) Malloc(5 + 2 + 3 * (3 * sizeof (int) * CHAR_BIT + 1) + 1);
+      sprintf(result, "param%d.%d.%d", number, category, discipline);
     }
-
   //Finally, we fall back to outputting a name of the format "param<num>.<cat>.<dis>".
-  return myAsprintf("param%d.%d.%d", number, category, discipline);
+  return result;
 }
 
 /*
@@ -63786,7 +65934,7 @@ void vlistDefVarName(int vlistID, int varID, const char *name)
     {
       if ( vlistptr->vars[varID].name )
 	{
-	  free(vlistptr->vars[varID].name);
+	  Free(vlistptr->vars[varID].name);
 	  vlistptr->vars[varID].name = NULL;
 	}
 
@@ -63820,7 +65968,7 @@ void vlistDefVarLongname(int vlistID, int varID, const char *longname)
     {
       if ( vlistptr->vars[varID].longname )
 	{
-	  free(vlistptr->vars[varID].longname);
+	  Free(vlistptr->vars[varID].longname);
 	  vlistptr->vars[varID].longname = 0;
 	}
 
@@ -63854,7 +66002,7 @@ void vlistDefVarStdname(int vlistID, int varID, const char *stdname)
     {
       if ( vlistptr->vars[varID].stdname )
 	{
-	  free(vlistptr->vars[varID].stdname);
+	  Free(vlistptr->vars[varID].stdname);
 	  vlistptr->vars[varID].stdname = 0;
 	}
 
@@ -63888,7 +66036,7 @@ void vlistDefVarUnits(int vlistID, int varID, const char *units)
     {
       if ( vlistptr->vars[varID].units )
 	{
-	  free(vlistptr->vars[varID].units);
+	  Free(vlistptr->vars[varID].units);
 	  vlistptr->vars[varID].units = 0;
 	}
 
@@ -63973,7 +66121,7 @@ void vlistDefVarExtra(int vlistID, int varID, const char *extra)
     {
       if ( vlistptr->vars[varID].extra )
 	{
-	  free(vlistptr->vars[varID].extra);
+	  Free(vlistptr->vars[varID].extra);
 	  vlistptr->vars[varID].extra = NULL;
 	}
 
@@ -64192,7 +66340,7 @@ void vlistDestroyVarName(int vlistID, int varID)
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
   if ( vlistptr->vars[varID].name )
     {
-      free(vlistptr->vars[varID].name);
+      Free(vlistptr->vars[varID].name);
       vlistptr->vars[varID].name = NULL;
       reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
     }
@@ -64205,7 +66353,7 @@ void vlistDestroyVarLongname(int vlistID, int varID)
 
   if ( vlistptr->vars[varID].longname )
     {
-      free(vlistptr->vars[varID].longname);
+      Free(vlistptr->vars[varID].longname);
       vlistptr->vars[varID].longname = NULL;
       reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
     }
@@ -64218,7 +66366,7 @@ void vlistDestroyVarStdname(int vlistID, int varID)
 
   if ( vlistptr->vars[varID].stdname )
     {
-      free(vlistptr->vars[varID].stdname);
+      Free(vlistptr->vars[varID].stdname);
       vlistptr->vars[varID].stdname = NULL;
       reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
     }
@@ -64231,7 +66379,7 @@ void vlistDestroyVarUnits(int vlistID, int varID)
 
   if ( vlistptr->vars[varID].units )
     {
-      free(vlistptr->vars[varID].units);
+      Free(vlistptr->vars[varID].units);
       vlistptr->vars[varID].units = NULL;
       reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
     }
@@ -64604,7 +66752,7 @@ void vlistDefVarEnsemble(int vlistID, int varID, int ensID, int ensCount, int fo
 
   if ( vlistptr->vars[varID].ensdata == NULL )
     vlistptr->vars[varID].ensdata
-      = (ensinfo_t *)xmalloc( sizeof( ensinfo_t ) );
+      = (ensinfo_t *) Malloc( sizeof( ensinfo_t ) );
 
   vlistptr->vars[varID].ensdata->ens_index          = ensID;
   vlistptr->vars[varID].ensdata->ens_count          = ensCount;
@@ -64632,42 +66780,61 @@ int vlistInqVarEnsemble( int vlistID, int varID, int *ensID, int *ensCount, int
   return (status);
 }
 
-/* ---------------------------------- */
-/* Local change: 2013-01-28, FP (DWD) */
-/* ---------------------------------- */
+
 
 /* vlistDefVarIntKey: Set an arbitrary keyword/integer value pair for GRIB API */
 void vlistDefVarIntKey(int vlistID, int varID, const char *name, int value)
 {
 #if  defined  (HAVE_LIBGRIB_API)
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
+  if (vlistptr == NULL)  Error("Internal error!");
   int idx;
 
-  if ( !vlistptr->locked )
+  if ( vlistptr->locked != 0 )
     Error("User defined vlist object (vlistID=%d) isn't allowed!\n"
           "Need a CDI internal vlist object from streamInqVlist(streamID).", vlistID);
 
-  for ( idx=0; idx<vlistptr->vars[varID].opt_grib_int_nentries; idx++)
-    if ( strcmp(name, vlistptr->vars[varID].opt_grib_int_keyword[idx]) == 0 ) break;
+  for ( idx=0; idx<vlistptr->vars[varID].opt_grib_nentries; idx++)
+    if ( (strcmp(name, vlistptr->vars[varID].opt_grib_kvpair[idx].keyword) == 0 ) &&
+         (vlistptr->vars[varID].opt_grib_kvpair[idx].data_type == t_int) )  break;
 
-  if ( idx < vlistptr->vars[varID].opt_grib_int_nentries )
+  if ( idx < vlistptr->vars[varID].opt_grib_nentries )
     {
-      vlistptr->vars[varID].opt_grib_int_val[idx] = value;
-      vlistptr->vars[varID].opt_grib_int_update[idx] = TRUE;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].int_val = value;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].update  = TRUE;
     }
   else
     {
-      idx = vlistptr->vars[varID].opt_grib_int_nentries;
-      vlistptr->vars[varID].opt_grib_int_nentries++;
-      if ( idx >= MAX_OPT_GRIB_ENTRIES ) Error("Too many optional keyword/integer value pairs!");
-      vlistptr->vars[varID].opt_grib_int_val[idx] = value;
-      vlistptr->vars[varID].opt_grib_int_update[idx] = TRUE;
+      resize_opt_grib_entries(&vlistptr->vars[varID], vlistptr->vars[varID].opt_grib_nentries+1);
+      vlistptr->vars[varID].opt_grib_nentries += 1;
+      idx = vlistptr->vars[varID].opt_grib_nentries -1;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].data_type   = t_int;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].int_val     = value;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].update      = TRUE;
       if ( name )
-        vlistptr->vars[varID].opt_grib_int_keyword[idx] = strdupx(name);
+        vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = strdupx(name);
       else
         Error("Internal error, name undefined!");
     }
 
+  if ( CDI_Debug )
+    {
+      Message("define additional GRIB2 key \"%s\" (integer): %d", name, value);
+      Message("total list of registered, additional GRIB2 keys (total: %d):",
+              vlistptr->vars[varID].opt_grib_nentries);
+      for ( idx=0; idx<vlistptr->vars[varID].opt_grib_nentries; idx++)
+        if (vlistptr->vars[varID].opt_grib_kvpair[idx].data_type == t_int)
+          Message("%s -> integer %d",
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].keyword,
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].int_val);
+        else if (vlistptr->vars[varID].opt_grib_kvpair[idx].data_type == t_double)
+          Message("%s -> double %d",
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].keyword,
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].dbl_val);
+        else
+          Message("%s -> unknown", vlistptr->vars[varID].opt_grib_kvpair[idx].keyword);
+    }
+
   reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
 #else
   (void)vlistID;
@@ -64682,33 +66849,54 @@ void vlistDefVarDblKey(int vlistID, int varID, const char *name, double value)
 {
 #if  defined  (HAVE_LIBGRIB_API)
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
+  if (vlistptr == NULL)  Error("Internal error!");
   int idx;
 
-  if ( !vlistptr->locked )
+  if ( vlistptr->locked != 0 )
     Error("User defined vlist object (vlistID=%d) isn't allowed!\n"
           "Need a CDI internal vlist object from streamInqVlist(streamID).", vlistID);
 
-  for ( idx=0; idx<vlistptr->vars[varID].opt_grib_dbl_nentries; idx++)
-    if ( strcmp(name, vlistptr->vars[varID].opt_grib_dbl_keyword[idx]) == 0 ) break;
+  for ( idx=0; idx<vlistptr->vars[varID].opt_grib_nentries; idx++)
+    if ( (strcmp(name, vlistptr->vars[varID].opt_grib_kvpair[idx].keyword) == 0 ) &&
+         (vlistptr->vars[varID].opt_grib_kvpair[idx].data_type == t_double) )  break;
 
-  if ( idx < vlistptr->vars[varID].opt_grib_dbl_nentries )
+  if ( idx < vlistptr->vars[varID].opt_grib_nentries )
     {
-      vlistptr->vars[varID].opt_grib_dbl_val[idx] = value;
-      vlistptr->vars[varID].opt_grib_dbl_update[idx] = TRUE;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].dbl_val = value;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].update  = TRUE;
     }
   else
     {
-      idx = vlistptr->vars[varID].opt_grib_dbl_nentries;
-      vlistptr->vars[varID].opt_grib_dbl_nentries++;
-      if ( idx >= MAX_OPT_GRIB_ENTRIES ) Error("Too many optional keyword/double value pairs!");
-      vlistptr->vars[varID].opt_grib_dbl_val[idx] = value;
-      vlistptr->vars[varID].opt_grib_dbl_update[idx] = TRUE;
+      resize_opt_grib_entries(&vlistptr->vars[varID], vlistptr->vars[varID].opt_grib_nentries+1);
+      vlistptr->vars[varID].opt_grib_nentries += 1;
+      idx = vlistptr->vars[varID].opt_grib_nentries - 1;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].data_type = t_double;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].dbl_val   = value;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].update    = TRUE;
       if ( name )
-        vlistptr->vars[varID].opt_grib_dbl_keyword[idx] = strdupx(name);
+        vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = strdupx(name);
       else
         Error("Internal error, name undefined!");
     }
 
+  if ( CDI_Debug )
+    {
+      Message("define additional GRIB2 key \"%s\" (double): %d", name, value);
+      Message("total list of registered, additional GRIB2 keys (total: %d):",
+              vlistptr->vars[varID].opt_grib_nentries);
+      for ( idx=0; idx<vlistptr->vars[varID].opt_grib_nentries; idx++)
+        if (vlistptr->vars[varID].opt_grib_kvpair[idx].data_type == t_int)
+          Message("%s -> integer %d",
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].keyword,
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].int_val);
+        else if (vlistptr->vars[varID].opt_grib_kvpair[idx].data_type == t_double)
+          Message("%s -> double %d",
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].keyword,
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].dbl_val);
+        else
+          Message("%s -> unknown", vlistptr->vars[varID].opt_grib_kvpair[idx].keyword);
+    }
+
   reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
 #else
   (void)vlistID;
@@ -64723,7 +66911,7 @@ void vlistDefVarDblKey(int vlistID, int varID, const char *name, double value)
 void cdiClearAdditionalKeys()
 {
 #if  defined  (HAVE_LIBGRIB_API)
-  for (int i=0; i<cdiNAdditionalGRIBKeys; i++)  free(cdiAdditionalGRIBKeys[i]);
+  for (int i=0; i<cdiNAdditionalGRIBKeys; i++)  Free(cdiAdditionalGRIBKeys[i]);
   cdiNAdditionalGRIBKeys = 0;
 #endif
 }
@@ -64751,15 +66939,9 @@ int vlistHasVarKey(int vlistID, int varID, const char* name)
   /* check if the GRIB key was previously read and is stored */
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
 
-  for (int i=0; i<vlistptr->vars[varID].opt_grib_dbl_nentries; i++)
+  for (int i=0; i<vlistptr->vars[varID].opt_grib_nentries; i++)
     {
-      if ( strcmp(name, vlistptr->vars[varID].opt_grib_dbl_keyword[i]) == 0 )
-	return 1;
-    }
-
-  for (int i=0; i<vlistptr->vars[varID].opt_grib_int_nentries; i++)
-    {
-      if ( strcmp(name, vlistptr->vars[varID].opt_grib_int_keyword[i]) == 0 )
+      if ( strcmp(name, vlistptr->vars[varID].opt_grib_kvpair[i].keyword) == 0 )
 	return 1;
     }
 #else
@@ -64778,9 +66960,14 @@ double vlistInqVarDblKey(int vlistID, int varID, const char* name)
   /* check if the GRIB key was previously read and is stored in "opt_grib_dbl_val" */
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
 
-  for (int i=0; i<vlistptr->vars[varID].opt_grib_dbl_nentries; i++)
-    if ( strcmp(name, vlistptr->vars[varID].opt_grib_dbl_keyword[i]) == 0 )
-      return vlistptr->vars[varID].opt_grib_dbl_val[i];
+  for (int i=0; i<vlistptr->vars[varID].opt_grib_nentries; i++)
+    {
+      int isub = subtypeInqActiveIndex(vlistptr->vars[varID].subtypeID);
+      if ( (strcmp(name, vlistptr->vars[varID].opt_grib_kvpair[i].keyword) == 0 ) &&
+           (vlistptr->vars[varID].opt_grib_kvpair[i].data_type == t_double)       &&
+           (vlistptr->vars[varID].opt_grib_kvpair[i].subtype_index == isub) )
+        return vlistptr->vars[varID].opt_grib_kvpair[i].dbl_val;
+    }
 #else
   (void)vlistID;
   (void)varID;
@@ -64798,9 +66985,15 @@ int vlistInqVarIntKey(int vlistID, int varID, const char* name)
   /* check if the GRIB key was previously read and is stored in "opt_grib_int_val" */
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
 
-  for (int i=0; i<vlistptr->vars[varID].opt_grib_int_nentries; i++)
-    if ( strcmp(name, vlistptr->vars[varID].opt_grib_int_keyword[i]) == 0 )
-      return vlistptr->vars[varID].opt_grib_int_val[i];
+  for (int i=0; i<vlistptr->vars[varID].opt_grib_nentries; i++)
+    {
+      int isub = subtypeInqActiveIndex(vlistptr->vars[varID].subtypeID);
+      if ( (strcmp(name, vlistptr->vars[varID].opt_grib_kvpair[i].keyword) == 0 ) &&
+           (vlistptr->vars[varID].opt_grib_kvpair[i].data_type == t_int)          &&
+           (vlistptr->vars[varID].opt_grib_kvpair[i].subtype_index == isub) )
+        return vlistptr->vars[varID].opt_grib_kvpair[i].int_val;
+    }
+
 #else
   (void)vlistID;
   (void)varID;
@@ -64882,7 +67075,7 @@ int vlistVarCompare(vlist_t *a, int varIDA, vlist_t *b, int varIDB)
 
 
 enum {
-  vlistvar_nints = 20,
+  vlistvar_nints = 21,
   vlistvar_ndbls = 3,
 };
 
@@ -64899,6 +67092,8 @@ int vlistVarGetPackSize(vlist_t *p, int varID, void *context)
     varsize += serializeGetSize((int)strlen(var->stdname), DATATYPE_TXT, context);
   if (var->units)
     varsize += serializeGetSize((int)strlen(var->units), DATATYPE_TXT, context);
+  if (var->extra)
+    varsize += serializeGetSize((int)strlen(var->extra), DATATYPE_TXT, context);
   varsize += serializeGetSize(4 * zaxisInqSize(var->zaxisID),
                               DATATYPE_INT, context);
   varsize += vlistAttsGetSize(p, varID, context);
@@ -64910,7 +67105,8 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position,
 {
   double dtempbuf[vlistvar_ndbls];
   var_t *var = p->vars + varID;
-  int tempbuf[vlistvar_nints], namesz, longnamesz, stdnamesz, unitssz;
+  int tempbuf[vlistvar_nints], namesz, longnamesz, stdnamesz, unitssz,
+    extralen;
 
   tempbuf[0] = var->flag;
   tempbuf[1] = var->gridID;
@@ -64933,6 +67129,7 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position,
   int nlevs = var->levinfo ? zaxisInqSize(var->zaxisID) : 0;
   tempbuf[18] = nlevs;
   tempbuf[19] = var->iorank;
+  tempbuf[20] = extralen = var->extra?(int)strlen(var->extra):0;
   dtempbuf[0] = var->missval;
   dtempbuf[1] = var->scalefactor;
   dtempbuf[2] = var->addoffset;
@@ -64951,6 +67148,9 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position,
   if (unitssz)
     serializePack(var->units, unitssz, DATATYPE_TXT,
                   buf, size, position, context);
+  if (extralen)
+    serializePack(var->extra, extralen, DATATYPE_TXT,
+                  buf, size, position, context);
   if (nlevs)
     {
       int levbuf[nlevs][4];
@@ -64986,14 +67186,19 @@ void vlistVarUnpack(int vlistID, char * buf, int size, int *position,
   serializeUnpack(buf, size, position,
                   dtempbuf, vlistvar_ndbls, DATATYPE_FLT64, context);
 
+  /* ------------------------------------------- */
+  /* NOTE: Tile sets  currently not supported!!! */
+  /* ------------------------------------------- */
+
   int newvar = vlistDefVar ( vlistID,
 			 namespaceAdaptKey ( tempbuf[1], originNamespace ),
 			 namespaceAdaptKey ( tempbuf[2], originNamespace ),
 			 tempbuf[3]);
-  if (tempbuf[4] || tempbuf[5] || tempbuf[6] || tempbuf[7])
-    varname = (char *)xmalloc((size_t)imax(imax(imax(tempbuf[4],tempbuf[5]),
-                                                tempbuf[6]),
-                                           tempbuf[7]) + 1);
+  if (tempbuf[4] || tempbuf[5] || tempbuf[6] || tempbuf[7] || tempbuf[20])
+    varname = (char *)Malloc((size_t)imax(imax(imax(imax(tempbuf[4],
+                                                         tempbuf[5]),
+                                                    tempbuf[6]),
+                                               tempbuf[7]), tempbuf[20]) + 1);
   if (tempbuf[4])
   {
     serializeUnpack(buf, size, position,
@@ -65022,7 +67227,14 @@ void vlistVarUnpack(int vlistID, char * buf, int size, int *position,
     varname[tempbuf[7]] = '\0';
     vlistDefVarUnits(vlistID, newvar, varname);
   }
-  free(varname);
+  if (tempbuf[20])
+    {
+      serializeUnpack(buf, size, position,
+                      varname, tempbuf[20], DATATYPE_TXT, context);
+      varname[tempbuf[20]] = '\0';
+      vlistDefVarExtra(vlistID, newvar, varname);
+    }
+  Free(varname);
   vlistDefVarDatatype(vlistID, newvar, tempbuf[8]);
   vlistDefVarInstitut ( vlistID, newvar,
 			namespaceAdaptKey ( tempbuf[10], originNamespace ));
@@ -65089,10 +67301,10 @@ void vlistVarUnpack(int vlistID, char * buf, int size, int *position,
 
 static const struct {
   unsigned char positive;   // 1: up;  2: down
-  char *name;
-  char *longname;
-  char *stdname;
-  char *units;
+  const char *name;
+  const char *longname;
+  const char *stdname;
+  const char *units;
 }
 ZaxistypeEntry[] = {
   { /*  0 */ 0, "sfc",               "surface",                "",               ""},
@@ -65120,7 +67332,7 @@ ZaxistypeEntry[] = {
   { /* 22 */ 0, "sedimentbottomta",  "sediment_bottom_ta",     "",               ""},
   { /* 23 */ 0, "sedimentbottomtw",  "sediment_bottom_tw",     "",               ""},
   { /* 24 */ 0, "mixlayer",          "mix_layer",              "",               ""},
-  { /* 25 */ 0, "height",            "generalized height",     "height",         ""},
+  { /* 25 */ 0, "height",            "generalized_height",     "height",         ""},
 };
 
 enum {
@@ -65134,12 +67346,14 @@ typedef struct {
   char     longname[CDI_MAX_NAME];
   char     stdname[CDI_MAX_NAME];
   char     units[CDI_MAX_NAME];
+  char     psname[CDI_MAX_NAME];
   double  *vals;
   double  *lbounds;
   double  *ubounds;
   double  *weights;
   int      self;
   int      prec;
+  int      scalar;
   int      type;
   int      ltype;    /* GRIB level type */
   int      ltype2;
@@ -65153,14 +67367,14 @@ typedef struct {
 }
 zaxis_t;
 
-static int zaxisCompareP(zaxis_t *z1, zaxis_t *z2);
+static int    zaxisCompareP    (zaxis_t *z1, zaxis_t *z2);
 static void   zaxisDestroyP    ( void * zaxisptr );
 static void   zaxisPrintP      ( void * zaxisptr, FILE * fp );
 static int    zaxisGetPackSize ( void * zaxisptr, void *context);
 static void   zaxisPack        ( void * zaxisptr, void * buffer, int size, int *pos, void *context);
 static int    zaxisTxCode      ( void );
 
-const resOps zaxisOps = {
+static const resOps zaxisOps = {
   (int (*)(void *, void *))zaxisCompareP,
   zaxisDestroyP,
   zaxisPrintP,
@@ -65169,6 +67383,11 @@ const resOps zaxisOps = {
   zaxisTxCode
 };
 
+const resOps *getZaxisOps(void)
+{
+  return &zaxisOps;
+}
+
 static int  ZAXIS_Debug = 0;   /* If set to 1, debugging */
 
 void zaxisGetTypeDescription(int zaxisType, int* outPositive, const char** outName, const char** outLongName, const char** outStdName, const char** outUnit)
@@ -65199,6 +67418,7 @@ void zaxisDefaultValue(zaxis_t *zaxisptr)
   zaxisptr->longname[0] = 0;
   zaxisptr->stdname[0]  = 0;
   zaxisptr->units[0]    = 0;
+  zaxisptr->psname[0]   = 0;
   zaxisptr->vals        = NULL;
   zaxisptr->ubounds     = NULL;
   zaxisptr->lbounds     = NULL;
@@ -65207,6 +67427,7 @@ void zaxisDefaultValue(zaxis_t *zaxisptr)
   zaxisptr->ltype       = 0;
   zaxisptr->ltype2      = -1;
   zaxisptr->positive    = 0;
+  zaxisptr->scalar      = 0;
   zaxisptr->direction   = 0;
   zaxisptr->prec        = 0;
   zaxisptr->size        = 0;
@@ -65221,7 +67442,7 @@ void zaxisDefaultValue(zaxis_t *zaxisptr)
 static
 zaxis_t *zaxisNewEntry(int id)
 {
-  zaxis_t *zaxisptr = (zaxis_t *)xmalloc(sizeof(zaxis_t));
+  zaxis_t *zaxisptr = (zaxis_t *) Malloc(sizeof(zaxis_t));
 
   zaxisDefaultValue ( zaxisptr );
 
@@ -65236,6 +67457,13 @@ zaxis_t *zaxisNewEntry(int id)
   return (zaxisptr);
 }
 
+static inline zaxis_t *
+zaxisID2Ptr(int id)
+{
+  return (zaxis_t *)reshGetVal(id, &zaxisOps);
+}
+
+
 static
 void zaxisInit(void)
 {
@@ -65263,6 +67491,7 @@ unsigned cdiZaxisCount(void)
   return reshCountType(&zaxisOps);
 }
 
+
 static int
 zaxisCreate_(int zaxistype, int size, int id)
 {
@@ -65286,7 +67515,7 @@ zaxisCreate_(int zaxistype, int size, int id)
   zaxisptr->positive = ZaxistypeEntry[zaxistype].positive;
 
   double *vals = zaxisptr->vals
-    = (double *)xmalloc((size_t)size * sizeof(double));
+    = (double *) Malloc((size_t)size * sizeof(double));
 
   for ( int ilev = 0; ilev < size; ilev++ )
     vals[ilev] = 0.0;
@@ -65346,19 +67575,17 @@ int zaxisCreate(int zaxistype, int size)
 
 static void zaxisDestroyKernel( zaxis_t * zaxisptr )
 {
-  int id;
-
   xassert ( zaxisptr );
 
-  id = zaxisptr->self;
+  int id = zaxisptr->self;
 
-  if ( zaxisptr->vals )    free ( zaxisptr->vals );
-  if ( zaxisptr->lbounds ) free ( zaxisptr->lbounds );
-  if ( zaxisptr->ubounds ) free ( zaxisptr->ubounds );
-  if ( zaxisptr->weights ) free ( zaxisptr->weights );
-  if ( zaxisptr->vct )     free ( zaxisptr->vct );
+  if ( zaxisptr->vals )    Free( zaxisptr->vals );
+  if ( zaxisptr->lbounds ) Free( zaxisptr->lbounds );
+  if ( zaxisptr->ubounds ) Free( zaxisptr->ubounds );
+  if ( zaxisptr->weights ) Free( zaxisptr->weights );
+  if ( zaxisptr->vct )     Free( zaxisptr->vct );
 
-  free ( zaxisptr );
+  Free( zaxisptr );
 
   reshRemove ( id, &zaxisOps );
 }
@@ -65375,7 +67602,7 @@ static void zaxisDestroyKernel( zaxis_t * zaxisptr )
 */
 void zaxisDestroy(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   zaxisDestroyKernel ( zaxisptr );
 }
@@ -65388,15 +67615,11 @@ void zaxisDestroyP ( void * zaxisptr )
 }
 
 
-char *zaxisNamePtr(int zaxistype)
+const char *zaxisNamePtr(int zaxistype)
 {
-  char *name;
-
-  if ( zaxistype >= 0 && zaxistype < CDI_NumZaxistype )
-    name = ZaxistypeEntry[zaxistype].longname;
-  else
-    name = ZaxistypeEntry[ZAXIS_GENERIC].longname;
-
+  const char *name = (zaxistype >= 0 && zaxistype < CDI_NumZaxistype)
+    ? ZaxistypeEntry[zaxistype].longname
+    : ZaxistypeEntry[ZAXIS_GENERIC].longname;
   return (name);
 }
 
@@ -65422,7 +67645,7 @@ The function @func{zaxisDefName} defines the name of a Z-axis.
 */
 void zaxisDefName(int zaxisID, const char *name)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( name )
     {
@@ -65448,7 +67671,7 @@ The function @func{zaxisDefLongname} defines the longname of a Z-axis.
 */
 void zaxisDefLongname(int zaxisID, const char *longname)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( longname )
     {
@@ -65474,7 +67697,7 @@ The function @func{zaxisDefUnits} defines the units of a Z-axis.
 */
 void zaxisDefUnits(int zaxisID, const char *units)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( units )
     {
@@ -65484,6 +67707,19 @@ void zaxisDefUnits(int zaxisID, const char *units)
     }
 }
 
+
+void zaxisDefPsName(int zaxisID, const char *psname)
+{
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+
+  if ( psname )
+    {
+      strncpy(zaxisptr->psname, psname, CDI_MAX_NAME - 1);
+      zaxisptr->name[CDI_MAX_NAME - 1] = '\0';
+      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
+    }
+}
+
 /*
 @Function  zaxisInqName
 @Title     Get the name of a Z-axis
@@ -65505,7 +67741,7 @@ The function @func{zaxisInqName} returns the name of a Z-axis.
 */
 void zaxisInqName(int zaxisID, char *name)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   strcpy(name, zaxisptr->name);
 }
 
@@ -65530,7 +67766,7 @@ The function @func{zaxisInqLongname} returns the longname of a Z-axis.
 */
 void zaxisInqLongname(int zaxisID, char *longname)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   strcpy(longname, zaxisptr->longname);
 }
 
@@ -65555,21 +67791,28 @@ The function @func{zaxisInqUnits} returns the units of a Z-axis.
 */
 void zaxisInqUnits(int zaxisID, char *units)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   strcpy(units, zaxisptr->units);
 }
 
 
 void zaxisInqStdname(int zaxisID, char *stdname)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   strcpy(stdname, zaxisptr->stdname);
 }
 
 
+void zaxisInqPsName(int zaxisID, char *psname)
+{
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  strcpy(psname, zaxisptr->psname);
+}
+
+
 void zaxisDefPrec(int zaxisID, int prec)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if (zaxisptr->prec != prec)
     {
@@ -65581,15 +67824,14 @@ void zaxisDefPrec(int zaxisID, int prec)
 
 int zaxisInqPrec(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   return (zaxisptr->prec);
 }
 
 
 void zaxisDefPositive(int zaxisID, int positive)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if (zaxisptr->positive != positive)
     {
@@ -65601,15 +67843,29 @@ void zaxisDefPositive(int zaxisID, int positive)
 
 int zaxisInqPositive(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  return zaxisptr->positive;
+}
+
+
+void zaxisDefScalar(int zaxisID)
+{
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+
+  zaxisptr->scalar = 1;
+  reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
+}
 
-  return (zaxisptr->positive);
+int zaxisInqScalar(int zaxisID)
+{
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  return zaxisptr->scalar;
 }
 
 
 void zaxisDefLtype(int zaxisID, int ltype)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if (zaxisptr->ltype != ltype)
     {
@@ -65621,15 +67877,14 @@ void zaxisDefLtype(int zaxisID, int ltype)
 
 int zaxisInqLtype(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
-  return (zaxisptr->ltype);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  return zaxisptr->ltype;
 }
 
 
 void zaxisDefLtype2(int zaxisID, int ltype2)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if (zaxisptr->ltype2 != ltype2)
     {
@@ -65641,9 +67896,8 @@ void zaxisDefLtype2(int zaxisID, int ltype2)
 
 int zaxisInqLtype2(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
-  return (zaxisptr->ltype2);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  return zaxisptr->ltype2;
 }
 
 /*
@@ -65662,7 +67916,7 @@ The function @func{zaxisDefLevels} defines the levels of a Z-axis.
 */
 void zaxisDefLevels(int zaxisID, const double *levels)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   int size = zaxisptr->size;
 
@@ -65690,8 +67944,7 @@ The function @func{zaxisDefLevel} defines one level of a Z-axis.
 */
 void zaxisDefLevel(int zaxisID, int levelID, double level)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   if ( levelID >= 0 && levelID < zaxisptr->size )
     zaxisptr->vals[levelID] = level;
   reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
@@ -65700,8 +67953,7 @@ void zaxisDefLevel(int zaxisID, int levelID, double level)
 
 void zaxisDefNlevRef(int zaxisID, const int nhlev)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   if (zaxisptr->nhlev != nhlev)
     {
       zaxisptr->nhlev = nhlev;
@@ -65712,9 +67964,8 @@ void zaxisDefNlevRef(int zaxisID, const int nhlev)
 
 int zaxisInqNlevRef(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
-  return (zaxisptr->nhlev);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  return zaxisptr->nhlev;
 }
 
 /*
@@ -65733,8 +67984,7 @@ The function @func{zaxisDefNumber} defines the reference number for a generalize
 */
 void zaxisDefNumber(int zaxisID, const int number)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   if (zaxisptr->number != number)
     {
       zaxisptr->number = number;
@@ -65759,9 +68009,8 @@ The function @func{zaxisInqNumber} returns the reference number to a generalized
 */
 int zaxisInqNumber(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
-  return (zaxisptr->number);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  return zaxisptr->number;
 }
 
 /*
@@ -65780,8 +68029,7 @@ The function @func{zaxisDefUUID} defines the UUID for a generalized  Z-axis.
 */
 void zaxisDefUUID(int zaxisID, const unsigned char uuid[CDI_UUID_SIZE])
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   memcpy(zaxisptr->uuid, uuid, CDI_UUID_SIZE);
   reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
 }
@@ -65804,7 +68052,7 @@ The function @func{zaxisInqUUID} returns the UUID to a generalized Z-axis.
 */
 void zaxisInqUUID(int zaxisID, unsigned char uuid[CDI_UUID_SIZE])
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   memcpy(uuid, zaxisptr->uuid, CDI_UUID_SIZE);
 }
 
@@ -65827,44 +68075,41 @@ The function @func{zaxisInqLevel} returns one level of a Z-axis.
 double zaxisInqLevel(int zaxisID, int levelID)
 {
   double level = 0;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( levelID >= 0 && levelID < zaxisptr->size )
     level = zaxisptr->vals[levelID];
 
-  return (level);
+  return level;
 }
 
 double zaxisInqLbound(int zaxisID, int index)
 {
   double level = 0;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
-  if ( zaxisptr->lbounds )
-    if ( index >= 0 && index < zaxisptr->size )
+  if ( zaxisptr->lbounds && ( index >= 0 && index < zaxisptr->size ) )
       level = zaxisptr->lbounds[index];
 
-  return (level);
+  return level;
 }
 
 
 double zaxisInqUbound(int zaxisID, int index)
 {
   double level = 0;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
-  if ( zaxisptr->ubounds )
-    if ( index >= 0 && index < zaxisptr->size )
-      level = zaxisptr->ubounds[index];
-
-  return (level);
+  if ( zaxisptr->ubounds && ( index >= 0 && index < zaxisptr->size ) )
+    level = zaxisptr->ubounds[index];
+  return level;
 }
 
 
 const double *zaxisInqLevelsPtr(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-  return ( zaxisptr->vals );
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  return zaxisptr->vals;
 }
 
 /*
@@ -65886,7 +68131,7 @@ The function @func{zaxisInqLevels} returns all levels of a Z-axis.
 */
 void zaxisInqLevels(int zaxisID, double *levels)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   int size = zaxisptr->size;
   for (int i = 0; i < size; i++ )
     levels[i] =  zaxisptr->vals[i];
@@ -65896,7 +68141,7 @@ void zaxisInqLevels(int zaxisID, double *levels)
 int zaxisInqLbounds(int zaxisID, double *lbounds)
 {
   int size = 0;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( zaxisptr->lbounds )
     {
@@ -65914,7 +68159,7 @@ int zaxisInqLbounds(int zaxisID, double *lbounds)
 int zaxisInqUbounds(int zaxisID, double *ubounds)
 {
   int size = 0;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( zaxisptr->ubounds )
     {
@@ -65932,7 +68177,7 @@ int zaxisInqUbounds(int zaxisID, double *ubounds)
 int zaxisInqWeights(int zaxisID, double *weights)
 {
   int size = 0;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( zaxisptr->weights )
     {
@@ -65950,7 +68195,7 @@ int zaxisInqWeights(int zaxisID, double *weights)
 int zaxisInqLevelID(int zaxisID, double level)
 {
   int levelID = CDI_UNDEFID;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   int size = zaxisptr->size;
   for ( int i = 0; i < size; i++ )
@@ -65960,7 +68205,7 @@ int zaxisInqLevelID(int zaxisID, double level)
         break;
       }
 
-  return (levelID);
+  return levelID;
 }
 
 /*
@@ -65990,7 +68235,7 @@ The valid CDI Z-axis types are @func{ZAXIS_GENERIC}, @func{ZAXIS_SURFACE},
 */
 int zaxisInqType(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   return (zaxisptr->type);
 }
 
@@ -66012,14 +68257,14 @@ The function @func{zaxisInqSize} returns the size of a Z-axis.
 */
 int zaxisInqSize(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   return (zaxisptr->size);
 }
 
 
 void cdiCheckZaxis(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( zaxisInqType(zaxisID) == ZAXIS_GENERIC )
     {
@@ -66055,45 +68300,43 @@ void cdiCheckZaxis(int zaxisID)
 
 void zaxisDefVct(int zaxisID, int size, const double *vct)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
-  if ( zaxisptr->vct == 0 )
+  if ( zaxisptr->vct == 0 || zaxisptr->vctsize != size )
     {
       zaxisptr->vctsize = size;
-      zaxisptr->vct = (double *)xmalloc((size_t)size * sizeof (double));
-      memcpy(zaxisptr->vct, vct, (size_t)size * sizeof (double));
-      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
+      zaxisptr->vct = (double *) Realloc(zaxisptr->vct, (size_t)size*sizeof(double));
     }
-  else
-    if ( zaxisptr->vctsize != size )
-      Warning("VCT was already defined");
+
+  memcpy(zaxisptr->vct, vct, (size_t)size*sizeof(double));
+  reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
 }
 
 
 void zaxisInqVct(int zaxisID, double *vct)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   memcpy(vct, zaxisptr->vct, (size_t)zaxisptr->vctsize * sizeof (double));
 }
 
 
 int zaxisInqVctSize(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   return (zaxisptr->vctsize);
 }
 
 
 const double *zaxisInqVctPtr(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   return (zaxisptr->vct);
 }
 
 
 void zaxisDefLbounds(int zaxisID, const double *lbounds)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   size_t size = (size_t)zaxisptr->size;
 
@@ -66102,7 +68345,7 @@ void zaxisDefLbounds(int zaxisID, const double *lbounds)
       Warning("Lower bounds already defined for zaxisID = %d", zaxisID);
 
   if ( zaxisptr->lbounds == NULL )
-    zaxisptr->lbounds = (double *)xmalloc(size*sizeof(double));
+    zaxisptr->lbounds = (double *) Malloc(size*sizeof(double));
 
   memcpy(zaxisptr->lbounds, lbounds, size*sizeof(double));
   reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
@@ -66111,7 +68354,7 @@ void zaxisDefLbounds(int zaxisID, const double *lbounds)
 
 void zaxisDefUbounds(int zaxisID, const double *ubounds)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   size_t size = (size_t)zaxisptr->size;
 
@@ -66120,7 +68363,7 @@ void zaxisDefUbounds(int zaxisID, const double *ubounds)
       Warning("Upper bounds already defined for zaxisID = %d", zaxisID);
 
   if ( zaxisptr->ubounds == NULL )
-    zaxisptr->ubounds = (double *)xmalloc(size*sizeof(double));
+    zaxisptr->ubounds = (double *) Malloc(size*sizeof(double));
 
   memcpy(zaxisptr->ubounds, ubounds, size*sizeof(double));
   reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
@@ -66129,7 +68372,7 @@ void zaxisDefUbounds(int zaxisID, const double *ubounds)
 
 void zaxisDefWeights(int zaxisID, const double *weights)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   size_t size = (size_t)zaxisptr->size;
 
@@ -66138,7 +68381,7 @@ void zaxisDefWeights(int zaxisID, const double *weights)
       Warning("Weights already defined for zaxisID = %d", zaxisID);
 
   if ( zaxisptr->weights == NULL )
-    zaxisptr->weights = (double *)xmalloc(size*sizeof(double));
+    zaxisptr->weights = (double *) Malloc(size*sizeof(double));
 
   memcpy(zaxisptr->weights, weights, size*sizeof(double));
   reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
@@ -66147,34 +68390,34 @@ void zaxisDefWeights(int zaxisID, const double *weights)
 
 void zaxisChangeType(int zaxisID, int zaxistype)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   zaxisptr->type = zaxistype;
 }
 
 
 void zaxisResize(int zaxisID, int size)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   xassert(size >= 0);
 
   zaxisptr->size = size;
 
   if ( zaxisptr->vals )
-    zaxisptr->vals = (double *)xrealloc(zaxisptr->vals, (size_t)size * sizeof(double));
+    zaxisptr->vals = (double *) Realloc(zaxisptr->vals, (size_t)size * sizeof(double));
 }
 
 
 int zaxisDuplicate(int zaxisID)
 {
   int zaxisIDnew;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   int zaxistype = zaxisInqType(zaxisID);
   int zaxissize = zaxisInqSize(zaxisID);
 
   zaxisIDnew = zaxisCreate(zaxistype, zaxissize);
-  zaxis_t *zaxisptrnew = reshGetVal(zaxisIDnew, &zaxisOps);
+  zaxis_t *zaxisptrnew = zaxisID2Ptr(zaxisIDnew);
 
   zaxis_copy(zaxisptrnew, zaxisptr);
 
@@ -66186,7 +68429,7 @@ int zaxisDuplicate(int zaxisID)
     {
       size_t size = (size_t)zaxissize;
 
-      zaxisptrnew->vals = (double *)xmalloc(size * sizeof (double));
+      zaxisptrnew->vals = (double *) Malloc(size * sizeof (double));
       memcpy(zaxisptrnew->vals, zaxisptr->vals, size * sizeof (double));
     }
 
@@ -66194,7 +68437,7 @@ int zaxisDuplicate(int zaxisID)
     {
       size_t size = (size_t)zaxissize;
 
-      zaxisptrnew->lbounds = (double *)xmalloc(size * sizeof (double));
+      zaxisptrnew->lbounds = (double *) Malloc(size * sizeof (double));
       memcpy(zaxisptrnew->lbounds, zaxisptr->lbounds, size * sizeof(double));
     }
 
@@ -66202,7 +68445,7 @@ int zaxisDuplicate(int zaxisID)
     {
       size_t size = (size_t)zaxissize;
 
-      zaxisptrnew->ubounds = (double *)xmalloc(size * sizeof (double));
+      zaxisptrnew->ubounds = (double *) Malloc(size * sizeof (double));
       memcpy(zaxisptrnew->ubounds, zaxisptr->ubounds, size * sizeof (double));
     }
 
@@ -66213,7 +68456,7 @@ int zaxisDuplicate(int zaxisID)
       if ( size )
         {
           zaxisptrnew->vctsize = (int)size;
-          zaxisptrnew->vct = (double *)xmalloc(size * sizeof (double));
+          zaxisptrnew->vct = (double *) Malloc(size * sizeof (double));
           memcpy(zaxisptrnew->vct, zaxisptr->vct, size * sizeof (double));
         }
     }
@@ -66222,7 +68465,7 @@ int zaxisDuplicate(int zaxisID)
 }
 
 
-void zaxisPrintKernel ( zaxis_t * zaxisptr, int index, FILE * fp )
+static void zaxisPrintKernel ( zaxis_t * zaxisptr, int index, FILE * fp )
 {
   unsigned char uuid[CDI_UUID_SIZE];
   int levelID;
@@ -66323,19 +68566,21 @@ void zaxisPrintKernel ( zaxis_t * zaxisptr, int index, FILE * fp )
 
   if ( type == ZAXIS_REFERENCE )
     {
-      const unsigned char *d;
       zaxisInqUUID(zaxisID, uuid);
-      d = uuid;
-      fprintf(fp, "uuid      = %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
-              d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
-              d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
+      if ( *uuid )
+        {
+          const unsigned char *d = uuid;
+          fprintf(fp, "uuid      = %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
+                  d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
+                  d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
+        }
     }
 }
 
 
 void zaxisPrint ( int zaxisID, int index )
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   zaxisPrintKernel ( zaxisptr, index, stdout );
 }
@@ -66551,7 +68796,7 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
       int size = zaxisP->size;
       xassert(size >= 0);
 
-      zaxisP->vals = (double *)xmalloc((size_t)size * sizeof (double));
+      zaxisP->vals = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       zaxisP->vals, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -66564,7 +68809,7 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
       int size = zaxisP->size;
       xassert(size >= 0);
 
-      zaxisP->lbounds = (double *)xmalloc((size_t)size * sizeof (double));
+      zaxisP->lbounds = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       zaxisP->lbounds, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -66577,7 +68822,7 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
       int size = zaxisP->size;
       xassert(size >= 0);
 
-      zaxisP->ubounds = (double *)xmalloc((size_t)size * sizeof (double));
+      zaxisP->ubounds = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       zaxisP->ubounds, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -66590,7 +68835,7 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
       int size = zaxisP->size;
       xassert(size >= 0);
 
-      zaxisP->weights = (double *)xmalloc((size_t)size * sizeof (double));
+      zaxisP->weights = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       zaxisP->weights, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -66603,7 +68848,7 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
       int size = zaxisP->vctsize;
       xassert(size >= 0);
 
-      zaxisP->vct = (double *)xmalloc((size_t)size * sizeof (double));
+      zaxisP->vct = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       zaxisP->vct, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -66625,6 +68870,8 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
     serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                     zaxisP->uuid, CDI_UUID_SIZE, DATATYPE_UCHAR, context);
 
+  reshSetStatus(zaxisP->self, &zaxisOps,
+                reshGetStatus(zaxisP->self, &zaxisOps) & ~RESH_SYNC_BIT);
 }
 
 static void
@@ -66722,7 +68969,7 @@ zaxisPack(void * voidP, void * packBuffer, int packBufferSize,
 }
 
 
-void cdiZaxisGetIndexList(unsigned nzaxis, int zaxisResHs[nzaxis])
+void cdiZaxisGetIndexList(unsigned nzaxis, int *zaxisResHs)
 {
   reshGetResHListOfType(nzaxis, zaxisResHs, &zaxisOps);
 }
@@ -66738,7 +68985,7 @@ void cdiZaxisGetIndexList(unsigned nzaxis, int zaxisResHs[nzaxis])
  * require-trailing-newline: t
  * End:
  */
-   static const char cdi_libvers[] = "1.6.9" " of ""Apr 27 2015"" ""08:19:12";
+   static const char cdi_libvers[] = "1.7.0" " of " "Oct 25 2015"" " "12:56:26";
 const char *cdiLibraryVersion(void)
 {
   return (cdi_libvers);
@@ -66749,13 +68996,9 @@ const char *cdiLibraryVersion(void)
 #undef calloc
 #undef free
 #undef DOUBLE_PRECISION
-/* cfortran.h  4.3 */
+/* cfortran.h  4.4 */
 /* http://www-zeus.desy.de/~burow/cfortran/                   */
-/* Burkhard Burow  burow at desy.de                 1990 - 2001. */
-
-/* 02/12/2002 Uwe Schulzweida : UXP Fortran support           */
-/* 02/05/2003 Uwe Schulzweida : Linux Fortran support on i386 */
-/* 09/09/2005 Uwe Schulzweida : Linux Fortran support on ia64 */
+/* Burkhard Burow  burow at desy.de                 1990 - 2002. */
 
 #ifndef __CFORTRAN_LOADED
 #define __CFORTRAN_LOADED
@@ -66766,11 +69009,108 @@ const char *cdiLibraryVersion(void)
    MODIFYING, COPYING AND DISTRIBUTING THE CFORTRAN.H PACKAGE.
 */
 
+/* THIS PACKAGE, I.E. CFORTRAN.H, THIS DOCUMENT, AND THE CFORTRAN.H EXAMPLE
+PROGRAMS ARE PROPERTY OF THE AUTHOR WHO RESERVES ALL RIGHTS. THIS PACKAGE AND
+THE CODE IT PRODUCES MAY BE FREELY DISTRIBUTED WITHOUT FEES, SUBJECT
+(AT YOUR CHOICE) EITHER TO THE GNU LIBRARY GENERAL PUBLIC LICENSE
+AT http://www.gnu.org/licenses/lgpl.html OR TO THE FOLLOWING RESTRICTIONS:
+- YOU MUST ACCOMPANY ANY COPIES OR DISTRIBUTION WITH THIS (UNALTERED) NOTICE.
+- YOU MAY NOT RECEIVE MONEY FOR THE DISTRIBUTION OR FOR ITS MEDIA 
+  (E.G. TAPE, DISK, COMPUTER, PAPER.)
+- YOU MAY NOT PREVENT OTHERS FROM COPYING IT FREELY.
+- YOU MAY NOT DISTRIBUTE MODIFIED VERSIONS WITHOUT CLEARLY DOCUMENTING YOUR
+  CHANGES AND NOTIFYING THE AUTHOR.
+- YOU MAY NOT MISREPRESENTED THE ORIGIN OF THIS SOFTWARE, EITHER BY EXPLICIT
+  CLAIM OR BY OMISSION.
+
+THE INTENT OF THE ABOVE TERMS IS TO ENSURE THAT THE CFORTRAN.H PACKAGE NOT BE
+USED FOR PROFIT MAKING ACTIVITIES UNLESS SOME ROYALTY ARRANGEMENT IS ENTERED
+INTO WITH ITS AUTHOR.
+              
+THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
+EXPRESSED OR IMPLIED. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST
+OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. THE AUTHOR IS NOT RESPONSIBLE
+FOR ANY SUPPORT OR SERVICE OF THE CFORTRAN.H PACKAGE.
+
+                                              Burkhard Burow 
+                                              burow at desy.de
+*/
+
+/* The following modifications were made by the authors of CFITSIO or by me. 
+ * They are flagged below with CFITSIO, the author's initials, or KMCCARTY.
+ * PDW = Peter Wilson
+ * DM  = Doug Mink
+ * LEB = Lee E Brotzman
+ * MR  = Martin Reinecke
+ * WDP = William D Pence
+ * BR  = Bastien ROUCARIES
+ * -- Kevin McCarty, for Debian (19 Dec. 2005) */
+
+/*******
+   Modifications:
+      Oct 1997: Changed symbol name extname to appendus (PDW/HSTX)
+                (Conflicted with a common variable name in FTOOLS)
+      Nov 1997: If g77Fortran defined, also define f2cFortran (PDW/HSTX)
+      Feb 1998: Let VMS see the NUM_ELEMS code. Lets programs treat
+                single strings as vectors with single elements
+      Nov 1999: If macintoxh defined, also define f2cfortran (for Mac OS-X)
+      Apr 2000: If WIN32 defined, also define PowerStationFortran and
+                VISUAL_CPLUSPLUS (Visual C++)
+      Jun 2000: If __GNUC__ and linux defined, also define f2cFortran
+                (linux/gcc environment detection)
+      Apr 2002: If __CYGWIN__ is defined, also define f2cFortran
+      Nov 2002: If __APPLE__ defined, also define f2cfortran (for Mac OS-X)
+
+      Nov 2003: If __INTEL_COMPILER or INTEL_COMPILER defined, also define
+                f2cFortran (KMCCARTY)
+      Dec 2005: If f2cFortran is defined, enforce REAL functions in FORTRAN
+                returning "double" in C.  This was one of the items on
+		Burkhard's TODO list. (KMCCARTY)
+      Dec 2005: Modifications to support 8-byte integers. (MR)
+		USE AT YOUR OWN RISK!
+      Feb 2006  Added logic to typedef the symbol 'LONGLONG' to an appropriate
+                intrinsic 8-byte integer datatype  (WDP)
+      Apr 2006: Modifications to support gfortran (and g77 with -fno-f2c flag)
+                since by default it returns "float" for FORTRAN REAL function.
+                (KMCCARTY)
+      May 2008: Revert commenting out of "extern" in COMMON_BLOCK_DEF macro.
+		Add braces around do-nothing ";" in 3 empty while blocks to
+		get rid of compiler warnings.  Thanks to ROOT developers
+		Jacek Holeczek and Rene Brun for these suggestions. (KMCCARTY)
+      Aug 2008: If __GNUC__ is defined and no FORTRAN compiler is specified
+		via a #define or -D, default to gfortran behavior rather than
+		g77 behavior. (KMCCARTY)
+      Oct 2009: Add warning if guessing default fortran. Move g77 above guessing bloc
+ *******/
+
 /* 
   Avoid symbols already used by compilers and system *.h:
   __ - OSF1 zukal06 V3.0 347 alpha, cc -c -std1 cfortest.c
 
- */
+*/
+
+/* 
+   Determine what 8-byte integer data type is available.
+  'long long' is now supported by most compilers, but older
+  MS Visual C++ compilers before V7.0 use '__int64' instead. (WDP)
+*/
+
+#ifndef LONGLONG_TYPE   /* this may have been previously defined */
+#if defined(_MSC_VER)   /* Microsoft Visual C++ */
+
+#if (_MSC_VER < 1300)   /* versions earlier than V7.0 do not have 'long long' */
+    typedef __int64 LONGLONG;
+#else                   /* newer versions do support 'long long' */
+    typedef long long LONGLONG; 
+#endif
+
+#else
+    typedef long long LONGLONG; 
+#endif
+
+#define LONGLONG_TYPE
+#endif  
 
 
 /* First prepare for the C compiler. */
@@ -66815,7 +69155,6 @@ const char *cdiLibraryVersion(void)
 #define __CF__APOLLO67 /* __STDCPP__ is in Apollo 6.8 (i.e. ANSI) and onwards */
 #endif
 #endif
-#include <limits.h>    /* LONG_MAX */
 
 #if !defined(__GNUC__) && !defined(__sun) && (defined(sun)||defined(VAXUltrix)||defined(lynx))
 #define __CF__KnR     /* Sun, LynxOS and VAX Ultrix cc only supports K&R.     */
@@ -66831,7 +69170,13 @@ only C calling FORTRAN subroutines will work using K&R style.*/
 
 /* Remainder of cfortran.h depends on the Fortran compiler. */
 
-#if (defined(CLIPPERFortran) || defined(pgiFortran)) && !defined(f2cFortran)
+/* 11/29/2003 (KMCCARTY): add *INTEL_COMPILER symbols here */
+/* 04/05/2006 (KMCCARTY): add gFortran symbol here */
+#if defined(CLIPPERFortran) || defined(pgiFortran) || defined(__INTEL_COMPILER) || defined(INTEL_COMPILER) || defined(gFortran)
+#define f2cFortran
+#endif
+
+#if defined(g77Fortran)                        /* 11/03/97 PDW (CFITSIO) */
 #define f2cFortran
 #endif
 
@@ -66840,14 +69185,8 @@ only C calling FORTRAN subroutines will work using K&R style.*/
 #if !(defined(NAGf90Fortran)||defined(f2cFortran)||defined(hpuxFortran)||defined(apolloFortran)||defined(sunFortran)||defined(IBMR2Fortran)||defined(CRAYFortran))
 #if !(defined(mipsFortran)||defined(DECFortran)||defined(vmsFortran)||defined(CONVEXFortran)||defined(PowerStationFortran)||defined(AbsoftUNIXFortran)||defined(AbsoftProFortran)||defined(SXFortran))
 /* If no Fortran compiler is given, we choose one for the machines we know.   */
-#if defined(__linux__) && defined(__i386__)
-#define f2cFortran
-#endif
-#if defined(__linux__) && defined(__ia64__)
-#define f2cFortran
-#endif
-#if defined(__linux__) && defined(__x86_64__)
-#define f2cFortran
+#if defined(__GNUC__) || defined(WIN32) /* 10/2009 BR: warm if guess */
+#warning "Please specify the fortran compiler using -D flags. Try to guess the compiler used"
 #endif
 #if defined(lynx) || defined(VAXUltrix)
 #define f2cFortran    /* Lynx:      Only support f2c at the moment.
@@ -66855,6 +69194,28 @@ only C calling FORTRAN subroutines will work using K&R style.*/
                            Support f2c or f77 with gcc, vcc with f2c. 
                            f77 with vcc works, missing link magic for f77 I/O.*/
 #endif
+/* 04/13/00 DM (CFITSIO): Add these lines for NT */
+/*   with PowerStationFortran and and Visual C++ */
+#if defined(WIN32) && !defined(__CYGWIN__)
+#define PowerStationFortran   
+#define VISUAL_CPLUSPLUS
+#endif
+#if        defined(__CYGWIN__)                 /* 04/11/02 LEB (CFITSIO) */
+#define       f2cFortran 
+#define	      gFortran /* 8/26/08 (KMCCARTY) */
+#endif
+#if        defined(__GNUC__) && defined(linux) /* 06/21/00 PDW (CFITSIO) */
+#define       f2cFortran 
+#define	      gFortran /* 8/26/08 (KMCCARTY) */
+#endif
+#if defined(macintosh)                         /* 11/1999 (CFITSIO) */
+#define f2cFortran
+#define	      gFortran /* 8/26/08 (KMCCARTY) */
+#endif
+#if defined(__APPLE__)                         /* 11/2002 (CFITSIO) */
+#define f2cFortran
+#define	      gFortran /* 8/26/08 (KMCCARTY) */
+#endif
 #if defined(__hpux)             /* 921107: Use __hpux instead of __hp9000s300 */
 #define       hpuxFortran       /*         Should also allow hp9000s7/800 use.*/
 #endif
@@ -66873,9 +69234,6 @@ only C calling FORTRAN subroutines will work using K&R style.*/
 #if        defined(_SX)
 #define               SXFortran
 #endif
-#if        defined(__uxp__)
-#define               UXPFortran
-#endif
 #if         defined(mips) || defined(__mips)
 #define             mipsFortran
 #endif
@@ -66896,9 +69254,10 @@ only C calling FORTRAN subroutines will work using K&R style.*/
 
 /* Split #if into 2 because some HP-UX can't handle long #if */
 #if !(defined(NAGf90Fortran)||defined(f2cFortran)||defined(hpuxFortran)||defined(apolloFortran)||defined(sunFortran)||defined(IBMR2Fortran)||defined(CRAYFortran))
-#if !(defined(mipsFortran)||defined(DECFortran)||defined(vmsFortran)||defined(CONVEXFortran)||defined(PowerStationFortran)||defined(AbsoftUNIXFortran)||defined(AbsoftProFortran)||defined(SXFortran)||defined(UXPFortran))
+#if !(defined(mipsFortran)||defined(DECFortran)||defined(vmsFortran)||defined(CONVEXFortran)||defined(PowerStationFortran)||defined(AbsoftUNIXFortran)||defined(AbsoftProFortran)||defined(SXFortran))
 /* If your compiler barfs on ' #error', replace # with the trigraph for #     */
  #error "cfortran.h:  Can't find your environment among:\
+    - GNU gcc (gfortran) on Linux.                                       \
     - MIPS cc and f77 2.0. (e.g. Silicon Graphics, DECstations, ...)     \
     - IBM AIX XL C and FORTRAN Compiler/6000 Version 01.01.0000.0000     \
     - VAX   VMS CC 3.1 and FORTRAN 5.4.                                  \
@@ -66915,11 +69274,14 @@ only C calling FORTRAN subroutines will work using K&R style.*/
     - VAXUltrix: vcc,cc or gcc with f2c. gcc or cc with f77.             \
     -            f77 with vcc works; but missing link magic for f77 I/O. \
     -            NO fort. None of gcc, cc or vcc generate required names.\
-    - f2c    : Use #define    f2cFortran, or cc -Df2cFortran             \
+    - f2c/g77:   Use #define    f2cFortran, or cc -Df2cFortran           \
+    - gfortran:  Use #define    gFortran,   or cc -DgFortran             \
+                 (also necessary for g77 with -fno-f2c option)           \
     - NAG f90: Use #define NAGf90Fortran, or cc -DNAGf90Fortran          \
     - Absoft UNIX F77: Use #define AbsoftUNIXFortran or cc -DAbsoftUNIXFortran \
     - Absoft Pro Fortran: Use #define AbsoftProFortran \
-    - Portland Group Fortran: Use #define pgiFortran"
+    - Portland Group Fortran: Use #define pgiFortran \
+    - Intel Fortran: Use #define INTEL_COMPILER"
 /* Compiler must throw us out at this point! */
 #endif
 #endif
@@ -66932,7 +69294,8 @@ only C calling FORTRAN subroutines will work using K&R style.*/
 
 /* Throughout cfortran.h we use: UN = Uppercase Name.  LN = Lowercase Name.   */
 
-#if defined(f2cFortran) || defined(NAGf90Fortran) || defined(DECFortran) || defined(mipsFortran) || defined(apolloFortran) || defined(sunFortran) || defined(CONVEXFortran) || defined(SXFortran) || defined(UXPFortran) || defined(extname)
+/* "extname" changed to "appendus" below (CFITSIO) */
+#if defined(f2cFortran) || defined(NAGf90Fortran) || defined(DECFortran) || defined(mipsFortran) || defined(apolloFortran) || defined(sunFortran) || defined(CONVEXFortran) || defined(SXFortran) || defined(appendus)
 #define CFC_(UN,LN)            _(LN,_)      /* Lowercase FORTRAN symbols.     */
 #define orig_fcallsc(UN,LN)    CFC_(UN,LN)
 #else 
@@ -66996,18 +69359,6 @@ only C calling FORTRAN subroutines will work using K&R style.*/
 #endif
 #endif
 
-/* INT64_T for 8 byte integers */
-#if ! defined (LONG_MAX)
-#  error LONG_MAX undefined
-#endif
-
-#undef  INT64_T
-#if LONG_MAX > 2147483647L
-#  define INT64_T long int
-#else
-#  define INT64_T long long int       /* c.f. typedef of int64_t in <stdint.h> */
-#endif
-
 #ifdef CRAYFortran
 #ifdef _CRAY
 #include <fortran.h>
@@ -67123,7 +69474,7 @@ Apollo                                           : neg.   = TRUE, else FALSE.
 [DECFortran for Ultrix RISC is also called f77 but is the same as VAX/VMS.]   
 [MIPS f77 treats .eqv./.neqv. as .eq./.ne. and hence requires LOGICAL_STRICT.]*/
 
-#if defined(NAGf90Fortran) || defined(f2cFortran) || defined(mipsFortran) || defined(PowerStationFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran) || defined(AbsoftProFortran) || defined(SXFortran) || defined(UXPFortran)
+#if defined(NAGf90Fortran) || defined(f2cFortran) || defined(mipsFortran) || defined(PowerStationFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran) || defined(AbsoftProFortran) || defined(SXFortran)
 /* SX/PowerStationFortran have 0 and 1 defined, others are neither T nor F.   */
 /* hpuxFortran800 has 0 and 0x01000000 defined. Others are unknown.           */
 #define LOGICAL_STRICT      /* Other Fortran have .eqv./.neqv. == .eq./.ne.   */
@@ -67225,16 +69576,6 @@ for (i=0; i<sizeofcstr/elem_len; i++) {
 } return cstr; }
 
 /* kill the trailing char t's in string s. */
-#if !defined(GNUC_PUSH_POP) && defined(__GNUC__) && !defined(__ICC) && !defined(__clang__)
-#if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 4)
-#define GNUC_PUSH_POP
-#endif
-#endif
-
-#if defined(GNUC_PUSH_POP)
-#pragma GCC push_options
-#pragma GCC optimize ("O2")
-#endif
 #ifndef __CF__KnR
 static char *kill_trailing(char *s, char t)
 #else
@@ -67243,13 +69584,13 @@ static char *kill_trailing(      s,      t) char *s; char t;
 {char *e; 
 e = s + strlen(s);
 if (e>s) {                           /* Need this to handle NULL string.*/
-  while (e>s && *--e==t);            /* Don't follow t's past beginning. */
+  while (e>s && *--e==t) {;}         /* Don't follow t's past beginning. */
   e[*e==t?0:1] = '\0';               /* Handle s[0]=t correctly.       */
 } return s; }
-#if defined(GNUC_PUSH_POP)
-#pragma GCC pop_options
-#endif
 
+#ifndef __CF__KnR
+static int num_elem(char *strv, unsigned elem_len, int term_char, int num_term);
+#endif
 /* kill_trailingn(s,t,e) will kill the trailing t's in string s. e normally 
 points to the terminating '\0' of s, but may actually point to anywhere in s.
 s's new '\0' will be placed at e or earlier in order to remove any trailing t's.
@@ -67262,9 +69603,13 @@ static char *kill_trailingn(      s,      t,       e) char *s; char t; char *e;
 { 
 if (e==s) *e = '\0';                 /* Kill the string makes sense here.*/
 else if (e>s) {                      /* Watch out for neg. length string.*/
-  while (e>s && *--e==t);            /* Don't follow t's past beginning. */
+  while (e>s && *--e==t){;}          /* Don't follow t's past beginning. */
   e[*e==t?0:1] = '\0';               /* Handle s[0]=t correctly.       */
-} return s; }
+}
+if (0)  /* to prevent not used warnings in gcc (added by TJ) */
+  num_elem("", 0, '\0', 1);
+
+ return s; }
 
 /* Note the following assumes that any element which has t's to be chopped off,
 does indeed fill the entire element. */
@@ -67305,7 +69650,7 @@ typedef DSC$DESCRIPTOR_A(1) fstringvector;
                     *( (F).dsc$l_m[0]=(F).dsc$bounds[0].dsc$l_u=(ELEMNO)  ),   \
   (F).dsc$a_a0    =  ( (F).dsc$a_pointer=(C) ) - (F).dsc$w_length          ,(F))
 
-#else
+#endif      /* PDW: 2/10/98 (CFITSIO) -- Let VMS see NUM_ELEMS definitions */
 #define _NUM_ELEMS      -1
 #define _NUM_ELEM_ARG   -2
 #define NUM_ELEMS(A)    A,_NUM_ELEMS
@@ -67327,13 +69672,18 @@ if (num_term == _NUM_ELEMS || num_term == _NUM_ELEM_ARG)
   return term_char;
 if (num_term <=0) num_term = (int)elem_len;
 for (num=0; ; num++) {
-  for (i=0; i<(unsigned)num_term && *strv==term_char; i++,strv++);
+  for (i=0; i<(unsigned)num_term && *strv==term_char; i++,strv++){;}
   if (i==(unsigned)num_term) break;
   else strv += elem_len-i;
 }
+if (0) {  /* to prevent not used warnings in gcc (added by ROOT) */
+   c2fstrv(0, 0, 0, 0); f2cstrv(0, 0, 0, 0); kill_trailing(0, 0);
+   vkill_trailing(0, 0, 0, 0); num_elem(0, 0, 0, 0);
+}
 return (int)num;
 }
-#endif
+/* #endif removed 2/10/98 (CFITSIO) */
+
 /*-------------------------------------------------------------------------*/
 
 /*           UTILITIES FOR C TO USE STRINGS IN FORTRAN COMMON BLOCKS       */
@@ -67444,8 +69794,8 @@ typedef void (*cfCAST_FUNCTION)(CF_NULL_PROTO);
 #define   PSTRINGV_cfV(T,A,B,F) static fstringvector B =                       \
           {0,DSC$K_DTYPE_T,DSC$K_CLASS_A,NULL,0,0,{0,0,1,1,1},1,0,NULL,0,{1,0}};
 #else
-#define     STRING_cfV(T,A,B,F) struct {unsigned int clen, flen;} B;
-#define    STRINGV_cfV(T,A,B,F) struct {char *s, *fs; unsigned flen;} B;
+#define     STRING_cfV(T,A,B,F) struct {unsigned int clen, flen; char *nombre;} B;
+#define    STRINGV_cfV(T,A,B,F) struct {char *s, *fs; unsigned flen; char *nombre;} B;
 #define    PSTRING_cfV(T,A,B,F) int     B;
 #define   PSTRINGV_cfV(T,A,B,F) struct{char *fs; unsigned int sizeofA,flen;}B;
 #endif
@@ -67563,7 +69913,7 @@ typedef void (*cfCAST_FUNCTION)(CF_NULL_PROTO);
 #define  DEFAULT_cfW(A,B)
 #define  LOGICAL_cfW(A,B)
 #define PLOGICAL_cfW(A,B) *B=F2CLOGICAL(*B);
-#define   STRING_cfW(A,B) (A[B.clen]!='\0'?A[B.clen]='\0':0); /* A?="constnt"*/
+#define   STRING_cfW(A,B) (B.nombre=A,B.nombre[B.clen]!='\0'?B.nombre[B.clen]='\0':0); /* A?="constnt"*/
 #define  PSTRING_cfW(A,B) kill_trailing(A,' ');
 #ifdef vmsFortran
 #define  STRINGV_cfW(A,B) _cf_free(B.dsc$a_pointer);
@@ -68105,24 +70455,22 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #else
 #define INTEGER_BYTE        unsigned char
 #endif
-#define     BYTEVVVVVVV_cfTYPE INTEGER_BYTE
-#define   DOUBLEVVVVVVV_cfTYPE DOUBLE_PRECISION 
-#define    FLOATVVVVVVV_cfTYPE FORTRAN_REAL
-#define      INTVVVVVVV_cfTYPE int
-#define  LOGICALVVVVVVV_cfTYPE int
-#define     LONGVVVVVVV_cfTYPE long
-#define LONGLONGVVVVVVV_cfTYPE long long
-#define    INT64VVVVVVV_cfTYPE INT64_T
-#define    SHORTVVVVVVV_cfTYPE short
-#define           PBYTE_cfTYPE INTEGER_BYTE
-#define         PDOUBLE_cfTYPE DOUBLE_PRECISION 
-#define          PFLOAT_cfTYPE FORTRAN_REAL
-#define            PINT_cfTYPE int
-#define        PLOGICAL_cfTYPE int
-#define           PLONG_cfTYPE long
-#define       PLONGLONG_cfTYPE long long
-#define          PINT64_cfTYPE INT64_T
-#define          PSHORT_cfTYPE short
+#define    BYTEVVVVVVV_cfTYPE INTEGER_BYTE
+#define  DOUBLEVVVVVVV_cfTYPE DOUBLE_PRECISION 
+#define   FLOATVVVVVVV_cfTYPE FORTRAN_REAL
+#define     INTVVVVVVV_cfTYPE int
+#define LOGICALVVVVVVV_cfTYPE int
+#define    LONGVVVVVVV_cfTYPE long
+#define LONGLONGVVVVVVV_cfTYPE LONGLONG   /* added by MR December 2005 */
+#define   SHORTVVVVVVV_cfTYPE short
+#define          PBYTE_cfTYPE INTEGER_BYTE
+#define        PDOUBLE_cfTYPE DOUBLE_PRECISION 
+#define         PFLOAT_cfTYPE FORTRAN_REAL
+#define           PINT_cfTYPE int
+#define       PLOGICAL_cfTYPE int
+#define          PLONG_cfTYPE long
+#define      PLONGLONG_cfTYPE LONGLONG  /* added by MR December 2005 */
+#define         PSHORT_cfTYPE short
 
 #define CFARGS0(A,T,V,W,X,Y,Z) _3(T,_cf,A)
 #define CFARGS1(A,T,V,W,X,Y,Z) _3(T,_cf,A)(V)
@@ -68139,8 +70487,7 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define            INT_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
 #define        LOGICAL_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
 #define           LONG_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
-#define       LONGLONG_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
-#define          INT64_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
+#define       LONGLONG_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
 #define          SHORT_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
 #define          PBYTE_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
 #define        PDOUBLE_cfINT(N,A,B,X,Y,Z) _(CFARGS,N)(A,PINT,B,X,Y,Z,0)
@@ -68148,8 +70495,7 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define           PINT_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
 #define       PLOGICAL_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
 #define          PLONG_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
-#define      PLONGLONG_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
-#define         PINT64_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
+#define      PLONGLONG_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
 #define         PSHORT_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
 #define          BYTEV_cfINT(N,A,B,X,Y,Z)       DOUBLEV_cfINT(N,A,B,X,Y,Z)
 #define         BYTEVV_cfINT(N,A,B,X,Y,Z)      DOUBLEVV_cfINT(N,A,B,X,Y,Z)
@@ -68193,6 +70539,13 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define      LONGVVVVV_cfINT(N,A,B,X,Y,Z)   DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z)
 #define     LONGVVVVVV_cfINT(N,A,B,X,Y,Z)  DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z)
 #define    LONGVVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define      LONGLONGV_cfINT(N,A,B,X,Y,Z)       DOUBLEV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define     LONGLONGVV_cfINT(N,A,B,X,Y,Z)      DOUBLEVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define    LONGLONGVVV_cfINT(N,A,B,X,Y,Z)     DOUBLEVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define   LONGLONGVVVV_cfINT(N,A,B,X,Y,Z)    DOUBLEVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define  LONGLONGVVVVV_cfINT(N,A,B,X,Y,Z)   DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define LONGLONGVVVVVV_cfINT(N,A,B,X,Y,Z)  DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define LONGLONGVVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
 #define         SHORTV_cfINT(N,A,B,X,Y,Z)       DOUBLEV_cfINT(N,A,B,X,Y,Z)
 #define        SHORTVV_cfINT(N,A,B,X,Y,Z)      DOUBLEVV_cfINT(N,A,B,X,Y,Z)
 #define       SHORTVVV_cfINT(N,A,B,X,Y,Z)     DOUBLEVVV_cfINT(N,A,B,X,Y,Z)
@@ -68252,7 +70605,12 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define      BYTE_cfPU(A)   CFextern INTEGER_BYTE      FCALLSC_QUALIFIER A
 #define    DOUBLE_cfPU(A)   CFextern DOUBLE_PRECISION  FCALLSC_QUALIFIER A
 #if ! (defined(FLOATFUNCTIONTYPE)&&defined(ASSIGNFLOAT)&&defined(RETURNFLOAT))
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define     FLOAT_cfPU(A)   CFextern DOUBLE_PRECISION  FCALLSC_QUALIFIER A
+#else
 #define     FLOAT_cfPU(A)   CFextern FORTRAN_REAL      FCALLSC_QUALIFIER A
+#endif
 #else				   	                   
 #define     FLOAT_cfPU(A)   CFextern FLOATFUNCTIONTYPE FCALLSC_QUALIFIER A
 #endif				   	                   
@@ -68390,8 +70748,7 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define            INT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define        LOGICAL_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,LOGICAL,A,B,C,D,E)
 #define           LONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
-#define       LONGLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
-#define          INT64_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define       LONGLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
 #define          SHORT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define          BYTEV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define         BYTEVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
@@ -68435,6 +70792,13 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define      LONGVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define     LONGVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define    LONGVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define      LONGLONGV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define     LONGLONGVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define    LONGLONGVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define   LONGLONGVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define  LONGLONGVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define LONGLONGVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define LONGLONGVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
 #define         SHORTV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define        SHORTVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define       SHORTVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
@@ -68448,8 +70812,7 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define           PINT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define       PLOGICAL_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,PLOGICAL,A,B,C,D,E)
 #define          PLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
-#define      PLONGLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
-#define         PINT64_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define      PLONGLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
 #define         PSHORT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define         STRING_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,STRING,A,B,C,D,E)
 #define        PSTRING_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,PSTRING,A,B,C,D,E)
@@ -68476,11 +70839,11 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
       /* PSTRING_cfC to beware of array A which does not contain any \0.      */
 #define  PSTRING_cfC(M,I,A,B,C) (B.dsc$a_pointer=A, C==sizeof(char*) ?         \
              B.dsc$w_length=strlen(A):  (A[C-1]='\0',B.dsc$w_length=strlen(A), \
-       memset((A)+B.dsc$w_length,' ',C-B.dsc$w_length-1), B.dsc$w_length=C-1));
+       (unsigned)memset((A)+B.dsc$w_length,' ',C-B.dsc$w_length-1), B.dsc$w_length=C-1));
 #else
-#define   STRING_cfC(M,I,A,B,C) (B.clen=strlen(A),                             \
+#define   STRING_cfC(M,I,A,B,C) (B.nombre=A,B.clen=(unsigned)strlen(A),                             \
                 C==sizeof(char*)||C==(unsigned)(B.clen+1)?B.flen=B.clen:       \
-                        (memset((A)+B.clen,' ',C-B.clen-1),A[B.flen=C-1]='\0'));
+                        (unsigned)(memset(B.nombre+B.clen,' ',C-B.clen-1),B.nombre[B.flen=C-1]='\0'));
 #define  PSTRING_cfC(M,I,A,B,C) (C==sizeof(char*)? B=strlen(A):                \
                     (A[C-1]='\0',B=strlen(A),memset((A)+B,' ',C-B-1),B=C-1));
 #endif
@@ -68507,8 +70870,6 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define      INT_cfCCC(A,B) &A
 #define  LOGICAL_cfCCC(A,B) &A
 #define     LONG_cfCCC(A,B) &A
-#define LONGLONG_cfCCC(A,B) &A
-#define    INT64_cfCCC(A,B) &A
 #define    SHORT_cfCCC(A,B) &A
 #define    PBYTE_cfCCC(A,B)  A
 #define  PDOUBLE_cfCCC(A,B)  A
@@ -68764,8 +71125,7 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #define            INT_cfT(M,I,A,B,D) *A
 #define        LOGICAL_cfT(M,I,A,B,D)  F2CLOGICAL(*A)
 #define           LONG_cfT(M,I,A,B,D) *A
-#define       LONGLONG_cfT(M,I,A,B,D) *A
-#define          INT64_cfT(M,I,A,B,D) *A
+#define       LONGLONG_cfT(M,I,A,B,D) *A /* added by MR December 2005 */
 #define          SHORT_cfT(M,I,A,B,D) *A
 #define          BYTEV_cfT(M,I,A,B,D)  A
 #define        DOUBLEV_cfT(M,I,A,B,D)  A
@@ -68773,6 +71133,7 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #define           INTV_cfT(M,I,A,B,D)  A
 #define       LOGICALV_cfT(M,I,A,B,D)  A
 #define          LONGV_cfT(M,I,A,B,D)  A
+#define      LONGLONGV_cfT(M,I,A,B,D)  A /* added by MR December 2005 */
 #define         SHORTV_cfT(M,I,A,B,D)  A
 #define         BYTEVV_cfT(M,I,A,B,D)  (void *)A /* We have to cast to void *,*/
 #define        BYTEVVV_cfT(M,I,A,B,D)  (void *)A /* since we don't know the   */
@@ -68810,6 +71171,12 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #define      LONGVVVVV_cfT(M,I,A,B,D)  (void *)A
 #define     LONGVVVVVV_cfT(M,I,A,B,D)  (void *)A
 #define    LONGVVVVVVV_cfT(M,I,A,B,D)  (void *)A
+#define     LONGLONGVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define    LONGLONGVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define   LONGLONGVVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define  LONGLONGVVVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define LONGLONGVVVVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define LONGLONGVVVVVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
 #define        SHORTVV_cfT(M,I,A,B,D)  (void *)A
 #define       SHORTVVV_cfT(M,I,A,B,D)  (void *)A
 #define      SHORTVVVV_cfT(M,I,A,B,D)  (void *)A
@@ -68822,8 +71189,7 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #define           PINT_cfT(M,I,A,B,D)  A
 #define       PLOGICAL_cfT(M,I,A,B,D)  ((*A=F2CLOGICAL(*A)),A)
 #define          PLONG_cfT(M,I,A,B,D)  A
-#define      PLONGLONG_cfT(M,I,A,B,D)  A
-#define         PINT64_cfT(M,I,A,B,D)  A
+#define      PLONGLONG_cfT(M,I,A,B,D)  A /* added by MR December 2005 */
 #define         PSHORT_cfT(M,I,A,B,D)  A
 #define          PVOID_cfT(M,I,A,B,D)  A
 #if defined(apolloFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran)
@@ -68857,7 +71223,7 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #define         STRING_cfT(M,I,A,B,D)  TTTTSTR( A,B,D)
 #define        STRINGV_cfT(M,I,A,B,D)  TTTTSTRV(A,B,D, num_elem(A,D,_3(M,_STRV_A,I)))
 #define        PSTRING_cfT(M,I,A,B,D)    TTSTR( A,B,D)
-#define       PPSTRING_cfT(M,I,A,B,D)           A
+#define       PPSTRING_cfT(M,I,A,B,D)           ((void)D, A)
 #endif
 #endif
 #define       PNSTRING_cfT(M,I,A,B,D)    STRING_cfT(M,I,A,B,D)
@@ -68894,12 +71260,18 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #define     INT_cfFZ(UN,LN) int   FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #define LOGICAL_cfFZ(UN,LN) int   FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #define    LONG_cfFZ(UN,LN) long  FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#define LONGLONG_cfFZ(UN,LN) LONGLONG FCALLSC_QUALIFIER fcallsc(UN,LN)( /* added by MR December 2005 */
 #define   SHORT_cfFZ(UN,LN) short FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #define    VOID_cfFZ(UN,LN) void  FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #ifndef __CF__KnR
 /* The void is req'd by the Apollo, to make this an ANSI function declaration.
    The Apollo promotes K&R float functions to double. */
-#define   FLOAT_cfFZ(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(void
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define FLOAT_cfFZ(UN,LN) DOUBLE_PRECISION FCALLSC_QUALIFIER fcallsc(UN,LN)(void
+#else
+#define FLOAT_cfFZ(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(void
+#endif
 #ifdef vmsFortran
 #define  STRING_cfFZ(UN,LN) void  FCALLSC_QUALIFIER fcallsc(UN,LN)(fstring *AS
 #else
@@ -68915,7 +71287,12 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #endif
 #else
 #if ! (defined(FLOATFUNCTIONTYPE)&&defined(ASSIGNFLOAT)&&defined(RETURNFLOAT))
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define   FLOAT_cfFZ(UN,LN) DOUBLE_PRECISION  FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#else
 #define   FLOAT_cfFZ(UN,LN) FORTRAN_REAL      FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#endif
 #else
 #define   FLOAT_cfFZ(UN,LN) FLOATFUNCTIONTYPE FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #endif
@@ -68929,13 +71306,19 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #define    BYTE_cfF(UN,LN)     BYTE_cfFZ(UN,LN)
 #define  DOUBLE_cfF(UN,LN)   DOUBLE_cfFZ(UN,LN)
 #ifndef __CF_KnR
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define   FLOAT_cfF(UN,LN)  DOUBLE_PRECISION FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#else
 #define   FLOAT_cfF(UN,LN)  FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#endif
 #else
 #define   FLOAT_cfF(UN,LN)    FLOAT_cfFZ(UN,LN)
 #endif
 #define     INT_cfF(UN,LN)      INT_cfFZ(UN,LN)
 #define LOGICAL_cfF(UN,LN)  LOGICAL_cfFZ(UN,LN)
 #define    LONG_cfF(UN,LN)     LONG_cfFZ(UN,LN)
+#define LONGLONG_cfF(UN,LN) LONGLONG_cfFZ(UN,LN) /* added by MR December 2005 */
 #define   SHORT_cfF(UN,LN)    SHORT_cfFZ(UN,LN)
 #define    VOID_cfF(UN,LN)     VOID_cfFZ(UN,LN)
 #define  STRING_cfF(UN,LN)   STRING_cfFZ(UN,LN),
@@ -68998,6 +71381,7 @@ string. */
 #define LOGICAL_cfI  return C2FLOGICAL(A0);
 #endif
 #define    LONG_cfI  return A0;
+#define LONGLONG_cfI  return A0; /* added by MR December 2005 */
 #define   SHORT_cfI  return A0;
 #define  STRING_cfI  return   ;
 #define    VOID_cfI  return   ;
@@ -69217,6 +71601,15 @@ string. */
 /*  ZAXIS types  */
 
 
+/*  SUBTYPE types  */
+
+
+/*  Data structure defining a key-value search, possibly with multiple
+   key-value pairs in combination.
+
+   Currently, only multiple pairs combined by AND are supported.  */
+
+
 /*  TIME types  */
 
 
@@ -69254,6 +71647,7 @@ FCALLSCFUN0 (DOUBLE, cdiInqMissval, CDIINQMISSVAL, cdiinqmissval)
 FCALLSCSUB2 (cdiDefGlobal, CDIDEFGLOBAL, cdidefglobal, STRING, INT)
 FCALLSCFUN0 (INT, namespaceNew, NAMESPACENEW, namespacenew)
 FCALLSCSUB1 (namespaceSetActive, NAMESPACESETACTIVE, namespacesetactive, INT)
+FCALLSCFUN0 (INT, namespaceGetActive, NAMESPACEGETACTIVE, namespacegetactive)
 FCALLSCSUB1 (namespaceDelete, NAMESPACEDELETE, namespacedelete, INT)
 
 /*  CDI converter routines  */
@@ -69285,10 +71679,6 @@ FCALLSCSUB1 (streamClose, STREAMCLOSE, streamclose, INT)
 FCALLSCSUB1 (streamSync, STREAMSYNC, streamsync, INT)
 FCALLSCSUB2 (streamDefVlist, STREAMDEFVLIST, streamdefvlist, INT, INT)
 FCALLSCFUN1 (INT, streamInqVlist, STREAMINQVLIST, streaminqvlist, INT)
-
-/*  PIO:  */
-
-FCALLSCFUN1 (INT, streamInqVlistIDorig, STREAMINQVLISTIDORIG, streaminqvlistidorig, INT)
 FCALLSCFUN1 (INT, streamInqFiletype, STREAMINQFILETYPE, streaminqfiletype, INT)
 FCALLSCSUB2 (streamDefByteorder, STREAMDEFBYTEORDER, streamdefbyteorder, INT, INT)
 FCALLSCFUN1 (INT, streamInqByteorder, STREAMINQBYTEORDER, streaminqbyteorder, INT)
@@ -69299,27 +71689,29 @@ FCALLSCFUN1 (INT, streamInqCompLevel, STREAMINQCOMPLEVEL, streaminqcomplevel, IN
 FCALLSCFUN2 (INT, streamDefTimestep, STREAMDEFTIMESTEP, streamdeftimestep, INT, INT)
 FCALLSCFUN2 (INT, streamInqTimestep, STREAMINQTIMESTEP, streaminqtimestep, INT, INT)
 FCALLSCFUN1 (INT, streamInqCurTimestepID, STREAMINQCURTIMESTEPID, streaminqcurtimestepid, INT)
+FCALLSCFUN1 (STRING, streamFilename, STREAMFILENAME, streamfilename, INT)
+FCALLSCFUN1 (STRING, streamFilesuffix, STREAMFILESUFFIX, streamfilesuffix, INT)
 FCALLSCFUN1 (INT, streamInqNvars, STREAMINQNVARS, streaminqnvars, INT)
 
 /*  STREAM var I/O routines  */
 
-FCALLSCSUB4 (streamWriteVar, STREAMWRITEVAR, streamwritevar, INT, INT, PDOUBLE, INT)
-FCALLSCSUB4 (streamWriteVarF, STREAMWRITEVARF, streamwritevarf, INT, INT, PFLOAT, INT)
-FCALLSCSUB4 (streamReadVar, STREAMREADVAR, streamreadvar, INT, INT, PDOUBLE, PINT)
-FCALLSCSUB4 (streamReadVarF, STREAMREADVARF, streamreadvarf, INT, INT, PFLOAT, PINT)
-FCALLSCSUB5 (streamWriteVarSlice, STREAMWRITEVARSLICE, streamwritevarslice, INT, INT, INT, PDOUBLE, INT)
-FCALLSCSUB5 (streamWriteVarSliceF, STREAMWRITEVARSLICEF, streamwritevarslicef, INT, INT, INT, PFLOAT, INT)
-FCALLSCSUB5 (streamReadVarSlice, STREAMREADVARSLICE, streamreadvarslice, INT, INT, INT, PDOUBLE, PINT)
-FCALLSCSUB5 (streamReadVarSliceF, STREAMREADVARSLICEF, streamreadvarslicef, INT, INT, INT, PFLOAT, PINT)
-FCALLSCSUB5 (streamWriteVarChunk, STREAMWRITEVARCHUNK, streamwritevarchunk, INT, INT, INTVV, PDOUBLE, INT)
+FCALLSCSUB4 (streamWriteVar, STREAMWRITEVAR, streamwritevar, INT, INT, DOUBLEV, INT)
+FCALLSCSUB4 (streamWriteVarF, STREAMWRITEVARF, streamwritevarf, INT, INT, FLOATV, INT)
+FCALLSCSUB4 (streamReadVar, STREAMREADVAR, streamreadvar, INT, INT, DOUBLEV, PINT)
+FCALLSCSUB4 (streamReadVarF, STREAMREADVARF, streamreadvarf, INT, INT, FLOATV, PINT)
+FCALLSCSUB5 (streamWriteVarSlice, STREAMWRITEVARSLICE, streamwritevarslice, INT, INT, INT, DOUBLEV, INT)
+FCALLSCSUB5 (streamWriteVarSliceF, STREAMWRITEVARSLICEF, streamwritevarslicef, INT, INT, INT, FLOATV, INT)
+FCALLSCSUB5 (streamReadVarSlice, STREAMREADVARSLICE, streamreadvarslice, INT, INT, INT, DOUBLEV, PINT)
+FCALLSCSUB5 (streamReadVarSliceF, STREAMREADVARSLICEF, streamreadvarslicef, INT, INT, INT, FLOATV, PINT)
+FCALLSCSUB5 (streamWriteVarChunk, STREAMWRITEVARCHUNK, streamwritevarchunk, INT, INT, INTVV, DOUBLEV, INT)
 
 /*  STREAM record I/O routines  */
 
 FCALLSCSUB3 (streamDefRecord, STREAMDEFRECORD, streamdefrecord, INT, INT, INT)
 FCALLSCSUB3 (streamInqRecord, STREAMINQRECORD, streaminqrecord, INT, PINT, PINT)
-FCALLSCSUB3 (streamWriteRecord, STREAMWRITERECORD, streamwriterecord, INT, PDOUBLE, INT)
-FCALLSCSUB3 (streamWriteRecordF, STREAMWRITERECORDF, streamwriterecordf, INT, PFLOAT, INT)
-FCALLSCSUB3 (streamReadRecord, STREAMREADRECORD, streamreadrecord, INT, PDOUBLE, PINT)
+FCALLSCSUB3 (streamWriteRecord, STREAMWRITERECORD, streamwriterecord, INT, DOUBLEV, INT)
+FCALLSCSUB3 (streamWriteRecordF, STREAMWRITERECORDF, streamwriterecordf, INT, FLOATV, INT)
+FCALLSCSUB3 (streamReadRecord, STREAMREADRECORD, streamreadrecord, INT, DOUBLEV, PINT)
 FCALLSCSUB2 (streamCopyRecord, STREAMCOPYRECORD, streamcopyrecord, INT, INT)
 
 /*  File driven I/O (may yield better performance than using the streamXXX functions)  */
@@ -69340,6 +71732,7 @@ FCALLSCFUN1 (INT, vlistNumber, VLISTNUMBER, vlistnumber, INT)
 FCALLSCFUN1 (INT, vlistNvars, VLISTNVARS, vlistnvars, INT)
 FCALLSCFUN1 (INT, vlistNgrids, VLISTNGRIDS, vlistngrids, INT)
 FCALLSCFUN1 (INT, vlistNzaxis, VLISTNZAXIS, vlistnzaxis, INT)
+FCALLSCFUN1 (INT, vlistNsubtypes, VLISTNSUBTYPES, vlistnsubtypes, INT)
 FCALLSCSUB2 (vlistDefNtsteps, VLISTDEFNTSTEPS, vlistdefntsteps, INT, INT)
 FCALLSCFUN1 (INT, vlistNtsteps, VLISTNTSTEPS, vlistntsteps, INT)
 FCALLSCFUN1 (INT, vlistGridsizeMax, VLISTGRIDSIZEMAX, vlistgridsizemax, INT)
@@ -69352,6 +71745,8 @@ FCALLSCFUN2 (INT, vlistZaxisIndex, VLISTZAXISINDEX, vlistzaxisindex, INT, INT)
 FCALLSCSUB3 (vlistChangeZaxisIndex, VLISTCHANGEZAXISINDEX, vlistchangezaxisindex, INT, INT, INT)
 FCALLSCSUB3 (vlistChangeZaxis, VLISTCHANGEZAXIS, vlistchangezaxis, INT, INT, INT)
 FCALLSCFUN1 (INT, vlistNrecs, VLISTNRECS, vlistnrecs, INT)
+FCALLSCFUN2 (INT, vlistSubtype, VLISTSUBTYPE, vlistsubtype, INT, INT)
+FCALLSCFUN2 (INT, vlistSubtypeIndex, VLISTSUBTYPEINDEX, vlistsubtypeindex, INT, INT)
 FCALLSCSUB2 (vlistDefTaxis, VLISTDEFTAXIS, vlistdeftaxis, INT, INT)
 FCALLSCFUN1 (INT, vlistInqTaxis, VLISTINQTAXIS, vlistinqtaxis, INT)
 FCALLSCSUB2 (vlistDefTable, VLISTDEFTABLE, vlistdeftable, INT, INT)
@@ -69363,6 +71758,7 @@ FCALLSCFUN1 (INT, vlistInqModel, VLISTINQMODEL, vlistinqmodel, INT)
 
 /*  VLIST VAR routines  */
 
+FCALLSCFUN5 (INT, vlistDefVarTiles, VLISTDEFVARTILES, vlistdefvartiles, INT, INT, INT, INT, INT)
 FCALLSCFUN4 (INT, vlistDefVar, VLISTDEFVAR, vlistdefvar, INT, INT, INT, INT)
 FCALLSCSUB3 (vlistChangeVarGrid, VLISTCHANGEVARGRID, vlistchangevargrid, INT, INT, INT)
 FCALLSCSUB3 (vlistChangeVarZaxis, VLISTCHANGEVARZAXIS, vlistchangevarzaxis, INT, INT, INT)
@@ -69398,6 +71794,7 @@ FCALLSCSUB3 (vlistDefVarTable, VLISTDEFVARTABLE, vlistdefvartable, INT, INT, INT
 FCALLSCFUN2 (INT, vlistInqVarTable, VLISTINQVARTABLE, vlistinqvartable, INT, INT)
 FCALLSCSUB3 (vlistDefVarName, VLISTDEFVARNAME, vlistdefvarname, INT, INT, STRING)
 FCALLSCSUB3 (vlistInqVarName, VLISTINQVARNAME, vlistinqvarname, INT, INT, PSTRING)
+FCALLSCFUN2 (STRING, vlistCopyVarName, VLISTCOPYVARNAME, vlistcopyvarname, INT, INT)
 FCALLSCSUB3 (vlistDefVarStdname, VLISTDEFVARSTDNAME, vlistdefvarstdname, INT, INT, STRING)
 FCALLSCSUB3 (vlistInqVarStdname, VLISTINQVARSTDNAME, vlistinqvarstdname, INT, INT, PSTRING)
 FCALLSCSUB3 (vlistDefVarLongname, VLISTDEFVARLONGNAME, vlistdefvarlongname, INT, INT, STRING)
@@ -69447,11 +71844,11 @@ FCALLSCFUN3 (INT, vlistInqVarIntKey, VLISTINQVARINTKEY, vlistinqvarintkey, INT,
 FCALLSCFUN3 (INT, vlistInqNatts, VLISTINQNATTS, vlistinqnatts, INT, INT, PINT)
 FCALLSCFUN6 (INT, vlistInqAtt, VLISTINQATT, vlistinqatt, INT, INT, INT, PSTRING, PINT, PINT)
 FCALLSCFUN3 (INT, vlistDelAtt, VLISTDELATT, vlistdelatt, INT, INT, STRING)
-FCALLSCFUN6 (INT, vlistDefAttInt, VLISTDEFATTINT, vlistdefattint, INT, INT, STRING, INT, INT, PINT)
-FCALLSCFUN6 (INT, vlistDefAttFlt, VLISTDEFATTFLT, vlistdefattflt, INT, INT, STRING, INT, INT, PDOUBLE)
+FCALLSCFUN6 (INT, vlistDefAttInt, VLISTDEFATTINT, vlistdefattint, INT, INT, STRING, INT, INT, INTV)
+FCALLSCFUN6 (INT, vlistDefAttFlt, VLISTDEFATTFLT, vlistdefattflt, INT, INT, STRING, INT, INT, DOUBLEV)
 FCALLSCFUN5 (INT, vlistDefAttTxt, VLISTDEFATTTXT, vlistdefatttxt, INT, INT, STRING, INT, PPSTRING)
-FCALLSCFUN5 (INT, vlistInqAttInt, VLISTINQATTINT, vlistinqattint, INT, INT, STRING, INT, PINT)
-FCALLSCFUN5 (INT, vlistInqAttFlt, VLISTINQATTFLT, vlistinqattflt, INT, INT, STRING, INT, PDOUBLE)
+FCALLSCFUN5 (INT, vlistInqAttInt, VLISTINQATTINT, vlistinqattint, INT, INT, STRING, INT, INTV)
+FCALLSCFUN5 (INT, vlistInqAttFlt, VLISTINQATTFLT, vlistinqattflt, INT, INT, STRING, INT, DOUBLEV)
 FCALLSCFUN5 (INT, vlistInqAttTxt, VLISTINQATTTXT, vlistinqatttxt, INT, INT, STRING, INT, PPSTRING)
 
 /*  GRID routines  */
@@ -69459,10 +71856,10 @@ FCALLSCFUN5 (INT, vlistInqAttTxt, VLISTINQATTTXT, vlistinqatttxt, INT, INT, STRI
 FCALLSCSUB2 (gridName, GRIDNAME, gridname, INT, PSTRING)
 FCALLSCFUN1 (STRING, gridNamePtr, GRIDNAMEPTR, gridnameptr, INT)
 FCALLSCSUB1 (gridCompress, GRIDCOMPRESS, gridcompress, INT)
-FCALLSCSUB2 (gridDefMaskGME, GRIDDEFMASKGME, griddefmaskgme, INT, PINT)
-FCALLSCFUN2 (INT, gridInqMaskGME, GRIDINQMASKGME, gridinqmaskgme, INT, PINT)
-FCALLSCSUB2 (gridDefMask, GRIDDEFMASK, griddefmask, INT, PINT)
-FCALLSCFUN2 (INT, gridInqMask, GRIDINQMASK, gridinqmask, INT, PINT)
+FCALLSCSUB2 (gridDefMaskGME, GRIDDEFMASKGME, griddefmaskgme, INT, INTV)
+FCALLSCFUN2 (INT, gridInqMaskGME, GRIDINQMASKGME, gridinqmaskgme, INT, INTV)
+FCALLSCSUB2 (gridDefMask, GRIDDEFMASK, griddefmask, INT, INTV)
+FCALLSCFUN2 (INT, gridInqMask, GRIDINQMASK, gridinqmask, INT, INTV)
 FCALLSCSUB3 (gridPrint, GRIDPRINT, gridprint, INT, INT, INT)
 FCALLSCFUN2 (INT, gridCreate, GRIDCREATE, gridcreate, INT, INT)
 FCALLSCSUB1 (gridDestroy, GRIDDESTROY, griddestroy, INT)
@@ -69475,10 +71872,10 @@ FCALLSCSUB2 (gridDefYsize, GRIDDEFYSIZE, griddefysize, INT, INT)
 FCALLSCFUN1 (INT, gridInqYsize, GRIDINQYSIZE, gridinqysize, INT)
 FCALLSCSUB2 (gridDefNP, GRIDDEFNP, griddefnp, INT, INT)
 FCALLSCFUN1 (INT, gridInqNP, GRIDINQNP, gridinqnp, INT)
-FCALLSCSUB2 (gridDefXvals, GRIDDEFXVALS, griddefxvals, INT, PDOUBLE)
-FCALLSCFUN2 (INT, gridInqXvals, GRIDINQXVALS, gridinqxvals, INT, PDOUBLE)
-FCALLSCSUB2 (gridDefYvals, GRIDDEFYVALS, griddefyvals, INT, PDOUBLE)
-FCALLSCFUN2 (INT, gridInqYvals, GRIDINQYVALS, gridinqyvals, INT, PDOUBLE)
+FCALLSCSUB2 (gridDefXvals, GRIDDEFXVALS, griddefxvals, INT, DOUBLEV)
+FCALLSCFUN2 (INT, gridInqXvals, GRIDINQXVALS, gridinqxvals, INT, DOUBLEV)
+FCALLSCSUB2 (gridDefYvals, GRIDDEFYVALS, griddefyvals, INT, DOUBLEV)
+FCALLSCFUN2 (INT, gridInqYvals, GRIDINQYVALS, gridinqyvals, INT, DOUBLEV)
 FCALLSCSUB2 (gridDefXname, GRIDDEFXNAME, griddefxname, INT, STRING)
 FCALLSCSUB2 (gridInqXname, GRIDINQXNAME, gridinqxname, INT, PSTRING)
 FCALLSCSUB2 (gridDefXlongname, GRIDDEFXLONGNAME, griddefxlongname, INT, STRING)
@@ -69546,16 +71943,17 @@ FCALLSCSUB6 (gridInqLcc2, GRIDINQLCC2, gridinqlcc2, INT, PDOUBLE, PDOUBLE, PDOUB
 
 FCALLSCSUB4 (gridDefLaea, GRIDDEFLAEA, griddeflaea, INT, DOUBLE, DOUBLE, DOUBLE)
 FCALLSCSUB4 (gridInqLaea, GRIDINQLAEA, gridinqlaea, INT, PDOUBLE, PDOUBLE, PDOUBLE)
-FCALLSCSUB2 (gridDefArea, GRIDDEFAREA, griddefarea, INT, PDOUBLE)
-FCALLSCSUB2 (gridInqArea, GRIDINQAREA, gridinqarea, INT, PDOUBLE)
+FCALLSCSUB2 (gridDefArea, GRIDDEFAREA, griddefarea, INT, DOUBLEV)
+FCALLSCSUB2 (gridInqArea, GRIDINQAREA, gridinqarea, INT, DOUBLEV)
 FCALLSCFUN1 (INT, gridHasArea, GRIDHASAREA, gridhasarea, INT)
 FCALLSCSUB2 (gridDefNvertex, GRIDDEFNVERTEX, griddefnvertex, INT, INT)
 FCALLSCFUN1 (INT, gridInqNvertex, GRIDINQNVERTEX, gridinqnvertex, INT)
-FCALLSCSUB2 (gridDefXbounds, GRIDDEFXBOUNDS, griddefxbounds, INT, PDOUBLE)
-FCALLSCFUN2 (INT, gridInqXbounds, GRIDINQXBOUNDS, gridinqxbounds, INT, PDOUBLE)
-FCALLSCSUB2 (gridDefYbounds, GRIDDEFYBOUNDS, griddefybounds, INT, PDOUBLE)
-FCALLSCFUN2 (INT, gridInqYbounds, GRIDINQYBOUNDS, gridinqybounds, INT, PDOUBLE)
-FCALLSCSUB2 (gridInqRowlon, GRIDINQROWLON, gridinqrowlon, INT, PINT)
+FCALLSCSUB2 (gridDefXbounds, GRIDDEFXBOUNDS, griddefxbounds, INT, DOUBLEV)
+FCALLSCFUN2 (INT, gridInqXbounds, GRIDINQXBOUNDS, gridinqxbounds, INT, DOUBLEV)
+FCALLSCSUB2 (gridDefYbounds, GRIDDEFYBOUNDS, griddefybounds, INT, DOUBLEV)
+FCALLSCFUN2 (INT, gridInqYbounds, GRIDINQYBOUNDS, gridinqybounds, INT, DOUBLEV)
+FCALLSCSUB3 (gridDefRowlon, GRIDDEFROWLON, griddefrowlon, INT, INT, INTV)
+FCALLSCSUB2 (gridInqRowlon, GRIDINQROWLON, gridinqrowlon, INT, INTV)
 FCALLSCSUB2 (gridChangeType, GRIDCHANGETYPE, gridchangetype, INT, INT)
 FCALLSCSUB2 (gridDefComplexPacking, GRIDDEFCOMPLEXPACKING, griddefcomplexpacking, INT, INT)
 FCALLSCFUN1 (INT, gridInqComplexPacking, GRIDINQCOMPLEXPACKING, gridinqcomplexpacking, INT)
@@ -69570,8 +71968,8 @@ FCALLSCFUN1 (INT, zaxisInqSize, ZAXISINQSIZE, zaxisinqsize, INT)
 FCALLSCFUN1 (INT, zaxisDuplicate, ZAXISDUPLICATE, zaxisduplicate, INT)
 FCALLSCSUB2 (zaxisResize, ZAXISRESIZE, zaxisresize, INT, INT)
 FCALLSCSUB2 (zaxisPrint, ZAXISPRINT, zaxisprint, INT, INT)
-FCALLSCSUB2 (zaxisDefLevels, ZAXISDEFLEVELS, zaxisdeflevels, INT, PDOUBLE)
-FCALLSCSUB2 (zaxisInqLevels, ZAXISINQLEVELS, zaxisinqlevels, INT, PDOUBLE)
+FCALLSCSUB2 (zaxisDefLevels, ZAXISDEFLEVELS, zaxisdeflevels, INT, DOUBLEV)
+FCALLSCSUB2 (zaxisInqLevels, ZAXISINQLEVELS, zaxisinqlevels, INT, DOUBLEV)
 FCALLSCSUB3 (zaxisDefLevel, ZAXISDEFLEVEL, zaxisdeflevel, INT, INT, DOUBLE)
 FCALLSCFUN2 (DOUBLE, zaxisInqLevel, ZAXISINQLEVEL, zaxisinqlevel, INT, INT)
 FCALLSCSUB2 (zaxisDefNlevRef, ZAXISDEFNLEVREF, zaxisdefnlevref, INT, INT)
@@ -69587,23 +71985,27 @@ FCALLSCSUB2 (zaxisInqLongname, ZAXISINQLONGNAME, zaxisinqlongname, INT, PSTRING)
 FCALLSCSUB2 (zaxisDefUnits, ZAXISDEFUNITS, zaxisdefunits, INT, STRING)
 FCALLSCSUB2 (zaxisInqUnits, ZAXISINQUNITS, zaxisinqunits, INT, PSTRING)
 FCALLSCSUB2 (zaxisInqStdname, ZAXISINQSTDNAME, zaxisinqstdname, INT, PSTRING)
+FCALLSCSUB2 (zaxisDefPsName, ZAXISDEFPSNAME, zaxisdefpsname, INT, STRING)
+FCALLSCSUB2 (zaxisInqPsName, ZAXISINQPSNAME, zaxisinqpsname, INT, PSTRING)
 FCALLSCSUB2 (zaxisDefPrec, ZAXISDEFPREC, zaxisdefprec, INT, INT)
 FCALLSCFUN1 (INT, zaxisInqPrec, ZAXISINQPREC, zaxisinqprec, INT)
 FCALLSCSUB2 (zaxisDefPositive, ZAXISDEFPOSITIVE, zaxisdefpositive, INT, INT)
 FCALLSCFUN1 (INT, zaxisInqPositive, ZAXISINQPOSITIVE, zaxisinqpositive, INT)
+FCALLSCSUB1 (zaxisDefScalar, ZAXISDEFSCALAR, zaxisdefscalar, INT)
+FCALLSCFUN1 (INT, zaxisInqScalar, ZAXISINQSCALAR, zaxisinqscalar, INT)
 FCALLSCSUB2 (zaxisDefLtype, ZAXISDEFLTYPE, zaxisdefltype, INT, INT)
 FCALLSCFUN1 (INT, zaxisInqLtype, ZAXISINQLTYPE, zaxisinqltype, INT)
-FCALLSCSUB3 (zaxisDefVct, ZAXISDEFVCT, zaxisdefvct, INT, INT, PDOUBLE)
-FCALLSCSUB2 (zaxisInqVct, ZAXISINQVCT, zaxisinqvct, INT, PDOUBLE)
+FCALLSCSUB3 (zaxisDefVct, ZAXISDEFVCT, zaxisdefvct, INT, INT, DOUBLEV)
+FCALLSCSUB2 (zaxisInqVct, ZAXISINQVCT, zaxisinqvct, INT, DOUBLEV)
 FCALLSCFUN1 (INT, zaxisInqVctSize, ZAXISINQVCTSIZE, zaxisinqvctsize, INT)
-FCALLSCSUB2 (zaxisDefLbounds, ZAXISDEFLBOUNDS, zaxisdeflbounds, INT, PDOUBLE)
-FCALLSCFUN2 (INT, zaxisInqLbounds, ZAXISINQLBOUNDS, zaxisinqlbounds, INT, PDOUBLE)
+FCALLSCSUB2 (zaxisDefLbounds, ZAXISDEFLBOUNDS, zaxisdeflbounds, INT, DOUBLEV)
+FCALLSCFUN2 (INT, zaxisInqLbounds, ZAXISINQLBOUNDS, zaxisinqlbounds, INT, DOUBLEV)
 FCALLSCFUN2 (DOUBLE, zaxisInqLbound, ZAXISINQLBOUND, zaxisinqlbound, INT, INT)
-FCALLSCSUB2 (zaxisDefUbounds, ZAXISDEFUBOUNDS, zaxisdefubounds, INT, PDOUBLE)
-FCALLSCFUN2 (INT, zaxisInqUbounds, ZAXISINQUBOUNDS, zaxisinqubounds, INT, PDOUBLE)
+FCALLSCSUB2 (zaxisDefUbounds, ZAXISDEFUBOUNDS, zaxisdefubounds, INT, DOUBLEV)
+FCALLSCFUN2 (INT, zaxisInqUbounds, ZAXISINQUBOUNDS, zaxisinqubounds, INT, DOUBLEV)
 FCALLSCFUN2 (DOUBLE, zaxisInqUbound, ZAXISINQUBOUND, zaxisinqubound, INT, INT)
-FCALLSCSUB2 (zaxisDefWeights, ZAXISDEFWEIGHTS, zaxisdefweights, INT, PDOUBLE)
-FCALLSCFUN2 (INT, zaxisInqWeights, ZAXISINQWEIGHTS, zaxisinqweights, INT, PDOUBLE)
+FCALLSCSUB2 (zaxisDefWeights, ZAXISDEFWEIGHTS, zaxisdefweights, INT, DOUBLEV)
+FCALLSCFUN2 (INT, zaxisInqWeights, ZAXISINQWEIGHTS, zaxisinqweights, INT, DOUBLEV)
 FCALLSCSUB2 (zaxisChangeType, ZAXISCHANGETYPE, zaxischangetype, INT, INT)
 
 /*  TAXIS routines  */
@@ -69642,6 +72044,7 @@ FCALLSCFUN1 (DOUBLE, taxisInqForecastPeriod, TAXISINQFORECASTPERIOD, taxisinqfor
 FCALLSCSUB2 (taxisDefNumavg, TAXISDEFNUMAVG, taxisdefnumavg, INT, INT)
 FCALLSCFUN1 (INT, taxisInqType, TAXISINQTYPE, taxisinqtype, INT)
 FCALLSCFUN1 (INT, taxisInqNumavg, TAXISINQNUMAVG, taxisinqnumavg, INT)
+FCALLSCFUN1 (STRING, tunitNamePtr, TUNITNAMEPTR, tunitnameptr, INT)
 
 /*  Institut routines  */
 
@@ -69651,11 +72054,12 @@ FCALLSCFUN0 (INT, institutInqNumber, INSTITUTINQNUMBER, institutinqnumber)
 FCALLSCFUN1 (INT, institutInqCenter, INSTITUTINQCENTER, institutinqcenter, INT)
 FCALLSCFUN1 (INT, institutInqSubcenter, INSTITUTINQSUBCENTER, institutinqsubcenter, INT)
 FCALLSCFUN1 (STRING, institutInqNamePtr, INSTITUTINQNAMEPTR, institutinqnameptr, INT)
+FCALLSCFUN1 (STRING, institutInqLongnamePtr, INSTITUTINQLONGNAMEPTR, institutinqlongnameptr, INT)
 
 /*  Model routines  */
 
 FCALLSCFUN3 (INT, modelDef, MODELDEF, modeldef, INT, INT, STRING)
-FCALLSCFUN3 (INT, modelInq, MODELINQ, modelinq, INT, INT, PSTRING)
+FCALLSCFUN3 (INT, modelInq, MODELINQ, modelinq, INT, INT, STRING)
 FCALLSCFUN1 (INT, modelInqInstitut, MODELINQINSTITUT, modelinqinstitut, INT)
 FCALLSCFUN1 (INT, modelInqGribID, MODELINQGRIBID, modelinqgribid, INT)
 FCALLSCFUN1 (STRING, modelInqNamePtr, MODELINQNAMEPTR, modelinqnameptr, INT)
@@ -69666,6 +72070,7 @@ FCALLSCSUB2 (tableWriteC, TABLEWRITEC, tablewritec, STRING, INT)
 FCALLSCSUB2 (tableWrite, TABLEWRITE, tablewrite, STRING, INT)
 FCALLSCFUN1 (INT, tableRead, TABLEREAD, tableread, STRING)
 FCALLSCFUN3 (INT, tableDef, TABLEDEF, tabledef, INT, INT, STRING)
+FCALLSCFUN1 (STRING, tableInqNamePtr, TABLEINQNAMEPTR, tableinqnameptr, INT)
 FCALLSCSUB5 (tableDefEntry, TABLEDEFENTRY, tabledefentry, INT, INT, STRING, STRING, STRING)
 FCALLSCFUN3 (INT, tableInq, TABLEINQ, tableinq, INT, INT, STRING)
 FCALLSCFUN0 (INT, tableInqNumber, TABLEINQNUMBER, tableinqnumber)
@@ -69685,6 +72090,30 @@ FCALLSCFUN2 (STRING, tableInqParUnitsPtr, TABLEINQPARUNITSPTR, tableinqparunitsp
 FCALLSCSUB3 (streamDefHistory, STREAMDEFHISTORY, streamdefhistory, INT, INT, STRING)
 FCALLSCFUN1 (INT, streamInqHistorySize, STREAMINQHISTORYSIZE, streaminqhistorysize, INT)
 FCALLSCSUB2 (streamInqHistoryString, STREAMINQHISTORYSTRING, streaminqhistorystring, INT, PSTRING)
+
+/*  Subtype routines  */
+
+FCALLSCFUN1 (INT, subtypeCreate, SUBTYPECREATE, subtypecreate, INT)
+
+/*  Gives a textual summary of the variable subtype  */
+
+FCALLSCSUB1 (subtypePrint, SUBTYPEPRINT, subtypeprint, INT)
+
+/*  Compares two subtype data structures.  */
+
+FCALLSCFUN2 (INT, subtypeCompare, SUBTYPECOMPARE, subtypecompare, INT, INT)
+FCALLSCFUN1 (INT, subtypeInqSize, SUBTYPEINQSIZE, subtypeinqsize, INT)
+FCALLSCFUN1 (INT, subtypeInqActiveIndex, SUBTYPEINQACTIVEINDEX, subtypeinqactiveindex, INT)
+FCALLSCSUB2 (subtypeDefActiveIndex, SUBTYPEDEFACTIVEINDEX, subtypedefactiveindex, INT, INT)
+
+/*  Generate a "query object" out of a key-value pair.  */
+
+
+/*  Generate an AND-combined "query object" out of two previous
+         query objects.  */
+
+FCALLSCFUN3 (INT, subtypeInqTile, SUBTYPEINQTILE, subtypeinqtile, INT, INT, INT)
+FCALLSCFUN2 (INT, vlistInqVarSubtype, VLISTINQVARSUBTYPE, vlistinqvarsubtype, INT, INT)
 FCALLSCSUB3 (gribapiLibraryVersion, GRIBAPILIBRARYVERSION, gribapilibraryversion, PINT, PINT, PINT)
 
 #endif
diff --git a/libcdi/src/cdipio.h b/libcdi/src/cdipio.h
index e6a9323..4ff825a 100644
--- a/libcdi/src/cdipio.h
+++ b/libcdi/src/cdipio.h
@@ -12,15 +12,23 @@
 
 /* parallel IO IOMode */
 
-#define  PIO_NONE                 0
-#define  PIO_MPI                  1
-#define  PIO_WRITER               2
-#define  PIO_ASYNCH               3
-#define  PIO_FPGUARD              4
+#define PIO_NONE                 0
+#define PIO_MPI                  1
+#define PIO_WRITER               2
+#define PIO_ASYNCH               3
+#define PIO_FPGUARD              4
+#define PIO_MPI_FW_ORDERED       5
+#define PIO_MPI_FW_AT_ALL        6
+#define PIO_MPI_FW_AT_REBLOCK    7
 
-#define  PIO_MINIOMODE                  PIO_NONE
-#define  PIO_MAXIOMODE                  PIO_FPGUARD
-#define  PIO_MINIOMODEWITHSPECIALPROCS  PIO_WRITER
+#define PIO_MINIOMODE PIO_NONE
+#define PIO_MAXIOMODE PIO_MPI_FW_AT_REBLOCK
+
+#define PIO_ROLE_CLIENT 0
+#define PIO_ROLE_COLLECTOR 1
+#define PIO_ROLE_WRITER 2
+#define PIO_ROLE_WRITER_COLLECTOR 3
+#define PIO_ROLE_FPGUARD 4
 
 /* parallel IO routines */
 #include <yaxt.h>
@@ -35,8 +43,10 @@ void cdiPioNoPostCommSetup(void);
 MPI_Comm pioInit(MPI_Comm commSuper, int nProcsIO, int IOMode,
                  int *pioNamespace, float partInflate,
                  void (*postCommSetupActions)(void));
-void     pioWriteTimestep();
-void     cdiPioRDMAProgress();
+/*      cdiPioInit: initialize I/O server processes and communication */
+MPI_Comm cdiPioInit(MPI_Comm commSuper, int confResH, int *pioNamespace);
+void     pioWriteTimestep(void);
+void     cdiPioRDMAProgress(void);
 
 void     streamWriteVarPart    (int streamID, int varID,
                                 const void *data, int nmiss,
@@ -45,5 +55,100 @@ void     streamWriteScatteredVarPart(int streamID, int varID, const void *data,
                                      int numBlocks, const int blocklengths[],
                                      const int displacements[],
                                      int nmiss, Xt_idxlist partDesc);
+/* cdiPioCSRLastN: return role codes appropriate to use the last
+   \textit{nProcsIO} tasks as I/O servers */
+int cdiPioCSRLastN(MPI_Comm commSuper, int IOMode, int nProcsIO);
+
+/* cdiPioCSRFirstN: return role codes appropriate to use the first
+   \textit{nProcsIO} tasks as I/O servers */
+int cdiPioCSRFirstN(MPI_Comm commSuper, int IOMode, int nProcsIO);
+
+/* cdiPioCSRBalanced: return role codes appropriate to use \textit{nProcsIO}
+ * tasks distributed on evenly spaced ranks as I/O servers */
+int cdiPioCSRBalanced(MPI_Comm commSuper, int IOMode, int nProcsIO);
+
+/* cdiPioStr2IOMode: return integer code corresponding to string
+ * representation of mode or -1 if no match was found */
+int cdiPioStr2IOMode(const char *modeStr);
+
+/* cdiPioStr2IOMode: return string corresponding to integer
+ * code of mode or empty string if code is not valid */
+const char *
+cdiPioIOMode2Str(int IOMode);
+
+/* cdiPioConfCreate: create new configuration object and return its handle */
+int cdiPioConfCreate(void);
+
+/* cdiPioConfDestroy: delete configuration object */
+void cdiPioConfDestroy(int confResH);
+
+/* cdiPioConfSetPartInflate: set partition imbalance attribute of
+ * configuration object */
+void cdiPioConfSetPartInflate(int confResH, float partInflate);
+
+/* cdiPioConfGetPartInflate: query partition imbalance attribute of
+ * configuration object */
+float cdiPioConfGetPartInflate(int confResH);
+
+/* cdiPioConfSetIOMode: set IOMode attribute of configuration object */
+void cdiPioConfSetIOMode(int confResH, int IOMode);
+
+/* cdiPioConfGetIOMode: query IOMode attribute of configuration object */
+int cdiPioConfGetIOMode(int confResH);
+
+/* cdiPioConfSetCSRole: set role attribute of configuration object */
+void cdiPioConfSetCSRole(int confResH, int CSRole);
+
+/* cdiPioConfGetCSRole: query role attribute of configuration object */
+int cdiPioConfGetCSRole(int confResH);
+
+/* cdiPioConfSetPostCommSetupActions: set function to be called after
+ * setup of client/server communications of configuration object */
+void cdiPioConfSetPostCommSetupActions(int confResH,
+                                       void (*postCommSetupActions)(void));
+
+/* cdiPioConfGetPostCommSetupActions: get function to be called after
+ * setup of client/server communications from configuration object */
+void (*cdiPioConfGetPostCommSetupActions(int confResH))(void);
+
+/* cdiPioConfSetLargePageAlign should block buffer be aligned to
+ * large pages instead of normal pages? */
+void cdiPioConfSetLargePageAlign(int confResH, int largePageAlign);
+
+/* cdiPioConfSetLargePageAlign: should block buffer be aligned to
+ * large pages instead of normal pages? */
+int cdiPioConfGetLargePageAlign(int confResH);
+
+/* cdiPioConfSetRedistCache: set doCache to anything non-zero if data
+ * for internal data exchanges is to be cached. This makes sense when
+ * the data passed via streamWriteVarPart or streamWriteScatteredVarPart
+ * is always decomposed statically using the same partitioning
+ * description objects and the sequence of calls to streamWriteVarPart
+ * or streamWriteScatteredVarPart for a stream matches the sequence
+ * of the previous sequence (divided by pioWriteTimestep) */
+void cdiPioConfSetRedistCache(int confResH, int doCache);
+
+/* cdiPioConfSetRedistCache: will data for internal data exchanges
+ * be cached? */
+int cdiPioConfGetRedistCache(int confResH);
+
+/* cdiPioConfSetXmapNew: set method to compute part intersections,
+ * defaults to xt_xmap_dist_dir_new */
+void cdiPioConfSetXmapNew(int confResH,
+                          Xt_xmap (*xmap_new)(Xt_idxlist src_idxlist,
+                                              Xt_idxlist dst_idxlist,
+                                              MPI_Comm comm));
+
+/* cdiPioConfSetXmapNew: get method to compute part intersections */
+Xt_xmap (*cdiPioConfGetXmapNew(int confResH))(Xt_idxlist src_idxlist,
+                                              Xt_idxlist dst_idxlist,
+                                              MPI_Comm comm);
+/* convert index lists to stripes prior to intersection computation,
+ * defaults to true */
+void cdiPioConfSetStripeConversion(int confResH, int doStripify);
+
+/* are index lists of parts converted stripes before being passed
+ * to the xmap constructor? */
+int cdiPioConfGetStripeConversion(int confResH);
 
 #endif
diff --git a/libcdi/src/cdipio.inc b/libcdi/src/cdipio.inc
index 52e90ac..d6afa53 100644
--- a/libcdi/src/cdipio.inc
+++ b/libcdi/src/cdipio.inc
@@ -1,10 +1,10 @@
 ! This file was automatically generated, don't edit!
 !
-! Fortran interface for CDI library version 1.6.4
+! Fortran interface for CDI library version 1.7.0
 !
 ! Author:
 ! -------
-! Uwe Schulzweida, MPI-MET, Hamburg,   November 2014
+! Uwe Schulzweida, MPI-MET, Hamburg,   October 2015
 !
 
 !
@@ -20,6 +20,22 @@
       PARAMETER (PIO_ASYNCH             =  3)
       INTEGER    PIO_FPGUARD           
       PARAMETER (PIO_FPGUARD            =  4)
+      INTEGER    PIO_MPI_FW_ORDERED    
+      PARAMETER (PIO_MPI_FW_ORDERED     =  5)
+      INTEGER    PIO_MPI_FW_AT_ALL     
+      PARAMETER (PIO_MPI_FW_AT_ALL      =  6)
+      INTEGER    PIO_MPI_FW_AT_REBLOCK 
+      PARAMETER (PIO_MPI_FW_AT_REBLOCK  =  7)
+      INTEGER    PIO_ROLE_CLIENT       
+      PARAMETER (PIO_ROLE_CLIENT        =  0)
+      INTEGER    PIO_ROLE_COLLECTOR    
+      PARAMETER (PIO_ROLE_COLLECTOR     =  1)
+      INTEGER    PIO_ROLE_WRITER       
+      PARAMETER (PIO_ROLE_WRITER        =  2)
+      INTEGER    PIO_ROLE_WRITER_COLLECTOR
+      PARAMETER (PIO_ROLE_WRITER_COLLECTOR =  3)
+      INTEGER    PIO_ROLE_FPGUARD      
+      PARAMETER (PIO_ROLE_FPGUARD       =  4)
 !
 !  parallel IO routines
 !
@@ -44,6 +60,12 @@
 !                                     PROCEDURE       postCommSetupActions)
       EXTERNAL        pioInit
 
+      INTEGER         cdiPioInit
+!                                    (INTEGER         commSuper,
+!                                     INTEGER         confResH,
+!                                     INTEGER         pioNamespace)
+      EXTERNAL        cdiPioInit
+
 !                     pioWriteTimestep
       EXTERNAL        pioWriteTimestep
 
@@ -63,9 +85,109 @@
 !                                     INTEGER         varID,
 !                                     CHOICE          data,
 !                                     INTEGER         numBlocks,
-!                                     INTEGER         blocklengths,
-!                                     INTEGER         displacements,
+!                                     INTEGER         blocklengths(*),
+!                                     INTEGER         displacements(*),
 !                                     INTEGER         nmiss,
 !                                     TYPE(XT_IDXLIST)partDesc)
       EXTERNAL        streamWriteScatteredVarPart
 
+      INTEGER         cdiPioCSRLastN
+!                                    (INTEGER         commSuper,
+!                                     INTEGER         IOMode,
+!                                     INTEGER         nProcsIO)
+      EXTERNAL        cdiPioCSRLastN
+
+      INTEGER         cdiPioCSRFirstN
+!                                    (INTEGER         commSuper,
+!                                     INTEGER         IOMode,
+!                                     INTEGER         nProcsIO)
+      EXTERNAL        cdiPioCSRFirstN
+
+      INTEGER         cdiPioCSRBalanced
+!                                    (INTEGER         commSuper,
+!                                     INTEGER         IOMode,
+!                                     INTEGER         nProcsIO)
+      EXTERNAL        cdiPioCSRBalanced
+
+      INTEGER         cdiPioStr2IOMode
+!                                    (CHARACTER*(*)   modeStr)
+      EXTERNAL        cdiPioStr2IOMode
+
+      INTEGER         cdiPioConfCreate
+      EXTERNAL        cdiPioConfCreate
+
+!                     cdiPioConfDestroy
+!                                    (INTEGER         confResH)
+      EXTERNAL        cdiPioConfDestroy
+
+!                     cdiPioConfSetPartInflate
+!                                    (INTEGER         confResH,
+!                                     REAL            partInflate)
+      EXTERNAL        cdiPioConfSetPartInflate
+
+      REAL            cdiPioConfGetPartInflate
+!                                    (INTEGER         confResH)
+      EXTERNAL        cdiPioConfGetPartInflate
+
+!                     cdiPioConfSetIOMode
+!                                    (INTEGER         confResH,
+!                                     INTEGER         IOMode)
+      EXTERNAL        cdiPioConfSetIOMode
+
+      INTEGER         cdiPioConfGetIOMode
+!                                    (INTEGER         confResH)
+      EXTERNAL        cdiPioConfGetIOMode
+
+!                     cdiPioConfSetCSRole
+!                                    (INTEGER         confResH,
+!                                     INTEGER         CSRole)
+      EXTERNAL        cdiPioConfSetCSRole
+
+      INTEGER         cdiPioConfGetCSRole
+!                                    (INTEGER         confResH)
+      EXTERNAL        cdiPioConfGetCSRole
+
+!                     cdiPioConfSetPostCommSetupActions
+!                                    (INTEGER         confResH,
+!                                     PROCEDURE       postCommSetupActions)
+      EXTERNAL        cdiPioConfSetPostCommSetupActions
+
+!
+!  cdiPioConfSetLargePageAlign should block buffer be aligned to
+!  large pages instead of normal pages?
+!
+!                     cdiPioConfSetLargePageAlign
+!                                    (INTEGER         confResH,
+!                                     INTEGER         largePageAlign)
+      EXTERNAL        cdiPioConfSetLargePageAlign
+
+      INTEGER         cdiPioConfGetLargePageAlign
+!                                    (INTEGER         confResH)
+      EXTERNAL        cdiPioConfGetLargePageAlign
+
+!                     cdiPioConfSetRedistCache
+!                                    (INTEGER         confResH,
+!                                     INTEGER         doCache)
+      EXTERNAL        cdiPioConfSetRedistCache
+
+      INTEGER         cdiPioConfGetRedistCache
+!                                    (INTEGER         confResH)
+      EXTERNAL        cdiPioConfGetRedistCache
+
+!
+!  convert index lists to stripes prior to intersection computation,
+!  defaults to true
+!
+!                     cdiPioConfSetStripeConversion
+!                                    (INTEGER         confResH,
+!                                     INTEGER         doStripify)
+      EXTERNAL        cdiPioConfSetStripeConversion
+
+!
+!  are index lists of parts converted stripes before being passed
+!  to the xmap constructor?
+!
+      INTEGER         cdiPioConfGetStripeConversion
+!                                    (INTEGER         confResH)
+      EXTERNAL        cdiPioConfGetStripeConversion
+
diff --git a/libcdi/src/cdipioFortran.c b/libcdi/src/cdipioFortran.c
index ffc8f14..522faab 100644
--- a/libcdi/src/cdipioFortran.c
+++ b/libcdi/src/cdipioFortran.c
@@ -34,6 +34,13 @@ static int pioInit_fwrap(int commSuper, int nProcsIO, int IOMode, int *pioNamesp
   return MPI_Comm_c2f(v);
 }
 FCALLSCFUN6 (INT, pioInit_fwrap, PIOINIT, pioinit, INT, INT, INT, PINT, FLOAT, ROUTINE)
+static int cdiPioInit_fwrap(int commSuper, int confResH, int *pioNamespace)
+{
+  MPI_Comm v;
+  v = cdiPioInit(MPI_Comm_f2c(commSuper), confResH, pioNamespace);
+  return MPI_Comm_c2f(v);
+}
+FCALLSCFUN3 (INT, cdiPioInit_fwrap, CDIPIOINIT, cdipioinit, INT, INT, PINT)
 FCALLSCSUB0 (pioWriteTimestep, PIOWRITETIMESTEP, piowritetimestep)
 FCALLSCSUB0 (cdiPioRDMAProgress, CDIPIORDMAPROGRESS, cdipiordmaprogress)
 static void streamWriteVarPart_fwrap(int streamID, int varID, const void *data, int nmiss, void *partDesc)
@@ -46,5 +53,57 @@ static void streamWriteScatteredVarPart_fwrap(int streamID, int varID, const voi
   streamWriteScatteredVarPart(streamID, varID, data, numBlocks, blocklengths, displacements, nmiss, (*(Xt_idxlist *)partDesc));
 }
 FCALLSCSUB8 (streamWriteScatteredVarPart_fwrap, STREAMWRITESCATTEREDVARPART, streamwritescatteredvarpart, INT, INT, PVOID, INT, INTV, INTV, INT, PVOID)
+static int cdiPioCSRLastN_fwrap(int commSuper, int IOMode, int nProcsIO)
+{
+  int v;
+  v = cdiPioCSRLastN(MPI_Comm_f2c(commSuper), IOMode, nProcsIO);
+  return v;
+}
+FCALLSCFUN3 (INT, cdiPioCSRLastN_fwrap, CDIPIOCSRLASTN, cdipiocsrlastn, INT, INT, INT)
+static int cdiPioCSRFirstN_fwrap(int commSuper, int IOMode, int nProcsIO)
+{
+  int v;
+  v = cdiPioCSRFirstN(MPI_Comm_f2c(commSuper), IOMode, nProcsIO);
+  return v;
+}
+FCALLSCFUN3 (INT, cdiPioCSRFirstN_fwrap, CDIPIOCSRFIRSTN, cdipiocsrfirstn, INT, INT, INT)
+static int cdiPioCSRBalanced_fwrap(int commSuper, int IOMode, int nProcsIO)
+{
+  int v;
+  v = cdiPioCSRBalanced(MPI_Comm_f2c(commSuper), IOMode, nProcsIO);
+  return v;
+}
+FCALLSCFUN3 (INT, cdiPioCSRBalanced_fwrap, CDIPIOCSRBALANCED, cdipiocsrbalanced, INT, INT, INT)
+FCALLSCFUN1 (INT, cdiPioStr2IOMode, CDIPIOSTR2IOMODE, cdipiostr2iomode, STRING)
+FCALLSCFUN0 (INT, cdiPioConfCreate, CDIPIOCONFCREATE, cdipioconfcreate)
+FCALLSCSUB1 (cdiPioConfDestroy, CDIPIOCONFDESTROY, cdipioconfdestroy, INT)
+FCALLSCSUB2 (cdiPioConfSetPartInflate, CDIPIOCONFSETPARTINFLATE, cdipioconfsetpartinflate, INT, FLOAT)
+FCALLSCFUN1 (FLOAT, cdiPioConfGetPartInflate, CDIPIOCONFGETPARTINFLATE, cdipioconfgetpartinflate, INT)
+FCALLSCSUB2 (cdiPioConfSetIOMode, CDIPIOCONFSETIOMODE, cdipioconfsetiomode, INT, INT)
+FCALLSCFUN1 (INT, cdiPioConfGetIOMode, CDIPIOCONFGETIOMODE, cdipioconfgetiomode, INT)
+FCALLSCSUB2 (cdiPioConfSetCSRole, CDIPIOCONFSETCSROLE, cdipioconfsetcsrole, INT, INT)
+FCALLSCFUN1 (INT, cdiPioConfGetCSRole, CDIPIOCONFGETCSROLE, cdipioconfgetcsrole, INT)
+
+#undef ROUTINE_2
+#define ROUTINE_2 (void (*)(void))
+FCALLSCSUB2 (cdiPioConfSetPostCommSetupActions, CDIPIOCONFSETPOSTCOMMSETUPACTIONS, cdipioconfsetpostcommsetupactions, INT, ROUTINE)
+
+/*  cdiPioConfSetLargePageAlign should block buffer be aligned to
+ * large pages instead of normal pages?  */
+
+FCALLSCSUB2 (cdiPioConfSetLargePageAlign, CDIPIOCONFSETLARGEPAGEALIGN, cdipioconfsetlargepagealign, INT, INT)
+FCALLSCFUN1 (INT, cdiPioConfGetLargePageAlign, CDIPIOCONFGETLARGEPAGEALIGN, cdipioconfgetlargepagealign, INT)
+FCALLSCSUB2 (cdiPioConfSetRedistCache, CDIPIOCONFSETREDISTCACHE, cdipioconfsetredistcache, INT, INT)
+FCALLSCFUN1 (INT, cdiPioConfGetRedistCache, CDIPIOCONFGETREDISTCACHE, cdipioconfgetredistcache, INT)
+
+/*  convert index lists to stripes prior to intersection computation,
+ * defaults to true  */
+
+FCALLSCSUB2 (cdiPioConfSetStripeConversion, CDIPIOCONFSETSTRIPECONVERSION, cdipioconfsetstripeconversion, INT, INT)
+
+/*  are index lists of parts converted stripes before being passed
+ * to the xmap constructor?  */
+
+FCALLSCFUN1 (INT, cdiPioConfGetStripeConversion, CDIPIOCONFGETSTRIPECONVERSION, cdipioconfgetstripeconversion, INT)
 
 #endif
diff --git a/libcdi/src/cfortran.h b/libcdi/src/cfortran.h
index a6316f8..275b8cf 100644
--- a/libcdi/src/cfortran.h
+++ b/libcdi/src/cfortran.h
@@ -1,10 +1,6 @@
-/* cfortran.h  4.3 */
+/* cfortran.h  4.4 */
 /* http://www-zeus.desy.de/~burow/cfortran/                   */
-/* Burkhard Burow  burow at desy.de                 1990 - 2001. */
-
-/* 02/12/2002 Uwe Schulzweida : UXP Fortran support           */
-/* 02/05/2003 Uwe Schulzweida : Linux Fortran support on i386 */
-/* 09/09/2005 Uwe Schulzweida : Linux Fortran support on ia64 */
+/* Burkhard Burow  burow at desy.de                 1990 - 2002. */
 
 #ifndef __CFORTRAN_LOADED
 #define __CFORTRAN_LOADED
@@ -15,11 +11,108 @@
    MODIFYING, COPYING AND DISTRIBUTING THE CFORTRAN.H PACKAGE.
 */
 
+/* THIS PACKAGE, I.E. CFORTRAN.H, THIS DOCUMENT, AND THE CFORTRAN.H EXAMPLE
+PROGRAMS ARE PROPERTY OF THE AUTHOR WHO RESERVES ALL RIGHTS. THIS PACKAGE AND
+THE CODE IT PRODUCES MAY BE FREELY DISTRIBUTED WITHOUT FEES, SUBJECT
+(AT YOUR CHOICE) EITHER TO THE GNU LIBRARY GENERAL PUBLIC LICENSE
+AT http://www.gnu.org/licenses/lgpl.html OR TO THE FOLLOWING RESTRICTIONS:
+- YOU MUST ACCOMPANY ANY COPIES OR DISTRIBUTION WITH THIS (UNALTERED) NOTICE.
+- YOU MAY NOT RECEIVE MONEY FOR THE DISTRIBUTION OR FOR ITS MEDIA 
+  (E.G. TAPE, DISK, COMPUTER, PAPER.)
+- YOU MAY NOT PREVENT OTHERS FROM COPYING IT FREELY.
+- YOU MAY NOT DISTRIBUTE MODIFIED VERSIONS WITHOUT CLEARLY DOCUMENTING YOUR
+  CHANGES AND NOTIFYING THE AUTHOR.
+- YOU MAY NOT MISREPRESENTED THE ORIGIN OF THIS SOFTWARE, EITHER BY EXPLICIT
+  CLAIM OR BY OMISSION.
+
+THE INTENT OF THE ABOVE TERMS IS TO ENSURE THAT THE CFORTRAN.H PACKAGE NOT BE
+USED FOR PROFIT MAKING ACTIVITIES UNLESS SOME ROYALTY ARRANGEMENT IS ENTERED
+INTO WITH ITS AUTHOR.
+              
+THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER
+EXPRESSED OR IMPLIED. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+SOFTWARE IS WITH YOU. SHOULD THE SOFTWARE PROVE DEFECTIVE, YOU ASSUME THE COST
+OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. THE AUTHOR IS NOT RESPONSIBLE
+FOR ANY SUPPORT OR SERVICE OF THE CFORTRAN.H PACKAGE.
+
+                                              Burkhard Burow 
+                                              burow at desy.de
+*/
+
+/* The following modifications were made by the authors of CFITSIO or by me. 
+ * They are flagged below with CFITSIO, the author's initials, or KMCCARTY.
+ * PDW = Peter Wilson
+ * DM  = Doug Mink
+ * LEB = Lee E Brotzman
+ * MR  = Martin Reinecke
+ * WDP = William D Pence
+ * BR  = Bastien ROUCARIES
+ * -- Kevin McCarty, for Debian (19 Dec. 2005) */
+
+/*******
+   Modifications:
+      Oct 1997: Changed symbol name extname to appendus (PDW/HSTX)
+                (Conflicted with a common variable name in FTOOLS)
+      Nov 1997: If g77Fortran defined, also define f2cFortran (PDW/HSTX)
+      Feb 1998: Let VMS see the NUM_ELEMS code. Lets programs treat
+                single strings as vectors with single elements
+      Nov 1999: If macintoxh defined, also define f2cfortran (for Mac OS-X)
+      Apr 2000: If WIN32 defined, also define PowerStationFortran and
+                VISUAL_CPLUSPLUS (Visual C++)
+      Jun 2000: If __GNUC__ and linux defined, also define f2cFortran
+                (linux/gcc environment detection)
+      Apr 2002: If __CYGWIN__ is defined, also define f2cFortran
+      Nov 2002: If __APPLE__ defined, also define f2cfortran (for Mac OS-X)
+
+      Nov 2003: If __INTEL_COMPILER or INTEL_COMPILER defined, also define
+                f2cFortran (KMCCARTY)
+      Dec 2005: If f2cFortran is defined, enforce REAL functions in FORTRAN
+                returning "double" in C.  This was one of the items on
+		Burkhard's TODO list. (KMCCARTY)
+      Dec 2005: Modifications to support 8-byte integers. (MR)
+		USE AT YOUR OWN RISK!
+      Feb 2006  Added logic to typedef the symbol 'LONGLONG' to an appropriate
+                intrinsic 8-byte integer datatype  (WDP)
+      Apr 2006: Modifications to support gfortran (and g77 with -fno-f2c flag)
+                since by default it returns "float" for FORTRAN REAL function.
+                (KMCCARTY)
+      May 2008: Revert commenting out of "extern" in COMMON_BLOCK_DEF macro.
+		Add braces around do-nothing ";" in 3 empty while blocks to
+		get rid of compiler warnings.  Thanks to ROOT developers
+		Jacek Holeczek and Rene Brun for these suggestions. (KMCCARTY)
+      Aug 2008: If __GNUC__ is defined and no FORTRAN compiler is specified
+		via a #define or -D, default to gfortran behavior rather than
+		g77 behavior. (KMCCARTY)
+      Oct 2009: Add warning if guessing default fortran. Move g77 above guessing bloc
+ *******/
+
 /* 
   Avoid symbols already used by compilers and system *.h:
   __ - OSF1 zukal06 V3.0 347 alpha, cc -c -std1 cfortest.c
 
- */
+*/
+
+/* 
+   Determine what 8-byte integer data type is available.
+  'long long' is now supported by most compilers, but older
+  MS Visual C++ compilers before V7.0 use '__int64' instead. (WDP)
+*/
+
+#ifndef LONGLONG_TYPE   /* this may have been previously defined */
+#if defined(_MSC_VER)   /* Microsoft Visual C++ */
+
+#if (_MSC_VER < 1300)   /* versions earlier than V7.0 do not have 'long long' */
+    typedef __int64 LONGLONG;
+#else                   /* newer versions do support 'long long' */
+    typedef long long LONGLONG; 
+#endif
+
+#else
+    typedef long long LONGLONG; 
+#endif
+
+#define LONGLONG_TYPE
+#endif  
 
 
 /* First prepare for the C compiler. */
@@ -64,7 +157,6 @@
 #define __CF__APOLLO67 /* __STDCPP__ is in Apollo 6.8 (i.e. ANSI) and onwards */
 #endif
 #endif
-#include <limits.h>    /* LONG_MAX */
 
 #if !defined(__GNUC__) && !defined(__sun) && (defined(sun)||defined(VAXUltrix)||defined(lynx))
 #define __CF__KnR     /* Sun, LynxOS and VAX Ultrix cc only supports K&R.     */
@@ -80,7 +172,13 @@ only C calling FORTRAN subroutines will work using K&R style.*/
 
 /* Remainder of cfortran.h depends on the Fortran compiler. */
 
-#if (defined(CLIPPERFortran) || defined(pgiFortran)) && !defined(f2cFortran)
+/* 11/29/2003 (KMCCARTY): add *INTEL_COMPILER symbols here */
+/* 04/05/2006 (KMCCARTY): add gFortran symbol here */
+#if defined(CLIPPERFortran) || defined(pgiFortran) || defined(__INTEL_COMPILER) || defined(INTEL_COMPILER) || defined(gFortran)
+#define f2cFortran
+#endif
+
+#if defined(g77Fortran)                        /* 11/03/97 PDW (CFITSIO) */
 #define f2cFortran
 #endif
 
@@ -89,14 +187,8 @@ only C calling FORTRAN subroutines will work using K&R style.*/
 #if !(defined(NAGf90Fortran)||defined(f2cFortran)||defined(hpuxFortran)||defined(apolloFortran)||defined(sunFortran)||defined(IBMR2Fortran)||defined(CRAYFortran))
 #if !(defined(mipsFortran)||defined(DECFortran)||defined(vmsFortran)||defined(CONVEXFortran)||defined(PowerStationFortran)||defined(AbsoftUNIXFortran)||defined(AbsoftProFortran)||defined(SXFortran))
 /* If no Fortran compiler is given, we choose one for the machines we know.   */
-#if defined(__linux__) && defined(__i386__)
-#define f2cFortran
-#endif
-#if defined(__linux__) && defined(__ia64__)
-#define f2cFortran
-#endif
-#if defined(__linux__) && defined(__x86_64__)
-#define f2cFortran
+#if defined(__GNUC__) || defined(WIN32) /* 10/2009 BR: warm if guess */
+#warning "Please specify the fortran compiler using -D flags. Try to guess the compiler used"
 #endif
 #if defined(lynx) || defined(VAXUltrix)
 #define f2cFortran    /* Lynx:      Only support f2c at the moment.
@@ -104,6 +196,28 @@ only C calling FORTRAN subroutines will work using K&R style.*/
                            Support f2c or f77 with gcc, vcc with f2c. 
                            f77 with vcc works, missing link magic for f77 I/O.*/
 #endif
+/* 04/13/00 DM (CFITSIO): Add these lines for NT */
+/*   with PowerStationFortran and and Visual C++ */
+#if defined(WIN32) && !defined(__CYGWIN__)
+#define PowerStationFortran   
+#define VISUAL_CPLUSPLUS
+#endif
+#if        defined(__CYGWIN__)                 /* 04/11/02 LEB (CFITSIO) */
+#define       f2cFortran 
+#define	      gFortran /* 8/26/08 (KMCCARTY) */
+#endif
+#if        defined(__GNUC__) && defined(linux) /* 06/21/00 PDW (CFITSIO) */
+#define       f2cFortran 
+#define	      gFortran /* 8/26/08 (KMCCARTY) */
+#endif
+#if defined(macintosh)                         /* 11/1999 (CFITSIO) */
+#define f2cFortran
+#define	      gFortran /* 8/26/08 (KMCCARTY) */
+#endif
+#if defined(__APPLE__)                         /* 11/2002 (CFITSIO) */
+#define f2cFortran
+#define	      gFortran /* 8/26/08 (KMCCARTY) */
+#endif
 #if defined(__hpux)             /* 921107: Use __hpux instead of __hp9000s300 */
 #define       hpuxFortran       /*         Should also allow hp9000s7/800 use.*/
 #endif
@@ -122,9 +236,6 @@ only C calling FORTRAN subroutines will work using K&R style.*/
 #if        defined(_SX)
 #define               SXFortran
 #endif
-#if        defined(__uxp__)
-#define               UXPFortran
-#endif
 #if         defined(mips) || defined(__mips)
 #define             mipsFortran
 #endif
@@ -145,9 +256,10 @@ only C calling FORTRAN subroutines will work using K&R style.*/
 
 /* Split #if into 2 because some HP-UX can't handle long #if */
 #if !(defined(NAGf90Fortran)||defined(f2cFortran)||defined(hpuxFortran)||defined(apolloFortran)||defined(sunFortran)||defined(IBMR2Fortran)||defined(CRAYFortran))
-#if !(defined(mipsFortran)||defined(DECFortran)||defined(vmsFortran)||defined(CONVEXFortran)||defined(PowerStationFortran)||defined(AbsoftUNIXFortran)||defined(AbsoftProFortran)||defined(SXFortran)||defined(UXPFortran))
+#if !(defined(mipsFortran)||defined(DECFortran)||defined(vmsFortran)||defined(CONVEXFortran)||defined(PowerStationFortran)||defined(AbsoftUNIXFortran)||defined(AbsoftProFortran)||defined(SXFortran))
 /* If your compiler barfs on ' #error', replace # with the trigraph for #     */
  #error "cfortran.h:  Can't find your environment among:\
+    - GNU gcc (gfortran) on Linux.                                       \
     - MIPS cc and f77 2.0. (e.g. Silicon Graphics, DECstations, ...)     \
     - IBM AIX XL C and FORTRAN Compiler/6000 Version 01.01.0000.0000     \
     - VAX   VMS CC 3.1 and FORTRAN 5.4.                                  \
@@ -164,11 +276,14 @@ only C calling FORTRAN subroutines will work using K&R style.*/
     - VAXUltrix: vcc,cc or gcc with f2c. gcc or cc with f77.             \
     -            f77 with vcc works; but missing link magic for f77 I/O. \
     -            NO fort. None of gcc, cc or vcc generate required names.\
-    - f2c    : Use #define    f2cFortran, or cc -Df2cFortran             \
+    - f2c/g77:   Use #define    f2cFortran, or cc -Df2cFortran           \
+    - gfortran:  Use #define    gFortran,   or cc -DgFortran             \
+                 (also necessary for g77 with -fno-f2c option)           \
     - NAG f90: Use #define NAGf90Fortran, or cc -DNAGf90Fortran          \
     - Absoft UNIX F77: Use #define AbsoftUNIXFortran or cc -DAbsoftUNIXFortran \
     - Absoft Pro Fortran: Use #define AbsoftProFortran \
-    - Portland Group Fortran: Use #define pgiFortran"
+    - Portland Group Fortran: Use #define pgiFortran \
+    - Intel Fortran: Use #define INTEL_COMPILER"
 /* Compiler must throw us out at this point! */
 #endif
 #endif
@@ -181,7 +296,8 @@ only C calling FORTRAN subroutines will work using K&R style.*/
 
 /* Throughout cfortran.h we use: UN = Uppercase Name.  LN = Lowercase Name.   */
 
-#if defined(f2cFortran) || defined(NAGf90Fortran) || defined(DECFortran) || defined(mipsFortran) || defined(apolloFortran) || defined(sunFortran) || defined(CONVEXFortran) || defined(SXFortran) || defined(UXPFortran) || defined(extname)
+/* "extname" changed to "appendus" below (CFITSIO) */
+#if defined(f2cFortran) || defined(NAGf90Fortran) || defined(DECFortran) || defined(mipsFortran) || defined(apolloFortran) || defined(sunFortran) || defined(CONVEXFortran) || defined(SXFortran) || defined(appendus)
 #define CFC_(UN,LN)            _(LN,_)      /* Lowercase FORTRAN symbols.     */
 #define orig_fcallsc(UN,LN)    CFC_(UN,LN)
 #else 
@@ -245,18 +361,6 @@ only C calling FORTRAN subroutines will work using K&R style.*/
 #endif
 #endif
 
-/* INT64_T for 8 byte integers */
-#if ! defined (LONG_MAX)
-#  error LONG_MAX undefined
-#endif
-
-#undef  INT64_T
-#if LONG_MAX > 2147483647L
-#  define INT64_T long int
-#else
-#  define INT64_T long long int       /* c.f. typedef of int64_t in <stdint.h> */
-#endif
-
 #ifdef CRAYFortran
 #ifdef _CRAY
 #include <fortran.h>
@@ -372,7 +476,7 @@ Apollo                                           : neg.   = TRUE, else FALSE.
 [DECFortran for Ultrix RISC is also called f77 but is the same as VAX/VMS.]   
 [MIPS f77 treats .eqv./.neqv. as .eq./.ne. and hence requires LOGICAL_STRICT.]*/
 
-#if defined(NAGf90Fortran) || defined(f2cFortran) || defined(mipsFortran) || defined(PowerStationFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran) || defined(AbsoftProFortran) || defined(SXFortran) || defined(UXPFortran)
+#if defined(NAGf90Fortran) || defined(f2cFortran) || defined(mipsFortran) || defined(PowerStationFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran) || defined(AbsoftProFortran) || defined(SXFortran)
 /* SX/PowerStationFortran have 0 and 1 defined, others are neither T nor F.   */
 /* hpuxFortran800 has 0 and 0x01000000 defined. Others are unknown.           */
 #define LOGICAL_STRICT      /* Other Fortran have .eqv./.neqv. == .eq./.ne.   */
@@ -474,16 +578,6 @@ for (i=0; i<sizeofcstr/elem_len; i++) {
 } return cstr; }
 
 /* kill the trailing char t's in string s. */
-#if !defined(GNUC_PUSH_POP) && defined(__GNUC__) && !defined(__ICC) && !defined(__clang__)
-#if (__GNUC__ >= 4) && (__GNUC_MINOR__ >= 4)
-#define GNUC_PUSH_POP
-#endif
-#endif
-
-#if defined(GNUC_PUSH_POP)
-#pragma GCC push_options
-#pragma GCC optimize ("O2")
-#endif
 #ifndef __CF__KnR
 static char *kill_trailing(char *s, char t)
 #else
@@ -492,13 +586,13 @@ static char *kill_trailing(      s,      t) char *s; char t;
 {char *e; 
 e = s + strlen(s);
 if (e>s) {                           /* Need this to handle NULL string.*/
-  while (e>s && *--e==t);            /* Don't follow t's past beginning. */
+  while (e>s && *--e==t) {;}         /* Don't follow t's past beginning. */
   e[*e==t?0:1] = '\0';               /* Handle s[0]=t correctly.       */
 } return s; }
-#if defined(GNUC_PUSH_POP)
-#pragma GCC pop_options
-#endif
 
+#ifndef __CF__KnR
+static int num_elem(char *strv, unsigned elem_len, int term_char, int num_term);
+#endif
 /* kill_trailingn(s,t,e) will kill the trailing t's in string s. e normally 
 points to the terminating '\0' of s, but may actually point to anywhere in s.
 s's new '\0' will be placed at e or earlier in order to remove any trailing t's.
@@ -511,9 +605,13 @@ static char *kill_trailingn(      s,      t,       e) char *s; char t; char *e;
 { 
 if (e==s) *e = '\0';                 /* Kill the string makes sense here.*/
 else if (e>s) {                      /* Watch out for neg. length string.*/
-  while (e>s && *--e==t);            /* Don't follow t's past beginning. */
+  while (e>s && *--e==t){;}          /* Don't follow t's past beginning. */
   e[*e==t?0:1] = '\0';               /* Handle s[0]=t correctly.       */
-} return s; }
+}
+if (0)  /* to prevent not used warnings in gcc (added by TJ) */
+  num_elem("", 0, '\0', 1);
+
+ return s; }
 
 /* Note the following assumes that any element which has t's to be chopped off,
 does indeed fill the entire element. */
@@ -554,7 +652,7 @@ typedef DSC$DESCRIPTOR_A(1) fstringvector;
                     *( (F).dsc$l_m[0]=(F).dsc$bounds[0].dsc$l_u=(ELEMNO)  ),   \
   (F).dsc$a_a0    =  ( (F).dsc$a_pointer=(C) ) - (F).dsc$w_length          ,(F))
 
-#else
+#endif      /* PDW: 2/10/98 (CFITSIO) -- Let VMS see NUM_ELEMS definitions */
 #define _NUM_ELEMS      -1
 #define _NUM_ELEM_ARG   -2
 #define NUM_ELEMS(A)    A,_NUM_ELEMS
@@ -576,13 +674,18 @@ if (num_term == _NUM_ELEMS || num_term == _NUM_ELEM_ARG)
   return term_char;
 if (num_term <=0) num_term = (int)elem_len;
 for (num=0; ; num++) {
-  for (i=0; i<(unsigned)num_term && *strv==term_char; i++,strv++);
+  for (i=0; i<(unsigned)num_term && *strv==term_char; i++,strv++){;}
   if (i==(unsigned)num_term) break;
   else strv += elem_len-i;
 }
+if (0) {  /* to prevent not used warnings in gcc (added by ROOT) */
+   c2fstrv(0, 0, 0, 0); f2cstrv(0, 0, 0, 0); kill_trailing(0, 0);
+   vkill_trailing(0, 0, 0, 0); num_elem(0, 0, 0, 0);
+}
 return (int)num;
 }
-#endif
+/* #endif removed 2/10/98 (CFITSIO) */
+
 /*-------------------------------------------------------------------------*/
 
 /*           UTILITIES FOR C TO USE STRINGS IN FORTRAN COMMON BLOCKS       */
@@ -693,8 +796,8 @@ typedef void (*cfCAST_FUNCTION)(CF_NULL_PROTO);
 #define   PSTRINGV_cfV(T,A,B,F) static fstringvector B =                       \
           {0,DSC$K_DTYPE_T,DSC$K_CLASS_A,NULL,0,0,{0,0,1,1,1},1,0,NULL,0,{1,0}};
 #else
-#define     STRING_cfV(T,A,B,F) struct {unsigned int clen, flen;} B;
-#define    STRINGV_cfV(T,A,B,F) struct {char *s, *fs; unsigned flen;} B;
+#define     STRING_cfV(T,A,B,F) struct {unsigned int clen, flen; char *nombre;} B;
+#define    STRINGV_cfV(T,A,B,F) struct {char *s, *fs; unsigned flen; char *nombre;} B;
 #define    PSTRING_cfV(T,A,B,F) int     B;
 #define   PSTRINGV_cfV(T,A,B,F) struct{char *fs; unsigned int sizeofA,flen;}B;
 #endif
@@ -812,7 +915,7 @@ typedef void (*cfCAST_FUNCTION)(CF_NULL_PROTO);
 #define  DEFAULT_cfW(A,B)
 #define  LOGICAL_cfW(A,B)
 #define PLOGICAL_cfW(A,B) *B=F2CLOGICAL(*B);
-#define   STRING_cfW(A,B) (A[B.clen]!='\0'?A[B.clen]='\0':0); /* A?="constnt"*/
+#define   STRING_cfW(A,B) (B.nombre=A,B.nombre[B.clen]!='\0'?B.nombre[B.clen]='\0':0); /* A?="constnt"*/
 #define  PSTRING_cfW(A,B) kill_trailing(A,' ');
 #ifdef vmsFortran
 #define  STRINGV_cfW(A,B) _cf_free(B.dsc$a_pointer);
@@ -1354,24 +1457,22 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #else
 #define INTEGER_BYTE        unsigned char
 #endif
-#define     BYTEVVVVVVV_cfTYPE INTEGER_BYTE
-#define   DOUBLEVVVVVVV_cfTYPE DOUBLE_PRECISION 
-#define    FLOATVVVVVVV_cfTYPE FORTRAN_REAL
-#define      INTVVVVVVV_cfTYPE int
-#define  LOGICALVVVVVVV_cfTYPE int
-#define     LONGVVVVVVV_cfTYPE long
-#define LONGLONGVVVVVVV_cfTYPE long long
-#define    INT64VVVVVVV_cfTYPE INT64_T
-#define    SHORTVVVVVVV_cfTYPE short
-#define           PBYTE_cfTYPE INTEGER_BYTE
-#define         PDOUBLE_cfTYPE DOUBLE_PRECISION 
-#define          PFLOAT_cfTYPE FORTRAN_REAL
-#define            PINT_cfTYPE int
-#define        PLOGICAL_cfTYPE int
-#define           PLONG_cfTYPE long
-#define       PLONGLONG_cfTYPE long long
-#define          PINT64_cfTYPE INT64_T
-#define          PSHORT_cfTYPE short
+#define    BYTEVVVVVVV_cfTYPE INTEGER_BYTE
+#define  DOUBLEVVVVVVV_cfTYPE DOUBLE_PRECISION 
+#define   FLOATVVVVVVV_cfTYPE FORTRAN_REAL
+#define     INTVVVVVVV_cfTYPE int
+#define LOGICALVVVVVVV_cfTYPE int
+#define    LONGVVVVVVV_cfTYPE long
+#define LONGLONGVVVVVVV_cfTYPE LONGLONG   /* added by MR December 2005 */
+#define   SHORTVVVVVVV_cfTYPE short
+#define          PBYTE_cfTYPE INTEGER_BYTE
+#define        PDOUBLE_cfTYPE DOUBLE_PRECISION 
+#define         PFLOAT_cfTYPE FORTRAN_REAL
+#define           PINT_cfTYPE int
+#define       PLOGICAL_cfTYPE int
+#define          PLONG_cfTYPE long
+#define      PLONGLONG_cfTYPE LONGLONG  /* added by MR December 2005 */
+#define         PSHORT_cfTYPE short
 
 #define CFARGS0(A,T,V,W,X,Y,Z) _3(T,_cf,A)
 #define CFARGS1(A,T,V,W,X,Y,Z) _3(T,_cf,A)(V)
@@ -1388,8 +1489,7 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define            INT_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
 #define        LOGICAL_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
 #define           LONG_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
-#define       LONGLONG_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
-#define          INT64_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
+#define       LONGLONG_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
 #define          SHORT_cfINT(N,A,B,X,Y,Z)        DOUBLE_cfINT(N,A,B,X,Y,Z)
 #define          PBYTE_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
 #define        PDOUBLE_cfINT(N,A,B,X,Y,Z) _(CFARGS,N)(A,PINT,B,X,Y,Z,0)
@@ -1397,8 +1497,7 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define           PINT_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
 #define       PLOGICAL_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
 #define          PLONG_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
-#define      PLONGLONG_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
-#define         PINT64_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
+#define      PLONGLONG_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
 #define         PSHORT_cfINT(N,A,B,X,Y,Z)       PDOUBLE_cfINT(N,A,B,X,Y,Z)
 #define          BYTEV_cfINT(N,A,B,X,Y,Z)       DOUBLEV_cfINT(N,A,B,X,Y,Z)
 #define         BYTEVV_cfINT(N,A,B,X,Y,Z)      DOUBLEVV_cfINT(N,A,B,X,Y,Z)
@@ -1442,6 +1541,13 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define      LONGVVVVV_cfINT(N,A,B,X,Y,Z)   DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z)
 #define     LONGVVVVVV_cfINT(N,A,B,X,Y,Z)  DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z)
 #define    LONGVVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z)
+#define      LONGLONGV_cfINT(N,A,B,X,Y,Z)       DOUBLEV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define     LONGLONGVV_cfINT(N,A,B,X,Y,Z)      DOUBLEVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define    LONGLONGVVV_cfINT(N,A,B,X,Y,Z)     DOUBLEVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define   LONGLONGVVVV_cfINT(N,A,B,X,Y,Z)    DOUBLEVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define  LONGLONGVVVVV_cfINT(N,A,B,X,Y,Z)   DOUBLEVVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define LONGLONGVVVVVV_cfINT(N,A,B,X,Y,Z)  DOUBLEVVVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
+#define LONGLONGVVVVVVV_cfINT(N,A,B,X,Y,Z) DOUBLEVVVVVVV_cfINT(N,A,B,X,Y,Z) /* added by MR December 2005 */
 #define         SHORTV_cfINT(N,A,B,X,Y,Z)       DOUBLEV_cfINT(N,A,B,X,Y,Z)
 #define        SHORTVV_cfINT(N,A,B,X,Y,Z)      DOUBLEVV_cfINT(N,A,B,X,Y,Z)
 #define       SHORTVVV_cfINT(N,A,B,X,Y,Z)     DOUBLEVVV_cfINT(N,A,B,X,Y,Z)
@@ -1501,7 +1607,12 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define      BYTE_cfPU(A)   CFextern INTEGER_BYTE      FCALLSC_QUALIFIER A
 #define    DOUBLE_cfPU(A)   CFextern DOUBLE_PRECISION  FCALLSC_QUALIFIER A
 #if ! (defined(FLOATFUNCTIONTYPE)&&defined(ASSIGNFLOAT)&&defined(RETURNFLOAT))
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define     FLOAT_cfPU(A)   CFextern DOUBLE_PRECISION  FCALLSC_QUALIFIER A
+#else
 #define     FLOAT_cfPU(A)   CFextern FORTRAN_REAL      FCALLSC_QUALIFIER A
+#endif
 #else				   	                   
 #define     FLOAT_cfPU(A)   CFextern FLOATFUNCTIONTYPE FCALLSC_QUALIFIER A
 #endif				   	                   
@@ -1639,8 +1750,7 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define            INT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define        LOGICAL_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,LOGICAL,A,B,C,D,E)
 #define           LONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
-#define       LONGLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
-#define          INT64_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define       LONGLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
 #define          SHORT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define          BYTEV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define         BYTEVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
@@ -1684,6 +1794,13 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define      LONGVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define     LONGVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define    LONGVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define      LONGLONGV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define     LONGLONGVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define    LONGLONGVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define   LONGLONGVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define  LONGLONGVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define LONGLONGVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
+#define LONGLONGVVVVVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
 #define         SHORTV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define        SHORTVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define       SHORTVVV_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
@@ -1697,8 +1814,7 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define           PINT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define       PLOGICAL_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,PLOGICAL,A,B,C,D,E)
 #define          PLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
-#define      PLONGLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
-#define         PINT64_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
+#define      PLONGLONG_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E) /* added by MR December 2005 */
 #define         PSHORT_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,DEFAULT,A,B,C,D,E)
 #define         STRING_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,STRING,A,B,C,D,E)
 #define        PSTRING_cfSTR(N,T,A,B,C,D,E) _(CFARGS,N)(T,PSTRING,A,B,C,D,E)
@@ -1725,11 +1841,11 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
       /* PSTRING_cfC to beware of array A which does not contain any \0.      */
 #define  PSTRING_cfC(M,I,A,B,C) (B.dsc$a_pointer=A, C==sizeof(char*) ?         \
              B.dsc$w_length=strlen(A):  (A[C-1]='\0',B.dsc$w_length=strlen(A), \
-       memset((A)+B.dsc$w_length,' ',C-B.dsc$w_length-1), B.dsc$w_length=C-1));
+       (unsigned)memset((A)+B.dsc$w_length,' ',C-B.dsc$w_length-1), B.dsc$w_length=C-1));
 #else
-#define   STRING_cfC(M,I,A,B,C) (B.clen=strlen(A),                             \
+#define   STRING_cfC(M,I,A,B,C) (B.nombre=A,B.clen=(unsigned)strlen(A),                             \
                 C==sizeof(char*)||C==(unsigned)(B.clen+1)?B.flen=B.clen:       \
-                        (memset((A)+B.clen,' ',C-B.clen-1),A[B.flen=C-1]='\0'));
+                        (unsigned)(memset(B.nombre+B.clen,' ',C-B.clen-1),B.nombre[B.flen=C-1]='\0'));
 #define  PSTRING_cfC(M,I,A,B,C) (C==sizeof(char*)? B=strlen(A):                \
                     (A[C-1]='\0',B=strlen(A),memset((A)+B,' ',C-B-1),B=C-1));
 #endif
@@ -1756,8 +1872,6 @@ do{VVCF(T1,A1,B1)  VVCF(T2,A2,B2)  VVCF(T3,A3,B3)  VVCF(T4,A4,B4)  VVCF(T5,A5,B5
 #define      INT_cfCCC(A,B) &A
 #define  LOGICAL_cfCCC(A,B) &A
 #define     LONG_cfCCC(A,B) &A
-#define LONGLONG_cfCCC(A,B) &A
-#define    INT64_cfCCC(A,B) &A
 #define    SHORT_cfCCC(A,B) &A
 #define    PBYTE_cfCCC(A,B)  A
 #define  PDOUBLE_cfCCC(A,B)  A
@@ -2013,8 +2127,7 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #define            INT_cfT(M,I,A,B,D) *A
 #define        LOGICAL_cfT(M,I,A,B,D)  F2CLOGICAL(*A)
 #define           LONG_cfT(M,I,A,B,D) *A
-#define       LONGLONG_cfT(M,I,A,B,D) *A
-#define          INT64_cfT(M,I,A,B,D) *A
+#define       LONGLONG_cfT(M,I,A,B,D) *A /* added by MR December 2005 */
 #define          SHORT_cfT(M,I,A,B,D) *A
 #define          BYTEV_cfT(M,I,A,B,D)  A
 #define        DOUBLEV_cfT(M,I,A,B,D)  A
@@ -2022,6 +2135,7 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #define           INTV_cfT(M,I,A,B,D)  A
 #define       LOGICALV_cfT(M,I,A,B,D)  A
 #define          LONGV_cfT(M,I,A,B,D)  A
+#define      LONGLONGV_cfT(M,I,A,B,D)  A /* added by MR December 2005 */
 #define         SHORTV_cfT(M,I,A,B,D)  A
 #define         BYTEVV_cfT(M,I,A,B,D)  (void *)A /* We have to cast to void *,*/
 #define        BYTEVVV_cfT(M,I,A,B,D)  (void *)A /* since we don't know the   */
@@ -2059,6 +2173,12 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #define      LONGVVVVV_cfT(M,I,A,B,D)  (void *)A
 #define     LONGVVVVVV_cfT(M,I,A,B,D)  (void *)A
 #define    LONGVVVVVVV_cfT(M,I,A,B,D)  (void *)A
+#define     LONGLONGVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define    LONGLONGVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define   LONGLONGVVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define  LONGLONGVVVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define LONGLONGVVVVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
+#define LONGLONGVVVVVVV_cfT(M,I,A,B,D)  (void *)A /* added by MR December 2005 */
 #define        SHORTVV_cfT(M,I,A,B,D)  (void *)A
 #define       SHORTVVV_cfT(M,I,A,B,D)  (void *)A
 #define      SHORTVVVV_cfT(M,I,A,B,D)  (void *)A
@@ -2071,8 +2191,7 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #define           PINT_cfT(M,I,A,B,D)  A
 #define       PLOGICAL_cfT(M,I,A,B,D)  ((*A=F2CLOGICAL(*A)),A)
 #define          PLONG_cfT(M,I,A,B,D)  A
-#define      PLONGLONG_cfT(M,I,A,B,D)  A
-#define         PINT64_cfT(M,I,A,B,D)  A
+#define      PLONGLONG_cfT(M,I,A,B,D)  A /* added by MR December 2005 */
 #define         PSHORT_cfT(M,I,A,B,D)  A
 #define          PVOID_cfT(M,I,A,B,D)  A
 #if defined(apolloFortran) || defined(hpuxFortran800) || defined(AbsoftUNIXFortran)
@@ -2106,7 +2225,7 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #define         STRING_cfT(M,I,A,B,D)  TTTTSTR( A,B,D)
 #define        STRINGV_cfT(M,I,A,B,D)  TTTTSTRV(A,B,D, num_elem(A,D,_3(M,_STRV_A,I)))
 #define        PSTRING_cfT(M,I,A,B,D)    TTSTR( A,B,D)
-#define       PPSTRING_cfT(M,I,A,B,D)           A
+#define       PPSTRING_cfT(M,I,A,B,D)           ((void)D, A)
 #endif
 #endif
 #define       PNSTRING_cfT(M,I,A,B,D)    STRING_cfT(M,I,A,B,D)
@@ -2143,12 +2262,18 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #define     INT_cfFZ(UN,LN) int   FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #define LOGICAL_cfFZ(UN,LN) int   FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #define    LONG_cfFZ(UN,LN) long  FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#define LONGLONG_cfFZ(UN,LN) LONGLONG FCALLSC_QUALIFIER fcallsc(UN,LN)( /* added by MR December 2005 */
 #define   SHORT_cfFZ(UN,LN) short FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #define    VOID_cfFZ(UN,LN) void  FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #ifndef __CF__KnR
 /* The void is req'd by the Apollo, to make this an ANSI function declaration.
    The Apollo promotes K&R float functions to double. */
-#define   FLOAT_cfFZ(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(void
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define FLOAT_cfFZ(UN,LN) DOUBLE_PRECISION FCALLSC_QUALIFIER fcallsc(UN,LN)(void
+#else
+#define FLOAT_cfFZ(UN,LN) FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(void
+#endif
 #ifdef vmsFortran
 #define  STRING_cfFZ(UN,LN) void  FCALLSC_QUALIFIER fcallsc(UN,LN)(fstring *AS
 #else
@@ -2164,7 +2289,12 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #endif
 #else
 #if ! (defined(FLOATFUNCTIONTYPE)&&defined(ASSIGNFLOAT)&&defined(RETURNFLOAT))
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define   FLOAT_cfFZ(UN,LN) DOUBLE_PRECISION  FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#else
 #define   FLOAT_cfFZ(UN,LN) FORTRAN_REAL      FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#endif
 #else
 #define   FLOAT_cfFZ(UN,LN) FLOATFUNCTIONTYPE FCALLSC_QUALIFIER fcallsc(UN,LN)(
 #endif
@@ -2178,13 +2308,19 @@ static _Icf(2,U,F,CFFUN(UN),0)() {_(F,_cfE) _Icf(3,GZ,F,UN,LN) ABSOFT_cf1(F));_(
 #define    BYTE_cfF(UN,LN)     BYTE_cfFZ(UN,LN)
 #define  DOUBLE_cfF(UN,LN)   DOUBLE_cfFZ(UN,LN)
 #ifndef __CF_KnR
+#if defined (f2cFortran) && ! defined (gFortran)
+/* f2c/g77 return double from FORTRAN REAL functions. (KMCCARTY, 2005/12/09) */
+#define   FLOAT_cfF(UN,LN)  DOUBLE_PRECISION FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#else
 #define   FLOAT_cfF(UN,LN)  FORTRAN_REAL FCALLSC_QUALIFIER fcallsc(UN,LN)(
+#endif
 #else
 #define   FLOAT_cfF(UN,LN)    FLOAT_cfFZ(UN,LN)
 #endif
 #define     INT_cfF(UN,LN)      INT_cfFZ(UN,LN)
 #define LOGICAL_cfF(UN,LN)  LOGICAL_cfFZ(UN,LN)
 #define    LONG_cfF(UN,LN)     LONG_cfFZ(UN,LN)
+#define LONGLONG_cfF(UN,LN) LONGLONG_cfFZ(UN,LN) /* added by MR December 2005 */
 #define   SHORT_cfF(UN,LN)    SHORT_cfFZ(UN,LN)
 #define    VOID_cfF(UN,LN)     VOID_cfFZ(UN,LN)
 #define  STRING_cfF(UN,LN)   STRING_cfFZ(UN,LN),
@@ -2247,6 +2383,7 @@ string. */
 #define LOGICAL_cfI  return C2FLOGICAL(A0);
 #endif
 #define    LONG_cfI  return A0;
+#define LONGLONG_cfI  return A0; /* added by MR December 2005 */
 #define   SHORT_cfI  return A0;
 #define  STRING_cfI  return   ;
 #define    VOID_cfI  return   ;
diff --git a/libcdi/src/cgribexlib.c b/libcdi/src/cgribexlib.c
index b152910..62a26c5 100644
--- a/libcdi/src/cgribexlib.c
+++ b/libcdi/src/cgribexlib.c
@@ -1,12 +1,10 @@
 
-/* Automatically generated by m214003 at 2015-04-22, do not edit */
+/* Automatically generated by m214003 at 2015-09-14, do not edit */
 
-/* CGRIBEXLIB_VERSION="1.7.2" */
+/* CGRIBEXLIB_VERSION="1.7.3" */
 
-#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5) || defined (__clang__)
 #pragma GCC diagnostic push
-#endif
-#ifdef __GNUC__
 #pragma GCC diagnostic ignored "-Wconversion"
 #pragma GCC diagnostic ignored "-Wsign-conversion"
 #pragma GCC diagnostic warning "-Wstrict-overflow"
@@ -1202,7 +1200,7 @@ int main(void)
 
   {
     float fmin, fmax;
-    float *data_sp = (float*) malloc(datasize*sizeof(float));
+    float *data_sp = (float*) Malloc(datasize*sizeof(float));
 
     for ( long i = 0; i < datasize/2; i++ )        data_sp[i] = (float) (i);
     for ( long i = datasize/2; i < datasize; i++ ) data_sp[i] = (float) (-datasize + i);
@@ -1217,12 +1215,12 @@ int main(void)
       }
     t_end = dtime();
     printf("minmax_val: fmin: %ld  fmax: %ld  time: %6.2fs\n", (long)fmin, (long) fmax, t_end-t_begin);
-    free(data_sp);
+    Free(data_sp);
   }
 
   {
     double fmin, fmax;
-    double *data_dp = (double*) malloc(datasize*sizeof(double));
+    double *data_dp = (double*) Malloc(datasize*sizeof(double));
 
     // for ( long i = datasize-1; i >= 0; i-- ) data[i] = (double) (-datasize/2 + i);
     for ( long i = 0; i < datasize/2; i++ )        data_dp[i] = (double) (i);
@@ -1288,7 +1286,7 @@ int main(void)
     t_end = dtime();
     printf("pwr6u6  : fmin: %ld  fmax: %ld  time: %6.2fs\n", (long)fmin, (long) fmax, t_end-t_begin);
 #endif
-    free(data_dp);
+    Free(data_dp);
   }
 
   return (0);
@@ -1300,6 +1298,14 @@ int main(void)
 #undef _ENABLE_SSE2
 #undef GNUC_PUSH_POP
 /* 
+icc -g -Wall -O3 -march=native -std=c99 -qopt-report=5 -DTEST_ENCODE encode_array.c
+ result on hama (icc 15.0.1):
+  float:
+    orig: val1: 1  val2: 1  val3: 2  valn: 66  time: 8.7936s
+  double:
+    orig: val1: 1  val2: 1  val3: 2  valn: 66  time: 13.6093s
+     avx: val1: 1  val2: 1  val3: 2  valn: 66  time: 3.90009s
+
 gcc -g -Wall -O3 -march=native -std=c99 -DTEST_ENCODE encode_array.c
  result on hama (gcc 4.8.2):
   orig    : val1: 1  val2: 1  val3: 2  valn: 66  time: 16.0471s
@@ -1662,7 +1668,8 @@ double dtime()
 static
 void pout(char *name, int s, unsigned char *lgrib, long datasize, double tt)
 {
-  printf("%8s: val1: %d  val2: %d  val3: %d  valn: %d  time: %gs\n", name, (int) lgrib[s*1+1], (int) lgrib[s*2+1], (int) lgrib[s*3+1], (int) lgrib[2*datasize-1], tt);
+  printf("%8s: val1: %d  val2: %d  val3: %d  valn: %d  time: %gs\n",
+         name, (int) lgrib[s*1+1], (int) lgrib[s*2+1], (int) lgrib[s*3+1], (int) lgrib[2*datasize-1], tt);
 }
 
 int main(void)
@@ -1673,9 +1680,9 @@ int main(void)
   double t_begin, t_end;
   unsigned char *lgrib;
 
-  dataf = (float*) malloc(datasize*sizeof(float));
-  data  = (double*) malloc(datasize*sizeof(double));
-  lgrib = (unsigned char*) malloc(2*datasize*sizeof(unsigned char));
+  dataf = (float*) Malloc(datasize*sizeof(float));
+  data  = (double*) Malloc(datasize*sizeof(double));
+  lgrib = (unsigned char*) Malloc(2*datasize*sizeof(unsigned char));
 
   for ( long i = 0; i < datasize; ++i ) dataf[i] = (float) (-datasize/2 + i);
   for ( long i = 0; i < datasize; ++i ) data[i] = (double) (-datasize/2 + i);
@@ -1782,7 +1789,9 @@ int main(void)
 #include <mach/mach_time.h>
 #endif
 
+#ifdef __cplusplus
 #define __STDC_FORMAT_MACROS
+#endif
 #include <inttypes.h>
 
 #if   defined(__GNUC__) && (__GNUC__ >= 4)
@@ -2101,8 +2110,8 @@ void confp3(double pval, int *kexp, int *kmant, int kbits, int kround)
     {
       *kexp  = 0;
       *kmant = 0;
-      iexp   = 0;
-      isign  = 0;
+      // iexp   = 0;
+      // isign  = 0;
       goto LABEL900;
     }
 
@@ -2191,8 +2200,8 @@ void confp3(double pval, int *kexp, int *kmant, int kbits, int kround)
           Message("Value arbitrarily set to zero.");
           *kexp  = 0;
           *kmant = 0;
-          iexp  = 0;
-          isign = 0;
+          // iexp  = 0;
+          // isign = 0;
           goto LABEL900;
 	}
 
@@ -2644,7 +2653,7 @@ gribExSP_old(int *isec0, int *isec1, int *isec2, float *fsec2sp, int *isec3,
       fsec3dp[1] = fsec3sp[1];
 
       inum = isec4[0];
-      fsec4dp = (double*) malloc(inum*sizeof(double));
+      fsec4dp = (double*) Malloc(inum*sizeof(double));
       if ( fsec4dp == NULL ) SysError("No Memory!");
 
       for ( j = 0; j < inum; j++ ) fsec4dp[j] = fsec4sp[j];
@@ -2653,13 +2662,13 @@ gribExSP_old(int *isec0, int *isec1, int *isec2, float *fsec2sp, int *isec3,
 	       fsec3dp, isec4, fsec4dp, klenp, kgrib,
 	       kleng, kword, hoper, kret);
 
-      free(fsec4dp);
+      Free(fsec4dp);
     }
   else if ( yfunc == 'D' || yfunc == 'J' || yfunc == 'R' )
     {
       if ( yfunc == 'D' || yfunc == 'R' )
 	{
-	  fsec4dp = (double*) malloc(klenp*sizeof(double));
+	  fsec4dp = (double*) Malloc(klenp*sizeof(double));
 	  if ( fsec4dp == NULL ) SysError("No Memory!");
 	}
 
@@ -2691,7 +2700,7 @@ gribExSP_old(int *isec0, int *isec1, int *isec2, float *fsec2sp, int *isec3,
 		fsec4sp[j] = fsec4dp[j];
 	    }
 
-	  free(fsec4dp);
+	  Free(fsec4dp);
 	}
     }
   else if ( yfunc == 'V' )
@@ -3365,7 +3374,6 @@ void gribPrintSec1(int *isec0, int *isec1)
           fprintf(grprsm, " Number of different time intervals used  %5d\n", isec1[48]);
           fprintf(grprsm, " List of different time intervals used:\n");
           iprev  = isec1[49];
-          icurr  = 0;
           unsigned icount = 0;
           for (jloop = 1; jloop <= isec1[48]; jloop++)
 	    {
@@ -3855,7 +3863,7 @@ void gribPrintSec2DP(int *isec0, int *isec2, double *fsec2)
       fprintf(grprsm, " Number of points along Y axis.               %9d\n", isec2[2]);
       fprintf(grprsm, " Latitude of sub-satellite point.             %9d\n", isec2[3]);
       fprintf(grprsm, " Longitude of sub-satellite point.            %9d\n", isec2[4]);
-      iresol = isec2[17] + isec2[18];
+      //iresol = isec2[17] + isec2[18];
       fprintf(grprsm, " Diameter of the earth in x direction.        %9d\n", isec2[6]);
       fprintf(grprsm, " Y coordinate of sub-satellite point.         %9d\n", isec2[9]);
       ibit = 8;
@@ -3984,7 +3992,7 @@ void gribPrintSec2SP(int *isec0, int *isec2, float  *fsec2sp)
 
   inum = 10 + isec2[11];
 
-  fsec2 = (double*) malloc(inum*sizeof(double));
+  fsec2 = (double*) Malloc(inum*sizeof(double));
   if ( fsec2 == NULL ) SysError("No Memory!");
 
   for ( j = 0; j < inum; j++ )
@@ -3992,7 +4000,7 @@ void gribPrintSec2SP(int *isec0, int *isec2, float  *fsec2sp)
   
   gribPrintSec2DP(isec0, isec2, fsec2);
 
-  free(fsec2);
+  Free(fsec2);
 }
 
 void gribPrintSec3DP(int *isec0, int *isec3, double *fsec3)
@@ -5724,7 +5732,7 @@ int grib2Sections(unsigned char *gribbuffer, long gribbufsize, unsigned char **i
 
       /* section 3 */
       sec_len = GRIB2_SECLEN(section);
-      sec_num = GRIB2_SECNUM(section);
+      //sec_num = GRIB2_SECNUM(section);
       //fprintf(stderr, "gds %d %ld\n", sec_num, sec_len);
 
       *gdsp = section;
@@ -6503,7 +6511,7 @@ void repair1(unsigned char *gbuf, long gbufsize)
       long nelem;
       unsigned char *pbuf;
       nelem = sourceLen/3;
-      pbuf = (unsigned char*) malloc(sourceLen);
+      pbuf = (unsigned char*) Malloc(sourceLen);
       for ( i = 0; i < nelem; i++ )
 	{
 	  pbuf[3*i  ] = source[        i];
@@ -6511,7 +6519,7 @@ void repair1(unsigned char *gbuf, long gbufsize)
 	  pbuf[3*i+2] = source[2*nelem+i];
 	}
       memcpy(source, pbuf, sourceLen);
-      free(pbuf);
+      Free(pbuf);
     }
 }
 
@@ -6785,7 +6793,7 @@ int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
       {
 	long nelem;
 	nelem = sourceLen/3;
-	pbuf = (unsigned char*) malloc(sourceLen);
+	pbuf = (unsigned char*) Malloc(sourceLen);
 	for ( i = 0; i < nelem; i++ )
 	  {
 	    pbuf[        i] = source[3*i  ];
@@ -6827,7 +6835,7 @@ int  gribZip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbufs
       }
 #endif
     
-    if ( pbuf ) free(pbuf);
+    if ( pbuf ) Free(pbuf);
     /*
     fprintf(stderr, "sourceLen, destLen %d %d\n", sourceLen, destLen);
     */
@@ -7143,7 +7151,7 @@ int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
 	long nelem;
 	unsigned char *pbuf;
 	nelem = tmpLen/3;
-	pbuf = (unsigned char*) malloc(tmpLen);
+	pbuf = (unsigned char*) Malloc(tmpLen);
 	for ( i = 0; i < nelem; i++ )
 	  {
 	    pbuf[3*i  ] = dest[        i];
@@ -7151,7 +7159,7 @@ int  gribUnzip(unsigned char *dbuf, long dbufsize, unsigned char *sbuf, long sbu
 	    pbuf[3*i+2] = dest[2*nelem+i];
 	  }
 	memcpy(dest, pbuf, tmpLen);
-	free(pbuf);
+        Free(pbuf);
       }
 #endif
 
@@ -7251,14 +7259,14 @@ double calculate_pfactor(const double* spectralField, long fieldTruncation, long
 
   range = (double) (ismax - ismin +1);
 
-  weights = (double*) malloc((ismax+1)*sizeof(double));
+  weights = (double*) Malloc((ismax+1)*sizeof(double));
   for( loop = ismin; loop <= ismax; loop++ )
     weights[loop] = range / (double) (loop-ismin+1);
   /*
   // Compute norms
   // Handle values 2 at a time (real and imaginary parts).
    */
-  norms = (double*) malloc((ismax+1)*sizeof(double));
+  norms = (double*) Malloc((ismax+1)*sizeof(double));
 
   for( loop = 0; loop < ismax+1; loop++ ) norms[loop] = 0.0;
   /*
@@ -7332,8 +7340,8 @@ double calculate_pfactor(const double* spectralField, long fieldTruncation, long
   }
   slope = numerator / denominator;
 
-  free(weights);
-  free(norms);
+  Free(weights);
+  Free(norms);
 
   pFactor = -slope;
   if( pFactor < -9999.9 ) pFactor = -9999.9;
@@ -7527,10 +7535,10 @@ int qu2reg2(double *pfield, int *kpoint, int klat, int klon,
    int iregno, iquano, j210, j220, j230, j240, j225;
 
 
-   zline = (double*) malloc(2*klon*sizeof(double));
+   zline = (double*) Malloc(2*klon*sizeof(double));
    if ( zline == NULL ) SysError("No Memory!");
 
-   zwork = (double*) malloc(3*(2*klon+3)*sizeof(double));
+   zwork = (double*) Malloc(3*(2*klon+3)*sizeof(double));
    if ( zwork == NULL ) SysError("No Memory!");
 
    /* Parameter adjustments */
@@ -7667,8 +7675,8 @@ int qu2reg2(double *pfield, int *kpoint, int klat, int klon,
 
 L900:
 
-   free(zline);
-   free(zwork);
+   Free(zline);
+   Free(zwork);
 
    return 0;
 } /* qu2reg2 */
@@ -7684,7 +7692,7 @@ L900:
 void TEMPLATE(scale_complex,T)(T *fpdata, int pcStart, int pcScale, int trunc, int inv)
 {
   double power;
-  double *scale = (double*) malloc((trunc+1)*sizeof(double));
+  double *scale = (double*) Malloc((trunc+1)*sizeof(double));
   int  n, m;
   int  index;
 
@@ -7737,13 +7745,13 @@ void TEMPLATE(scale_complex,T)(T *fpdata, int pcStart, int pcScale, int trunc, i
 	index += 2;
       }
 
-  free(scale);
+  Free(scale);
 }
 
 
 void TEMPLATE(scatter_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 {
-  T *fphelp = (T*) malloc(nsp*sizeof(T));
+  T *fphelp = (T*) Malloc(nsp*sizeof(T));
   int  m, n;
   int  index, inext;
 
@@ -7776,13 +7784,13 @@ void TEMPLATE(scatter_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 
   for ( m = 0; m < nsp; m++ ) fpdata[m] = fphelp[m];
 
-  free(fphelp);
+  Free(fphelp);
 }
 
 
 void TEMPLATE(gather_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 {
-  T *fphelp = (T*) malloc(nsp*sizeof(T));
+  T *fphelp = (T*) Malloc(nsp*sizeof(T));
   int  m, n;
   int  index, inext;
 
@@ -7815,7 +7823,7 @@ void TEMPLATE(gather_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 
   for ( m = 0; m < nsp; m++ ) fpdata[m] = fphelp[m];
 
-  free(fphelp);
+  Free(fphelp);
 }
 
 
@@ -8219,13 +8227,13 @@ C
    T *zline = NULL;
    T *zwork = NULL;
 
-   ztemp = (T*) malloc(klon*klat*sizeof(T));
+   ztemp = (T*) Malloc(klon*klat*sizeof(T));
    if ( ztemp == NULL ) SysError("No Memory!");
 
-   zline = (T*) malloc(2*klon*sizeof(T));
+   zline = (T*) Malloc(2*klon*sizeof(T));
    if ( zline == NULL ) SysError("No Memory!");
 
-   zwork = (T*) malloc(3*(2*klon+3)*sizeof(T));
+   zwork = (T*) Malloc(3*(2*klon+3)*sizeof(T));
    if ( zwork == NULL ) SysError("No Memory!");
 
    /* Parameter adjustments */
@@ -8329,9 +8337,9 @@ C
 
 L900:
 
-   free(zwork);
-   free(zline);
-   free(ztemp);
+   Free(zwork);
+   Free(zline);
+   Free(ztemp);
 
    return 0;
 } /* qu2reg3 */
@@ -8347,7 +8355,7 @@ L900:
 void TEMPLATE(scale_complex,T)(T *fpdata, int pcStart, int pcScale, int trunc, int inv)
 {
   double power;
-  double *scale = (double*) malloc((trunc+1)*sizeof(double));
+  double *scale = (double*) Malloc((trunc+1)*sizeof(double));
   int  n, m;
   int  index;
 
@@ -8400,13 +8408,13 @@ void TEMPLATE(scale_complex,T)(T *fpdata, int pcStart, int pcScale, int trunc, i
 	index += 2;
       }
 
-  free(scale);
+  Free(scale);
 }
 
 
 void TEMPLATE(scatter_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 {
-  T *fphelp = (T*) malloc(nsp*sizeof(T));
+  T *fphelp = (T*) Malloc(nsp*sizeof(T));
   int  m, n;
   int  index, inext;
 
@@ -8439,13 +8447,13 @@ void TEMPLATE(scatter_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 
   for ( m = 0; m < nsp; m++ ) fpdata[m] = fphelp[m];
 
-  free(fphelp);
+  Free(fphelp);
 }
 
 
 void TEMPLATE(gather_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 {
-  T *fphelp = (T*) malloc(nsp*sizeof(T));
+  T *fphelp = (T*) Malloc(nsp*sizeof(T));
   int  m, n;
   int  index, inext;
 
@@ -8478,7 +8486,7 @@ void TEMPLATE(gather_complex,T)(T *fpdata, int pcStart, int trunc, int nsp)
 
   for ( m = 0; m < nsp; m++ ) fpdata[m] = fphelp[m];
 
-  free(fphelp);
+  Free(fphelp);
 }
 
 
@@ -8882,13 +8890,13 @@ C
    T *zline = NULL;
    T *zwork = NULL;
 
-   ztemp = (T*) malloc(klon*klat*sizeof(T));
+   ztemp = (T*) Malloc(klon*klat*sizeof(T));
    if ( ztemp == NULL ) SysError("No Memory!");
 
-   zline = (T*) malloc(2*klon*sizeof(T));
+   zline = (T*) Malloc(2*klon*sizeof(T));
    if ( zline == NULL ) SysError("No Memory!");
 
-   zwork = (T*) malloc(3*(2*klon+3)*sizeof(T));
+   zwork = (T*) Malloc(3*(2*klon+3)*sizeof(T));
    if ( zwork == NULL ) SysError("No Memory!");
 
    /* Parameter adjustments */
@@ -8992,9 +9000,9 @@ C
 
 L900:
 
-   free(zwork);
-   free(zline);
-   free(ztemp);
+   Free(zwork);
+   Free(zline);
+   Free(ztemp);
 
    return 0;
 } /* qu2reg3 */
@@ -9402,7 +9410,7 @@ void TEMPLATE(decode_array,T)(const unsigned char *restrict igrib, long jlend, i
       long jlenc = jlend * numBits / 8;
       if ( jlenc > 0 ) 
 	{
-	  lgrib = (GRIBPACK*) malloc(jlenc*sizeof(GRIBPACK));
+	  lgrib = (GRIBPACK*) Malloc(jlenc*sizeof(GRIBPACK));
 	  if ( lgrib == NULL ) SysError("No Memory!");
 
 	  (void) UNPACK_GRIB(igrib, lgrib, jlenc, -1L);
@@ -9453,7 +9461,7 @@ void TEMPLATE(decode_array,T)(const unsigned char *restrict igrib, long jlend, i
       Error("Unimplemented packing factor %d!", numBits);
     }
 
-  if ( lgrib ) free(lgrib);
+  if ( lgrib ) Free(lgrib);
 
 #else
   if ( numBits ==  0 )
@@ -9660,7 +9668,7 @@ void TEMPLATE(decode_array,T)(const unsigned char *restrict igrib, long jlend, i
       long jlenc = jlend * numBits / 8;
       if ( jlenc > 0 ) 
 	{
-	  lgrib = (GRIBPACK*) malloc(jlenc*sizeof(GRIBPACK));
+	  lgrib = (GRIBPACK*) Malloc(jlenc*sizeof(GRIBPACK));
 	  if ( lgrib == NULL ) SysError("No Memory!");
 
 	  (void) UNPACK_GRIB(igrib, lgrib, jlenc, -1L);
@@ -9711,7 +9719,7 @@ void TEMPLATE(decode_array,T)(const unsigned char *restrict igrib, long jlend, i
       Error("Unimplemented packing factor %d!", numBits);
     }
 
-  if ( lgrib ) free(lgrib);
+  if ( lgrib ) Free(lgrib);
 
 #else
   if ( numBits ==  0 )
@@ -10022,7 +10030,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
 	}
 #if defined (SX)
       lGribLen = 4*ISEC2_NumVCP;	      
-      lgrib    = (GRIBPACK*) malloc(lGribLen*sizeof(GRIBPACK));
+      lgrib    = (GRIBPACK*) Malloc(lGribLen*sizeof(GRIBPACK));
 
       igrib = &gds[locnv];
       if ( ISEC2_NumVCP > 0 ) (void) UNPACK_GRIB(igrib, lgrib, lGribLen, -1L);
@@ -10035,7 +10043,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
 	  fsec2[10+i] = POW_2_M24 * imant * pow(16.0, (double)(iexp - 64));
 	}
 
-      free(lgrib);
+      Free(lgrib);
 #else
       for ( i = 0; i < ISEC2_NumVCP; i++ )
 	{
@@ -10168,7 +10176,7 @@ int TEMPLATE(decodeBDS,T)(int decscale, unsigned char *bds, int *isec2, int *ise
 	{
 	  /*    no unpacked binary data present */
 
-	  jup = kup = mup = 0;
+	  //jup = kup = mup = 0;
 
 	  /*    octet number of start of packed data */
 	  /*    calculated from start of block 4 - 1 */
@@ -10569,7 +10577,7 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 	    }
 	  */
 
-	  imask = (GRIBPACK*) malloc(imaskSize*sizeof(GRIBPACK));
+	  imask = (GRIBPACK*) Malloc(imaskSize*sizeof(GRIBPACK));
 
 #if defined (VECTORCODE)
 	  (void) UNPACK_GRIB(BMS_Bitmap, imask, imaskSize/8, -1L);
@@ -10628,17 +10636,16 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 		fsec4[i] = imask[i] ? fsec4[--j] : FSEC3_MissVal;
 	    }
 
-	  free(imask);
+	  Free(imask);
 	}
     }
 
   if ( ISEC2_Reduced )
     {
       int nlon, nlat;
-      int lsect3, lperio = 1, lveggy;
+      int lperio = 1, lveggy;
       int ilat;
       int nvalues = 0;
-      int dlon;
 
       nlat = ISEC2_NumLat;
       nlon = ISEC2_RowLonPtr[0];
@@ -10646,8 +10653,8 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
       for ( ilat = 1; ilat < nlat; ++ilat )
 	if ( ISEC2_RowLon(ilat) > nlon ) nlon = ISEC2_RowLon(ilat);
 
-      dlon = ISEC2_LastLon-ISEC2_FirstLon;
-      if ( dlon < 0 ) dlon += 360000;
+      // int dlon = ISEC2_LastLon-ISEC2_FirstLon;
+      // if ( dlon < 0 ) dlon += 360000;
 	  
       if ( nvalues != ISEC4_NumValues )
 	{
@@ -10955,7 +10962,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
 	}
 #if defined (SX)
       lGribLen = 4*ISEC2_NumVCP;	      
-      lgrib    = (GRIBPACK*) malloc(lGribLen*sizeof(GRIBPACK));
+      lgrib    = (GRIBPACK*) Malloc(lGribLen*sizeof(GRIBPACK));
 
       igrib = &gds[locnv];
       if ( ISEC2_NumVCP > 0 ) (void) UNPACK_GRIB(igrib, lgrib, lGribLen, -1L);
@@ -10968,7 +10975,7 @@ int TEMPLATE(decodeGDS,T)(unsigned char  *gds, int *isec0, int *isec2, T *fsec2,
 	  fsec2[10+i] = POW_2_M24 * imant * pow(16.0, (double)(iexp - 64));
 	}
 
-      free(lgrib);
+      Free(lgrib);
 #else
       for ( i = 0; i < ISEC2_NumVCP; i++ )
 	{
@@ -11101,7 +11108,7 @@ int TEMPLATE(decodeBDS,T)(int decscale, unsigned char *bds, int *isec2, int *ise
 	{
 	  /*    no unpacked binary data present */
 
-	  jup = kup = mup = 0;
+	  //jup = kup = mup = 0;
 
 	  /*    octet number of start of packed data */
 	  /*    calculated from start of block 4 - 1 */
@@ -11502,7 +11509,7 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 	    }
 	  */
 
-	  imask = (GRIBPACK*) malloc(imaskSize*sizeof(GRIBPACK));
+	  imask = (GRIBPACK*) Malloc(imaskSize*sizeof(GRIBPACK));
 
 #if defined (VECTORCODE)
 	  (void) UNPACK_GRIB(BMS_Bitmap, imask, imaskSize/8, -1L);
@@ -11561,17 +11568,16 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 		fsec4[i] = imask[i] ? fsec4[--j] : FSEC3_MissVal;
 	    }
 
-	  free(imask);
+	  Free(imask);
 	}
     }
 
   if ( ISEC2_Reduced )
     {
       int nlon, nlat;
-      int lsect3, lperio = 1, lveggy;
+      int lperio = 1, lveggy;
       int ilat;
       int nvalues = 0;
-      int dlon;
 
       nlat = ISEC2_NumLat;
       nlon = ISEC2_RowLonPtr[0];
@@ -11579,8 +11585,8 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
       for ( ilat = 1; ilat < nlat; ++ilat )
 	if ( ISEC2_RowLon(ilat) > nlon ) nlon = ISEC2_RowLon(ilat);
 
-      dlon = ISEC2_LastLon-ISEC2_FirstLon;
-      if ( dlon < 0 ) dlon += 360000;
+      // int dlon = ISEC2_LastLon-ISEC2_FirstLon;
+      // if ( dlon < 0 ) dlon += 360000;
 	  
       if ( nvalues != ISEC4_NumValues )
 	{
@@ -11681,7 +11687,8 @@ void TEMPLATE(grib_decode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 static
 void encodeIS(GRIBPACK *lGrib, long *gribLen)
 {
-  long z = *gribLen;
+  long z;
+  // z = *gribLen;
 
   lGrib[0] = 'G';
   lGrib[1] = 'R';
@@ -13126,7 +13133,7 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
   fsec4size = 0;
 
 #if defined (VECTORCODE)
-  imask = (unsigned int*) malloc(imaskSize*sizeof(unsigned int));
+  imask = (unsigned int*) Malloc(imaskSize*sizeof(unsigned int));
   memset(imask, 0, imaskSize*sizeof(int));
 
 #if defined (CRAY)
@@ -13164,7 +13171,7 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
 	          (imask[i*8+6] << 1) | (imask[i*8+7]);
     }
 
-  free(imask);
+  Free(imask);
 #else
   for ( i = 0; i < imaskSize/8; i++ ) bitmap[i] = 0;
 
@@ -13503,7 +13510,7 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
   if ( bmsIncluded ) len += (klenp+7)>>3;
 
 #if defined (VECTORCODE)
-  lGrib = (GRIBPACK*) malloc(len*sizeof(GRIBPACK));
+  lGrib = (GRIBPACK*) Malloc(len*sizeof(GRIBPACK));
   if ( lGrib == NULL ) SysError("No Memory!");
 #else
   lGrib = CGrib;
@@ -13565,7 +13572,7 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 
   (void) PACK_GRIB(lGrib, (unsigned char *)CGrib, gribLen, -1L);
 
-  free(lGrib);
+  Free(lGrib);
 #endif
 
   ISEC0_GRIB_Len     = gribLen;
@@ -13745,7 +13752,7 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
   fsec4size = 0;
 
 #if defined (VECTORCODE)
-  imask = (unsigned int*) malloc(imaskSize*sizeof(unsigned int));
+  imask = (unsigned int*) Malloc(imaskSize*sizeof(unsigned int));
   memset(imask, 0, imaskSize*sizeof(int));
 
 #if defined (CRAY)
@@ -13783,7 +13790,7 @@ void TEMPLATE(encodeBMS,T)(GRIBPACK *lGrib, long *gribLen, T *fsec3, int *isec4,
 	          (imask[i*8+6] << 1) | (imask[i*8+7]);
     }
 
-  free(imask);
+  Free(imask);
 #else
   for ( i = 0; i < imaskSize/8; i++ ) bitmap[i] = 0;
 
@@ -14122,7 +14129,7 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
   if ( bmsIncluded ) len += (klenp+7)>>3;
 
 #if defined (VECTORCODE)
-  lGrib = (GRIBPACK*) malloc(len*sizeof(GRIBPACK));
+  lGrib = (GRIBPACK*) Malloc(len*sizeof(GRIBPACK));
   if ( lGrib == NULL ) SysError("No Memory!");
 #else
   lGrib = CGrib;
@@ -14184,7 +14191,7 @@ void TEMPLATE(grib_encode,T)(int *isec0, int *isec1, int *isec2, T *fsec2, int *
 
   (void) PACK_GRIB(lGrib, (unsigned char *)CGrib, gribLen, -1L);
 
-  free(lGrib);
+  Free(lGrib);
 #endif
 
   ISEC0_GRIB_Len     = gribLen;
@@ -14203,7 +14210,7 @@ void encode_dummy(void)
   (void) encode_array_unrolled_double(0, 0, 0, NULL, NULL, 0, 0, NULL);
   (void) encode_array_unrolled_float(0, 0, 0, NULL, NULL, 0, 0, NULL);
 }
-static const char grb_libvers[] = "1.7.2" " of ""Apr 22 2015"" ""13:44:04";
+static const char grb_libvers[] = "1.7.3" " of ""Sep 14 2015"" ""10:58:44";
 const char *
 cgribexLibraryVersion(void)
 {
diff --git a/libcdi/src/cksum.c b/libcdi/src/cksum.c
index 32c3cc3..4999fa7 100644
--- a/libcdi/src/cksum.c
+++ b/libcdi/src/cksum.c
@@ -112,6 +112,7 @@ memcrc_r(uint32_t *state, const unsigned char *block, size_t block_len)
   *state = s;
 }
 
+#ifdef WORDS_BIGENDIAN
 #define SWAP_CSUM(BITWIDTH,BYTEWIDTH,NACC)                              \
   do {                                                                  \
     register const uint##BITWIDTH##_t *b = (uint##BITWIDTH##_t *)elems; \
@@ -126,7 +127,7 @@ memcrc_r(uint32_t *state, const unsigned char *block, size_t block_len)
       }                                                                 \
     }                                                                   \
   } while (0)
-
+#endif
 
 
 /**
diff --git a/libcdi/src/cksum.h b/libcdi/src/cksum.h
index 5601826..d2cac3e 100644
--- a/libcdi/src/cksum.h
+++ b/libcdi/src/cksum.h
@@ -18,3 +18,12 @@ memcrc_finish(uint32_t *state, off_t total_size);
 uint32_t
 memcrc(const unsigned char *b, size_t n);
 
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/config.h.in b/libcdi/src/config.h.in
index 25182f7..230bf53 100644
--- a/libcdi/src/config.h.in
+++ b/libcdi/src/config.h.in
@@ -3,6 +3,9 @@
 /* Define if building universal (internal helper macro) */
 #undef AC_APPLE_UNIVERSAL_BUILD
 
+/* CDI version */
+#undef CDI
+
 /* Compiler */
 #undef COMPILER
 
@@ -12,13 +15,25 @@
 /* Defined if backtrace() could be fully identified. */
 #undef HAVE_BACKTRACE
 
-/* Define if C / Fortran interface cfortran.h works */
+/* Defined to 1 if C / Fortran interface cfortran.h works */
 #undef HAVE_CF_INTERFACE
 
 /* Define to 1 if you have the declaration of `isnan', and to 0 if you don't.
    */
 #undef HAVE_DECL_ISNAN
 
+/* Define to 1 if you have the declaration of `PAGESIZE', and to 0 if you
+   don't. */
+#undef HAVE_DECL_PAGESIZE
+
+/* Define to 1 if you have the declaration of `PAGE_SIZE', and to 0 if you
+   don't. */
+#undef HAVE_DECL_PAGE_SIZE
+
+/* Define to 1 if you have the declaration of `POSIX_REC_XFER_ALIGN', and to 0
+   if you don't. */
+#undef HAVE_DECL_POSIX_REC_XFER_ALIGN
+
 /* Define to 1 if you have the declaration of `uuid_create', and to 0 if you
    don't. */
 #undef HAVE_DECL_UUID_CREATE
@@ -27,6 +42,22 @@
    don't. */
 #undef HAVE_DECL_UUID_GENERATE
 
+/* Define to 1 if you have the declaration of `_PC_REC_XFER_ALIGN', and to 0
+   if you don't. */
+#undef HAVE_DECL__PC_REC_XFER_ALIGN
+
+/* Define to 1 if you have the declaration of `_SC_LARGE_PAGESIZE', and to 0
+   if you don't. */
+#undef HAVE_DECL__SC_LARGE_PAGESIZE
+
+/* Define to 1 if you have the declaration of `_SC_PAGESIZE', and to 0 if you
+   don't. */
+#undef HAVE_DECL__SC_PAGESIZE
+
+/* Define to 1 if you have the declaration of `_SC_PAGE_SIZE', and to 0 if you
+   don't. */
+#undef HAVE_DECL__SC_PAGE_SIZE
+
 /* Define to 1 if you have the declaration of `__builtin_ctz', and to 0 if you
    don't. */
 #undef HAVE_DECL___BUILTIN_CTZ
@@ -46,6 +77,9 @@
 /* Define to 1 if you have the <grib_api.h> header file. */
 #undef HAVE_GRIB_API_H
 
+/* Define to 1 if you have the `grib_get_length' function. */
+#undef HAVE_GRIB_GET_LENGTH
+
 /* Define to 1 if you have the <hdf5.h> header file. */
 #undef HAVE_HDF5_H
 
diff --git a/libcdi/src/create_uuid.h b/libcdi/src/create_uuid.h
index 6b031b3..30566d2 100644
--- a/libcdi/src/create_uuid.h
+++ b/libcdi/src/create_uuid.h
@@ -11,3 +11,13 @@ void
 create_uuid(unsigned char uuid[CDI_UUID_SIZE]);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/datetime.h b/libcdi/src/datetime.h
index 10a2174..d0939d9 100644
--- a/libcdi/src/datetime.h
+++ b/libcdi/src/datetime.h
@@ -1,9 +1,22 @@
+#ifndef CDI_DATETIME_H
+#define CDI_DATETIME_H
+
 typedef struct
 {
   long date;
   long time;
 }
 DateTime;
+
+static inline int
+datetimeCmp(DateTime dt1, DateTime dt2)
+{
+  return 2 * ((dt1.date > dt2.date) - (dt1.date < dt2.date))
+    + (dt1.time > dt2.time) - (dt1.time < dt2.time);
+}
+
+
+#endif
 /*
  * Local Variables:
  * c-file-style: "Java"
diff --git a/libcdi/src/dmemory.c b/libcdi/src/dmemory.c
index 3adb757..0a54f5e 100644
--- a/libcdi/src/dmemory.c
+++ b/libcdi/src/dmemory.c
@@ -9,8 +9,6 @@
 #include <stdarg.h>
 #include <errno.h>
 
-#include "error.h"
-
 #if !defined(HAVE_CONFIG_H) && !defined(HAVE_MALLOC_H) && defined(SX)
 #  define  HAVE_MALLOC_H
 #endif
@@ -19,39 +17,28 @@
 #  include <malloc.h>
 #endif
 
-//There is no point in avoiding to include our own header, it is likely to be included before this file in the backed cdilib.c.
-//As such, we may as well always include it and let the compiler check our function signatures.
 #include "dmemory.h"
 
-//However, we need to avoid clobbering our own `malloc()` calls, so we ensure that our own malloc calls cannot be interpreted as macro calls.
-#define protected_realloc (realloc)
-#define protected_calloc (calloc)
-#define protected_malloc (malloc)
-#define protected_free (free)
-
-
-#define  MALLOC_FUNC   0
-#define  CALLOC_FUNC   1
-#define  REALLOC_FUNC  2
-#define  FREE_FUNC     3
+enum             {MALLOC_FUNC=0, CALLOC_FUNC, REALLOC_FUNC, FREE_FUNC};
+static const char *memfunc[] = {"Malloc", "Calloc", "Realloc", "Free"};
 
-#undef   UNDEFID
-#define  UNDEFID  -1
+#undef   MEM_UNDEFID
+#define  MEM_UNDEFID  -1
 
-#define  MAXNAME  32   /* Min = 8, for  "unknown" ! */
+#define  MEM_MAXNAME  32   /* Min = 8, for  "unknown" ! */
 
-int dmemory_ExitOnError = 0;
+static int dmemory_ExitOnError = 1;
 
 typedef struct
 {
   void     *ptr;
-  int       item;
   size_t    size;
   size_t    nobj;
+  int       item;
   int       mtype;
   int       line;
-  char      file[MAXNAME];
-  char      caller[MAXNAME];
+  char      filename[MEM_MAXNAME];
+  char      functionname[MEM_MAXNAME];
 }
 MemTable_t;
 
@@ -65,21 +52,45 @@ static size_t  MemUsed       = 0;
 static size_t  MaxMemUsed    = 0;
 
 static int     MEM_Debug     = 0;   /* If set to 1, debugging */
+static int     MEM_Info      = 0;   /* If set to 1, print mem table at exit */
+
+static
+const char *get_filename(const char *file)
+{
+  const char *fnptr = strrchr(file, '/');
+  if ( fnptr ) fnptr++;
+  else         fnptr = (char *) file;
+
+  return fnptr;
+}
+
 
 void memDebug(int debug)
 {
   MEM_Debug = debug;
 }
 
+/* If we're not using GNU C, elide __attribute__ */
+#if ! defined __GNUC__ && ! defined __attribute__
+#  define  __attribute__(x)  /*NOTHING*/
+#endif
+
 static
 void memInternalProblem(const char *caller, const char *fmt, ...)
+  __attribute__((noreturn));
+static
+void memError(const char *caller, const char *file, int line, size_t size)
+  __attribute__((noreturn));
+
+static
+void memInternalProblem(const char *functionname, const char *fmt, ...)
 {
   va_list args;
 
   va_start(args, fmt);
 
   printf("\n");
-   fprintf(stderr, "Internal problem (%s) : ", caller);
+   fprintf(stderr, "Internal problem (%s) : ", functionname);
   vfprintf(stderr, fmt, args);
    fprintf(stderr, "\n");
 
@@ -89,11 +100,11 @@ void memInternalProblem(const char *caller, const char *fmt, ...)
 }
 
 static
-void memError(const char *caller, const char *file, int line, size_t size)
+void memError(const char *functionname, const char *file, int line, size_t size)
 {
-  printf("\n");
+  fputs("\n", stdout);
   fprintf(stderr, "Error (%s) : Allocation of %zu bytes failed. [ line %d file %s ]\n",
-	  caller, size, line, file);
+	  functionname, size, line, get_filename(file));
 
   if ( errno ) perror("System error message ");
 
@@ -102,64 +113,36 @@ void memError(const char *caller, const char *file, int line, size_t size)
 
 static
 void memListPrintEntry(int mtype, int item, size_t size, void *ptr,
-		       const char *caller, const char *file, int line)
+		       const char *functionname, const char *file, int line)
 {
-  switch (mtype)
+  fprintf(stderr, "[%-7s ", memfunc[mtype]);
+
+  fprintf(stderr, "memory item %3d ", item);
+  fprintf(stderr, "(%6zu byte) ", size);
+  fprintf(stderr, "at %p", ptr);
+  if ( file != NULL )
     {
-    case MALLOC_FUNC:
-      fprintf(stderr, "[%-7s ", "Malloc");
-      break;
-    case CALLOC_FUNC:
-      fprintf(stderr, "[%-7s ", "Calloc");
-      break;
-    case REALLOC_FUNC:
-      fprintf(stderr, "[%-7s ", "Realloc");
-      break;
-    case FREE_FUNC:
-      fprintf(stderr, "[%-7s ", "Free");
-      break;
+      fprintf(stderr, " line %4d", line);
+      fprintf(stderr, " file %s", get_filename(file));
     }
-
-   fprintf(stderr, "memory item %3d ", item);
-   fprintf(stderr, "(%6zu byte) ", size);
-   fprintf(stderr, "at %p", ptr);
-   if ( file != NULL )
-     {
-       fprintf(stderr, " line %4d", line);
-       fprintf(stderr, " file %s", file);
-     }
-   if ( caller != NULL )
-     fprintf(stderr, " (%s)", caller);
-   fprintf(stderr, "]\n");
+  if ( functionname != NULL )
+    fprintf(stderr, " (%s)", functionname);
+  fprintf(stderr, "]\n");
 }
 
 static
 void memListPrintTable(void)
 {
-  int item, item1, item2 = 0;
-
   if ( MemObjs ) fprintf(stderr, "\nMemory table:\n");
 
-  /* find maximum item */
-  for (size_t memID = 0; memID < memTableSize; memID++)
-    if ( memTable[memID].item != UNDEFID )
-      if ( memTable[memID].item > item2 ) item2 = memTable[memID].item;
-
-  /* find minimum item */
-  item1 = item2;
-  for (size_t memID = 0; memID < memTableSize; memID++)
-    if ( memTable[memID].item != UNDEFID )
-      if ( memTable[memID].item < item1 ) item1 = memTable[memID].item;
-
-  for ( item = item1; item <= item2; item++ )
-    for (size_t memID = 0; memID < memTableSize; memID++)
-      {
-	if ( memTable[memID].item == item )
-	  memListPrintEntry(memTable[memID].mtype, memTable[memID].item,
-			    memTable[memID].size*memTable[memID].nobj,
-			    memTable[memID].ptr, memTable[memID].caller,
-			    memTable[memID].file, memTable[memID].line);
-      }
+  for ( size_t memID = 0; memID < memTableSize; memID++ )
+    {
+      if ( memTable[memID].item != MEM_UNDEFID )
+        memListPrintEntry(memTable[memID].mtype, memTable[memID].item,
+                          memTable[memID].size*memTable[memID].nobj,
+                          memTable[memID].ptr, memTable[memID].functionname,
+                          memTable[memID].filename, memTable[memID].line);
+    }
 
   if ( MemObjs )
     {
@@ -195,18 +178,17 @@ void memListPrintTable(void)
 static
 void memGetDebugLevel(void)
 {
-  char *debugLevel;
+  const char *envstr;
 
-  debugLevel = getenv("MEMORY_DEBUG");
+  envstr = getenv("MEMORY_INFO");
+  if ( envstr && isdigit((int) envstr[0]) ) MEM_Info = atoi(envstr);
 
-  if ( debugLevel )
-    {
-      if ( isdigit((int) debugLevel[0]) )
-	MEM_Debug = atoi(debugLevel);
+  envstr = getenv("MEMORY_DEBUG");
+  if ( envstr && isdigit((int) envstr[0]) ) MEM_Debug = atoi(envstr);
 
-      if ( MEM_Debug )
-	atexit(memListPrintTable);
-    }
+  if ( MEM_Debug && !MEM_Info ) MEM_Info = 1;
+
+  if ( MEM_Info ) atexit(memListPrintTable);
 }
 
 static
@@ -224,12 +206,12 @@ void memInit(void)
 static
 int memListDeleteEntry(void *ptr, size_t *size)
 {
-  int item = UNDEFID;
+  int item = MEM_UNDEFID;
   size_t memID;
 
-  for (memID = 0; memID < memTableSize; memID++ )
+  for ( memID = 0; memID < memTableSize; memID++ )
     {
-      if ( memTable[memID].item == UNDEFID ) continue;
+      if ( memTable[memID].item == MEM_UNDEFID ) continue;
       if ( memTable[memID].ptr == ptr ) break;
     }
 
@@ -238,11 +220,11 @@ int memListDeleteEntry(void *ptr, size_t *size)
       MemObjs--;
       MemUsed -= memTable[memID].size * memTable[memID].nobj;
       *size = memTable[memID].size * memTable[memID].nobj;
-       item = memTable[memID].item;
-       memTable[memID].item   = UNDEFID;
+      item = memTable[memID].item;
+      memTable[memID].item = MEM_UNDEFID;
     }
 
-  return (item);
+  return item;
 }
 
 static
@@ -252,16 +234,16 @@ void memTableInitEntry(size_t memID)
     memInternalProblem(__func__, "memID %d undefined!", memID);
 
   memTable[memID].ptr    = NULL;
-  memTable[memID].item   = UNDEFID;
+  memTable[memID].item   = MEM_UNDEFID;
   memTable[memID].size   = 0;
   memTable[memID].nobj   = 0;
-  memTable[memID].mtype  = UNDEFID;
-  memTable[memID].line   = UNDEFID;
+  memTable[memID].mtype  = MEM_UNDEFID;
+  memTable[memID].line   = MEM_UNDEFID;
 }
 
 static
 int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
-		    const char *caller, const char *file, int line)
+		    const char *functionname, const char *file, int line)
 {
   static int item = 0;
   size_t memSize = 0;
@@ -275,17 +257,17 @@ int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
     {
       memTableSize = 8;
       memSize  = memTableSize * sizeof(MemTable_t);
-      memTable = (MemTable_t *) protected_malloc(memSize);
+      memTable = (MemTable_t *) malloc(memSize);
       if( memTable == NULL ) memError(__func__, __FILE__, __LINE__, memSize);
 
-      for(size_t i = 0; i < memTableSize; i++)
+      for ( size_t i = 0; i < memTableSize; i++ )
 	memTableInitEntry(i);
     }
   else
     {
-      while( memID < memTableSize )
+      while ( memID < memTableSize )
 	{
-	  if ( memTable[memID].item == UNDEFID ) break;
+	  if ( memTable[memID].item == MEM_UNDEFID ) break;
 	  memID++;
 	}
     }
@@ -296,10 +278,10 @@ int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
     {
       memTableSize = 2*memTableSize;
       memSize  = memTableSize*sizeof(MemTable_t);
-      memTable = (MemTable_t*) protected_realloc(memTable, memSize);
-      if( memTable == NULL ) memError(__func__, __FILE__, __LINE__, memSize);
+      memTable = (MemTable_t*) realloc(memTable, memSize);
+      if ( memTable == NULL ) memError(__func__, __FILE__, __LINE__, memSize);
 
-      for (size_t i = memID; i < memTableSize; i++)
+      for ( size_t i = memID; i < memTableSize; i++ )
 	memTableInitEntry(i);
     }
 
@@ -312,28 +294,29 @@ int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
 
   if ( file )
     {
-      size_t len = strlen(file);
-      if ( len > MAXNAME-1 ) len = MAXNAME-1;
+      const char *filename = get_filename(file);
+      size_t len = strlen(filename);
+      if ( len > MEM_MAXNAME-1 ) len = MEM_MAXNAME-1;
 
-      (void) memcpy(memTable[memID].file, file, len);
-      memTable[memID].file[len] = '\0';
+      (void) memcpy(memTable[memID].filename, filename, len);
+      memTable[memID].filename[len] = '\0';
     }
   else
     {
-      (void) strcpy(memTable[memID].file, "unknown");
+      (void) strcpy(memTable[memID].filename, "unknown");
     }
 
-  if ( caller )
+  if ( functionname )
     {
-      size_t len = strlen(caller);
-      if ( len > MAXNAME-1 ) len = MAXNAME-1;
+      size_t len = strlen(functionname);
+      if ( len > MEM_MAXNAME-1 ) len = MEM_MAXNAME-1;
 
-      (void) memcpy(memTable[memID].caller, caller, len);
-      memTable[memID].caller[len] = '\0';
+      (void) memcpy(memTable[memID].functionname, functionname, len);
+      memTable[memID].functionname[len] = '\0';
     }
   else
     {
-      (void) strcpy(memTable[memID].caller, "unknown");
+      (void) strcpy(memTable[memID].functionname, "unknown");
     }
 
   MaxMemObjs++;
@@ -341,20 +324,19 @@ int memListNewEntry(int mtype, void *ptr, size_t size, size_t nobj,
   MemUsed += size*nobj;
   if ( MemUsed > MaxMemUsed ) MaxMemUsed = MemUsed;
 
-  return (item++);
+  return item++;
 }
 
 static
 int memListChangeEntry(void *ptrold, void *ptr, size_t size,
-		       const char *caller, const char *file, int line)
+		       const char *functionname, const char *file, int line)
 {
-  int item = UNDEFID;
+  int item = MEM_UNDEFID;
   size_t memID = 0;
-  size_t sizeold;
 
   while( memID < memTableSize )
     {
-      if ( memTable[memID].item != UNDEFID )
+      if ( memTable[memID].item != MEM_UNDEFID )
 	if ( memTable[memID].ptr == ptrold ) break;
       memID++;
     }
@@ -368,7 +350,7 @@ int memListChangeEntry(void *ptrold, void *ptr, size_t size,
     {
       item = memTable[memID].item;
 
-      sizeold = memTable[memID].size*memTable[memID].nobj;
+      size_t sizeold = memTable[memID].size*memTable[memID].nobj;
 
       memTable[memID].ptr   = ptr;
       memTable[memID].size  = size;
@@ -378,28 +360,29 @@ int memListChangeEntry(void *ptrold, void *ptr, size_t size,
 
       if ( file )
 	{
-	  size_t len = strlen(file);
-	  if ( len > MAXNAME-1 ) len = MAXNAME-1;
+          const char *filename = get_filename(file);
+	  size_t len = strlen(filename);
+	  if ( len > MEM_MAXNAME-1 ) len = MEM_MAXNAME-1;
 
-	  (void) memcpy(memTable[memID].file, file, len);
-	  memTable[memID].file[len] = '\0';
+	  (void) memcpy(memTable[memID].filename, filename, len);
+	  memTable[memID].filename[len] = '\0';
 	}
       else
 	{
-	  (void) strcpy(memTable[memID].file, "unknown");
+	  (void) strcpy(memTable[memID].filename, "unknown");
 	}
 
-      if ( caller )
+      if ( functionname )
 	{
-	  size_t len = strlen(caller);
-	  if ( len > MAXNAME-1 ) len = MAXNAME-1;
+	  size_t len = strlen(functionname);
+	  if ( len > MEM_MAXNAME-1 ) len = MEM_MAXNAME-1;
 
-	  (void) memcpy(memTable[memID].caller, caller, len);
-	  memTable[memID].caller[len] = '\0';
+	  (void) memcpy(memTable[memID].functionname, functionname, len);
+	  memTable[memID].functionname[len] = '\0';
 	}
       else
 	{
-	  (void) strcpy(memTable[memID].caller, "unknown");
+	  (void) strcpy(memTable[memID].functionname, "unknown");
 	}
 
       MemUsed -= sizeold;
@@ -407,155 +390,129 @@ int memListChangeEntry(void *ptrold, void *ptr, size_t size,
       if ( MemUsed > MaxMemUsed ) MaxMemUsed = MemUsed;
     }
 
-  return (item);
+  return item;
 }
 
 
-void *Calloc(const char *caller, const char *file, int line, size_t nobjs, size_t size)
+void *memCalloc(size_t nobjs, size_t size, const char *file, const char *functionname, int line)
 {
   void *ptr = NULL;
-  int item = UNDEFID;
 
   memInit();
 
   if ( nobjs*size > 0 )
     {
-      ptr = protected_calloc(nobjs, size);
+      ptr = calloc(nobjs, size);
 
-      if ( MEM_Debug )
+      if ( MEM_Info )
 	{
 	  memAccess++;
 
-	  if ( ptr ) item = memListNewEntry(CALLOC_FUNC, ptr, size, nobjs, caller, file, line);
+          int item = MEM_UNDEFID;
+	  if ( ptr ) item = memListNewEntry(CALLOC_FUNC, ptr, size, nobjs, functionname, file, line);
 
-	  memListPrintEntry(CALLOC_FUNC, item, size*nobjs, ptr, caller, file, line);
+	  if ( MEM_Debug ) memListPrintEntry(CALLOC_FUNC, item, size*nobjs, ptr, functionname, file, line);
 	}
 
       if ( ptr == NULL && dmemory_ExitOnError )
-	memError(caller, file, line, size*nobjs);
+	memError(functionname, file, line, size*nobjs);
     }
   else
-    fprintf(stderr, "Warning (%s) : Allocation of 0 bytes! [ line %d file %s ]\n", caller, line, file);
+    fprintf(stderr, "Warning (%s) : Allocation of 0 bytes! [ line %d file %s ]\n", functionname, line, file);
 
-  return(ptr);
+  return ptr;
 }
 
 
-void *Malloc(const char *caller, const char *file, int line, size_t size)
+void *memMalloc(size_t size, const char *file, const char *functionname, int line)
 {
   void *ptr = NULL;
-  int item = UNDEFID;
 
   memInit();
 
   if ( size > 0 )
     {
-      ptr = protected_malloc(size);
+      ptr = malloc(size);
 
-      if ( MEM_Debug )
+      if ( MEM_Info )
 	{
 	  memAccess++;
 
-	  if ( ptr ) item = memListNewEntry(MALLOC_FUNC, ptr, size, 1, caller, file, line);
+          int item = MEM_UNDEFID;
+	  if ( ptr ) item = memListNewEntry(MALLOC_FUNC, ptr, size, 1, functionname, file, line);
 
-	  memListPrintEntry(MALLOC_FUNC, item, size, ptr, caller, file, line);
+	  if ( MEM_Debug ) memListPrintEntry(MALLOC_FUNC, item, size, ptr, functionname, file, line);
 	}
 
       if ( ptr == NULL && dmemory_ExitOnError )
-	memError(caller, file, line, size);
+	memError(functionname, file, line, size);
     }
   else
-    fprintf(stderr, "Warning (%s) : Allocation of 0 bytes! [ line %d file %s ]\n", caller, line, file);
+    fprintf(stderr, "Warning (%s) : Allocation of 0 bytes! [ line %d file %s ]\n", functionname, line, file);
 
-  return (ptr);
+  return ptr;
 }
 
 
-void *Realloc(const char *caller, const char *file, int line, void *ptrold, size_t size)
+void *memRealloc(void *ptrold, size_t size, const char *file, const char *functionname, int line)
 {
   void *ptr = NULL;
-  int item = UNDEFID;
 
   memInit();
 
   if ( size > 0 )
     {
-      ptr = protected_realloc(ptrold, size);
+      ptr = realloc(ptrold, size);
 
-      if ( MEM_Debug )
+      if ( MEM_Info )
 	{
 	  memAccess++;
 
+          int item = MEM_UNDEFID;
 	  if ( ptr )
 	    {
-	      item = memListChangeEntry(ptrold, ptr, size, caller, file, line);
+	      item = memListChangeEntry(ptrold, ptr, size, functionname, file, line);
 
-	      if ( item == UNDEFID ) item = memListNewEntry(REALLOC_FUNC, ptr, size, 1, caller, file, line);
+	      if ( item == MEM_UNDEFID ) item = memListNewEntry(REALLOC_FUNC, ptr, size, 1, functionname, file, line);
 	    }
 
-	  memListPrintEntry(REALLOC_FUNC, item, size, ptr, caller, file, line);
+	  if ( MEM_Debug ) memListPrintEntry(REALLOC_FUNC, item, size, ptr, functionname, file, line);
 	}
 
       if ( ptr == NULL && dmemory_ExitOnError )
-	memError(caller, file, line, size);
+	memError(functionname, file, line, size);
     }
   else
-    fprintf(stderr, "Warning (%s) : Allocation of 0 bytes! [ line %d file %s ]\n", caller, line, file);
+    fprintf(stderr, "Warning (%s) : Allocation of 0 bytes! [ line %d file %s ]\n", functionname, line, get_filename(file));
 
-  return (ptr);
+  return ptr;
 }
 
 
-void Free(const char *caller, const char *file, int line, void *ptr)
+void memFree(void *ptr, const char *file, const char *functionname, int line)
 {
-  int item;
-  size_t size;
-
   memInit();
 
-  if ( MEM_Debug )
+  if ( MEM_Info )
     {
+      int item;
+      size_t size;
+
       if ( (item = memListDeleteEntry(ptr, &size)) >= 0 )
 	{
-	  memListPrintEntry(FREE_FUNC, item, size, ptr, caller, file, line);
+	  if ( MEM_Debug ) memListPrintEntry(FREE_FUNC, item, size, ptr, functionname, file, line);
 	}
       else
 	{
-	  if ( ptr )
+	  if ( ptr && MEM_Debug  )
 	    fprintf(stderr, "%s info: memory entry at %p not found. [line %4d file %s (%s)]\n",
-		    __func__, ptr, line, file, caller);
+		    __func__, ptr, line, get_filename(file), functionname);
 	}
     }
 
-  protected_free(ptr);
-}
-
-void *cdiXmalloc(size_t size, const char *filename, const char *functionname,
-                 int line)
-{
-  void *value = protected_malloc(size);
-  if (size == 0 || value != NULL) ; else
-    cdiAbort(filename, functionname, line, "malloc failed: %s", strerror(errno));
-  return value;
-}
-
-void *cdiXcalloc(size_t nmemb, size_t size, const char *filename,
-                 const char *functionname, int line)
-{
-  void *value = protected_calloc(nmemb, size);
-  if (size == 0 || value != NULL) ; else
-    cdiAbort(filename, functionname, line, "calloc failed: %s", strerror(errno) );
-  return value;
+  free(ptr);
 }
 
-void *cdiXrealloc(void *p, size_t size, const char *functionname,
-                  const char *filename, int line)
-{
-  void *value = protected_realloc(p, size);
-  if (size == 0 || value != NULL) ; else
-    cdiAbort(filename, functionname, line, "realloc failed: %s", strerror(errno));
-  return value;
-}
 
 size_t memTotal(void)
 {
@@ -581,7 +538,7 @@ size_t memTotal(void)
   memtotal = (size_t)meminfo.arena;
 #endif
 
-  return (memtotal);
+  return memtotal;
 }
 
 
diff --git a/libcdi/src/dmemory.h b/libcdi/src/dmemory.h
index dced537..d5f60a9 100644
--- a/libcdi/src/dmemory.h
+++ b/libcdi/src/dmemory.h
@@ -1,20 +1,13 @@
 #ifndef _DMEMORY_H
 #define _DMEMORY_H
 
-//Ensure that all standard headers that may declare malloc() and friends are already included so that our macros won't clobber their definitions.
-#include <stdlib.h>
-#ifdef HAVE_MALLOC_H
-    #include <malloc.h>
-#endif
-
-/*
- * if DEBUG_MEMORY is defined setenv MEMORY_DEBUG to debug memory
- */
+#include <stdio.h>
 
+// if DEBUG_MEMORY is defined setenv MEMORY_DEBUG to debug memory
 #define  DEBUG_MEMORY
 
-#ifndef  WITH_CALLER_NAME
-#define  WITH_CALLER_NAME
+#ifndef  WITH_FUNCTION_NAME
+#define  WITH_FUNCTION_NAME
 #endif
 
 extern size_t  memTotal(void);
@@ -23,38 +16,25 @@ extern void    memExitOnError(void);
 
 #if  defined  DEBUG_MEMORY
 
-extern void   *Realloc(const char *caller, const char *file, int line, void *ptr, size_t size);
-extern void   *Calloc (const char *caller, const char *file, int line, size_t nmemb, size_t size);
-extern void   *Malloc (const char *caller, const char *file, int line, size_t size);
-extern void    Free   (const char *caller, const char *file, int line, void *ptr);
+extern void   *memRealloc(void *ptr, size_t size, const char *file, const char *functionname, int line);
+extern void   *memCalloc (size_t nmemb, size_t size, const char *file, const char *functionname, int line);
+extern void   *memMalloc (size_t size, const char *file, const char *functionname, int line);
+extern void    memFree   (void *ptr, const char *file, const char *functionname, int line);
 
-#if  defined  calloc
-#  undef  calloc
-#endif
-
-#if  defined  WITH_CALLER_NAME
-#  define  realloc(p, s)  Realloc(__func__, __FILE__, __LINE__, (p), (s))
-#  define   calloc(n, s)   Calloc(__func__, __FILE__, __LINE__, (n), (s))
-#  define   malloc(s)      Malloc(__func__, __FILE__, __LINE__, (s))
-#  define     free(p)        Free(__func__, __FILE__, __LINE__, (p))
+#if  defined  WITH_FUNCTION_NAME
+#  define  Realloc(p, s)  memRealloc((p), (s), __FILE__, __func__, __LINE__)
+#  define   Calloc(n, s)   memCalloc((n), (s), __FILE__, __func__, __LINE__)
+#  define   Malloc(s)      memMalloc((s), __FILE__, __func__, __LINE__)
+#  define     Free(p)        memFree((p), __FILE__, __func__, __LINE__)
 #else
-#  define  realloc(p, s)  Realloc((void *) NULL, __FILE__, __LINE__, (p), (s))
-#  define   calloc(n, s)   Calloc((void *) NULL, __FILE__, __LINE__, (n), (s))
-#  define   malloc(s)      Malloc((void *) NULL, __FILE__, __LINE__, (s))
-#  define     free(p)        Free((void *) NULL, __FILE__, __LINE__, (p))
+#  define  Realloc(p, s)  memRealloc((p), (s), __FILE__, (void *) NULL, __LINE__)
+#  define   Calloc(n, s)   memCalloc((n), (s), __FILE__, (void *) NULL, __LINE__)
+#  define   Malloc(s)      memMalloc((s), __FILE__, (void *) NULL, __LINE__)
+#  define     Free(p)        memFree((p), __FILE__, (void *) NULL, __LINE__)
 #endif
 
 #endif /* DEBUG_MEMORY */
 
-void *cdiXmalloc(size_t, const char *, const char *, int);
-#define xmalloc(size) cdiXmalloc((size), __FILE__, __func__,  __LINE__ )
-
-void *cdiXcalloc(size_t, size_t, const char *, const char *, int);
-#define xcalloc(nmemb,size) cdiXcalloc((nmemb), (size), __FILE__, __func__, __LINE__)
-
-void *cdiXrealloc(void *, size_t, const char *, const char *, int);
-#define xrealloc(p,size) cdiXrealloc((p), (size), __FILE__, __func__, __LINE__)
-
 #endif /* _DMEMORY_H */
 /*
  * Local Variables:
diff --git a/libcdi/src/error.c b/libcdi/src/error.c
index 4d21a81..7d488a9 100644
--- a/libcdi/src/error.c
+++ b/libcdi/src/error.c
@@ -10,11 +10,19 @@
 #if !defined (NAMESPACE_H)
 #include "namespace.h"
 #endif
+#include "error.h"
 
 int _ExitOnError   = 1;	/* If set to 1, exit on error       */
 int _Verbose = 1;	/* If set to 1, errors are reported */
 int _Debug   = 0;       /* If set to 1, debugging           */
 
+/* If we're not using GNU C, elide __attribute__ */
+#if ! defined __GNUC__ && ! defined __attribute__
+#  define  __attribute__(x)  /*NOTHING*/
+#endif
+
+void SysError_(const char *caller, const char *fmt, ...)
+  __attribute__((noreturn));
 
 void SysError_(const char *caller, const char *fmt, ...)
 {
diff --git a/libcdi/src/exse.h b/libcdi/src/exse.h
new file mode 100644
index 0000000..a21eec4
--- /dev/null
+++ b/libcdi/src/exse.h
@@ -0,0 +1,9 @@
+#ifndef EXSE_H
+#define EXSE_H
+
+enum {
+  EXSE_SINGLE_PRECISION = 4,
+  EXSE_DOUBLE_PRECISION = 8,
+};
+
+#endif
diff --git a/libcdi/src/extralib.c b/libcdi/src/extralib.c
index 9b92391..972f40b 100644
--- a/libcdi/src/extralib.c
+++ b/libcdi/src/extralib.c
@@ -3,17 +3,17 @@
 #endif
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
 #include <ctype.h>
 
 #include "dmemory.h"
-
 #include "extra.h"
 #include "error.h"
 #include "file.h"
 #include "binary.h"
-#include "stream_fcommon.h"
+#include "exse.h"
 #include "swap.h"
 
 
@@ -30,16 +30,15 @@ static int extDefaultNumber = EXT_REAL;
 /*
  * A version string.
  */
-
 #undef  LIBVERSION
-#define LIBVERSION      1.3.2
+#define LIBVERSION      1.4.0
 #define XSTRING(x)	#x
 #define STRING(x)	XSTRING(x)
-static const char ext_libvers[] = STRING(LIBVERSION) " of "__DATE__" "__TIME__;
+static const char ext_libvers[] = STRING(LIBVERSION) " of " __DATE__ " " __TIME__ ;
 
 const char *extLibraryVersion(void)
 {
-  return (ext_libvers);
+  return ext_libvers;
 }
 
 
@@ -55,13 +54,12 @@ void extDebug(int debug)
 }
 
 
-static void extLibInit()
+static
+void extLibInit()
 {
-  char *envString;
-  char *envName = "EXT_PRECISION";
+  const char *envName = "EXT_PRECISION";
 
-
-  envString = getenv(envName);
+  char *envString = getenv(envName);
   if ( envString )
     {
       int pos = 0;
@@ -75,8 +73,8 @@ static void extLibInit()
 		extDefaultNumber = EXT_REAL;
 		switch ( (int) envString[pos+1] )
 		  {
-		  case '4': extDefaultPrec = SINGLE_PRECISION; break;
-		  case '8': extDefaultPrec = DOUBLE_PRECISION; break;
+		  case '4': extDefaultPrec = EXSE_SINGLE_PRECISION; break;
+		  case '8': extDefaultPrec = EXSE_DOUBLE_PRECISION; break;
 		  default:
 		    Message("Invalid digit in %s: %s", envName, envString);
 		  }
@@ -87,8 +85,8 @@ static void extLibInit()
 		extDefaultNumber = EXT_COMP;
 		switch ( (int) envString[pos+1] )
 		  {
-		  case '4': extDefaultPrec = SINGLE_PRECISION; break;
-		  case '8': extDefaultPrec = DOUBLE_PRECISION; break;
+		  case '4': extDefaultPrec = EXSE_SINGLE_PRECISION; break;
+		  case '8': extDefaultPrec = EXSE_DOUBLE_PRECISION; break;
 		  default:
 		    Message("Invalid digit in %s: %s", envName, envString);
 		  }
@@ -121,15 +119,13 @@ void extInit(extrec_t *extp)
 
 void *extNew(void)
 {
-  extrec_t *extp;
-
   if ( ! initExtLib ) extLibInit();
 
-  extp = (extrec_t *) malloc(sizeof(extrec_t));
+  extrec_t *extp = (extrec_t *) Malloc(sizeof(extrec_t));
 
   extInit(extp);
 
-  return ((void*)extp);
+  return (void*)extp;
 }
 
 
@@ -139,25 +135,24 @@ void extDelete(void *ext)
 
   if ( extp )
     {
-      if ( extp->buffer ) free(extp->buffer);
-      free(extp);
+      if ( extp->buffer ) Free(extp->buffer);
+      Free(extp);
     }
 }
 
 
 int extCheckFiletype(int fileID, int *swap)
 {
-  size_t blocklen = 0, fact = 0;
-  size_t sblocklen = 0;
+  size_t fact = 0;
   size_t data =  0;
   size_t dimxy = 0;
   int found = 0;
   unsigned char buffer[40], *pbuf;
 
-  if ( fileRead(fileID, buffer, 4) != 4 ) return (found);
+  if ( fileRead(fileID, buffer, 4) != 4 ) return found;
 
-  blocklen  = (size_t) get_UINT32(buffer);
-  sblocklen = (size_t) get_SUINT32(buffer);
+  size_t blocklen  = (size_t) get_UINT32(buffer);
+  size_t sblocklen = (size_t) get_SUINT32(buffer);
 
   if ( EXT_Debug )
     Message("blocklen = %d sblocklen = %d", blocklen, sblocklen);
@@ -166,7 +161,7 @@ int extCheckFiletype(int fileID, int *swap)
     {
      *swap = 0;
       fact = blocklen/4;
-      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return found;
       pbuf = buffer+3*fact;      dimxy = (size_t) get_UINT32(pbuf);
       pbuf = buffer+blocklen+4;  data  = (size_t) get_UINT32(pbuf);
     }
@@ -174,7 +169,7 @@ int extCheckFiletype(int fileID, int *swap)
     {
      *swap = 0;
       fact = blocklen/4;
-      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return found;
       pbuf = buffer+3*fact;      dimxy = (size_t) get_UINT64(pbuf);
       pbuf = buffer+blocklen+4;  data  = (size_t) get_UINT32(pbuf);
     }
@@ -182,7 +177,7 @@ int extCheckFiletype(int fileID, int *swap)
     {
      *swap = 1;
       fact = sblocklen/4;
-      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return found;
       pbuf = buffer+3*fact;       dimxy = (size_t) get_SUINT32(pbuf);
       pbuf = buffer+sblocklen+4;  data  = (size_t) get_SUINT32(pbuf);
     }
@@ -190,7 +185,7 @@ int extCheckFiletype(int fileID, int *swap)
     {
      *swap = 1;
       fact = sblocklen/4;
-      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return found;
       pbuf = buffer+3*fact;       dimxy = (size_t) get_SUINT64(pbuf);
       pbuf = buffer+sblocklen+4;  data  = (size_t) get_SUINT32(pbuf);
     }
@@ -206,30 +201,28 @@ int extCheckFiletype(int fileID, int *swap)
       Message("dimxy = %lu data = %lu", dimxy, data);
     }
 
-  return (found);
+  return found;
 }
 
 
 int extInqHeader(void *ext, int *header)
 {
   extrec_t *extp = (extrec_t *) ext;
-  size_t i;
 
-  for ( i = 0; i < EXT_HEADER_LEN; i++ )
+  for ( size_t i = 0; i < EXT_HEADER_LEN; i++ )
     header[i] = extp->header[i];
 
   if ( EXT_Debug ) Message("datasize = %lu", extp->datasize);
 
-  return (0);
+  return 0;
 }
 
 
 int extDefHeader(void *ext, const int *header)
 {
   extrec_t *extp = (extrec_t *) ext;
-  size_t i;
 
-  for ( i = 0; i < EXT_HEADER_LEN; i++ )
+  for ( size_t i = 0; i < EXT_HEADER_LEN; i++ )
     extp->header[i] = header[i];
 
   extp->datasize = (size_t)header[3];
@@ -237,26 +230,22 @@ int extDefHeader(void *ext, const int *header)
 
   if ( EXT_Debug ) Message("datasize = %lu", extp->datasize);
 
-  return (0);
+  return 0;
 }
 
-
-static int extInqData(extrec_t *extp, int prec, void *data)
+static
+int extInqData(extrec_t *extp, int prec, void *data)
 {
-  size_t datasize;
   size_t i;
   int ierr = 0;
-  int rprec;
-  void *buffer;
   int byteswap = extp->byteswap;
-
-  datasize = extp->datasize;
-  buffer   = extp->buffer;
-  rprec    = extp->prec;
+  size_t datasize = extp->datasize;
+  void *buffer   = extp->buffer;
+  int rprec    = extp->prec;
 
   switch ( rprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	if ( sizeof(FLT32) == 4 )
 	  {
@@ -274,7 +263,7 @@ static int extInqData(extrec_t *extp, int prec, void *data)
 	  }
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
 	if ( sizeof(FLT64) == 8 )
 	  {
 	    if ( byteswap ) swap8byte(buffer, datasize);
@@ -297,31 +286,27 @@ static int extInqData(extrec_t *extp, int prec, void *data)
       }
     }
 
-  return (ierr);
+  return ierr;
 }
 
 
 int extInqDataSP(void *ext, float *data)
 {
-  return (extInqData(ext, SINGLE_PRECISION, (void *) data));
+  return extInqData((extrec_t *)ext, EXSE_SINGLE_PRECISION, (void *) data);
 }
 
 
 int extInqDataDP(void *ext, double *data)
 {
-  return (extInqData(ext, DOUBLE_PRECISION, (void *) data));
+  return extInqData((extrec_t *)ext, EXSE_DOUBLE_PRECISION, (void *) data);
 }
 
 
-int extDefData(void *ext, int prec, const void *data)
+static int extDefData(void *ext, int prec, const void *data)
 {
   extrec_t *extp = (extrec_t *) ext;
-  size_t datasize;
-  size_t blocklen;
-  size_t buffersize;
   size_t i;
   int rprec;
-  int *header;
   void *buffer;
 
   if ( extDefaultPrec ) rprec = extDefaultPrec;
@@ -331,21 +316,21 @@ int extDefData(void *ext, int prec, const void *data)
 
   extp->prec = rprec;
 
-  header = extp->header;
+  int *header = extp->header;
 
-  datasize = (size_t)header[3];
+  size_t datasize = (size_t)header[3];
   if ( extp->number == EXT_COMP ) datasize *= 2;
-  blocklen = datasize * (size_t)rprec;
+  size_t blocklen = datasize * (size_t)rprec;
 
   extp->datasize = datasize;
 
-  buffersize = extp->buffersize;
+  size_t buffersize = extp->buffersize;
 
   if ( buffersize != blocklen )
     {
       buffersize = blocklen;
       buffer = extp->buffer;
-      buffer = realloc(buffer, buffersize);
+      buffer = Realloc(buffer, buffersize);
       extp->buffer = buffer;
       extp->buffersize = buffersize;
     }
@@ -354,22 +339,22 @@ int extDefData(void *ext, int prec, const void *data)
 
   switch ( rprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	if ( rprec == prec )
 	  memcpy(buffer, data, datasize*sizeof(FLT32));
 	else
-	  for (i = 0; i < datasize; i++)
+	  for ( i = 0; i < datasize; i++ )
 	    ((float *) buffer)[i] = (float) ((double *) data)[i];
 
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
 	if ( rprec == prec )
 	  memcpy(buffer, data, datasize*sizeof(FLT64));
 	else
-	  for (i = 0; i < datasize; i++)
+	  for ( i = 0; i < datasize; i++ )
 	    ((double *) buffer)[i] = (double) ((float *) data)[i];
 
 	break;
@@ -381,29 +366,27 @@ int extDefData(void *ext, int prec, const void *data)
       }
     }
 
-  return (0);
+  return 0;
 }
 
 
 int extDefDataSP(void *ext, const float *data)
 {
-  return (extDefData(ext, SINGLE_PRECISION, (void *) data));
+  return extDefData(ext, EXSE_SINGLE_PRECISION, (void *) data);
 }
 
 
 int extDefDataDP(void *ext, const double *data)
 {
-  return (extDefData(ext, DOUBLE_PRECISION, (void *) data));
+  return extDefData(ext, EXSE_DOUBLE_PRECISION, (void *) data);
 }
 
 
 int extRead(int fileID, void *ext)
 {
   extrec_t *extp = (extrec_t *) ext;
-  size_t blocklen, blocklen2;
   size_t i;
   void *buffer;
-  int byteswap;
   int status;
 
   if ( ! extp->checked )
@@ -413,12 +396,12 @@ int extRead(int fileID, void *ext)
       extp->checked = 1;
     }
 
-  byteswap = extp->byteswap;
+  int byteswap = extp->byteswap;
 
   /* read header record */
-  blocklen = binReadF77Block(fileID, byteswap);
+  size_t blocklen = binReadF77Block(fileID, byteswap);
 
-  if ( fileEOF(fileID) ) return (-1);
+  if ( fileEOF(fileID) ) return -1;
 
   if ( EXT_Debug )
     Message("blocklen = %lu", blocklen);
@@ -429,7 +412,7 @@ int extRead(int fileID, void *ext)
 
   switch ( hprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
         INT32 tempheader[4];
 	binReadInt32(fileID, byteswap, EXT_HEADER_LEN, tempheader);
@@ -439,7 +422,7 @@ int extRead(int fileID, void *ext)
 
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
         INT64 tempheader[4];
 	binReadInt64(fileID, byteswap, EXT_HEADER_LEN, tempheader);
@@ -456,12 +439,12 @@ int extRead(int fileID, void *ext)
       }
     }
 
-  blocklen2 = binReadF77Block(fileID, byteswap);
+  size_t blocklen2 = binReadF77Block(fileID, byteswap);
 
   if ( blocklen2 != blocklen )
     {
       Warning("Header blocklen differ (blocklen1=%d; blocklen2=%d)!", blocklen, blocklen2);
-      if ( blocklen2 != 0 ) return (-1);
+      if ( blocklen2 != 0 ) return -1;
     }
 
   extp->datasize = (size_t)extp->header[3];
@@ -476,7 +459,7 @@ int extRead(int fileID, void *ext)
     {
       buffersize = blocklen;
       buffer = extp->buffer;
-      buffer = realloc(buffer, buffersize);
+      buffer = Realloc(buffer, buffersize);
       extp->buffer = buffer;
       extp->buffersize = buffersize;
     }
@@ -496,10 +479,10 @@ int extRead(int fileID, void *ext)
       extp->number = EXT_COMP;
     }
 
-  if ( dprec != SINGLE_PRECISION && dprec != DOUBLE_PRECISION )
+  if ( dprec != EXSE_SINGLE_PRECISION && dprec != EXSE_DOUBLE_PRECISION )
     {
       Warning("Unexpected data precision %d", dprec);
-      return (-1);
+      return -1;
     }
 
   fileRead(fileID, buffer, blocklen);
@@ -509,52 +492,45 @@ int extRead(int fileID, void *ext)
   if ( blocklen2 != blocklen )
     {
       Warning("Data blocklen differ (blocklen1=%d; blocklen2=%d)!", blocklen, blocklen2);
-      if ( blocklen2 != 0 ) return (-1);
+      if ( blocklen2 != 0 ) return -1;
     }
 
-  return (0);
+  return 0;
 }
 
 
 int extWrite(int fileID, void *ext)
 {
   extrec_t *extp = (extrec_t *) ext;
-  size_t datasize;
-  size_t blocklen;
   size_t i;
-  int rprec, number;
-  char tempheader[32];
-  int *header;
-  void *buffer;
+  union { INT32 i32[EXT_HEADER_LEN]; INT64 i64[EXT_HEADER_LEN]; } tempheader;
   int byteswap = extp->byteswap;
-
-
-  rprec  = extp->prec;
-  number = extp->number;
-  header = extp->header;
+  int rprec  = extp->prec;
+  int number = extp->number;
+  int *header = extp->header;
 
   /* write header record */
-  blocklen = EXT_HEADER_LEN * (size_t)rprec;
+  size_t blocklen = EXT_HEADER_LEN * (size_t)rprec;
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
   switch ( rprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
-	for (i = 0; i < EXT_HEADER_LEN; i++)
-          ((INT32 *) tempheader)[i] = (INT32) header[i];
+	for ( i = 0; i < EXT_HEADER_LEN; i++ )
+          tempheader.i32[i] = (INT32) header[i];
 
-	binWriteInt32(fileID, byteswap, EXT_HEADER_LEN, (INT32 *) tempheader);
+	binWriteInt32(fileID, byteswap, EXT_HEADER_LEN, tempheader.i32);
 
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
-	for (i = 0; i < EXT_HEADER_LEN; i++)
-          ((INT64 *) tempheader)[i] = (INT64) header[i];
+	for ( i = 0; i < EXT_HEADER_LEN; i++ )
+          tempheader.i64[i] = (INT64) header[i];
 
-	binWriteInt64(fileID, byteswap, EXT_HEADER_LEN, (INT64 *) tempheader);
+	binWriteInt64(fileID, byteswap, EXT_HEADER_LEN, tempheader.i64);
 
 	break;
       }
@@ -567,7 +543,7 @@ int extWrite(int fileID, void *ext)
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
-  datasize = (size_t)header[3];
+  size_t datasize = (size_t)header[3];
   if ( number == EXT_COMP ) datasize *= 2;
   blocklen = datasize * (size_t)rprec;
 
@@ -575,16 +551,16 @@ int extWrite(int fileID, void *ext)
 
   extp->datasize = datasize;
 
-  buffer = extp->buffer;
+  void *buffer = extp->buffer;
 
   switch ( rprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	binWriteFlt32(fileID, byteswap, datasize, (FLT32 *) buffer);
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
 	binWriteFlt64(fileID, byteswap, datasize, (FLT64 *) buffer);
 	break;
@@ -598,7 +574,7 @@ int extWrite(int fileID, void *ext)
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
-  return (0);
+  return 0;
 }
 /*
  * Local Variables:
diff --git a/libcdi/src/file.c b/libcdi/src/file.c
index 279d10a..529732e 100644
--- a/libcdi/src/file.c
+++ b/libcdi/src/file.c
@@ -35,7 +35,7 @@ char *strdup(const char *s);
 ({                                                \
    const char *__old = (s);                       \
    size_t __len = strlen(__old) + 1;              \
-   char *__new = (char *) malloc(__len);          \
+   char *__new = (char *) Malloc(__len);          \
    (char *) memcpy(__new, __old, __len);          \
 })
 */
@@ -92,15 +92,15 @@ typedef struct
   int        eof;            /* end of file flag              */
   int        fd;             /* file descriptor used for read */
   FILE      *fp;             /* FILE pointer used for write   */
-  int        mode;           /* file access mode              */
   char      *name;           /* file name                     */
   off_t      size;           /* file size                     */
   off_t      position;       /* file position                 */
   long       access;         /* file access                   */
   off_t      byteTrans;      /*                               */
   size_t     blockSize;      /* file block size               */
-  int        type;           /* file type ( 1:open 2:fopen )  */
-  int        bufferType;     /* buffer type ( 1:std 2:mmap )  */
+  int        mode;           /* file access mode              */
+  short      type;           /* file type ( 1:open 2:fopen )  */
+  short      bufferType;     /* buffer type ( 1:std 2:mmap )  */
   size_t     bufferSize;     /* file buffer size              */
   size_t     mappedSize;     /* mmap buffer size              */
   char      *buffer;         /* file buffer                   */
@@ -135,10 +135,10 @@ static int FileInfo  = FALSE;
 
 static size_t FileBufferSizeMin = MIN_BUF_SIZE;
 static long   FileBufferSizeEnv = -1;
-static int    FileBufferTypeEnv =  0;
+static short  FileBufferTypeEnv =  0;
 
-static int    FileTypeRead  = FILE_TYPE_OPEN;
-static int    FileTypeWrite = FILE_TYPE_FOPEN;
+static short  FileTypeRead  = FILE_TYPE_OPEN;
+static short  FileTypeWrite = FILE_TYPE_FOPEN;
 static int    FileFlagWrite = 0;
 
 static int    FILE_Debug = 0;   /* If set to 1, debugging */
@@ -153,7 +153,7 @@ static void file_table_print(void);
 #define  LIBVERSION      1.8.2
 #define  XSTRING(x)	 #x
 #define  STRING(x) 	 XSTRING(x)
-const char file_libvers[] = STRING(LIBVERSION) " of "__DATE__" "__TIME__;
+static const char file_libvers[] = STRING(LIBVERSION) " of " __DATE__ " " __TIME__;
 
 /*
   21/05/2004  1.3.2 set min I/O Buffersize to 128k
@@ -190,7 +190,7 @@ void file_list_new(void)
 {
   assert(_fileList == NULL);
 
-  _fileList = (filePtrToIdx *)xmalloc((size_t)_file_max * sizeof (filePtrToIdx));
+  _fileList = (filePtrToIdx *) Malloc((size_t)_file_max * sizeof (filePtrToIdx));
 }
 
 static
@@ -198,7 +198,7 @@ void file_list_delete(void)
 {
   if ( _fileList )
     {
-      free(_fileList);
+      Free(_fileList);
       _fileList = NULL;
     }
 }
@@ -307,7 +307,7 @@ bfile_t *file_new_entry(void)
 {
   bfile_t *fileptr;
 
-  fileptr = (bfile_t *) malloc(sizeof(bfile_t));
+  fileptr = (bfile_t *) Malloc(sizeof(bfile_t));
 
   if ( fileptr ) file_init_entry(fileptr);
 
@@ -323,7 +323,7 @@ void file_delete_entry(bfile_t *fileptr)
 
   FILE_LOCK();
 
-  free(fileptr);
+  Free(fileptr);
 
   _fileList[idx].next = _fileAvail;
   _fileList[idx].ptr  = 0;
@@ -342,16 +342,15 @@ const char *fileLibraryVersion(void)
 }
 
 
-#ifndef POSIXIO_DEFAULT_PAGESIZE
-#define POSIXIO_DEFAULT_PAGESIZE 4096
-#endif
-
 static
 int pagesize(void)
 {
 #if defined(_SC_PAGESIZE)
   return ((int) sysconf(_SC_PAGESIZE));
 #else
+#ifndef POSIXIO_DEFAULT_PAGESIZE
+#define POSIXIO_DEFAULT_PAGESIZE 4096
+#endif
   return ((int) POSIXIO_DEFAULT_PAGESIZE);
 #endif
 }
@@ -409,7 +408,7 @@ int fileSetBufferType(int fileID, int type)
 	{
 	case FILE_BUFTYPE_STD:
 	case FILE_BUFTYPE_MMAP:
-	  fileptr->bufferType = type;
+	  fileptr->bufferType = (short)type;
 	  break;
 	default:
 	  Error("File type %d not implemented!", type);
@@ -423,20 +422,6 @@ int fileSetBufferType(int fileID, int type)
   return (ret);
 }
 
-
-int fileGetBufferType(int fileID)
-{
-  bfile_t *fileptr;
-  int bufferType = 0;
-
-  fileptr = file_to_pointer(fileID);
-
-  if ( fileptr ) bufferType = fileptr->bufferType;
-
-  return (bufferType);
-}
-
-
 int fileFlush(int fileID)
 {
   bfile_t *fileptr;
@@ -487,20 +472,6 @@ int fileEOF(int fileID)
   return (retval);
 }
 
-
-int fileError(int fileID)
-{
-  bfile_t *fileptr;
-  int retval = 0;
-
-  fileptr = file_to_pointer(fileID);
-
-  if ( fileptr ) retval = (fileptr->flag & FILE_ERROR) != 0;
-
-  return (retval);
-}
-
-
 void fileRewind(int fileID)
 {
   fileSetPos(fileID, (off_t) 0, SEEK_SET);
@@ -780,7 +751,7 @@ void file_initialize(void)
 	{
 	case FILE_TYPE_OPEN:
 	case FILE_TYPE_FOPEN:
-	  FileTypeRead = (int)value;
+	  FileTypeRead = (short)value;
 	  break;
 	default:
 	  Warning("File type %d not implemented!", value);
@@ -794,7 +765,7 @@ void file_initialize(void)
 	{
 	case FILE_TYPE_OPEN:
 	case FILE_TYPE_FOPEN:
-	  FileTypeWrite = (int)value;
+	  FileTypeWrite = (short)value;
 	  break;
 	default:
 	  Warning("File type %d not implemented!", value);
@@ -826,7 +797,7 @@ void file_initialize(void)
 	{
 	case FILE_BUFTYPE_STD:
 	case FILE_BUFTYPE_MMAP:
-	  FileBufferTypeEnv = (int)value;
+	  FileBufferTypeEnv = (short)value;
 	  break;
 	default:
 	  Warning("File buffer type %d not implemented!", value);
@@ -903,7 +874,7 @@ void file_set_buffer(bfile_t *fileptr)
     {
       if ( buffersize > 0 )
         {
-          fileptr->buffer = (char *) malloc(buffersize);
+          fileptr->buffer = (char *) Malloc(buffersize);
           if ( fileptr->buffer == NULL )
             SysError("Allocation of file buffer failed!");
         }
@@ -1206,8 +1177,8 @@ int fileClose_serial(int fileID)
 {
   char *name;
   int ret;
-  char *fbtname[] = {"unknown", "standard", "mmap"};
-  char *ftname[] = {"unknown", "open", "fopen"};
+  const char *fbtname[] = {"unknown", "standard", "mmap"};
+  const char *ftname[] = {"unknown", "open", "fopen"};
   bfile_t *fileptr = file_to_pointer(fileID);
   double rout = 0;
 
@@ -1301,8 +1272,8 @@ int fileClose_serial(int fileID)
 	SysError("EOF returned for close of %s!", name);
     }
 
-  if ( fileptr->name )    free((void*) fileptr->name);
-  if ( fileptr->buffer )  free((void*) fileptr->buffer);
+  if ( fileptr->name )    Free((void*) fileptr->name);
+  if ( fileptr->buffer )  Free((void*) fileptr->buffer);
 
   file_delete_entry(fileptr);
 
diff --git a/libcdi/src/gaussgrid.c b/libcdi/src/gaussgrid.c
index ec31a64..2ae1b9f 100644
--- a/libcdi/src/gaussgrid.c
+++ b/libcdi/src/gaussgrid.c
@@ -1,9 +1,15 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
 #include <math.h>
 #include <float.h>
 #include <stdio.h>
 #include <stdlib.h>
 
+
 #include "dmemory.h"
+#include "gaussgrid.h"
 
 #ifndef  M_PI
 #define  M_PI        3.14159265358979323846  /* pi */
@@ -24,7 +30,7 @@ void cpledn(size_t kn, size_t kodd, double *pfn, double pdx, int kflag,
   double zdlmod;
   double zdlxn;
 
-  size_t ik, jn;
+  size_t ik;
 
   /* 1.0 Newton iteration step */
 
@@ -60,7 +66,7 @@ void cpledn(size_t kn, size_t kodd, double *pfn, double pdx, int kflag,
 
   if (kflag == 1) 
     {
-      for(jn = 2-kodd; jn <= kn; jn += 2) 
+      for(size_t jn = 2-kodd; jn <= kn; jn += 2) 
 	{
 	  /* normalised derivative */
 	  zdlldn = zdlldn - pfn[ik]*(double)(jn)*sin((double)(jn)*zdlx);
@@ -108,7 +114,7 @@ void gawl(double *pfn, double *pl, double *pw, size_t kn)
 }
 
 static
-void gauaw(size_t kn, double *restrict pl, double *restrict pw)
+void gauaw(size_t kn, double *__restrict__ pl, double *__restrict__ pw)
 {
   /*
    * 1.0 Initialize Fourier coefficients for ordinary Legendre polynomials
@@ -120,8 +126,8 @@ void gauaw(size_t kn, double *restrict pl, double *restrict pw)
 
   double z, zfnn;
 
-  zfn    = (double *) malloc((kn+1) * (kn+1) * sizeof(double));
-  zfnlat = (double *) malloc((kn/2+1+1)*sizeof(double));
+  zfn    = (double *) Malloc((kn+1) * (kn+1) * sizeof(double));
+  zfnlat = (double *) Malloc((kn/2+1+1)*sizeof(double));
 
   zfn[0] = M_SQRT2;
   for (size_t jn = 1; jn <= kn; jn++)
@@ -189,8 +195,8 @@ void gauaw(size_t kn, double *restrict pl, double *restrict pw)
       pw[isym] =  pw[jglm1];
     }
 
-  free(zfnlat);
-  free(zfn);
+  Free(zfnlat);
+  Free(zfn);
 
   return;
 }
diff --git a/libcdi/src/gribapi.c b/libcdi/src/gribapi.c
index 798a0a6..675816e 100644
--- a/libcdi/src/gribapi.c
+++ b/libcdi/src/gribapi.c
@@ -13,9 +13,6 @@
 #include "gribapi.h"
 #include "dmemory.h"
 
-#define XSTRING(x)	#x
-#define STRING(x)	XSTRING(x)
-
 static char gribapi_libvers[64] = "";
 #if  defined  (HAVE_LIBGRIB_API)
 static int gribapi_libvers_init;
@@ -26,9 +23,9 @@ void gribapiLibraryVersion(int* major_version, int* minor_version, int* revision
 {
 #if  defined  (HAVE_LIBGRIB_API)
   long version = grib_get_api_version();
-  (*major_version)    = version/10000;
-  (*minor_version)    = (version-(*major_version)*10000)/100;
-  (*revision_version) = (version-(*major_version)*10000-(*minor_version)*100);
+  (*major_version)    = (int)(version/10000);
+  (*minor_version)    = (int)((version-(*major_version)*10000)/100);
+  (*revision_version) = (int)(version-(*major_version)*10000-(*minor_version)*100);
 #else
   (*major_version)    = 0;
   (*minor_version)    = 0;
@@ -71,12 +68,12 @@ void gribContainersNew(stream_t * streamptr)
 
 #if defined (GRIBCONTAINER2D)
       gribContainer_t **gribContainers;
-      gribContainers = (gribContainer_t **) malloc(nvars*sizeof(gribContainer_t *));
+      gribContainers = (gribContainer_t **) Malloc(nvars*sizeof(gribContainer_t *));
 
       for ( int varID = 0; varID < nvars; ++varID )
         {
           int nlevs = streamptr->vars[varID].nlevs;
-          gribContainers[varID] = (gribContainer_t *) malloc(nlevs*sizeof(gribContainer_t));
+          gribContainers[varID] = (gribContainer_t *) Malloc(nlevs*sizeof(gribContainer_t));
 
           for ( int levelID = 0; levelID < nlevs; ++levelID )
             {
@@ -88,7 +85,7 @@ void gribContainersNew(stream_t * streamptr)
       streamptr->gribContainers = (void **) gribContainers;
 #else
       gribContainer_t *gribContainers
-        = (gribContainer_t *)xmalloc((size_t)nvars*sizeof(gribContainer_t));
+        = (gribContainer_t *) Malloc((size_t)nvars*sizeof(gribContainer_t));
 
       for ( int varID = 0; varID < nvars; ++varID )
         {
@@ -118,7 +115,7 @@ void gribContainersDelete(stream_t * streamptr)
             {
               gribHandleDelete(gribContainers[varID][levelID].gribHandle);
             }
-          free(gribContainers[varID]);
+          Free(gribContainers[varID]);
 	}
 #else
       gribContainer_t *gribContainers = (gribContainer_t *) streamptr->gribContainers;
@@ -129,7 +126,7 @@ void gribContainersDelete(stream_t * streamptr)
 	}
 #endif
 
-      free(gribContainers);
+      Free(gribContainers);
 
       streamptr->gribContainers = NULL;
     }
diff --git a/libcdi/src/gribapi.h b/libcdi/src/gribapi.h
index ab11feb..0a1db9a 100644
--- a/libcdi/src/gribapi.h
+++ b/libcdi/src/gribapi.h
@@ -67,9 +67,42 @@ static inline void *gribHandleNew(int editionNumber)
   return gh;
 }
 
+static inline int my_grib_set_double(grib_handle* h, const char* key, double val)
+{
+  if ( cdiGribApiDebug )
+    fprintf(stderr, "grib_set_double(\tgrib_handle* h, \"%s\", %f)\n", key, val);
+
+  int ret_val = grib_set_double(h, key, val);
+  if (ret_val != 0)
+    fprintf(stderr, "!!! failed call to grib_set_double(\tgrib_handle* h, \"%s\", %f) !!!\n", key, val);
+  return ret_val;
+}
+
+static inline int my_grib_set_long(grib_handle* h, const char* key, long val)
+{
+  if ( cdiGribApiDebug )
+    fprintf(stderr, "grib_set_long(  \tgrib_handle* h, \"%s\", %ld)\n", key, val);
+
+  int ret_val = grib_set_long(h, key, val);
+  if (ret_val != 0)
+    fprintf(stderr, "!!! failed call to grib_set_long(  \tgrib_handle* h, \"%s\", %ld) !!!\n", key, val);
+  return ret_val;
+}
+
+static inline int my_grib_set_string(grib_handle* h, const char* key, const char* val, size_t* length)
+{
+  if ( cdiGribApiDebug )
+    fprintf(stderr, "grib_set_string(\tgrib_handle* h, \"%s\", \"%s\")\n", key, val);
+
+  int ret_val = grib_set_string(h, key, val, length);
+  if (ret_val != 0)
+    fprintf(stderr, "!!! grib_set_string(\tgrib_handle* h, \"%s\", \"%s\") !!!\n", key, val);
+  return ret_val;
+}
+
 static inline void gribHandleDelete(void *gh)
 {
-  grib_handle_delete(gh);
+  grib_handle_delete((struct grib_handle *)gh);
 }
 #else
 #define gribHandleNew(editionNumber) (NULL)
diff --git a/libcdi/src/gribapi_utilities.c b/libcdi/src/gribapi_utilities.c
index 408ce3a..a8907ec 100644
--- a/libcdi/src/gribapi_utilities.c
+++ b/libcdi/src/gribapi_utilities.c
@@ -2,8 +2,6 @@
 #  include "config.h"
 #endif
 
-static int dummy;
-
 #ifdef HAVE_LIBGRIB_API
 
 #include "gribapi_utilities.h"
@@ -12,14 +10,13 @@ static int dummy;
 #include "dmemory.h"
 #include "error.h"
 #include "gribapi.h"
-#include "proprietarySystemWorkarounds.h"
 
 #include <assert.h>
 #include <time.h>
 
 #define FAIL_ON_GRIB_ERROR(function, gribHandle, key, ...) do\
 {\
-  int errorCode = function(gribHandle, key, __VA_ARGS__);\
+  int errorCode = (int)function(gribHandle, key, __VA_ARGS__);  \
   if(errorCode)\
     {\
       fprintf(stderr, "%s:%d: Error in function `%s`: `%s` returned error code %d for key \"%s\"", __FILE__, __LINE__, __func__, #function, errorCode, key);\
@@ -30,24 +27,77 @@ static int dummy;
 //A simple wrapper for grib_get_string() that returns a newly allocated string.
 char* gribCopyString(grib_handle* gribHandle, const char* key)
 {
+  char* result = NULL;
   size_t length;
-  if(grib_get_length(gribHandle, key, &length)) return NULL;
-  char* result = xmalloc(length);
-  if(!grib_get_string(gribHandle, key, result, &length)) return result;
-  free(result);
-  return NULL;
+#ifdef HAVE_GRIB_GET_LENGTH
+  if(!grib_get_length(gribHandle, key, &length))
+    {
+    char* result = (char *) Malloc(length);
+    if(!grib_get_string(gribHandle, key, result, &length))
+    result = (char *) Realloc(result, length);
+
+    else
+      {
+          Free(result);
+          result = NULL;
+      }
+    }
+#else
+  length = 1024;         /* there's an implementation limit
+                          * that makes strings longer than
+                          * this unlikely in grib_api versions
+                          * not providing grib_get_length */
+  int rc;
+  result = (char *) Malloc(length);
+  while ((rc = grib_get_string(gribHandle, key, result, &length))
+         == GRIB_BUFFER_TOO_SMALL || rc == GRIB_ARRAY_TOO_SMALL)
+    {
+      if (length <= 1024UL * 1024UL)
+        {
+          length *= 2;
+          result = Realloc(result, length);
+        }
+      else
+        break;
+    }
+  if (!rc)
+    result = Realloc(result, length);
+  else
+    {
+      Free(result);
+      result = NULL;
+    }
+#endif
+  return result;
 }
 
 //A simple wrapper for grib_get_string() for the usecase that the result is only compared to a given constant string.
 //Returns true if the key exists and the value is equal to the given string.
 bool gribCheckString(grib_handle* gribHandle, const char* key, const char* expectedValue)
 {
-  size_t expectedLength = strlen(expectedValue) + 1, length;
+  size_t expectedLength = strlen(expectedValue) + 1;
+#ifdef HAVE_GRIB_GET_LENGTH
+  size_t length;
   if(grib_get_length(gribHandle, key, &length)) return false;
   if(length != expectedLength) return false;
-  char value[length];
+  char *value = (char *) Malloc(length);
   if(grib_get_string(gribHandle, key, value, &length)) return false;
-  return !strcmp(value, expectedValue);
+  int rc = !strcmp(value, expectedValue);
+  Free(value);
+#else
+  char *value = gribCopyString(gribHandle, key);
+  int rc;
+  if (value)
+  {
+    rc = strlen(value) + 1 == expectedLength ?
+      !strcmp(value, expectedValue)
+      : false;
+  }
+  else
+    rc = false;
+  Free(value);
+#endif
+  return rc;
 }
 
 //A simple wrapper for grib_get_long() for the usecase that the result is only compared to a given constant value.
@@ -126,7 +176,7 @@ long gribEditionNumber(grib_handle* gh)
 static char* setUtc()
 {
   char* temp = getenv("TZ"), *result = NULL;
-  if(temp) result = myStrDup(temp);
+  if(temp) result = strdup(temp);
   setenv("TZ", "UTC", 1);
   return result;
 }
@@ -137,7 +187,7 @@ static void resetTz(char* savedTz)
   if(savedTz)
     {
       setenv("TZ", savedTz, 1);
-      free(savedTz);
+      Free(savedTz);
     }
   else
     {
@@ -163,13 +213,13 @@ static int addSecondsToDate(struct tm* me, long long amount)
   //It is irrelevant here whether days are zero or one based, the correction would have be undone again so that it is effectless.
   long long seconds = ((me->tm_mday*24ll + me->tm_hour)*60 + me->tm_min)*60 + me->tm_sec;    //The portion of the date that uses fixed increments.
   seconds += amount;
-  me->tm_mday = seconds/24/60/60;
-  seconds -= me->tm_mday*24*60*60;
-  me->tm_hour = seconds/60/60;
-  seconds -= me->tm_hour*60*60;
-  me->tm_min = seconds/60;
-  seconds -= me->tm_min*60;
-  me->tm_sec = seconds;
+  me->tm_mday = (int)(seconds / 24 / 60 / 60);
+  seconds -= (long long)me->tm_mday * 24 * 60 * 60;
+  me->tm_hour = (int)(seconds / 60 / 60);
+  seconds -= (long long)me->tm_hour * 60 * 60;
+  me->tm_min = (int)(seconds / 60);
+  seconds -= (long long)(me->tm_min * 60);
+  me->tm_sec = (int)seconds;
   return normalizeDays(me);
 }
 
@@ -177,9 +227,9 @@ static void addMonthsToDate(struct tm* me, long long amount)
 {
   long long months = me->tm_year*12ll + me->tm_mon;
   months += amount;
-  me->tm_year = months/12;
-  months -= me->tm_year*12;
-  me->tm_mon = months;
+  me->tm_year = (int)(months/12);
+  months -= (long long)me->tm_year*12;
+  me->tm_mon = (int)months;
 }
 
 //unit is a value according to code table 4.4 of the GRIB2 specification, returns non-zero on error
@@ -208,7 +258,10 @@ static int addToDate(struct tm* me, long long amount, long unit)
 
 static char* makeDateString(struct tm* me)
 {
-  return myAsprintf("%04d-%02d-%02dT%02d:%02d:%02d.000", me->tm_year + 1900, me->tm_mon + 1, me->tm_mday, me->tm_hour, me->tm_min, me->tm_sec);
+  char *result
+    = (char *) Malloc(       4+1+ 2+1+ 2+1+ 2+1+ 2+1+ 2+ 4+ 1);
+  sprintf(result, "%04d-%02d-%02dT%02d:%02d:%02d.000", me->tm_year + 1900, me->tm_mon + 1, me->tm_mday, me->tm_hour, me->tm_min, me->tm_sec);
+  return result;
 }
 
 //FIXME: This ignores any calendar definition that might be present.
@@ -237,20 +290,29 @@ static int getAvailabilityOfRelativeTimes(grib_handle* gh, bool* outHaveForecast
 char* gribMakeTimeString(grib_handle* gh, bool getEndTime)
 {
   //Get the parts of the reference date.
+#ifdef __cplusplus
+    struct tm date;
+    date.tm_mon = (int) gribGetLong(gh, "month") - 1;   //months are zero based in struct tm and one based in GRIBy
+
+    date.tm_mday = (int)gribGetLong(gh, "day");
+    date.tm_hour = (int)gribGetLong(gh, "hour");
+    date.tm_min = (int)gribGetLong(gh, "minute");
+#else
   struct tm date = {
-      .tm_mon = gribGetLong(gh, "month") - 1,   //months are zero based in struct tm and one based in GRIB
-      .tm_mday = gribGetLong(gh, "day"),
-      .tm_hour = gribGetLong(gh, "hour"),
-      .tm_min = gribGetLong(gh, "minute")
+    .tm_mon = (int)gribGetLong(gh, "month") - 1,   //months are zero based in struct tm and one based in GRIBy
+    .tm_mday = (int)gribGetLong(gh, "day"),
+    .tm_hour = (int)gribGetLong(gh, "hour"),
+    .tm_min = (int)gribGetLong(gh, "minute")
   };
+#endif
   if(gribEditionNumber(gh) == 1)
     {
-      date.tm_year = gribGetLong(gh, "yearOfCentury");  //years are -1900 based both in struct tm and GRIB1
+      date.tm_year = (int)gribGetLong(gh, "yearOfCentury");  //years are -1900 based both in struct tm and GRIB1
     }
   else
     {
-      date.tm_year = gribGetLong(gh, "year") - 1900;   //years are -1900 based in struct tm and zero based in GRIB2
-      date.tm_sec = gribGetLong(gh, "second");
+      date.tm_year = (int)gribGetLong(gh, "year") - 1900;   //years are -1900 based in struct tm and zero based in GRIB2
+      date.tm_sec = (int)gribGetLong(gh, "second");
 
       //Determine whether we have a forecast time and a time range.
       bool haveForecastTime, haveTimeRange;
@@ -499,13 +561,13 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
         /* FIXME: assert(numberOfPoints <= INT_MAX && numberOfPoints >= INT_MIN) */
         grid->size   = (int)numberOfPoints;
 
-        grid->rowlon = (int *) malloc((size_t)nlat * sizeof (int));
-        pl          = (long *) malloc((size_t)nlat * sizeof (long));
+        grid->rowlon = (int *) Malloc((size_t)nlat * sizeof (int));
+        pl          = (long *) Malloc((size_t)nlat * sizeof (long));
         dummy       = (size_t)nlat;
         FAIL_ON_GRIB_ERROR(grib_get_long_array, gh, "pl", pl, &dummy);
         /* FIXME: assert(pl[i] >= INT_MIN && pl[i] <= INT_MIN) */
         for (int i = 0; i < nlat; ++i ) grid->rowlon[i] = (int)pl[i];
-        free(pl);
+        Free(pl);
 
         grid->ysize  = nlat;
         grid->xinc   = 0;
@@ -561,14 +623,14 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
         long lpar;
 
         FAIL_ON_GRIB_ERROR(grib_get_long, gh, "Nx", &lpar);
-        nlon = lpar;
+        nlon = (int)lpar;
         FAIL_ON_GRIB_ERROR(grib_get_long, gh, "Ny", &lpar);
-        nlat = lpar;
+        nlat = (int)lpar;
 
         if ( numberOfPoints != nlon*nlat )
           Error("numberOfPoints (%d) and gridSize (%d) differ!", (int)numberOfPoints, nlon*nlat);
 
-        grid->size  = numberOfPoints;
+        grid->size  = (int)numberOfPoints;
         grid->xsize = nlon;
         grid->ysize = nlat;
 
@@ -700,8 +762,9 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
       FAIL_ON_GRIB_ERROR(grib_get_double, gh, "longitudeOfSouthernPoleInDegrees", &grid->xpole);
       FAIL_ON_GRIB_ERROR(grib_get_double, gh, "angleOfRotation", &grid->angle);
       /* change from south to north pole */
-      grid->ypole = -grid->ypole;
+      if ( fabs(grid->ypole) > 0 ) grid->ypole = -grid->ypole;
       grid->xpole =  grid->xpole - 180;
+      if ( fabs(grid->angle) > 0 ) grid->angle = -grid->angle;
     }
 
   grid->xvals = NULL;
@@ -709,3 +772,12 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid)
   grid->type  = gridtype;
 }
 #endif
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/gribapi_utilities.h b/libcdi/src/gribapi_utilities.h
index 6c76723..0f8a12c 100644
--- a/libcdi/src/gribapi_utilities.h
+++ b/libcdi/src/gribapi_utilities.h
@@ -35,3 +35,13 @@ void gribapiGetGrid(grib_handle *gh, grid_t *grid);
 #endif
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/grid.c b/libcdi/src/grid.c
index 3c5acdd..a2ff574 100644
--- a/libcdi/src/grid.c
+++ b/libcdi/src/grid.c
@@ -16,15 +16,10 @@
 #include "resource_unpack.h"
 #include "namespace.h"
 #include "serialize.h"
+#include "vlist.h"
 
-#ifndef  RAD2DEG
-#define  RAD2DEG  (180./M_PI)   /* conversion for rad to deg */
-#endif
-
-#ifndef  DEG2RAD
-#define  DEG2RAD  (M_PI/180.)   /* conversion for deg to rad */
-#endif
-
+#undef  UNDEFID
+#define UNDEFID -1
 
 /* the value in the second pair of brackets must match the length of
  * the longest string (including terminating NUL) */
@@ -56,7 +51,7 @@ static void   gridPack        ( void * gridptr, void * buff, int size,
 				int *position, void *context);
 static int    gridTxCode      ( void );
 
-const resOps gridOps = {
+static const resOps gridOps = {
   gridCompareP,
   gridDestroyP,
   gridPrintP,
@@ -148,16 +143,16 @@ void grid_init(grid_t *gridptr)
 
 void grid_free(grid_t *gridptr)
 {
-  if ( gridptr->mask      ) free(gridptr->mask);
-  if ( gridptr->mask_gme  ) free(gridptr->mask_gme);
-  if ( gridptr->xvals     ) free(gridptr->xvals);
-  if ( gridptr->yvals     ) free(gridptr->yvals);
-  if ( gridptr->area      ) free(gridptr->area);
-  if ( gridptr->xbounds   ) free(gridptr->xbounds);
-  if ( gridptr->ybounds   ) free(gridptr->ybounds);
-  if ( gridptr->rowlon    ) free(gridptr->rowlon);
-  if ( gridptr->reference ) free(gridptr->reference);
-  if ( gridptr->name      ) free(gridptr->name);
+  if ( gridptr->mask      ) Free(gridptr->mask);
+  if ( gridptr->mask_gme  ) Free(gridptr->mask_gme);
+  if ( gridptr->xvals     ) Free(gridptr->xvals);
+  if ( gridptr->yvals     ) Free(gridptr->yvals);
+  if ( gridptr->area      ) Free(gridptr->area);
+  if ( gridptr->xbounds   ) Free(gridptr->xbounds);
+  if ( gridptr->ybounds   ) Free(gridptr->ybounds);
+  if ( gridptr->rowlon    ) Free(gridptr->rowlon);
+  if ( gridptr->reference ) Free(gridptr->reference);
+  if ( gridptr->name      ) Free(gridptr->name);
 
   grid_init(gridptr);
 }
@@ -165,7 +160,7 @@ void grid_free(grid_t *gridptr)
 static grid_t *
 gridNewEntry(cdiResH resH)
 {
-  grid_t *gridptr = (grid_t*) xmalloc(sizeof(grid_t));
+  grid_t *gridptr = (grid_t*) Malloc(sizeof(grid_t));
   grid_init(gridptr);
   if (resH == CDI_UNDEFID)
     gridptr->self = reshPut(gridptr, &gridOps);
@@ -229,9 +224,9 @@ void gridGenXvals(int xsize, double xfirst, double xlast, double xinc, double *x
 static
 void calc_gaussgrid(double *yvals, int ysize, double yfirst, double ylast)
 {
-  double *restrict yw = (double *)xmalloc((size_t)ysize * sizeof(double));
+  double *restrict yw = (double *) Malloc((size_t)ysize * sizeof(double));
   gaussaw(yvals, yw, (size_t)ysize);
-  free(yw);
+  Free(yw);
   for (int i = 0; i < ysize; i++ )
     yvals[i] = asin(yvals[i])/M_PI*180.0;
 
@@ -261,31 +256,30 @@ void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast, double y
 	  if ( ! (IS_EQUAL(yfirst, 0) && IS_EQUAL(ylast, 0)) )
 	    if ( fabs(yvals[0] - yfirst) > deleps || fabs(yvals[ysize-1] - ylast) > deleps )
 	      {
-		double yinc = fabs(ylast-yfirst)/(ysize-1);
 		double *restrict ytmp = NULL;
 		int nstart, lfound = 0;
-		int ny = (int) (180./yinc + 0.5);
+		int ny = (int) (180./fabs(ylast-yfirst)/(ysize-1) + 0.5);
 		ny -= ny%2;
-		/* printf("%g %g %g %g %g %d\n", ylast, yfirst, ylast-yfirst,yinc, 180/yinc, ny); */
 		if ( ny > ysize && ny < 4096 )
 		  {
-		    ytmp = (double *)xmalloc((size_t)ny * sizeof (double));
+		    ytmp = (double *) Malloc((size_t)ny * sizeof (double));
 		    calc_gaussgrid(ytmp, ny, yfirst, ylast);
-                    int i;
-		    for ( i = 0; i < (ny-ysize); i++ )
-		      if ( fabs(ytmp[i] - yfirst) < deleps ) break;
-
-		    nstart = i;
+                    {
+                      int i;
+                      for ( i = 0; i < (ny-ysize); i++ )
+                        if ( fabs(ytmp[i] - yfirst) < deleps ) break;
+                      nstart = i;
+                    }
 
 		    lfound = (nstart+ysize-1) < ny
                       && fabs(ytmp[nstart+ysize-1] - ylast) < deleps;
+                    if ( lfound )
+                      {
+                        for (int i = 0; i < ysize; i++) yvals[i] = ytmp[i+nstart];
+                      }
 		  }
 
-		if ( lfound )
-		  {
-		    for (int i = 0; i < ysize; i++) yvals[i] = ytmp[i+nstart];
-		  }
-		else
+		if ( !lfound )
 		  {
 		    Warning("Cannot calculate gaussian latitudes for lat1 = %g latn = %g!", yfirst, ylast);
 		    for (int i = 0; i < ysize; i++ ) yvals[i] = 0;
@@ -293,7 +287,7 @@ void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast, double y
 		    yvals[ysize-1] = ylast;
 		  }
 
-		if ( ytmp ) free(ytmp);
+		if ( ytmp ) Free(ytmp);
 	      }
 	}
       else
@@ -490,17 +484,17 @@ void gridDestroyKernel( grid_t * gridptr )
 
   id = gridptr->self;
 
-  if ( gridptr->mask      ) free(gridptr->mask);
-  if ( gridptr->mask_gme  ) free(gridptr->mask_gme);
-  if ( gridptr->xvals     ) free(gridptr->xvals);
-  if ( gridptr->yvals     ) free(gridptr->yvals);
-  if ( gridptr->area      ) free(gridptr->area);
-  if ( gridptr->xbounds   ) free(gridptr->xbounds);
-  if ( gridptr->ybounds   ) free(gridptr->ybounds);
-  if ( gridptr->rowlon    ) free(gridptr->rowlon);
-  if ( gridptr->reference ) free(gridptr->reference);
+  if ( gridptr->mask      ) Free(gridptr->mask);
+  if ( gridptr->mask_gme  ) Free(gridptr->mask_gme);
+  if ( gridptr->xvals     ) Free(gridptr->xvals);
+  if ( gridptr->yvals     ) Free(gridptr->yvals);
+  if ( gridptr->area      ) Free(gridptr->area);
+  if ( gridptr->xbounds   ) Free(gridptr->xbounds);
+  if ( gridptr->ybounds   ) Free(gridptr->ybounds);
+  if ( gridptr->rowlon    ) Free(gridptr->rowlon);
+  if ( gridptr->reference ) Free(gridptr->reference);
 
-  free ( gridptr );
+  Free( gridptr );
 
   reshRemove ( id, &gridOps );
 }
@@ -530,10 +524,9 @@ void gridDestroyP ( void * gridptr )
 
 const char *gridNamePtr(int gridtype)
 {
-  const char *name;
-  int size = (int) (sizeof(Grids)/sizeof(char *));
+  int size = (int) (sizeof(Grids)/sizeof(Grids[0]));
 
-  name = gridtype >= 0 && gridtype < size ? Grids[gridtype] : Grids[GRID_GENERIC];
+  const char *name = gridtype >= 0 && gridtype < size ? Grids[gridtype] : Grids[GRID_GENERIC];
 
   return (name);
 }
@@ -1210,7 +1203,7 @@ void gridDefRowlon(int gridID, int nrowlon, const int rowlon[])
 {
   grid_t *gridptr = gridID2Ptr(gridID);
 
-  gridptr->rowlon = (int *)xmalloc((size_t)nrowlon * sizeof(int));
+  gridptr->rowlon = (int *) Malloc((size_t)nrowlon * sizeof(int));
   gridptr->nrowlon = nrowlon;
   memcpy(gridptr->rowlon, rowlon, (size_t)nrowlon * sizeof(int));
   reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
@@ -1268,14 +1261,14 @@ void gridDefMask(int gridID, const int *mask)
     {
       if ( gridptr->mask )
 	{
-	  free(gridptr->mask);
+	  Free(gridptr->mask);
 	  gridptr->mask = NULL;
 	}
     }
   else
     {
       if ( gridptr->mask == NULL )
-	gridptr->mask = (mask_t *)xmalloc((size_t)size*sizeof(mask_t));
+	gridptr->mask = (mask_t *) Malloc((size_t)size*sizeof(mask_t));
       else if ( CDI_Debug )
 	Warning("grid mask already defined!");
 
@@ -1314,7 +1307,7 @@ void gridDefMaskGME(int gridID, const int *mask)
     Error("Size undefined for gridID = %d", gridID);
 
   if ( gridptr->mask_gme == NULL )
-    gridptr->mask_gme = (mask_t *)xmalloc((size_t)size * sizeof (mask_t));
+    gridptr->mask_gme = (mask_t *) Malloc((size_t)size * sizeof (mask_t));
   else if ( CDI_Debug )
     Warning("mask already defined!");
 
@@ -1382,12 +1375,10 @@ The function @func{gridDefXvals} defines all values of the X-axis.
 void gridDefXvals(int gridID, const double *xvals)
 {
   grid_t *gridptr = gridID2Ptr(gridID);
+  int gridtype = gridptr->type;
 
-  int gridtype;
   long size;
 
-  gridtype = gridptr->type;
-
   if ( gridtype == GRID_UNSTRUCTURED || gridtype == GRID_CURVILINEAR )
     size = gridptr->size;
   else if ( gridtype == GRID_GAUSSIAN_REDUCED )
@@ -1400,7 +1391,7 @@ void gridDefXvals(int gridID, const double *xvals)
 
   if (gridptr->xvals && CDI_Debug)
     Warning("values already defined!");
-  gridptr->xvals = (double *)xrealloc(gridptr->xvals,
+  gridptr->xvals = (double *) Realloc(gridptr->xvals,
                                       (size_t)size * sizeof(double));
   memcpy(gridptr->xvals, xvals, (size_t)size * sizeof (double));
   reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
@@ -1475,7 +1466,7 @@ void gridDefYvals(int gridID, const double *yvals)
   if (gridptr->yvals && CDI_Debug)
     Warning("Values already defined!");
 
-  gridptr->yvals = (double *)xrealloc(gridptr->yvals, (size_t)size * sizeof (double));
+  gridptr->yvals = (double *) Realloc(gridptr->yvals, (size_t)size * sizeof (double));
   memcpy(gridptr->yvals, yvals, (size_t)size * sizeof (double));
   reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
 }
@@ -1486,10 +1477,9 @@ double gridInqXval(int gridID, int index)
   double xval = 0;
   grid_t *gridptr = gridID2Ptr(gridID);
 
-  if ( gridptr->xvals )
-    xval = gridptr->xvals[index];
+  if ( gridptr->xvals ) xval = gridptr->xvals[index];
 
-  return (xval);
+  return xval;
 }
 
 /*
@@ -1507,10 +1497,9 @@ double gridInqYval(int gridID, int index)
   double yval = 0;
   grid_t *gridptr = gridID2Ptr(gridID);
 
-  if ( gridptr->yvals )
-    yval = gridptr->yvals[index];
+  if ( gridptr->yvals ) yval = gridptr->yvals[index];
 
-  return (yval);
+  return yval;
 }
 
 /*
@@ -1526,25 +1515,27 @@ double gridInqYval(int gridID, int index)
 double gridInqXinc(int gridID)
 {
   grid_t *gridptr = gridID2Ptr(gridID);
-
   double xinc = gridptr->xinc;
+  const double *restrict xvals = gridptr->xvals;
 
-  if ( (! (fabs(xinc) > 0)) && gridptr->xvals )
+  if ( (! (fabs(xinc) > 0)) && xvals )
     {
       int xsize = gridptr->xsize;
       if ( xsize > 1 )
         {
-          double *xvals = gridptr->xvals;
           xinc = fabs(xvals[xsize-1] - xvals[0])/(xsize-1);
-          int i;
-          for (i = 2; i < xsize; i++ )
-            if ( fabs(fabs(xvals[i-1] - xvals[i]) - xinc) > 0.01*xinc ) break;
+          for ( size_t i = 2; i < (size_t)xsize; i++ )
+            if ( fabs(fabs(xvals[i-1] - xvals[i]) - xinc) > 0.01*xinc )
+              {
+                xinc = 0;
+                break;
+              }
 
-          if ( i < xsize ) xinc = 0;
+          gridptr->xinc = xinc;
         }
     }
 
-  return (xinc);
+  return xinc;
 }
 
 /*
@@ -1560,30 +1551,28 @@ double gridInqXinc(int gridID)
 double gridInqYinc(int gridID)
 {
   grid_t *gridptr = gridID2Ptr(gridID);
-
   double yinc = gridptr->yinc;
+  const double *yvals = gridptr->yvals;
 
-  if ( (! (fabs(yinc) > 0)) && gridptr->yvals )
+  if ( (! (fabs(yinc) > 0)) && yvals )
     {
-      int ysize;
-      double *yvals;
-
-      ysize = gridptr->ysize;
-      yvals = gridptr->yvals;
-
+      int ysize = gridptr->ysize;
       if ( ysize > 1 )
         {
-          yinc = fabs(yvals[1] - yvals[0]);
-          int i;
-          for ( i = 2; i < ysize; i++ )
-            if ( fabs(fabs(yvals[i] - yvals[i-1]) - yinc) > (yinc/1000) ) break;
+          yinc = yvals[1] - yvals[0];
+          double abs_yinc = fabs(yinc);
+          for ( size_t i = 2; i < (size_t)ysize; i++ )
+            if ( fabs(fabs(yvals[i] - yvals[i-1]) - abs_yinc) > (0.01*abs_yinc))
+              {
+                yinc = 0;
+                break;
+              }
 
-          if ( i < ysize ) yinc = 0;
-          else             yinc = yvals[1] - yvals[0];
+          gridptr->yinc = yinc;
         }
     }
 
-  return (yinc);
+  return yinc;
 }
 
 /*
@@ -1598,9 +1587,10 @@ double gridInqYinc(int gridID)
 */
 double gridInqXpole(int gridID)
 {
+  // Xpole -> grid_north_pole_longitude
   grid_t *gridptr = gridID2Ptr(gridID);
 
-  return (gridptr->xpole);
+  return gridptr->xpole;
 }
 
 /*
@@ -1615,6 +1605,7 @@ double gridInqXpole(int gridID)
 */
 void gridDefXpole(int gridID, double xpole)
 {
+  // Xpole -> grid_north_pole_longitude
   grid_t *gridptr = gridID2Ptr(gridID);
 
   if ( memcmp(gridptr->xstdname, "grid", 4) != 0 )
@@ -1640,6 +1631,7 @@ void gridDefXpole(int gridID, double xpole)
 */
 double gridInqYpole(int gridID)
 {
+  // Ypole -> grid_north_pole_latitude
   grid_t *gridptr = gridID2Ptr(gridID);
 
   return (gridptr->ypole);
@@ -1657,6 +1649,7 @@ double gridInqYpole(int gridID)
 */
 void gridDefYpole(int gridID, double ypole)
 {
+  // Ypole -> grid_north_pole_latitude
   grid_t *gridptr = gridID2Ptr(gridID);
 
   if ( memcmp(gridptr->ystdname, "grid", 4) != 0 )
@@ -1682,6 +1675,7 @@ void gridDefYpole(int gridID, double ypole)
 */
 double gridInqAngle(int gridID)
 {
+  // Angle -> north_pole_grid_longitude
   grid_t *gridptr = gridID2Ptr(gridID);
 
   return (gridptr->angle);
@@ -1695,10 +1689,11 @@ double gridInqAngle(int gridID)
 @Parameter
     @Item  Grid identifier
 
- at EndFunction
+ at EndFunction<
 */
 void gridDefAngle(int gridID, double angle)
 {
+  // Angle -> north_pole_grid_longitude
   grid_t *gridptr = gridID2Ptr(gridID);
 
   if ( gridptr->isRotated != TRUE || IS_NOT_EQUAL(gridptr->angle, angle) )
@@ -1878,26 +1873,21 @@ void gridChangeType(int gridID, int gridtype)
 static
 void grid_check_cyclic(grid_t *gridptr)
 {
-  int xsize, ysize;
-  long i1, i2, in, j, k1, k2, nc;
-  double xinc, x0;
-  const double *xvals, *xbounds;
-
   gridptr->isCyclic = FALSE;
 
-  xsize = gridptr->xsize;
-  ysize = gridptr->ysize;
-  xvals = gridptr->xvals;
-  xbounds = gridptr->xbounds;
+  int xsize = gridptr->xsize,
+    ysize = gridptr->ysize;
+  const double *xvals = gridptr->xvals,
+    *xbounds = gridptr->xbounds;
 
   if ( gridptr->type == GRID_GAUSSIAN || gridptr->type == GRID_LONLAT )
     {
       if ( xvals && xsize > 1 )
         {
-          xinc = xvals[1] - xvals[0];
+          double xinc = xvals[1] - xvals[0];
           if ( IS_EQUAL(xinc, 0) ) xinc = (xvals[xsize-1] - xvals[0])/(xsize-1);
 
-          x0 = 2*xvals[xsize-1]-xvals[xsize-2]-360;
+          double x0 = 2*xvals[xsize-1]-xvals[xsize-2]-360;
 
           if ( IS_NOT_EQUAL(xvals[0], xvals[xsize-1]) )
             if ( fabs(x0 - xvals[0]) < 0.01*xinc ) gridptr->isCyclic = TRUE;
@@ -1907,20 +1897,17 @@ void grid_check_cyclic(grid_t *gridptr)
     {
       if ( xvals && xsize > 1 )
         {
-          double val1, val2, valn;
-
-          nc = 0;
-          gridptr->isCyclic = FALSE;
-          for ( j = 0; j < ysize; ++j )
+          long nc = 0;
+          for ( int j = 0; j < ysize; ++j )
             {
-              i1 = j*xsize;
-              i2 = j*xsize+1;
-              in = j*xsize+(xsize-1);
-              val1 = xvals[i1];
-              val2 = xvals[i2];
-              valn = xvals[in];
+              long i1 = j*xsize,
+                i2 = j*xsize+1,
+                in = j*xsize+(xsize-1);
+              double val1 = xvals[i1],
+                val2 = xvals[i2],
+                valn = xvals[in];
 
-              xinc = fabs(val2-val1);
+              double xinc = fabs(val2-val1);
 
 	      if ( val1 <    1 && valn > 300 ) val1 += 360;
 	      if ( valn <    1 && val1 > 300 ) valn += 360;
@@ -1928,31 +1915,27 @@ void grid_check_cyclic(grid_t *gridptr)
 	      if ( valn < -179 && val1 > 120 ) valn += 360;
               if ( fabs(valn-val1) > 180 ) val1 += 360;
 
-              if ( valn > val1 ) x0 = valn - xinc;
-              else               x0 = valn + xinc;
+              double x0 = valn + copysign(xinc, val1 - valn);
 
-              if ( fabs(x0-val1) < 0.5*xinc ) nc++;
+              nc += fabs(x0-val1) < 0.5*xinc;
             }
-
-          if ( nc > 0.5*ysize ) gridptr->isCyclic = TRUE;
+          gridptr->isCyclic = nc > 0.5*ysize ? TRUE : FALSE;
         }
 
       if ( xbounds && xsize > 1 )
 	{
-	  double val1, val2;
-
-	  gridptr->isCyclic = TRUE;
-	  for ( j = 0; j < ysize; ++j )
+          gridptr->isCyclic = TRUE;
+	  for ( int j = 0; j < ysize; ++j )
 	    {
-	      i1 = j*xsize*4;
-	      i2 = j*xsize*4+(xsize-1)*4;
-	      nc = 0;
-	      for ( k1 = 0; k1 < 4; ++k1 )
+	      long i1 = j*xsize*4,
+                i2 = j*xsize*4+(xsize-1)*4;
+	      long nc = 0;
+	      for (unsigned k1 = 0; k1 < 4; ++k1 )
 		{
-		  val1 = xbounds[i1+k1];
-		  for ( k2 = 0; k2 < 4; ++k2 )
+		  double val1 = xbounds[i1+k1];
+		  for (unsigned k2 = 0; k2 < 4; ++k2 )
 		    {
-		      val2 = xbounds[i2+k2];
+		      double val2 = xbounds[i2+k2];
 
 		      if ( val1 <    1 && val2 > 300 ) val1 += 360;
 		      if ( val2 <    1 && val1 > 300 ) val2 += 360;
@@ -2004,7 +1987,7 @@ int compareXYvals(int gridID, long xsize, long ysize, double *xvals0, double *yv
 
   if ( !differ && xsize == gridInqXvals(gridID, NULL) )
     {
-      double *xvals = (double *)xmalloc((size_t)xsize * sizeof (double));
+      double *xvals = (double *) Malloc((size_t)xsize * sizeof (double));
 
       gridInqXvals(gridID, xvals);
 
@@ -2015,12 +1998,12 @@ int compareXYvals(int gridID, long xsize, long ysize, double *xvals0, double *yv
 	    break;
 	  }
 
-      free(xvals);
+      Free(xvals);
     }
 
   if ( !differ && ysize == gridInqYvals(gridID, NULL) )
     {
-      double *yvals = (double *)xmalloc((size_t)ysize * sizeof (double));
+      double *yvals = (double *) Malloc((size_t)ysize * sizeof (double));
 
       gridInqYvals(gridID, yvals);
 
@@ -2031,7 +2014,7 @@ int compareXYvals(int gridID, long xsize, long ysize, double *xvals0, double *yv
 	    break;
 	  }
 
-      free(yvals);
+      Free(yvals);
     }
 
   return (differ);
@@ -2059,7 +2042,7 @@ int compareXYvals2(int gridID, int gridsize, double *xvals, double *yvals)
 	differ = 1;
     }
 
-  return (differ);
+  return differ;
 }
 
 
@@ -2189,23 +2172,29 @@ int gridCompare(int gridID, const grid_t *grid)
               unsigned char uuidOfHGrid[CDI_UUID_SIZE];
               gridInqUUID(gridID, uuidOfHGrid);
 
-              if ( !differ && memcmp(uuidOfHGrid, grid->uuid, CDI_UUID_SIZE) != 0 ) differ = 1;
-
-              if ( !differ && grid->nvertex != gridInqNvertex(gridID) ) differ = 1;
+              if ( !differ && uuidOfHGrid[0] && grid->uuid[0] && memcmp(uuidOfHGrid, grid->uuid, CDI_UUID_SIZE) != 0 ) differ = 1;
 
-              if ( !differ && grid->number != gridInqNumber(gridID) ) differ = 1;
-              if ( !differ && grid->position != gridInqPosition(gridID) ) differ = 1;
-
-              if ( !differ && grid->nvertex != gridInqNvertex(gridID) ) differ = 1;
-              if ( !differ && grid->number != gridInqNumber(gridID) ) differ = 1;
-              if ( !differ && grid->number > 0 && grid->position != gridInqPosition(gridID) ) differ = 1;
-	      if ( !differ )
-		differ = compareXYvals2(gridID, grid->size, grid->xvals, grid->yvals);
-	    }
+              if ( !differ &&
+                   ((grid->xvals == NULL && gridInqXvalsPtr(gridID) != NULL) || (grid->xvals != NULL && gridInqXvalsPtr(gridID) == NULL)) &&
+                   ((grid->yvals == NULL && gridInqYvalsPtr(gridID) != NULL) || (grid->yvals != NULL && gridInqYvalsPtr(gridID) == NULL)) )
+                {
+                  if ( !differ && grid->nvertex && gridInqNvertex(gridID) && grid->nvertex != gridInqNvertex(gridID) ) differ = 1;
+                  if ( !differ && grid->number && gridInqNumber(gridID) && grid->number != gridInqNumber(gridID) ) differ = 1;
+                  if ( !differ && grid->number && gridInqNumber(gridID) && grid->position != gridInqPosition(gridID) ) differ = 1;
+                }
+              else
+                {
+                  if ( !differ && grid->nvertex != gridInqNvertex(gridID) ) differ = 1;
+                  if ( !differ && grid->number != gridInqNumber(gridID) ) differ = 1;
+                  if ( !differ && grid->number > 0 && grid->position != gridInqPosition(gridID) ) differ = 1;
+                  if ( !differ )
+                    differ = compareXYvals2(gridID, grid->size, grid->xvals, grid->yvals);
+                }
+              }
 	}
     }
 
-  return (differ);
+  return differ;
 }
 
 
@@ -2437,10 +2426,10 @@ int gridGenerate(const grid_t *grid)
 	else if ( grid->xdef == 2 )
 	  {
 	    double *xvals
-              = (double *)xmalloc((size_t)grid->xsize * sizeof (double));
+              = (double *) Malloc((size_t)grid->xsize * sizeof (double));
 	    gridGenXvals(grid->xsize, grid->xfirst, grid->xlast, grid->xinc, xvals);
 	    gridDefXvals(gridID, xvals);
-	    free(xvals);
+	    Free(xvals);
 	    /*
 	    gridDefXinc(gridID, grid->xinc);
 	    */
@@ -2455,10 +2444,10 @@ int gridGenerate(const grid_t *grid)
 	else if ( grid->ydef == 2 )
 	  {
 	    double *yvals
-              = (double *)xmalloc((size_t)grid->ysize * sizeof (double));
+              = (double *) Malloc((size_t)grid->ysize * sizeof (double));
 	    gridGenYvals(grid->type, grid->ysize, grid->yfirst, grid->ylast, grid->yinc, yvals);
 	    gridDefYvals(gridID, yvals);
-	    free(yvals);
+	    Free(yvals);
 	    /*
 	    gridDefYinc(gridID, grid->yinc);
 	    */
@@ -2540,10 +2529,10 @@ int gridGenerate(const grid_t *grid)
 	else if ( grid->ydef == 2 )
 	  {
 	    double *yvals
-              = (double *)xmalloc((size_t)grid->ysize * sizeof (double));
+              = (double *) Malloc((size_t)grid->ysize * sizeof (double));
 	    gridGenYvals(grid->type, grid->ysize, grid->yfirst, grid->ylast, grid->yinc, yvals);
 	    gridDefYvals(gridID, yvals);
-	    free(yvals);
+	    Free(yvals);
 	    /*
 	    gridDefYinc(gridID, grid->yinc);
 	    */
@@ -2623,13 +2612,13 @@ The function @func{gridDuplicate} duplicates a horizontal Grid.
 */
 int gridDuplicate(int gridID)
 {
-  grid_t *gridptr = reshGetVal(gridID, &gridOps);
+  grid_t *gridptr = (grid_t *)reshGetVal(gridID, &gridOps);
 
   int gridtype = gridInqType(gridID);
   int gridsize = gridInqSize(gridID);
 
   int gridIDnew = gridCreate(gridtype, gridsize);
-  grid_t *gridptrnew = reshGetVal(gridIDnew, &gridOps);
+  grid_t *gridptrnew = (grid_t *)reshGetVal(gridIDnew, &gridOps);
 
   grid_copy(gridptrnew, gridptr);
 
@@ -2649,7 +2638,7 @@ int gridDuplicate(int gridID)
   int irregular = gridtype == GRID_CURVILINEAR || gridtype == GRID_UNSTRUCTURED;
   if ( nrowlon )
     {
-      gridptrnew->rowlon = (int *)xmalloc(nrowlon * sizeof (int));
+      gridptrnew->rowlon = (int *) Malloc(nrowlon * sizeof (int));
       memcpy(gridptrnew->rowlon, gridptr->rowlon, nrowlon * sizeof(int));
     }
 
@@ -2657,7 +2646,7 @@ int gridDuplicate(int gridID)
     {
       size_t size  = (size_t)(irregular ? gridsize : gridptr->xsize);
 
-      gridptrnew->xvals = (double *)xmalloc(size * sizeof (double));
+      gridptrnew->xvals = (double *) Malloc(size * sizeof (double));
       memcpy(gridptrnew->xvals, gridptr->xvals, size * sizeof (double));
     }
 
@@ -2665,7 +2654,7 @@ int gridDuplicate(int gridID)
     {
       size_t size  = (size_t)(irregular ? gridsize : gridptr->ysize);
 
-      gridptrnew->yvals = xmalloc(size * sizeof (double));
+      gridptrnew->yvals = (double *) Malloc(size * sizeof (double));
       memcpy(gridptrnew->yvals, gridptr->yvals, size * sizeof (double));
     }
 
@@ -2674,7 +2663,7 @@ int gridDuplicate(int gridID)
       size_t size  = (size_t)(irregular ? gridsize : gridptr->xsize)
         * (size_t)gridptr->nvertex;
 
-      gridptrnew->xbounds = xmalloc(size * sizeof (double));
+      gridptrnew->xbounds = (double *) Malloc(size * sizeof (double));
       memcpy(gridptrnew->xbounds, gridptr->xbounds, size * sizeof (double));
     }
 
@@ -2683,7 +2672,7 @@ int gridDuplicate(int gridID)
       size_t size = (size_t)(irregular ? gridsize : gridptr->ysize)
         * (size_t)gridptr->nvertex;
 
-      gridptrnew->ybounds = xmalloc(size * sizeof (double));
+      gridptrnew->ybounds = (double *) Malloc(size * sizeof (double));
       memcpy(gridptrnew->ybounds, gridptr->ybounds, size * sizeof (double));
     }
 
@@ -2691,7 +2680,7 @@ int gridDuplicate(int gridID)
     {
       size_t size = (size_t)gridsize;
 
-      gridptrnew->area = xmalloc(size * sizeof (double));
+      gridptrnew->area = (double *) Malloc(size * sizeof (double));
       memcpy(gridptrnew->area, gridptr->area, size * sizeof (double));
     }
 
@@ -2699,7 +2688,7 @@ int gridDuplicate(int gridID)
     {
       size_t size = (size_t)gridsize;
 
-      gridptrnew->mask = xmalloc(size * sizeof(mask_t));
+      gridptrnew->mask = (mask_t *) Malloc(size * sizeof(mask_t));
       memcpy(gridptrnew->mask, gridptr->mask, size * sizeof (mask_t));
     }
 
@@ -2707,7 +2696,7 @@ int gridDuplicate(int gridID)
     {
       size_t size = (size_t)gridsize;
 
-      gridptrnew->mask_gme = xmalloc(size * sizeof (mask_t));
+      gridptrnew->mask_gme = (mask_t *) Malloc(size * sizeof (mask_t));
       memcpy(gridptrnew->mask_gme, gridptr->mask_gme, size * sizeof(mask_t));
     }
 
@@ -2759,21 +2748,21 @@ void gridCompress(int gridID)
 	  gridptr->ysize = (int)gridsize;
 
 	  if ( gridptr->xvals )
-	    gridptr->xvals = (double *)xrealloc(gridptr->xvals, gridsize*sizeof(double));
+	    gridptr->xvals = (double *) Realloc(gridptr->xvals, gridsize*sizeof(double));
 
 	  if ( gridptr->yvals )
-	    gridptr->yvals = (double *)xrealloc(gridptr->yvals, gridsize*sizeof(double));
+	    gridptr->yvals = (double *) Realloc(gridptr->yvals, gridsize*sizeof(double));
 
 	  if ( gridptr->area )
-	    gridptr->area  = (double *)xrealloc(gridptr->area, gridsize*sizeof(double));
+	    gridptr->area  = (double *) Realloc(gridptr->area, gridsize*sizeof(double));
 
 	  if ( gridptr->xbounds )
-	    gridptr->xbounds = (double *)xrealloc(gridptr->xbounds, nv*gridsize*sizeof(double));
+	    gridptr->xbounds = (double *) Realloc(gridptr->xbounds, nv*gridsize*sizeof(double));
 
 	  if ( gridptr->ybounds )
-	    gridptr->ybounds = (double *)xrealloc(gridptr->ybounds, nv*gridsize*sizeof(double));
+	    gridptr->ybounds = (double *) Realloc(gridptr->ybounds, nv*gridsize*sizeof(double));
 
-	  free(gridptr->mask_gme);
+	  Free(gridptr->mask_gme);
 	  gridptr->mask_gme = NULL;
           reshSetStatus(gridID, &gridOps, RESH_DESYNC_IN_USE);
 	}
@@ -2793,7 +2782,7 @@ void gridDefArea(int gridID, const double *area)
     Error("size undefined for gridID = %d", gridID);
 
   if ( gridptr->area == NULL )
-    gridptr->area = (double *)xmalloc(size*sizeof(double));
+    gridptr->area = (double *) Malloc(size*sizeof(double));
   else if ( CDI_Debug )
     Warning("values already defined!");
 
@@ -2881,7 +2870,7 @@ void gridDefXbounds(int gridID, const double *xbounds)
     Error("size undefined for gridID = %d", gridID);
 
   if (gridptr->xbounds == NULL)
-    gridptr->xbounds = xmalloc(size * sizeof (double));
+    gridptr->xbounds = (double *) Malloc(size * sizeof (double));
   else if ( CDI_Debug )
     Warning("values already defined!");
 
@@ -2968,7 +2957,7 @@ void gridDefYbounds(int gridID, const double *ybounds)
     Error("size undefined for gridID = %d", gridID);
 
   if ( gridptr->ybounds == NULL )
-    gridptr->ybounds = xmalloc(size * sizeof (double));
+    gridptr->ybounds = (double *) Malloc(size * sizeof (double));
   else if ( CDI_Debug )
     Warning("values already defined!");
 
@@ -3023,7 +3012,7 @@ const double *gridInqYboundsPtr(int gridID)
 }
 
 
-void gridPrintKernel(grid_t * gridptr, int index, int opt, FILE *fp)
+static void gridPrintKernel(grid_t * gridptr, int index, int opt, FILE *fp)
 {
   int xdim, ydim;
   int nbyte;
@@ -3272,7 +3261,7 @@ void gridPrintKernel(grid_t * gridptr, int index, int opt, FILE *fp)
             int *rowlon;
             nbyte0 = fprintf(fp, "rowlon    = ");
             nbyte  = nbyte0;
-            rowlon = (int *)xmalloc((size_t)ysize*sizeof(int));
+            rowlon = (int *) Malloc((size_t)ysize*sizeof(int));
             gridInqRowlon(gridID, rowlon);
             for ( i = 0; i < ysize; i++ )
               {
@@ -3285,7 +3274,7 @@ void gridPrintKernel(grid_t * gridptr, int index, int opt, FILE *fp)
                 nbyte += fprintf(fp, "%d ", rowlon[i]);
               }
             fprintf(fp, "\n");
-            free(rowlon);
+            Free(rowlon);
           }
 
 	break;
@@ -3778,7 +3767,7 @@ void gridDefReference(int gridID, const char *reference)
     {
       if ( gridptr->reference )
         {
-          free(gridptr->reference);
+          Free(gridptr->reference);
           gridptr->reference = NULL;
         }
 
@@ -4046,13 +4035,13 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
     gridP->prec          =   intBuffer[2];
     gridP->lcc_projflag  =   intBuffer[3];
     gridP->lcc_scanflag  =   intBuffer[4];
-    gridP->lcc_defined   =   intBuffer[5];
-    gridP->lcc2_defined  =   intBuffer[6];
+    gridP->lcc_defined   =   (short)intBuffer[5];
+    gridP->lcc2_defined  =   (short)intBuffer[6];
     gridP->laea_defined  =   intBuffer[7];
-    gridP->isCyclic      =   intBuffer[8];
-    gridP->isRotated     =   intBuffer[9];
-    gridP->xdef          =   intBuffer[10];
-    gridP->ydef          =   intBuffer[11];
+    gridP->isCyclic      =   (short)intBuffer[8];
+    gridP->isRotated     =   (short)intBuffer[9];
+    gridP->xdef          =   (short)intBuffer[10];
+    gridP->ydef          =   (short)intBuffer[11];
     gridP->nd            =   intBuffer[12];
     gridP->ni            =   intBuffer[13];
     gridP->ni2           =   intBuffer[14];
@@ -4073,7 +4062,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
   if (memberMask & gridHasRowLonFlag)
     {
       xassert(gridP->nrowlon);
-      gridP->rowlon = (int *)xmalloc((size_t)gridP->nrowlon * sizeof (int));
+      gridP->rowlon = (int *) Malloc((size_t)gridP->nrowlon * sizeof (int));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->rowlon, gridP->nrowlon , DATATYPE_INT, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -4121,7 +4110,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
     {
       size = irregular ? gridP->size : gridP->xsize;
 
-      gridP->xvals = (double *)xmalloc((size_t)size * sizeof (double));
+      gridP->xvals = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->xvals, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -4133,7 +4122,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
     {
       size = irregular ? gridP->size : gridP->ysize;
 
-      gridP->yvals = (double *)xmalloc((size_t)size * sizeof (double));
+      gridP->yvals = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->yvals, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -4145,7 +4134,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
     {
       size = gridP->size;
       xassert(size);
-      gridP->area = (double *)xmalloc((size_t)size * sizeof (double));
+      gridP->area = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->area, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -4158,7 +4147,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
       size = gridP->nvertex * (irregular ? gridP->size : gridP->xsize);
       xassert(size);
 
-      gridP->xbounds = (double *)xmalloc((size_t)size * sizeof (double));
+      gridP->xbounds = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->xbounds, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -4171,7 +4160,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
       size = gridP->nvertex * (irregular ? gridP->size : gridP->ysize);
       xassert(size);
 
-      gridP->ybounds = (double *)xmalloc((size_t)size * sizeof (double));
+      gridP->ybounds = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
 			  gridP->ybounds, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -4191,7 +4180,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
       int referenceSize;
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       &referenceSize, 1, DATATYPE_INT, context);
-      gridP->reference = (char *)xmalloc((size_t)referenceSize);
+      gridP->reference = (char *) Malloc((size_t)referenceSize);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->reference, referenceSize, DATATYPE_TXT, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -4202,7 +4191,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
   if (memberMask & gridHasMaskFlag)
     {
       xassert((size = gridP->size));
-      gridP->mask = (mask_t *)xmalloc((size_t)size * sizeof (mask_t));
+      gridP->mask = (mask_t *) Malloc((size_t)size * sizeof (mask_t));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->mask, gridP->size, DATATYPE_UCHAR, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -4213,7 +4202,7 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
   if (memberMask & gridHasGMEMaskFlag)
     {
       xassert((size = gridP->size));
-      gridP->mask_gme = (mask_t *)xmalloc((size_t)size * sizeof (mask_t));
+      gridP->mask_gme = (mask_t *) Malloc((size_t)size * sizeof (mask_t));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->mask_gme, gridP->size, DATATYPE_UCHAR, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -4225,6 +4214,9 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       gridP->uuid, CDI_UUID_SIZE, DATATYPE_UCHAR, context);
     }
+
+  reshSetStatus(gridP->self, &gridOps,
+                reshGetStatus(gridP->self, &gridOps) & ~RESH_SYNC_BIT);
 }
 
 
@@ -4440,6 +4432,84 @@ gridPack(void * voidP, void * packBuffer, int packBufferSize,
 
 #undef GRID_STR_SERIALIZE
 
+
+struct varDefGridSearchState
+{
+  int resIDValue;
+  const grid_t *queryKey;
+};
+
+static enum cdiApplyRet
+varDefGridSearch(int id, void *res, void *data)
+{
+  struct varDefGridSearchState *state = (struct varDefGridSearchState*)data;
+  (void)res;
+  if (gridCompare(id, state->queryKey) == 0)
+    {
+      state->resIDValue = id;
+      return CDI_APPLY_STOP;
+    }
+  else
+    return CDI_APPLY_GO_ON;
+}
+
+int varDefGrid(int vlistID, const grid_t *grid, int mode)
+{
+  /*
+    mode: 0 search in vlist and grid table
+          1 search in grid table
+   */
+  int gridglobdefined = FALSE;
+  int griddefined;
+  int gridID = CDI_UNDEFID;
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+
+  griddefined = FALSE;
+  unsigned ngrids = (unsigned)vlistptr->ngrids;
+
+  if ( mode == 0 )
+    for (unsigned index = 0; index < ngrids; index++ )
+      {
+	gridID = vlistptr->gridIDs[index];
+	if ( gridID == UNDEFID )
+	  Error("Internal problem: undefined gridID %d!", gridID);
+
+	if ( gridCompare(gridID, grid) == 0 )
+	  {
+	    griddefined = TRUE;
+	    break;
+	  }
+      }
+
+  if ( ! griddefined )
+    {
+      struct varDefGridSearchState query;
+      query.queryKey = grid;// = { .queryKey = grid };
+      if ((gridglobdefined
+           = (cdiResHFilterApply(&gridOps, varDefGridSearch, &query)
+              == CDI_APPLY_STOP)))
+        gridID = query.resIDValue;
+
+      if ( mode == 1 && gridglobdefined)
+	for (unsigned index = 0; index < ngrids; index++ )
+	  if ( vlistptr->gridIDs[index] == gridID )
+	    {
+	      gridglobdefined = FALSE;
+	      break;
+	    }
+    }
+
+  if ( ! griddefined )
+    {
+      if ( ! gridglobdefined ) gridID = gridGenerate(grid);
+      ngrids = (unsigned)vlistptr->ngrids;
+      vlistptr->gridIDs[ngrids] = gridID;
+      vlistptr->ngrids++;
+    }
+
+  return (gridID);
+}
+
 /*
  * Local Variables:
  * c-file-style: "Java"
diff --git a/libcdi/src/grid.h b/libcdi/src/grid.h
index cd30879..a248f59 100644
--- a/libcdi/src/grid.h
+++ b/libcdi/src/grid.h
@@ -2,9 +2,6 @@
 #define _GRID_H
 
 #include "cdi.h"
-#ifndef RESOURCE_HANDLE_H
-#include "resource_handle.h"
-#endif
 
 typedef unsigned char mask_t;
 
@@ -32,28 +29,28 @@ typedef struct {
   double  lcc_yinc;
   int     lcc_projflag;
   int     lcc_scanflag;
-  int     lcc_defined;
+  short   lcc_defined;
+  short   lcc2_defined;
+  int     laea_defined;
   double  lcc2_lon_0;             /* Lambert Conformal Conic 2      */
   double  lcc2_lat_0;
   double  lcc2_lat_1;
   double  lcc2_lat_2;
   double  lcc2_a;
-  int     lcc2_defined;
   double  laea_lon_0;             /* Lambert Azimuthal Equal Area   */
   double  laea_lat_0;
   double  laea_a;
-  int     laea_defined;
   double  xpole, ypole, angle;    /* rotated north pole             */
-  int     isCyclic;               /* TRUE for global cyclic grids   */
-  int     isRotated;              /* TRUE for rotated grids         */
-  int     xdef;                   /* 0: undefined 1:xvals 2:x0+xinc */
-  int     ydef;                   /* 0: undefined 1:yvals 2:y0+yinc */
+  short   isCyclic;               /* TRUE for global cyclic grids   */
+  short   isRotated;              /* TRUE for rotated grids         */
+  short   xdef;                   /* 0: undefined 1:xvals 2:x0+xinc */
+  short   ydef;                   /* 0: undefined 1:yvals 2:y0+yinc */
   int     nd, ni, ni2, ni3;       /* parameter for GRID_GME         */
   int     number, position;       /* parameter for GRID_REFERENCE   */
-  char   *reference;
-  unsigned char uuid[CDI_UUID_SIZE]; /* uuid for grid reference        */
   int     trunc;                  /* parameter for GRID_SPECTEAL    */
   int     nvertex;
+  char   *reference;
+  unsigned char uuid[CDI_UUID_SIZE]; /* uuid for grid reference        */
   int    *rowlon;
   int     nrowlon;
   int     size;
@@ -98,7 +95,16 @@ gridUnpack(char * unpackBuffer, int unpackBufferSize,
            int * unpackBufferPos, int originNamespace, void *context,
            int force_id);
 
-extern const resOps gridOps;
+int  varDefGrid(int vlistID, const grid_t *grid, int mode);
+
+/* These are used by CDO. */
+void gridGenXvals(int xsize, double xfirst, double xlast,
+                  double xinc, double *xvals);
+void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast,
+                  double yinc, double *yvals);
+
+
+
 
 #endif
 /*
diff --git a/libcdi/src/ieg.h b/libcdi/src/ieg.h
index a7e78af..7b72d88 100644
--- a/libcdi/src/ieg.h
+++ b/libcdi/src/ieg.h
@@ -58,8 +58,8 @@ typedef struct {
   int    checked;
   int    byteswap;
   int    dprec;      /* data   precision */
-  double refval;
   int    ipdb[37];
+  double refval;
   int    igdb[22];
   double vct[100];
   size_t datasize;
@@ -74,23 +74,21 @@ const char *iegLibraryVersion(void);
 void iegDebug(int debug);
 int  iegCheckFiletype(int fileID, int *swap);
 
-iegrec_t *iegNew(void);
-void iegDelete(iegrec_t *iegp);
-void iegInit(iegrec_t *iegp);
-void iegInitMem(iegrec_t *iegp);
-
-int  iegRead(int fileID, iegrec_t *iegp);
-int  iegWrite(int fileID, iegrec_t *iegp);
+void *iegNew(void);
+void iegDelete(void *ieg);
+void iegInitMem(void *ieg);
 
-void iegCopyMeta(iegrec_t *diegp, iegrec_t *siegp);
-int  iegInqHeader(iegrec_t *iegp, int *header);
-int  iegInqDataSP(iegrec_t *iegp, float *data);
-int  iegInqDataDP(iegrec_t *iegp, double *data);
+int  iegRead(int fileID, void *ieg);
+int  iegWrite(int fileID, void *ieg);
 
-int  iegDefHeader(iegrec_t *iegp, const int *header);
-int  iegDefDataSP(iegrec_t *iegp, const float *data);
-int  iegDefDataDP(iegrec_t *iegp, const double *data);
+void iegCopyMeta(void *dieg, void *sieg);
+int  iegInqHeader(void *ieg, int *header);
+int  iegInqDataSP(void *ieg, float *data);
+int  iegInqDataDP(void *ieg, double *data);
 
+int  iegDefHeader(void *ieg, const int *header);
+int  iegDefDataSP(void *ieg, const float *data);
+int  iegDefDataDP(void *ieg, const double *data);
 
 #endif  /* _IEG_H */
 /*
diff --git a/libcdi/src/ieglib.c b/libcdi/src/ieglib.c
index c542dbd..2e0d494 100644
--- a/libcdi/src/ieglib.c
+++ b/libcdi/src/ieglib.c
@@ -3,17 +3,17 @@
 #endif
 
 #include <stdio.h>
+#include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
 #include <ctype.h>
 
 #include "dmemory.h"
-
 #include "ieg.h"
 #include "error.h"
 #include "file.h"
 #include "binary.h"
-#include "stream_fcommon.h"
+#include "exse.h"
 #include "swap.h"
 
 
@@ -24,30 +24,26 @@ static int iegDefaultDprec = 0;
 /*
  * A version string.
  */
-
 #undef  LIBVERSION
-#define LIBVERSION      1.3.3
+#define LIBVERSION      1.4.0
 #define XSTRING(x)	#x
 #define STRING(x)	XSTRING(x)
-static const char ieg_libvers[] = STRING(LIBVERSION) " of "__DATE__" "__TIME__;
+static const char ieg_libvers[] = STRING(LIBVERSION) " of " __DATE__ " " __TIME__;
 
 const char *iegLibraryVersion(void)
 {
-  return (ieg_libvers);
+  return ieg_libvers;
 }
 
 
-int IEG_Debug = 0;    /* If set to 1, debugging */
-
+static int IEG_Debug = 0;    /* If set to 1, debugging */
 
-
-void iegLibInit()
+static
+void iegLibInit(void)
 {
-  char *envString;
-  char *envName = "IEG_PRECISION";
-
+  const char *envName = "IEG_PRECISION";
 
-  envString = getenv(envName);
+  char *envString = getenv(envName);
   if ( envString )
     {
       int pos;
@@ -64,8 +60,8 @@ void iegLibInit()
 	      {
 		switch ( (int) envString[pos+1] )
 		  {
-		  case '4': iegDefaultDprec = SINGLE_PRECISION; break;
-		  case '8': iegDefaultDprec = DOUBLE_PRECISION; break;
+		  case '4': iegDefaultDprec = EXSE_SINGLE_PRECISION; break;
+		  case '8': iegDefaultDprec = EXSE_DOUBLE_PRECISION; break;
 		  default:
 		    Message("Invalid digit in %s: %s", envName, envString);
 		  }
@@ -93,7 +89,7 @@ void iegDebug(int debug)
     Message("debug level %d", debug);
 }
 
-
+static
 void iegInit(iegrec_t *iegp)
 {
   iegp->checked    = 0;
@@ -106,52 +102,52 @@ void iegInit(iegrec_t *iegp)
 }
 
 
-void iegInitMem(iegrec_t *iegp)
+void iegInitMem(void *ieg)
 {
+  iegrec_t *iegp = (iegrec_t *) ieg;
+
   memset(iegp->ipdb, 0, sizeof(iegp->ipdb));
   memset(iegp->igdb, 0, sizeof(iegp->igdb));
   memset(iegp->vct,  0, sizeof(iegp->vct));
 }
 
 
-iegrec_t *iegNew(void)
+void *iegNew(void)
 {
-  iegrec_t *iegp;
-
   if ( ! initIegLib ) iegLibInit();
 
-  iegp = (iegrec_t *) malloc(sizeof(iegrec_t));
+  iegrec_t *iegp = (iegrec_t *) Malloc(sizeof(iegrec_t));
 
   iegInit(iegp);
   iegInitMem(iegp);
 
-  return (iegp);
+  return (void*)iegp;
 }
 
 
-void iegDelete(iegrec_t *iegp)
+void iegDelete(void *ieg)
 {
+  iegrec_t *iegp = (iegrec_t *) ieg;
+
   if ( iegp )
     {
-      if ( iegp->buffer ) free(iegp->buffer);
-      free(iegp);
+      if ( iegp->buffer ) Free(iegp->buffer);
+      Free(iegp);
     }
 }
 
 
 int iegCheckFiletype(int fileID, int *swap)
 {
-  size_t blocklen = 0;
-  size_t sblocklen = 0;
   size_t data = 0;
   size_t dimx = 0, dimy = 0;
   size_t fact = 0;
   unsigned char buffer[1048], *pbuf;
 
-  if ( fileRead(fileID, buffer, 4) != 4 ) return (0);
+  if ( fileRead(fileID, buffer, 4) != 4 ) return 0;
 
-  blocklen  = get_UINT32(buffer);
-  sblocklen = get_SUINT32(buffer);
+  size_t blocklen  = get_UINT32(buffer);
+  size_t sblocklen = get_SUINT32(buffer);
 
   if ( IEG_Debug )
     Message("blocklen = %d sblocklen = %d", blocklen, sblocklen);
@@ -160,7 +156,7 @@ int iegCheckFiletype(int fileID, int *swap)
     {
      *swap = 0;
       fact = 4;
-      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return (0);
+      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return 0;
       pbuf = buffer+(37+4)*4;    dimx = (size_t) get_UINT32(pbuf);
       pbuf = buffer+(37+5)*4;    dimy = (size_t) get_UINT32(pbuf);
       pbuf = buffer+blocklen+4;  data = (size_t) get_UINT32(pbuf);
@@ -169,7 +165,7 @@ int iegCheckFiletype(int fileID, int *swap)
     {
      *swap = 0;
       fact = 8;
-      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return (0);
+      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return 0;
       pbuf = buffer+(37+4)*4;    dimx = (size_t) get_UINT32(pbuf);
       pbuf = buffer+(37+5)*4;    dimy = (size_t) get_UINT32(pbuf);
       pbuf = buffer+blocklen+4;  data = (size_t) get_UINT32(pbuf);
@@ -178,7 +174,7 @@ int iegCheckFiletype(int fileID, int *swap)
     {
      *swap = 1;
       fact = 4;
-      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return (0);
+      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return 0;
       pbuf = buffer+(37+4)*4;     dimx = (size_t) get_SUINT32(pbuf);
       pbuf = buffer+(37+5)*4;     dimy = (size_t) get_SUINT32(pbuf);
       pbuf = buffer+sblocklen+4;  data = (size_t) get_SUINT32(pbuf);
@@ -187,7 +183,7 @@ int iegCheckFiletype(int fileID, int *swap)
     {
      *swap = 1;
       fact = 8;
-      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return (0);
+      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return 0;
       pbuf = buffer+(37+4)*4;     dimx = (size_t) get_SUINT32(pbuf);
       pbuf = buffer+(37+5)*4;     dimy = (size_t) get_SUINT32(pbuf);
       pbuf = buffer+sblocklen+4;  data = (size_t) get_SUINT32(pbuf);
@@ -203,12 +199,15 @@ int iegCheckFiletype(int fileID, int *swap)
       Message("dimx = %lu dimy = %lu data = %lu", dimx, dimy, data);
     }
 
-  return (found);
+  return found;
 }
 
 
-void iegCopyMeta(iegrec_t *diegp, iegrec_t *siegp)
+void iegCopyMeta(void *dieg, void *sieg)
 {
+  iegrec_t *diegp = (iegrec_t *) dieg;
+  iegrec_t *siegp = (iegrec_t *) sieg;
+
   /*  diegp->byteswap = siegp->byteswap; */
   diegp->dprec    = siegp->dprec;
   diegp->refval   = siegp->refval;
@@ -218,26 +217,19 @@ void iegCopyMeta(iegrec_t *diegp, iegrec_t *siegp)
   memcpy(diegp->vct,  siegp->vct,  sizeof(siegp->vct));
 }
 
-
-int iegInqData(iegrec_t *iegp, int prec, void *data)
+static
+int iegInqData(void *ieg, int prec, void *data)
 {
-  size_t datasize;
-  size_t i;
+  iegrec_t *iegp = (iegrec_t *) ieg;
   int ierr = 0;
-  int dprec;
-  void *buffer;
   int byteswap = iegp->byteswap;
-
-
-  datasize = iegp->datasize;
-
-  buffer = iegp->buffer;
-
-  dprec = iegp->dprec;
+  size_t datasize = iegp->datasize;
+  void *buffer = iegp->buffer;
+  int dprec = iegp->dprec;
 
   switch ( dprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	if ( sizeof(FLT32) == 4 )
 	  {
@@ -246,8 +238,12 @@ int iegInqData(iegrec_t *iegp, int prec, void *data)
 	    if ( dprec == prec )
 	      memcpy(data, buffer, datasize*sizeof(FLT32));
 	    else
-	      for (i = 0; i < datasize; i++)
-		((double *) data)[i] = (double) ((float *) buffer)[i];
+              {
+                const float *restrict p = (float *)buffer;
+                double *restrict q = (double *)data;
+                for ( size_t i = 0; i < datasize; i++)
+                  q[i] = p[i];
+              }
 	  }
 	else
 	  {
@@ -255,7 +251,7 @@ int iegInqData(iegrec_t *iegp, int prec, void *data)
 	  }
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
 	if ( sizeof(FLT64) == 8 )
 	  {
 	    if ( byteswap ) swap8byte(buffer, datasize);
@@ -263,8 +259,12 @@ int iegInqData(iegrec_t *iegp, int prec, void *data)
 	    if ( dprec == prec )
 	      memcpy(data, buffer, datasize*sizeof(FLT64));
 	    else
-	      for (i = 0; i < datasize; i++)
-		((float *) data)[i] = (float) ((double *) buffer)[i];
+              {
+                const double *restrict p = (double *)buffer;
+                float *restrict q = (float *)data;
+                for ( size_t i = 0; i < datasize; i++)
+                  q[i] = (float)p[i];
+              }
 	  }
 	else
 	  {
@@ -278,32 +278,28 @@ int iegInqData(iegrec_t *iegp, int prec, void *data)
       }
     }
 
-  return (ierr);
+  return ierr;
 }
 
 
-int iegInqDataSP(iegrec_t *iegp, float *data)
+int iegInqDataSP(void *ieg, float *data)
 {
-  return (iegInqData(iegp, SINGLE_PRECISION, (void *) data));
+  return iegInqData(ieg, EXSE_SINGLE_PRECISION, (void *) data);
 }
 
 
-int iegInqDataDP(iegrec_t *iegp, double *data)
+int iegInqDataDP(void *ieg, double *data)
 {
-  return (iegInqData(iegp, DOUBLE_PRECISION, (void *) data));
+  return iegInqData(ieg, EXSE_DOUBLE_PRECISION, (void *) data);
 }
 
 
-int iegDefData(iegrec_t *iegp, int prec, const void *data)
+static int
+iegDefData(iegrec_t *iegp, int prec, const void *data)
 {
-  size_t datasize;
-  size_t blocklen;
-  size_t buffersize;
-  size_t i;
   int dprec;
   void *buffer;
 
-
   if ( iegDefaultDprec ) dprec = iegDefaultDprec;
   else                   dprec = iegp->dprec;
 
@@ -311,18 +307,18 @@ int iegDefData(iegrec_t *iegp, int prec, const void *data)
 
   iegp->dprec = dprec;
 
-  datasize = (size_t)IEG_G_NumLon(iegp->igdb) * (size_t)IEG_G_NumLat(iegp->igdb);
-  blocklen = datasize * (size_t)dprec;
+  size_t datasize = (size_t)IEG_G_NumLon(iegp->igdb) * (size_t)IEG_G_NumLat(iegp->igdb);
+  size_t blocklen = datasize * (size_t)dprec;
 
   iegp->datasize = datasize;
 
-  buffersize = iegp->buffersize;
+  size_t buffersize = iegp->buffersize;
 
   if ( buffersize != blocklen )
     {
       buffersize = blocklen;
       buffer = iegp->buffer;
-      buffer = realloc(buffer, buffersize);
+      buffer = Realloc(buffer, buffersize);
       iegp->buffer = buffer;
       iegp->buffersize = buffersize;
     }
@@ -331,24 +327,30 @@ int iegDefData(iegrec_t *iegp, int prec, const void *data)
 
   switch ( dprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	if ( dprec == prec )
 	  memcpy(buffer, data, datasize*sizeof(FLT32));
 	else
-	  for (i = 0; i < datasize; i++)
-	    ((float *) buffer)[i] = (float) ((double *) data)[i];
-
+          {
+            const double *restrict p = (const double *)data;
+            float *restrict q = (float *)buffer;
+            for (size_t i = 0; i < datasize; i++)
+              q[i] = (float)p[i];
+          }
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
 	if ( dprec == prec )
 	  memcpy(buffer, data, datasize*sizeof(FLT64));
 	else
-	  for (i = 0; i < datasize; i++)
-	    ((double *) buffer)[i] = (double) ((float *) data)[i];
-
+          {
+            const float *restrict p = (const float *)data;
+            double *restrict q = (double *)buffer;
+            for ( size_t i = 0; i < datasize; i++)
+              q[i] = p[i];
+          }
 	break;
       }
     default:
@@ -358,50 +360,45 @@ int iegDefData(iegrec_t *iegp, int prec, const void *data)
       }
     }
 
-  return (0);
+  return 0;
 }
 
 
-int iegDefDataSP(iegrec_t *iegp, const float *data)
+int iegDefDataSP(void *ieg, const float *data)
 {
-  return (iegDefData(iegp, SINGLE_PRECISION, (void *) data));
+  return iegDefData((iegrec_t *)ieg, EXSE_SINGLE_PRECISION, (void *) data);
 }
 
 
-int iegDefDataDP(iegrec_t *iegp, const double *data)
+int iegDefDataDP(void *ieg, const double *data)
 {
-  return (iegDefData(iegp, DOUBLE_PRECISION, (void *) data));
+  return iegDefData((iegrec_t *)ieg, EXSE_DOUBLE_PRECISION, (void *) data);
 }
 
 
-int iegRead(int fileID, iegrec_t *iegp)
+int iegRead(int fileID, void *ieg)
 {
-  size_t datasize;
-  size_t blocklen, blocklen2;
-  size_t i;
-  char tmpbuffer[800], *tmpbuf = tmpbuffer;
-  int dprec = 0;
-  void *buffer;
-  int byteswap;
-  int status;
+  iegrec_t *iegp = (iegrec_t *) ieg;
+  union { double d[200]; float f[200]; int32_t i32[200]; } buf;
 
   if ( ! iegp->checked )
     {
-      status = iegCheckFiletype(fileID, &iegp->byteswap);
+      int status = iegCheckFiletype(fileID, &iegp->byteswap);
       if ( status == 0 ) Error("Not a IEG file!");
       iegp->checked = 1;
     }
 
-  byteswap = iegp->byteswap;
+  int byteswap = iegp->byteswap;
 
   /* read header record */
-  blocklen = binReadF77Block(fileID, byteswap);
+  size_t blocklen = binReadF77Block(fileID, byteswap);
 
-  if ( fileEOF(fileID) ) return (-1);
+  if ( fileEOF(fileID) ) return -1;
 
   if ( IEG_Debug )
     Message("blocklen = %lu", blocklen);
 
+  int dprec = 0;
   if ( blocklen == 636 || blocklen == 640 )
     dprec = 4;
   else if ( blocklen == 1040 || blocklen == 1036 )
@@ -409,98 +406,91 @@ int iegRead(int fileID, iegrec_t *iegp)
   else
     {
       Warning("unexpecteted header size %d!", (int) blocklen);
-      return (-1);
+      return -1;
     }
 
   iegp->dprec = dprec;
 
-  binReadInt32(fileID, byteswap, 37, (INT32 *) tmpbuf);
-  for ( i = 0; i < 37; i++ ) iegp->ipdb[i] = (int) ((INT32 *) tmpbuf)[i];
+  binReadInt32(fileID, byteswap, 37, buf.i32);
+  for ( size_t i = 0; i < 37; i++ ) iegp->ipdb[i] = (int)buf.i32[i];
 
-  binReadInt32(fileID, byteswap, 18, (INT32 *) tmpbuf);
-  for ( i = 0; i < 18; i++ ) iegp->igdb[i] = (int) ((INT32 *) tmpbuf)[i];
+  binReadInt32(fileID, byteswap, 18, buf.i32);
+  for ( size_t i = 0; i < 18; i++ ) iegp->igdb[i] = (int)buf.i32[i];
 
   if ( blocklen == 636 || blocklen == 1036 )
     {
-      fileRead(fileID, tmpbuf, 4);
-      if ( byteswap ) swap4byte(tmpbuf, 1);
-      iegp->refval = (double) ((float *) tmpbuf)[0];
+      fileRead(fileID, buf.f, 4);
+      if ( byteswap ) swap4byte(buf.f, 1);
+      iegp->refval = (double)buf.f[0];
     }
   else
     {
-      fileRead(fileID, tmpbuf, 8);
-      if ( byteswap ) swap8byte(tmpbuf, 1);
-      iegp->refval = (double) ((double *) tmpbuf)[0];
+      fileRead(fileID, buf.d, 8);
+      if ( byteswap ) swap8byte(buf.d, 1);
+      iegp->refval = (double)buf.d[0];
     }
 
-  binReadInt32(fileID, byteswap, 3, (INT32 *) tmpbuf);
-  for ( i = 0; i < 3; i++ ) iegp->igdb[18+i] = (int) ((INT32 *) tmpbuf)[i];
+  binReadInt32(fileID, byteswap, 3, buf.i32);
+  for ( size_t i = 0; i < 3; i++ ) iegp->igdb[18+i] = (int)buf.i32[i];
 
-  if ( dprec == SINGLE_PRECISION )
+  if ( dprec == EXSE_SINGLE_PRECISION )
     {
-      fileRead(fileID, tmpbuf, 400);
-      if ( byteswap ) swap4byte(tmpbuf, 100);
-      for ( i = 0; i < 100; i++ )
-	iegp->vct[i] = (double) ((float *) tmpbuf)[i];
+      fileRead(fileID, buf.f, 400);
+      if ( byteswap ) swap4byte(buf.f, 100);
+      for ( size_t i = 0; i < 100; i++ )
+	iegp->vct[i] = (double)buf.f[i];
     }
   else
     {
-      fileRead(fileID, tmpbuf, 800);
-      if ( byteswap ) swap8byte(tmpbuf, 100);
-      for ( i = 0; i < 100; i++ )
-	iegp->vct[i] = (double) ((double *) tmpbuf)[i];
+      fileRead(fileID, buf.d, 800);
+      if ( byteswap ) swap8byte(buf.d, 100);
+      for ( size_t i = 0; i < 100; i++ )
+	iegp->vct[i] = buf.d[i];
     }
 
   /*
   fprintf(stderr, "refval %g\n", iegp->refval);
 
-  for ( i = 0; i < 100; i++ )
+  for ( size_t i = 0; i < 100; i++ )
     fprintf(stderr, "%3d %g\n", i, iegp->vct[i]);
 
   {
     int i;
-    for ( i = 0; i < 37; i++ )
+    for ( size_t i = 0; i < 37; i++ )
       fprintf(stderr, "pdb: %d %d\n", i, iegp->ipdb[i]);
-    for ( i = 0; i < 22; i++ )
+    for ( size_t i = 0; i < 22; i++ )
       fprintf(stderr, "gdb: %d %d\n", i, iegp->igdb[i]);
   }
   */
-  blocklen2 = binReadF77Block(fileID, byteswap);
+  size_t blocklen2 = binReadF77Block(fileID, byteswap);
 
   if ( blocklen2 != blocklen )
     {
       Warning("header blocklen differ!");
-      return (-1);
+      return -1;
     }
 
-  iegp->datasize = (size_t)IEG_G_NumLon(iegp->igdb)
-    * (size_t)IEG_G_NumLat(iegp->igdb);
+  size_t datasize = iegp->datasize
+    = (size_t)IEG_G_NumLon(iegp->igdb) * (size_t)IEG_G_NumLat(iegp->igdb);
 
   if ( IEG_Debug )
     Message("datasize = %lu", iegp->datasize);
 
   blocklen = binReadF77Block(fileID, byteswap);
 
-  size_t buffersize = iegp->buffersize;
 
-  if ( buffersize < blocklen )
+  void *buffer = iegp->buffer;
+  if ( iegp->buffersize < blocklen )
     {
-      buffersize = blocklen;
-      buffer = iegp->buffer;
-      buffer = realloc(buffer, buffersize);
-      iegp->buffer = buffer;
-      iegp->buffersize = buffersize;
+      iegp->buffer = buffer = Realloc(buffer, blocklen);
+      iegp->buffersize = blocklen;
     }
-  else
-    buffer = iegp->buffer;
-
-  datasize = iegp->datasize;
 
   if ( dprec != (int) (blocklen/datasize) )
     {
       Warning("data precision differ! (h = %d; d = %d)",
 	      (int) dprec, (int) (blocklen/datasize));
-      return (-1);
+      return -1;
     }
 
   fileRead(fileID, buffer, blocklen);
@@ -510,57 +500,45 @@ int iegRead(int fileID, iegrec_t *iegp)
   if ( blocklen2 != blocklen )
     {
       Warning("data blocklen differ!");
-      return (-1);
+      return -1;
     }
 
-  return (0);
+  return 0;
 }
 
 
-int iegWrite(int fileID, iegrec_t *iegp)
+int iegWrite(int fileID, void *ieg)
 {
-  size_t datasize;
-  size_t blocklen;
-  size_t i;
-  int dprec;
-  float refvalf;
-  double refval;
-  char tmpbuf[800];
-  float fvct[100];
-  void *buffer;
+  iegrec_t *iegp = (iegrec_t *) ieg;
+  union { INT32 i32[200]; float fvct[100]; } buf;
+  int dprec  = iegp->dprec;
   int byteswap = iegp->byteswap;
 
-
-  dprec  = iegp->dprec;
-
   /* write header record */
-  if ( dprec == SINGLE_PRECISION )
-    blocklen = 636;
-  else
-    blocklen = 1040;
+  size_t blocklen = ( dprec == EXSE_SINGLE_PRECISION ) ? 636 : 1040;
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
-  for ( i = 0; i < 37; i++ ) ((INT32 *) tmpbuf)[i] = (INT32) iegp->ipdb[i];
-  binWriteInt32(fileID, byteswap, 37, (INT32 *) tmpbuf);
+  for ( size_t i = 0; i < 37; i++ ) buf.i32[i] = (INT32) iegp->ipdb[i];
+  binWriteInt32(fileID, byteswap, 37, buf.i32);
 
-  for ( i = 0; i < 18; i++ ) ((INT32 *) tmpbuf)[i] = (INT32) iegp->igdb[i];
-  binWriteInt32(fileID, byteswap, 18, (INT32 *) tmpbuf);
+  for ( size_t i = 0; i < 18; i++ ) buf.i32[i] = (INT32) iegp->igdb[i];
+  binWriteInt32(fileID, byteswap, 18, buf.i32);
 
-  refval = iegp->refval;
-  refvalf = (float) refval;
-  if ( dprec == SINGLE_PRECISION )
-    binWriteFlt32(fileID, byteswap, 1, (FLT32 *) &refvalf);
+  FLT64 refval = (FLT64)iegp->refval;
+  FLT32 refvalf = (FLT32)iegp->refval;
+  if ( dprec == EXSE_SINGLE_PRECISION )
+    binWriteFlt32(fileID, byteswap, 1, &refvalf);
   else
-    binWriteFlt64(fileID, byteswap, 1, (FLT64 *) &refval);
+    binWriteFlt64(fileID, byteswap, 1, &refval);
 
-  for ( i = 0; i < 3; i++ ) ((INT32 *) tmpbuf)[i] = (INT32) iegp->igdb[18+i];
-  binWriteInt32(fileID, byteswap, 3, (INT32 *) tmpbuf);
+  for ( size_t i = 0; i < 3; i++ ) buf.i32[i] = (INT32) iegp->igdb[18+i];
+  binWriteInt32(fileID, byteswap, 3, buf.i32);
 
-  if ( dprec == SINGLE_PRECISION )
+  if ( dprec == EXSE_SINGLE_PRECISION )
     {
-      for ( i = 0; i < 100; i++ ) fvct[i] = (float) iegp->vct[i];
-      binWriteFlt32(fileID, byteswap, 100, fvct);
+      for ( size_t i = 0; i < 100; i++ ) buf.fvct[i] = (float) iegp->vct[i];
+      binWriteFlt32(fileID, byteswap, 100, buf.fvct);
     }
   else
     {
@@ -569,23 +547,23 @@ int iegWrite(int fileID, iegrec_t *iegp)
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
-  datasize = (size_t)iegp->igdb[4] * (size_t)iegp->igdb[5];
+  size_t datasize = (size_t)iegp->igdb[4] * (size_t)iegp->igdb[5];
   blocklen = datasize * (size_t)dprec;
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
   iegp->datasize = datasize;
 
-  buffer = iegp->buffer;
+  void *buffer = iegp->buffer;
 
   switch ( dprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	binWriteFlt32(fileID, byteswap, datasize, (FLT32 *) buffer);
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
 	binWriteFlt64(fileID, byteswap, datasize, (FLT64 *) buffer);
 	break;
@@ -599,7 +577,7 @@ int iegWrite(int fileID, iegrec_t *iegp)
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
-  return (0);
+  return 0;
 }
 /*
  * Local Variables:
diff --git a/libcdi/src/input_file.c b/libcdi/src/input_file.c
index 5d1e36f..c0f1647 100644
--- a/libcdi/src/input_file.c
+++ b/libcdi/src/input_file.c
@@ -1,8 +1,8 @@
+#define _XOPEN_SOURCE 600
 #include "input_file.h"
 
 #include "cdi.h"
 #include "dmemory.h"
-#include "proprietarySystemWorkarounds.h"
 
 #include <errno.h>
 #include <fcntl.h>
@@ -20,7 +20,7 @@ static CdiInputFile* cdiInputFile_condestruct(CdiInputFile* me, const char* path
   #define super() (&me->super)
   if(!path) goto destruct;
   cdiRefObject_construct(super());
-  me->path = myStrDup(path);
+  me->path = strdup(path);
   if(!me->path) goto destructSuper;
   do
     {
@@ -39,7 +39,7 @@ static CdiInputFile* cdiInputFile_condestruct(CdiInputFile* me, const char* path
 destruct:
   close(me->fileDescriptor);
 freePath:
-  free(me->path);
+  Free(me->path);
 destructSuper:
   cdiRefObject_destruct(super());
   me = NULL;
@@ -49,7 +49,7 @@ success:
   #undef super
 }
 
-static CdiInputFile** openFileList = NULL;
+static CdiInputFile **openFileList = NULL;
 static size_t openFileCount = 0, openFileListSize = 0;
 static pthread_mutex_t openFileListLock = PTHREAD_MUTEX_INITIALIZER;
 
@@ -73,11 +73,11 @@ CdiInputFile* cdiInputFile_make(const char* path)
         }
       else
         {
-          result = xmalloc(sizeof(*result));
+          result = (CdiInputFile *) Malloc(sizeof(*result));
           if(!cdiInputFile_condestruct(result, path))
             {
               //An error occured during construction, avoid a memory leak.
-              free(result);
+              Free(result);
               result = NULL;
             }
           else
@@ -87,7 +87,7 @@ CdiInputFile* cdiInputFile_make(const char* path)
                 {
                   openFileListSize *= 2;
                   if(openFileListSize < 16) openFileListSize = 16;
-                  openFileList = xrealloc(openFileList, openFileListSize);
+                  openFileList = (CdiInputFile **) Realloc(openFileList, openFileListSize);
                 }
               xassert(openFileCount < openFileListSize);
               openFileList[openFileCount++] = result;
@@ -101,7 +101,7 @@ CdiInputFile* cdiInputFile_make(const char* path)
 
 int cdiInputFile_read(const CdiInputFile* me, off_t readPosition, size_t readSize, size_t* outActualReadSize, void* buffer)
 {
-  char* byteBuffer = buffer;
+  char* byteBuffer = (char *)buffer;
   size_t trash;
   if(!outActualReadSize) outActualReadSize = &trash;
   *outActualReadSize = 0;
@@ -112,15 +112,15 @@ int cdiInputFile_read(const CdiInputFile* me, off_t readPosition, size_t readSiz
       if(bytesRead == 0) return CDI_EEOF;
       byteBuffer += bytesRead;
       readPosition += bytesRead;
-      readSize -= bytesRead;
-      *outActualReadSize += bytesRead;
+      readSize -= (size_t)bytesRead;
+      *outActualReadSize += (size_t)bytesRead;
     }
   return CDI_NOERR;
 }
 
-char* cdiInputFile_copyPath(const CdiInputFile* me)
+const char* cdiInputFile_getPath(const CdiInputFile* me)
 {
-  return myStrDup(me->path);
+  return me->path;
 }
 
 void cdiInputFile_destruct(CdiInputFile* me)
@@ -129,9 +129,8 @@ void cdiInputFile_destruct(CdiInputFile* me)
   xassert(!error);
     {
       //Find the position of me in the list of open files.
-      ssize_t position;
-      for(position = openFileCount; position--; ) if(openFileList[position] == me) break;
-      xassert(position != -1);
+      ssize_t position = (ssize_t)openFileCount;
+      while (position > 0 && openFileList[--position] != me);
       //Remove me from the list
       openFileList[position] = openFileList[--openFileCount];
     }
@@ -139,3 +138,13 @@ void cdiInputFile_destruct(CdiInputFile* me)
   xassert(!error);
   cdiInputFile_condestruct(me, NULL);
 }
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/input_file.h b/libcdi/src/input_file.h
index ab3c8d3..6be9c25 100644
--- a/libcdi/src/input_file.h
+++ b/libcdi/src/input_file.h
@@ -21,7 +21,19 @@ typedef struct CdiInputFile {
 //Final class, the constructor is private and not defined here.
 CdiInputFile* cdiInputFile_make(const char* path);   //The caller is responsible to call cdiRefObject_release() on the returned object.
 int cdiInputFile_read(const CdiInputFile* me, off_t readPosition, size_t readSize, size_t* outActualReadSize, void* buffer);       //Returns one of CDI_EINVAL, CDI_ESYSTEM, CDI_EEOF, OR CDI_NOERR.
-char* cdiInputFile_copyPath(const CdiInputFile* me);    //Returns a malloc'ed string, don't forget to free() it.
+/* Returns path string, don't use after destruction of CdiInputFile
+ * object */
+const char* cdiInputFile_getPath(const CdiInputFile* me);
 //Destructor is private as well.
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/institution.c b/libcdi/src/institution.c
index b4cdadb..10ea652 100644
--- a/libcdi/src/institution.c
+++ b/libcdi/src/institution.c
@@ -18,10 +18,9 @@
 #undef  UNDEFID
 #define UNDEFID  -1
 
-int ECMWF  = UNDEFID;
-int MPIMET = UNDEFID;
-int DWD    = UNDEFID;
-int MCH    = UNDEFID;
+static int ECMWF  = UNDEFID,
+  MPIMET = UNDEFID,
+  MCH    = UNDEFID;
 
 typedef struct
 {
@@ -151,7 +150,7 @@ findInstitute(int id, void *res, void *data)
 
 int institutInq(int center, int subcenter, const char *name, const char *longname)
 {
-  institute_t * ip_ref = (institute_t *)xmalloc(sizeof (*ip_ref));
+  institute_t * ip_ref = (institute_t *) Malloc(sizeof (*ip_ref));
   ip_ref->self       = UNDEFID;
   ip_ref->used       = 0;
   ip_ref->center     = center;
@@ -162,7 +161,7 @@ int institutInq(int center, int subcenter, const char *name, const char *longnam
   struct instLoc state = { .ip = ip_ref, .id = UNDEFID };
   cdiResHFilterApply(&instituteOps, findInstitute, &state);
 
-  free(ip_ref);
+  Free(ip_ref);
 
   return state.id;
 }
@@ -171,7 +170,7 @@ static
 institute_t *instituteNewEntry(cdiResH resH, int center, int subcenter,
                                const char *name, const char *longname)
 {
-  institute_t *instituteptr = (institute_t*) xmalloc(sizeof(institute_t));
+  institute_t *instituteptr = (institute_t*) Malloc(sizeof(institute_t));
   instituteDefaultValue(instituteptr);
   if (resH == CDI_UNDEFID)
     instituteptr->self = reshPut(instituteptr, &instituteOps);
@@ -266,10 +265,10 @@ instituteDestroyP(institute_t *instituteptr)
   xassert(instituteptr);
 
   int instituteID = instituteptr->self;
-  free(instituteptr->name);
-  free(instituteptr->longname);
+  Free(instituteptr->name);
+  Free(instituteptr->longname);
   reshRemove(instituteID, &instituteOps);
-  free(instituteptr);
+  Free(instituteptr);
 }
 
 
@@ -333,7 +332,7 @@ int instituteUnpack(void *buf, int size, int *position, int originNamespace,
   int instituteID;
   char *name, *longname;
   serializeUnpack(buf, size, position, tempbuf, institute_nints, DATATYPE_INT, context);
-  name = (char *)xmalloc((size_t)tempbuf[3] + (size_t)tempbuf[4]);
+  name = (char *) Malloc((size_t)tempbuf[3] + (size_t)tempbuf[4]);
   longname = name + tempbuf[3];
   serializeUnpack(buf, size, position, name, tempbuf[3], DATATYPE_TXT, context);
   serializeUnpack(buf, size, position, longname, tempbuf[4], DATATYPE_TXT, context);
@@ -342,7 +341,9 @@ int instituteUnpack(void *buf, int size, int *position, int originNamespace,
                                       tempbuf[1], tempbuf[2], name, longname);
   instituteID = ip->self;
   xassert(!force_id || instituteID == targetID);
-  free(name);
+  Free(name);
+  reshSetStatus(instituteID, &instituteOps,
+                reshGetStatus(instituteID, &instituteOps) & ~RESH_SYNC_BIT);
   return instituteID;
 }
 
diff --git a/libcdi/src/iterator.c b/libcdi/src/iterator.c
index 2b431fd..2ed5933 100644
--- a/libcdi/src/iterator.c
+++ b/libcdi/src/iterator.c
@@ -1,50 +1,53 @@
 #include "cdi.h"
+#include "dmemory.h"
 #include "iterator.h"
 #include "iterator_fallback.h"
 #include "iterator_grib.h"
 #include "cdi_int.h"
-#include "proprietarySystemWorkarounds.h"
 
 #include <assert.h>
 #include <ctype.h>
 
-const char* const kUnexpectedFileTypeMessage = "Internal error: Unexpected file type encountered in iterator.\nThis is either due to an illegal memory access by the application or an internal logical error in CDI (unlikely, but possible).";
-const char* const kAdvancedString = "advanced";
-const char* const kUnadvancedString = "unadvanced";
+static const char kUnexpectedFileTypeMessage[]
+  = "Internal error: Unexpected file type encountered in iterator.\n"
+  "This is either due to an illegal memory access by the application\n"
+  " or an internal logical error in CDI (unlikely, but possible).";
+static const char kAdvancedString[] = "advanced";
+static const char kUnadvancedString[] = "unadvanced";
 
 //Returns a static string.
 static const char* fileType2String(int fileType)
 {
   switch(fileType)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB: return "CDI::Iterator::GRIB1";
         case FILETYPE_GRB2: return "CDI::Iterator::GRIB2";
-      #endif
-      #ifdef HAVE_LIBNETCDF
+#endif
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC: return "CDI::Iterator::NetCDF";
         case FILETYPE_NC2: return "CDI::Iterator::NetCDF2";
         case FILETYPE_NC4: return "CDI::Iterator::NetCDF4";
         case FILETYPE_NC4C: return "CDI::Iterator::NetCDF4C";
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV: return "CDI::Iterator::SRV";
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT: return "CDI::Iterator::EXT";
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG: return "CDI::Iterator::IEG";
-      #endif
+#endif
 
       default: return NULL;
     }
 }
 
-static int string2FileType(const char* fileType, const char** outRestString)
+static int string2FileType(const char* fileType, const char **outRestString)
 {
   //This first part unconditionally checks all known type strings, and only if the given string matches one of these strings, we use fileType2string() to check whether support for this type has been compiled in. This is to avoid throwing "invalid type string" errors when we just have a library version mismatch.
-  #define check(givenString, typeString, typeConstant) do \
+#define check(givenString, typeString, typeConstant) do \
     { \
       if(givenString == strstr(givenString, typeString)) \
         { \
@@ -63,7 +66,7 @@ static int string2FileType(const char* fileType, const char** outRestString)
   check(fileType, "CDI::Iterator::SRV", FILETYPE_SRV);
   check(fileType, "CDI::Iterator::EXT", FILETYPE_EXT);
   check(fileType, "CDI::Iterator::IEG", FILETYPE_IEG);
-  #undef check
+#undef check
 
   //If this point is reached, the given string does not seem to be produced by a cdiIterator_serialize() call.
   Error("The string \"%s\" does not start with a valid iterator type. Please check the source of this string.", fileType);
@@ -71,7 +74,7 @@ static int string2FileType(const char* fileType, const char** outRestString)
   return FILETYPE_UNDEF;
 }
 
-/**
+/*
 @Function cdiIterator_new
 @Title Create an iterator for an input file
 
@@ -100,27 +103,27 @@ CdiIterator* cdiIterator_new(const char* path)
         Warning("Can't open file \"%s\": unknown format\n", path);
         return NULL;
 
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_new(path, filetype);
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           return cdiFallbackIterator_new(path, filetype);
 
       default:
@@ -144,12 +147,12 @@ const char* baseIter_constructFromString(CdiIterator* me, const char* descriptio
   if(result == strstr(result, kAdvancedString))
     {
       me->isAdvanced = true;
-      result += strlen(kAdvancedString);
+      result += sizeof (kAdvancedString) - 1;
     }
   else if(result == strstr(result, kUnadvancedString))
     {
       me->isAdvanced = false;
-      result += strlen(kUnadvancedString);
+      result += sizeof (kUnadvancedString) - 1;
     }
   else
     {
@@ -164,7 +167,7 @@ const char* baseIter_constructFromString(CdiIterator* me, const char* descriptio
     if(!me->isAdvanced) xabort("Calling %s is not allowed without calling cdiIterator_nextField() first.", __func__); \
 } while(0)
 
-/**
+/*
 @Function cdiIterator_clone
 @Title Make a copy of an iterator
 
@@ -189,28 +192,28 @@ CdiIterator* cdiIterator_clone(CdiIterator* me)
   sanityCheck(me);
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
-          return &cdiGribIterator_clone(me)->super;
-      #endif
+          return cdiGribIterator_getSuper(cdiGribIterator_clone(me));
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
-          return &cdiFallbackIterator_clone(me)->super;
+#endif
+          return cdiFallbackIterator_getSuper(cdiFallbackIterator_clone(me));
 
       default:
         Error(kUnexpectedFileTypeMessage);
@@ -218,7 +221,7 @@ CdiIterator* cdiIterator_clone(CdiIterator* me)
     }
 }
 
-/**
+/*
 @Function cdiGribIterator_clone
 @Title Gain access to GRIB specific functionality
 
@@ -239,18 +242,18 @@ CdiGribIterator* cdiGribIterator_clone(CdiIterator* me)
   sanityCheck(me);
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_makeClone(me);
-      #endif
+#endif
 
       default:
         return NULL;
     }
 }
 
-/**
+/*
 @Function cdiIterator_serialize
 @Title Serialize an iterator for sending it to another process
 
@@ -261,7 +264,7 @@ CdiGribIterator* cdiGribIterator_clone(CdiIterator* me)
 @Result A malloc'ed string that contains the full description of the iterator.
 
 @Description
-    Make sure to call free() on the resulting string.
+    Make sure to call Free() on the resulting string.
 */
 char* cdiIterator_serialize(CdiIterator* me)
 {
@@ -269,28 +272,28 @@ char* cdiIterator_serialize(CdiIterator* me)
   char* subclassDescription = NULL;
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           subclassDescription = cdiGribIterator_serialize(me);
           break;
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           subclassDescription = cdiFallbackIterator_serialize(me);
           break;
 
@@ -299,12 +302,16 @@ char* cdiIterator_serialize(CdiIterator* me)
         return NULL;
     }
 
-  char* result = myAsprintf("%s %s %s", fileType2String(me->filetype), (me->isAdvanced ? kAdvancedString : kUnadvancedString), subclassDescription);
-  free(subclassDescription);
+  const char *ftypeStr = fileType2String(me->filetype),
+    *advStr = me->isAdvanced ? kAdvancedString : kUnadvancedString;
+  char* result = (char *) Malloc(strlen(ftypeStr) + 1 + strlen(advStr) + 1
+                         + strlen(subclassDescription) + 1);
+  sprintf(result, "%s %s %s", ftypeStr, advStr, subclassDescription);
+  Free(subclassDescription);
   return result;
 }
 
-/**
+/*
 @Function cdiIterator_deserialize
 @Title Recreate an iterator from its textual description
 
@@ -325,28 +332,28 @@ CdiIterator* cdiIterator_deserialize(const char* description)
 {
   switch(string2FileType(description, NULL))
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
-          return &cdiGribIterator_deserialize(description)->super;
-      #endif
+          return cdiGribIterator_getSuper(cdiGribIterator_deserialize(description));
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
-          return &cdiFallbackIterator_deserialize(description)->super;
+#endif
+          return cdiFallbackIterator_getSuper(cdiFallbackIterator_deserialize(description));
 
       default:
         Error(kUnexpectedFileTypeMessage);
@@ -355,7 +362,7 @@ CdiIterator* cdiIterator_deserialize(const char* description)
 }
 
 
-/**
+/*
 @Function cdiIterator_print
 @Title Print a textual description of the iterator to a stream
 
@@ -371,11 +378,11 @@ void cdiIterator_print(CdiIterator* me, FILE* stream)
 {
   char* description = cdiIterator_serialize(me);
   fprintf(stream, "%s\n", description);
-  free(description);
+  Free(description);
 }
 
 
-/**
+/*
 @Function cdiIterator_nextField
 @Title Advance an iterator to the next field in the file
 
@@ -397,27 +404,27 @@ int cdiIterator_nextField(CdiIterator* me)
   me->isAdvanced = true;
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_nextField(me);
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           return cdiFallbackIterator_nextField(me);
 
       default:
@@ -431,27 +438,27 @@ static char* cdiIterator_inqTime(CdiIterator* me, bool getEndTime)
   sanityCheck(me);
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_inqTime(me, getEndTime);
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           return cdiFallbackIterator_inqTime(me, getEndTime);
 
       default:
@@ -460,7 +467,7 @@ static char* cdiIterator_inqTime(CdiIterator* me, bool getEndTime)
     }
 }
 
-/**
+/*
 @Function cdiIterator_inqStartTime
 @Title Get the start time of a measurement
 
@@ -475,7 +482,7 @@ The returned time is either the time of the data (fields defined at a time point
 or the start time of an integration time range (statistical fields).
 
 Converts the time to the ISO-8601 format and returns it in a newly allocated buffer.
-The caller is responsible to free() the resulting string.
+The caller is responsible to Free() the resulting string.
 
 If the file is a GRIB file, the calendar that is used to resolve the relative times is the proleptic calendar
 as it is implemented by the standard C mktime() function.
@@ -486,7 +493,7 @@ char* cdiIterator_inqStartTime(CdiIterator* me)
   return cdiIterator_inqTime(me, false);
 }
 
-/**
+/*
 @Function cdiIterator_inqEndTime
 @Title Get the end time of a measurement
 
@@ -501,7 +508,7 @@ The returned time is the end time of an integration period if such a time exists
 Otherwise, NULL is returned.
 
 Converts the time to the ISO-8601 format and returns it in a newly allocated buffer.
-The caller is responsible to free() the resulting string.
+The caller is responsible to Free() the resulting string.
 
 If the file is a GRIB file, the calendar that is used to resolve the relative times is the proleptic calendar
 as it is implemented by the standard C mktime() function.
@@ -512,7 +519,7 @@ char* cdiIterator_inqEndTime(CdiIterator* me)
   return cdiIterator_inqTime(me, true);
 }
 
-/**
+/*
 @Function cdiIterator_inqVTime
 @Title Get the validity time of the current field
 
@@ -528,7 +535,7 @@ That is, if the field is a time point, its time is returned,
 if it is a statistical field with an integration period, the end time of the integration period is returned.
 
 Converts the time to the ISO-8601 format and returns it in a newly allocated buffer.
-The caller is responsible to free() the resulting string.
+The caller is responsible to Free() the resulting string.
 
 If the file is a GRIB file, the calendar that is used to resolve the relative times is the proleptic calendar
 as it is implemented by the standard C mktime() function.
@@ -540,18 +547,18 @@ char* cdiIterator_inqVTime(CdiIterator* me)
   return (result) ? result : cdiIterator_inqStartTime(me);
 }
 
-/**
+/*
 @Function cdiIterator_inqLevelType
 @Title Get the type of a level
 
- at Prototype int cdiIterator_inqLevelType(CdiIterator* me, int levelSelector, char** outName = NULL, char** outLongName = NULL, char** outStdName = NULL, char** outUnit = NULL)
+ at Prototype int cdiIterator_inqLevelType(CdiIterator* me, int levelSelector, char **outName = NULL, char **outLongName = NULL, char **outStdName = NULL, char **outUnit = NULL)
 @Parameter
     @item iterator The iterator to operate on.
     @item levelSelector Zero for the top level, one for the bottom level
-    @item outName Will be set to a malloc()'ed string with the name of the level if not NULL.
-    @item outLongName Will be set to a malloc()'ed string with the long name of the level if not NULL.
-    @item outStdName Will be set to a malloc()'ed string with the standard name of the level if not NULL.
-    @item outUnit Will be set to a malloc()'ed string with the unit of the level if not NULL.
+    @item outName Will be set to a Malloc()'ed string with the name of the level if not NULL.
+    @item outLongName Will be set to a Malloc()'ed string with the long name of the level if not NULL.
+    @item outStdName Will be set to a Malloc()'ed string with the standard name of the level if not NULL.
+    @item outUnit Will be set to a Malloc()'ed string with the unit of the level if not NULL.
 
 @Result An integer indicating the type of the level.
 
@@ -559,32 +566,32 @@ char* cdiIterator_inqVTime(CdiIterator* me)
 Find out some basic information about the given level, the levelSelector selects the function of the requested level.
 If the requested level does not exist, this returns CDI_UNDEFID.
 */
-int cdiIterator_inqLevelType(CdiIterator* me, int levelSelector, char** outName, char** outLongName, char** outStdName, char** outUnit)
+int cdiIterator_inqLevelType(CdiIterator* me, int levelSelector, char **outName, char **outLongName, char **outStdName, char **outUnit)
 {
   sanityCheck(me);
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_levelType(me, levelSelector, outName, outLongName, outStdName, outUnit);
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           return cdiFallbackIterator_levelType(me, levelSelector, outName, outLongName, outStdName, outUnit);
 
       default:
@@ -593,7 +600,7 @@ int cdiIterator_inqLevelType(CdiIterator* me, int levelSelector, char** outName,
     }
 }
 
-/**
+/*
 @Function cdiIterator_inqLevel
 @Title Get the value of the z-coordinate
 
@@ -614,27 +621,27 @@ int cdiIterator_inqLevel(CdiIterator* me, int levelSelector, double* outValue1,
   sanityCheck(me);
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_level(me, levelSelector, outValue1, outValue2);
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           return cdiFallbackIterator_level(me, levelSelector, outValue1, outValue2);
 
       default:
@@ -643,7 +650,7 @@ int cdiIterator_inqLevel(CdiIterator* me, int levelSelector, double* outValue1,
     }
 }
 
-/**
+/*
 @Function cdiIterator_inqLevelUuid
 @Title Get the UUID of the z-axis used by this field
 
@@ -659,32 +666,32 @@ int cdiIterator_inqLevel(CdiIterator* me, int levelSelector, double* outValue1,
 @Description
 Returns identifying information for the external z-axis description. May only be called for generalized levels.
 */
-int cdiIterator_inqLevelUuid(CdiIterator* me, int* outVgridNumber, int* outLevelCount, unsigned char (*outUuid)[16])
+int cdiIterator_inqLevelUuid(CdiIterator* me, int* outVgridNumber, int* outLevelCount, unsigned char outUuid[CDI_UUID_SIZE])
 {
   sanityCheck(me);
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_zaxisUuid(me, outVgridNumber, outLevelCount, outUuid);
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           return cdiFallbackIterator_zaxisUuid(me, outVgridNumber, outLevelCount, outUuid);
 
       default:
@@ -693,7 +700,7 @@ int cdiIterator_inqLevelUuid(CdiIterator* me, int* outVgridNumber, int* outLevel
     }
 }
 
-/**
+/*
 @Function cdiIterator_inqParam
 @Title Get discipline, category, and number
 
@@ -712,7 +719,7 @@ CdiParam cdiIterator_inqParam(CdiIterator* me)
   return me->param;
 }
 
-/**
+/*
 @Function cdiIterator_inqDatatype
 @Title Get the datatype of the current field
 
@@ -731,7 +738,7 @@ int cdiIterator_inqDatatype(CdiIterator* me)
   return me->datatype;
 }
 
-/**
+/*
 @Function cdiIterator_inqTsteptype
 @Title Get the timestep type
 
@@ -750,7 +757,7 @@ int cdiIterator_inqTsteptype(CdiIterator* me)
   return me->timesteptype;
 }
 
-/**
+/*
 @Function cdiIterator_inqVariableName
 @Title Get the variable name of the current field
 
@@ -758,38 +765,38 @@ int cdiIterator_inqTsteptype(CdiIterator* me)
 @Parameter
     @item iterator The iterator to operate on.
 
- at Result A pointer to a C-string containing the name. The storage for this string is allocated with malloc(), and it is the responsibility of the caller to free() it.
+ at Result A pointer to a C-string containing the name. The storage for this string is allocated with Malloc(), and it is the responsibility of the caller to Free() it.
 
 @Description
     Allocates a buffer to hold the string, copies the current variable name into this buffer, and returns the buffer.
-    The caller is responsible to make the corresponding free() call.
+    The caller is responsible to make the corresponding Free() call.
 */
 char* cdiIterator_inqVariableName(CdiIterator* me)
 {
   sanityCheck(me);
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           return cdiGribIterator_copyVariableName(me);
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           return cdiFallbackIterator_copyVariableName(me);
 
       default:
@@ -798,7 +805,7 @@ char* cdiIterator_inqVariableName(CdiIterator* me)
     }
 }
 
-/**
+/*
 @Function cdiIterator_inqGridId
 @Title Get the ID of the current grid
 
@@ -818,7 +825,7 @@ int cdiIterator_inqGridId(CdiIterator* me)
   return me->gridId;
 }
 
-/**
+/*
 @Function cdiIterator_readField
 @Title Read the whole field into a double buffer
 
@@ -838,28 +845,28 @@ void cdiIterator_readField(CdiIterator* me, double* buffer, size_t* nmiss)
   if(!buffer) xabort("NULL was passed in a buffer. Please provide a suitable buffer.");
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           cdiGribIterator_readField(me, buffer, nmiss);
 	  return;
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           cdiFallbackIterator_readField(me, buffer, nmiss);
           return;
       default:
@@ -867,7 +874,7 @@ void cdiIterator_readField(CdiIterator* me, double* buffer, size_t* nmiss)
     }
 }
 
-/**
+/*
 @Function cdiIterator_readFieldF
 @Title Read the whole field into a double buffer
 
@@ -887,28 +894,28 @@ void cdiIterator_readFieldF(CdiIterator* me, float* buffer, size_t* nmiss)
   if(!buffer) xabort("NULL was passed in a buffer. Please provide a suitable buffer.");
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           cdiGribIterator_readFieldF(me, buffer, nmiss);
 	  return;
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           cdiFallbackIterator_readFieldF(me, buffer, nmiss);
           return; 
       default:
@@ -916,7 +923,7 @@ void cdiIterator_readFieldF(CdiIterator* me, float* buffer, size_t* nmiss)
     }
 }
 
-/**
+/*
 @Function cdiIterator_delete
 @Title Destroy an iterator
 
@@ -932,28 +939,28 @@ void cdiIterator_delete(CdiIterator* me)
   if(!me) xabort("NULL was passed in as an iterator. Please check the return value of cdiIterator_new().");
   switch(me->filetype)
     {
-      #ifdef HAVE_LIBGRIB_API
+#ifdef HAVE_LIBGRIB_API
         case FILETYPE_GRB:
         case FILETYPE_GRB2:
           cdiGribIterator_delete((CdiGribIterator*)me);
           break;
-      #endif
+#endif
 
-      #ifdef HAVE_LIBNETCDF
+#ifdef HAVE_LIBNETCDF
         case FILETYPE_NC:
         case FILETYPE_NC2:
         case FILETYPE_NC4:
         case FILETYPE_NC4C:
-      #endif
-      #ifdef HAVE_LIBSERVICE
+#endif
+#ifdef HAVE_LIBSERVICE
         case FILETYPE_SRV:
-      #endif
-      #ifdef HAVE_LIBEXTRA
+#endif
+#ifdef HAVE_LIBEXTRA
         case FILETYPE_EXT:
-      #endif
-      #ifdef HAVE_LIBIEG
+#endif
+#ifdef HAVE_LIBIEG
         case FILETYPE_IEG:
-      #endif
+#endif
           cdiFallbackIterator_delete(me);
           break;
 
@@ -962,4 +969,18 @@ void cdiIterator_delete(CdiIterator* me)
     }
 }
 
-void baseIterDestruct(CdiIterator* me) { /*currently empty, but that's no reason not to call it*/ }
+void baseIterDestruct(CdiIterator* me)
+{
+  /*currently empty, but that's no reason not to call it*/
+  (void)me;
+}
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/iterator.h b/libcdi/src/iterator.h
index a65ef37..f70ebe4 100644
--- a/libcdi/src/iterator.h
+++ b/libcdi/src/iterator.h
@@ -41,8 +41,18 @@ struct CdiIterator {
   //The status information for reading/advancing is added in the subclasses.
 };
 
-void baseIterConstruct(CdiIterator* me, int filetype);
-const char* baseIter_constructFromString(CdiIterator* me, const char* description);     //Returns a pointer past the end of the parsed portion of the description string.
-void baseIterDestruct(CdiIterator* me);
+void baseIterConstruct(CdiIterator *me, int filetype);
+const char* baseIter_constructFromString(CdiIterator *me, const char *description);     //Returns a pointer past the end of the parsed portion of the description string.
+void baseIterDestruct(CdiIterator *me);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/iterator_fallback.c b/libcdi/src/iterator_fallback.c
index be0b6cf..74177ba 100644
--- a/libcdi/src/iterator_fallback.c
+++ b/libcdi/src/iterator_fallback.c
@@ -3,18 +3,34 @@
 #include "cdi.h"
 #include "cdi_int.h"
 #include "dmemory.h"
-#include "proprietarySystemWorkarounds.h"
 #include "vlist.h"      //Required for vlist_t, which we require because there is no safe function available to access a variable name.
 
 #include <assert.h>
+#include <limits.h>
 #include <stdlib.h>
 
+struct CdiFallbackIterator {
+  CdiIterator super;
+  int streamId, vlistId;
+  char *path;   //needed for clone() & serialize()
+
+  int variableCount, curVariable;
+  int curLevelCount, curLevel;
+  int curTimestep;
+};
+
+CdiIterator *cdiFallbackIterator_getSuper(CdiFallbackIterator *me)
+{
+  return &me->super;
+}
+
+
 //For more information on the condestruct() pattern, see comment in src/iterator_grib.c
-static CdiFallbackIterator* cdiFallbackIterator_condestruct(CdiFallbackIterator* me, const char* path, int filetype)
+static CdiFallbackIterator *cdiFallbackIterator_condestruct(CdiFallbackIterator *me, const char *path, int filetype)
 {
   if(me) goto destruct;
 
-  me = xmalloc(sizeof(*me));
+  me = (CdiFallbackIterator *) Malloc(sizeof(*me));
   baseIterConstruct(&me->super, filetype);
 
   me->streamId = streamOpenRead(path);
@@ -30,7 +46,7 @@ static CdiFallbackIterator* cdiFallbackIterator_condestruct(CdiFallbackIterator*
   if(streamInqTimestep(me->streamId, me->curTimestep) <= 0) goto closeStream;
   me->curVariable = 0;
   me->curLevel = -1;
-  me->path = myStrDup(path);
+  me->path = strdup(path);
   if(!me->path) goto closeStream;
 
   return me;
@@ -40,22 +56,22 @@ static CdiFallbackIterator* cdiFallbackIterator_condestruct(CdiFallbackIterator*
 // v destructor/error-cleanup code  v
 
 destruct:
-  free(me->path);
+  Free(me->path);
 closeStream:
   streamClose(me->streamId);
 destructSuper:
   baseIterDestruct(&me->super);
-  free(me);
+  Free(me);
   return NULL;
 }
 
-CdiIterator* cdiFallbackIterator_new(const char* path, int filetype)
+CdiIterator *cdiFallbackIterator_new(const char *path, int filetype)
 {
   return &cdiFallbackIterator_condestruct(NULL, path, filetype)->super;
 }
 
 //Fetches the info that is published by the variables in the base class from the current field.
-static void fetchSuperInfo(CdiFallbackIterator* me)
+static void fetchSuperInfo(CdiFallbackIterator *me)
 {
   me->super.datatype = vlistInqVarDatatype(me->vlistId, me->curVariable);
   me->super.timesteptype = vlistInqVarTsteptype(me->vlistId, me->curVariable);
@@ -64,12 +80,12 @@ static void fetchSuperInfo(CdiFallbackIterator* me)
   cdiDecodeParam(param, &me->super.param.number, &me->super.param.category, &me->super.param.discipline);
 }
 
-CdiFallbackIterator* cdiFallbackIterator_clone(CdiIterator* super)
+CdiFallbackIterator *cdiFallbackIterator_clone(CdiIterator *super)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
 
   //Make another stream for this file. This yields an unadvanced iterator.
-  CdiFallbackIterator* clone = cdiFallbackIterator_condestruct(NULL, me->path, me->super.filetype);
+  CdiFallbackIterator *clone = cdiFallbackIterator_condestruct(NULL, me->path, me->super.filetype);
   if(!clone) return NULL;
 
   //Point the clone to the same position in the file.
@@ -85,19 +101,21 @@ CdiFallbackIterator* cdiFallbackIterator_clone(CdiIterator* super)
   return clone;
 }
 
-char* cdiFallbackIterator_serialize(CdiIterator* super)
+char *cdiFallbackIterator_serialize(CdiIterator *super)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
 
-  char* escapedPath = cdiEscapeSpaces(me->path);
-  char* result = myAsprintf("%s %d %d %d %d %d", escapedPath, me->variableCount, me->curVariable, me->curLevelCount, me->curLevel, me->curTimestep);
-  free(escapedPath);
+  char *escapedPath = cdiEscapeSpaces(me->path);
+  char *result = (char *) Malloc(strlen(escapedPath)
+                         + 5 * (3 * sizeof (int) * CHAR_BIT / 8 + 1) + 1);
+  sprintf(result, "%s %d %d %d %d %d", escapedPath, me->variableCount, me->curVariable, me->curLevelCount, me->curLevel, me->curTimestep);
+  Free(escapedPath);
   return result;
 }
 
-CdiFallbackIterator* cdiFallbackIterator_deserialize(const char* description)
+CdiFallbackIterator *cdiFallbackIterator_deserialize(const char *description)
 {
-  CdiFallbackIterator* me = xmalloc(sizeof(*me));
+  CdiFallbackIterator *me = (CdiFallbackIterator *) Malloc(sizeof(*me));
   if(!me) goto fail;
 
   description = baseIter_constructFromString(&me->super, description);
@@ -112,9 +130,9 @@ CdiFallbackIterator* cdiFallbackIterator_deserialize(const char* description)
   if(me->vlistId == CDI_UNDEFID) goto closeStream;
 
   //This reads one variable from the description string, does error checking, and advances the given string pointer.
-  #define decodeValue(variable, description) do \
+#define decodeValue(variable, description) do \
     { \
-      const char* savedStart = description; \
+      const char *savedStart = description; \
       long long decodedValue = strtoll(description, (char**)&description, 0);   /*The cast is a workaround for the wrong signature of strtoll().*/ \
       variable = (int)decodedValue; \
       if(savedStart == description) goto closeStream; \
@@ -125,7 +143,7 @@ CdiFallbackIterator* cdiFallbackIterator_deserialize(const char* description)
   decodeValue(me->curLevelCount, description);
   decodeValue(me->curLevel, description);
   decodeValue(me->curTimestep, description);
-  #undef decodeValue
+#undef decodeValue
 
   if(streamInqTimestep(me->streamId, me->curTimestep) <= 0) goto closeStream;
   if(me->super.isAdvanced) fetchSuperInfo(me);
@@ -135,15 +153,15 @@ CdiFallbackIterator* cdiFallbackIterator_deserialize(const char* description)
 closeStream:
   streamClose(me->streamId);
 freePath:
-  free(me->path);
+  Free(me->path);
 destructSuper:
   baseIterDestruct(&me->super);
-  free(me);
+  Free(me);
 fail:
   return NULL;
 }
 
-static int advance(CdiFallbackIterator* me)
+static int advance(CdiFallbackIterator *me)
 {
   me->curLevel++;
   if(me->curLevel == me->curLevelCount)
@@ -160,9 +178,9 @@ static int advance(CdiFallbackIterator* me)
   return CDI_NOERR;
 }
 
-int cdiFallbackIterator_nextField(CdiIterator* super)
+int cdiFallbackIterator_nextField(CdiIterator *super)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   int result = advance(me);
   if(result) return result;
 
@@ -174,9 +192,9 @@ int cdiFallbackIterator_nextField(CdiIterator* super)
   return CDI_NOERR;
 }
 
-char* cdiFallbackIterator_inqTime(CdiIterator* super, bool getEndTime)
+char *cdiFallbackIterator_inqTime(CdiIterator *super, bool getEndTime)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator *)(void *)super;
   if(getEndTime) return NULL;   //The stream interface does not export the start/end times of statistical fields, so we treat all data as point of time data, returning the validity time as the start time.
   int taxisId = vlistInqTaxis(me->vlistId);
   int date = taxisInqVdate(taxisId);
@@ -184,20 +202,24 @@ char* cdiFallbackIterator_inqTime(CdiIterator* super, bool getEndTime)
   int year, month, day, hour, minute, second;
   cdiDecodeDate(date, &year, &month, &day);
   cdiDecodeTime(time, &hour, &minute, &second);
-  return myAsprintf("%04d-%02d-%02dT%02d:%02d:%02d.000", year, month, day, hour, minute, second);
+  char *result
+    = (char *) Malloc(   4+1 +2+1 +2+1 +2+1 +2+1 +2+4+1);
+  sprintf(result,     "%04d-%02d-%02dT%02d:%02d:%02d.000", year, month, day, hour, minute, second);
+  return result;
 }
 
-int cdiFallbackIterator_levelType(CdiIterator* super, int levelSelector, char** outName, char** outLongName, char** outStdName, char** outUnit)
+int cdiFallbackIterator_levelType(CdiIterator *super, int levelSelector, char **outName, char **outLongName, char **outStdName, char **outUnit)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   int zaxisId = vlistInqVarZaxis(me->vlistId, me->curVariable);
-  #define copyString(outPointer, function) do \
+  (void)levelSelector;
+#define copyString(outPointer, function) do \
     { \
       if(outPointer) \
         { \
           char tempBuffer[CDI_MAX_NAME]; \
           function(zaxisId, tempBuffer); \
-          *outPointer = myStrDup(tempBuffer); \
+          *outPointer = strdup(tempBuffer); \
         } \
     } \
   while(0)
@@ -205,13 +227,13 @@ int cdiFallbackIterator_levelType(CdiIterator* super, int levelSelector, char**
   copyString(outLongName, zaxisInqLongname);    //FIXME: zaxisInqLongname is unsafe.
   copyString(outStdName, zaxisInqStdname);    //FIXME: zaxisInqStdname is unsafe.
   copyString(outUnit, zaxisInqUnits);    //FIXME: zaxisInqUnits is unsafe.
-  #undef copyString
+#undef copyString
   return zaxisInqLtype(zaxisId);
 }
 
-int cdiFallbackIterator_level(CdiIterator* super, int levelSelector, double* outValue1, double* outValue2)
+int cdiFallbackIterator_level(CdiIterator *super, int levelSelector, double *outValue1, double *outValue2)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   int zaxisId = vlistInqVarZaxis(me->vlistId, me->curVariable);
 
   //handle NULL pointers once and for all
@@ -238,48 +260,58 @@ int cdiFallbackIterator_level(CdiIterator* super, int levelSelector, double* out
   ssize_t intLevel = (ssize_t)(2**outValue1);
   if(0 <= intLevel && intLevel < zaxisInqVctSize(zaxisId) - 1)
     {
-      const double* coordinateTable = zaxisInqVctPtr(zaxisId);
+      const double *coordinateTable = zaxisInqVctPtr(zaxisId);
       *outValue1 = coordinateTable[intLevel];
       *outValue2 = coordinateTable[intLevel + 1];
     }
   return CDI_NOERR;
 }
 
-int cdiFallbackIterator_zaxisUuid(CdiIterator* super, int* outVgridNumber, int* outLevelCount, unsigned char (*outUuid)[16])
+int cdiFallbackIterator_zaxisUuid(CdiIterator *super, int *outVgridNumber, int *outLevelCount, unsigned char outUuid[CDI_UUID_SIZE])
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   int zaxisId = vlistInqVarZaxis(me->vlistId, me->curVariable);
   if(zaxisInqLtype(zaxisId) != ZAXIS_HYBRID) return CDI_EINVAL;
   if(outVgridNumber) *outVgridNumber = zaxisInqNumber(zaxisId);
   if(outLevelCount) *outLevelCount = zaxisInqNlevRef(zaxisId);
-  if(outUuid) zaxisInqUUID(zaxisId, *outUuid);
+  if(outUuid) zaxisInqUUID(zaxisId, outUuid);
   return CDI_NOERR;
 }
 
-char* cdiFallbackIterator_copyVariableName(CdiIterator* super)
+char *cdiFallbackIterator_copyVariableName(CdiIterator *super)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   return vlistCopyVarName(me->vlistId, me->curVariable);
 }
 
-void cdiFallbackIterator_readField(CdiIterator* super, double* buffer, size_t* nmiss)
+void cdiFallbackIterator_readField(CdiIterator *super, double *buffer, size_t *nmiss)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   int missingValues = 0;
   streamReadVarSlice(me->streamId, me->curVariable, me->curLevel, buffer, &missingValues);
-  if(nmiss) *nmiss = missingValues;
+  if(nmiss) *nmiss = (size_t)missingValues;
 }
 
-void cdiFallbackIterator_readFieldF(CdiIterator* super, float* buffer, size_t* nmiss)
+void cdiFallbackIterator_readFieldF(CdiIterator *super, float *buffer, size_t *nmiss)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   int missingValues = 0;
   streamReadVarSliceF(me->streamId, me->curVariable, me->curLevel, buffer, &missingValues);
-  if(nmiss) *nmiss = missingValues;
+  if(nmiss) *nmiss = (size_t)missingValues;
 }
 
-void cdiFallbackIterator_delete(CdiIterator* super)
+void cdiFallbackIterator_delete(CdiIterator *super)
 {
-  CdiFallbackIterator* me = (CdiFallbackIterator*)super;
+  CdiFallbackIterator *me = (CdiFallbackIterator*)(void *)super;
   cdiFallbackIterator_condestruct(me, NULL, 0);
 }
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/iterator_fallback.h b/libcdi/src/iterator_fallback.h
index 1128746..aee5ae9 100644
--- a/libcdi/src/iterator_fallback.h
+++ b/libcdi/src/iterator_fallback.h
@@ -8,34 +8,38 @@
 #ifndef INCLUDE_GUARD_CDI_ITERATOR_FALLBACK_H
 #define INCLUDE_GUARD_CDI_ITERATOR_FALLBACK_H
 
+#include "cdi.h"
 #include "iterator.h"
 
-typedef struct CdiFallbackIterator {
-  CdiIterator super;
-  int streamId, vlistId;
-  char* path;   //needed for clone() & serialize()
+typedef struct CdiFallbackIterator CdiFallbackIterator;
 
-  int variableCount, curVariable;
-  int curLevelCount, curLevel;
-  int curTimestep;
-} CdiFallbackIterator;
+CdiIterator *cdiFallbackIterator_new(const char *path, int filetype);
+CdiFallbackIterator *cdiFallbackIterator_clone(CdiIterator *me);
+CdiIterator *cdiFallbackIterator_getSuper(CdiFallbackIterator *me);
+char *cdiFallbackIterator_serialize(CdiIterator *me);
+CdiFallbackIterator *cdiFallbackIterator_deserialize(const char *me);
 
-CdiIterator* cdiFallbackIterator_new(const char* path, int filetype);
-CdiFallbackIterator* cdiFallbackIterator_clone(CdiIterator* me);
-char* cdiFallbackIterator_serialize(CdiIterator* me);
-CdiFallbackIterator* cdiFallbackIterator_deserialize(const char* me);
+int cdiFallbackIterator_nextField(CdiIterator *me);
 
-int cdiFallbackIterator_nextField(CdiIterator* me);
+char *cdiFallbackIterator_inqTime(CdiIterator *me, bool getEndTime);
+int cdiFallbackIterator_levelType(CdiIterator *me, int levelSelector, char **outName, char **outLongName, char **outStdName, char **outUnit);
+int cdiFallbackIterator_level(CdiIterator *me, int levelSelector, double *outValue1, double *outValue2);
+int cdiFallbackIterator_zaxisUuid(CdiIterator *me, int *outVgridNumber, int *outLevelCount, unsigned char outUuid[CDI_UUID_SIZE]);
+char *cdiFallbackIterator_copyVariableName(CdiIterator *me);
 
-char* cdiFallbackIterator_inqTime(CdiIterator* me, bool getEndTime);
-int cdiFallbackIterator_levelType(CdiIterator* me, int levelSelector, char** outName, char** outLongName, char** outStdName, char** outUnit);
-int cdiFallbackIterator_level(CdiIterator* me, int levelSelector, double* outValue1, double* outValue2);
-int cdiFallbackIterator_zaxisUuid(CdiIterator* me, int* outVgridNumber, int* outLevelCount, unsigned char (*outUuid)[16]);
-char* cdiFallbackIterator_copyVariableName(CdiIterator* me);
+void cdiFallbackIterator_readField(CdiIterator *me, double *buffer, size_t *nmiss);
+void cdiFallbackIterator_readFieldF(CdiIterator *me, float *buffer, size_t *nmiss);
 
-void cdiFallbackIterator_readField(CdiIterator* me, double* buffer, size_t* nmiss);
-void cdiFallbackIterator_readFieldF(CdiIterator* me, float* buffer, size_t* nmiss);
-
-void cdiFallbackIterator_delete(CdiIterator* super);
+void cdiFallbackIterator_delete(CdiIterator *super);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/iterator_grib.c b/libcdi/src/iterator_grib.c
index 02daeca..7dd6ba1 100644
--- a/libcdi/src/iterator_grib.c
+++ b/libcdi/src/iterator_grib.c
@@ -1,32 +1,52 @@
 #include "iterator_grib.h"
 
+#include "cdi.h"
 #include "cdi_int.h"
 #include "cgribex.h"
 #include "dmemory.h"
 #include "error.h"
 #include "gribapi.h"
 #include "gribapi_utilities.h"
-#include "proprietarySystemWorkarounds.h"
 #include "stream_grb.h"
 #include "zaxis.h"
 
 #include <assert.h>
+#include <limits.h>
 #include <stdlib.h>
 #include <string.h>
 
 
 #ifdef HAVE_LIBGRIB_API
 
+struct CdiGribIterator {
+  CdiIterator super;
+
+  CdiInputFile* file;
+  off_t fileOffset;
+  unsigned char* gribBuffer;
+  size_t bufferSize, curRecordSize;
+#ifdef HAVE_LIBGRIB_API
+  grib_handle* gribHandle;
+#else
+  void* gribHandle;
+#endif
+};
+
+CdiIterator *cdiGribIterator_getSuper(CdiGribIterator *me)
+{
+  return &me->super;
+}
+
 //Since the error handling in constructors is usually very closely related to the workings of a destructor,
 //this function combines both functions in one, using a centralized exit.
 //The mode of operation depends on whether me is a NULL pointer on entry:
 //If it is NULL, a new object is allocated and constructed, which is returned if construction is successful.
 //If a non-NULL pointer is passed in, the object is destructed and NULL is returned. In this case, the other arguments are ignored.
-static CdiGribIterator* cdiGribIterator_condestruct(CdiGribIterator* me, const char* path, int filetype)
+static CdiGribIterator *cdiGribIterator_condestruct(CdiGribIterator *me, const char *path, int filetype)
 {
-  #define super() (&me->super)
+#define super() (&me->super)
   if(me) goto destruct;
-  me = xmalloc(sizeof(*me));
+  me = (CdiGribIterator *) Malloc(sizeof(*me));
   baseIterConstruct(super(), filetype);
 
   me->file = cdiInputFile_make(path);
@@ -45,43 +65,42 @@ static CdiGribIterator* cdiGribIterator_condestruct(CdiGribIterator* me, const c
 
 destruct:
   if(me->super.gridId != CDI_UNDEFID) gridDestroy(me->super.gridId);
-  if(me->gribHandle) grib_handle_delete(me->gribHandle);
-  free(me->gribBuffer);
+  if(me->gribHandle) grib_handle_delete((struct grib_handle *)me->gribHandle);
+  Free(me->gribBuffer);
   cdiRefObject_release(&me->file->super);
 destructSuper:
   baseIterDestruct(super());
-  free(me);
+  Free(me);
   me = NULL;
 
 success:
   return me;
-  #undef super
+#undef super
 }
 
-CdiIterator* cdiGribIterator_new(const char* path, int filetype)
+CdiIterator *cdiGribIterator_new(const char *path, int filetype)
 {
   return &cdiGribIterator_condestruct(NULL, path, filetype)->super;
 }
 
-CdiGribIterator* cdiGribIterator_makeClone(CdiIterator* super)
+CdiGribIterator *cdiGribIterator_makeClone(CdiIterator *super)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
 
   //Allocate memory and copy data. (operations that may fail)
-  CdiGribIterator* result = xmalloc(sizeof(*result));
+  CdiGribIterator* result = (struct CdiGribIterator *) Malloc(sizeof(*result));
   if(!result) goto fail;
-  *result = (CdiGribIterator)
-    {
-      .file = me->file,
-      .fileOffset = me->fileOffset,
-      .gribBuffer = NULL,
-      .bufferSize = me->bufferSize,
-      .curRecordSize = me->curRecordSize,
-      .gribHandle = NULL
-    };
+
+  result->file = me->file;
+  result->fileOffset = me->fileOffset;
+  result->gribBuffer = NULL;
+  result->bufferSize = me->bufferSize;
+  result->curRecordSize = me->curRecordSize;
+  result->gribHandle = NULL;
+
   if(me->gribBuffer)
     {
-      result->gribBuffer = xmalloc(me->bufferSize);
+      result->gribBuffer = (unsigned char *) Malloc(me->bufferSize);
       if(!result->gribBuffer) goto freeResult;
       memcpy(result->gribBuffer, me->gribBuffer, me->curRecordSize);
     }
@@ -109,30 +128,30 @@ CdiGribIterator* cdiGribIterator_makeClone(CdiIterator* super)
 deleteGribHandle:
   if(result->gribHandle) grib_handle_delete(result->gribHandle);
 freeBuffer:
-  free(result->gribBuffer);
+  Free(result->gribBuffer);
 freeResult:
-  free(result);
+  Free(result);
 fail:
   return NULL;
 }
 
-char* cdiGribIterator_serialize(CdiIterator* super)
+char *cdiGribIterator_serialize(CdiIterator *super)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
 
-  char* path = cdiInputFile_copyPath(me->file);
+  const char* path = cdiInputFile_getPath(me->file);
   char* escapedPath = cdiEscapeSpaces(path);
-  free(path);
-  char* result = myAsprintf("%s %zu", escapedPath, me->fileOffset);
-  free(escapedPath);
+  char* result = (char *) Malloc(strlen(escapedPath) + 3 * sizeof(int) * CHAR_BIT/8);
+  sprintf(result, "%s %zu", escapedPath, me->fileOffset);
+  Free(escapedPath);
   return result;
 }
 
 
-CdiGribIterator* cdiGribIterator_deserialize(const char* description)
+CdiGribIterator *cdiGribIterator_deserialize(const char *description)
 {
   char* path;
-  CdiGribIterator* me = xmalloc(sizeof(*me));
+  CdiGribIterator* me = (CdiGribIterator *) Malloc(sizeof(*me));
   if(!me) goto fail;
 
   description = baseIter_constructFromString(&me->super, description);
@@ -142,11 +161,11 @@ CdiGribIterator* cdiGribIterator_deserialize(const char* description)
   if(!path) goto destructSuper;
 
   me->file = cdiInputFile_make(path);
-  free(path);
+  Free(path);
   if(!me->file) goto destructSuper;
 
   {
-    const char* savedStart = description;
+    const char *savedStart = description;
     long long decodedOffset = strtoll(description, (char**)&description, 0);    //The cast is a workaround for the wrong signature of strtoll() (it should have been `long long strtoll(const char*, const char**, int)`, not `long long strtoll(const char*, char**, int)`.
     me->fileOffset = (off_t)decodedOffset;
     if(savedStart == description) goto closeFile;
@@ -166,20 +185,18 @@ closeFile:
   cdiRefObject_release(&me->file->super);
 destructSuper:
   baseIterDestruct(&me->super);
-  free(me);
+  Free(me);
 fail:
   return NULL;
 }
-#endif
 
-#ifdef HAVE_LIBGRIB_API
-static void cdiGribIterator_ensureBuffer(CdiGribIterator* me, size_t requiredSize)
+static void cdiGribIterator_ensureBuffer(CdiGribIterator *me, size_t requiredSize)
 {
   if(me->bufferSize < requiredSize)
     {
       me->bufferSize *= 2;
       if(me->bufferSize < requiredSize) me->bufferSize = requiredSize;
-      me->gribBuffer = xrealloc(me->gribBuffer, me->bufferSize);
+      me->gribBuffer = (unsigned char *) Realloc(me->gribBuffer, me->bufferSize);
     }
 }
 
@@ -195,11 +212,11 @@ static bool isGrib1DualLevel(int levelType)
     }
 }
 
-static const unsigned char* positionOfGribMarker(const unsigned char* data, size_t size)
+static const unsigned char *positionOfGribMarker(const unsigned char *data, size_t size)
 {
-  for(const unsigned char* currentPosition = data, *end = data + size; currentPosition < end; currentPosition++)
+  for(const unsigned char *currentPosition = data, *end = data + size; currentPosition < end; currentPosition++)
     {
-      currentPosition = memchr(currentPosition, 'G', size - (currentPosition - data) - 3);      //-3 to ensure that we don't overrun the buffer during the strncmp() call.
+      currentPosition = (unsigned char *)memchr(currentPosition, 'G', size - (size_t)(currentPosition - data) - 3);      //-3 to ensure that we don't overrun the buffer during the strncmp() call.
       if(!currentPosition) return NULL;
       if(!strncmp((const char*)currentPosition, "GRIB", 4)) return currentPosition;
     }
@@ -208,7 +225,7 @@ static const unsigned char* positionOfGribMarker(const unsigned char* data, size
 
 //This clobbers the contents of the gribBuffer!
 //Returns the file offset of the next 'GRIB' marker.
-static ssize_t scanToGribMarker(CdiGribIterator* me)
+static ssize_t scanToGribMarker(CdiGribIterator *me)
 {
   cdiGribIterator_ensureBuffer(me, 8*1024);
   const size_t kMaxScanSize = 16*1024*1024;
@@ -218,39 +235,39 @@ static ssize_t scanToGribMarker(CdiGribIterator* me)
       scanSize = me->bufferSize;
       if(scannedBytes + scanSize > kMaxScanSize) scanSize = kMaxScanSize - scannedBytes;
       assert(scanSize <= me->bufferSize);
-      int status = cdiInputFile_read(me->file, me->fileOffset + scannedBytes, scanSize, &scanSize, me->gribBuffer);
+      int status = cdiInputFile_read(me->file, me->fileOffset + (off_t)scannedBytes, scanSize, &scanSize, me->gribBuffer);
       if(status != CDI_NOERR && status != CDI_EEOF) return status;
 
-      const unsigned char* startPosition = positionOfGribMarker(me->gribBuffer, scanSize);
+      const unsigned char *startPosition = positionOfGribMarker(me->gribBuffer, scanSize);
       if(startPosition)
         {
-          return me->fileOffset + scannedBytes + (startPosition - me->gribBuffer);
+          return (ssize_t)(me->fileOffset + (off_t)scannedBytes + (off_t)(startPosition - me->gribBuffer));
         }
 
       //Get the offset for the next iteration if there is a next iteration.
       scanSize -= 3;        //so that we won't miss a 'GRIB' sequence that happens to be cut off
       scannedBytes += scanSize;
-      scannedBytes &= ~0xf; //make 16 bytes aligned
+      scannedBytes &= ~(size_t)0xf; //make 16 bytes aligned
     }
   return -1;
 }
 
-static unsigned decode24(void* beData)
+static unsigned decode24(void *beData)
 {
-  unsigned char* bytes = beData;
+  unsigned char* bytes = (unsigned char *)beData;
   return ((unsigned)bytes[0] << 16) + ((unsigned)bytes[1] << 8) + (unsigned)bytes[2];
 }
 
-static uint64_t decode64(void* beData)
+static uint64_t decode64(void *beData)
 {
-  unsigned char* bytes = beData;
+  unsigned char* bytes = (unsigned char *)beData;
   uint64_t result = 0;
   for(size_t i = 0; i < 8; i++) result = (result << 8) + bytes[i];
   return result;
 }
 
 //Determine the size of the GRIB record that begins at the given file offset.
-static int getRecordSize(CdiGribIterator* me, off_t gribFileOffset, size_t* outRecordSize)
+static int getRecordSize(CdiGribIterator *me, off_t gribFileOffset, size_t *outRecordSize)
 {
   char buffer[16];
   size_t readSize;
@@ -282,9 +299,9 @@ static int getRecordSize(CdiGribIterator* me, off_t gribFileOffset, size_t* outR
 }
 
 #if 0
-static void hexdump(void* data, size_t size)
+static void hexdump(void *data, size_t size)
 {
-  unsigned char* charData = data;
+  unsigned char *charData = data;
   for(size_t offset = 0; offset < size; )
     {
       printf("%016zx:", offset);
@@ -301,11 +318,11 @@ static void hexdump(void* data, size_t size)
 
 //Read a record into memory and wrap it in a grib_handle.
 //XXX: I have omitted checking for szip compression as it is done in grbReadVarDP() & friends since that appears to be a non-standard extension of the GRIB1 standard: bit 1 in octet 14 of the binary data section which is used to signal szip compressio is defined to be reserved in the standard. As such, it seems prudent not to support this and to encourage people with such szip compressed files to switch to the GRIB2/JPEG2000 format. However, in the case that this reasoning is wrong, this [...]
-static int readMessage(CdiGribIterator* me)
+static int readMessage(CdiGribIterator *me)
 {
   //Destroy the old grib_handle.
   if(me->gribHandle) grib_handle_delete(me->gribHandle), me->gribHandle = NULL;
-  me->fileOffset += me->curRecordSize;
+  me->fileOffset += (off_t)me->curRecordSize;
 
   //Find the next record and determine its size.
   ssize_t gribFileOffset = scanToGribMarker(me);
@@ -329,9 +346,9 @@ fail:
   return result;
 }
 
-int cdiGribIterator_nextField(CdiIterator* super)
+int cdiGribIterator_nextField(CdiIterator *super)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
 
   if(super->gridId != CDI_UNDEFID) gridDestroy(super->gridId), super->gridId = CDI_UNDEFID;
 
@@ -350,15 +367,15 @@ int cdiGribIterator_nextField(CdiIterator* super)
   return CDI_NOERR;
 }
 
-char* cdiGribIterator_inqTime(CdiIterator* super, bool getEndTime)
+char *cdiGribIterator_inqTime(CdiIterator *super, bool getEndTime)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
   return gribMakeTimeString(me->gribHandle, getEndTime);
 }
 
-int cdiGribIterator_levelType(CdiIterator* super, int levelSelector, char** outName, char** outLongName, char** outStdName, char** outUnit)
+int cdiGribIterator_levelType(CdiIterator *super, int levelSelector, char **outName, char **outLongName, char **outStdName, char **outUnit)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
 
   //First determine the zaxis type corresponding to the given level.
   int zaxisType = ZAXIS_GENERIC;
@@ -375,12 +392,12 @@ int cdiGribIterator_levelType(CdiIterator* super, int levelSelector, char** outN
     }
 
   //Then lookup the requested names.
-  const char* name, *longName, *stdName, *unit;
+  const char *name, *longName, *stdName, *unit;
   zaxisGetTypeDescription(zaxisType, NULL, &name, &longName, &stdName, &unit);
-  if(outName) *outName = myStrDup(name);
-  if(outLongName) *outLongName = myStrDup(longName);
-  if(outStdName) *outStdName = myStrDup(stdName);
-  if(outUnit) *outUnit = myStrDup(unit);
+  if(outName) *outName = strdup(name);
+  if(outLongName) *outLongName = strdup(longName);
+  if(outStdName) *outStdName = strdup(stdName);
+  if(outUnit) *outUnit = strdup(unit);
 
   return zaxisType;
 }
@@ -394,18 +411,18 @@ static double logicalLevelValue2(long gribType, long storedValue, long power)
       case GRIB2_LTYPE_LANDDEPTH:
       case GRIB2_LTYPE_ISOBARIC:
       case GRIB2_LTYPE_SIGMA:
-        return storedValue*(1000/factor);      //The evaluation order allows the factors of ten to cancel out before rounding.
+        return (double)storedValue * (1000.0/factor);      //The evaluation order allows the factors of ten to cancel out before rounding.
 
       case 255:
         return 0;
 
       default:
-        return storedValue/factor;
+        return (double)storedValue/factor;
     }
 }
 
 //The output values must be preinitialized, this function does not always write them.
-static int readLevel2(grib_handle* gribHandle, const char* levelTypeKey, const char* powerKey, const char* valueKey, double* outValue1, double* outValue2)
+static int readLevel2(grib_handle *gribHandle, const char *levelTypeKey, const char *powerKey, const char *valueKey, double *outValue1, double *outValue2)
 {
   assert(levelTypeKey && powerKey && valueKey && outValue1 && outValue2);
 
@@ -426,8 +443,8 @@ static int readLevel2(grib_handle* gribHandle, const char* levelTypeKey, const c
           int status;
           //XXX: I'm not 100% sure about how the coordinate pairs are stored in the file.
           //     I'm assuming an array of pairs due to the example code in grib_api-1.12.3/examples/F90/set_pv.f90, but that may be wrong.
-          if((status = grib_get_double_element(gribHandle, "pv", value*2    , outValue1))) return status;
-          if((status = grib_get_double_element(gribHandle, "pv", value*2 + 1, outValue2))) return status;
+          if((status = grib_get_double_element(gribHandle, "pv", (int)value*2    , outValue1))) return status;
+          if((status = grib_get_double_element(gribHandle, "pv", (int)value*2 + 1, outValue2))) return status;
           break;
         }
 
@@ -442,9 +459,9 @@ static int readLevel2(grib_handle* gribHandle, const char* levelTypeKey, const c
   return CDI_NOERR;
 }
 
-int cdiGribIterator_level(CdiIterator* super, int levelSelector, double* outValue1, double* outValue2)
+int cdiGribIterator_level(CdiIterator *super, int levelSelector, double *outValue1, double *outValue2)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
   double trash;
   if(!outValue1) outValue1 = &trash;
   if(!outValue2) outValue2 = &trash;
@@ -466,25 +483,25 @@ int cdiGribIterator_level(CdiIterator* super, int levelSelector, double* outValu
       long levelType = (uint8_t)gribGetLongDefault(me->gribHandle, "indicatorOfTypeOfLevel", -1);    //1 byte
       if(levelType == 255)
         {}
-      else if(isGrib1DualLevel(levelType))
+      else if(isGrib1DualLevel((int)levelType))
         {
-          *outValue1 = gribGetLongDefault(me->gribHandle, (levelSelector ? "bottomLevel" : "topLevel"), 0);
+          *outValue1 = (double)gribGetLongDefault(me->gribHandle, (levelSelector ? "bottomLevel" : "topLevel"), 0);
         }
       else if(levelType == 100)
         {
-          *outValue1 = 100*gribGetLongDefault(me->gribHandle, "level", 0);        //2 bytes
+          *outValue1 = 100 * (double)gribGetLongDefault(me->gribHandle, "level", 0);        //2 bytes
         }
       else
         {
-          *outValue1 = gribGetLongDefault(me->gribHandle, "level", 0);        //2 bytes
+          *outValue1 = (double)gribGetLongDefault(me->gribHandle, "level", 0);        //2 bytes
         }
     }
   return CDI_NOERR;
 }
 
-int cdiGribIterator_zaxisUuid(CdiIterator* super, int* outVgridNumber, int* outLevelCount, unsigned char (*outUuid)[16])
+int cdiGribIterator_zaxisUuid(CdiIterator *super, int *outVgridNumber, int *outLevelCount, unsigned char outUuid[CDI_UUID_SIZE])
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
 
   if(outVgridNumber)
     {
@@ -500,57 +517,64 @@ int cdiGribIterator_zaxisUuid(CdiIterator* super, int* outVgridNumber, int* outL
     }
   if(outUuid)
     {
-      size_t size = sizeof(*outUuid);
-      if(grib_get_bytes(me->gribHandle, "uuidOfVGrid", *outUuid, &size)) return CDI_EINVAL;
-      if(size != sizeof(*outUuid)) return CDI_EUFSTRUCT;
+      size_t size = CDI_UUID_SIZE;
+      if(grib_get_bytes(me->gribHandle, "uuidOfVGrid", outUuid, &size)) return CDI_EINVAL;
+      if(size != CDI_UUID_SIZE) return CDI_EUFSTRUCT;
     }
 
   return CDI_NOERR;
 }
 
-char* cdiGribIterator_copyVariableName(CdiIterator* super)
+char *cdiGribIterator_copyVariableName(CdiIterator *super)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
   return gribCopyString(me->gribHandle, "shortName");
 }
 
-void cdiGribIterator_readField(CdiIterator* super, double* buffer, size_t* nmiss)
+void cdiGribIterator_readField(CdiIterator *super, double *buffer, size_t *nmiss)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
 
+  GRIB_CHECK(my_grib_set_double(me->gribHandle, "missingValue", cdiDefaultMissval), 0);
   gribGetDoubleArray(me->gribHandle, "values", buffer);
   long gridType = gribGetLong(me->gribHandle, "gridDefinitionTemplateNumber");
   if(nmiss)
     {
-      *nmiss = (gridType >= 50 && gridType <= 53) ? 0 : (int)gribGetLong(me->gribHandle, "numberOfMissing");        //The condition excludes harmonic data.
+      *nmiss = (gridType >= 50 && gridType <= 53) ? (size_t)0 : (size_t)gribGetLong(me->gribHandle, "numberOfMissing");        //The condition excludes harmonic data.
     }
 }
 
-void cdiGribIterator_readFieldF(CdiIterator* super, float* buffer, size_t* nmiss)
+void cdiGribIterator_readFieldF(CdiIterator *super, float *buffer, size_t *nmiss)
 {
-  CdiGribIterator* me = (CdiGribIterator*)super;
+  CdiGribIterator *me = (CdiGribIterator*)super;
 
   size_t valueCount = gribGetArraySize(me->gribHandle, "values");
-  double* temp = malloc(valueCount*sizeof(*temp));
+  double* temp = (double *) Malloc(valueCount*sizeof(*temp));
   cdiGribIterator_readField(super, temp, nmiss);
-  for(size_t i = valueCount; i--; ) buffer[i] = temp[i];
-  free(temp);
+  for(size_t i = valueCount; i--; ) buffer[i] = (float)temp[i];
+  Free(temp);
 }
+#endif
 
-/**
+/*
 @Function cdiGribIterator_delete
 @Title Dispose off a CdiGribIterator instance.
 
- at Prototype void cdiGribIterator_delete(CdiGribIterator* me)
+ at Prototype void cdiGribIterator_delete(CdiGribIterator *me)
 @Parameter
     @item me The iterator to delete.
 
 @Description
     Combined destructor and deallocator. Make sure to match every call to cdiGribIterator_clone() with a call to this function.
 */
-void cdiGribIterator_delete(CdiGribIterator* me)
+void cdiGribIterator_delete(CdiGribIterator *me)
 {
+#ifdef HAVE_LIBGRIB_API
   if(me) cdiGribIterator_condestruct(me, NULL, 0);
+#else
+  (void)me;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
 
@@ -558,11 +582,11 @@ void cdiGribIterator_delete(CdiGribIterator* me)
 // callthroughs to provide direct access to the grib keys //////////////////////////////////////////
 ////////////////////////////////////////////////////////////////////////////////////////////////////
 
-/**
+/*
 @Function cdiGribIterator_inqEdition
 @Title Get the version of the GRIB standard that is used
 
- at Prototype int cdiGribIterator_inqEdition(CdiGribIterator* me)
+ at Prototype int cdiGribIterator_inqEdition(CdiGribIterator *me)
 @Parameter
     @item me The iterator to operate on.
 
@@ -571,16 +595,21 @@ void cdiGribIterator_delete(CdiGribIterator* me)
 @Description
     Returns the version of the file format.
 */
-int cdiGribIterator_inqEdition(CdiGribIterator* me)
+int cdiGribIterator_inqEdition(CdiGribIterator *me)
 {
-  return gribEditionNumber(me->gribHandle);
+#ifdef HAVE_LIBGRIB_API
+  return (int)gribEditionNumber(me->gribHandle);
+#else
+  (void)me;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_getLong
 @Title Access to grib_get_long()
 
- at Prototype int cdiGribIterator_getLong(CdiGribIterator* me, const char* key, long* result)
+ at Prototype int cdiGribIterator_getLong(CdiGribIterator *me, const char *key, long *result)
 @Parameter
     @item me The iterator to operate on.
     @item ... The arguments to the underlying GRIB-API function.
@@ -590,16 +619,23 @@ int cdiGribIterator_inqEdition(CdiGribIterator* me)
 @Description
     Callthrough to grib_get_long().
 */
-int cdiGribIterator_getLong(CdiGribIterator* me, const char* key, long* result)
+int cdiGribIterator_getLong(CdiGribIterator *me, const char *key, long *result)
 {
+#ifdef HAVE_LIBGRIB_API
   return grib_get_long(me->gribHandle, key, result);
+#else
+  (void)me;
+  (void)key;
+  (void)result;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_getLength
 @Title Access to grib_get_length()
 
- at Prototype int cdiGribIterator_getLength(CdiGribIterator* me, const char* key, size_t* result)
+ at Prototype int cdiGribIterator_getLength(CdiGribIterator *me, const char *key, size_t *result)
 @Parameter
     @item me The iterator to operate on.
     @item ... The arguments to the underlying GRIB-API function.
@@ -609,16 +645,29 @@ int cdiGribIterator_getLong(CdiGribIterator* me, const char* key, long* result)
 @Description
     Callthrough to grib_get_length().
 */
-int cdiGribIterator_getLength(CdiGribIterator* me, const char* key, size_t* result)
+int cdiGribIterator_getLength(CdiGribIterator *me, const char *key, size_t *result)
 {
+#ifdef HAVE_GRIB_GET_LENGTH
   return grib_get_length(me->gribHandle, key, result);
+#elif defined(HAVE_LIBGRIB_API)
+  (void)me;
+  (void)key;
+  (void)result;
+  Error("grib_get_length() is not available, so cdiGribIterator_getLength() can't be used");
+  return -1;
+#else
+  (void)me;
+  (void)key;
+  (void)result;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_getString
 @Title Access to grib_get_string()
 
- at Prototype int cdiGribIterator_getString(CdiGribIterator* me, const char* key, char* result, size_t* length)
+ at Prototype int cdiGribIterator_getString(CdiGribIterator *me, const char *key, char *result, size_t *length)
 @Parameter
     @item me The iterator to operate on.
     @item ... The arguments to the underlying GRIB-API function.
@@ -628,16 +677,24 @@ int cdiGribIterator_getLength(CdiGribIterator* me, const char* key, size_t* resu
 @Description
     Callthrough to grib_get_string().
 */
-int cdiGribIterator_getString(CdiGribIterator* me, const char* key, char* result, size_t* length)
+int cdiGribIterator_getString(CdiGribIterator *me, const char *key, char *result, size_t *length)
 {
+#ifdef HAVE_LIBGRIB_API
   return grib_get_string(me->gribHandle, key, result, length);
+#else
+  (void)me;
+  (void)key;
+  (void)result;
+  (void)length;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_inqLongValue
 @Title Get the value of a GRIB-API key as a long
 
- at Prototype long cdiGribIterator_inqLongValue(CdiGribIterator* me, const char* key)
+ at Prototype long cdiGribIterator_inqLongValue(CdiGribIterator *me, const char *key)
 @Parameter
     @item me The iterator to operate on.
     @item key The GRIB-API key to retrieve.
@@ -648,16 +705,22 @@ int cdiGribIterator_getString(CdiGribIterator* me, const char* key, char* result
     Use this to fetch a grib value if you are certain that the given key must be present.
     This will abort the process if the key cannot be retrieved.
 */
-long cdiGribIterator_inqLongValue(CdiGribIterator* me, const char* key)
+long cdiGribIterator_inqLongValue(CdiGribIterator *me, const char *key)
 {
+#ifdef HAVE_LIBGRIB_API
   return gribGetLong(me->gribHandle, key);
+#else
+  (void)me;
+  (void)key;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_inqLongDefaultValue
 @Title Get the value of a GRIB-API key as a long
 
- at Prototype long cdiGribIterator_inqLongDefaultValue(CdiGribIterator* me, const char* key, long defaultValue)
+ at Prototype long cdiGribIterator_inqLongDefaultValue(CdiGribIterator *me, const char *key, long defaultValue)
 @Parameter
     @item me The iterator to operate on.
     @item key The GRIB-API key to retrieve.
@@ -669,16 +732,23 @@ long cdiGribIterator_inqLongValue(CdiGribIterator* me, const char* key)
     Use this if you can handle failure to fetch the key by supplying a default value.
     This function cannot fail.
 */
-long cdiGribIterator_inqLongDefaultValue(CdiGribIterator* me, const char* key, long defaultValue)
+long cdiGribIterator_inqLongDefaultValue(CdiGribIterator *me, const char *key, long defaultValue)
 {
+#ifdef HAVE_LIBGRIB_API
   return gribGetLongDefault(me->gribHandle, key, defaultValue);
+#else
+  (void)me;
+  (void)key;
+  (void)defaultValue;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_inqStringValue
 @Title Safely retrieve a GRIB-API key with a string value
 
- at Prototype char* cdiGribIterator_inqStringValue(CdiGribIterator* me, const char* key)
+ at Prototype char *cdiGribIterator_inqStringValue(CdiGribIterator *me, const char *key)
 @Parameter
     @item me The iterator to operate on.
     @item key The GRIB-API key to retrieve.
@@ -690,16 +760,22 @@ long cdiGribIterator_inqLongDefaultValue(CdiGribIterator* me, const char* key, l
     allocate memory accordingly, call grib_get_string(), and return the pointer to the new string.
     Returns NULL on failure.
 */
-char* cdiGribIterator_inqStringValue(CdiGribIterator* me, const char* key)
+char *cdiGribIterator_inqStringValue(CdiGribIterator *me, const char *key)
 {
+#ifdef HAVE_LIBGRIB_API
   return gribCopyString(me->gribHandle, key);
+#else
+  (void)me;
+  (void)key;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_getDouble
 @Title Access to grib_get_double()
 
- at Prototype int cdiGribIterator_getDouble(CdiGribIterator* me, const char* key, double* result)
+ at Prototype int cdiGribIterator_getDouble(CdiGribIterator *me, const char *key, double *result)
 @Parameter
     @item me The iterator to operate on.
     @item ... The arguments to the underlying GRIB-API function.
@@ -709,16 +785,23 @@ char* cdiGribIterator_inqStringValue(CdiGribIterator* me, const char* key)
 @Description
     Callthrough to grib_get_double().
 */
-int cdiGribIterator_getDouble(CdiGribIterator* me, const char* key, double* result)
+int cdiGribIterator_getDouble(CdiGribIterator *me, const char *key, double *result)
 {
+#ifdef HAVE_LIBGRIB_API
   return grib_get_double(me->gribHandle, key, result);
+#else
+  (void)me;
+  (void)key;
+  (void)result;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_getSize
 @Title Access to grib_get_size()
 
- at Prototype int cdiGribIterator_getSize(CdiGribIterator* me, const char* key, size_t* result)
+ at Prototype int cdiGribIterator_getSize(CdiGribIterator *me, const char *key, size_t *result)
 @Parameter
     @item me The iterator to operate on.
     @item ... The arguments to the underlying GRIB-API function.
@@ -728,16 +811,23 @@ int cdiGribIterator_getDouble(CdiGribIterator* me, const char* key, double* resu
 @Description
     Callthrough to grib_get_size().
 */
-int cdiGribIterator_getSize(CdiGribIterator* me, const char* key, size_t* result)
+int cdiGribIterator_getSize(CdiGribIterator *me, const char *key, size_t *result)
 {
+#ifdef HAVE_LIBGRIB_API
   return grib_get_size(me->gribHandle, key, result);
+#else
+  (void)me;
+  (void)key;
+  (void)result;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_getLongArray
 @Title Access to grib_get_long_array()
 
- at Prototype int cdiGribIterator_getLongArray(CdiGribIterator* me, const char* key, long* result, size_t* size)
+ at Prototype int cdiGribIterator_getLongArray(CdiGribIterator *me, const char *key, long *result, size_t *size)
 @Parameter
     @item me The iterator to operate on.
     @item ... The arguments to the underlying GRIB-API function.
@@ -747,16 +837,24 @@ int cdiGribIterator_getSize(CdiGribIterator* me, const char* key, size_t* result
 @Description
     Callthrough to grib_get_long_array().
 */
-int cdiGribIterator_getLongArray(CdiGribIterator* me, const char* key, long* result, size_t* size)
+int cdiGribIterator_getLongArray(CdiGribIterator *me, const char *key, long *result, size_t *size)
 {
+#ifdef HAVE_LIBGRIB_API
   return grib_get_long_array(me->gribHandle, key, result, size);
+#else
+  (void)me;
+  (void)key;
+  (void)result;
+  (void)size;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_getDoubleArray
 @Title Access to grib_get_double_array()
 
- at Prototype int cdiGribIterator_getDoubleArray(CdiGribIterator* me, const char* key, double* result, size_t* size)
+ at Prototype int cdiGribIterator_getDoubleArray(CdiGribIterator *me, const char *key, double *result, size_t *size)
 @Parameter
     @item me The iterator to operate on.
     @item ... The arguments to the underlying GRIB-API function.
@@ -766,16 +864,24 @@ int cdiGribIterator_getLongArray(CdiGribIterator* me, const char* key, long* res
 @Description
     Callthrough to grib_get_double_array().
 */
-int cdiGribIterator_getDoubleArray(CdiGribIterator* me, const char* key, double* result, size_t* size)
+int cdiGribIterator_getDoubleArray(CdiGribIterator *me, const char *key, double *result, size_t *size)
 {
+#ifdef HAVE_LIBGRIB_API
   return grib_get_double_array(me->gribHandle, key, result, size);
+#else
+  (void)me;
+  (void)key;
+  (void)result;
+  (void)size;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_inqDoubleValue
 @Title Get the value of a GRIB-API key as a double
 
- at Prototype double cdiGribIterator_inqDoubleValue(CdiGribIterator* me, const char* key)
+ at Prototype double cdiGribIterator_inqDoubleValue(CdiGribIterator *me, const char *key)
 @Parameter
     @item me The iterator to operate on.
     @item key The GRIB-API key to retrieve.
@@ -786,16 +892,22 @@ int cdiGribIterator_getDoubleArray(CdiGribIterator* me, const char* key, double*
     Use this to fetch a grib value if you are certain that the given key must be present.
     This will abort the process if the key cannot be retrieved.
 */
-double cdiGribIterator_inqDoubleValue(CdiGribIterator* me, const char* key)
+double cdiGribIterator_inqDoubleValue(CdiGribIterator *me, const char *key)
 {
+#ifdef HAVE_LIBGRIB_API
   return gribGetDouble(me->gribHandle, key);
+#else
+  (void)me;
+  (void)key;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-/**
+/*
 @Function cdiGribIterator_inqDoubleDefaultValue
 @Title Get the value of a GRIB-API key as a double
 
- at Prototype double cdiGribIterator_inqDoubleDefaultValue(CdiGribIterator* me, const char* key, double defaultValue)
+ at Prototype double cdiGribIterator_inqDoubleDefaultValue(CdiGribIterator *me, const char *key, double defaultValue)
 @Parameter
     @item me The iterator to operate on.
     @item key The GRIB-API key to retrieve.
@@ -807,9 +919,24 @@ double cdiGribIterator_inqDoubleValue(CdiGribIterator* me, const char* key)
     Use this if you can handle failure to fetch the key by supplying a default value.
     This function cannot fail.
 */
-double cdiGribIterator_inqDoubleDefaultValue(CdiGribIterator* me, const char* key, double defaultValue)
+double cdiGribIterator_inqDoubleDefaultValue(CdiGribIterator *me, const char *key, double defaultValue)
 {
+#ifdef HAVE_LIBGRIB_API
   return gribGetDoubleDefault(me->gribHandle, key, defaultValue);
+#else
+  (void)me;
+  (void)key;
+  (void)defaultValue;
+  xabort("CDI was compiled without GribAPI support, so you can't possibly have a valid CdiGribIterator* to call this function with");
+#endif
 }
 
-#endif
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/iterator_grib.h b/libcdi/src/iterator_grib.h
index 2847f72..2b19110 100644
--- a/libcdi/src/iterator_grib.h
+++ b/libcdi/src/iterator_grib.h
@@ -7,6 +7,7 @@
 #ifndef INCLUDE_GUARD_CDI_ITERATOR_GRIB_H
 #define INCLUDE_GUARD_CDI_ITERATOR_GRIB_H
 
+#include "cdi.h"
 #include "iterator.h"
 #include "input_file.h"
 
@@ -15,34 +16,32 @@
 #endif
 
 typedef struct recordList recordList;
-struct CdiGribIterator {
-  CdiIterator super;
 
-  CdiInputFile* file;
-  off_t fileOffset;
-  unsigned char* gribBuffer;
-  size_t bufferSize, curRecordSize;
-#ifdef HAVE_LIBGRIB_API
-  grib_handle* gribHandle;
-#else
-  void* gribHandle;
-#endif
-};
-
-CdiIterator* cdiGribIterator_new(const char* path, int filetype);
-CdiGribIterator* cdiGribIterator_makeClone(CdiIterator* me);
-char* cdiGribIterator_serialize(CdiIterator* me);
-CdiGribIterator* cdiGribIterator_deserialize(const char* me);
+CdiIterator *cdiGribIterator_new(const char *path, int filetype);
+CdiGribIterator *cdiGribIterator_makeClone(CdiIterator *me);
+CdiIterator *cdiGribIterator_getSuper(CdiGribIterator *me);
+char *cdiGribIterator_serialize(CdiIterator *me);
+CdiGribIterator *cdiGribIterator_deserialize(const char *me);
 
-int cdiGribIterator_nextField(CdiIterator* me);
+int cdiGribIterator_nextField(CdiIterator *me);
 
-char* cdiGribIterator_inqTime(CdiIterator* me, bool getEndTime);
-int cdiGribIterator_levelType(CdiIterator* me, int levelSelector, char** outName, char** outLongName, char** outStdName, char** outUnit);
-int cdiGribIterator_level(CdiIterator* me, int levelSelector, double* outValue1, double* outValue2);
-int cdiGribIterator_zaxisUuid(CdiIterator* me, int* outVgridNumber, int* outLevelCount, unsigned char (*outUuid)[16]);
-char* cdiGribIterator_copyVariableName(CdiIterator* me);
+char *cdiGribIterator_inqTime(CdiIterator *me, bool getEndTime);
+int cdiGribIterator_levelType(CdiIterator *me, int levelSelector, char **outName, char **outLongName, char **outStdName, char **outUnit);
+int cdiGribIterator_level(CdiIterator *me, int levelSelector, double *outValue1, double *outValue2);
+int cdiGribIterator_zaxisUuid(CdiIterator *me, int *outVgridNumber, int *outLevelCount, unsigned char outUuid[CDI_UUID_SIZE]);
+char *cdiGribIterator_copyVariableName(CdiIterator *me);
 
-void cdiGribIterator_readField(CdiIterator* me, double* buffer, size_t* nmiss);
-void cdiGribIterator_readFieldF(CdiIterator* me, float* buffer, size_t* nmiss);
+void cdiGribIterator_readField(CdiIterator *me, double *buffer, size_t *nmiss);
+void cdiGribIterator_readFieldF(CdiIterator *me, float *buffer, size_t *nmiss);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/mo_cdi.f90 b/libcdi/src/mo_cdi.f90
index 1036158..02a4b7f 100644
--- a/libcdi/src/mo_cdi.f90
+++ b/libcdi/src/mo_cdi.f90
@@ -3,7916 +3,6228 @@
 ! Generated by "../../../../libcdi/interfaces/f2003/bindGen.rb" from input file "../../../../libcdi/src/cdi.h".
 
 module mo_cdi
-	use iso_c_binding
-	implicit none
-	private
-
-	public ctrim
-	public c_len
-
-	interface
-		integer(c_size_t) function lib_strlen(charPtr) bind(c, name = "strlen")
-			import c_size_t, c_ptr
-			type(c_ptr), value :: charPtr
-		end function lib_strlen
-
-		subroutine lib_free(pointer) bind(c, name = "free")
-			import c_ptr
-			type(c_ptr), value :: pointer
-		end subroutine lib_free
-	end interface
-
-	integer(c_int), public, parameter :: CDI_MAX_NAME = 256
-	integer(c_int), public, parameter :: CDI_UNDEFID = -1
-	integer(c_int), public, parameter :: CDI_GLOBAL = -1
-	integer(c_int), public, parameter :: CDI_BIGENDIAN = 0
-	integer(c_int), public, parameter :: CDI_LITTLEENDIAN = 1
-	integer(c_int), public, parameter :: CDI_REAL = 1
-	integer(c_int), public, parameter :: CDI_COMP = 2
-	integer(c_int), public, parameter :: CDI_BOTH = 3
-	integer(c_int), public, parameter :: CDI_NOERR = 0
-	integer(c_int), public, parameter :: CDI_EEOF = -1
-	integer(c_int), public, parameter :: CDI_ESYSTEM = -10
-	integer(c_int), public, parameter :: CDI_EINVAL = -20
-	integer(c_int), public, parameter :: CDI_EUFTYPE = -21
-	integer(c_int), public, parameter :: CDI_ELIBNAVAIL = -22
-	integer(c_int), public, parameter :: CDI_EUFSTRUCT = -23
-	integer(c_int), public, parameter :: CDI_EUNC4 = -24
-	integer(c_int), public, parameter :: CDI_ELIMIT = -99
-	integer(c_int), public, parameter :: FILETYPE_UNDEF = -1
-	integer(c_int), public, parameter :: FILETYPE_GRB = 1
-	integer(c_int), public, parameter :: FILETYPE_GRB2 = 2
-	integer(c_int), public, parameter :: FILETYPE_NC = 3
-	integer(c_int), public, parameter :: FILETYPE_NC2 = 4
-	integer(c_int), public, parameter :: FILETYPE_NC4 = 5
-	integer(c_int), public, parameter :: FILETYPE_NC4C = 6
-	integer(c_int), public, parameter :: FILETYPE_SRV = 7
-	integer(c_int), public, parameter :: FILETYPE_EXT = 8
-	integer(c_int), public, parameter :: FILETYPE_IEG = 9
-	integer(c_int), public, parameter :: COMPRESS_NONE = 0
-	integer(c_int), public, parameter :: COMPRESS_SZIP = 1
-	integer(c_int), public, parameter :: COMPRESS_GZIP = 2
-	integer(c_int), public, parameter :: COMPRESS_BZIP2 = 3
-	integer(c_int), public, parameter :: COMPRESS_ZIP = 4
-	integer(c_int), public, parameter :: COMPRESS_JPEG = 5
-	integer(c_int), public, parameter :: DATATYPE_PACK = 0
-	integer(c_int), public, parameter :: DATATYPE_PACK1 = 1
-	integer(c_int), public, parameter :: DATATYPE_PACK2 = 2
-	integer(c_int), public, parameter :: DATATYPE_PACK3 = 3
-	integer(c_int), public, parameter :: DATATYPE_PACK4 = 4
-	integer(c_int), public, parameter :: DATATYPE_PACK5 = 5
-	integer(c_int), public, parameter :: DATATYPE_PACK6 = 6
-	integer(c_int), public, parameter :: DATATYPE_PACK7 = 7
-	integer(c_int), public, parameter :: DATATYPE_PACK8 = 8
-	integer(c_int), public, parameter :: DATATYPE_PACK9 = 9
-	integer(c_int), public, parameter :: DATATYPE_PACK10 = 10
-	integer(c_int), public, parameter :: DATATYPE_PACK11 = 11
-	integer(c_int), public, parameter :: DATATYPE_PACK12 = 12
-	integer(c_int), public, parameter :: DATATYPE_PACK13 = 13
-	integer(c_int), public, parameter :: DATATYPE_PACK14 = 14
-	integer(c_int), public, parameter :: DATATYPE_PACK15 = 15
-	integer(c_int), public, parameter :: DATATYPE_PACK16 = 16
-	integer(c_int), public, parameter :: DATATYPE_PACK17 = 17
-	integer(c_int), public, parameter :: DATATYPE_PACK18 = 18
-	integer(c_int), public, parameter :: DATATYPE_PACK19 = 19
-	integer(c_int), public, parameter :: DATATYPE_PACK20 = 20
-	integer(c_int), public, parameter :: DATATYPE_PACK21 = 21
-	integer(c_int), public, parameter :: DATATYPE_PACK22 = 22
-	integer(c_int), public, parameter :: DATATYPE_PACK23 = 23
-	integer(c_int), public, parameter :: DATATYPE_PACK24 = 24
-	integer(c_int), public, parameter :: DATATYPE_PACK25 = 25
-	integer(c_int), public, parameter :: DATATYPE_PACK26 = 26
-	integer(c_int), public, parameter :: DATATYPE_PACK27 = 27
-	integer(c_int), public, parameter :: DATATYPE_PACK28 = 28
-	integer(c_int), public, parameter :: DATATYPE_PACK29 = 29
-	integer(c_int), public, parameter :: DATATYPE_PACK30 = 30
-	integer(c_int), public, parameter :: DATATYPE_PACK31 = 31
-	integer(c_int), public, parameter :: DATATYPE_PACK32 = 32
-	integer(c_int), public, parameter :: DATATYPE_CPX32 = 64
-	integer(c_int), public, parameter :: DATATYPE_CPX64 = 128
-	integer(c_int), public, parameter :: DATATYPE_FLT32 = 132
-	integer(c_int), public, parameter :: DATATYPE_FLT64 = 164
-	integer(c_int), public, parameter :: DATATYPE_INT8 = 208
-	integer(c_int), public, parameter :: DATATYPE_INT16 = 216
-	integer(c_int), public, parameter :: DATATYPE_INT32 = 232
-	integer(c_int), public, parameter :: DATATYPE_UINT8 = 308
-	integer(c_int), public, parameter :: DATATYPE_UINT16 = 316
-	integer(c_int), public, parameter :: DATATYPE_UINT32 = 332
-	integer(c_int), public, parameter :: DATATYPE_INT = 251
-	integer(c_int), public, parameter :: DATATYPE_FLT = 252
-	integer(c_int), public, parameter :: DATATYPE_TXT = 253
-	integer(c_int), public, parameter :: DATATYPE_CPX = 254
-	integer(c_int), public, parameter :: DATATYPE_UCHAR = 255
-	integer(c_int), public, parameter :: DATATYPE_LONG = 256
-	integer(c_int), public, parameter :: CHUNK_AUTO = 1
-	integer(c_int), public, parameter :: CHUNK_GRID = 2
-	integer(c_int), public, parameter :: CHUNK_LINES = 3
-	integer(c_int), public, parameter :: GRID_GENERIC = 1
-	integer(c_int), public, parameter :: GRID_GAUSSIAN = 2
-	integer(c_int), public, parameter :: GRID_GAUSSIAN_REDUCED = 3
-	integer(c_int), public, parameter :: GRID_LONLAT = 4
-	integer(c_int), public, parameter :: GRID_SPECTRAL = 5
-	integer(c_int), public, parameter :: GRID_FOURIER = 6
-	integer(c_int), public, parameter :: GRID_GME = 7
-	integer(c_int), public, parameter :: GRID_TRAJECTORY = 8
-	integer(c_int), public, parameter :: GRID_UNSTRUCTURED = 9
-	integer(c_int), public, parameter :: GRID_CURVILINEAR = 10
-	integer(c_int), public, parameter :: GRID_LCC = 11
-	integer(c_int), public, parameter :: GRID_LCC2 = 12
-	integer(c_int), public, parameter :: GRID_LAEA = 13
-	integer(c_int), public, parameter :: GRID_SINUSOIDAL = 14
-	integer(c_int), public, parameter :: GRID_PROJECTION = 15
-	integer(c_int), public, parameter :: ZAXIS_SURFACE = 0
-	integer(c_int), public, parameter :: ZAXIS_GENERIC = 1
-	integer(c_int), public, parameter :: ZAXIS_HYBRID = 2
-	integer(c_int), public, parameter :: ZAXIS_HYBRID_HALF = 3
-	integer(c_int), public, parameter :: ZAXIS_PRESSURE = 4
-	integer(c_int), public, parameter :: ZAXIS_HEIGHT = 5
-	integer(c_int), public, parameter :: ZAXIS_DEPTH_BELOW_SEA = 6
-	integer(c_int), public, parameter :: ZAXIS_DEPTH_BELOW_LAND = 7
-	integer(c_int), public, parameter :: ZAXIS_ISENTROPIC = 8
-	integer(c_int), public, parameter :: ZAXIS_TRAJECTORY = 9
-	integer(c_int), public, parameter :: ZAXIS_ALTITUDE = 10
-	integer(c_int), public, parameter :: ZAXIS_SIGMA = 11
-	integer(c_int), public, parameter :: ZAXIS_MEANSEA = 12
-	integer(c_int), public, parameter :: ZAXIS_TOA = 13
-	integer(c_int), public, parameter :: ZAXIS_SEA_BOTTOM = 14
-	integer(c_int), public, parameter :: ZAXIS_ATMOSPHERE = 15
-	integer(c_int), public, parameter :: ZAXIS_CLOUD_BASE = 16
-	integer(c_int), public, parameter :: ZAXIS_CLOUD_TOP = 17
-	integer(c_int), public, parameter :: ZAXIS_ISOTHERM_ZERO = 18
-	integer(c_int), public, parameter :: ZAXIS_SNOW = 19
-	integer(c_int), public, parameter :: ZAXIS_LAKE_BOTTOM = 20
-	integer(c_int), public, parameter :: ZAXIS_SEDIMENT_BOTTOM = 21
-	integer(c_int), public, parameter :: ZAXIS_SEDIMENT_BOTTOM_TA = 22
-	integer(c_int), public, parameter :: ZAXIS_SEDIMENT_BOTTOM_TW = 23
-	integer(c_int), public, parameter :: ZAXIS_MIX_LAYER = 24
-	integer(c_int), public, parameter :: ZAXIS_REFERENCE = 25
-	integer(c_int), public, parameter :: TIME_CONSTANT = 0
-	integer(c_int), public, parameter :: TIME_VARIABLE = 1
-	integer(c_int), public, parameter :: TSTEP_CONSTANT = 0
-	integer(c_int), public, parameter :: TSTEP_INSTANT = 1
-	integer(c_int), public, parameter :: TSTEP_AVG = 2
-	integer(c_int), public, parameter :: TSTEP_ACCUM = 3
-	integer(c_int), public, parameter :: TSTEP_MAX = 4
-	integer(c_int), public, parameter :: TSTEP_MIN = 5
-	integer(c_int), public, parameter :: TSTEP_DIFF = 6
-	integer(c_int), public, parameter :: TSTEP_RMS = 7
-	integer(c_int), public, parameter :: TSTEP_SD = 8
-	integer(c_int), public, parameter :: TSTEP_COV = 9
-	integer(c_int), public, parameter :: TSTEP_RATIO = 10
-	integer(c_int), public, parameter :: TSTEP_RANGE = 11
-	integer(c_int), public, parameter :: TSTEP_INSTANT2 = 12
-	integer(c_int), public, parameter :: TSTEP_INSTANT3 = 13
-	integer(c_int), public, parameter :: TAXIS_ABSOLUTE = 1
-	integer(c_int), public, parameter :: TAXIS_RELATIVE = 2
-	integer(c_int), public, parameter :: TAXIS_FORECAST = 3
-	integer(c_int), public, parameter :: TUNIT_SECOND = 1
-	integer(c_int), public, parameter :: TUNIT_MINUTE = 2
-	integer(c_int), public, parameter :: TUNIT_QUARTER = 3
-	integer(c_int), public, parameter :: TUNIT_30MINUTES = 4
-	integer(c_int), public, parameter :: TUNIT_HOUR = 5
-	integer(c_int), public, parameter :: TUNIT_3HOURS = 6
-	integer(c_int), public, parameter :: TUNIT_6HOURS = 7
-	integer(c_int), public, parameter :: TUNIT_12HOURS = 8
-	integer(c_int), public, parameter :: TUNIT_DAY = 9
-	integer(c_int), public, parameter :: TUNIT_MONTH = 10
-	integer(c_int), public, parameter :: TUNIT_YEAR = 11
-	integer(c_int), public, parameter :: CALENDAR_STANDARD = 0
-	integer(c_int), public, parameter :: CALENDAR_PROLEPTIC = 1
-	integer(c_int), public, parameter :: CALENDAR_360DAYS = 2
-	integer(c_int), public, parameter :: CALENDAR_365DAYS = 3
-	integer(c_int), public, parameter :: CALENDAR_366DAYS = 4
-	integer(c_int), public, parameter :: CALENDAR_NONE = 5
-	integer(c_int), public, parameter :: CDI_UUID_SIZE = 16
-
-	public t_CdiParam
-	type, bind(c) :: t_CdiParam
-		integer(c_int) :: discipline
-		integer(c_int) :: category
-		integer(c_int) :: number
-	end type t_CdiParam
-
-	public t_CdiIterator
-	type t_CdiIterator
-		type(c_ptr) :: ptr
-	end type t_CdiIterator
-
-	public t_CdiGribIterator
-	type t_CdiGribIterator
-		type(c_ptr) :: ptr
-	end type t_CdiGribIterator
-	public cdiReset
-	public cdiStringError
-	public cdiDebug
-	public cdiLibraryVersion
-	public cdiPrintVersion
-	public cdiHaveFiletype
-	public cdiDefMissval
-	public cdiInqMissval
-	public cdiDefGlobal
-	public namespaceNew
-	public namespaceSetActive
-	public namespaceDelete
-	public cdiParamToString
-	public cdiDecodeParam
-	public cdiEncodeParam
-	public cdiDecodeDate
-	public cdiEncodeDate
-	public cdiDecodeTime
-	public cdiEncodeTime
-	public cdiGetFiletype
-	public streamOpenRead
-	public streamOpenWrite
-	public streamOpenAppend
-	public streamClose
-	public streamSync
-	public streamDefVlist
-	public streamInqVlist
-	public streamInqVlistIDorig
-	public streamInqFiletype
-	public streamDefByteorder
-	public streamInqByteorder
-	public streamDefCompType
-	public streamInqCompType
-	public streamDefCompLevel
-	public streamInqCompLevel
-	public streamDefTimestep
-	public streamInqTimestep
-	public streamInqCurTimestepID
-	public streamFilename
-	public streamFilesuffix
-	public streamInqNvars
-	public streamWriteVar
-	public streamWriteVarF
-	public streamReadVar
-	public streamReadVarF
-	public streamWriteVarSlice
-	public streamWriteVarSliceF
-	public streamReadVarSlice
-	public streamReadVarSliceF
-	public streamWriteVarChunk
-	public streamDefRecord
-	public streamInqRecord
-	public streamWriteRecord
-	public streamWriteRecordF
-	public streamReadRecord
-	public streamCopyRecord
-	public cdiIterator_new
-	public cdiIterator_clone
-	public cdiIterator_serialize
-	public cdiIterator_deserialize
-	public cdiIterator_delete
-	public cdiIterator_nextField
-	public cdiIterator_inqStartTime
-	public cdiIterator_inqEndTime
-	public cdiIterator_inqVTime
-	public cdiIterator_inqLevelType
-	public cdiIterator_inqLevel
-	public cdiIterator_inqLevelUuid
-	public cdiIterator_inqParam
-	public cdiIterator_inqDatatype
-	public cdiIterator_inqTsteptype
-	public cdiIterator_inqVariableName
-	public cdiIterator_inqGridId
-	public cdiIterator_readField
-	public cdiIterator_readFieldF
-	public cdiGribIterator_clone
-	public cdiGribIterator_delete
-	public cdiGribIterator_getLong
-	public cdiGribIterator_getDouble
-	public cdiGribIterator_getLength
-	public cdiGribIterator_getString
-	public cdiGribIterator_getSize
-	public cdiGribIterator_getLongArray
-	public cdiGribIterator_getDoubleArray
-	public cdiGribIterator_inqEdition
-	public cdiGribIterator_inqLongValue
-	public cdiGribIterator_inqLongDefaultValue
-	public cdiGribIterator_inqDoubleValue
-	public cdiGribIterator_inqDoubleDefaultValue
-	public cdiGribIterator_inqStringValue
-	public vlistCreate
-	public vlistDestroy
-	public vlistDuplicate
-	public vlistCopy
-	public vlistCopyFlag
-	public vlistClearFlag
-	public vlistCat
-	public vlistMerge
-	public vlistPrint
-	public vlistNumber
-	public vlistNvars
-	public vlistNgrids
-	public vlistNzaxis
-	public vlistDefNtsteps
-	public vlistNtsteps
-	public vlistGridsizeMax
-	public vlistGrid
-	public vlistGridIndex
-	public vlistChangeGridIndex
-	public vlistChangeGrid
-	public vlistZaxis
-	public vlistZaxisIndex
-	public vlistChangeZaxisIndex
-	public vlistChangeZaxis
-	public vlistNrecs
-	public vlistDefTaxis
-	public vlistInqTaxis
-	public vlistDefTable
-	public vlistInqTable
-	public vlistDefInstitut
-	public vlistInqInstitut
-	public vlistDefModel
-	public vlistInqModel
-	public vlistDefVar
-	public vlistChangeVarGrid
-	public vlistChangeVarZaxis
-	public vlistInqVar
-	public vlistInqVarGrid
-	public vlistInqVarZaxis
-	public vlistInqVarID
-	public vlistDefVarTsteptype
-	public vlistInqVarTsteptype
-	public vlistDefVarCompType
-	public vlistInqVarCompType
-	public vlistDefVarCompLevel
-	public vlistInqVarCompLevel
-	public vlistDefVarParam
-	public vlistInqVarParam
-	public vlistDefVarCode
-	public vlistInqVarCode
-	public vlistDefVarDatatype
-	public vlistInqVarDatatype
-	public vlistDefVarChunkType
-	public vlistInqVarChunkType
-	public vlistDefVarXYZ
-	public vlistInqVarXYZ
-	public vlistInqVarNumber
-	public vlistDefVarInstitut
-	public vlistInqVarInstitut
-	public vlistDefVarModel
-	public vlistInqVarModel
-	public vlistDefVarTable
-	public vlistInqVarTable
-	public vlistDefVarName
-	public vlistInqVarName
-	public vlistCopyVarName
-	public vlistDefVarStdname
-	public vlistInqVarStdname
-	public vlistDefVarLongname
-	public vlistInqVarLongname
-	public vlistDefVarUnits
-	public vlistInqVarUnits
-	public vlistDefVarMissval
-	public vlistInqVarMissval
-	public vlistDefVarExtra
-	public vlistInqVarExtra
-	public vlistDefVarScalefactor
-	public vlistInqVarScalefactor
-	public vlistDefVarAddoffset
-	public vlistInqVarAddoffset
-	public vlistDefVarTimave
-	public vlistInqVarTimave
-	public vlistDefVarTimaccu
-	public vlistInqVarTimaccu
-	public vlistDefVarTypeOfGeneratingProcess
-	public vlistInqVarTypeOfGeneratingProcess
-	public vlistDefVarProductDefinitionTemplate
-	public vlistInqVarProductDefinitionTemplate
-	public vlistInqVarSize
-	public vlistDefIndex
-	public vlistInqIndex
-	public vlistDefFlag
-	public vlistInqFlag
-	public vlistFindVar
-	public vlistFindLevel
-	public vlistMergedVar
-	public vlistMergedLevel
-	public vlistDefVarEnsemble
-	public vlistInqVarEnsemble
-	public cdiClearAdditionalKeys
-	public cdiDefAdditionalKey
-	public vlistDefVarIntKey
-	public vlistDefVarDblKey
-	public vlistHasVarKey
-	public vlistInqVarDblKey
-	public vlistInqVarIntKey
-	public vlistInqNatts
-	public vlistInqAtt
-	public vlistDelAtt
-	public vlistDefAttInt
-	public vlistDefAttFlt
-	public vlistDefAttTxt
-	public vlistInqAttInt
-	public vlistInqAttFlt
-	public vlistInqAttTxt
-	public gridName
-	public gridNamePtr
-	public gridCompress
-	public gridDefMaskGME
-	public gridInqMaskGME
-	public gridDefMask
-	public gridInqMask
-	public gridPrint
-	public gridCreate
-	public gridDestroy
-	public gridDuplicate
-	public gridInqType
-	public gridInqSize
-	public gridDefXsize
-	public gridInqXsize
-	public gridDefYsize
-	public gridInqYsize
-	public gridDefNP
-	public gridInqNP
-	public gridDefXvals
-	public gridInqXvals
-	public gridDefYvals
-	public gridInqYvals
-	public gridDefXname
-	public gridInqXname
-	public gridDefXlongname
-	public gridInqXlongname
-	public gridDefXunits
-	public gridInqXunits
-	public gridDefYname
-	public gridInqYname
-	public gridDefYlongname
-	public gridInqYlongname
-	public gridDefYunits
-	public gridInqYunits
-	public gridInqXstdname
-	public gridInqYstdname
-	public gridDefPrec
-	public gridInqPrec
-	public gridInqXval
-	public gridInqYval
-	public gridInqXinc
-	public gridInqYinc
-	public gridIsCircular
-	public gridIsRotated
-	public gridDefXpole
-	public gridInqXpole
-	public gridDefYpole
-	public gridInqYpole
-	public gridDefAngle
-	public gridInqAngle
-	public gridInqTrunc
-	public gridDefTrunc
-	public gridDefGMEnd
-	public gridInqGMEnd
-	public gridDefGMEni
-	public gridInqGMEni
-	public gridDefGMEni2
-	public gridInqGMEni2
-	public gridDefGMEni3
-	public gridInqGMEni3
-	public gridDefNumber
-	public gridInqNumber
-	public gridDefPosition
-	public gridInqPosition
-	public gridDefReference
-	public gridInqReference
-	public gridDefUUID
-	public gridInqUUID
-	public gridDefLCC
-	public gridInqLCC
-	public gridDefLcc2
-	public gridInqLcc2
-	public gridDefLaea
-	public gridInqLaea
-	public gridDefArea
-	public gridInqArea
-	public gridHasArea
-	public gridDefNvertex
-	public gridInqNvertex
-	public gridDefXbounds
-	public gridInqXbounds
-	public gridDefYbounds
-	public gridInqYbounds
-	public gridDefRowlon
-	public gridInqRowlon
-	public gridChangeType
-	public gridDefComplexPacking
-	public gridInqComplexPacking
-	public zaxisName
-	public zaxisCreate
-	public zaxisDestroy
-	public zaxisInqType
-	public zaxisInqSize
-	public zaxisDuplicate
-	public zaxisResize
-	public zaxisPrint
-	public zaxisDefLevels
-	public zaxisInqLevels
-	public zaxisDefLevel
-	public zaxisInqLevel
-	public zaxisDefNlevRef
-	public zaxisInqNlevRef
-	public zaxisDefNumber
-	public zaxisInqNumber
-	public zaxisDefUUID
-	public zaxisInqUUID
-	public zaxisDefName
-	public zaxisInqName
-	public zaxisDefLongname
-	public zaxisInqLongname
-	public zaxisDefUnits
-	public zaxisInqUnits
-	public zaxisInqStdname
-	public zaxisDefPrec
-	public zaxisInqPrec
-	public zaxisDefPositive
-	public zaxisInqPositive
-	public zaxisDefLtype
-	public zaxisInqLtype
-	public zaxisInqLevelsPtr
-	public zaxisDefVct
-	public zaxisInqVct
-	public zaxisInqVctSize
-	public zaxisInqVctPtr
-	public zaxisDefLbounds
-	public zaxisInqLbounds
-	public zaxisInqLbound
-	public zaxisDefUbounds
-	public zaxisInqUbounds
-	public zaxisInqUbound
-	public zaxisDefWeights
-	public zaxisInqWeights
-	public zaxisChangeType
-	public taxisCreate
-	public taxisDestroy
-	public taxisDuplicate
-	public taxisCopyTimestep
-	public taxisDefType
-	public taxisDefVdate
-	public taxisDefVtime
-	public taxisInqVdate
-	public taxisInqVtime
-	public taxisDefRdate
-	public taxisDefRtime
-	public taxisInqRdate
-	public taxisInqRtime
-	public taxisDefFdate
-	public taxisDefFtime
-	public taxisInqFdate
-	public taxisInqFtime
-	public taxisHasBounds
-	public taxisDeleteBounds
-	public taxisDefVdateBounds
-	public taxisDefVtimeBounds
-	public taxisInqVdateBounds
-	public taxisInqVtimeBounds
-	public taxisDefCalendar
-	public taxisInqCalendar
-	public taxisDefTunit
-	public taxisInqTunit
-	public taxisDefForecastTunit
-	public taxisInqForecastTunit
-	public taxisDefForecastPeriod
-	public taxisInqForecastPeriod
-	public taxisDefNumavg
-	public taxisInqType
-	public taxisInqNumavg
-	public tunitNamePtr
-	public institutDef
-	public institutInq
-	public institutInqNumber
-	public institutInqCenter
-	public institutInqSubcenter
-	public institutInqNamePtr
-	public institutInqLongnamePtr
-	public modelDef
-	public modelInq
-	public modelInqInstitut
-	public modelInqGribID
-	public modelInqNamePtr
-	public tableWriteC
-	public tableWrite
-	public tableRead
-	public tableDef
-	public tableInqNamePtr
-	public tableDefEntry
-	public tableInq
-	public tableInqNumber
-	public tableInqNum
-	public tableInqModel
-	public tableInqPar
-	public tableInqParCode
-	public tableInqParName
-	public tableInqParLongname
-	public tableInqParUnits
-	public tableInqParNamePtr
-	public tableInqParLongnamePtr
-	public tableInqParUnitsPtr
-	public streamDefHistory
-	public streamInqHistorySize
-	public streamInqHistoryString
-	public gribapiLibraryVersion
+  use iso_c_binding
+  implicit none
+  private
+
+  public ctrim
+  public c_len
+
+  interface
+    integer(c_size_t) function lib_strlen(charPtr) bind(c, name = "strlen")
+      import c_size_t, c_ptr
+      type(c_ptr), value :: charPtr
+    end function lib_strlen
+
+    subroutine lib_free(pointer) bind(c, name = "free")
+      import c_ptr
+      type(c_ptr), value :: pointer
+    end subroutine lib_free
+  end interface
+
+  integer(c_int), public, parameter :: CDI_MAX_NAME = 256
+  integer(c_int), public, parameter :: CDI_UNDEFID = -1
+  integer(c_int), public, parameter :: CDI_GLOBAL = -1
+  integer(c_int), public, parameter :: CDI_BIGENDIAN = 0
+  integer(c_int), public, parameter :: CDI_LITTLEENDIAN = 1
+  integer(c_int), public, parameter :: CDI_PDPENDIAN = 2
+  integer(c_int), public, parameter :: CDI_REAL = 1
+  integer(c_int), public, parameter :: CDI_COMP = 2
+  integer(c_int), public, parameter :: CDI_BOTH = 3
+  integer(c_int), public, parameter :: CDI_NOERR = 0
+  integer(c_int), public, parameter :: CDI_EEOF = -1
+  integer(c_int), public, parameter :: CDI_ESYSTEM = -10
+  integer(c_int), public, parameter :: CDI_EINVAL = -20
+  integer(c_int), public, parameter :: CDI_EUFTYPE = -21
+  integer(c_int), public, parameter :: CDI_ELIBNAVAIL = -22
+  integer(c_int), public, parameter :: CDI_EUFSTRUCT = -23
+  integer(c_int), public, parameter :: CDI_EUNC4 = -24
+  integer(c_int), public, parameter :: CDI_ELIMIT = -99
+  integer(c_int), public, parameter :: FILETYPE_UNDEF = -1
+  integer(c_int), public, parameter :: FILETYPE_GRB = 1
+  integer(c_int), public, parameter :: FILETYPE_GRB2 = 2
+  integer(c_int), public, parameter :: FILETYPE_NC = 3
+  integer(c_int), public, parameter :: FILETYPE_NC2 = 4
+  integer(c_int), public, parameter :: FILETYPE_NC4 = 5
+  integer(c_int), public, parameter :: FILETYPE_NC4C = 6
+  integer(c_int), public, parameter :: FILETYPE_SRV = 7
+  integer(c_int), public, parameter :: FILETYPE_EXT = 8
+  integer(c_int), public, parameter :: FILETYPE_IEG = 9
+  integer(c_int), public, parameter :: COMPRESS_NONE = 0
+  integer(c_int), public, parameter :: COMPRESS_SZIP = 1
+  integer(c_int), public, parameter :: COMPRESS_GZIP = 2
+  integer(c_int), public, parameter :: COMPRESS_BZIP2 = 3
+  integer(c_int), public, parameter :: COMPRESS_ZIP = 4
+  integer(c_int), public, parameter :: COMPRESS_JPEG = 5
+  integer(c_int), public, parameter :: DATATYPE_PACK = 0
+  integer(c_int), public, parameter :: DATATYPE_PACK1 = 1
+  integer(c_int), public, parameter :: DATATYPE_PACK2 = 2
+  integer(c_int), public, parameter :: DATATYPE_PACK3 = 3
+  integer(c_int), public, parameter :: DATATYPE_PACK4 = 4
+  integer(c_int), public, parameter :: DATATYPE_PACK5 = 5
+  integer(c_int), public, parameter :: DATATYPE_PACK6 = 6
+  integer(c_int), public, parameter :: DATATYPE_PACK7 = 7
+  integer(c_int), public, parameter :: DATATYPE_PACK8 = 8
+  integer(c_int), public, parameter :: DATATYPE_PACK9 = 9
+  integer(c_int), public, parameter :: DATATYPE_PACK10 = 10
+  integer(c_int), public, parameter :: DATATYPE_PACK11 = 11
+  integer(c_int), public, parameter :: DATATYPE_PACK12 = 12
+  integer(c_int), public, parameter :: DATATYPE_PACK13 = 13
+  integer(c_int), public, parameter :: DATATYPE_PACK14 = 14
+  integer(c_int), public, parameter :: DATATYPE_PACK15 = 15
+  integer(c_int), public, parameter :: DATATYPE_PACK16 = 16
+  integer(c_int), public, parameter :: DATATYPE_PACK17 = 17
+  integer(c_int), public, parameter :: DATATYPE_PACK18 = 18
+  integer(c_int), public, parameter :: DATATYPE_PACK19 = 19
+  integer(c_int), public, parameter :: DATATYPE_PACK20 = 20
+  integer(c_int), public, parameter :: DATATYPE_PACK21 = 21
+  integer(c_int), public, parameter :: DATATYPE_PACK22 = 22
+  integer(c_int), public, parameter :: DATATYPE_PACK23 = 23
+  integer(c_int), public, parameter :: DATATYPE_PACK24 = 24
+  integer(c_int), public, parameter :: DATATYPE_PACK25 = 25
+  integer(c_int), public, parameter :: DATATYPE_PACK26 = 26
+  integer(c_int), public, parameter :: DATATYPE_PACK27 = 27
+  integer(c_int), public, parameter :: DATATYPE_PACK28 = 28
+  integer(c_int), public, parameter :: DATATYPE_PACK29 = 29
+  integer(c_int), public, parameter :: DATATYPE_PACK30 = 30
+  integer(c_int), public, parameter :: DATATYPE_PACK31 = 31
+  integer(c_int), public, parameter :: DATATYPE_PACK32 = 32
+  integer(c_int), public, parameter :: DATATYPE_CPX32 = 64
+  integer(c_int), public, parameter :: DATATYPE_CPX64 = 128
+  integer(c_int), public, parameter :: DATATYPE_FLT32 = 132
+  integer(c_int), public, parameter :: DATATYPE_FLT64 = 164
+  integer(c_int), public, parameter :: DATATYPE_INT8 = 208
+  integer(c_int), public, parameter :: DATATYPE_INT16 = 216
+  integer(c_int), public, parameter :: DATATYPE_INT32 = 232
+  integer(c_int), public, parameter :: DATATYPE_UINT8 = 308
+  integer(c_int), public, parameter :: DATATYPE_UINT16 = 316
+  integer(c_int), public, parameter :: DATATYPE_UINT32 = 332
+  integer(c_int), public, parameter :: DATATYPE_INT = 251
+  integer(c_int), public, parameter :: DATATYPE_FLT = 252
+  integer(c_int), public, parameter :: DATATYPE_TXT = 253
+  integer(c_int), public, parameter :: DATATYPE_CPX = 254
+  integer(c_int), public, parameter :: DATATYPE_UCHAR = 255
+  integer(c_int), public, parameter :: DATATYPE_LONG = 256
+  integer(c_int), public, parameter :: CHUNK_AUTO = 1
+  integer(c_int), public, parameter :: CHUNK_GRID = 2
+  integer(c_int), public, parameter :: CHUNK_LINES = 3
+  integer(c_int), public, parameter :: GRID_GENERIC = 1
+  integer(c_int), public, parameter :: GRID_GAUSSIAN = 2
+  integer(c_int), public, parameter :: GRID_GAUSSIAN_REDUCED = 3
+  integer(c_int), public, parameter :: GRID_LONLAT = 4
+  integer(c_int), public, parameter :: GRID_SPECTRAL = 5
+  integer(c_int), public, parameter :: GRID_FOURIER = 6
+  integer(c_int), public, parameter :: GRID_GME = 7
+  integer(c_int), public, parameter :: GRID_TRAJECTORY = 8
+  integer(c_int), public, parameter :: GRID_UNSTRUCTURED = 9
+  integer(c_int), public, parameter :: GRID_CURVILINEAR = 10
+  integer(c_int), public, parameter :: GRID_LCC = 11
+  integer(c_int), public, parameter :: GRID_LCC2 = 12
+  integer(c_int), public, parameter :: GRID_LAEA = 13
+  integer(c_int), public, parameter :: GRID_SINUSOIDAL = 14
+  integer(c_int), public, parameter :: GRID_PROJECTION = 15
+  integer(c_int), public, parameter :: ZAXIS_SURFACE = 0
+  integer(c_int), public, parameter :: ZAXIS_GENERIC = 1
+  integer(c_int), public, parameter :: ZAXIS_HYBRID = 2
+  integer(c_int), public, parameter :: ZAXIS_HYBRID_HALF = 3
+  integer(c_int), public, parameter :: ZAXIS_PRESSURE = 4
+  integer(c_int), public, parameter :: ZAXIS_HEIGHT = 5
+  integer(c_int), public, parameter :: ZAXIS_DEPTH_BELOW_SEA = 6
+  integer(c_int), public, parameter :: ZAXIS_DEPTH_BELOW_LAND = 7
+  integer(c_int), public, parameter :: ZAXIS_ISENTROPIC = 8
+  integer(c_int), public, parameter :: ZAXIS_TRAJECTORY = 9
+  integer(c_int), public, parameter :: ZAXIS_ALTITUDE = 10
+  integer(c_int), public, parameter :: ZAXIS_SIGMA = 11
+  integer(c_int), public, parameter :: ZAXIS_MEANSEA = 12
+  integer(c_int), public, parameter :: ZAXIS_TOA = 13
+  integer(c_int), public, parameter :: ZAXIS_SEA_BOTTOM = 14
+  integer(c_int), public, parameter :: ZAXIS_ATMOSPHERE = 15
+  integer(c_int), public, parameter :: ZAXIS_CLOUD_BASE = 16
+  integer(c_int), public, parameter :: ZAXIS_CLOUD_TOP = 17
+  integer(c_int), public, parameter :: ZAXIS_ISOTHERM_ZERO = 18
+  integer(c_int), public, parameter :: ZAXIS_SNOW = 19
+  integer(c_int), public, parameter :: ZAXIS_LAKE_BOTTOM = 20
+  integer(c_int), public, parameter :: ZAXIS_SEDIMENT_BOTTOM = 21
+  integer(c_int), public, parameter :: ZAXIS_SEDIMENT_BOTTOM_TA = 22
+  integer(c_int), public, parameter :: ZAXIS_SEDIMENT_BOTTOM_TW = 23
+  integer(c_int), public, parameter :: ZAXIS_MIX_LAYER = 24
+  integer(c_int), public, parameter :: ZAXIS_REFERENCE = 25
+  integer(c_int), public, parameter :: MAX_KV_PAIRS_MATCH = 10
+  integer(c_int), public, parameter :: TIME_CONSTANT = 0
+  integer(c_int), public, parameter :: TIME_VARIABLE = 1
+  integer(c_int), public, parameter :: TSTEP_CONSTANT = 0
+  integer(c_int), public, parameter :: TSTEP_INSTANT = 1
+  integer(c_int), public, parameter :: TSTEP_AVG = 2
+  integer(c_int), public, parameter :: TSTEP_ACCUM = 3
+  integer(c_int), public, parameter :: TSTEP_MAX = 4
+  integer(c_int), public, parameter :: TSTEP_MIN = 5
+  integer(c_int), public, parameter :: TSTEP_DIFF = 6
+  integer(c_int), public, parameter :: TSTEP_RMS = 7
+  integer(c_int), public, parameter :: TSTEP_SD = 8
+  integer(c_int), public, parameter :: TSTEP_COV = 9
+  integer(c_int), public, parameter :: TSTEP_RATIO = 10
+  integer(c_int), public, parameter :: TSTEP_RANGE = 11
+  integer(c_int), public, parameter :: TSTEP_INSTANT2 = 12
+  integer(c_int), public, parameter :: TSTEP_INSTANT3 = 13
+  integer(c_int), public, parameter :: TAXIS_ABSOLUTE = 1
+  integer(c_int), public, parameter :: TAXIS_RELATIVE = 2
+  integer(c_int), public, parameter :: TAXIS_FORECAST = 3
+  integer(c_int), public, parameter :: TUNIT_SECOND = 1
+  integer(c_int), public, parameter :: TUNIT_MINUTE = 2
+  integer(c_int), public, parameter :: TUNIT_QUARTER = 3
+  integer(c_int), public, parameter :: TUNIT_30MINUTES = 4
+  integer(c_int), public, parameter :: TUNIT_HOUR = 5
+  integer(c_int), public, parameter :: TUNIT_3HOURS = 6
+  integer(c_int), public, parameter :: TUNIT_6HOURS = 7
+  integer(c_int), public, parameter :: TUNIT_12HOURS = 8
+  integer(c_int), public, parameter :: TUNIT_DAY = 9
+  integer(c_int), public, parameter :: TUNIT_MONTH = 10
+  integer(c_int), public, parameter :: TUNIT_YEAR = 11
+  integer(c_int), public, parameter :: CALENDAR_STANDARD = 0
+  integer(c_int), public, parameter :: CALENDAR_PROLEPTIC = 1
+  integer(c_int), public, parameter :: CALENDAR_360DAYS = 2
+  integer(c_int), public, parameter :: CALENDAR_365DAYS = 3
+  integer(c_int), public, parameter :: CALENDAR_366DAYS = 4
+  integer(c_int), public, parameter :: CALENDAR_NONE = 5
+  integer(c_int), public, parameter :: CDI_UUID_SIZE = 16
+
+  public t_CdiParam
+  type, bind(c) :: t_CdiParam
+    integer(c_int) :: discipline
+    integer(c_int) :: category
+    integer(c_int) :: number
+  end type t_CdiParam
+
+  public :: t_CdiIterator
+  type :: t_CdiIterator
+    type(c_ptr) :: ptr
+  end type t_CdiIterator
+
+  public :: t_CdiGribIterator
+  type :: t_CdiGribIterator
+    type(c_ptr) :: ptr
+  end type t_CdiGribIterator
+  public :: cdiReset
+  public :: cdiStringError
+  public :: cdiDebug
+  public :: cdiLibraryVersion
+  public :: cdiPrintVersion
+  public :: cdiHaveFiletype
+  public :: cdiDefMissval
+  public :: cdiInqMissval
+  public :: cdiDefGlobal
+  public :: namespaceNew
+  public :: namespaceSetActive
+  public :: namespaceGetActive
+  public :: namespaceDelete
+  public :: cdiParamToString
+  public :: cdiDecodeParam
+  public :: cdiEncodeParam
+  public :: cdiDecodeDate
+  public :: cdiEncodeDate
+  public :: cdiDecodeTime
+  public :: cdiEncodeTime
+  public :: cdiGetFiletype
+  public :: streamOpenRead
+  public :: streamOpenWrite
+  public :: streamOpenAppend
+  public :: streamClose
+  public :: streamSync
+  public :: streamDefVlist
+  public :: streamInqVlist
+  public :: streamInqFiletype
+  public :: streamDefByteorder
+  public :: streamInqByteorder
+  public :: streamDefCompType
+  public :: streamInqCompType
+  public :: streamDefCompLevel
+  public :: streamInqCompLevel
+  public :: streamDefTimestep
+  public :: streamInqTimestep
+  public :: streamInqCurTimestepID
+  public :: streamFilename
+  public :: streamFilesuffix
+  public :: streamInqNvars
+  public :: streamWriteVar
+  public :: streamWriteVarF
+  public :: streamReadVar
+  public :: streamReadVarF
+  public :: streamWriteVarSlice
+  public :: streamWriteVarSliceF
+  public :: streamReadVarSlice
+  public :: streamReadVarSliceF
+  public :: streamWriteVarChunk
+  public :: streamDefRecord
+  public :: streamInqRecord
+  public :: streamWriteRecord
+  public :: streamWriteRecordF
+  public :: streamReadRecord
+  public :: streamCopyRecord
+  public :: cdiIterator_new
+  public :: cdiIterator_clone
+  public :: cdiIterator_serialize
+  public :: cdiIterator_deserialize
+  public :: cdiIterator_delete
+  public :: cdiIterator_nextField
+  public :: cdiIterator_inqStartTime
+  public :: cdiIterator_inqEndTime
+  public :: cdiIterator_inqVTime
+  public :: cdiIterator_inqLevelType
+  public :: cdiIterator_inqLevel
+  public :: cdiIterator_inqLevelUuid
+  public :: cdiIterator_inqParam
+  public :: cdiIterator_inqDatatype
+  public :: cdiIterator_inqTsteptype
+  public :: cdiIterator_inqVariableName
+  public :: cdiIterator_inqGridId
+  public :: cdiIterator_readField
+  public :: cdiIterator_readFieldF
+  public :: cdiGribIterator_clone
+  public :: cdiGribIterator_delete
+  public :: cdiGribIterator_getLong
+  public :: cdiGribIterator_getDouble
+  public :: cdiGribIterator_getLength
+  public :: cdiGribIterator_getString
+  public :: cdiGribIterator_getSize
+  public :: cdiGribIterator_getLongArray
+  public :: cdiGribIterator_getDoubleArray
+  public :: cdiGribIterator_inqEdition
+  public :: cdiGribIterator_inqLongValue
+  public :: cdiGribIterator_inqLongDefaultValue
+  public :: cdiGribIterator_inqDoubleValue
+  public :: cdiGribIterator_inqDoubleDefaultValue
+  public :: cdiGribIterator_inqStringValue
+  public :: vlistCreate
+  public :: vlistDestroy
+  public :: vlistDuplicate
+  public :: vlistCopy
+  public :: vlistCopyFlag
+  public :: vlistClearFlag
+  public :: vlistCat
+  public :: vlistMerge
+  public :: vlistPrint
+  public :: vlistNumber
+  public :: vlistNvars
+  public :: vlistNgrids
+  public :: vlistNzaxis
+  public :: vlistNsubtypes
+  public :: vlistDefNtsteps
+  public :: vlistNtsteps
+  public :: vlistGridsizeMax
+  public :: vlistGrid
+  public :: vlistGridIndex
+  public :: vlistChangeGridIndex
+  public :: vlistChangeGrid
+  public :: vlistZaxis
+  public :: vlistZaxisIndex
+  public :: vlistChangeZaxisIndex
+  public :: vlistChangeZaxis
+  public :: vlistNrecs
+  public :: vlistSubtype
+  public :: vlistSubtypeIndex
+  public :: vlistDefTaxis
+  public :: vlistInqTaxis
+  public :: vlistDefTable
+  public :: vlistInqTable
+  public :: vlistDefInstitut
+  public :: vlistInqInstitut
+  public :: vlistDefModel
+  public :: vlistInqModel
+  public :: vlistDefVarTiles
+  public :: vlistDefVar
+  public :: vlistChangeVarGrid
+  public :: vlistChangeVarZaxis
+  public :: vlistInqVar
+  public :: vlistInqVarGrid
+  public :: vlistInqVarZaxis
+  public :: vlistInqVarID
+  public :: vlistDefVarTsteptype
+  public :: vlistInqVarTsteptype
+  public :: vlistDefVarCompType
+  public :: vlistInqVarCompType
+  public :: vlistDefVarCompLevel
+  public :: vlistInqVarCompLevel
+  public :: vlistDefVarParam
+  public :: vlistInqVarParam
+  public :: vlistDefVarCode
+  public :: vlistInqVarCode
+  public :: vlistDefVarDatatype
+  public :: vlistInqVarDatatype
+  public :: vlistDefVarChunkType
+  public :: vlistInqVarChunkType
+  public :: vlistDefVarXYZ
+  public :: vlistInqVarXYZ
+  public :: vlistInqVarNumber
+  public :: vlistDefVarInstitut
+  public :: vlistInqVarInstitut
+  public :: vlistDefVarModel
+  public :: vlistInqVarModel
+  public :: vlistDefVarTable
+  public :: vlistInqVarTable
+  public :: vlistDefVarName
+  public :: vlistInqVarName
+  public :: vlistCopyVarName
+  public :: vlistDefVarStdname
+  public :: vlistInqVarStdname
+  public :: vlistDefVarLongname
+  public :: vlistInqVarLongname
+  public :: vlistDefVarUnits
+  public :: vlistInqVarUnits
+  public :: vlistDefVarMissval
+  public :: vlistInqVarMissval
+  public :: vlistDefVarExtra
+  public :: vlistInqVarExtra
+  public :: vlistDefVarScalefactor
+  public :: vlistInqVarScalefactor
+  public :: vlistDefVarAddoffset
+  public :: vlistInqVarAddoffset
+  public :: vlistDefVarTimave
+  public :: vlistInqVarTimave
+  public :: vlistDefVarTimaccu
+  public :: vlistInqVarTimaccu
+  public :: vlistDefVarTypeOfGeneratingProcess
+  public :: vlistInqVarTypeOfGeneratingProcess
+  public :: vlistDefVarProductDefinitionTemplate
+  public :: vlistInqVarProductDefinitionTemplate
+  public :: vlistInqVarSize
+  public :: vlistDefIndex
+  public :: vlistInqIndex
+  public :: vlistDefFlag
+  public :: vlistInqFlag
+  public :: vlistFindVar
+  public :: vlistFindLevel
+  public :: vlistMergedVar
+  public :: vlistMergedLevel
+  public :: vlistDefVarEnsemble
+  public :: vlistInqVarEnsemble
+  public :: cdiClearAdditionalKeys
+  public :: cdiDefAdditionalKey
+  public :: vlistDefVarIntKey
+  public :: vlistDefVarDblKey
+  public :: vlistHasVarKey
+  public :: vlistInqVarDblKey
+  public :: vlistInqVarIntKey
+  public :: vlistInqNatts
+  public :: vlistInqAtt
+  public :: vlistDelAtt
+  public :: vlistDefAttInt
+  public :: vlistDefAttFlt
+  public :: vlistDefAttTxt
+  public :: vlistInqAttInt
+  public :: vlistInqAttFlt
+  public :: vlistInqAttTxt
+  public :: gridName
+  public :: gridNamePtr
+  public :: gridCompress
+  public :: gridDefMaskGME
+  public :: gridInqMaskGME
+  public :: gridDefMask
+  public :: gridInqMask
+  public :: gridPrint
+  public :: gridCreate
+  public :: gridDestroy
+  public :: gridDuplicate
+  public :: gridInqType
+  public :: gridInqSize
+  public :: gridDefXsize
+  public :: gridInqXsize
+  public :: gridDefYsize
+  public :: gridInqYsize
+  public :: gridDefNP
+  public :: gridInqNP
+  public :: gridDefXvals
+  public :: gridInqXvals
+  public :: gridDefYvals
+  public :: gridInqYvals
+  public :: gridDefXname
+  public :: gridInqXname
+  public :: gridDefXlongname
+  public :: gridInqXlongname
+  public :: gridDefXunits
+  public :: gridInqXunits
+  public :: gridDefYname
+  public :: gridInqYname
+  public :: gridDefYlongname
+  public :: gridInqYlongname
+  public :: gridDefYunits
+  public :: gridInqYunits
+  public :: gridInqXstdname
+  public :: gridInqYstdname
+  public :: gridDefPrec
+  public :: gridInqPrec
+  public :: gridInqXval
+  public :: gridInqYval
+  public :: gridInqXinc
+  public :: gridInqYinc
+  public :: gridIsCircular
+  public :: gridIsRotated
+  public :: gridDefXpole
+  public :: gridInqXpole
+  public :: gridDefYpole
+  public :: gridInqYpole
+  public :: gridDefAngle
+  public :: gridInqAngle
+  public :: gridInqTrunc
+  public :: gridDefTrunc
+  public :: gridDefGMEnd
+  public :: gridInqGMEnd
+  public :: gridDefGMEni
+  public :: gridInqGMEni
+  public :: gridDefGMEni2
+  public :: gridInqGMEni2
+  public :: gridDefGMEni3
+  public :: gridInqGMEni3
+  public :: gridDefNumber
+  public :: gridInqNumber
+  public :: gridDefPosition
+  public :: gridInqPosition
+  public :: gridDefReference
+  public :: gridInqReference
+  public :: gridDefUUID
+  public :: gridInqUUID
+  public :: gridDefLCC
+  public :: gridInqLCC
+  public :: gridDefLcc2
+  public :: gridInqLcc2
+  public :: gridDefLaea
+  public :: gridInqLaea
+  public :: gridDefArea
+  public :: gridInqArea
+  public :: gridHasArea
+  public :: gridDefNvertex
+  public :: gridInqNvertex
+  public :: gridDefXbounds
+  public :: gridInqXbounds
+  public :: gridDefYbounds
+  public :: gridInqYbounds
+  public :: gridDefRowlon
+  public :: gridInqRowlon
+  public :: gridChangeType
+  public :: gridDefComplexPacking
+  public :: gridInqComplexPacking
+  public :: zaxisName
+  public :: zaxisCreate
+  public :: zaxisDestroy
+  public :: zaxisInqType
+  public :: zaxisInqSize
+  public :: zaxisDuplicate
+  public :: zaxisResize
+  public :: zaxisPrint
+  public :: zaxisDefLevels
+  public :: zaxisInqLevels
+  public :: zaxisDefLevel
+  public :: zaxisInqLevel
+  public :: zaxisDefNlevRef
+  public :: zaxisInqNlevRef
+  public :: zaxisDefNumber
+  public :: zaxisInqNumber
+  public :: zaxisDefUUID
+  public :: zaxisInqUUID
+  public :: zaxisDefName
+  public :: zaxisInqName
+  public :: zaxisDefLongname
+  public :: zaxisInqLongname
+  public :: zaxisDefUnits
+  public :: zaxisInqUnits
+  public :: zaxisInqStdname
+  public :: zaxisDefPsName
+  public :: zaxisInqPsName
+  public :: zaxisDefPrec
+  public :: zaxisInqPrec
+  public :: zaxisDefPositive
+  public :: zaxisInqPositive
+  public :: zaxisDefScalar
+  public :: zaxisInqScalar
+  public :: zaxisDefLtype
+  public :: zaxisInqLtype
+  public :: zaxisInqLevelsPtr
+  public :: zaxisDefVct
+  public :: zaxisInqVct
+  public :: zaxisInqVctSize
+  public :: zaxisInqVctPtr
+  public :: zaxisDefLbounds
+  public :: zaxisInqLbounds
+  public :: zaxisInqLbound
+  public :: zaxisDefUbounds
+  public :: zaxisInqUbounds
+  public :: zaxisInqUbound
+  public :: zaxisDefWeights
+  public :: zaxisInqWeights
+  public :: zaxisChangeType
+  public :: taxisCreate
+  public :: taxisDestroy
+  public :: taxisDuplicate
+  public :: taxisCopyTimestep
+  public :: taxisDefType
+  public :: taxisDefVdate
+  public :: taxisDefVtime
+  public :: taxisInqVdate
+  public :: taxisInqVtime
+  public :: taxisDefRdate
+  public :: taxisDefRtime
+  public :: taxisInqRdate
+  public :: taxisInqRtime
+  public :: taxisDefFdate
+  public :: taxisDefFtime
+  public :: taxisInqFdate
+  public :: taxisInqFtime
+  public :: taxisHasBounds
+  public :: taxisDeleteBounds
+  public :: taxisDefVdateBounds
+  public :: taxisDefVtimeBounds
+  public :: taxisInqVdateBounds
+  public :: taxisInqVtimeBounds
+  public :: taxisDefCalendar
+  public :: taxisInqCalendar
+  public :: taxisDefTunit
+  public :: taxisInqTunit
+  public :: taxisDefForecastTunit
+  public :: taxisInqForecastTunit
+  public :: taxisDefForecastPeriod
+  public :: taxisInqForecastPeriod
+  public :: taxisDefNumavg
+  public :: taxisInqType
+  public :: taxisInqNumavg
+  public :: tunitNamePtr
+  public :: institutDef
+  public :: institutInq
+  public :: institutInqNumber
+  public :: institutInqCenter
+  public :: institutInqSubcenter
+  public :: institutInqNamePtr
+  public :: institutInqLongnamePtr
+  public :: modelDef
+  public :: modelInq
+  public :: modelInqInstitut
+  public :: modelInqGribID
+  public :: modelInqNamePtr
+  public :: tableWriteC
+  public :: tableWrite
+  public :: tableRead
+  public :: tableDef
+  public :: tableInqNamePtr
+  public :: tableDefEntry
+  public :: tableInq
+  public :: tableInqNumber
+  public :: tableInqNum
+  public :: tableInqModel
+  public :: tableInqPar
+  public :: tableInqParCode
+  public :: tableInqParName
+  public :: tableInqParLongname
+  public :: tableInqParUnits
+  public :: tableInqParNamePtr
+  public :: tableInqParLongnamePtr
+  public :: tableInqParUnitsPtr
+  public :: streamDefHistory
+  public :: streamInqHistorySize
+  public :: streamInqHistoryString
+  public :: subtypeCreate
+  public :: subtypePrint
+  public :: subtypeCompare
+  public :: subtypeInqSize
+  public :: subtypeInqActiveIndex
+  public :: subtypeDefActiveIndex
+  public :: subtypeInqTile
+  public :: vlistInqVarSubtype
+  public :: gribapiLibraryVersion
+
+  interface
+    subroutine cdiReset() bind(c, name = 'cdiReset')
+    end subroutine cdiReset
+
+    subroutine cdiDebug(debug_dummy) bind(c, name = 'cdiDebug')
+      import c_int
+      integer(c_int), value :: debug_dummy
+    end subroutine cdiDebug
+
+    subroutine cdiPrintVersion() bind(c, name = 'cdiPrintVersion')
+    end subroutine cdiPrintVersion
+
+    function cdiHaveFiletype(filetype_dummy) bind(c, name = 'cdiHaveFiletype')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: filetype_dummy
+      integer(c_int) :: f_result
+    end function cdiHaveFiletype
+
+    subroutine cdiDefMissval(missval_dummy) bind(c, name = 'cdiDefMissval')
+      import c_double
+      real(c_double), value :: missval_dummy
+    end subroutine cdiDefMissval
+
+    function cdiInqMissval() bind(c, name = 'cdiInqMissval') result(f_result)
+      import c_double
+      real(c_double) :: f_result
+    end function cdiInqMissval
+
+    function namespaceNew() bind(c, name = 'namespaceNew') result(f_result)
+      import c_int
+      integer(c_int) :: f_result
+    end function namespaceNew
+
+    subroutine namespaceSetActive(namespaceID_dummy) bind(c, name =&
+    & 'namespaceSetActive')
+      import c_int
+      integer(c_int), value :: namespaceID_dummy
+    end subroutine namespaceSetActive
+
+    function namespaceGetActive() bind(c, name = 'namespaceGetActive')&
+    & result(f_result)
+      import c_int
+      integer(c_int) :: f_result
+    end function namespaceGetActive
+
+    subroutine namespaceDelete(namespaceID_dummy) bind(c, name =&
+    & 'namespaceDelete')
+      import c_int
+      integer(c_int), value :: namespaceID_dummy
+    end subroutine namespaceDelete
+
+    subroutine cdiDecodeParam(param_dummy, pnum_dummy, pcat_dummy, pdis_dummy)&
+    & bind(c, name = 'cdiDecodeParam')
+      import c_int
+      integer(c_int), value :: param_dummy
+      integer(c_int), intent(inout) :: pnum_dummy
+      integer(c_int), intent(inout) :: pcat_dummy
+      integer(c_int), intent(inout) :: pdis_dummy
+    end subroutine cdiDecodeParam
+
+    function cdiEncodeParam(pnum_dummy, pcat_dummy, pdis_dummy) bind(c, name =&
+    & 'cdiEncodeParam') result(f_result)
+      import c_int
+      integer(c_int), value :: pnum_dummy
+      integer(c_int), value :: pcat_dummy
+      integer(c_int), value :: pdis_dummy
+      integer(c_int) :: f_result
+    end function cdiEncodeParam
+
+    subroutine cdiDecodeDate(date_dummy, year_dummy, month_dummy, day_dummy)&
+    & bind(c, name = 'cdiDecodeDate')
+      import c_int
+      integer(c_int), value :: date_dummy
+      integer(c_int), intent(inout) :: year_dummy
+      integer(c_int), intent(inout) :: month_dummy
+      integer(c_int), intent(inout) :: day_dummy
+    end subroutine cdiDecodeDate
+
+    function cdiEncodeDate(year_dummy, month_dummy, day_dummy) bind(c, name =&
+    & 'cdiEncodeDate') result(f_result)
+      import c_int
+      integer(c_int), value :: year_dummy
+      integer(c_int), value :: month_dummy
+      integer(c_int), value :: day_dummy
+      integer(c_int) :: f_result
+    end function cdiEncodeDate
+
+    subroutine cdiDecodeTime(time_dummy, hour_dummy, minute_dummy,&
+    & second_dummy) bind(c, name = 'cdiDecodeTime')
+      import c_int
+      integer(c_int), value :: time_dummy
+      integer(c_int), intent(inout) :: hour_dummy
+      integer(c_int), intent(inout) :: minute_dummy
+      integer(c_int), intent(inout) :: second_dummy
+    end subroutine cdiDecodeTime
+
+    function cdiEncodeTime(hour_dummy, minute_dummy, second_dummy) bind(c, name&
+    & = 'cdiEncodeTime') result(f_result)
+      import c_int
+      integer(c_int), value :: hour_dummy
+      integer(c_int), value :: minute_dummy
+      integer(c_int), value :: second_dummy
+      integer(c_int) :: f_result
+    end function cdiEncodeTime
+
+    subroutine streamClose(streamID_dummy) bind(c, name = 'streamClose')
+      import c_int
+      integer(c_int), value :: streamID_dummy
+    end subroutine streamClose
+
+    subroutine streamSync(streamID_dummy) bind(c, name = 'streamSync')
+      import c_int
+      integer(c_int), value :: streamID_dummy
+    end subroutine streamSync
+
+    subroutine streamDefVlist(streamID_dummy, vlistID_dummy) bind(c, name =&
+    & 'streamDefVlist')
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: vlistID_dummy
+    end subroutine streamDefVlist
+
+    function streamInqVlist(streamID_dummy) bind(c, name = 'streamInqVlist')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int) :: f_result
+    end function streamInqVlist
+
+    function streamInqFiletype(streamID_dummy) bind(c, name =&
+    & 'streamInqFiletype') result(f_result)
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int) :: f_result
+    end function streamInqFiletype
+
+    subroutine streamDefByteorder(streamID_dummy, byteorder_dummy) bind(c, name&
+    & = 'streamDefByteorder')
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: byteorder_dummy
+    end subroutine streamDefByteorder
+
+    function streamInqByteorder(streamID_dummy) bind(c, name =&
+    & 'streamInqByteorder') result(f_result)
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int) :: f_result
+    end function streamInqByteorder
+
+    subroutine streamDefCompType(streamID_dummy, comptype_dummy) bind(c, name =&
+    & 'streamDefCompType')
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: comptype_dummy
+    end subroutine streamDefCompType
+
+    function streamInqCompType(streamID_dummy) bind(c, name =&
+    & 'streamInqCompType') result(f_result)
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int) :: f_result
+    end function streamInqCompType
+
+    subroutine streamDefCompLevel(streamID_dummy, complevel_dummy) bind(c, name&
+    & = 'streamDefCompLevel')
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: complevel_dummy
+    end subroutine streamDefCompLevel
+
+    function streamInqCompLevel(streamID_dummy) bind(c, name =&
+    & 'streamInqCompLevel') result(f_result)
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int) :: f_result
+    end function streamInqCompLevel
+
+    function streamDefTimestep(streamID_dummy, tsID_dummy) bind(c, name =&
+    & 'streamDefTimestep') result(f_result)
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: tsID_dummy
+      integer(c_int) :: f_result
+    end function streamDefTimestep
+
+    function streamInqTimestep(streamID_dummy, tsID_dummy) bind(c, name =&
+    & 'streamInqTimestep') result(f_result)
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: tsID_dummy
+      integer(c_int) :: f_result
+    end function streamInqTimestep
+
+    function streamInqCurTimestepID(streamID_dummy) bind(c, name =&
+    & 'streamInqCurTimestepID') result(f_result)
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int) :: f_result
+    end function streamInqCurTimestepID
+
+    function streamInqNvars(streamID_dummy) bind(c, name = 'streamInqNvars')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int) :: f_result
+    end function streamInqNvars
+
+    subroutine streamWriteVar(streamID_dummy, varID_dummy, data_dummy,&
+    & nmiss_dummy) bind(c, name = 'streamWriteVar')
+      import c_double, c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: varID_dummy
+      real(c_double), intent(in) :: data_dummy(*)
+      integer(c_int), value :: nmiss_dummy
+    end subroutine streamWriteVar
+
+    subroutine streamWriteVarF(streamID_dummy, varID_dummy, data_dummy,&
+    & nmiss_dummy) bind(c, name = 'streamWriteVarF')
+      import c_float, c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: varID_dummy
+      real(c_float), intent(in) :: data_dummy(*)
+      integer(c_int), value :: nmiss_dummy
+    end subroutine streamWriteVarF
+
+    subroutine streamReadVar(streamID_dummy, varID_dummy, data_dummy,&
+    & nmiss_dummy) bind(c, name = 'streamReadVar')
+      import c_double, c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: varID_dummy
+      real(c_double), intent(inout) :: data_dummy(*)
+      integer(c_int), intent(inout) :: nmiss_dummy
+    end subroutine streamReadVar
+
+    subroutine streamReadVarF(streamID_dummy, varID_dummy, data_dummy,&
+    & nmiss_dummy) bind(c, name = 'streamReadVarF')
+      import c_float, c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: varID_dummy
+      real(c_float), intent(inout) :: data_dummy(*)
+      integer(c_int), intent(inout) :: nmiss_dummy
+    end subroutine streamReadVarF
+
+    subroutine streamWriteVarSlice(streamID_dummy, varID_dummy, levelID_dummy,&
+    & data_dummy, nmiss_dummy) bind(c, name = 'streamWriteVarSlice')
+      import c_double, c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: levelID_dummy
+      real(c_double), intent(in) :: data_dummy(*)
+      integer(c_int), value :: nmiss_dummy
+    end subroutine streamWriteVarSlice
+
+    subroutine streamWriteVarSliceF(streamID_dummy, varID_dummy, levelID_dummy,&
+    & data_dummy, nmiss_dummy) bind(c, name = 'streamWriteVarSliceF')
+      import c_float, c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: levelID_dummy
+      real(c_float), intent(in) :: data_dummy(*)
+      integer(c_int), value :: nmiss_dummy
+    end subroutine streamWriteVarSliceF
+
+    subroutine streamReadVarSlice(streamID_dummy, varID_dummy, levelID_dummy,&
+    & data_dummy, nmiss_dummy) bind(c, name = 'streamReadVarSlice')
+      import c_double, c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: levelID_dummy
+      real(c_double), intent(inout) :: data_dummy(*)
+      integer(c_int), intent(inout) :: nmiss_dummy
+    end subroutine streamReadVarSlice
+
+    subroutine streamReadVarSliceF(streamID_dummy, varID_dummy, levelID_dummy,&
+    & data_dummy, nmiss_dummy) bind(c, name = 'streamReadVarSliceF')
+      import c_float, c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: levelID_dummy
+      real(c_float), intent(inout) :: data_dummy(*)
+      integer(c_int), intent(inout) :: nmiss_dummy
+    end subroutine streamReadVarSliceF
+
+    subroutine streamWriteVarChunk(streamID_dummy, varID_dummy, rect_dummy,&
+    & data_dummy, nmiss_dummy) bind(c, name = 'streamWriteVarChunk')
+      import c_double, c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), intent(in) :: rect_dummy(2, 3)
+      real(c_double), intent(in) :: data_dummy(*)
+      integer(c_int), value :: nmiss_dummy
+    end subroutine streamWriteVarChunk
+
+    subroutine streamDefRecord(streamID_dummy, varID_dummy, levelID_dummy)&
+    & bind(c, name = 'streamDefRecord')
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: levelID_dummy
+    end subroutine streamDefRecord
+
+    subroutine streamInqRecord(streamID_dummy, varID_dummy, levelID_dummy)&
+    & bind(c, name = 'streamInqRecord')
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int), intent(inout) :: varID_dummy
+      integer(c_int), intent(inout) :: levelID_dummy
+    end subroutine streamInqRecord
+
+    subroutine streamWriteRecord(streamID_dummy, data_dummy, nmiss_dummy)&
+    & bind(c, name = 'streamWriteRecord')
+      import c_double, c_int
+      integer(c_int), value :: streamID_dummy
+      real(c_double), intent(in) :: data_dummy(*)
+      integer(c_int), value :: nmiss_dummy
+    end subroutine streamWriteRecord
+
+    subroutine streamWriteRecordF(streamID_dummy, data_dummy, nmiss_dummy)&
+    & bind(c, name = 'streamWriteRecordF')
+      import c_float, c_int
+      integer(c_int), value :: streamID_dummy
+      real(c_float), intent(in) :: data_dummy(*)
+      integer(c_int), value :: nmiss_dummy
+    end subroutine streamWriteRecordF
+
+    subroutine streamReadRecord(streamID_dummy, data_dummy, nmiss_dummy)&
+    & bind(c, name = 'streamReadRecord')
+      import c_double, c_int
+      integer(c_int), value :: streamID_dummy
+      real(c_double), intent(inout) :: data_dummy(*)
+      integer(c_int), intent(inout) :: nmiss_dummy
+    end subroutine streamReadRecord
+
+    subroutine streamCopyRecord(streamIDdest_dummy, streamIDsrc_dummy) bind(c,&
+    & name = 'streamCopyRecord')
+      import c_int
+      integer(c_int), value :: streamIDdest_dummy
+      integer(c_int), value :: streamIDsrc_dummy
+    end subroutine streamCopyRecord
+
+    function vlistCreate() bind(c, name = 'vlistCreate') result(f_result)
+      import c_int
+      integer(c_int) :: f_result
+    end function vlistCreate
+
+    subroutine vlistDestroy(vlistID_dummy) bind(c, name = 'vlistDestroy')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+    end subroutine vlistDestroy
+
+    function vlistDuplicate(vlistID_dummy) bind(c, name = 'vlistDuplicate')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int) :: f_result
+    end function vlistDuplicate
+
+    subroutine vlistCopy(vlistID2_dummy, vlistID1_dummy) bind(c, name =&
+    & 'vlistCopy')
+      import c_int
+      integer(c_int), value :: vlistID2_dummy
+      integer(c_int), value :: vlistID1_dummy
+    end subroutine vlistCopy
+
+    subroutine vlistCopyFlag(vlistID2_dummy, vlistID1_dummy) bind(c, name =&
+    & 'vlistCopyFlag')
+      import c_int
+      integer(c_int), value :: vlistID2_dummy
+      integer(c_int), value :: vlistID1_dummy
+    end subroutine vlistCopyFlag
+
+    subroutine vlistClearFlag(vlistID_dummy) bind(c, name = 'vlistClearFlag')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+    end subroutine vlistClearFlag
+
+    subroutine vlistCat(vlistID2_dummy, vlistID1_dummy) bind(c, name =&
+    & 'vlistCat')
+      import c_int
+      integer(c_int), value :: vlistID2_dummy
+      integer(c_int), value :: vlistID1_dummy
+    end subroutine vlistCat
+
+    subroutine vlistMerge(vlistID2_dummy, vlistID1_dummy) bind(c, name =&
+    & 'vlistMerge')
+      import c_int
+      integer(c_int), value :: vlistID2_dummy
+      integer(c_int), value :: vlistID1_dummy
+    end subroutine vlistMerge
+
+    subroutine vlistPrint(vlistID_dummy) bind(c, name = 'vlistPrint')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+    end subroutine vlistPrint
+
+    function vlistNumber(vlistID_dummy) bind(c, name = 'vlistNumber')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int) :: f_result
+    end function vlistNumber
+
+    function vlistNvars(vlistID_dummy) bind(c, name = 'vlistNvars')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int) :: f_result
+    end function vlistNvars
+
+    function vlistNgrids(vlistID_dummy) bind(c, name = 'vlistNgrids')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int) :: f_result
+    end function vlistNgrids
+
+    function vlistNzaxis(vlistID_dummy) bind(c, name = 'vlistNzaxis')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int) :: f_result
+    end function vlistNzaxis
+
+    function vlistNsubtypes(vlistID_dummy) bind(c, name = 'vlistNsubtypes')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int) :: f_result
+    end function vlistNsubtypes
+
+    subroutine vlistDefNtsteps(vlistID_dummy, nts_dummy) bind(c, name =&
+    & 'vlistDefNtsteps')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: nts_dummy
+    end subroutine vlistDefNtsteps
+
+    function vlistNtsteps(vlistID_dummy) bind(c, name = 'vlistNtsteps')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int) :: f_result
+    end function vlistNtsteps
+
+    function vlistGridsizeMax(vlistID_dummy) bind(c, name = 'vlistGridsizeMax')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int) :: f_result
+    end function vlistGridsizeMax
+
+    function vlistGrid(vlistID_dummy, index_dummy) bind(c, name = 'vlistGrid')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: index_dummy
+      integer(c_int) :: f_result
+    end function vlistGrid
+
+    function vlistGridIndex(vlistID_dummy, gridID_dummy) bind(c, name =&
+    & 'vlistGridIndex') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function vlistGridIndex
+
+    subroutine vlistChangeGridIndex(vlistID_dummy, index_dummy, gridID_dummy)&
+    & bind(c, name = 'vlistChangeGridIndex')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: index_dummy
+      integer(c_int), value :: gridID_dummy
+    end subroutine vlistChangeGridIndex
+
+    subroutine vlistChangeGrid(vlistID_dummy, gridID1_dummy, gridID2_dummy)&
+    & bind(c, name = 'vlistChangeGrid')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: gridID1_dummy
+      integer(c_int), value :: gridID2_dummy
+    end subroutine vlistChangeGrid
+
+    function vlistZaxis(vlistID_dummy, index_dummy) bind(c, name =&
+    & 'vlistZaxis') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: index_dummy
+      integer(c_int) :: f_result
+    end function vlistZaxis
+
+    function vlistZaxisIndex(vlistID_dummy, zaxisID_dummy) bind(c, name =&
+    & 'vlistZaxisIndex') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int) :: f_result
+    end function vlistZaxisIndex
+
+    subroutine vlistChangeZaxisIndex(vlistID_dummy, index_dummy, zaxisID_dummy)&
+    & bind(c, name = 'vlistChangeZaxisIndex')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: index_dummy
+      integer(c_int), value :: zaxisID_dummy
+    end subroutine vlistChangeZaxisIndex
+
+    subroutine vlistChangeZaxis(vlistID_dummy, zaxisID1_dummy, zaxisID2_dummy)&
+    & bind(c, name = 'vlistChangeZaxis')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: zaxisID1_dummy
+      integer(c_int), value :: zaxisID2_dummy
+    end subroutine vlistChangeZaxis
+
+    function vlistNrecs(vlistID_dummy) bind(c, name = 'vlistNrecs')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int) :: f_result
+    end function vlistNrecs
+
+    function vlistSubtype(vlistID_dummy, index_dummy) bind(c, name =&
+    & 'vlistSubtype') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: index_dummy
+      integer(c_int) :: f_result
+    end function vlistSubtype
+
+    function vlistSubtypeIndex(vlistID_dummy, subtypeID_dummy) bind(c, name =&
+    & 'vlistSubtypeIndex') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: subtypeID_dummy
+      integer(c_int) :: f_result
+    end function vlistSubtypeIndex
+
+    subroutine vlistDefTaxis(vlistID_dummy, taxisID_dummy) bind(c, name =&
+    & 'vlistDefTaxis')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: taxisID_dummy
+    end subroutine vlistDefTaxis
+
+    function vlistInqTaxis(vlistID_dummy) bind(c, name = 'vlistInqTaxis')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqTaxis
+
+    subroutine vlistDefTable(vlistID_dummy, tableID_dummy) bind(c, name =&
+    & 'vlistDefTable')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: tableID_dummy
+    end subroutine vlistDefTable
+
+    function vlistInqTable(vlistID_dummy) bind(c, name = 'vlistInqTable')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqTable
+
+    subroutine vlistDefInstitut(vlistID_dummy, instID_dummy) bind(c, name =&
+    & 'vlistDefInstitut')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: instID_dummy
+    end subroutine vlistDefInstitut
+
+    function vlistInqInstitut(vlistID_dummy) bind(c, name = 'vlistInqInstitut')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqInstitut
+
+    subroutine vlistDefModel(vlistID_dummy, modelID_dummy) bind(c, name =&
+    & 'vlistDefModel')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: modelID_dummy
+    end subroutine vlistDefModel
+
+    function vlistInqModel(vlistID_dummy) bind(c, name = 'vlistInqModel')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqModel
+
+    function vlistDefVarTiles(vlistID_dummy, gridID_dummy, zaxisID_dummy,&
+    & tsteptype_dummy, tilesetID_dummy) bind(c, name = 'vlistDefVarTiles')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int), value :: tsteptype_dummy
+      integer(c_int), value :: tilesetID_dummy
+      integer(c_int) :: f_result
+    end function vlistDefVarTiles
+
+    function vlistDefVar(vlistID_dummy, gridID_dummy, zaxisID_dummy,&
+    & tsteptype_dummy) bind(c, name = 'vlistDefVar') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int), value :: tsteptype_dummy
+      integer(c_int) :: f_result
+    end function vlistDefVar
+
+    subroutine vlistChangeVarGrid(vlistID_dummy, varID_dummy, gridID_dummy)&
+    & bind(c, name = 'vlistChangeVarGrid')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: gridID_dummy
+    end subroutine vlistChangeVarGrid
+
+    subroutine vlistChangeVarZaxis(vlistID_dummy, varID_dummy, zaxisID_dummy)&
+    & bind(c, name = 'vlistChangeVarZaxis')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: zaxisID_dummy
+    end subroutine vlistChangeVarZaxis
+
+    subroutine vlistInqVar(vlistID_dummy, varID_dummy, gridID_dummy,&
+    & zaxisID_dummy, tsteptype_dummy) bind(c, name = 'vlistInqVar')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), intent(inout) :: gridID_dummy
+      integer(c_int), intent(inout) :: zaxisID_dummy
+      integer(c_int), intent(inout) :: tsteptype_dummy
+    end subroutine vlistInqVar
+
+    function vlistInqVarGrid(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarGrid') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarGrid
+
+    function vlistInqVarZaxis(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarZaxis') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarZaxis
+
+    function vlistInqVarID(vlistID_dummy, code_dummy) bind(c, name =&
+    & 'vlistInqVarID') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: code_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarID
+
+    subroutine vlistDefVarTsteptype(vlistID_dummy, varID_dummy,&
+    & tsteptype_dummy) bind(c, name = 'vlistDefVarTsteptype')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: tsteptype_dummy
+    end subroutine vlistDefVarTsteptype
+
+    function vlistInqVarTsteptype(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarTsteptype') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarTsteptype
+
+    subroutine vlistDefVarCompType(vlistID_dummy, varID_dummy, comptype_dummy)&
+    & bind(c, name = 'vlistDefVarCompType')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: comptype_dummy
+    end subroutine vlistDefVarCompType
+
+    function vlistInqVarCompType(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarCompType') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarCompType
+
+    subroutine vlistDefVarCompLevel(vlistID_dummy, varID_dummy,&
+    & complevel_dummy) bind(c, name = 'vlistDefVarCompLevel')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: complevel_dummy
+    end subroutine vlistDefVarCompLevel
+
+    function vlistInqVarCompLevel(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarCompLevel') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarCompLevel
+
+    subroutine vlistDefVarParam(vlistID_dummy, varID_dummy, param_dummy)&
+    & bind(c, name = 'vlistDefVarParam')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: param_dummy
+    end subroutine vlistDefVarParam
+
+    function vlistInqVarParam(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarParam') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarParam
+
+    subroutine vlistDefVarCode(vlistID_dummy, varID_dummy, code_dummy) bind(c,&
+    & name = 'vlistDefVarCode')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: code_dummy
+    end subroutine vlistDefVarCode
+
+    function vlistInqVarCode(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarCode') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarCode
+
+    subroutine vlistDefVarDatatype(vlistID_dummy, varID_dummy, datatype_dummy)&
+    & bind(c, name = 'vlistDefVarDatatype')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: datatype_dummy
+    end subroutine vlistDefVarDatatype
+
+    function vlistInqVarDatatype(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarDatatype') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarDatatype
+
+    subroutine vlistDefVarChunkType(vlistID_dummy, varID_dummy,&
+    & chunktype_dummy) bind(c, name = 'vlistDefVarChunkType')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: chunktype_dummy
+    end subroutine vlistDefVarChunkType
+
+    function vlistInqVarChunkType(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarChunkType') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarChunkType
+
+    subroutine vlistDefVarXYZ(vlistID_dummy, varID_dummy, xyz_dummy) bind(c,&
+    & name = 'vlistDefVarXYZ')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: xyz_dummy
+    end subroutine vlistDefVarXYZ
+
+    function vlistInqVarXYZ(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarXYZ') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarXYZ
+
+    function vlistInqVarNumber(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarNumber') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarNumber
+
+    subroutine vlistDefVarInstitut(vlistID_dummy, varID_dummy, instID_dummy)&
+    & bind(c, name = 'vlistDefVarInstitut')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: instID_dummy
+    end subroutine vlistDefVarInstitut
+
+    function vlistInqVarInstitut(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarInstitut') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarInstitut
+
+    subroutine vlistDefVarModel(vlistID_dummy, varID_dummy, modelID_dummy)&
+    & bind(c, name = 'vlistDefVarModel')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: modelID_dummy
+    end subroutine vlistDefVarModel
+
+    function vlistInqVarModel(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarModel') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarModel
+
+    subroutine vlistDefVarTable(vlistID_dummy, varID_dummy, tableID_dummy)&
+    & bind(c, name = 'vlistDefVarTable')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: tableID_dummy
+    end subroutine vlistDefVarTable
+
+    function vlistInqVarTable(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarTable') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarTable
+
+    subroutine vlistDefVarMissval(vlistID_dummy, varID_dummy, missval_dummy)&
+    & bind(c, name = 'vlistDefVarMissval')
+      import c_double, c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      real(c_double), value :: missval_dummy
+    end subroutine vlistDefVarMissval
+
+    function vlistInqVarMissval(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarMissval') result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      real(c_double) :: f_result
+    end function vlistInqVarMissval
+
+    subroutine vlistDefVarScalefactor(vlistID_dummy, varID_dummy,&
+    & scalefactor_dummy) bind(c, name = 'vlistDefVarScalefactor')
+      import c_double, c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      real(c_double), value :: scalefactor_dummy
+    end subroutine vlistDefVarScalefactor
+
+    function vlistInqVarScalefactor(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarScalefactor') result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      real(c_double) :: f_result
+    end function vlistInqVarScalefactor
+
+    subroutine vlistDefVarAddoffset(vlistID_dummy, varID_dummy,&
+    & addoffset_dummy) bind(c, name = 'vlistDefVarAddoffset')
+      import c_double, c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      real(c_double), value :: addoffset_dummy
+    end subroutine vlistDefVarAddoffset
+
+    function vlistInqVarAddoffset(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarAddoffset') result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      real(c_double) :: f_result
+    end function vlistInqVarAddoffset
+
+    subroutine vlistDefVarTimave(vlistID_dummy, varID_dummy, timave_dummy)&
+    & bind(c, name = 'vlistDefVarTimave')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: timave_dummy
+    end subroutine vlistDefVarTimave
+
+    function vlistInqVarTimave(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarTimave') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarTimave
+
+    subroutine vlistDefVarTimaccu(vlistID_dummy, varID_dummy, timaccu_dummy)&
+    & bind(c, name = 'vlistDefVarTimaccu')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: timaccu_dummy
+    end subroutine vlistDefVarTimaccu
+
+    function vlistInqVarTimaccu(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarTimaccu') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarTimaccu
+
+    subroutine vlistDefVarTypeOfGeneratingProcess(vlistID_dummy, varID_dummy,&
+    & typeOfGeneratingProcess_dummy) bind(c, name =&
+    & 'vlistDefVarTypeOfGeneratingProcess')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: typeOfGeneratingProcess_dummy
+    end subroutine vlistDefVarTypeOfGeneratingProcess
+
+    function vlistInqVarTypeOfGeneratingProcess(vlistID_dummy, varID_dummy)&
+    & bind(c, name = 'vlistInqVarTypeOfGeneratingProcess') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarTypeOfGeneratingProcess
+
+    subroutine vlistDefVarProductDefinitionTemplate(vlistID_dummy, varID_dummy,&
+    & productDefinitionTemplate_dummy) bind(c, name =&
+    & 'vlistDefVarProductDefinitionTemplate')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: productDefinitionTemplate_dummy
+    end subroutine vlistDefVarProductDefinitionTemplate
+
+    function vlistInqVarProductDefinitionTemplate(vlistID_dummy, varID_dummy)&
+    & bind(c, name = 'vlistInqVarProductDefinitionTemplate') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarProductDefinitionTemplate
+
+    function vlistInqVarSize(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarSize') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarSize
+
+    subroutine vlistDefIndex(vlistID_dummy, varID_dummy, levID_dummy,&
+    & index_dummy) bind(c, name = 'vlistDefIndex')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: levID_dummy
+      integer(c_int), value :: index_dummy
+    end subroutine vlistDefIndex
+
+    function vlistInqIndex(vlistID_dummy, varID_dummy, levID_dummy) bind(c,&
+    & name = 'vlistInqIndex') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: levID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqIndex
+
+    subroutine vlistDefFlag(vlistID_dummy, varID_dummy, levID_dummy,&
+    & flag_dummy) bind(c, name = 'vlistDefFlag')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: levID_dummy
+      integer(c_int), value :: flag_dummy
+    end subroutine vlistDefFlag
+
+    function vlistInqFlag(vlistID_dummy, varID_dummy, levID_dummy) bind(c, name&
+    & = 'vlistInqFlag') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: levID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqFlag
+
+    function vlistFindVar(vlistID_dummy, fvarID_dummy) bind(c, name =&
+    & 'vlistFindVar') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: fvarID_dummy
+      integer(c_int) :: f_result
+    end function vlistFindVar
+
+    function vlistFindLevel(vlistID_dummy, fvarID_dummy, flevelID_dummy)&
+    & bind(c, name = 'vlistFindLevel') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: fvarID_dummy
+      integer(c_int), value :: flevelID_dummy
+      integer(c_int) :: f_result
+    end function vlistFindLevel
+
+    function vlistMergedVar(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistMergedVar') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistMergedVar
+
+    function vlistMergedLevel(vlistID_dummy, varID_dummy, levelID_dummy)&
+    & bind(c, name = 'vlistMergedLevel') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: levelID_dummy
+      integer(c_int) :: f_result
+    end function vlistMergedLevel
+
+    subroutine vlistDefVarEnsemble(vlistID_dummy, varID_dummy, ensID_dummy,&
+    & ensCount_dummy, forecast_type_dummy) bind(c, name =&
+    & 'vlistDefVarEnsemble')
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), value :: ensID_dummy
+      integer(c_int), value :: ensCount_dummy
+      integer(c_int), value :: forecast_type_dummy
+    end subroutine vlistDefVarEnsemble
+
+    function vlistInqVarEnsemble(vlistID_dummy, varID_dummy, ensID_dummy,&
+    & ensCount_dummy, forecast_type_dummy) bind(c, name =&
+    & 'vlistInqVarEnsemble') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), intent(inout) :: ensID_dummy
+      integer(c_int), intent(inout) :: ensCount_dummy
+      integer(c_int), intent(inout) :: forecast_type_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarEnsemble
+
+    subroutine cdiClearAdditionalKeys() bind(c, name =&
+    & 'cdiClearAdditionalKeys')
+    end subroutine cdiClearAdditionalKeys
+
+    function vlistInqNatts(vlistID_dummy, varID_dummy, nattsp_dummy) bind(c,&
+    & name = 'vlistInqNatts') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int), intent(inout) :: nattsp_dummy
+      integer(c_int) :: f_result
+    end function vlistInqNatts
+
+    subroutine gridCompress(gridID_dummy) bind(c, name = 'gridCompress')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+    end subroutine gridCompress
+
+    subroutine gridDefMaskGME(gridID_dummy, mask_dummy) bind(c, name =&
+    & 'gridDefMaskGME')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), intent(in) :: mask_dummy(*)
+    end subroutine gridDefMaskGME
+
+    function gridInqMaskGME(gridID_dummy, mask_dummy) bind(c, name =&
+    & 'gridInqMaskGME') result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), intent(inout) :: mask_dummy(*)
+      integer(c_int) :: f_result
+    end function gridInqMaskGME
+
+    subroutine gridDefMask(gridID_dummy, mask_dummy) bind(c, name =&
+    & 'gridDefMask')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), intent(in) :: mask_dummy(*)
+    end subroutine gridDefMask
+
+    function gridInqMask(gridID_dummy, mask_dummy) bind(c, name =&
+    & 'gridInqMask') result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), intent(inout) :: mask_dummy(*)
+      integer(c_int) :: f_result
+    end function gridInqMask
+
+    subroutine gridPrint(gridID_dummy, index_dummy, opt_dummy) bind(c, name =&
+    & 'gridPrint')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: index_dummy
+      integer(c_int), value :: opt_dummy
+    end subroutine gridPrint
+
+    function gridCreate(gridtype_dummy, size_dummy) bind(c, name =&
+    & 'gridCreate') result(f_result)
+      import c_int
+      integer(c_int), value :: gridtype_dummy
+      integer(c_int), value :: size_dummy
+      integer(c_int) :: f_result
+    end function gridCreate
+
+    subroutine gridDestroy(gridID_dummy) bind(c, name = 'gridDestroy')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+    end subroutine gridDestroy
+
+    function gridDuplicate(gridID_dummy) bind(c, name = 'gridDuplicate')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridDuplicate
+
+    function gridInqType(gridID_dummy) bind(c, name = 'gridInqType')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqType
+
+    function gridInqSize(gridID_dummy) bind(c, name = 'gridInqSize')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqSize
+
+    subroutine gridDefXsize(gridID_dummy, xsize_dummy) bind(c, name =&
+    & 'gridDefXsize')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: xsize_dummy
+    end subroutine gridDefXsize
+
+    function gridInqXsize(gridID_dummy) bind(c, name = 'gridInqXsize')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqXsize
+
+    subroutine gridDefYsize(gridID_dummy, ysize_dummy) bind(c, name =&
+    & 'gridDefYsize')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: ysize_dummy
+    end subroutine gridDefYsize
+
+    function gridInqYsize(gridID_dummy) bind(c, name = 'gridInqYsize')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqYsize
+
+    subroutine gridDefNP(gridID_dummy, np_dummy) bind(c, name = 'gridDefNP')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: np_dummy
+    end subroutine gridDefNP
+
+    function gridInqNP(gridID_dummy) bind(c, name = 'gridInqNP')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqNP
+
+    subroutine gridDefXvals(gridID_dummy, xvals_dummy) bind(c, name =&
+    & 'gridDefXvals')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), intent(in) :: xvals_dummy(*)
+    end subroutine gridDefXvals
+
+    function gridInqXvals(gridID_dummy, xvals_dummy) bind(c, name =&
+    & 'gridInqXvals') result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), intent(inout) :: xvals_dummy(*)
+      integer(c_int) :: f_result
+    end function gridInqXvals
+
+    subroutine gridDefYvals(gridID_dummy, yvals_dummy) bind(c, name =&
+    & 'gridDefYvals')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), intent(in) :: yvals_dummy(*)
+    end subroutine gridDefYvals
+
+    function gridInqYvals(gridID_dummy, yvals_dummy) bind(c, name =&
+    & 'gridInqYvals') result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), intent(inout) :: yvals_dummy(*)
+      integer(c_int) :: f_result
+    end function gridInqYvals
+
+    subroutine gridDefPrec(gridID_dummy, prec_dummy) bind(c, name =&
+    & 'gridDefPrec')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: prec_dummy
+    end subroutine gridDefPrec
+
+    function gridInqPrec(gridID_dummy) bind(c, name = 'gridInqPrec')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqPrec
+
+    function gridInqXval(gridID_dummy, index_dummy) bind(c, name =&
+    & 'gridInqXval') result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: index_dummy
+      real(c_double) :: f_result
+    end function gridInqXval
+
+    function gridInqYval(gridID_dummy, index_dummy) bind(c, name =&
+    & 'gridInqYval') result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: index_dummy
+      real(c_double) :: f_result
+    end function gridInqYval
+
+    function gridInqXinc(gridID_dummy) bind(c, name = 'gridInqXinc')&
+    & result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double) :: f_result
+    end function gridInqXinc
+
+    function gridInqYinc(gridID_dummy) bind(c, name = 'gridInqYinc')&
+    & result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double) :: f_result
+    end function gridInqYinc
+
+    function gridIsCircular(gridID_dummy) bind(c, name = 'gridIsCircular')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridIsCircular
+
+    function gridIsRotated(gridID_dummy) bind(c, name = 'gridIsRotated')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridIsRotated
+
+    subroutine gridDefXpole(gridID_dummy, xpole_dummy) bind(c, name =&
+    & 'gridDefXpole')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), value :: xpole_dummy
+    end subroutine gridDefXpole
+
+    function gridInqXpole(gridID_dummy) bind(c, name = 'gridInqXpole')&
+    & result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double) :: f_result
+    end function gridInqXpole
+
+    subroutine gridDefYpole(gridID_dummy, ypole_dummy) bind(c, name =&
+    & 'gridDefYpole')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), value :: ypole_dummy
+    end subroutine gridDefYpole
+
+    function gridInqYpole(gridID_dummy) bind(c, name = 'gridInqYpole')&
+    & result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double) :: f_result
+    end function gridInqYpole
+
+    subroutine gridDefAngle(gridID_dummy, angle_dummy) bind(c, name =&
+    & 'gridDefAngle')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), value :: angle_dummy
+    end subroutine gridDefAngle
+
+    function gridInqAngle(gridID_dummy) bind(c, name = 'gridInqAngle')&
+    & result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double) :: f_result
+    end function gridInqAngle
+
+    function gridInqTrunc(gridID_dummy) bind(c, name = 'gridInqTrunc')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqTrunc
+
+    subroutine gridDefTrunc(gridID_dummy, trunc_dummy) bind(c, name =&
+    & 'gridDefTrunc')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: trunc_dummy
+    end subroutine gridDefTrunc
+
+    subroutine gridDefGMEnd(gridID_dummy, nd_dummy) bind(c, name =&
+    & 'gridDefGMEnd')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: nd_dummy
+    end subroutine gridDefGMEnd
+
+    function gridInqGMEnd(gridID_dummy) bind(c, name = 'gridInqGMEnd')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqGMEnd
+
+    subroutine gridDefGMEni(gridID_dummy, ni_dummy) bind(c, name =&
+    & 'gridDefGMEni')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: ni_dummy
+    end subroutine gridDefGMEni
+
+    function gridInqGMEni(gridID_dummy) bind(c, name = 'gridInqGMEni')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqGMEni
+
+    subroutine gridDefGMEni2(gridID_dummy, ni2_dummy) bind(c, name =&
+    & 'gridDefGMEni2')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: ni2_dummy
+    end subroutine gridDefGMEni2
+
+    function gridInqGMEni2(gridID_dummy) bind(c, name = 'gridInqGMEni2')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqGMEni2
+
+    subroutine gridDefGMEni3(gridID_dummy, ni3_dummy) bind(c, name =&
+    & 'gridDefGMEni3')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: ni3_dummy
+    end subroutine gridDefGMEni3
+
+    function gridInqGMEni3(gridID_dummy) bind(c, name = 'gridInqGMEni3')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqGMEni3
+
+    subroutine gridDefNumber(gridID_dummy, number_dummy) bind(c, name =&
+    & 'gridDefNumber')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: number_dummy
+    end subroutine gridDefNumber
+
+    function gridInqNumber(gridID_dummy) bind(c, name = 'gridInqNumber')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqNumber
+
+    subroutine gridDefPosition(gridID_dummy, position_dummy) bind(c, name =&
+    & 'gridDefPosition')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: position_dummy
+    end subroutine gridDefPosition
+
+    function gridInqPosition(gridID_dummy) bind(c, name = 'gridInqPosition')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqPosition
+
+    subroutine gridDefUUID(gridID_dummy, uuid_dummy) bind(c, name =&
+    & 'gridDefUUID')
+      import CDI_UUID_SIZE, c_int, c_signed_char
+      integer(c_int), value :: gridID_dummy
+      integer(kind = c_signed_char), intent(in) :: uuid_dummy(CDI_UUID_SIZE)
+    end subroutine gridDefUUID
+
+    subroutine gridInqUUID(gridID_dummy, uuid_dummy) bind(c, name =&
+    & 'gridInqUUID')
+      import CDI_UUID_SIZE, c_int, c_signed_char
+      integer(c_int), value :: gridID_dummy
+      integer(kind = c_signed_char), intent(inout) :: uuid_dummy(CDI_UUID_SIZE)
+    end subroutine gridInqUUID
+
+    subroutine gridDefLCC(gridID_dummy, originLon_dummy, originLat_dummy,&
+    & lonParY_dummy, lat1_dummy, lat2_dummy, xinc_dummy, yinc_dummy,&
+    & projflag_dummy, scanflag_dummy) bind(c, name = 'gridDefLCC')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), value :: originLon_dummy
+      real(c_double), value :: originLat_dummy
+      real(c_double), value :: lonParY_dummy
+      real(c_double), value :: lat1_dummy
+      real(c_double), value :: lat2_dummy
+      real(c_double), value :: xinc_dummy
+      real(c_double), value :: yinc_dummy
+      integer(c_int), value :: projflag_dummy
+      integer(c_int), value :: scanflag_dummy
+    end subroutine gridDefLCC
+
+    subroutine gridInqLCC(gridID_dummy, originLon_dummy, originLat_dummy,&
+    & lonParY_dummy, lat1_dummy, lat2_dummy, xinc_dummy, yinc_dummy,&
+    & projflag_dummy, scanflag_dummy) bind(c, name = 'gridInqLCC')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), intent(inout) :: originLon_dummy
+      real(c_double), intent(inout) :: originLat_dummy
+      real(c_double), intent(inout) :: lonParY_dummy
+      real(c_double), intent(inout) :: lat1_dummy
+      real(c_double), intent(inout) :: lat2_dummy
+      real(c_double), intent(inout) :: xinc_dummy
+      real(c_double), intent(inout) :: yinc_dummy
+      integer(c_int), intent(inout) :: projflag_dummy
+      integer(c_int), intent(inout) :: scanflag_dummy
+    end subroutine gridInqLCC
+
+    subroutine gridDefLcc2(gridID_dummy, earth_radius_dummy, lon_0_dummy,&
+    & lat_0_dummy, lat_1_dummy, lat_2_dummy) bind(c, name = 'gridDefLcc2')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), value :: earth_radius_dummy
+      real(c_double), value :: lon_0_dummy
+      real(c_double), value :: lat_0_dummy
+      real(c_double), value :: lat_1_dummy
+      real(c_double), value :: lat_2_dummy
+    end subroutine gridDefLcc2
+
+    subroutine gridInqLcc2(gridID_dummy, earth_radius_dummy, lon_0_dummy,&
+    & lat_0_dummy, lat_1_dummy, lat_2_dummy) bind(c, name = 'gridInqLcc2')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), intent(inout) :: earth_radius_dummy
+      real(c_double), intent(inout) :: lon_0_dummy
+      real(c_double), intent(inout) :: lat_0_dummy
+      real(c_double), intent(inout) :: lat_1_dummy
+      real(c_double), intent(inout) :: lat_2_dummy
+    end subroutine gridInqLcc2
+
+    subroutine gridDefLaea(gridID_dummy, earth_radius_dummy, lon_0_dummy,&
+    & lat_0_dummy) bind(c, name = 'gridDefLaea')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), value :: earth_radius_dummy
+      real(c_double), value :: lon_0_dummy
+      real(c_double), value :: lat_0_dummy
+    end subroutine gridDefLaea
+
+    subroutine gridInqLaea(gridID_dummy, earth_radius_dummy, lon_0_dummy,&
+    & lat_0_dummy) bind(c, name = 'gridInqLaea')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), intent(inout) :: earth_radius_dummy
+      real(c_double), intent(inout) :: lon_0_dummy
+      real(c_double), intent(inout) :: lat_0_dummy
+    end subroutine gridInqLaea
+
+    subroutine gridDefArea(gridID_dummy, area_dummy) bind(c, name =&
+    & 'gridDefArea')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), intent(in) :: area_dummy(*)
+    end subroutine gridDefArea
+
+    subroutine gridInqArea(gridID_dummy, area_dummy) bind(c, name =&
+    & 'gridInqArea')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), intent(inout) :: area_dummy(*)
+    end subroutine gridInqArea
+
+    function gridHasArea(gridID_dummy) bind(c, name = 'gridHasArea')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridHasArea
+
+    subroutine gridDefNvertex(gridID_dummy, nvertex_dummy) bind(c, name =&
+    & 'gridDefNvertex')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: nvertex_dummy
+    end subroutine gridDefNvertex
+
+    function gridInqNvertex(gridID_dummy) bind(c, name = 'gridInqNvertex')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqNvertex
+
+    subroutine gridDefXbounds(gridID_dummy, xbounds_dummy) bind(c, name =&
+    & 'gridDefXbounds')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), intent(in) :: xbounds_dummy(*)
+    end subroutine gridDefXbounds
+
+    function gridInqXbounds(gridID_dummy, xbounds_dummy) bind(c, name =&
+    & 'gridInqXbounds') result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), intent(inout) :: xbounds_dummy(*)
+      integer(c_int) :: f_result
+    end function gridInqXbounds
+
+    subroutine gridDefYbounds(gridID_dummy, ybounds_dummy) bind(c, name =&
+    & 'gridDefYbounds')
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), intent(in) :: ybounds_dummy(*)
+    end subroutine gridDefYbounds
+
+    function gridInqYbounds(gridID_dummy, ybounds_dummy) bind(c, name =&
+    & 'gridInqYbounds') result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: gridID_dummy
+      real(c_double), intent(inout) :: ybounds_dummy(*)
+      integer(c_int) :: f_result
+    end function gridInqYbounds
+
+    subroutine gridDefRowlon(gridID_dummy, nrowlon_dummy, rowlon_dummy) bind(c,&
+    & name = 'gridDefRowlon')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: nrowlon_dummy
+      integer(c_int), intent(in) :: rowlon_dummy(*)
+    end subroutine gridDefRowlon
+
+    subroutine gridInqRowlon(gridID_dummy, rowlon_dummy) bind(c, name =&
+    & 'gridInqRowlon')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), intent(inout) :: rowlon_dummy(*)
+    end subroutine gridInqRowlon
+
+    subroutine gridChangeType(gridID_dummy, gridtype_dummy) bind(c, name =&
+    & 'gridChangeType')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: gridtype_dummy
+    end subroutine gridChangeType
+
+    subroutine gridDefComplexPacking(gridID_dummy, lpack_dummy) bind(c, name =&
+    & 'gridDefComplexPacking')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: lpack_dummy
+    end subroutine gridDefComplexPacking
+
+    function gridInqComplexPacking(gridID_dummy) bind(c, name =&
+    & 'gridInqComplexPacking') result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function gridInqComplexPacking
+
+    function zaxisCreate(zaxistype_dummy, size_dummy) bind(c, name =&
+    & 'zaxisCreate') result(f_result)
+      import c_int
+      integer(c_int), value :: zaxistype_dummy
+      integer(c_int), value :: size_dummy
+      integer(c_int) :: f_result
+    end function zaxisCreate
+
+    subroutine zaxisDestroy(zaxisID_dummy) bind(c, name = 'zaxisDestroy')
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+    end subroutine zaxisDestroy
+
+    function zaxisInqType(zaxisID_dummy) bind(c, name = 'zaxisInqType')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int) :: f_result
+    end function zaxisInqType
+
+    function zaxisInqSize(zaxisID_dummy) bind(c, name = 'zaxisInqSize')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int) :: f_result
+    end function zaxisInqSize
+
+    function zaxisDuplicate(zaxisID_dummy) bind(c, name = 'zaxisDuplicate')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int) :: f_result
+    end function zaxisDuplicate
+
+    subroutine zaxisResize(zaxisID_dummy, size_dummy) bind(c, name =&
+    & 'zaxisResize')
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int), value :: size_dummy
+    end subroutine zaxisResize
+
+    subroutine zaxisPrint(zaxisID_dummy, index_dummy) bind(c, name =&
+    & 'zaxisPrint')
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int), value :: index_dummy
+    end subroutine zaxisPrint
+
+    subroutine zaxisDefLevels(zaxisID_dummy, levels_dummy) bind(c, name =&
+    & 'zaxisDefLevels')
+      import c_double, c_int
+      integer(c_int), value :: zaxisID_dummy
+      real(c_double), intent(in) :: levels_dummy(*)
+    end subroutine zaxisDefLevels
+
+    subroutine zaxisInqLevels(zaxisID_dummy, levels_dummy) bind(c, name =&
+    & 'zaxisInqLevels')
+      import c_double, c_int
+      integer(c_int), value :: zaxisID_dummy
+      real(c_double), intent(inout) :: levels_dummy(*)
+    end subroutine zaxisInqLevels
+
+    subroutine zaxisDefLevel(zaxisID_dummy, levelID_dummy, levels_dummy)&
+    & bind(c, name = 'zaxisDefLevel')
+      import c_double, c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int), value :: levelID_dummy
+      real(c_double), value :: levels_dummy
+    end subroutine zaxisDefLevel
+
+    function zaxisInqLevel(zaxisID_dummy, levelID_dummy) bind(c, name =&
+    & 'zaxisInqLevel') result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int), value :: levelID_dummy
+      real(c_double) :: f_result
+    end function zaxisInqLevel
+
+    subroutine zaxisDefNlevRef(gridID_dummy, nhlev_dummy) bind(c, name =&
+    & 'zaxisDefNlevRef')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: nhlev_dummy
+    end subroutine zaxisDefNlevRef
+
+    function zaxisInqNlevRef(gridID_dummy) bind(c, name = 'zaxisInqNlevRef')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function zaxisInqNlevRef
+
+    subroutine zaxisDefNumber(gridID_dummy, number_dummy) bind(c, name =&
+    & 'zaxisDefNumber')
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int), value :: number_dummy
+    end subroutine zaxisDefNumber
+
+    function zaxisInqNumber(gridID_dummy) bind(c, name = 'zaxisInqNumber')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: gridID_dummy
+      integer(c_int) :: f_result
+    end function zaxisInqNumber
+
+    subroutine zaxisDefUUID(zaxisID_dummy, uuid_dummy) bind(c, name =&
+    & 'zaxisDefUUID')
+      import CDI_UUID_SIZE, c_int, c_signed_char
+      integer(c_int), value :: zaxisID_dummy
+      integer(kind = c_signed_char), intent(in) :: uuid_dummy(CDI_UUID_SIZE)
+    end subroutine zaxisDefUUID
+
+    subroutine zaxisInqUUID(zaxisID_dummy, uuid_dummy) bind(c, name =&
+    & 'zaxisInqUUID')
+      import CDI_UUID_SIZE, c_int, c_signed_char
+      integer(c_int), value :: zaxisID_dummy
+      integer(kind = c_signed_char), intent(inout) :: uuid_dummy(CDI_UUID_SIZE)
+    end subroutine zaxisInqUUID
+
+    subroutine zaxisDefPrec(zaxisID_dummy, prec_dummy) bind(c, name =&
+    & 'zaxisDefPrec')
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int), value :: prec_dummy
+    end subroutine zaxisDefPrec
+
+    function zaxisInqPrec(zaxisID_dummy) bind(c, name = 'zaxisInqPrec')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int) :: f_result
+    end function zaxisInqPrec
+
+    subroutine zaxisDefPositive(zaxisID_dummy, positive_dummy) bind(c, name =&
+    & 'zaxisDefPositive')
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int), value :: positive_dummy
+    end subroutine zaxisDefPositive
+
+    function zaxisInqPositive(zaxisID_dummy) bind(c, name = 'zaxisInqPositive')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int) :: f_result
+    end function zaxisInqPositive
+
+    subroutine zaxisDefScalar(zaxisID_dummy) bind(c, name = 'zaxisDefScalar')
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+    end subroutine zaxisDefScalar
+
+    function zaxisInqScalar(zaxisID_dummy) bind(c, name = 'zaxisInqScalar')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int) :: f_result
+    end function zaxisInqScalar
+
+    subroutine zaxisDefLtype(zaxisID_dummy, ltype_dummy) bind(c, name =&
+    & 'zaxisDefLtype')
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int), value :: ltype_dummy
+    end subroutine zaxisDefLtype
+
+    function zaxisInqLtype(zaxisID_dummy) bind(c, name = 'zaxisInqLtype')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int) :: f_result
+    end function zaxisInqLtype
+
+    function zaxisInqLevelsPtr(zaxisID_dummy) bind(c, name =&
+    & 'zaxisInqLevelsPtr') result(f_result)
+      import c_int, c_ptr
+      integer(c_int), value :: zaxisID_dummy
+      type(c_ptr) :: f_result
+    end function zaxisInqLevelsPtr
+
+    subroutine zaxisDefVct(zaxisID_dummy, size_dummy, vct_dummy) bind(c, name =&
+    & 'zaxisDefVct')
+      import c_double, c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int), value :: size_dummy
+      real(c_double), intent(in) :: vct_dummy(*)
+    end subroutine zaxisDefVct
+
+    subroutine zaxisInqVct(zaxisID_dummy, vct_dummy) bind(c, name =&
+    & 'zaxisInqVct')
+      import c_double, c_int
+      integer(c_int), value :: zaxisID_dummy
+      real(c_double), intent(inout) :: vct_dummy(*)
+    end subroutine zaxisInqVct
+
+    function zaxisInqVctSize(zaxisID_dummy) bind(c, name = 'zaxisInqVctSize')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int) :: f_result
+    end function zaxisInqVctSize
+
+    function zaxisInqVctPtr(zaxisID_dummy) bind(c, name = 'zaxisInqVctPtr')&
+    & result(f_result)
+      import c_int, c_ptr
+      integer(c_int), value :: zaxisID_dummy
+      type(c_ptr) :: f_result
+    end function zaxisInqVctPtr
+
+    subroutine zaxisDefLbounds(zaxisID_dummy, lbounds_dummy) bind(c, name =&
+    & 'zaxisDefLbounds')
+      import c_double, c_int
+      integer(c_int), value :: zaxisID_dummy
+      real(c_double), intent(in) :: lbounds_dummy(*)
+    end subroutine zaxisDefLbounds
+
+    function zaxisInqLbound(zaxisID_dummy, index_dummy) bind(c, name =&
+    & 'zaxisInqLbound') result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int), value :: index_dummy
+      real(c_double) :: f_result
+    end function zaxisInqLbound
+
+    subroutine zaxisDefUbounds(zaxisID_dummy, ubounds_dummy) bind(c, name =&
+    & 'zaxisDefUbounds')
+      import c_double, c_int
+      integer(c_int), value :: zaxisID_dummy
+      real(c_double), intent(in) :: ubounds_dummy(*)
+    end subroutine zaxisDefUbounds
+
+    function zaxisInqUbound(zaxisID_dummy, index_dummy) bind(c, name =&
+    & 'zaxisInqUbound') result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int), value :: index_dummy
+      real(c_double) :: f_result
+    end function zaxisInqUbound
+
+    subroutine zaxisDefWeights(zaxisID_dummy, weights_dummy) bind(c, name =&
+    & 'zaxisDefWeights')
+      import c_double, c_int
+      integer(c_int), value :: zaxisID_dummy
+      real(c_double), intent(in) :: weights_dummy(*)
+    end subroutine zaxisDefWeights
+
+    subroutine zaxisChangeType(zaxisID_dummy, zaxistype_dummy) bind(c, name =&
+    & 'zaxisChangeType')
+      import c_int
+      integer(c_int), value :: zaxisID_dummy
+      integer(c_int), value :: zaxistype_dummy
+    end subroutine zaxisChangeType
+
+    function taxisCreate(timetype_dummy) bind(c, name = 'taxisCreate')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: timetype_dummy
+      integer(c_int) :: f_result
+    end function taxisCreate
+
+    subroutine taxisDestroy(taxisID_dummy) bind(c, name = 'taxisDestroy')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+    end subroutine taxisDestroy
+
+    function taxisDuplicate(taxisID_dummy) bind(c, name = 'taxisDuplicate')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int) :: f_result
+    end function taxisDuplicate
+
+    subroutine taxisCopyTimestep(taxisIDdes_dummy, taxisIDsrc_dummy) bind(c,&
+    & name = 'taxisCopyTimestep')
+      import c_int
+      integer(c_int), value :: taxisIDdes_dummy
+      integer(c_int), value :: taxisIDsrc_dummy
+    end subroutine taxisCopyTimestep
+
+    subroutine taxisDefType(taxisID_dummy, type_dummy) bind(c, name =&
+    & 'taxisDefType')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), value :: type_dummy
+    end subroutine taxisDefType
+
+    subroutine taxisDefVdate(taxisID_dummy, date_dummy) bind(c, name =&
+    & 'taxisDefVdate')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), value :: date_dummy
+    end subroutine taxisDefVdate
+
+    subroutine taxisDefVtime(taxisID_dummy, time_dummy) bind(c, name =&
+    & 'taxisDefVtime')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), value :: time_dummy
+    end subroutine taxisDefVtime
+
+    function taxisInqVdate(taxisID_dummy) bind(c, name = 'taxisInqVdate')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int) :: f_result
+    end function taxisInqVdate
+
+    function taxisInqVtime(taxisID_dummy) bind(c, name = 'taxisInqVtime')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int) :: f_result
+    end function taxisInqVtime
+
+    subroutine taxisDefRdate(taxisID_dummy, date_dummy) bind(c, name =&
+    & 'taxisDefRdate')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), value :: date_dummy
+    end subroutine taxisDefRdate
+
+    subroutine taxisDefRtime(taxisID_dummy, time_dummy) bind(c, name =&
+    & 'taxisDefRtime')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), value :: time_dummy
+    end subroutine taxisDefRtime
+
+    function taxisInqRdate(taxisID_dummy) bind(c, name = 'taxisInqRdate')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int) :: f_result
+    end function taxisInqRdate
+
+    function taxisInqRtime(taxisID_dummy) bind(c, name = 'taxisInqRtime')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int) :: f_result
+    end function taxisInqRtime
+
+    subroutine taxisDefFdate(taxisID_dummy, date_dummy) bind(c, name =&
+    & 'taxisDefFdate')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), value :: date_dummy
+    end subroutine taxisDefFdate
+
+    subroutine taxisDefFtime(taxisID_dummy, time_dummy) bind(c, name =&
+    & 'taxisDefFtime')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), value :: time_dummy
+    end subroutine taxisDefFtime
+
+    function taxisInqFdate(taxisID_dummy) bind(c, name = 'taxisInqFdate')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int) :: f_result
+    end function taxisInqFdate
+
+    function taxisInqFtime(taxisID_dummy) bind(c, name = 'taxisInqFtime')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int) :: f_result
+    end function taxisInqFtime
+
+    function taxisHasBounds(taxisID_dummy) bind(c, name = 'taxisHasBounds')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int) :: f_result
+    end function taxisHasBounds
+
+    subroutine taxisDeleteBounds(taxisID_dummy) bind(c, name =&
+    & 'taxisDeleteBounds')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+    end subroutine taxisDeleteBounds
+
+    subroutine taxisDefVdateBounds(taxisID_dummy, vdate_lb_dummy,&
+    & vdate_ub_dummy) bind(c, name = 'taxisDefVdateBounds')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), value :: vdate_lb_dummy
+      integer(c_int), value :: vdate_ub_dummy
+    end subroutine taxisDefVdateBounds
+
+    subroutine taxisDefVtimeBounds(taxisID_dummy, vtime_lb_dummy,&
+    & vtime_ub_dummy) bind(c, name = 'taxisDefVtimeBounds')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), value :: vtime_lb_dummy
+      integer(c_int), value :: vtime_ub_dummy
+    end subroutine taxisDefVtimeBounds
+
+    subroutine taxisInqVdateBounds(taxisID_dummy, vdate_lb_dummy,&
+    & vdate_ub_dummy) bind(c, name = 'taxisInqVdateBounds')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), intent(inout) :: vdate_lb_dummy
+      integer(c_int), intent(inout) :: vdate_ub_dummy
+    end subroutine taxisInqVdateBounds
+
+    subroutine taxisInqVtimeBounds(taxisID_dummy, vtime_lb_dummy,&
+    & vtime_ub_dummy) bind(c, name = 'taxisInqVtimeBounds')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), intent(inout) :: vtime_lb_dummy
+      integer(c_int), intent(inout) :: vtime_ub_dummy
+    end subroutine taxisInqVtimeBounds
+
+    subroutine taxisDefCalendar(taxisID_dummy, calendar_dummy) bind(c, name =&
+    & 'taxisDefCalendar')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), value :: calendar_dummy
+    end subroutine taxisDefCalendar
+
+    function taxisInqCalendar(taxisID_dummy) bind(c, name = 'taxisInqCalendar')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int) :: f_result
+    end function taxisInqCalendar
+
+    subroutine taxisDefTunit(taxisID_dummy, tunit_dummy) bind(c, name =&
+    & 'taxisDefTunit')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), value :: tunit_dummy
+    end subroutine taxisDefTunit
+
+    function taxisInqTunit(taxisID_dummy) bind(c, name = 'taxisInqTunit')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int) :: f_result
+    end function taxisInqTunit
+
+    subroutine taxisDefForecastTunit(taxisID_dummy, tunit_dummy) bind(c, name =&
+    & 'taxisDefForecastTunit')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), value :: tunit_dummy
+    end subroutine taxisDefForecastTunit
+
+    function taxisInqForecastTunit(taxisID_dummy) bind(c, name =&
+    & 'taxisInqForecastTunit') result(f_result)
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int) :: f_result
+    end function taxisInqForecastTunit
+
+    subroutine taxisDefForecastPeriod(taxisID_dummy, fc_period_dummy) bind(c,&
+    & name = 'taxisDefForecastPeriod')
+      import c_double, c_int
+      integer(c_int), value :: taxisID_dummy
+      real(c_double), value :: fc_period_dummy
+    end subroutine taxisDefForecastPeriod
+
+    function taxisInqForecastPeriod(taxisID_dummy) bind(c, name =&
+    & 'taxisInqForecastPeriod') result(f_result)
+      import c_double, c_int
+      integer(c_int), value :: taxisID_dummy
+      real(c_double) :: f_result
+    end function taxisInqForecastPeriod
+
+    subroutine taxisDefNumavg(taxisID_dummy, numavg_dummy) bind(c, name =&
+    & 'taxisDefNumavg')
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int), value :: numavg_dummy
+    end subroutine taxisDefNumavg
+
+    function taxisInqType(taxisID_dummy) bind(c, name = 'taxisInqType')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int) :: f_result
+    end function taxisInqType
+
+    function taxisInqNumavg(taxisID_dummy) bind(c, name = 'taxisInqNumavg')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: taxisID_dummy
+      integer(c_int) :: f_result
+    end function taxisInqNumavg
+
+    function institutInqNumber() bind(c, name = 'institutInqNumber')&
+    & result(f_result)
+      import c_int
+      integer(c_int) :: f_result
+    end function institutInqNumber
+
+    function institutInqCenter(instID_dummy) bind(c, name =&
+    & 'institutInqCenter') result(f_result)
+      import c_int
+      integer(c_int), value :: instID_dummy
+      integer(c_int) :: f_result
+    end function institutInqCenter
+
+    function institutInqSubcenter(instID_dummy) bind(c, name =&
+    & 'institutInqSubcenter') result(f_result)
+      import c_int
+      integer(c_int), value :: instID_dummy
+      integer(c_int) :: f_result
+    end function institutInqSubcenter
+
+    function modelInqInstitut(modelID_dummy) bind(c, name = 'modelInqInstitut')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: modelID_dummy
+      integer(c_int) :: f_result
+    end function modelInqInstitut
+
+    function modelInqGribID(modelID_dummy) bind(c, name = 'modelInqGribID')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: modelID_dummy
+      integer(c_int) :: f_result
+    end function modelInqGribID
+
+    function tableInqNumber() bind(c, name = 'tableInqNumber') result(f_result)
+      import c_int
+      integer(c_int) :: f_result
+    end function tableInqNumber
+
+    function tableInqNum(tableID_dummy) bind(c, name = 'tableInqNum')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: tableID_dummy
+      integer(c_int) :: f_result
+    end function tableInqNum
+
+    function tableInqModel(tableID_dummy) bind(c, name = 'tableInqModel')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: tableID_dummy
+      integer(c_int) :: f_result
+    end function tableInqModel
+
+    function streamInqHistorySize(streamID_dummy) bind(c, name =&
+    & 'streamInqHistorySize') result(f_result)
+      import c_int
+      integer(c_int), value :: streamID_dummy
+      integer(c_int) :: f_result
+    end function streamInqHistorySize
+
+    function subtypeCreate(subtype_dummy) bind(c, name = 'subtypeCreate')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: subtype_dummy
+      integer(c_int) :: f_result
+    end function subtypeCreate
+
+    subroutine subtypePrint(subtypeID_dummy) bind(c, name = 'subtypePrint')
+      import c_int
+      integer(c_int), value :: subtypeID_dummy
+    end subroutine subtypePrint
+
+    function subtypeCompare(subtypeID1_dummy, subtypeID2_dummy) bind(c, name =&
+    & 'subtypeCompare') result(f_result)
+      import c_int
+      integer(c_int), value :: subtypeID1_dummy
+      integer(c_int), value :: subtypeID2_dummy
+      integer(c_int) :: f_result
+    end function subtypeCompare
+
+    function subtypeInqSize(subtypeID_dummy) bind(c, name = 'subtypeInqSize')&
+    & result(f_result)
+      import c_int
+      integer(c_int), value :: subtypeID_dummy
+      integer(c_int) :: f_result
+    end function subtypeInqSize
+
+    function subtypeInqActiveIndex(subtypeID_dummy) bind(c, name =&
+    & 'subtypeInqActiveIndex') result(f_result)
+      import c_int
+      integer(c_int), value :: subtypeID_dummy
+      integer(c_int) :: f_result
+    end function subtypeInqActiveIndex
+
+    subroutine subtypeDefActiveIndex(subtypeID_dummy, index_dummy) bind(c, name&
+    & = 'subtypeDefActiveIndex')
+      import c_int
+      integer(c_int), value :: subtypeID_dummy
+      integer(c_int), value :: index_dummy
+    end subroutine subtypeDefActiveIndex
+
+    function subtypeInqTile(subtypeID_dummy, tileindex_dummy, attribute_dummy)&
+    & bind(c, name = 'subtypeInqTile') result(f_result)
+      import c_int
+      integer(c_int), value :: subtypeID_dummy
+      integer(c_int), value :: tileindex_dummy
+      integer(c_int), value :: attribute_dummy
+      integer(c_int) :: f_result
+    end function subtypeInqTile
+
+    function vlistInqVarSubtype(vlistID_dummy, varID_dummy) bind(c, name =&
+    & 'vlistInqVarSubtype') result(f_result)
+      import c_int
+      integer(c_int), value :: vlistID_dummy
+      integer(c_int), value :: varID_dummy
+      integer(c_int) :: f_result
+    end function vlistInqVarSubtype
+
+    subroutine gribapiLibraryVersion(major_version_dummy, minor_version_dummy,&
+    & revision_version_dummy) bind(c, name = 'gribapiLibraryVersion')
+      import c_int
+      integer(c_int), intent(inout) :: major_version_dummy
+      integer(c_int), intent(inout) :: minor_version_dummy
+      integer(c_int), intent(inout) :: revision_version_dummy
+    end subroutine gribapiLibraryVersion
+
+  end interface
 
 contains
 
-	subroutine ctrim(str)
-		character(kind = c_char, len = *), intent(inout) :: str
-		integer :: i
-
-		do i=1,len(str)
-			if (str(i:i) == c_null_char) then
-				str(i:len(str)) = ' '
-				exit
-			end if
-		end do
-	end subroutine ctrim
-
-	function c_len(s) result(i)
-		character(kind = c_char, len = *), intent(in) :: s
-		integer :: i
-
-		do i = 1, len(s)
-			if (s(i:i) == c_null_char) exit
-		end do
-		i = i - 1
-	end function
-
-	subroutine cdiReset()
-		interface
-			subroutine lib_cdiReset() bind(c, name = 'cdiReset')
-			end subroutine lib_cdiReset
-		end interface
-		call lib_cdiReset()
-	end subroutine cdiReset
-
-	function cdiStringError(cdiErrno_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		integer(c_int), value :: cdiErrno_dummy
-		type(c_ptr) :: ptr
-		integer :: shape(1)
-		interface
-			type(c_ptr) function lib_cdiStringError(cdiErrno_dummy) bind(c, name = 'cdiStringError')
-				import c_int, c_ptr
-				integer(c_int), value :: cdiErrno_dummy
-			end function lib_cdiStringError
-		end interface
-		result => null()
-		ptr = lib_cdiStringError(cdiErrno_dummy)
-		if(c_associated(ptr)) then
-			shape(1) = int(lib_strlen(ptr))
-			call c_f_pointer(ptr, result, shape)
-		end if
-	end function cdiStringError
-
-	subroutine cdiDebug(debug_dummy)
-		integer(c_int), value :: debug_dummy
-		interface
-			subroutine lib_cdiDebug(debug_dummy) bind(c, name = 'cdiDebug')
-				import c_int
-				integer(c_int), value :: debug_dummy
-			end subroutine lib_cdiDebug
-		end interface
-		call lib_cdiDebug(debug_dummy)
-	end subroutine cdiDebug
-
-	function cdiLibraryVersion() result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		type(c_ptr) :: ptr
-		integer :: shape(1)
-		interface
-			type(c_ptr) function lib_cdiLibraryVersion() bind(c, name = 'cdiLibraryVersion')
-				import c_ptr
-			end function lib_cdiLibraryVersion
-		end interface
-		result => null()
-		ptr = lib_cdiLibraryVersion()
-		if(c_associated(ptr)) then
-			shape(1) = int(lib_strlen(ptr))
-			call c_f_pointer(ptr, result, shape)
-		end if
-	end function cdiLibraryVersion
-
-	subroutine cdiPrintVersion()
-		interface
-			subroutine lib_cdiPrintVersion() bind(c, name = 'cdiPrintVersion')
-			end subroutine lib_cdiPrintVersion
-		end interface
-		call lib_cdiPrintVersion()
-	end subroutine cdiPrintVersion
-
-	function cdiHaveFiletype(filetype_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: filetype_dummy
-		interface
-			integer(c_int) function lib_cdiHaveFiletype(filetype_dummy) bind(c, name = 'cdiHaveFiletype')
-				import c_int
-				integer(c_int), value :: filetype_dummy
-			end function lib_cdiHaveFiletype
-		end interface
-		result = lib_cdiHaveFiletype(filetype_dummy)
-	end function cdiHaveFiletype
-
-	subroutine cdiDefMissval(missval_dummy)
-		real(c_double), value :: missval_dummy
-		interface
-			subroutine lib_cdiDefMissval(missval_dummy) bind(c, name = 'cdiDefMissval')
-				import c_double
-				real(c_double), value :: missval_dummy
-			end subroutine lib_cdiDefMissval
-		end interface
-		call lib_cdiDefMissval(missval_dummy)
-	end subroutine cdiDefMissval
-
-	function cdiInqMissval() result(result)
-		real(c_double) :: result
-		interface
-			real(c_double) function lib_cdiInqMissval() bind(c, name = 'cdiInqMissval')
-				import c_double
-			end function lib_cdiInqMissval
-		end interface
-		result = lib_cdiInqMissval()
-	end function cdiInqMissval
-
-	subroutine cdiDefGlobal(string_dummy, val_dummy)
-		character(kind = c_char, len = *), intent(in) :: string_dummy
-		integer(c_int), value :: val_dummy
-		character(kind = c_char) :: string_temp(len(string_dummy) + 1)
-		integer :: string_i
-		interface
-			subroutine lib_cdiDefGlobal(string_dummy, val_dummy) bind(c, name = 'cdiDefGlobal')
-				import c_char, c_int
-				character(kind = c_char) :: string_dummy(*)
-				integer(c_int), value :: val_dummy
-			end subroutine lib_cdiDefGlobal
-		end interface
-		do string_i = 1, len(string_dummy)
-		string_temp(string_i) = string_dummy(string_i:string_i)
-		end do
-		string_temp(len(string_dummy) + 1) = c_null_char
-		call lib_cdiDefGlobal(string_temp, val_dummy)
-	end subroutine cdiDefGlobal
-
-	function namespaceNew() result(result)
-		integer(c_int) :: result
-		interface
-			integer(c_int) function lib_namespaceNew() bind(c, name = 'namespaceNew')
-				import c_int
-			end function lib_namespaceNew
-		end interface
-		result = lib_namespaceNew()
-	end function namespaceNew
-
-	subroutine namespaceSetActive(namespaceID_dummy)
-		integer(c_int), value :: namespaceID_dummy
-		interface
-			subroutine lib_namespaceSetActive(namespaceID_dummy) bind(c, name = 'namespaceSetActive')
-				import c_int
-				integer(c_int), value :: namespaceID_dummy
-			end subroutine lib_namespaceSetActive
-		end interface
-		call lib_namespaceSetActive(namespaceID_dummy)
-	end subroutine namespaceSetActive
-
-	subroutine namespaceDelete(namespaceID_dummy)
-		integer(c_int), value :: namespaceID_dummy
-		interface
-			subroutine lib_namespaceDelete(namespaceID_dummy) bind(c, name = 'namespaceDelete')
-				import c_int
-				integer(c_int), value :: namespaceID_dummy
-			end subroutine lib_namespaceDelete
-		end interface
-		call lib_namespaceDelete(namespaceID_dummy)
-	end subroutine namespaceDelete
-
-	subroutine cdiParamToString(param_dummy, paramstr_dummy, maxlen_dummy)
-		integer(c_int), value :: param_dummy
-		character(kind = c_char, len = *), intent(inout) :: paramstr_dummy
-		integer(c_int), value :: maxlen_dummy
-		character(kind = c_char) :: paramstr_temp(len(paramstr_dummy))
-		integer :: paramstr_i
-		logical :: paramstr_padding = .true.
-		interface
-			subroutine lib_cdiParamToString(param_dummy, paramstr_dummy, maxlen_dummy) bind(c, name = 'cdiParamToString')
-				import c_char, c_int
-				integer(c_int), value :: param_dummy
-				character(kind = c_char) :: paramstr_dummy(*)
-				integer(c_int), value :: maxlen_dummy
-			end subroutine lib_cdiParamToString
-		end interface
-		do paramstr_i = len(paramstr_dummy), 1, -1
-			if(paramstr_dummy(paramstr_i:paramstr_i) /= ' ') paramstr_padding = .false.
-			if(paramstr_padding) then
-				paramstr_temp(paramstr_i) = c_null_char
-			else
-				paramstr_temp(paramstr_i) = paramstr_dummy(paramstr_i:paramstr_i)
-			end if
-		end do
-		call lib_cdiParamToString(param_dummy, paramstr_temp, maxlen_dummy)
-		paramstr_padding = .false.
-		do paramstr_i = 1, len(paramstr_dummy)
-			if(paramstr_temp(paramstr_i) == c_null_char) paramstr_padding = .true.
-			if(paramstr_padding) then
-				paramstr_dummy(paramstr_i:paramstr_i) = ' '
-			else
-				paramstr_dummy(paramstr_i:paramstr_i) = paramstr_temp(paramstr_i)
-			end if
-		end do
-	end subroutine cdiParamToString
-
-	subroutine cdiDecodeParam(param_dummy, pnum, pcat, pdis)
-		integer(c_int), value :: param_dummy
-		integer(c_int), optional, intent(inout) :: pnum
-		integer(c_int), optional, intent(inout) :: pcat
-		integer(c_int), optional, intent(inout) :: pdis
-		integer(c_int), target :: pnum_temp
-		type(c_ptr) :: pnum_ptr
-		integer(c_int), target :: pcat_temp
-		type(c_ptr) :: pcat_ptr
-		integer(c_int), target :: pdis_temp
-		type(c_ptr) :: pdis_ptr
-		interface
-			subroutine lib_cdiDecodeParam(param_dummy, pnum, pcat, pdis) bind(c, name = 'cdiDecodeParam')
-				import c_int, c_ptr
-				integer(c_int), value :: param_dummy
-				type(c_ptr), value :: pnum
-				type(c_ptr), value :: pcat
-				type(c_ptr), value :: pdis
-			end subroutine lib_cdiDecodeParam
-		end interface
-		pnum_ptr = c_null_ptr
-		if(present(pnum)) pnum_ptr = c_loc(pnum_temp)
-		pcat_ptr = c_null_ptr
-		if(present(pcat)) pcat_ptr = c_loc(pcat_temp)
-		pdis_ptr = c_null_ptr
-		if(present(pdis)) pdis_ptr = c_loc(pdis_temp)
-		call lib_cdiDecodeParam(param_dummy, pnum_ptr, pcat_ptr, pdis_ptr)
-		if(present(pnum)) pnum = pnum_temp
-		if(present(pcat)) pcat = pcat_temp
-		if(present(pdis)) pdis = pdis_temp
-	end subroutine cdiDecodeParam
-
-	function cdiEncodeParam(pnum_dummy, pcat_dummy, pdis_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: pnum_dummy
-		integer(c_int), value :: pcat_dummy
-		integer(c_int), value :: pdis_dummy
-		interface
-			integer(c_int) function lib_cdiEncodeParam(pnum_dummy, pcat_dummy, pdis_dummy) bind(c, name = 'cdiEncodeParam')
-				import c_int
-				integer(c_int), value :: pnum_dummy
-				integer(c_int), value :: pcat_dummy
-				integer(c_int), value :: pdis_dummy
-			end function lib_cdiEncodeParam
-		end interface
-		result = lib_cdiEncodeParam(pnum_dummy, pcat_dummy, pdis_dummy)
-	end function cdiEncodeParam
-
-	subroutine cdiDecodeDate(date_dummy, year, month, day)
-		integer(c_int), value :: date_dummy
-		integer(c_int), optional, intent(inout) :: year
-		integer(c_int), optional, intent(inout) :: month
-		integer(c_int), optional, intent(inout) :: day
-		integer(c_int), target :: year_temp
-		type(c_ptr) :: year_ptr
-		integer(c_int), target :: month_temp
-		type(c_ptr) :: month_ptr
-		integer(c_int), target :: day_temp
-		type(c_ptr) :: day_ptr
-		interface
-			subroutine lib_cdiDecodeDate(date_dummy, year, month, day) bind(c, name = 'cdiDecodeDate')
-				import c_int, c_ptr
-				integer(c_int), value :: date_dummy
-				type(c_ptr), value :: year
-				type(c_ptr), value :: month
-				type(c_ptr), value :: day
-			end subroutine lib_cdiDecodeDate
-		end interface
-		year_ptr = c_null_ptr
-		if(present(year)) year_ptr = c_loc(year_temp)
-		month_ptr = c_null_ptr
-		if(present(month)) month_ptr = c_loc(month_temp)
-		day_ptr = c_null_ptr
-		if(present(day)) day_ptr = c_loc(day_temp)
-		call lib_cdiDecodeDate(date_dummy, year_ptr, month_ptr, day_ptr)
-		if(present(year)) year = year_temp
-		if(present(month)) month = month_temp
-		if(present(day)) day = day_temp
-	end subroutine cdiDecodeDate
-
-	function cdiEncodeDate(year_dummy, month_dummy, day_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: year_dummy
-		integer(c_int), value :: month_dummy
-		integer(c_int), value :: day_dummy
-		interface
-			integer(c_int) function lib_cdiEncodeDate(year_dummy, month_dummy, day_dummy) bind(c, name = 'cdiEncodeDate')
-				import c_int
-				integer(c_int), value :: year_dummy
-				integer(c_int), value :: month_dummy
-				integer(c_int), value :: day_dummy
-			end function lib_cdiEncodeDate
-		end interface
-		result = lib_cdiEncodeDate(year_dummy, month_dummy, day_dummy)
-	end function cdiEncodeDate
-
-	subroutine cdiDecodeTime(time_dummy, hour, minute, second)
-		integer(c_int), value :: time_dummy
-		integer(c_int), optional, intent(inout) :: hour
-		integer(c_int), optional, intent(inout) :: minute
-		integer(c_int), optional, intent(inout) :: second
-		integer(c_int), target :: hour_temp
-		type(c_ptr) :: hour_ptr
-		integer(c_int), target :: minute_temp
-		type(c_ptr) :: minute_ptr
-		integer(c_int), target :: second_temp
-		type(c_ptr) :: second_ptr
-		interface
-			subroutine lib_cdiDecodeTime(time_dummy, hour, minute, second) bind(c, name = 'cdiDecodeTime')
-				import c_int, c_ptr
-				integer(c_int), value :: time_dummy
-				type(c_ptr), value :: hour
-				type(c_ptr), value :: minute
-				type(c_ptr), value :: second
-			end subroutine lib_cdiDecodeTime
-		end interface
-		hour_ptr = c_null_ptr
-		if(present(hour)) hour_ptr = c_loc(hour_temp)
-		minute_ptr = c_null_ptr
-		if(present(minute)) minute_ptr = c_loc(minute_temp)
-		second_ptr = c_null_ptr
-		if(present(second)) second_ptr = c_loc(second_temp)
-		call lib_cdiDecodeTime(time_dummy, hour_ptr, minute_ptr, second_ptr)
-		if(present(hour)) hour = hour_temp
-		if(present(minute)) minute = minute_temp
-		if(present(second)) second = second_temp
-	end subroutine cdiDecodeTime
-
-	function cdiEncodeTime(hour_dummy, minute_dummy, second_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: hour_dummy
-		integer(c_int), value :: minute_dummy
-		integer(c_int), value :: second_dummy
-		interface
-			integer(c_int) function lib_cdiEncodeTime(hour_dummy, minute_dummy, second_dummy) bind(c, name = 'cdiEncodeTime')
-				import c_int
-				integer(c_int), value :: hour_dummy
-				integer(c_int), value :: minute_dummy
-				integer(c_int), value :: second_dummy
-			end function lib_cdiEncodeTime
-		end interface
-		result = lib_cdiEncodeTime(hour_dummy, minute_dummy, second_dummy)
-	end function cdiEncodeTime
-
-	function cdiGetFiletype(path_dummy, byteorder) result(result)
-		integer(c_int) :: result
-		character(kind = c_char, len = *), intent(in) :: path_dummy
-		integer(c_int), optional, intent(inout) :: byteorder
-		character(kind = c_char) :: path_temp(len(path_dummy) + 1)
-		integer :: path_i
-		integer(c_int), target :: byteorder_temp
-		type(c_ptr) :: byteorder_ptr
-		interface
-			integer(c_int) function lib_cdiGetFiletype(path_dummy, byteorder) bind(c, name = 'cdiGetFiletype')
-				import c_char, c_int, c_ptr
-				character(kind = c_char) :: path_dummy(*)
-				type(c_ptr), value :: byteorder
-			end function lib_cdiGetFiletype
-		end interface
-		do path_i = 1, len(path_dummy)
-		path_temp(path_i) = path_dummy(path_i:path_i)
-		end do
-		path_temp(len(path_dummy) + 1) = c_null_char
-		byteorder_ptr = c_null_ptr
-		if(present(byteorder)) byteorder_ptr = c_loc(byteorder_temp)
-		result = lib_cdiGetFiletype(path_temp, byteorder_ptr)
-		if(present(byteorder)) byteorder = byteorder_temp
-	end function cdiGetFiletype
-
-	function streamOpenRead(path_dummy) result(result)
-		integer(c_int) :: result
-		character(kind = c_char, len = *), intent(in) :: path_dummy
-		character(kind = c_char) :: path_temp(len(path_dummy) + 1)
-		integer :: path_i
-		interface
-			integer(c_int) function lib_streamOpenRead(path_dummy) bind(c, name = 'streamOpenRead')
-				import c_char, c_int
-				character(kind = c_char) :: path_dummy(*)
-			end function lib_streamOpenRead
-		end interface
-		do path_i = 1, len(path_dummy)
-		path_temp(path_i) = path_dummy(path_i:path_i)
-		end do
-		path_temp(len(path_dummy) + 1) = c_null_char
-		result = lib_streamOpenRead(path_temp)
-	end function streamOpenRead
-
-	function streamOpenWrite(path_dummy, filetype_dummy) result(result)
-		integer(c_int) :: result
-		character(kind = c_char, len = *), intent(in) :: path_dummy
-		integer(c_int), value :: filetype_dummy
-		character(kind = c_char) :: path_temp(len(path_dummy) + 1)
-		integer :: path_i
-		interface
-			integer(c_int) function lib_streamOpenWrite(path_dummy, filetype_dummy) bind(c, name = 'streamOpenWrite')
-				import c_char, c_int
-				character(kind = c_char) :: path_dummy(*)
-				integer(c_int), value :: filetype_dummy
-			end function lib_streamOpenWrite
-		end interface
-		do path_i = 1, len(path_dummy)
-		path_temp(path_i) = path_dummy(path_i:path_i)
-		end do
-		path_temp(len(path_dummy) + 1) = c_null_char
-		result = lib_streamOpenWrite(path_temp, filetype_dummy)
-	end function streamOpenWrite
-
-	function streamOpenAppend(path_dummy) result(result)
-		integer(c_int) :: result
-		character(kind = c_char, len = *), intent(in) :: path_dummy
-		character(kind = c_char) :: path_temp(len(path_dummy) + 1)
-		integer :: path_i
-		interface
-			integer(c_int) function lib_streamOpenAppend(path_dummy) bind(c, name = 'streamOpenAppend')
-				import c_char, c_int
-				character(kind = c_char) :: path_dummy(*)
-			end function lib_streamOpenAppend
-		end interface
-		do path_i = 1, len(path_dummy)
-		path_temp(path_i) = path_dummy(path_i:path_i)
-		end do
-		path_temp(len(path_dummy) + 1) = c_null_char
-		result = lib_streamOpenAppend(path_temp)
-	end function streamOpenAppend
-
-	subroutine streamClose(streamID_dummy)
-		integer(c_int), value :: streamID_dummy
-		interface
-			subroutine lib_streamClose(streamID_dummy) bind(c, name = 'streamClose')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-			end subroutine lib_streamClose
-		end interface
-		call lib_streamClose(streamID_dummy)
-	end subroutine streamClose
-
-	subroutine streamSync(streamID_dummy)
-		integer(c_int), value :: streamID_dummy
-		interface
-			subroutine lib_streamSync(streamID_dummy) bind(c, name = 'streamSync')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-			end subroutine lib_streamSync
-		end interface
-		call lib_streamSync(streamID_dummy)
-	end subroutine streamSync
-
-	subroutine streamDefVlist(streamID_dummy, vlistID_dummy)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: vlistID_dummy
-		interface
-			subroutine lib_streamDefVlist(streamID_dummy, vlistID_dummy) bind(c, name = 'streamDefVlist')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: vlistID_dummy
-			end subroutine lib_streamDefVlist
-		end interface
-		call lib_streamDefVlist(streamID_dummy, vlistID_dummy)
-	end subroutine streamDefVlist
-
-	function streamInqVlist(streamID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: streamID_dummy
-		interface
-			integer(c_int) function lib_streamInqVlist(streamID_dummy) bind(c, name = 'streamInqVlist')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-			end function lib_streamInqVlist
-		end interface
-		result = lib_streamInqVlist(streamID_dummy)
-	end function streamInqVlist
-
-	function streamInqVlistIDorig(streamID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: streamID_dummy
-		interface
-			integer(c_int) function lib_streamInqVlistIDorig(streamID_dummy) bind(c, name = 'streamInqVlistIDorig')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-			end function lib_streamInqVlistIDorig
-		end interface
-		result = lib_streamInqVlistIDorig(streamID_dummy)
-	end function streamInqVlistIDorig
-
-	function streamInqFiletype(streamID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: streamID_dummy
-		interface
-			integer(c_int) function lib_streamInqFiletype(streamID_dummy) bind(c, name = 'streamInqFiletype')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-			end function lib_streamInqFiletype
-		end interface
-		result = lib_streamInqFiletype(streamID_dummy)
-	end function streamInqFiletype
-
-	subroutine streamDefByteorder(streamID_dummy, byteorder_dummy)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: byteorder_dummy
-		interface
-			subroutine lib_streamDefByteorder(streamID_dummy, byteorder_dummy) bind(c, name = 'streamDefByteorder')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: byteorder_dummy
-			end subroutine lib_streamDefByteorder
-		end interface
-		call lib_streamDefByteorder(streamID_dummy, byteorder_dummy)
-	end subroutine streamDefByteorder
-
-	function streamInqByteorder(streamID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: streamID_dummy
-		interface
-			integer(c_int) function lib_streamInqByteorder(streamID_dummy) bind(c, name = 'streamInqByteorder')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-			end function lib_streamInqByteorder
-		end interface
-		result = lib_streamInqByteorder(streamID_dummy)
-	end function streamInqByteorder
-
-	subroutine streamDefCompType(streamID_dummy, comptype_dummy)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: comptype_dummy
-		interface
-			subroutine lib_streamDefCompType(streamID_dummy, comptype_dummy) bind(c, name = 'streamDefCompType')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: comptype_dummy
-			end subroutine lib_streamDefCompType
-		end interface
-		call lib_streamDefCompType(streamID_dummy, comptype_dummy)
-	end subroutine streamDefCompType
-
-	function streamInqCompType(streamID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: streamID_dummy
-		interface
-			integer(c_int) function lib_streamInqCompType(streamID_dummy) bind(c, name = 'streamInqCompType')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-			end function lib_streamInqCompType
-		end interface
-		result = lib_streamInqCompType(streamID_dummy)
-	end function streamInqCompType
-
-	subroutine streamDefCompLevel(streamID_dummy, complevel_dummy)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: complevel_dummy
-		interface
-			subroutine lib_streamDefCompLevel(streamID_dummy, complevel_dummy) bind(c, name = 'streamDefCompLevel')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: complevel_dummy
-			end subroutine lib_streamDefCompLevel
-		end interface
-		call lib_streamDefCompLevel(streamID_dummy, complevel_dummy)
-	end subroutine streamDefCompLevel
-
-	function streamInqCompLevel(streamID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: streamID_dummy
-		interface
-			integer(c_int) function lib_streamInqCompLevel(streamID_dummy) bind(c, name = 'streamInqCompLevel')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-			end function lib_streamInqCompLevel
-		end interface
-		result = lib_streamInqCompLevel(streamID_dummy)
-	end function streamInqCompLevel
-
-	function streamDefTimestep(streamID_dummy, tsID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: tsID_dummy
-		interface
-			integer(c_int) function lib_streamDefTimestep(streamID_dummy, tsID_dummy) bind(c, name = 'streamDefTimestep')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: tsID_dummy
-			end function lib_streamDefTimestep
-		end interface
-		result = lib_streamDefTimestep(streamID_dummy, tsID_dummy)
-	end function streamDefTimestep
-
-	function streamInqTimestep(streamID_dummy, tsID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: tsID_dummy
-		interface
-			integer(c_int) function lib_streamInqTimestep(streamID_dummy, tsID_dummy) bind(c, name = 'streamInqTimestep')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: tsID_dummy
-			end function lib_streamInqTimestep
-		end interface
-		result = lib_streamInqTimestep(streamID_dummy, tsID_dummy)
-	end function streamInqTimestep
-
-	function streamInqCurTimestepID(streamID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: streamID_dummy
-		interface
-			integer(c_int) function lib_streamInqCurTimestepID(streamID_dummy) bind(c, name = 'streamInqCurTimestepID')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-			end function lib_streamInqCurTimestepID
-		end interface
-		result = lib_streamInqCurTimestepID(streamID_dummy)
-	end function streamInqCurTimestepID
-
-	function streamFilename(streamID_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		integer(c_int), value :: streamID_dummy
-		type(c_ptr) :: ptr
-		integer :: shape(1)
-		interface
-			type(c_ptr) function lib_streamFilename(streamID_dummy) bind(c, name = 'streamFilename')
-				import c_int, c_ptr
-				integer(c_int), value :: streamID_dummy
-			end function lib_streamFilename
-		end interface
-		result => null()
-		ptr = lib_streamFilename(streamID_dummy)
-		if(c_associated(ptr)) then
-			shape(1) = int(lib_strlen(ptr))
-			call c_f_pointer(ptr, result, shape)
-		end if
-	end function streamFilename
-
-	function streamFilesuffix(filetype_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		integer(c_int), value :: filetype_dummy
-		type(c_ptr) :: ptr
-		integer :: shape(1)
-		interface
-			type(c_ptr) function lib_streamFilesuffix(filetype_dummy) bind(c, name = 'streamFilesuffix')
-				import c_int, c_ptr
-				integer(c_int), value :: filetype_dummy
-			end function lib_streamFilesuffix
-		end interface
-		result => null()
-		ptr = lib_streamFilesuffix(filetype_dummy)
-		if(c_associated(ptr)) then
-			shape(1) = int(lib_strlen(ptr))
-			call c_f_pointer(ptr, result, shape)
-		end if
-	end function streamFilesuffix
-
-	function streamInqNvars(streamID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: streamID_dummy
-		interface
-			integer(c_int) function lib_streamInqNvars(streamID_dummy) bind(c, name = 'streamInqNvars')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-			end function lib_streamInqNvars
-		end interface
-		result = lib_streamInqNvars(streamID_dummy)
-	end function streamInqNvars
-
-	subroutine streamWriteVar(streamID_dummy, varID_dummy, data_vec_dummy, nmiss_dummy)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: varID_dummy
-		real(c_double), intent(in) :: data_vec_dummy(*)
-		integer(c_int), value :: nmiss_dummy
-		interface
-			subroutine lib_streamWriteVar(streamID_dummy, varID_dummy, data_vec_dummy, nmiss_dummy) bind(c, name = 'streamWriteVar')
-				import c_double, c_int
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: varID_dummy
-				real(c_double), intent(in) :: data_vec_dummy(*)
-				integer(c_int), value :: nmiss_dummy
-			end subroutine lib_streamWriteVar
-		end interface
-		call lib_streamWriteVar(streamID_dummy, varID_dummy, data_vec_dummy, nmiss_dummy)
-	end subroutine streamWriteVar
-
-	subroutine streamWriteVarF(streamID_dummy, varID_dummy, data_vec_dummy, nmiss_dummy)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: varID_dummy
-		real(c_float), intent(in) :: data_vec_dummy(*)
-		integer(c_int), value :: nmiss_dummy
-		interface
-			subroutine lib_streamWriteVarF(streamID_dummy, varID_dummy, data_vec_dummy, nmiss_dummy) bind(c, name = 'streamWriteVarF')
-				import c_float, c_int
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: varID_dummy
-				real(c_float), intent(in) :: data_vec_dummy(*)
-				integer(c_int), value :: nmiss_dummy
-			end subroutine lib_streamWriteVarF
-		end interface
-		call lib_streamWriteVarF(streamID_dummy, varID_dummy, data_vec_dummy, nmiss_dummy)
-	end subroutine streamWriteVarF
-
-	subroutine streamReadVar(streamID_dummy, varID_dummy, data_vec_dummy, nmiss)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: varID_dummy
-		real(c_double), intent(inout) :: data_vec_dummy(*)
-		integer(c_int), optional, intent(inout) :: nmiss
-		integer(c_int), target :: nmiss_temp
-		type(c_ptr) :: nmiss_ptr
-		interface
-			subroutine lib_streamReadVar(streamID_dummy, varID_dummy, data_vec_dummy, nmiss) bind(c, name = 'streamReadVar')
-				import c_double, c_int, c_ptr
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: varID_dummy
-				real(c_double), intent(inout) :: data_vec_dummy(*)
-				type(c_ptr), value :: nmiss
-			end subroutine lib_streamReadVar
-		end interface
-		nmiss_ptr = c_null_ptr
-		if(present(nmiss)) nmiss_ptr = c_loc(nmiss_temp)
-		call lib_streamReadVar(streamID_dummy, varID_dummy, data_vec_dummy, nmiss_ptr)
-		if(present(nmiss)) nmiss = nmiss_temp
-	end subroutine streamReadVar
-
-	subroutine streamReadVarF(streamID_dummy, varID_dummy, data_vec_dummy, nmiss)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: varID_dummy
-		real(c_float), intent(inout) :: data_vec_dummy(*)
-		integer(c_int), optional, intent(inout) :: nmiss
-		integer(c_int), target :: nmiss_temp
-		type(c_ptr) :: nmiss_ptr
-		interface
-			subroutine lib_streamReadVarF(streamID_dummy, varID_dummy, data_vec_dummy, nmiss) bind(c, name = 'streamReadVarF')
-				import c_float, c_int, c_ptr
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: varID_dummy
-				real(c_float), intent(inout) :: data_vec_dummy(*)
-				type(c_ptr), value :: nmiss
-			end subroutine lib_streamReadVarF
-		end interface
-		nmiss_ptr = c_null_ptr
-		if(present(nmiss)) nmiss_ptr = c_loc(nmiss_temp)
-		call lib_streamReadVarF(streamID_dummy, varID_dummy, data_vec_dummy, nmiss_ptr)
-		if(present(nmiss)) nmiss = nmiss_temp
-	end subroutine streamReadVarF
-
-	subroutine streamWriteVarSlice(streamID_dummy, varID_dummy, levelID_dummy, data_vec_dummy, nmiss_dummy)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: levelID_dummy
-		real(c_double), intent(in) :: data_vec_dummy(*)
-		integer(c_int), value :: nmiss_dummy
-		interface
-			subroutine lib_streamWriteVarSlice(streamID_dummy, varID_dummy, levelID_dummy, data_vec_dummy, nmiss_dummy) bind(c, name = 'stre&
-			&amWriteVarSlice')
-				import c_double, c_int
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: levelID_dummy
-				real(c_double), intent(in) :: data_vec_dummy(*)
-				integer(c_int), value :: nmiss_dummy
-			end subroutine lib_streamWriteVarSlice
-		end interface
-		call lib_streamWriteVarSlice(streamID_dummy, varID_dummy, levelID_dummy, data_vec_dummy, nmiss_dummy)
-	end subroutine streamWriteVarSlice
-
-	subroutine streamWriteVarSliceF(streamID_dummy, varID_dummy, levelID_dummy, data_vec_dummy, nmiss_dummy)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: levelID_dummy
-		real(c_float), intent(in) :: data_vec_dummy(*)
-		integer(c_int), value :: nmiss_dummy
-		interface
-			subroutine lib_streamWriteVarSliceF(streamID_dummy, varID_dummy, levelID_dummy, data_vec_dummy, nmiss_dummy) bind(c, name = 'str&
-			&eamWriteVarSliceF')
-				import c_float, c_int
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: levelID_dummy
-				real(c_float), intent(in) :: data_vec_dummy(*)
-				integer(c_int), value :: nmiss_dummy
-			end subroutine lib_streamWriteVarSliceF
-		end interface
-		call lib_streamWriteVarSliceF(streamID_dummy, varID_dummy, levelID_dummy, data_vec_dummy, nmiss_dummy)
-	end subroutine streamWriteVarSliceF
-
-	subroutine streamReadVarSlice(streamID_dummy, varID_dummy, levelID_dummy, data_vec_dummy, nmiss)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: levelID_dummy
-		real(c_double), intent(inout) :: data_vec_dummy(*)
-		integer(c_int), optional, intent(inout) :: nmiss
-		integer(c_int), target :: nmiss_temp
-		type(c_ptr) :: nmiss_ptr
-		interface
-			subroutine lib_streamReadVarSlice(streamID_dummy, varID_dummy, levelID_dummy, data_vec_dummy, nmiss) bind(c, name = 'streamReadV&
-			&arSlice')
-				import c_double, c_int, c_ptr
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: levelID_dummy
-				real(c_double), intent(inout) :: data_vec_dummy(*)
-				type(c_ptr), value :: nmiss
-			end subroutine lib_streamReadVarSlice
-		end interface
-		nmiss_ptr = c_null_ptr
-		if(present(nmiss)) nmiss_ptr = c_loc(nmiss_temp)
-		call lib_streamReadVarSlice(streamID_dummy, varID_dummy, levelID_dummy, data_vec_dummy, nmiss_ptr)
-		if(present(nmiss)) nmiss = nmiss_temp
-	end subroutine streamReadVarSlice
-
-	subroutine streamReadVarSliceF(streamID_dummy, varID_dummy, levelID_dummy, data_vec_dummy, nmiss)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: levelID_dummy
-		real(c_float), intent(inout) :: data_vec_dummy(*)
-		integer(c_int), optional, intent(inout) :: nmiss
-		integer(c_int), target :: nmiss_temp
-		type(c_ptr) :: nmiss_ptr
-		interface
-			subroutine lib_streamReadVarSliceF(streamID_dummy, varID_dummy, levelID_dummy, data_vec_dummy, nmiss) bind(c, name = 'streamRead&
-			&VarSliceF')
-				import c_float, c_int, c_ptr
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: levelID_dummy
-				real(c_float), intent(inout) :: data_vec_dummy(*)
-				type(c_ptr), value :: nmiss
-			end subroutine lib_streamReadVarSliceF
-		end interface
-		nmiss_ptr = c_null_ptr
-		if(present(nmiss)) nmiss_ptr = c_loc(nmiss_temp)
-		call lib_streamReadVarSliceF(streamID_dummy, varID_dummy, levelID_dummy, data_vec_dummy, nmiss_ptr)
-		if(present(nmiss)) nmiss = nmiss_temp
-	end subroutine streamReadVarSliceF
-
-	subroutine streamWriteVarChunk(streamID_dummy, varID_dummy, rect_dummy, data_vec_dummy, nmiss_dummy)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), intent(in) :: rect_dummy(2, 3)
-		real(c_double), intent(in) :: data_vec_dummy(*)
-		integer(c_int), value :: nmiss_dummy
-		interface
-			subroutine lib_streamWriteVarChunk(streamID_dummy, varID_dummy, rect_dummy, data_vec_dummy, nmiss_dummy) bind(c, name = 'streamW&
-			&riteVarChunk')
-				import c_double, c_int
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), intent(in) :: rect_dummy(*)
-				real(c_double), intent(in) :: data_vec_dummy(*)
-				integer(c_int), value :: nmiss_dummy
-			end subroutine lib_streamWriteVarChunk
-		end interface
-		call lib_streamWriteVarChunk(streamID_dummy, varID_dummy, rect_dummy, data_vec_dummy, nmiss_dummy)
-	end subroutine streamWriteVarChunk
-
-	subroutine streamDefRecord(streamID_dummy, varID_dummy, levelID_dummy)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: levelID_dummy
-		interface
-			subroutine lib_streamDefRecord(streamID_dummy, varID_dummy, levelID_dummy) bind(c, name = 'streamDefRecord')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: levelID_dummy
-			end subroutine lib_streamDefRecord
-		end interface
-		call lib_streamDefRecord(streamID_dummy, varID_dummy, levelID_dummy)
-	end subroutine streamDefRecord
-
-	subroutine streamInqRecord(streamID_dummy, varID, levelID)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), optional, intent(inout) :: varID
-		integer(c_int), optional, intent(inout) :: levelID
-		integer(c_int), target :: varID_temp
-		type(c_ptr) :: varID_ptr
-		integer(c_int), target :: levelID_temp
-		type(c_ptr) :: levelID_ptr
-		interface
-			subroutine lib_streamInqRecord(streamID_dummy, varID, levelID) bind(c, name = 'streamInqRecord')
-				import c_int, c_ptr
-				integer(c_int), value :: streamID_dummy
-				type(c_ptr), value :: varID
-				type(c_ptr), value :: levelID
-			end subroutine lib_streamInqRecord
-		end interface
-		varID_ptr = c_null_ptr
-		if(present(varID)) varID_ptr = c_loc(varID_temp)
-		levelID_ptr = c_null_ptr
-		if(present(levelID)) levelID_ptr = c_loc(levelID_temp)
-		call lib_streamInqRecord(streamID_dummy, varID_ptr, levelID_ptr)
-		if(present(varID)) varID = varID_temp
-		if(present(levelID)) levelID = levelID_temp
-	end subroutine streamInqRecord
-
-	subroutine streamWriteRecord(streamID_dummy, data_vec_dummy, nmiss_dummy)
-		integer(c_int), value :: streamID_dummy
-		real(c_double), intent(in) :: data_vec_dummy(*)
-		integer(c_int), value :: nmiss_dummy
-		interface
-			subroutine lib_streamWriteRecord(streamID_dummy, data_vec_dummy, nmiss_dummy) bind(c, name = 'streamWriteRecord')
-				import c_double, c_int
-				integer(c_int), value :: streamID_dummy
-				real(c_double), intent(in) :: data_vec_dummy(*)
-				integer(c_int), value :: nmiss_dummy
-			end subroutine lib_streamWriteRecord
-		end interface
-		call lib_streamWriteRecord(streamID_dummy, data_vec_dummy, nmiss_dummy)
-	end subroutine streamWriteRecord
-
-	subroutine streamWriteRecordF(streamID_dummy, data_vec_dummy, nmiss_dummy)
-		integer(c_int), value :: streamID_dummy
-		real(c_float), intent(in) :: data_vec_dummy(*)
-		integer(c_int), value :: nmiss_dummy
-		interface
-			subroutine lib_streamWriteRecordF(streamID_dummy, data_vec_dummy, nmiss_dummy) bind(c, name = 'streamWriteRecordF')
-				import c_float, c_int
-				integer(c_int), value :: streamID_dummy
-				real(c_float), intent(in) :: data_vec_dummy(*)
-				integer(c_int), value :: nmiss_dummy
-			end subroutine lib_streamWriteRecordF
-		end interface
-		call lib_streamWriteRecordF(streamID_dummy, data_vec_dummy, nmiss_dummy)
-	end subroutine streamWriteRecordF
-
-	subroutine streamReadRecord(streamID_dummy, data_vec_dummy, nmiss)
-		integer(c_int), value :: streamID_dummy
-		real(c_double), intent(inout) :: data_vec_dummy(*)
-		integer(c_int), optional, intent(inout) :: nmiss
-		integer(c_int), target :: nmiss_temp
-		type(c_ptr) :: nmiss_ptr
-		interface
-			subroutine lib_streamReadRecord(streamID_dummy, data_vec_dummy, nmiss) bind(c, name = 'streamReadRecord')
-				import c_double, c_int, c_ptr
-				integer(c_int), value :: streamID_dummy
-				real(c_double), intent(inout) :: data_vec_dummy(*)
-				type(c_ptr), value :: nmiss
-			end subroutine lib_streamReadRecord
-		end interface
-		nmiss_ptr = c_null_ptr
-		if(present(nmiss)) nmiss_ptr = c_loc(nmiss_temp)
-		call lib_streamReadRecord(streamID_dummy, data_vec_dummy, nmiss_ptr)
-		if(present(nmiss)) nmiss = nmiss_temp
-	end subroutine streamReadRecord
-
-	subroutine streamCopyRecord(streamIDdest_dummy, streamIDsrc_dummy)
-		integer(c_int), value :: streamIDdest_dummy
-		integer(c_int), value :: streamIDsrc_dummy
-		interface
-			subroutine lib_streamCopyRecord(streamIDdest_dummy, streamIDsrc_dummy) bind(c, name = 'streamCopyRecord')
-				import c_int
-				integer(c_int), value :: streamIDdest_dummy
-				integer(c_int), value :: streamIDsrc_dummy
-			end subroutine lib_streamCopyRecord
-		end interface
-		call lib_streamCopyRecord(streamIDdest_dummy, streamIDsrc_dummy)
-	end subroutine streamCopyRecord
-
-	function cdiIterator_new(path_dummy) result(result)
-		type(t_CdiIterator) :: result
-		character(kind = c_char, len = *), intent(in) :: path_dummy
-		character(kind = c_char) :: path_temp(len(path_dummy) + 1)
-		integer :: path_i
-		interface
-			type(c_ptr) function lib_cdiIterator_new(path_dummy) bind(c, name = 'cdiIterator_new')
-				import c_char, c_ptr
-				character(kind = c_char) :: path_dummy(*)
-			end function lib_cdiIterator_new
-		end interface
-		do path_i = 1, len(path_dummy)
-		path_temp(path_i) = path_dummy(path_i:path_i)
-		end do
-		path_temp(len(path_dummy) + 1) = c_null_char
-		result%ptr = lib_cdiIterator_new(path_temp)
-	end function cdiIterator_new
-
-	function cdiIterator_clone(me_dummy) result(result)
-		type(t_CdiIterator) :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		interface
-			type(c_ptr) function lib_cdiIterator_clone(me_dummy) bind(c, name = 'cdiIterator_clone')
-				import c_ptr
-				type(c_ptr), value :: me_dummy
-			end function lib_cdiIterator_clone
-		end interface
-		result%ptr = lib_cdiIterator_clone(me_dummy%ptr)
-	end function cdiIterator_clone
-
-	function cdiIterator_serialize(me_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		type(c_ptr) :: cString
-		integer :: shape(1)
-		character(kind = c_char), dimension(:), pointer :: temp
-		interface
-			type(c_ptr) function lib_cdiIterator_serialize(me_dummy) bind(c, name = 'cdiIterator_serialize')
-				import c_ptr
-				type(c_ptr), value :: me_dummy
-			end function lib_cdiIterator_serialize
-		end interface
-		cString = lib_cdiIterator_serialize(me_dummy%ptr)
-		if(c_associated(cString)) then
-			shape(1) = int(lib_strlen(cString))
-			call c_f_pointer(cString, temp, shape)
-			allocate(result(shape(1)))
-			result = temp
-			call lib_free(cString)
-		else
-			result => null()
-		end if
-	end function cdiIterator_serialize
-
-	function cdiIterator_deserialize(description_dummy) result(result)
-		type(t_CdiIterator) :: result
-		character(kind = c_char, len = *), intent(in) :: description_dummy
-		character(kind = c_char) :: description_temp(len(description_dummy) + 1)
-		integer :: description_i
-		interface
-			type(c_ptr) function lib_cdiIterator_deserialize(description_dummy) bind(c, name = 'cdiIterator_deserialize')
-				import c_char, c_ptr
-				character(kind = c_char) :: description_dummy(*)
-			end function lib_cdiIterator_deserialize
-		end interface
-		do description_i = 1, len(description_dummy)
-		description_temp(description_i) = description_dummy(description_i:description_i)
-		end do
-		description_temp(len(description_dummy) + 1) = c_null_char
-		result%ptr = lib_cdiIterator_deserialize(description_temp)
-	end function cdiIterator_deserialize
-
-	subroutine cdiIterator_delete(me_dummy)
-		type(t_CdiIterator), intent(in) :: me_dummy
-		interface
-			subroutine lib_cdiIterator_delete(me_dummy) bind(c, name = 'cdiIterator_delete')
-				import c_ptr
-				type(c_ptr), value :: me_dummy
-			end subroutine lib_cdiIterator_delete
-		end interface
-		call lib_cdiIterator_delete(me_dummy%ptr)
-	end subroutine cdiIterator_delete
-
-	function cdiIterator_nextField(me_dummy) result(result)
-		integer(c_int) :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		interface
-			integer(c_int) function lib_cdiIterator_nextField(me_dummy) bind(c, name = 'cdiIterator_nextField')
-				import c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-			end function lib_cdiIterator_nextField
-		end interface
-		result = lib_cdiIterator_nextField(me_dummy%ptr)
-	end function cdiIterator_nextField
-
-	function cdiIterator_inqStartTime(me_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		type(c_ptr) :: cString
-		integer :: shape(1)
-		character(kind = c_char), dimension(:), pointer :: temp
-		interface
-			type(c_ptr) function lib_cdiIterator_inqStartTime(me_dummy) bind(c, name = 'cdiIterator_inqStartTime')
-				import c_ptr
-				type(c_ptr), value :: me_dummy
-			end function lib_cdiIterator_inqStartTime
-		end interface
-		cString = lib_cdiIterator_inqStartTime(me_dummy%ptr)
-		if(c_associated(cString)) then
-			shape(1) = int(lib_strlen(cString))
-			call c_f_pointer(cString, temp, shape)
-			allocate(result(shape(1)))
-			result = temp
-			call lib_free(cString)
-		else
-			result => null()
-		end if
-	end function cdiIterator_inqStartTime
-
-	function cdiIterator_inqEndTime(me_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		type(c_ptr) :: cString
-		integer :: shape(1)
-		character(kind = c_char), dimension(:), pointer :: temp
-		interface
-			type(c_ptr) function lib_cdiIterator_inqEndTime(me_dummy) bind(c, name = 'cdiIterator_inqEndTime')
-				import c_ptr
-				type(c_ptr), value :: me_dummy
-			end function lib_cdiIterator_inqEndTime
-		end interface
-		cString = lib_cdiIterator_inqEndTime(me_dummy%ptr)
-		if(c_associated(cString)) then
-			shape(1) = int(lib_strlen(cString))
-			call c_f_pointer(cString, temp, shape)
-			allocate(result(shape(1)))
-			result = temp
-			call lib_free(cString)
-		else
-			result => null()
-		end if
-	end function cdiIterator_inqEndTime
-
-	function cdiIterator_inqVTime(me_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		type(c_ptr) :: cString
-		integer :: shape(1)
-		character(kind = c_char), dimension(:), pointer :: temp
-		interface
-			type(c_ptr) function lib_cdiIterator_inqVTime(me_dummy) bind(c, name = 'cdiIterator_inqVTime')
-				import c_ptr
-				type(c_ptr), value :: me_dummy
-			end function lib_cdiIterator_inqVTime
-		end interface
-		cString = lib_cdiIterator_inqVTime(me_dummy%ptr)
-		if(c_associated(cString)) then
-			shape(1) = int(lib_strlen(cString))
-			call c_f_pointer(cString, temp, shape)
-			allocate(result(shape(1)))
-			result = temp
-			call lib_free(cString)
-		else
-			result => null()
-		end if
-	end function cdiIterator_inqVTime
-
-	function cdiIterator_inqLevelType(me_dummy, levelSelector_dummy, outName, outLongName, outStdName, outUnit) result(result)
-		integer(c_int) :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		integer(c_int), value :: levelSelector_dummy
-		character(kind = c_char), pointer, optional, intent(inout) :: outName(:)
-		character(kind = c_char), pointer, optional, intent(inout) :: outLongName(:)
-		character(kind = c_char), pointer, optional, intent(inout) :: outStdName(:)
-		character(kind = c_char), pointer, optional, intent(inout) :: outUnit(:)
-		type(c_ptr), target :: outName_ptr
-		type(c_ptr) :: outName_handle
-		integer :: outName_shape(1)
-		character(kind = c_char), pointer :: outName_fptr(:)
-		type(c_ptr), target :: outLongName_ptr
-		type(c_ptr) :: outLongName_handle
-		integer :: outLongName_shape(1)
-		character(kind = c_char), pointer :: outLongName_fptr(:)
-		type(c_ptr), target :: outStdName_ptr
-		type(c_ptr) :: outStdName_handle
-		integer :: outStdName_shape(1)
-		character(kind = c_char), pointer :: outStdName_fptr(:)
-		type(c_ptr), target :: outUnit_ptr
-		type(c_ptr) :: outUnit_handle
-		integer :: outUnit_shape(1)
-		character(kind = c_char), pointer :: outUnit_fptr(:)
-		interface
-			integer(c_int) function lib_cdiIterator_inqLevelType(me_dummy, levelSelector_dummy, outName, outLongName, outStdName, outUnit) b&
-			&ind(c, name = 'cdiIterator_inqLevelType')
-				import c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-				integer(c_int), value :: levelSelector_dummy
-				type(c_ptr), value :: outName
-				type(c_ptr), value :: outLongName
-				type(c_ptr), value :: outStdName
-				type(c_ptr), value :: outUnit
-			end function lib_cdiIterator_inqLevelType
-		end interface
-		outName_handle = c_null_ptr
-		if(present(outName)) outName_handle = c_loc(outName_ptr)
-		outLongName_handle = c_null_ptr
-		if(present(outLongName)) outLongName_handle = c_loc(outLongName_ptr)
-		outStdName_handle = c_null_ptr
-		if(present(outStdName)) outStdName_handle = c_loc(outStdName_ptr)
-		outUnit_handle = c_null_ptr
-		if(present(outUnit)) outUnit_handle = c_loc(outUnit_ptr)
-		result = lib_cdiIterator_inqLevelType(me_dummy%ptr, levelSelector_dummy, outName_handle, outLongName_handle, outStdName_handle, o&
-		&utUnit_handle)
-		if(present(outName)) then
-			if(c_associated(outName_ptr)) then
-				outName_shape(1) = int(lib_strlen(outName_ptr))
-				call c_f_pointer(outName_ptr, outName_fptr, outName_shape)
-				allocate(outName(outName_shape(1)))
-				outName = outName_fptr
-				call lib_free(outName_ptr)
-			else
-				outName => null()
-			end if
-		end if
-		if(present(outLongName)) then
-			if(c_associated(outLongName_ptr)) then
-				outLongName_shape(1) = int(lib_strlen(outLongName_ptr))
-				call c_f_pointer(outLongName_ptr, outLongName_fptr, outLongName_shape)
-				allocate(outLongName(outLongName_shape(1)))
-				outLongName = outLongName_fptr
-				call lib_free(outLongName_ptr)
-			else
-				outLongName => null()
-			end if
-		end if
-		if(present(outStdName)) then
-			if(c_associated(outStdName_ptr)) then
-				outStdName_shape(1) = int(lib_strlen(outStdName_ptr))
-				call c_f_pointer(outStdName_ptr, outStdName_fptr, outStdName_shape)
-				allocate(outStdName(outStdName_shape(1)))
-				outStdName = outStdName_fptr
-				call lib_free(outStdName_ptr)
-			else
-				outStdName => null()
-			end if
-		end if
-		if(present(outUnit)) then
-			if(c_associated(outUnit_ptr)) then
-				outUnit_shape(1) = int(lib_strlen(outUnit_ptr))
-				call c_f_pointer(outUnit_ptr, outUnit_fptr, outUnit_shape)
-				allocate(outUnit(outUnit_shape(1)))
-				outUnit = outUnit_fptr
-				call lib_free(outUnit_ptr)
-			else
-				outUnit => null()
-			end if
-		end if
-	end function cdiIterator_inqLevelType
-
-	function cdiIterator_inqLevel(me_dummy, levelSelector_dummy, outValue1, outValue2) result(result)
-		integer(c_int) :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		integer(c_int), value :: levelSelector_dummy
-		real(c_double), optional, intent(inout) :: outValue1
-		real(c_double), optional, intent(inout) :: outValue2
-		real(c_double), target :: outValue1_temp
-		type(c_ptr) :: outValue1_ptr
-		real(c_double), target :: outValue2_temp
-		type(c_ptr) :: outValue2_ptr
-		interface
-			integer(c_int) function lib_cdiIterator_inqLevel(me_dummy, levelSelector_dummy, outValue1, outValue2) bind(c, name = 'cdiIterato&
-			&r_inqLevel')
-				import c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-				integer(c_int), value :: levelSelector_dummy
-				type(c_ptr), value :: outValue1
-				type(c_ptr), value :: outValue2
-			end function lib_cdiIterator_inqLevel
-		end interface
-		outValue1_ptr = c_null_ptr
-		if(present(outValue1)) outValue1_ptr = c_loc(outValue1_temp)
-		outValue2_ptr = c_null_ptr
-		if(present(outValue2)) outValue2_ptr = c_loc(outValue2_temp)
-		result = lib_cdiIterator_inqLevel(me_dummy%ptr, levelSelector_dummy, outValue1_ptr, outValue2_ptr)
-		if(present(outValue1)) outValue1 = outValue1_temp
-		if(present(outValue2)) outValue2 = outValue2_temp
-	end function cdiIterator_inqLevel
-
-	function cdiIterator_inqLevelUuid(me_dummy, outVgridNumber, outLevelCount, outUuid) result(result)
-		integer(c_int) :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		integer(c_int), optional, intent(inout) :: outVgridNumber
-		integer(c_int), optional, intent(inout) :: outLevelCount
-		character(kind = c_char), optional, intent(inout) :: outUuid(CDI_UUID_SIZE)
-		integer(c_int), target :: outVgridNumber_temp
-		type(c_ptr) :: outVgridNumber_ptr
-		integer(c_int), target :: outLevelCount_temp
-		type(c_ptr) :: outLevelCount_ptr
-		character(kind = c_char), target :: outUuid_temp(CDI_UUID_SIZE)
-		type(c_ptr) :: outUuid_ptr
-		interface
-			integer(c_int) function lib_cdiIterator_inqLevelUuid(me_dummy, outVgridNumber, outLevelCount, outUuid) bind(c, name = 'cdiIterat&
-			&or_inqLevelUuid')
-				import c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-				type(c_ptr), value :: outVgridNumber
-				type(c_ptr), value :: outLevelCount
-				type(c_ptr), value :: outUuid
-			end function lib_cdiIterator_inqLevelUuid
-		end interface
-		outVgridNumber_ptr = c_null_ptr
-		if(present(outVgridNumber)) outVgridNumber_ptr = c_loc(outVgridNumber_temp)
-		outLevelCount_ptr = c_null_ptr
-		if(present(outLevelCount)) outLevelCount_ptr = c_loc(outLevelCount_temp)
-		outUuid_ptr = c_null_ptr
-		if(present(outUuid)) outUuid_ptr = c_loc(outUuid_temp)
-		result = lib_cdiIterator_inqLevelUuid(me_dummy%ptr, outVgridNumber_ptr, outLevelCount_ptr, outUuid_ptr)
-		if(present(outVgridNumber)) outVgridNumber = outVgridNumber_temp
-		if(present(outLevelCount)) outLevelCount = outLevelCount_temp
-		if(present(outUuid)) outUuid = outUuid_temp
-	end function cdiIterator_inqLevelUuid
-
-	function cdiIterator_inqParam(me_dummy) result(result)
-		type(t_CdiParam) :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		interface
-			type(t_CdiParam) function lib_cdiIterator_inqParam(me_dummy) bind(c, name = 'cdiIterator_inqParam')
-				import c_ptr, t_CdiParam
-				type(c_ptr), value :: me_dummy
-			end function lib_cdiIterator_inqParam
-		end interface
-		result = lib_cdiIterator_inqParam(me_dummy%ptr)
-	end function cdiIterator_inqParam
-
-	function cdiIterator_inqDatatype(me_dummy) result(result)
-		integer(c_int) :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		interface
-			integer(c_int) function lib_cdiIterator_inqDatatype(me_dummy) bind(c, name = 'cdiIterator_inqDatatype')
-				import c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-			end function lib_cdiIterator_inqDatatype
-		end interface
-		result = lib_cdiIterator_inqDatatype(me_dummy%ptr)
-	end function cdiIterator_inqDatatype
-
-	function cdiIterator_inqTsteptype(me_dummy) result(result)
-		integer(c_int) :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		interface
-			integer(c_int) function lib_cdiIterator_inqTsteptype(me_dummy) bind(c, name = 'cdiIterator_inqTsteptype')
-				import c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-			end function lib_cdiIterator_inqTsteptype
-		end interface
-		result = lib_cdiIterator_inqTsteptype(me_dummy%ptr)
-	end function cdiIterator_inqTsteptype
-
-	function cdiIterator_inqVariableName(me_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		type(c_ptr) :: cString
-		integer :: shape(1)
-		character(kind = c_char), dimension(:), pointer :: temp
-		interface
-			type(c_ptr) function lib_cdiIterator_inqVariableName(me_dummy) bind(c, name = 'cdiIterator_inqVariableName')
-				import c_ptr
-				type(c_ptr), value :: me_dummy
-			end function lib_cdiIterator_inqVariableName
-		end interface
-		cString = lib_cdiIterator_inqVariableName(me_dummy%ptr)
-		if(c_associated(cString)) then
-			shape(1) = int(lib_strlen(cString))
-			call c_f_pointer(cString, temp, shape)
-			allocate(result(shape(1)))
-			result = temp
-			call lib_free(cString)
-		else
-			result => null()
-		end if
-	end function cdiIterator_inqVariableName
-
-	function cdiIterator_inqGridId(me_dummy) result(result)
-		integer(c_int) :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		interface
-			integer(c_int) function lib_cdiIterator_inqGridId(me_dummy) bind(c, name = 'cdiIterator_inqGridId')
-				import c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-			end function lib_cdiIterator_inqGridId
-		end interface
-		result = lib_cdiIterator_inqGridId(me_dummy%ptr)
-	end function cdiIterator_inqGridId
-
-	subroutine cdiIterator_readField(me_dummy, data_vec_dummy, nmiss)
-		type(t_CdiIterator), intent(in) :: me_dummy
-		real(c_double), intent(inout) :: data_vec_dummy(*)
-		integer(c_size_t), optional, intent(inout) :: nmiss
-		integer(c_size_t), target :: nmiss_temp
-		type(c_ptr) :: nmiss_ptr
-		interface
-			subroutine lib_cdiIterator_readField(me_dummy, data_vec_dummy, nmiss) bind(c, name = 'cdiIterator_readField')
-				import c_double, c_ptr
-				type(c_ptr), value :: me_dummy
-				real(c_double), intent(inout) :: data_vec_dummy(*)
-				type(c_ptr), value :: nmiss
-			end subroutine lib_cdiIterator_readField
-		end interface
-		nmiss_ptr = c_null_ptr
-		if(present(nmiss)) nmiss_ptr = c_loc(nmiss_temp)
-		call lib_cdiIterator_readField(me_dummy%ptr, data_vec_dummy, nmiss_ptr)
-		if(present(nmiss)) nmiss = nmiss_temp
-	end subroutine cdiIterator_readField
-
-	subroutine cdiIterator_readFieldF(me_dummy, data_vec_dummy, nmiss)
-		type(t_CdiIterator), intent(in) :: me_dummy
-		real(c_float), intent(inout) :: data_vec_dummy(*)
-		integer(c_size_t), optional, intent(inout) :: nmiss
-		integer(c_size_t), target :: nmiss_temp
-		type(c_ptr) :: nmiss_ptr
-		interface
-			subroutine lib_cdiIterator_readFieldF(me_dummy, data_vec_dummy, nmiss) bind(c, name = 'cdiIterator_readFieldF')
-				import c_float, c_ptr
-				type(c_ptr), value :: me_dummy
-				real(c_float), intent(inout) :: data_vec_dummy(*)
-				type(c_ptr), value :: nmiss
-			end subroutine lib_cdiIterator_readFieldF
-		end interface
-		nmiss_ptr = c_null_ptr
-		if(present(nmiss)) nmiss_ptr = c_loc(nmiss_temp)
-		call lib_cdiIterator_readFieldF(me_dummy%ptr, data_vec_dummy, nmiss_ptr)
-		if(present(nmiss)) nmiss = nmiss_temp
-	end subroutine cdiIterator_readFieldF
-
-	function cdiGribIterator_clone(me_dummy) result(result)
-		type(t_CdiGribIterator) :: result
-		type(t_CdiIterator), intent(in) :: me_dummy
-		interface
-			type(c_ptr) function lib_cdiGribIterator_clone(me_dummy) bind(c, name = 'cdiGribIterator_clone')
-				import c_ptr
-				type(c_ptr), value :: me_dummy
-			end function lib_cdiGribIterator_clone
-		end interface
-		result%ptr = lib_cdiGribIterator_clone(me_dummy%ptr)
-	end function cdiGribIterator_clone
-
-	subroutine cdiGribIterator_delete(me_dummy)
-		type(t_CdiGribIterator), intent(in) :: me_dummy
-		interface
-			subroutine lib_cdiGribIterator_delete(me_dummy) bind(c, name = 'cdiGribIterator_delete')
-				import c_ptr
-				type(c_ptr), value :: me_dummy
-			end subroutine lib_cdiGribIterator_delete
-		end interface
-		call lib_cdiGribIterator_delete(me_dummy%ptr)
-	end subroutine cdiGribIterator_delete
-
-	function cdiGribIterator_getLong(me_dummy, key_dummy, value) result(result)
-		integer(c_int) :: result
-		type(t_CdiGribIterator), intent(in) :: me_dummy
-		character(kind = c_char, len = *), intent(in) :: key_dummy
-		integer(c_long), optional, intent(inout) :: value
-		character(kind = c_char) :: key_temp(len(key_dummy) + 1)
-		integer :: key_i
-		integer(c_long), target :: value_temp
-		type(c_ptr) :: value_ptr
-		interface
-			integer(c_int) function lib_cdiGribIterator_getLong(me_dummy, key_dummy, value) bind(c, name = 'cdiGribIterator_getLong')
-				import c_char, c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-				character(kind = c_char) :: key_dummy(*)
-				type(c_ptr), value :: value
-			end function lib_cdiGribIterator_getLong
-		end interface
-		do key_i = 1, len(key_dummy)
-		key_temp(key_i) = key_dummy(key_i:key_i)
-		end do
-		key_temp(len(key_dummy) + 1) = c_null_char
-		value_ptr = c_null_ptr
-		if(present(value)) value_ptr = c_loc(value_temp)
-		result = lib_cdiGribIterator_getLong(me_dummy%ptr, key_temp, value_ptr)
-		if(present(value)) value = value_temp
-	end function cdiGribIterator_getLong
-
-	function cdiGribIterator_getDouble(me_dummy, key_dummy, value) result(result)
-		integer(c_int) :: result
-		type(t_CdiGribIterator), intent(in) :: me_dummy
-		character(kind = c_char, len = *), intent(in) :: key_dummy
-		real(c_double), optional, intent(inout) :: value
-		character(kind = c_char) :: key_temp(len(key_dummy) + 1)
-		integer :: key_i
-		real(c_double), target :: value_temp
-		type(c_ptr) :: value_ptr
-		interface
-			integer(c_int) function lib_cdiGribIterator_getDouble(me_dummy, key_dummy, value) bind(c, name = 'cdiGribIterator_getDouble')
-				import c_char, c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-				character(kind = c_char) :: key_dummy(*)
-				type(c_ptr), value :: value
-			end function lib_cdiGribIterator_getDouble
-		end interface
-		do key_i = 1, len(key_dummy)
-		key_temp(key_i) = key_dummy(key_i:key_i)
-		end do
-		key_temp(len(key_dummy) + 1) = c_null_char
-		value_ptr = c_null_ptr
-		if(present(value)) value_ptr = c_loc(value_temp)
-		result = lib_cdiGribIterator_getDouble(me_dummy%ptr, key_temp, value_ptr)
-		if(present(value)) value = value_temp
-	end function cdiGribIterator_getDouble
-
-	function cdiGribIterator_getLength(me_dummy, key_dummy, value) result(result)
-		integer(c_int) :: result
-		type(t_CdiGribIterator), intent(in) :: me_dummy
-		character(kind = c_char, len = *), intent(in) :: key_dummy
-		integer(c_size_t), optional, intent(inout) :: value
-		character(kind = c_char) :: key_temp(len(key_dummy) + 1)
-		integer :: key_i
-		integer(c_size_t), target :: value_temp
-		type(c_ptr) :: value_ptr
-		interface
-			integer(c_int) function lib_cdiGribIterator_getLength(me_dummy, key_dummy, value) bind(c, name = 'cdiGribIterator_getLength')
-				import c_char, c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-				character(kind = c_char) :: key_dummy(*)
-				type(c_ptr), value :: value
-			end function lib_cdiGribIterator_getLength
-		end interface
-		do key_i = 1, len(key_dummy)
-		key_temp(key_i) = key_dummy(key_i:key_i)
-		end do
-		key_temp(len(key_dummy) + 1) = c_null_char
-		value_ptr = c_null_ptr
-		if(present(value)) value_ptr = c_loc(value_temp)
-		result = lib_cdiGribIterator_getLength(me_dummy%ptr, key_temp, value_ptr)
-		if(present(value)) value = value_temp
-	end function cdiGribIterator_getLength
-
-	function cdiGribIterator_getString(me_dummy, key_dummy, value_dummy, length) result(result)
-		integer(c_int) :: result
-		type(t_CdiGribIterator), intent(in) :: me_dummy
-		character(kind = c_char, len = *), intent(in) :: key_dummy
-		character(kind = c_char, len = *), intent(inout) :: value_dummy
-		integer(c_size_t), optional, intent(inout) :: length
-		character(kind = c_char) :: key_temp(len(key_dummy) + 1)
-		integer :: key_i
-		character(kind = c_char) :: value_temp(len(value_dummy))
-		integer :: value_i
-		logical :: value_padding = .true.
-		integer(c_size_t), target :: length_temp
-		type(c_ptr) :: length_ptr
-		interface
-			integer(c_int) function lib_cdiGribIterator_getString(me_dummy, key_dummy, value_dummy, length) bind(c, name = 'cdiGribIterator_&
-			&getString')
-				import c_char, c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-				character(kind = c_char) :: key_dummy(*)
-				character(kind = c_char) :: value_dummy(*)
-				type(c_ptr), value :: length
-			end function lib_cdiGribIterator_getString
-		end interface
-		do key_i = 1, len(key_dummy)
-		key_temp(key_i) = key_dummy(key_i:key_i)
-		end do
-		key_temp(len(key_dummy) + 1) = c_null_char
-		do value_i = len(value_dummy), 1, -1
-			if(value_dummy(value_i:value_i) /= ' ') value_padding = .false.
-			if(value_padding) then
-				value_temp(value_i) = c_null_char
-			else
-				value_temp(value_i) = value_dummy(value_i:value_i)
-			end if
-		end do
-		length_ptr = c_null_ptr
-		if(present(length)) length_ptr = c_loc(length_temp)
-		result = lib_cdiGribIterator_getString(me_dummy%ptr, key_temp, value_temp, length_ptr)
-		value_padding = .false.
-		do value_i = 1, len(value_dummy)
-			if(value_temp(value_i) == c_null_char) value_padding = .true.
-			if(value_padding) then
-				value_dummy(value_i:value_i) = ' '
-			else
-				value_dummy(value_i:value_i) = value_temp(value_i)
-			end if
-		end do
-		if(present(length)) length = length_temp
-	end function cdiGribIterator_getString
-
-	function cdiGribIterator_getSize(me_dummy, key_dummy, value) result(result)
-		integer(c_int) :: result
-		type(t_CdiGribIterator), intent(in) :: me_dummy
-		character(kind = c_char, len = *), intent(in) :: key_dummy
-		integer(c_size_t), optional, intent(inout) :: value
-		character(kind = c_char) :: key_temp(len(key_dummy) + 1)
-		integer :: key_i
-		integer(c_size_t), target :: value_temp
-		type(c_ptr) :: value_ptr
-		interface
-			integer(c_int) function lib_cdiGribIterator_getSize(me_dummy, key_dummy, value) bind(c, name = 'cdiGribIterator_getSize')
-				import c_char, c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-				character(kind = c_char) :: key_dummy(*)
-				type(c_ptr), value :: value
-			end function lib_cdiGribIterator_getSize
-		end interface
-		do key_i = 1, len(key_dummy)
-		key_temp(key_i) = key_dummy(key_i:key_i)
-		end do
-		key_temp(len(key_dummy) + 1) = c_null_char
-		value_ptr = c_null_ptr
-		if(present(value)) value_ptr = c_loc(value_temp)
-		result = lib_cdiGribIterator_getSize(me_dummy%ptr, key_temp, value_ptr)
-		if(present(value)) value = value_temp
-	end function cdiGribIterator_getSize
-
-	function cdiGribIterator_getLongArray(me_dummy, key_dummy, value, array_size) result(result)
-		integer(c_int) :: result
-		type(t_CdiGribIterator), intent(in) :: me_dummy
-		character(kind = c_char, len = *), intent(in) :: key_dummy
-		integer(c_long), optional, intent(inout) :: value
-		integer(c_size_t), optional, intent(inout) :: array_size
-		character(kind = c_char) :: key_temp(len(key_dummy) + 1)
-		integer :: key_i
-		integer(c_long), target :: value_temp
-		type(c_ptr) :: value_ptr
-		integer(c_size_t), target :: array_size_temp
-		type(c_ptr) :: array_size_ptr
-		interface
-			integer(c_int) function lib_cdiGribIterator_getLongArray(me_dummy, key_dummy, value, array_size) bind(c, name = 'cdiGribIterator&
-			&_getLongArray')
-				import c_char, c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-				character(kind = c_char) :: key_dummy(*)
-				type(c_ptr), value :: value
-				type(c_ptr), value :: array_size
-			end function lib_cdiGribIterator_getLongArray
-		end interface
-		do key_i = 1, len(key_dummy)
-		key_temp(key_i) = key_dummy(key_i:key_i)
-		end do
-		key_temp(len(key_dummy) + 1) = c_null_char
-		value_ptr = c_null_ptr
-		if(present(value)) value_ptr = c_loc(value_temp)
-		array_size_ptr = c_null_ptr
-		if(present(array_size)) array_size_ptr = c_loc(array_size_temp)
-		result = lib_cdiGribIterator_getLongArray(me_dummy%ptr, key_temp, value_ptr, array_size_ptr)
-		if(present(value)) value = value_temp
-		if(present(array_size)) array_size = array_size_temp
-	end function cdiGribIterator_getLongArray
-
-	function cdiGribIterator_getDoubleArray(me_dummy, key_dummy, value, array_size) result(result)
-		integer(c_int) :: result
-		type(t_CdiGribIterator), intent(in) :: me_dummy
-		character(kind = c_char, len = *), intent(in) :: key_dummy
-		real(c_double), optional, intent(inout) :: value
-		integer(c_size_t), optional, intent(inout) :: array_size
-		character(kind = c_char) :: key_temp(len(key_dummy) + 1)
-		integer :: key_i
-		real(c_double), target :: value_temp
-		type(c_ptr) :: value_ptr
-		integer(c_size_t), target :: array_size_temp
-		type(c_ptr) :: array_size_ptr
-		interface
-			integer(c_int) function lib_cdiGribIterator_getDoubleArray(me_dummy, key_dummy, value, array_size) bind(c, name = 'cdiGribIterat&
-			&or_getDoubleArray')
-				import c_char, c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-				character(kind = c_char) :: key_dummy(*)
-				type(c_ptr), value :: value
-				type(c_ptr), value :: array_size
-			end function lib_cdiGribIterator_getDoubleArray
-		end interface
-		do key_i = 1, len(key_dummy)
-		key_temp(key_i) = key_dummy(key_i:key_i)
-		end do
-		key_temp(len(key_dummy) + 1) = c_null_char
-		value_ptr = c_null_ptr
-		if(present(value)) value_ptr = c_loc(value_temp)
-		array_size_ptr = c_null_ptr
-		if(present(array_size)) array_size_ptr = c_loc(array_size_temp)
-		result = lib_cdiGribIterator_getDoubleArray(me_dummy%ptr, key_temp, value_ptr, array_size_ptr)
-		if(present(value)) value = value_temp
-		if(present(array_size)) array_size = array_size_temp
-	end function cdiGribIterator_getDoubleArray
-
-	function cdiGribIterator_inqEdition(me_dummy) result(result)
-		integer(c_int) :: result
-		type(t_CdiGribIterator), intent(in) :: me_dummy
-		interface
-			integer(c_int) function lib_cdiGribIterator_inqEdition(me_dummy) bind(c, name = 'cdiGribIterator_inqEdition')
-				import c_int, c_ptr
-				type(c_ptr), value :: me_dummy
-			end function lib_cdiGribIterator_inqEdition
-		end interface
-		result = lib_cdiGribIterator_inqEdition(me_dummy%ptr)
-	end function cdiGribIterator_inqEdition
-
-	function cdiGribIterator_inqLongValue(me_dummy, key_dummy) result(result)
-		integer(c_long) :: result
-		type(t_CdiGribIterator), intent(in) :: me_dummy
-		character(kind = c_char, len = *), intent(in) :: key_dummy
-		character(kind = c_char) :: key_temp(len(key_dummy) + 1)
-		integer :: key_i
-		interface
-			integer(c_long) function lib_cdiGribIterator_inqLongValue(me_dummy, key_dummy) bind(c, name = 'cdiGribIterator_inqLongValue')
-				import c_char, c_long, c_ptr
-				type(c_ptr), value :: me_dummy
-				character(kind = c_char) :: key_dummy(*)
-			end function lib_cdiGribIterator_inqLongValue
-		end interface
-		do key_i = 1, len(key_dummy)
-		key_temp(key_i) = key_dummy(key_i:key_i)
-		end do
-		key_temp(len(key_dummy) + 1) = c_null_char
-		result = lib_cdiGribIterator_inqLongValue(me_dummy%ptr, key_temp)
-	end function cdiGribIterator_inqLongValue
-
-	function cdiGribIterator_inqLongDefaultValue(me_dummy, key_dummy, defaultValue_dummy) result(result)
-		integer(c_long) :: result
-		type(t_CdiGribIterator), intent(in) :: me_dummy
-		character(kind = c_char, len = *), intent(in) :: key_dummy
-		integer(c_long), value :: defaultValue_dummy
-		character(kind = c_char) :: key_temp(len(key_dummy) + 1)
-		integer :: key_i
-		interface
-			integer(c_long) function lib_cdiGribIterator_inqLongDefaultValue(me_dummy, key_dummy, defaultValue_dummy) bind(c, name = 'cdiGri&
-			&bIterator_inqLongDefaultValue')
-				import c_char, c_long, c_ptr
-				type(c_ptr), value :: me_dummy
-				character(kind = c_char) :: key_dummy(*)
-				integer(c_long), value :: defaultValue_dummy
-			end function lib_cdiGribIterator_inqLongDefaultValue
-		end interface
-		do key_i = 1, len(key_dummy)
-		key_temp(key_i) = key_dummy(key_i:key_i)
-		end do
-		key_temp(len(key_dummy) + 1) = c_null_char
-		result = lib_cdiGribIterator_inqLongDefaultValue(me_dummy%ptr, key_temp, defaultValue_dummy)
-	end function cdiGribIterator_inqLongDefaultValue
-
-	function cdiGribIterator_inqDoubleValue(me_dummy, key_dummy) result(result)
-		real(c_double) :: result
-		type(t_CdiGribIterator), intent(in) :: me_dummy
-		character(kind = c_char, len = *), intent(in) :: key_dummy
-		character(kind = c_char) :: key_temp(len(key_dummy) + 1)
-		integer :: key_i
-		interface
-			real(c_double) function lib_cdiGribIterator_inqDoubleValue(me_dummy, key_dummy) bind(c, name = 'cdiGribIterator_inqDoubleValue')
-				import c_char, c_double, c_ptr
-				type(c_ptr), value :: me_dummy
-				character(kind = c_char) :: key_dummy(*)
-			end function lib_cdiGribIterator_inqDoubleValue
-		end interface
-		do key_i = 1, len(key_dummy)
-		key_temp(key_i) = key_dummy(key_i:key_i)
-		end do
-		key_temp(len(key_dummy) + 1) = c_null_char
-		result = lib_cdiGribIterator_inqDoubleValue(me_dummy%ptr, key_temp)
-	end function cdiGribIterator_inqDoubleValue
-
-	function cdiGribIterator_inqDoubleDefaultValue(me_dummy, key_dummy, defaultValue_dummy) result(result)
-		real(c_double) :: result
-		type(t_CdiGribIterator), intent(in) :: me_dummy
-		character(kind = c_char, len = *), intent(in) :: key_dummy
-		real(c_double), value :: defaultValue_dummy
-		character(kind = c_char) :: key_temp(len(key_dummy) + 1)
-		integer :: key_i
-		interface
-			real(c_double) function lib_cdiGribIterator_inqDoubleDefaultValue(me_dummy, key_dummy, defaultValue_dummy) bind(c, name = 'cdiGr&
-			&ibIterator_inqDoubleDefaultValue')
-				import c_char, c_double, c_ptr
-				type(c_ptr), value :: me_dummy
-				character(kind = c_char) :: key_dummy(*)
-				real(c_double), value :: defaultValue_dummy
-			end function lib_cdiGribIterator_inqDoubleDefaultValue
-		end interface
-		do key_i = 1, len(key_dummy)
-		key_temp(key_i) = key_dummy(key_i:key_i)
-		end do
-		key_temp(len(key_dummy) + 1) = c_null_char
-		result = lib_cdiGribIterator_inqDoubleDefaultValue(me_dummy%ptr, key_temp, defaultValue_dummy)
-	end function cdiGribIterator_inqDoubleDefaultValue
-
-	function cdiGribIterator_inqStringValue(me_dummy, key_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		type(t_CdiGribIterator), intent(in) :: me_dummy
-		character(kind = c_char, len = *), intent(in) :: key_dummy
-		character(kind = c_char) :: key_temp(len(key_dummy) + 1)
-		integer :: key_i
-		type(c_ptr) :: cString
-		integer :: shape(1)
-		character(kind = c_char), dimension(:), pointer :: temp
-		interface
-			type(c_ptr) function lib_cdiGribIterator_inqStringValue(me_dummy, key_dummy) bind(c, name = 'cdiGribIterator_inqStringValue')
-				import c_char, c_ptr
-				type(c_ptr), value :: me_dummy
-				character(kind = c_char) :: key_dummy(*)
-			end function lib_cdiGribIterator_inqStringValue
-		end interface
-		do key_i = 1, len(key_dummy)
-		key_temp(key_i) = key_dummy(key_i:key_i)
-		end do
-		key_temp(len(key_dummy) + 1) = c_null_char
-		cString = lib_cdiGribIterator_inqStringValue(me_dummy%ptr, key_temp)
-		if(c_associated(cString)) then
-			shape(1) = int(lib_strlen(cString))
-			call c_f_pointer(cString, temp, shape)
-			allocate(result(shape(1)))
-			result = temp
-			call lib_free(cString)
-		else
-			result => null()
-		end if
-	end function cdiGribIterator_inqStringValue
-
-	function vlistCreate() result(result)
-		integer(c_int) :: result
-		interface
-			integer(c_int) function lib_vlistCreate() bind(c, name = 'vlistCreate')
-				import c_int
-			end function lib_vlistCreate
-		end interface
-		result = lib_vlistCreate()
-	end function vlistCreate
-
-	subroutine vlistDestroy(vlistID_dummy)
-		integer(c_int), value :: vlistID_dummy
-		interface
-			subroutine lib_vlistDestroy(vlistID_dummy) bind(c, name = 'vlistDestroy')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end subroutine lib_vlistDestroy
-		end interface
-		call lib_vlistDestroy(vlistID_dummy)
-	end subroutine vlistDestroy
-
-	function vlistDuplicate(vlistID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		interface
-			integer(c_int) function lib_vlistDuplicate(vlistID_dummy) bind(c, name = 'vlistDuplicate')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end function lib_vlistDuplicate
-		end interface
-		result = lib_vlistDuplicate(vlistID_dummy)
-	end function vlistDuplicate
-
-	subroutine vlistCopy(vlistID2_dummy, vlistID1_dummy)
-		integer(c_int), value :: vlistID2_dummy
-		integer(c_int), value :: vlistID1_dummy
-		interface
-			subroutine lib_vlistCopy(vlistID2_dummy, vlistID1_dummy) bind(c, name = 'vlistCopy')
-				import c_int
-				integer(c_int), value :: vlistID2_dummy
-				integer(c_int), value :: vlistID1_dummy
-			end subroutine lib_vlistCopy
-		end interface
-		call lib_vlistCopy(vlistID2_dummy, vlistID1_dummy)
-	end subroutine vlistCopy
-
-	subroutine vlistCopyFlag(vlistID2_dummy, vlistID1_dummy)
-		integer(c_int), value :: vlistID2_dummy
-		integer(c_int), value :: vlistID1_dummy
-		interface
-			subroutine lib_vlistCopyFlag(vlistID2_dummy, vlistID1_dummy) bind(c, name = 'vlistCopyFlag')
-				import c_int
-				integer(c_int), value :: vlistID2_dummy
-				integer(c_int), value :: vlistID1_dummy
-			end subroutine lib_vlistCopyFlag
-		end interface
-		call lib_vlistCopyFlag(vlistID2_dummy, vlistID1_dummy)
-	end subroutine vlistCopyFlag
-
-	subroutine vlistClearFlag(vlistID_dummy)
-		integer(c_int), value :: vlistID_dummy
-		interface
-			subroutine lib_vlistClearFlag(vlistID_dummy) bind(c, name = 'vlistClearFlag')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end subroutine lib_vlistClearFlag
-		end interface
-		call lib_vlistClearFlag(vlistID_dummy)
-	end subroutine vlistClearFlag
-
-	subroutine vlistCat(vlistID2_dummy, vlistID1_dummy)
-		integer(c_int), value :: vlistID2_dummy
-		integer(c_int), value :: vlistID1_dummy
-		interface
-			subroutine lib_vlistCat(vlistID2_dummy, vlistID1_dummy) bind(c, name = 'vlistCat')
-				import c_int
-				integer(c_int), value :: vlistID2_dummy
-				integer(c_int), value :: vlistID1_dummy
-			end subroutine lib_vlistCat
-		end interface
-		call lib_vlistCat(vlistID2_dummy, vlistID1_dummy)
-	end subroutine vlistCat
-
-	subroutine vlistMerge(vlistID2_dummy, vlistID1_dummy)
-		integer(c_int), value :: vlistID2_dummy
-		integer(c_int), value :: vlistID1_dummy
-		interface
-			subroutine lib_vlistMerge(vlistID2_dummy, vlistID1_dummy) bind(c, name = 'vlistMerge')
-				import c_int
-				integer(c_int), value :: vlistID2_dummy
-				integer(c_int), value :: vlistID1_dummy
-			end subroutine lib_vlistMerge
-		end interface
-		call lib_vlistMerge(vlistID2_dummy, vlistID1_dummy)
-	end subroutine vlistMerge
-
-	subroutine vlistPrint(vlistID_dummy)
-		integer(c_int), value :: vlistID_dummy
-		interface
-			subroutine lib_vlistPrint(vlistID_dummy) bind(c, name = 'vlistPrint')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end subroutine lib_vlistPrint
-		end interface
-		call lib_vlistPrint(vlistID_dummy)
-	end subroutine vlistPrint
-
-	function vlistNumber(vlistID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		interface
-			integer(c_int) function lib_vlistNumber(vlistID_dummy) bind(c, name = 'vlistNumber')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end function lib_vlistNumber
-		end interface
-		result = lib_vlistNumber(vlistID_dummy)
-	end function vlistNumber
-
-	function vlistNvars(vlistID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		interface
-			integer(c_int) function lib_vlistNvars(vlistID_dummy) bind(c, name = 'vlistNvars')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end function lib_vlistNvars
-		end interface
-		result = lib_vlistNvars(vlistID_dummy)
-	end function vlistNvars
-
-	function vlistNgrids(vlistID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		interface
-			integer(c_int) function lib_vlistNgrids(vlistID_dummy) bind(c, name = 'vlistNgrids')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end function lib_vlistNgrids
-		end interface
-		result = lib_vlistNgrids(vlistID_dummy)
-	end function vlistNgrids
-
-	function vlistNzaxis(vlistID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		interface
-			integer(c_int) function lib_vlistNzaxis(vlistID_dummy) bind(c, name = 'vlistNzaxis')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end function lib_vlistNzaxis
-		end interface
-		result = lib_vlistNzaxis(vlistID_dummy)
-	end function vlistNzaxis
-
-	subroutine vlistDefNtsteps(vlistID_dummy, nts_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: nts_dummy
-		interface
-			subroutine lib_vlistDefNtsteps(vlistID_dummy, nts_dummy) bind(c, name = 'vlistDefNtsteps')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: nts_dummy
-			end subroutine lib_vlistDefNtsteps
-		end interface
-		call lib_vlistDefNtsteps(vlistID_dummy, nts_dummy)
-	end subroutine vlistDefNtsteps
-
-	function vlistNtsteps(vlistID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		interface
-			integer(c_int) function lib_vlistNtsteps(vlistID_dummy) bind(c, name = 'vlistNtsteps')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end function lib_vlistNtsteps
-		end interface
-		result = lib_vlistNtsteps(vlistID_dummy)
-	end function vlistNtsteps
-
-	function vlistGridsizeMax(vlistID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		interface
-			integer(c_int) function lib_vlistGridsizeMax(vlistID_dummy) bind(c, name = 'vlistGridsizeMax')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end function lib_vlistGridsizeMax
-		end interface
-		result = lib_vlistGridsizeMax(vlistID_dummy)
-	end function vlistGridsizeMax
-
-	function vlistGrid(vlistID_dummy, index_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: index_dummy
-		interface
-			integer(c_int) function lib_vlistGrid(vlistID_dummy, index_dummy) bind(c, name = 'vlistGrid')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: index_dummy
-			end function lib_vlistGrid
-		end interface
-		result = lib_vlistGrid(vlistID_dummy, index_dummy)
-	end function vlistGrid
-
-	function vlistGridIndex(vlistID_dummy, gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_vlistGridIndex(vlistID_dummy, gridID_dummy) bind(c, name = 'vlistGridIndex')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: gridID_dummy
-			end function lib_vlistGridIndex
-		end interface
-		result = lib_vlistGridIndex(vlistID_dummy, gridID_dummy)
-	end function vlistGridIndex
-
-	subroutine vlistChangeGridIndex(vlistID_dummy, index_dummy, gridID_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: index_dummy
-		integer(c_int), value :: gridID_dummy
-		interface
-			subroutine lib_vlistChangeGridIndex(vlistID_dummy, index_dummy, gridID_dummy) bind(c, name = 'vlistChangeGridIndex')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: index_dummy
-				integer(c_int), value :: gridID_dummy
-			end subroutine lib_vlistChangeGridIndex
-		end interface
-		call lib_vlistChangeGridIndex(vlistID_dummy, index_dummy, gridID_dummy)
-	end subroutine vlistChangeGridIndex
-
-	subroutine vlistChangeGrid(vlistID_dummy, gridID1_dummy, gridID2_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: gridID1_dummy
-		integer(c_int), value :: gridID2_dummy
-		interface
-			subroutine lib_vlistChangeGrid(vlistID_dummy, gridID1_dummy, gridID2_dummy) bind(c, name = 'vlistChangeGrid')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: gridID1_dummy
-				integer(c_int), value :: gridID2_dummy
-			end subroutine lib_vlistChangeGrid
-		end interface
-		call lib_vlistChangeGrid(vlistID_dummy, gridID1_dummy, gridID2_dummy)
-	end subroutine vlistChangeGrid
-
-	function vlistZaxis(vlistID_dummy, index_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: index_dummy
-		interface
-			integer(c_int) function lib_vlistZaxis(vlistID_dummy, index_dummy) bind(c, name = 'vlistZaxis')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: index_dummy
-			end function lib_vlistZaxis
-		end interface
-		result = lib_vlistZaxis(vlistID_dummy, index_dummy)
-	end function vlistZaxis
-
-	function vlistZaxisIndex(vlistID_dummy, zaxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: zaxisID_dummy
-		interface
-			integer(c_int) function lib_vlistZaxisIndex(vlistID_dummy, zaxisID_dummy) bind(c, name = 'vlistZaxisIndex')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: zaxisID_dummy
-			end function lib_vlistZaxisIndex
-		end interface
-		result = lib_vlistZaxisIndex(vlistID_dummy, zaxisID_dummy)
-	end function vlistZaxisIndex
-
-	subroutine vlistChangeZaxisIndex(vlistID_dummy, index_dummy, zaxisID_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: index_dummy
-		integer(c_int), value :: zaxisID_dummy
-		interface
-			subroutine lib_vlistChangeZaxisIndex(vlistID_dummy, index_dummy, zaxisID_dummy) bind(c, name = 'vlistChangeZaxisIndex')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: index_dummy
-				integer(c_int), value :: zaxisID_dummy
-			end subroutine lib_vlistChangeZaxisIndex
-		end interface
-		call lib_vlistChangeZaxisIndex(vlistID_dummy, index_dummy, zaxisID_dummy)
-	end subroutine vlistChangeZaxisIndex
-
-	subroutine vlistChangeZaxis(vlistID_dummy, zaxisID1_dummy, zaxisID2_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: zaxisID1_dummy
-		integer(c_int), value :: zaxisID2_dummy
-		interface
-			subroutine lib_vlistChangeZaxis(vlistID_dummy, zaxisID1_dummy, zaxisID2_dummy) bind(c, name = 'vlistChangeZaxis')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: zaxisID1_dummy
-				integer(c_int), value :: zaxisID2_dummy
-			end subroutine lib_vlistChangeZaxis
-		end interface
-		call lib_vlistChangeZaxis(vlistID_dummy, zaxisID1_dummy, zaxisID2_dummy)
-	end subroutine vlistChangeZaxis
-
-	function vlistNrecs(vlistID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		interface
-			integer(c_int) function lib_vlistNrecs(vlistID_dummy) bind(c, name = 'vlistNrecs')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end function lib_vlistNrecs
-		end interface
-		result = lib_vlistNrecs(vlistID_dummy)
-	end function vlistNrecs
-
-	subroutine vlistDefTaxis(vlistID_dummy, taxisID_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: taxisID_dummy
-		interface
-			subroutine lib_vlistDefTaxis(vlistID_dummy, taxisID_dummy) bind(c, name = 'vlistDefTaxis')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: taxisID_dummy
-			end subroutine lib_vlistDefTaxis
-		end interface
-		call lib_vlistDefTaxis(vlistID_dummy, taxisID_dummy)
-	end subroutine vlistDefTaxis
-
-	function vlistInqTaxis(vlistID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		interface
-			integer(c_int) function lib_vlistInqTaxis(vlistID_dummy) bind(c, name = 'vlistInqTaxis')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end function lib_vlistInqTaxis
-		end interface
-		result = lib_vlistInqTaxis(vlistID_dummy)
-	end function vlistInqTaxis
-
-	subroutine vlistDefTable(vlistID_dummy, tableID_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: tableID_dummy
-		interface
-			subroutine lib_vlistDefTable(vlistID_dummy, tableID_dummy) bind(c, name = 'vlistDefTable')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: tableID_dummy
-			end subroutine lib_vlistDefTable
-		end interface
-		call lib_vlistDefTable(vlistID_dummy, tableID_dummy)
-	end subroutine vlistDefTable
-
-	function vlistInqTable(vlistID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		interface
-			integer(c_int) function lib_vlistInqTable(vlistID_dummy) bind(c, name = 'vlistInqTable')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end function lib_vlistInqTable
-		end interface
-		result = lib_vlistInqTable(vlistID_dummy)
-	end function vlistInqTable
-
-	subroutine vlistDefInstitut(vlistID_dummy, instID_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: instID_dummy
-		interface
-			subroutine lib_vlistDefInstitut(vlistID_dummy, instID_dummy) bind(c, name = 'vlistDefInstitut')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: instID_dummy
-			end subroutine lib_vlistDefInstitut
-		end interface
-		call lib_vlistDefInstitut(vlistID_dummy, instID_dummy)
-	end subroutine vlistDefInstitut
-
-	function vlistInqInstitut(vlistID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		interface
-			integer(c_int) function lib_vlistInqInstitut(vlistID_dummy) bind(c, name = 'vlistInqInstitut')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end function lib_vlistInqInstitut
-		end interface
-		result = lib_vlistInqInstitut(vlistID_dummy)
-	end function vlistInqInstitut
-
-	subroutine vlistDefModel(vlistID_dummy, modelID_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: modelID_dummy
-		interface
-			subroutine lib_vlistDefModel(vlistID_dummy, modelID_dummy) bind(c, name = 'vlistDefModel')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: modelID_dummy
-			end subroutine lib_vlistDefModel
-		end interface
-		call lib_vlistDefModel(vlistID_dummy, modelID_dummy)
-	end subroutine vlistDefModel
-
-	function vlistInqModel(vlistID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		interface
-			integer(c_int) function lib_vlistInqModel(vlistID_dummy) bind(c, name = 'vlistInqModel')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-			end function lib_vlistInqModel
-		end interface
-		result = lib_vlistInqModel(vlistID_dummy)
-	end function vlistInqModel
-
-	function vlistDefVar(vlistID_dummy, gridID_dummy, zaxisID_dummy, tsteptype_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: zaxisID_dummy
-		integer(c_int), value :: tsteptype_dummy
-		interface
-			integer(c_int) function lib_vlistDefVar(vlistID_dummy, gridID_dummy, zaxisID_dummy, tsteptype_dummy) bind(c, name = 'vlistDefVar&
-			&')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: zaxisID_dummy
-				integer(c_int), value :: tsteptype_dummy
-			end function lib_vlistDefVar
-		end interface
-		result = lib_vlistDefVar(vlistID_dummy, gridID_dummy, zaxisID_dummy, tsteptype_dummy)
-	end function vlistDefVar
-
-	subroutine vlistChangeVarGrid(vlistID_dummy, varID_dummy, gridID_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: gridID_dummy
-		interface
-			subroutine lib_vlistChangeVarGrid(vlistID_dummy, varID_dummy, gridID_dummy) bind(c, name = 'vlistChangeVarGrid')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: gridID_dummy
-			end subroutine lib_vlistChangeVarGrid
-		end interface
-		call lib_vlistChangeVarGrid(vlistID_dummy, varID_dummy, gridID_dummy)
-	end subroutine vlistChangeVarGrid
-
-	subroutine vlistChangeVarZaxis(vlistID_dummy, varID_dummy, zaxisID_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: zaxisID_dummy
-		interface
-			subroutine lib_vlistChangeVarZaxis(vlistID_dummy, varID_dummy, zaxisID_dummy) bind(c, name = 'vlistChangeVarZaxis')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: zaxisID_dummy
-			end subroutine lib_vlistChangeVarZaxis
-		end interface
-		call lib_vlistChangeVarZaxis(vlistID_dummy, varID_dummy, zaxisID_dummy)
-	end subroutine vlistChangeVarZaxis
-
-	subroutine vlistInqVar(vlistID_dummy, varID_dummy, gridID, zaxisID, tsteptype)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), optional, intent(inout) :: gridID
-		integer(c_int), optional, intent(inout) :: zaxisID
-		integer(c_int), optional, intent(inout) :: tsteptype
-		integer(c_int), target :: gridID_temp
-		type(c_ptr) :: gridID_ptr
-		integer(c_int), target :: zaxisID_temp
-		type(c_ptr) :: zaxisID_ptr
-		integer(c_int), target :: tsteptype_temp
-		type(c_ptr) :: tsteptype_ptr
-		interface
-			subroutine lib_vlistInqVar(vlistID_dummy, varID_dummy, gridID, zaxisID, tsteptype) bind(c, name = 'vlistInqVar')
-				import c_int, c_ptr
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				type(c_ptr), value :: gridID
-				type(c_ptr), value :: zaxisID
-				type(c_ptr), value :: tsteptype
-			end subroutine lib_vlistInqVar
-		end interface
-		gridID_ptr = c_null_ptr
-		if(present(gridID)) gridID_ptr = c_loc(gridID_temp)
-		zaxisID_ptr = c_null_ptr
-		if(present(zaxisID)) zaxisID_ptr = c_loc(zaxisID_temp)
-		tsteptype_ptr = c_null_ptr
-		if(present(tsteptype)) tsteptype_ptr = c_loc(tsteptype_temp)
-		call lib_vlistInqVar(vlistID_dummy, varID_dummy, gridID_ptr, zaxisID_ptr, tsteptype_ptr)
-		if(present(gridID)) gridID = gridID_temp
-		if(present(zaxisID)) zaxisID = zaxisID_temp
-		if(present(tsteptype)) tsteptype = tsteptype_temp
-	end subroutine vlistInqVar
-
-	function vlistInqVarGrid(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarGrid(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarGrid')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarGrid
-		end interface
-		result = lib_vlistInqVarGrid(vlistID_dummy, varID_dummy)
-	end function vlistInqVarGrid
-
-	function vlistInqVarZaxis(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarZaxis(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarZaxis')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarZaxis
-		end interface
-		result = lib_vlistInqVarZaxis(vlistID_dummy, varID_dummy)
-	end function vlistInqVarZaxis
-
-	function vlistInqVarID(vlistID_dummy, code_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: code_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarID(vlistID_dummy, code_dummy) bind(c, name = 'vlistInqVarID')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: code_dummy
-			end function lib_vlistInqVarID
-		end interface
-		result = lib_vlistInqVarID(vlistID_dummy, code_dummy)
-	end function vlistInqVarID
-
-	subroutine vlistDefVarTsteptype(vlistID_dummy, varID_dummy, tsteptype_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: tsteptype_dummy
-		interface
-			subroutine lib_vlistDefVarTsteptype(vlistID_dummy, varID_dummy, tsteptype_dummy) bind(c, name = 'vlistDefVarTsteptype')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: tsteptype_dummy
-			end subroutine lib_vlistDefVarTsteptype
-		end interface
-		call lib_vlistDefVarTsteptype(vlistID_dummy, varID_dummy, tsteptype_dummy)
-	end subroutine vlistDefVarTsteptype
-
-	function vlistInqVarTsteptype(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarTsteptype(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarTsteptype')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarTsteptype
-		end interface
-		result = lib_vlistInqVarTsteptype(vlistID_dummy, varID_dummy)
-	end function vlistInqVarTsteptype
-
-	subroutine vlistDefVarCompType(vlistID_dummy, varID_dummy, comptype_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: comptype_dummy
-		interface
-			subroutine lib_vlistDefVarCompType(vlistID_dummy, varID_dummy, comptype_dummy) bind(c, name = 'vlistDefVarCompType')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: comptype_dummy
-			end subroutine lib_vlistDefVarCompType
-		end interface
-		call lib_vlistDefVarCompType(vlistID_dummy, varID_dummy, comptype_dummy)
-	end subroutine vlistDefVarCompType
-
-	function vlistInqVarCompType(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarCompType(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarCompType')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarCompType
-		end interface
-		result = lib_vlistInqVarCompType(vlistID_dummy, varID_dummy)
-	end function vlistInqVarCompType
-
-	subroutine vlistDefVarCompLevel(vlistID_dummy, varID_dummy, complevel_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: complevel_dummy
-		interface
-			subroutine lib_vlistDefVarCompLevel(vlistID_dummy, varID_dummy, complevel_dummy) bind(c, name = 'vlistDefVarCompLevel')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: complevel_dummy
-			end subroutine lib_vlistDefVarCompLevel
-		end interface
-		call lib_vlistDefVarCompLevel(vlistID_dummy, varID_dummy, complevel_dummy)
-	end subroutine vlistDefVarCompLevel
-
-	function vlistInqVarCompLevel(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarCompLevel(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarCompLevel')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarCompLevel
-		end interface
-		result = lib_vlistInqVarCompLevel(vlistID_dummy, varID_dummy)
-	end function vlistInqVarCompLevel
-
-	subroutine vlistDefVarParam(vlistID_dummy, varID_dummy, param_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: param_dummy
-		interface
-			subroutine lib_vlistDefVarParam(vlistID_dummy, varID_dummy, param_dummy) bind(c, name = 'vlistDefVarParam')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: param_dummy
-			end subroutine lib_vlistDefVarParam
-		end interface
-		call lib_vlistDefVarParam(vlistID_dummy, varID_dummy, param_dummy)
-	end subroutine vlistDefVarParam
-
-	function vlistInqVarParam(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarParam(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarParam')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarParam
-		end interface
-		result = lib_vlistInqVarParam(vlistID_dummy, varID_dummy)
-	end function vlistInqVarParam
-
-	subroutine vlistDefVarCode(vlistID_dummy, varID_dummy, code_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: code_dummy
-		interface
-			subroutine lib_vlistDefVarCode(vlistID_dummy, varID_dummy, code_dummy) bind(c, name = 'vlistDefVarCode')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: code_dummy
-			end subroutine lib_vlistDefVarCode
-		end interface
-		call lib_vlistDefVarCode(vlistID_dummy, varID_dummy, code_dummy)
-	end subroutine vlistDefVarCode
-
-	function vlistInqVarCode(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarCode(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarCode')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarCode
-		end interface
-		result = lib_vlistInqVarCode(vlistID_dummy, varID_dummy)
-	end function vlistInqVarCode
-
-	subroutine vlistDefVarDatatype(vlistID_dummy, varID_dummy, datatype_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: datatype_dummy
-		interface
-			subroutine lib_vlistDefVarDatatype(vlistID_dummy, varID_dummy, datatype_dummy) bind(c, name = 'vlistDefVarDatatype')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: datatype_dummy
-			end subroutine lib_vlistDefVarDatatype
-		end interface
-		call lib_vlistDefVarDatatype(vlistID_dummy, varID_dummy, datatype_dummy)
-	end subroutine vlistDefVarDatatype
-
-	function vlistInqVarDatatype(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarDatatype(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarDatatype')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarDatatype
-		end interface
-		result = lib_vlistInqVarDatatype(vlistID_dummy, varID_dummy)
-	end function vlistInqVarDatatype
-
-	subroutine vlistDefVarChunkType(vlistID_dummy, varID_dummy, chunktype_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: chunktype_dummy
-		interface
-			subroutine lib_vlistDefVarChunkType(vlistID_dummy, varID_dummy, chunktype_dummy) bind(c, name = 'vlistDefVarChunkType')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: chunktype_dummy
-			end subroutine lib_vlistDefVarChunkType
-		end interface
-		call lib_vlistDefVarChunkType(vlistID_dummy, varID_dummy, chunktype_dummy)
-	end subroutine vlistDefVarChunkType
-
-	function vlistInqVarChunkType(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarChunkType(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarChunkType')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarChunkType
-		end interface
-		result = lib_vlistInqVarChunkType(vlistID_dummy, varID_dummy)
-	end function vlistInqVarChunkType
-
-	subroutine vlistDefVarXYZ(vlistID_dummy, varID_dummy, xyz_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: xyz_dummy
-		interface
-			subroutine lib_vlistDefVarXYZ(vlistID_dummy, varID_dummy, xyz_dummy) bind(c, name = 'vlistDefVarXYZ')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: xyz_dummy
-			end subroutine lib_vlistDefVarXYZ
-		end interface
-		call lib_vlistDefVarXYZ(vlistID_dummy, varID_dummy, xyz_dummy)
-	end subroutine vlistDefVarXYZ
-
-	function vlistInqVarXYZ(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarXYZ(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarXYZ')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarXYZ
-		end interface
-		result = lib_vlistInqVarXYZ(vlistID_dummy, varID_dummy)
-	end function vlistInqVarXYZ
-
-	function vlistInqVarNumber(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarNumber(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarNumber')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarNumber
-		end interface
-		result = lib_vlistInqVarNumber(vlistID_dummy, varID_dummy)
-	end function vlistInqVarNumber
-
-	subroutine vlistDefVarInstitut(vlistID_dummy, varID_dummy, instID_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: instID_dummy
-		interface
-			subroutine lib_vlistDefVarInstitut(vlistID_dummy, varID_dummy, instID_dummy) bind(c, name = 'vlistDefVarInstitut')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: instID_dummy
-			end subroutine lib_vlistDefVarInstitut
-		end interface
-		call lib_vlistDefVarInstitut(vlistID_dummy, varID_dummy, instID_dummy)
-	end subroutine vlistDefVarInstitut
-
-	function vlistInqVarInstitut(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarInstitut(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarInstitut')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarInstitut
-		end interface
-		result = lib_vlistInqVarInstitut(vlistID_dummy, varID_dummy)
-	end function vlistInqVarInstitut
-
-	subroutine vlistDefVarModel(vlistID_dummy, varID_dummy, modelID_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: modelID_dummy
-		interface
-			subroutine lib_vlistDefVarModel(vlistID_dummy, varID_dummy, modelID_dummy) bind(c, name = 'vlistDefVarModel')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: modelID_dummy
-			end subroutine lib_vlistDefVarModel
-		end interface
-		call lib_vlistDefVarModel(vlistID_dummy, varID_dummy, modelID_dummy)
-	end subroutine vlistDefVarModel
-
-	function vlistInqVarModel(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarModel(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarModel')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarModel
-		end interface
-		result = lib_vlistInqVarModel(vlistID_dummy, varID_dummy)
-	end function vlistInqVarModel
-
-	subroutine vlistDefVarTable(vlistID_dummy, varID_dummy, tableID_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: tableID_dummy
-		interface
-			subroutine lib_vlistDefVarTable(vlistID_dummy, varID_dummy, tableID_dummy) bind(c, name = 'vlistDefVarTable')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: tableID_dummy
-			end subroutine lib_vlistDefVarTable
-		end interface
-		call lib_vlistDefVarTable(vlistID_dummy, varID_dummy, tableID_dummy)
-	end subroutine vlistDefVarTable
-
-	function vlistInqVarTable(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarTable(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarTable')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarTable
-		end interface
-		result = lib_vlistInqVarTable(vlistID_dummy, varID_dummy)
-	end function vlistInqVarTable
-
-	subroutine vlistDefVarName(vlistID_dummy, varID_dummy, name_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		interface
-			subroutine lib_vlistDefVarName(vlistID_dummy, varID_dummy, name_dummy) bind(c, name = 'vlistDefVarName')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: name_dummy(*)
-			end subroutine lib_vlistDefVarName
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		call lib_vlistDefVarName(vlistID_dummy, varID_dummy, name_temp)
-	end subroutine vlistDefVarName
-
-	subroutine vlistInqVarName(vlistID_dummy, varID_dummy, name_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(inout) :: name_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy))
-		integer :: name_i
-		logical :: name_padding = .true.
-		interface
-			subroutine lib_vlistInqVarName(vlistID_dummy, varID_dummy, name_dummy) bind(c, name = 'vlistInqVarName')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: name_dummy(*)
-			end subroutine lib_vlistInqVarName
-		end interface
-		do name_i = len(name_dummy), 1, -1
-			if(name_dummy(name_i:name_i) /= ' ') name_padding = .false.
-			if(name_padding) then
-				name_temp(name_i) = c_null_char
-			else
-				name_temp(name_i) = name_dummy(name_i:name_i)
-			end if
-		end do
-		call lib_vlistInqVarName(vlistID_dummy, varID_dummy, name_temp)
-		name_padding = .false.
-		do name_i = 1, len(name_dummy)
-			if(name_temp(name_i) == c_null_char) name_padding = .true.
-			if(name_padding) then
-				name_dummy(name_i:name_i) = ' '
-			else
-				name_dummy(name_i:name_i) = name_temp(name_i)
-			end if
-		end do
-	end subroutine vlistInqVarName
-
-	function vlistCopyVarName(vlistId_dummy, varId_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		integer(c_int), value :: vlistId_dummy
-		integer(c_int), value :: varId_dummy
-		type(c_ptr) :: cString
-		integer :: shape(1)
-		character(kind = c_char), dimension(:), pointer :: temp
-		interface
-			type(c_ptr) function lib_vlistCopyVarName(vlistId_dummy, varId_dummy) bind(c, name = 'vlistCopyVarName')
-				import c_int, c_ptr
-				integer(c_int), value :: vlistId_dummy
-				integer(c_int), value :: varId_dummy
-			end function lib_vlistCopyVarName
-		end interface
-		cString = lib_vlistCopyVarName(vlistId_dummy, varId_dummy)
-		if(c_associated(cString)) then
-			shape(1) = int(lib_strlen(cString))
-			call c_f_pointer(cString, temp, shape)
-			allocate(result(shape(1)))
-			result = temp
-			call lib_free(cString)
-		else
-			result => null()
-		end if
-	end function vlistCopyVarName
-
-	subroutine vlistDefVarStdname(vlistID_dummy, varID_dummy, stdname_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: stdname_dummy
-		character(kind = c_char) :: stdname_temp(len(stdname_dummy) + 1)
-		integer :: stdname_i
-		interface
-			subroutine lib_vlistDefVarStdname(vlistID_dummy, varID_dummy, stdname_dummy) bind(c, name = 'vlistDefVarStdname')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: stdname_dummy(*)
-			end subroutine lib_vlistDefVarStdname
-		end interface
-		do stdname_i = 1, len(stdname_dummy)
-		stdname_temp(stdname_i) = stdname_dummy(stdname_i:stdname_i)
-		end do
-		stdname_temp(len(stdname_dummy) + 1) = c_null_char
-		call lib_vlistDefVarStdname(vlistID_dummy, varID_dummy, stdname_temp)
-	end subroutine vlistDefVarStdname
-
-	subroutine vlistInqVarStdname(vlistID_dummy, varID_dummy, stdname_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(inout) :: stdname_dummy
-		character(kind = c_char) :: stdname_temp(len(stdname_dummy))
-		integer :: stdname_i
-		logical :: stdname_padding = .true.
-		interface
-			subroutine lib_vlistInqVarStdname(vlistID_dummy, varID_dummy, stdname_dummy) bind(c, name = 'vlistInqVarStdname')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: stdname_dummy(*)
-			end subroutine lib_vlistInqVarStdname
-		end interface
-		do stdname_i = len(stdname_dummy), 1, -1
-			if(stdname_dummy(stdname_i:stdname_i) /= ' ') stdname_padding = .false.
-			if(stdname_padding) then
-				stdname_temp(stdname_i) = c_null_char
-			else
-				stdname_temp(stdname_i) = stdname_dummy(stdname_i:stdname_i)
-			end if
-		end do
-		call lib_vlistInqVarStdname(vlistID_dummy, varID_dummy, stdname_temp)
-		stdname_padding = .false.
-		do stdname_i = 1, len(stdname_dummy)
-			if(stdname_temp(stdname_i) == c_null_char) stdname_padding = .true.
-			if(stdname_padding) then
-				stdname_dummy(stdname_i:stdname_i) = ' '
-			else
-				stdname_dummy(stdname_i:stdname_i) = stdname_temp(stdname_i)
-			end if
-		end do
-	end subroutine vlistInqVarStdname
-
-	subroutine vlistDefVarLongname(vlistID_dummy, varID_dummy, longname_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: longname_dummy
-		character(kind = c_char) :: longname_temp(len(longname_dummy) + 1)
-		integer :: longname_i
-		interface
-			subroutine lib_vlistDefVarLongname(vlistID_dummy, varID_dummy, longname_dummy) bind(c, name = 'vlistDefVarLongname')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: longname_dummy(*)
-			end subroutine lib_vlistDefVarLongname
-		end interface
-		do longname_i = 1, len(longname_dummy)
-		longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
-		end do
-		longname_temp(len(longname_dummy) + 1) = c_null_char
-		call lib_vlistDefVarLongname(vlistID_dummy, varID_dummy, longname_temp)
-	end subroutine vlistDefVarLongname
-
-	subroutine vlistInqVarLongname(vlistID_dummy, varID_dummy, longname_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(inout) :: longname_dummy
-		character(kind = c_char) :: longname_temp(len(longname_dummy))
-		integer :: longname_i
-		logical :: longname_padding = .true.
-		interface
-			subroutine lib_vlistInqVarLongname(vlistID_dummy, varID_dummy, longname_dummy) bind(c, name = 'vlistInqVarLongname')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: longname_dummy(*)
-			end subroutine lib_vlistInqVarLongname
-		end interface
-		do longname_i = len(longname_dummy), 1, -1
-			if(longname_dummy(longname_i:longname_i) /= ' ') longname_padding = .false.
-			if(longname_padding) then
-				longname_temp(longname_i) = c_null_char
-			else
-				longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
-			end if
-		end do
-		call lib_vlistInqVarLongname(vlistID_dummy, varID_dummy, longname_temp)
-		longname_padding = .false.
-		do longname_i = 1, len(longname_dummy)
-			if(longname_temp(longname_i) == c_null_char) longname_padding = .true.
-			if(longname_padding) then
-				longname_dummy(longname_i:longname_i) = ' '
-			else
-				longname_dummy(longname_i:longname_i) = longname_temp(longname_i)
-			end if
-		end do
-	end subroutine vlistInqVarLongname
-
-	subroutine vlistDefVarUnits(vlistID_dummy, varID_dummy, units_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: units_dummy
-		character(kind = c_char) :: units_temp(len(units_dummy) + 1)
-		integer :: units_i
-		interface
-			subroutine lib_vlistDefVarUnits(vlistID_dummy, varID_dummy, units_dummy) bind(c, name = 'vlistDefVarUnits')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: units_dummy(*)
-			end subroutine lib_vlistDefVarUnits
-		end interface
-		do units_i = 1, len(units_dummy)
-		units_temp(units_i) = units_dummy(units_i:units_i)
-		end do
-		units_temp(len(units_dummy) + 1) = c_null_char
-		call lib_vlistDefVarUnits(vlistID_dummy, varID_dummy, units_temp)
-	end subroutine vlistDefVarUnits
-
-	subroutine vlistInqVarUnits(vlistID_dummy, varID_dummy, units_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(inout) :: units_dummy
-		character(kind = c_char) :: units_temp(len(units_dummy))
-		integer :: units_i
-		logical :: units_padding = .true.
-		interface
-			subroutine lib_vlistInqVarUnits(vlistID_dummy, varID_dummy, units_dummy) bind(c, name = 'vlistInqVarUnits')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: units_dummy(*)
-			end subroutine lib_vlistInqVarUnits
-		end interface
-		do units_i = len(units_dummy), 1, -1
-			if(units_dummy(units_i:units_i) /= ' ') units_padding = .false.
-			if(units_padding) then
-				units_temp(units_i) = c_null_char
-			else
-				units_temp(units_i) = units_dummy(units_i:units_i)
-			end if
-		end do
-		call lib_vlistInqVarUnits(vlistID_dummy, varID_dummy, units_temp)
-		units_padding = .false.
-		do units_i = 1, len(units_dummy)
-			if(units_temp(units_i) == c_null_char) units_padding = .true.
-			if(units_padding) then
-				units_dummy(units_i:units_i) = ' '
-			else
-				units_dummy(units_i:units_i) = units_temp(units_i)
-			end if
-		end do
-	end subroutine vlistInqVarUnits
-
-	subroutine vlistDefVarMissval(vlistID_dummy, varID_dummy, missval_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		real(c_double), value :: missval_dummy
-		interface
-			subroutine lib_vlistDefVarMissval(vlistID_dummy, varID_dummy, missval_dummy) bind(c, name = 'vlistDefVarMissval')
-				import c_double, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				real(c_double), value :: missval_dummy
-			end subroutine lib_vlistDefVarMissval
-		end interface
-		call lib_vlistDefVarMissval(vlistID_dummy, varID_dummy, missval_dummy)
-	end subroutine vlistDefVarMissval
-
-	function vlistInqVarMissval(vlistID_dummy, varID_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			real(c_double) function lib_vlistInqVarMissval(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarMissval')
-				import c_double, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarMissval
-		end interface
-		result = lib_vlistInqVarMissval(vlistID_dummy, varID_dummy)
-	end function vlistInqVarMissval
-
-	subroutine vlistDefVarExtra(vlistID_dummy, varID_dummy, extra_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: extra_dummy
-		character(kind = c_char) :: extra_temp(len(extra_dummy) + 1)
-		integer :: extra_i
-		interface
-			subroutine lib_vlistDefVarExtra(vlistID_dummy, varID_dummy, extra_dummy) bind(c, name = 'vlistDefVarExtra')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: extra_dummy(*)
-			end subroutine lib_vlistDefVarExtra
-		end interface
-		do extra_i = 1, len(extra_dummy)
-		extra_temp(extra_i) = extra_dummy(extra_i:extra_i)
-		end do
-		extra_temp(len(extra_dummy) + 1) = c_null_char
-		call lib_vlistDefVarExtra(vlistID_dummy, varID_dummy, extra_temp)
-	end subroutine vlistDefVarExtra
-
-	subroutine vlistInqVarExtra(vlistID_dummy, varID_dummy, extra_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(inout) :: extra_dummy
-		character(kind = c_char) :: extra_temp(len(extra_dummy))
-		integer :: extra_i
-		logical :: extra_padding = .true.
-		interface
-			subroutine lib_vlistInqVarExtra(vlistID_dummy, varID_dummy, extra_dummy) bind(c, name = 'vlistInqVarExtra')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: extra_dummy(*)
-			end subroutine lib_vlistInqVarExtra
-		end interface
-		do extra_i = len(extra_dummy), 1, -1
-			if(extra_dummy(extra_i:extra_i) /= ' ') extra_padding = .false.
-			if(extra_padding) then
-				extra_temp(extra_i) = c_null_char
-			else
-				extra_temp(extra_i) = extra_dummy(extra_i:extra_i)
-			end if
-		end do
-		call lib_vlistInqVarExtra(vlistID_dummy, varID_dummy, extra_temp)
-		extra_padding = .false.
-		do extra_i = 1, len(extra_dummy)
-			if(extra_temp(extra_i) == c_null_char) extra_padding = .true.
-			if(extra_padding) then
-				extra_dummy(extra_i:extra_i) = ' '
-			else
-				extra_dummy(extra_i:extra_i) = extra_temp(extra_i)
-			end if
-		end do
-	end subroutine vlistInqVarExtra
-
-	subroutine vlistDefVarScalefactor(vlistID_dummy, varID_dummy, scalefactor_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		real(c_double), value :: scalefactor_dummy
-		interface
-			subroutine lib_vlistDefVarScalefactor(vlistID_dummy, varID_dummy, scalefactor_dummy) bind(c, name = 'vlistDefVarScalefactor')
-				import c_double, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				real(c_double), value :: scalefactor_dummy
-			end subroutine lib_vlistDefVarScalefactor
-		end interface
-		call lib_vlistDefVarScalefactor(vlistID_dummy, varID_dummy, scalefactor_dummy)
-	end subroutine vlistDefVarScalefactor
-
-	function vlistInqVarScalefactor(vlistID_dummy, varID_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			real(c_double) function lib_vlistInqVarScalefactor(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarScalefactor')
-				import c_double, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarScalefactor
-		end interface
-		result = lib_vlistInqVarScalefactor(vlistID_dummy, varID_dummy)
-	end function vlistInqVarScalefactor
-
-	subroutine vlistDefVarAddoffset(vlistID_dummy, varID_dummy, addoffset_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		real(c_double), value :: addoffset_dummy
-		interface
-			subroutine lib_vlistDefVarAddoffset(vlistID_dummy, varID_dummy, addoffset_dummy) bind(c, name = 'vlistDefVarAddoffset')
-				import c_double, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				real(c_double), value :: addoffset_dummy
-			end subroutine lib_vlistDefVarAddoffset
-		end interface
-		call lib_vlistDefVarAddoffset(vlistID_dummy, varID_dummy, addoffset_dummy)
-	end subroutine vlistDefVarAddoffset
-
-	function vlistInqVarAddoffset(vlistID_dummy, varID_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			real(c_double) function lib_vlistInqVarAddoffset(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarAddoffset')
-				import c_double, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarAddoffset
-		end interface
-		result = lib_vlistInqVarAddoffset(vlistID_dummy, varID_dummy)
-	end function vlistInqVarAddoffset
-
-	subroutine vlistDefVarTimave(vlistID_dummy, varID_dummy, timave_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: timave_dummy
-		interface
-			subroutine lib_vlistDefVarTimave(vlistID_dummy, varID_dummy, timave_dummy) bind(c, name = 'vlistDefVarTimave')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: timave_dummy
-			end subroutine lib_vlistDefVarTimave
-		end interface
-		call lib_vlistDefVarTimave(vlistID_dummy, varID_dummy, timave_dummy)
-	end subroutine vlistDefVarTimave
-
-	function vlistInqVarTimave(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarTimave(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarTimave')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarTimave
-		end interface
-		result = lib_vlistInqVarTimave(vlistID_dummy, varID_dummy)
-	end function vlistInqVarTimave
-
-	subroutine vlistDefVarTimaccu(vlistID_dummy, varID_dummy, timaccu_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: timaccu_dummy
-		interface
-			subroutine lib_vlistDefVarTimaccu(vlistID_dummy, varID_dummy, timaccu_dummy) bind(c, name = 'vlistDefVarTimaccu')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: timaccu_dummy
-			end subroutine lib_vlistDefVarTimaccu
-		end interface
-		call lib_vlistDefVarTimaccu(vlistID_dummy, varID_dummy, timaccu_dummy)
-	end subroutine vlistDefVarTimaccu
-
-	function vlistInqVarTimaccu(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarTimaccu(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarTimaccu')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarTimaccu
-		end interface
-		result = lib_vlistInqVarTimaccu(vlistID_dummy, varID_dummy)
-	end function vlistInqVarTimaccu
-
-	subroutine vlistDefVarTypeOfGeneratingProcess(vlistID_dummy, varID_dummy, typeOfGeneratingProcess_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: typeOfGeneratingProcess_dummy
-		interface
-			subroutine lib_vlistDefVarTypeOfGeneratingProcess(vlistID_dummy, varID_dummy, typeOfGeneratingProcess_dummy) bind(c, name = 'vli&
-			&stDefVarTypeOfGeneratingProcess')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: typeOfGeneratingProcess_dummy
-			end subroutine lib_vlistDefVarTypeOfGeneratingProcess
-		end interface
-		call lib_vlistDefVarTypeOfGeneratingProcess(vlistID_dummy, varID_dummy, typeOfGeneratingProcess_dummy)
-	end subroutine vlistDefVarTypeOfGeneratingProcess
-
-	function vlistInqVarTypeOfGeneratingProcess(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarTypeOfGeneratingProcess(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarTypeOfGene&
-			&ratingProcess')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarTypeOfGeneratingProcess
-		end interface
-		result = lib_vlistInqVarTypeOfGeneratingProcess(vlistID_dummy, varID_dummy)
-	end function vlistInqVarTypeOfGeneratingProcess
-
-	subroutine vlistDefVarProductDefinitionTemplate(vlistID_dummy, varID_dummy, productDefinitionTemplate_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: productDefinitionTemplate_dummy
-		interface
-			subroutine lib_vlistDefVarProductDefinitionTemplate(vlistID_dummy, varID_dummy, productDefinitionTemplate_dummy) bind(c, name = &
-			&'vlistDefVarProductDefinitionTemplate')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: productDefinitionTemplate_dummy
-			end subroutine lib_vlistDefVarProductDefinitionTemplate
-		end interface
-		call lib_vlistDefVarProductDefinitionTemplate(vlistID_dummy, varID_dummy, productDefinitionTemplate_dummy)
-	end subroutine vlistDefVarProductDefinitionTemplate
-
-	function vlistInqVarProductDefinitionTemplate(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarProductDefinitionTemplate(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarProductD&
-			&efinitionTemplate')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarProductDefinitionTemplate
-		end interface
-		result = lib_vlistInqVarProductDefinitionTemplate(vlistID_dummy, varID_dummy)
-	end function vlistInqVarProductDefinitionTemplate
-
-	function vlistInqVarSize(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistInqVarSize(vlistID_dummy, varID_dummy) bind(c, name = 'vlistInqVarSize')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistInqVarSize
-		end interface
-		result = lib_vlistInqVarSize(vlistID_dummy, varID_dummy)
-	end function vlistInqVarSize
-
-	subroutine vlistDefIndex(vlistID_dummy, varID_dummy, levID_dummy, index_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: levID_dummy
-		integer(c_int), value :: index_dummy
-		interface
-			subroutine lib_vlistDefIndex(vlistID_dummy, varID_dummy, levID_dummy, index_dummy) bind(c, name = 'vlistDefIndex')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: levID_dummy
-				integer(c_int), value :: index_dummy
-			end subroutine lib_vlistDefIndex
-		end interface
-		call lib_vlistDefIndex(vlistID_dummy, varID_dummy, levID_dummy, index_dummy)
-	end subroutine vlistDefIndex
-
-	function vlistInqIndex(vlistID_dummy, varID_dummy, levID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: levID_dummy
-		interface
-			integer(c_int) function lib_vlistInqIndex(vlistID_dummy, varID_dummy, levID_dummy) bind(c, name = 'vlistInqIndex')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: levID_dummy
-			end function lib_vlistInqIndex
-		end interface
-		result = lib_vlistInqIndex(vlistID_dummy, varID_dummy, levID_dummy)
-	end function vlistInqIndex
-
-	subroutine vlistDefFlag(vlistID_dummy, varID_dummy, levID_dummy, flag_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: levID_dummy
-		integer(c_int), value :: flag_dummy
-		interface
-			subroutine lib_vlistDefFlag(vlistID_dummy, varID_dummy, levID_dummy, flag_dummy) bind(c, name = 'vlistDefFlag')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: levID_dummy
-				integer(c_int), value :: flag_dummy
-			end subroutine lib_vlistDefFlag
-		end interface
-		call lib_vlistDefFlag(vlistID_dummy, varID_dummy, levID_dummy, flag_dummy)
-	end subroutine vlistDefFlag
-
-	function vlistInqFlag(vlistID_dummy, varID_dummy, levID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: levID_dummy
-		interface
-			integer(c_int) function lib_vlistInqFlag(vlistID_dummy, varID_dummy, levID_dummy) bind(c, name = 'vlistInqFlag')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: levID_dummy
-			end function lib_vlistInqFlag
-		end interface
-		result = lib_vlistInqFlag(vlistID_dummy, varID_dummy, levID_dummy)
-	end function vlistInqFlag
-
-	function vlistFindVar(vlistID_dummy, fvarID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: fvarID_dummy
-		interface
-			integer(c_int) function lib_vlistFindVar(vlistID_dummy, fvarID_dummy) bind(c, name = 'vlistFindVar')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: fvarID_dummy
-			end function lib_vlistFindVar
-		end interface
-		result = lib_vlistFindVar(vlistID_dummy, fvarID_dummy)
-	end function vlistFindVar
-
-	function vlistFindLevel(vlistID_dummy, fvarID_dummy, flevelID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: fvarID_dummy
-		integer(c_int), value :: flevelID_dummy
-		interface
-			integer(c_int) function lib_vlistFindLevel(vlistID_dummy, fvarID_dummy, flevelID_dummy) bind(c, name = 'vlistFindLevel')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: fvarID_dummy
-				integer(c_int), value :: flevelID_dummy
-			end function lib_vlistFindLevel
-		end interface
-		result = lib_vlistFindLevel(vlistID_dummy, fvarID_dummy, flevelID_dummy)
-	end function vlistFindLevel
-
-	function vlistMergedVar(vlistID_dummy, varID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		interface
-			integer(c_int) function lib_vlistMergedVar(vlistID_dummy, varID_dummy) bind(c, name = 'vlistMergedVar')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-			end function lib_vlistMergedVar
-		end interface
-		result = lib_vlistMergedVar(vlistID_dummy, varID_dummy)
-	end function vlistMergedVar
-
-	function vlistMergedLevel(vlistID_dummy, varID_dummy, levelID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: levelID_dummy
-		interface
-			integer(c_int) function lib_vlistMergedLevel(vlistID_dummy, varID_dummy, levelID_dummy) bind(c, name = 'vlistMergedLevel')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: levelID_dummy
-			end function lib_vlistMergedLevel
-		end interface
-		result = lib_vlistMergedLevel(vlistID_dummy, varID_dummy, levelID_dummy)
-	end function vlistMergedLevel
-
-	subroutine vlistDefVarEnsemble(vlistID_dummy, varID_dummy, ensID_dummy, ensCount_dummy, forecast_type_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: ensID_dummy
-		integer(c_int), value :: ensCount_dummy
-		integer(c_int), value :: forecast_type_dummy
-		interface
-			subroutine lib_vlistDefVarEnsemble(vlistID_dummy, varID_dummy, ensID_dummy, ensCount_dummy, forecast_type_dummy) bind(c, name = &
-			&'vlistDefVarEnsemble')
-				import c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: ensID_dummy
-				integer(c_int), value :: ensCount_dummy
-				integer(c_int), value :: forecast_type_dummy
-			end subroutine lib_vlistDefVarEnsemble
-		end interface
-		call lib_vlistDefVarEnsemble(vlistID_dummy, varID_dummy, ensID_dummy, ensCount_dummy, forecast_type_dummy)
-	end subroutine vlistDefVarEnsemble
-
-	function vlistInqVarEnsemble(vlistID_dummy, varID_dummy, ensID, ensCount, forecast_type) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), optional, intent(inout) :: ensID
-		integer(c_int), optional, intent(inout) :: ensCount
-		integer(c_int), optional, intent(inout) :: forecast_type
-		integer(c_int), target :: ensID_temp
-		type(c_ptr) :: ensID_ptr
-		integer(c_int), target :: ensCount_temp
-		type(c_ptr) :: ensCount_ptr
-		integer(c_int), target :: forecast_type_temp
-		type(c_ptr) :: forecast_type_ptr
-		interface
-			integer(c_int) function lib_vlistInqVarEnsemble(vlistID_dummy, varID_dummy, ensID, ensCount, forecast_type) bind(c, name = 'vlis&
-			&tInqVarEnsemble')
-				import c_int, c_ptr
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				type(c_ptr), value :: ensID
-				type(c_ptr), value :: ensCount
-				type(c_ptr), value :: forecast_type
-			end function lib_vlistInqVarEnsemble
-		end interface
-		ensID_ptr = c_null_ptr
-		if(present(ensID)) ensID_ptr = c_loc(ensID_temp)
-		ensCount_ptr = c_null_ptr
-		if(present(ensCount)) ensCount_ptr = c_loc(ensCount_temp)
-		forecast_type_ptr = c_null_ptr
-		if(present(forecast_type)) forecast_type_ptr = c_loc(forecast_type_temp)
-		result = lib_vlistInqVarEnsemble(vlistID_dummy, varID_dummy, ensID_ptr, ensCount_ptr, forecast_type_ptr)
-		if(present(ensID)) ensID = ensID_temp
-		if(present(ensCount)) ensCount = ensCount_temp
-		if(present(forecast_type)) forecast_type = forecast_type_temp
-	end function vlistInqVarEnsemble
-
-	subroutine cdiClearAdditionalKeys()
-		interface
-			subroutine lib_cdiClearAdditionalKeys() bind(c, name = 'cdiClearAdditionalKeys')
-			end subroutine lib_cdiClearAdditionalKeys
-		end interface
-		call lib_cdiClearAdditionalKeys()
-	end subroutine cdiClearAdditionalKeys
-
-	subroutine cdiDefAdditionalKey(string_dummy)
-		character(kind = c_char, len = *), intent(in) :: string_dummy
-		character(kind = c_char) :: string_temp(len(string_dummy) + 1)
-		integer :: string_i
-		interface
-			subroutine lib_cdiDefAdditionalKey(string_dummy) bind(c, name = 'cdiDefAdditionalKey')
-				import c_char
-				character(kind = c_char) :: string_dummy(*)
-			end subroutine lib_cdiDefAdditionalKey
-		end interface
-		do string_i = 1, len(string_dummy)
-		string_temp(string_i) = string_dummy(string_i:string_i)
-		end do
-		string_temp(len(string_dummy) + 1) = c_null_char
-		call lib_cdiDefAdditionalKey(string_temp)
-	end subroutine cdiDefAdditionalKey
-
-	subroutine vlistDefVarIntKey(vlistID_dummy, varID_dummy, name_dummy, value_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		integer(c_int), value :: value_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		interface
-			subroutine lib_vlistDefVarIntKey(vlistID_dummy, varID_dummy, name_dummy, value_dummy) bind(c, name = 'vlistDefVarIntKey')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: name_dummy(*)
-				integer(c_int), value :: value_dummy
-			end subroutine lib_vlistDefVarIntKey
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		call lib_vlistDefVarIntKey(vlistID_dummy, varID_dummy, name_temp, value_dummy)
-	end subroutine vlistDefVarIntKey
-
-	subroutine vlistDefVarDblKey(vlistID_dummy, varID_dummy, name_dummy, value_dummy)
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		real(c_double), value :: value_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		interface
-			subroutine lib_vlistDefVarDblKey(vlistID_dummy, varID_dummy, name_dummy, value_dummy) bind(c, name = 'vlistDefVarDblKey')
-				import c_char, c_double, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: name_dummy(*)
-				real(c_double), value :: value_dummy
-			end subroutine lib_vlistDefVarDblKey
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		call lib_vlistDefVarDblKey(vlistID_dummy, varID_dummy, name_temp, value_dummy)
-	end subroutine vlistDefVarDblKey
-
-	function vlistHasVarKey(vlistID_dummy, varID_dummy, name_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		interface
-			integer(c_int) function lib_vlistHasVarKey(vlistID_dummy, varID_dummy, name_dummy) bind(c, name = 'vlistHasVarKey')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: name_dummy(*)
-			end function lib_vlistHasVarKey
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		result = lib_vlistHasVarKey(vlistID_dummy, varID_dummy, name_temp)
-	end function vlistHasVarKey
-
-	function vlistInqVarDblKey(vlistID_dummy, varID_dummy, name_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		interface
-			real(c_double) function lib_vlistInqVarDblKey(vlistID_dummy, varID_dummy, name_dummy) bind(c, name = 'vlistInqVarDblKey')
-				import c_char, c_double, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: name_dummy(*)
-			end function lib_vlistInqVarDblKey
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		result = lib_vlistInqVarDblKey(vlistID_dummy, varID_dummy, name_temp)
-	end function vlistInqVarDblKey
-
-	function vlistInqVarIntKey(vlistID_dummy, varID_dummy, name_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		interface
-			integer(c_int) function lib_vlistInqVarIntKey(vlistID_dummy, varID_dummy, name_dummy) bind(c, name = 'vlistInqVarIntKey')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: name_dummy(*)
-			end function lib_vlistInqVarIntKey
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		result = lib_vlistInqVarIntKey(vlistID_dummy, varID_dummy, name_temp)
-	end function vlistInqVarIntKey
-
-	function vlistInqNatts(vlistID_dummy, varID_dummy, nattsp) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), optional, intent(inout) :: nattsp
-		integer(c_int), target :: nattsp_temp
-		type(c_ptr) :: nattsp_ptr
-		interface
-			integer(c_int) function lib_vlistInqNatts(vlistID_dummy, varID_dummy, nattsp) bind(c, name = 'vlistInqNatts')
-				import c_int, c_ptr
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				type(c_ptr), value :: nattsp
-			end function lib_vlistInqNatts
-		end interface
-		nattsp_ptr = c_null_ptr
-		if(present(nattsp)) nattsp_ptr = c_loc(nattsp_temp)
-		result = lib_vlistInqNatts(vlistID_dummy, varID_dummy, nattsp_ptr)
-		if(present(nattsp)) nattsp = nattsp_temp
-	end function vlistInqNatts
-
-	function vlistInqAtt(vlistID_dummy, varID_dummy, attrnum_dummy, name_dummy, typep, lenp) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		integer(c_int), value :: attrnum_dummy
-		character(kind = c_char, len = *), intent(inout) :: name_dummy
-		integer(c_int), optional, intent(inout) :: typep
-		integer(c_int), optional, intent(inout) :: lenp
-		character(kind = c_char) :: name_temp(len(name_dummy))
-		integer :: name_i
-		logical :: name_padding = .true.
-		integer(c_int), target :: typep_temp
-		type(c_ptr) :: typep_ptr
-		integer(c_int), target :: lenp_temp
-		type(c_ptr) :: lenp_ptr
-		interface
-			integer(c_int) function lib_vlistInqAtt(vlistID_dummy, varID_dummy, attrnum_dummy, name_dummy, typep, lenp) bind(c, name = 'vlis&
-			&tInqAtt')
-				import c_char, c_int, c_ptr
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				integer(c_int), value :: attrnum_dummy
-				character(kind = c_char) :: name_dummy(*)
-				type(c_ptr), value :: typep
-				type(c_ptr), value :: lenp
-			end function lib_vlistInqAtt
-		end interface
-		do name_i = len(name_dummy), 1, -1
-			if(name_dummy(name_i:name_i) /= ' ') name_padding = .false.
-			if(name_padding) then
-				name_temp(name_i) = c_null_char
-			else
-				name_temp(name_i) = name_dummy(name_i:name_i)
-			end if
-		end do
-		typep_ptr = c_null_ptr
-		if(present(typep)) typep_ptr = c_loc(typep_temp)
-		lenp_ptr = c_null_ptr
-		if(present(lenp)) lenp_ptr = c_loc(lenp_temp)
-		result = lib_vlistInqAtt(vlistID_dummy, varID_dummy, attrnum_dummy, name_temp, typep_ptr, lenp_ptr)
-		name_padding = .false.
-		do name_i = 1, len(name_dummy)
-			if(name_temp(name_i) == c_null_char) name_padding = .true.
-			if(name_padding) then
-				name_dummy(name_i:name_i) = ' '
-			else
-				name_dummy(name_i:name_i) = name_temp(name_i)
-			end if
-		end do
-		if(present(typep)) typep = typep_temp
-		if(present(lenp)) lenp = lenp_temp
-	end function vlistInqAtt
-
-	function vlistDelAtt(vlistID_dummy, varID_dummy, name_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		interface
-			integer(c_int) function lib_vlistDelAtt(vlistID_dummy, varID_dummy, name_dummy) bind(c, name = 'vlistDelAtt')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: name_dummy(*)
-			end function lib_vlistDelAtt
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		result = lib_vlistDelAtt(vlistID_dummy, varID_dummy, name_temp)
-	end function vlistDelAtt
-
-	function vlistDefAttInt(vlistID_dummy, varID_dummy, name_dummy, type_dummy, len_dummy, ip_vec_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		integer(c_int), value :: type_dummy
-		integer(c_int), value :: len_dummy
-		integer(c_int), intent(in) :: ip_vec_dummy(*)
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		interface
-			integer(c_int) function lib_vlistDefAttInt(vlistID_dummy, varID_dummy, name_dummy, type_dummy, len_dummy, ip_vec_dummy) bind(c, &
-			&name = 'vlistDefAttInt')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: name_dummy(*)
-				integer(c_int), value :: type_dummy
-				integer(c_int), value :: len_dummy
-				integer(c_int), intent(in) :: ip_vec_dummy(*)
-			end function lib_vlistDefAttInt
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		result = lib_vlistDefAttInt(vlistID_dummy, varID_dummy, name_temp, type_dummy, len_dummy, ip_vec_dummy)
-	end function vlistDefAttInt
-
-	function vlistDefAttFlt(vlistID_dummy, varID_dummy, name_dummy, type_dummy, len_dummy, dp_vec_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		integer(c_int), value :: type_dummy
-		integer(c_int), value :: len_dummy
-		real(c_double), intent(in) :: dp_vec_dummy(*)
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		interface
-			integer(c_int) function lib_vlistDefAttFlt(vlistID_dummy, varID_dummy, name_dummy, type_dummy, len_dummy, dp_vec_dummy) bind(c, &
-			&name = 'vlistDefAttFlt')
-				import c_char, c_double, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: name_dummy(*)
-				integer(c_int), value :: type_dummy
-				integer(c_int), value :: len_dummy
-				real(c_double), intent(in) :: dp_vec_dummy(*)
-			end function lib_vlistDefAttFlt
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		result = lib_vlistDefAttFlt(vlistID_dummy, varID_dummy, name_temp, type_dummy, len_dummy, dp_vec_dummy)
-	end function vlistDefAttFlt
-
-	function vlistDefAttTxt(vlistID_dummy, varID_dummy, name_dummy, len_dummy, tp_cbuf_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		integer(c_int), value :: len_dummy
-		character(kind = c_char, len = *), intent(in) :: tp_cbuf_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		character(kind = c_char) :: tp_cbuf_temp(len(tp_cbuf_dummy) + 1)
-		integer :: tp_cbuf_i
-		interface
-			integer(c_int) function lib_vlistDefAttTxt(vlistID_dummy, varID_dummy, name_dummy, len_dummy, tp_cbuf_dummy) bind(c, name = 'vli&
-			&stDefAttTxt')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: name_dummy(*)
-				integer(c_int), value :: len_dummy
-				character(kind = c_char) :: tp_cbuf_dummy(*)
-			end function lib_vlistDefAttTxt
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		do tp_cbuf_i = 1, len(tp_cbuf_dummy)
-		tp_cbuf_temp(tp_cbuf_i) = tp_cbuf_dummy(tp_cbuf_i:tp_cbuf_i)
-		end do
-		tp_cbuf_temp(len(tp_cbuf_dummy) + 1) = c_null_char
-		result = lib_vlistDefAttTxt(vlistID_dummy, varID_dummy, name_temp, len_dummy, tp_cbuf_temp)
-	end function vlistDefAttTxt
-
-	function vlistInqAttInt(vlistID_dummy, varID_dummy, name_dummy, mlen_dummy, ip_vec_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		integer(c_int), value :: mlen_dummy
-		integer(c_int), intent(inout) :: ip_vec_dummy(*)
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		interface
-			integer(c_int) function lib_vlistInqAttInt(vlistID_dummy, varID_dummy, name_dummy, mlen_dummy, ip_vec_dummy) bind(c, name = 'vli&
-			&stInqAttInt')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: name_dummy(*)
-				integer(c_int), value :: mlen_dummy
-				integer(c_int), intent(inout) :: ip_vec_dummy(*)
-			end function lib_vlistInqAttInt
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		result = lib_vlistInqAttInt(vlistID_dummy, varID_dummy, name_temp, mlen_dummy, ip_vec_dummy)
-	end function vlistInqAttInt
-
-	function vlistInqAttFlt(vlistID_dummy, varID_dummy, name_dummy, mlen_dummy, dp_vec_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		integer(c_int), value :: mlen_dummy
-		real(c_double), intent(inout) :: dp_vec_dummy(*)
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		interface
-			integer(c_int) function lib_vlistInqAttFlt(vlistID_dummy, varID_dummy, name_dummy, mlen_dummy, dp_vec_dummy) bind(c, name = 'vli&
-			&stInqAttFlt')
-				import c_char, c_double, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: name_dummy(*)
-				integer(c_int), value :: mlen_dummy
-				real(c_double), intent(inout) :: dp_vec_dummy(*)
-			end function lib_vlistInqAttFlt
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		result = lib_vlistInqAttFlt(vlistID_dummy, varID_dummy, name_temp, mlen_dummy, dp_vec_dummy)
-	end function vlistInqAttFlt
-
-	function vlistInqAttTxt(vlistID_dummy, varID_dummy, name_dummy, mlen_dummy, tp_cbuf_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: vlistID_dummy
-		integer(c_int), value :: varID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		integer(c_int), value :: mlen_dummy
-		character(kind = c_char, len = *), intent(inout) :: tp_cbuf_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		character(kind = c_char) :: tp_cbuf_temp(len(tp_cbuf_dummy))
-		integer :: tp_cbuf_i
-		logical :: tp_cbuf_padding = .true.
-		interface
-			integer(c_int) function lib_vlistInqAttTxt(vlistID_dummy, varID_dummy, name_dummy, mlen_dummy, tp_cbuf_dummy) bind(c, name = 'vl&
-			&istInqAttTxt')
-				import c_char, c_int
-				integer(c_int), value :: vlistID_dummy
-				integer(c_int), value :: varID_dummy
-				character(kind = c_char) :: name_dummy(*)
-				integer(c_int), value :: mlen_dummy
-				character(kind = c_char) :: tp_cbuf_dummy(*)
-			end function lib_vlistInqAttTxt
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		do tp_cbuf_i = len(tp_cbuf_dummy), 1, -1
-			if(tp_cbuf_dummy(tp_cbuf_i:tp_cbuf_i) /= ' ') tp_cbuf_padding = .false.
-			if(tp_cbuf_padding) then
-				tp_cbuf_temp(tp_cbuf_i) = c_null_char
-			else
-				tp_cbuf_temp(tp_cbuf_i) = tp_cbuf_dummy(tp_cbuf_i:tp_cbuf_i)
-			end if
-		end do
-		result = lib_vlistInqAttTxt(vlistID_dummy, varID_dummy, name_temp, mlen_dummy, tp_cbuf_temp)
-		tp_cbuf_padding = .false.
-		do tp_cbuf_i = 1, len(tp_cbuf_dummy)
-			if(tp_cbuf_temp(tp_cbuf_i) == c_null_char) tp_cbuf_padding = .true.
-			if(tp_cbuf_padding) then
-				tp_cbuf_dummy(tp_cbuf_i:tp_cbuf_i) = ' '
-			else
-				tp_cbuf_dummy(tp_cbuf_i:tp_cbuf_i) = tp_cbuf_temp(tp_cbuf_i)
-			end if
-		end do
-	end function vlistInqAttTxt
-
-	subroutine gridName(gridtype_dummy, gridname_dummy)
-		integer(c_int), value :: gridtype_dummy
-		character(kind = c_char, len = *), intent(inout) :: gridname_dummy
-		character(kind = c_char) :: gridname_temp(len(gridname_dummy))
-		integer :: gridname_i
-		logical :: gridname_padding = .true.
-		interface
-			subroutine lib_gridName(gridtype_dummy, gridname_dummy) bind(c, name = 'gridName')
-				import c_char, c_int
-				integer(c_int), value :: gridtype_dummy
-				character(kind = c_char) :: gridname_dummy(*)
-			end subroutine lib_gridName
-		end interface
-		do gridname_i = len(gridname_dummy), 1, -1
-			if(gridname_dummy(gridname_i:gridname_i) /= ' ') gridname_padding = .false.
-			if(gridname_padding) then
-				gridname_temp(gridname_i) = c_null_char
-			else
-				gridname_temp(gridname_i) = gridname_dummy(gridname_i:gridname_i)
-			end if
-		end do
-		call lib_gridName(gridtype_dummy, gridname_temp)
-		gridname_padding = .false.
-		do gridname_i = 1, len(gridname_dummy)
-			if(gridname_temp(gridname_i) == c_null_char) gridname_padding = .true.
-			if(gridname_padding) then
-				gridname_dummy(gridname_i:gridname_i) = ' '
-			else
-				gridname_dummy(gridname_i:gridname_i) = gridname_temp(gridname_i)
-			end if
-		end do
-	end subroutine gridName
-
-	function gridNamePtr(gridtype_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		integer(c_int), value :: gridtype_dummy
-		type(c_ptr) :: ptr
-		integer :: shape(1)
-		interface
-			type(c_ptr) function lib_gridNamePtr(gridtype_dummy) bind(c, name = 'gridNamePtr')
-				import c_int, c_ptr
-				integer(c_int), value :: gridtype_dummy
-			end function lib_gridNamePtr
-		end interface
-		result => null()
-		ptr = lib_gridNamePtr(gridtype_dummy)
-		if(c_associated(ptr)) then
-			shape(1) = int(lib_strlen(ptr))
-			call c_f_pointer(ptr, result, shape)
-		end if
-	end function gridNamePtr
-
-	subroutine gridCompress(gridID_dummy)
-		integer(c_int), value :: gridID_dummy
-		interface
-			subroutine lib_gridCompress(gridID_dummy) bind(c, name = 'gridCompress')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end subroutine lib_gridCompress
-		end interface
-		call lib_gridCompress(gridID_dummy)
-	end subroutine gridCompress
-
-	subroutine gridDefMaskGME(gridID_dummy, mask_vec_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), intent(in) :: mask_vec_dummy(*)
-		interface
-			subroutine lib_gridDefMaskGME(gridID_dummy, mask_vec_dummy) bind(c, name = 'gridDefMaskGME')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), intent(in) :: mask_vec_dummy(*)
-			end subroutine lib_gridDefMaskGME
-		end interface
-		call lib_gridDefMaskGME(gridID_dummy, mask_vec_dummy)
-	end subroutine gridDefMaskGME
-
-	function gridInqMaskGME(gridID_dummy, mask_vec_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), intent(inout) :: mask_vec_dummy(*)
-		interface
-			integer(c_int) function lib_gridInqMaskGME(gridID_dummy, mask_vec_dummy) bind(c, name = 'gridInqMaskGME')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), intent(inout) :: mask_vec_dummy(*)
-			end function lib_gridInqMaskGME
-		end interface
-		result = lib_gridInqMaskGME(gridID_dummy, mask_vec_dummy)
-	end function gridInqMaskGME
-
-	subroutine gridDefMask(gridID_dummy, mask_vec_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), intent(in) :: mask_vec_dummy(*)
-		interface
-			subroutine lib_gridDefMask(gridID_dummy, mask_vec_dummy) bind(c, name = 'gridDefMask')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), intent(in) :: mask_vec_dummy(*)
-			end subroutine lib_gridDefMask
-		end interface
-		call lib_gridDefMask(gridID_dummy, mask_vec_dummy)
-	end subroutine gridDefMask
-
-	function gridInqMask(gridID_dummy, mask_vec_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), intent(inout) :: mask_vec_dummy(*)
-		interface
-			integer(c_int) function lib_gridInqMask(gridID_dummy, mask_vec_dummy) bind(c, name = 'gridInqMask')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), intent(inout) :: mask_vec_dummy(*)
-			end function lib_gridInqMask
-		end interface
-		result = lib_gridInqMask(gridID_dummy, mask_vec_dummy)
-	end function gridInqMask
-
-	subroutine gridPrint(gridID_dummy, index_dummy, opt_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: index_dummy
-		integer(c_int), value :: opt_dummy
-		interface
-			subroutine lib_gridPrint(gridID_dummy, index_dummy, opt_dummy) bind(c, name = 'gridPrint')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: index_dummy
-				integer(c_int), value :: opt_dummy
-			end subroutine lib_gridPrint
-		end interface
-		call lib_gridPrint(gridID_dummy, index_dummy, opt_dummy)
-	end subroutine gridPrint
-
-	function gridCreate(gridtype_dummy, size_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridtype_dummy
-		integer(c_int), value :: size_dummy
-		interface
-			integer(c_int) function lib_gridCreate(gridtype_dummy, size_dummy) bind(c, name = 'gridCreate')
-				import c_int
-				integer(c_int), value :: gridtype_dummy
-				integer(c_int), value :: size_dummy
-			end function lib_gridCreate
-		end interface
-		result = lib_gridCreate(gridtype_dummy, size_dummy)
-	end function gridCreate
-
-	subroutine gridDestroy(gridID_dummy)
-		integer(c_int), value :: gridID_dummy
-		interface
-			subroutine lib_gridDestroy(gridID_dummy) bind(c, name = 'gridDestroy')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end subroutine lib_gridDestroy
-		end interface
-		call lib_gridDestroy(gridID_dummy)
-	end subroutine gridDestroy
-
-	function gridDuplicate(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridDuplicate(gridID_dummy) bind(c, name = 'gridDuplicate')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridDuplicate
-		end interface
-		result = lib_gridDuplicate(gridID_dummy)
-	end function gridDuplicate
-
-	function gridInqType(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqType(gridID_dummy) bind(c, name = 'gridInqType')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqType
-		end interface
-		result = lib_gridInqType(gridID_dummy)
-	end function gridInqType
-
-	function gridInqSize(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqSize(gridID_dummy) bind(c, name = 'gridInqSize')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqSize
-		end interface
-		result = lib_gridInqSize(gridID_dummy)
-	end function gridInqSize
-
-	subroutine gridDefXsize(gridID_dummy, xsize_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: xsize_dummy
-		interface
-			subroutine lib_gridDefXsize(gridID_dummy, xsize_dummy) bind(c, name = 'gridDefXsize')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: xsize_dummy
-			end subroutine lib_gridDefXsize
-		end interface
-		call lib_gridDefXsize(gridID_dummy, xsize_dummy)
-	end subroutine gridDefXsize
-
-	function gridInqXsize(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqXsize(gridID_dummy) bind(c, name = 'gridInqXsize')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqXsize
-		end interface
-		result = lib_gridInqXsize(gridID_dummy)
-	end function gridInqXsize
-
-	subroutine gridDefYsize(gridID_dummy, ysize_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: ysize_dummy
-		interface
-			subroutine lib_gridDefYsize(gridID_dummy, ysize_dummy) bind(c, name = 'gridDefYsize')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: ysize_dummy
-			end subroutine lib_gridDefYsize
-		end interface
-		call lib_gridDefYsize(gridID_dummy, ysize_dummy)
-	end subroutine gridDefYsize
-
-	function gridInqYsize(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqYsize(gridID_dummy) bind(c, name = 'gridInqYsize')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqYsize
-		end interface
-		result = lib_gridInqYsize(gridID_dummy)
-	end function gridInqYsize
-
-	subroutine gridDefNP(gridID_dummy, np_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: np_dummy
-		interface
-			subroutine lib_gridDefNP(gridID_dummy, np_dummy) bind(c, name = 'gridDefNP')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: np_dummy
-			end subroutine lib_gridDefNP
-		end interface
-		call lib_gridDefNP(gridID_dummy, np_dummy)
-	end subroutine gridDefNP
-
-	function gridInqNP(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqNP(gridID_dummy) bind(c, name = 'gridInqNP')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqNP
-		end interface
-		result = lib_gridInqNP(gridID_dummy)
-	end function gridInqNP
-
-	subroutine gridDefXvals(gridID_dummy, xvals_vec_dummy)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), intent(in) :: xvals_vec_dummy(*)
-		interface
-			subroutine lib_gridDefXvals(gridID_dummy, xvals_vec_dummy) bind(c, name = 'gridDefXvals')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), intent(in) :: xvals_vec_dummy(*)
-			end subroutine lib_gridDefXvals
-		end interface
-		call lib_gridDefXvals(gridID_dummy, xvals_vec_dummy)
-	end subroutine gridDefXvals
-
-	function gridInqXvals(gridID_dummy, xvals_vec_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		real(c_double), intent(inout) :: xvals_vec_dummy(*)
-		interface
-			integer(c_int) function lib_gridInqXvals(gridID_dummy, xvals_vec_dummy) bind(c, name = 'gridInqXvals')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), intent(inout) :: xvals_vec_dummy(*)
-			end function lib_gridInqXvals
-		end interface
-		result = lib_gridInqXvals(gridID_dummy, xvals_vec_dummy)
-	end function gridInqXvals
-
-	subroutine gridDefYvals(gridID_dummy, yvals_vec_dummy)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), intent(in) :: yvals_vec_dummy(*)
-		interface
-			subroutine lib_gridDefYvals(gridID_dummy, yvals_vec_dummy) bind(c, name = 'gridDefYvals')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), intent(in) :: yvals_vec_dummy(*)
-			end subroutine lib_gridDefYvals
-		end interface
-		call lib_gridDefYvals(gridID_dummy, yvals_vec_dummy)
-	end subroutine gridDefYvals
-
-	function gridInqYvals(gridID_dummy, yvals_vec_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		real(c_double), intent(inout) :: yvals_vec_dummy(*)
-		interface
-			integer(c_int) function lib_gridInqYvals(gridID_dummy, yvals_vec_dummy) bind(c, name = 'gridInqYvals')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), intent(inout) :: yvals_vec_dummy(*)
-			end function lib_gridInqYvals
-		end interface
-		result = lib_gridInqYvals(gridID_dummy, yvals_vec_dummy)
-	end function gridInqYvals
-
-	subroutine gridDefXname(gridID_dummy, xname_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(in) :: xname_dummy
-		character(kind = c_char) :: xname_temp(len(xname_dummy) + 1)
-		integer :: xname_i
-		interface
-			subroutine lib_gridDefXname(gridID_dummy, xname_dummy) bind(c, name = 'gridDefXname')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: xname_dummy(*)
-			end subroutine lib_gridDefXname
-		end interface
-		do xname_i = 1, len(xname_dummy)
-		xname_temp(xname_i) = xname_dummy(xname_i:xname_i)
-		end do
-		xname_temp(len(xname_dummy) + 1) = c_null_char
-		call lib_gridDefXname(gridID_dummy, xname_temp)
-	end subroutine gridDefXname
-
-	subroutine gridInqXname(gridID_dummy, xname_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(inout) :: xname_dummy
-		character(kind = c_char) :: xname_temp(len(xname_dummy))
-		integer :: xname_i
-		logical :: xname_padding = .true.
-		interface
-			subroutine lib_gridInqXname(gridID_dummy, xname_dummy) bind(c, name = 'gridInqXname')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: xname_dummy(*)
-			end subroutine lib_gridInqXname
-		end interface
-		do xname_i = len(xname_dummy), 1, -1
-			if(xname_dummy(xname_i:xname_i) /= ' ') xname_padding = .false.
-			if(xname_padding) then
-				xname_temp(xname_i) = c_null_char
-			else
-				xname_temp(xname_i) = xname_dummy(xname_i:xname_i)
-			end if
-		end do
-		call lib_gridInqXname(gridID_dummy, xname_temp)
-		xname_padding = .false.
-		do xname_i = 1, len(xname_dummy)
-			if(xname_temp(xname_i) == c_null_char) xname_padding = .true.
-			if(xname_padding) then
-				xname_dummy(xname_i:xname_i) = ' '
-			else
-				xname_dummy(xname_i:xname_i) = xname_temp(xname_i)
-			end if
-		end do
-	end subroutine gridInqXname
-
-	subroutine gridDefXlongname(gridID_dummy, xlongname_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(in) :: xlongname_dummy
-		character(kind = c_char) :: xlongname_temp(len(xlongname_dummy) + 1)
-		integer :: xlongname_i
-		interface
-			subroutine lib_gridDefXlongname(gridID_dummy, xlongname_dummy) bind(c, name = 'gridDefXlongname')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: xlongname_dummy(*)
-			end subroutine lib_gridDefXlongname
-		end interface
-		do xlongname_i = 1, len(xlongname_dummy)
-		xlongname_temp(xlongname_i) = xlongname_dummy(xlongname_i:xlongname_i)
-		end do
-		xlongname_temp(len(xlongname_dummy) + 1) = c_null_char
-		call lib_gridDefXlongname(gridID_dummy, xlongname_temp)
-	end subroutine gridDefXlongname
-
-	subroutine gridInqXlongname(gridID_dummy, xlongname_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(inout) :: xlongname_dummy
-		character(kind = c_char) :: xlongname_temp(len(xlongname_dummy))
-		integer :: xlongname_i
-		logical :: xlongname_padding = .true.
-		interface
-			subroutine lib_gridInqXlongname(gridID_dummy, xlongname_dummy) bind(c, name = 'gridInqXlongname')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: xlongname_dummy(*)
-			end subroutine lib_gridInqXlongname
-		end interface
-		do xlongname_i = len(xlongname_dummy), 1, -1
-			if(xlongname_dummy(xlongname_i:xlongname_i) /= ' ') xlongname_padding = .false.
-			if(xlongname_padding) then
-				xlongname_temp(xlongname_i) = c_null_char
-			else
-				xlongname_temp(xlongname_i) = xlongname_dummy(xlongname_i:xlongname_i)
-			end if
-		end do
-		call lib_gridInqXlongname(gridID_dummy, xlongname_temp)
-		xlongname_padding = .false.
-		do xlongname_i = 1, len(xlongname_dummy)
-			if(xlongname_temp(xlongname_i) == c_null_char) xlongname_padding = .true.
-			if(xlongname_padding) then
-				xlongname_dummy(xlongname_i:xlongname_i) = ' '
-			else
-				xlongname_dummy(xlongname_i:xlongname_i) = xlongname_temp(xlongname_i)
-			end if
-		end do
-	end subroutine gridInqXlongname
-
-	subroutine gridDefXunits(gridID_dummy, xunits_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(in) :: xunits_dummy
-		character(kind = c_char) :: xunits_temp(len(xunits_dummy) + 1)
-		integer :: xunits_i
-		interface
-			subroutine lib_gridDefXunits(gridID_dummy, xunits_dummy) bind(c, name = 'gridDefXunits')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: xunits_dummy(*)
-			end subroutine lib_gridDefXunits
-		end interface
-		do xunits_i = 1, len(xunits_dummy)
-		xunits_temp(xunits_i) = xunits_dummy(xunits_i:xunits_i)
-		end do
-		xunits_temp(len(xunits_dummy) + 1) = c_null_char
-		call lib_gridDefXunits(gridID_dummy, xunits_temp)
-	end subroutine gridDefXunits
-
-	subroutine gridInqXunits(gridID_dummy, xunits_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(inout) :: xunits_dummy
-		character(kind = c_char) :: xunits_temp(len(xunits_dummy))
-		integer :: xunits_i
-		logical :: xunits_padding = .true.
-		interface
-			subroutine lib_gridInqXunits(gridID_dummy, xunits_dummy) bind(c, name = 'gridInqXunits')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: xunits_dummy(*)
-			end subroutine lib_gridInqXunits
-		end interface
-		do xunits_i = len(xunits_dummy), 1, -1
-			if(xunits_dummy(xunits_i:xunits_i) /= ' ') xunits_padding = .false.
-			if(xunits_padding) then
-				xunits_temp(xunits_i) = c_null_char
-			else
-				xunits_temp(xunits_i) = xunits_dummy(xunits_i:xunits_i)
-			end if
-		end do
-		call lib_gridInqXunits(gridID_dummy, xunits_temp)
-		xunits_padding = .false.
-		do xunits_i = 1, len(xunits_dummy)
-			if(xunits_temp(xunits_i) == c_null_char) xunits_padding = .true.
-			if(xunits_padding) then
-				xunits_dummy(xunits_i:xunits_i) = ' '
-			else
-				xunits_dummy(xunits_i:xunits_i) = xunits_temp(xunits_i)
-			end if
-		end do
-	end subroutine gridInqXunits
-
-	subroutine gridDefYname(gridID_dummy, yname_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(in) :: yname_dummy
-		character(kind = c_char) :: yname_temp(len(yname_dummy) + 1)
-		integer :: yname_i
-		interface
-			subroutine lib_gridDefYname(gridID_dummy, yname_dummy) bind(c, name = 'gridDefYname')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: yname_dummy(*)
-			end subroutine lib_gridDefYname
-		end interface
-		do yname_i = 1, len(yname_dummy)
-		yname_temp(yname_i) = yname_dummy(yname_i:yname_i)
-		end do
-		yname_temp(len(yname_dummy) + 1) = c_null_char
-		call lib_gridDefYname(gridID_dummy, yname_temp)
-	end subroutine gridDefYname
-
-	subroutine gridInqYname(gridID_dummy, yname_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(inout) :: yname_dummy
-		character(kind = c_char) :: yname_temp(len(yname_dummy))
-		integer :: yname_i
-		logical :: yname_padding = .true.
-		interface
-			subroutine lib_gridInqYname(gridID_dummy, yname_dummy) bind(c, name = 'gridInqYname')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: yname_dummy(*)
-			end subroutine lib_gridInqYname
-		end interface
-		do yname_i = len(yname_dummy), 1, -1
-			if(yname_dummy(yname_i:yname_i) /= ' ') yname_padding = .false.
-			if(yname_padding) then
-				yname_temp(yname_i) = c_null_char
-			else
-				yname_temp(yname_i) = yname_dummy(yname_i:yname_i)
-			end if
-		end do
-		call lib_gridInqYname(gridID_dummy, yname_temp)
-		yname_padding = .false.
-		do yname_i = 1, len(yname_dummy)
-			if(yname_temp(yname_i) == c_null_char) yname_padding = .true.
-			if(yname_padding) then
-				yname_dummy(yname_i:yname_i) = ' '
-			else
-				yname_dummy(yname_i:yname_i) = yname_temp(yname_i)
-			end if
-		end do
-	end subroutine gridInqYname
-
-	subroutine gridDefYlongname(gridID_dummy, ylongname_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(in) :: ylongname_dummy
-		character(kind = c_char) :: ylongname_temp(len(ylongname_dummy) + 1)
-		integer :: ylongname_i
-		interface
-			subroutine lib_gridDefYlongname(gridID_dummy, ylongname_dummy) bind(c, name = 'gridDefYlongname')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: ylongname_dummy(*)
-			end subroutine lib_gridDefYlongname
-		end interface
-		do ylongname_i = 1, len(ylongname_dummy)
-		ylongname_temp(ylongname_i) = ylongname_dummy(ylongname_i:ylongname_i)
-		end do
-		ylongname_temp(len(ylongname_dummy) + 1) = c_null_char
-		call lib_gridDefYlongname(gridID_dummy, ylongname_temp)
-	end subroutine gridDefYlongname
-
-	subroutine gridInqYlongname(gridID_dummy, ylongname_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(inout) :: ylongname_dummy
-		character(kind = c_char) :: ylongname_temp(len(ylongname_dummy))
-		integer :: ylongname_i
-		logical :: ylongname_padding = .true.
-		interface
-			subroutine lib_gridInqYlongname(gridID_dummy, ylongname_dummy) bind(c, name = 'gridInqYlongname')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: ylongname_dummy(*)
-			end subroutine lib_gridInqYlongname
-		end interface
-		do ylongname_i = len(ylongname_dummy), 1, -1
-			if(ylongname_dummy(ylongname_i:ylongname_i) /= ' ') ylongname_padding = .false.
-			if(ylongname_padding) then
-				ylongname_temp(ylongname_i) = c_null_char
-			else
-				ylongname_temp(ylongname_i) = ylongname_dummy(ylongname_i:ylongname_i)
-			end if
-		end do
-		call lib_gridInqYlongname(gridID_dummy, ylongname_temp)
-		ylongname_padding = .false.
-		do ylongname_i = 1, len(ylongname_dummy)
-			if(ylongname_temp(ylongname_i) == c_null_char) ylongname_padding = .true.
-			if(ylongname_padding) then
-				ylongname_dummy(ylongname_i:ylongname_i) = ' '
-			else
-				ylongname_dummy(ylongname_i:ylongname_i) = ylongname_temp(ylongname_i)
-			end if
-		end do
-	end subroutine gridInqYlongname
-
-	subroutine gridDefYunits(gridID_dummy, yunits_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(in) :: yunits_dummy
-		character(kind = c_char) :: yunits_temp(len(yunits_dummy) + 1)
-		integer :: yunits_i
-		interface
-			subroutine lib_gridDefYunits(gridID_dummy, yunits_dummy) bind(c, name = 'gridDefYunits')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: yunits_dummy(*)
-			end subroutine lib_gridDefYunits
-		end interface
-		do yunits_i = 1, len(yunits_dummy)
-		yunits_temp(yunits_i) = yunits_dummy(yunits_i:yunits_i)
-		end do
-		yunits_temp(len(yunits_dummy) + 1) = c_null_char
-		call lib_gridDefYunits(gridID_dummy, yunits_temp)
-	end subroutine gridDefYunits
-
-	subroutine gridInqYunits(gridID_dummy, yunits_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(inout) :: yunits_dummy
-		character(kind = c_char) :: yunits_temp(len(yunits_dummy))
-		integer :: yunits_i
-		logical :: yunits_padding = .true.
-		interface
-			subroutine lib_gridInqYunits(gridID_dummy, yunits_dummy) bind(c, name = 'gridInqYunits')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: yunits_dummy(*)
-			end subroutine lib_gridInqYunits
-		end interface
-		do yunits_i = len(yunits_dummy), 1, -1
-			if(yunits_dummy(yunits_i:yunits_i) /= ' ') yunits_padding = .false.
-			if(yunits_padding) then
-				yunits_temp(yunits_i) = c_null_char
-			else
-				yunits_temp(yunits_i) = yunits_dummy(yunits_i:yunits_i)
-			end if
-		end do
-		call lib_gridInqYunits(gridID_dummy, yunits_temp)
-		yunits_padding = .false.
-		do yunits_i = 1, len(yunits_dummy)
-			if(yunits_temp(yunits_i) == c_null_char) yunits_padding = .true.
-			if(yunits_padding) then
-				yunits_dummy(yunits_i:yunits_i) = ' '
-			else
-				yunits_dummy(yunits_i:yunits_i) = yunits_temp(yunits_i)
-			end if
-		end do
-	end subroutine gridInqYunits
-
-	subroutine gridInqXstdname(gridID_dummy, xstdname_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(inout) :: xstdname_dummy
-		character(kind = c_char) :: xstdname_temp(len(xstdname_dummy))
-		integer :: xstdname_i
-		logical :: xstdname_padding = .true.
-		interface
-			subroutine lib_gridInqXstdname(gridID_dummy, xstdname_dummy) bind(c, name = 'gridInqXstdname')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: xstdname_dummy(*)
-			end subroutine lib_gridInqXstdname
-		end interface
-		do xstdname_i = len(xstdname_dummy), 1, -1
-			if(xstdname_dummy(xstdname_i:xstdname_i) /= ' ') xstdname_padding = .false.
-			if(xstdname_padding) then
-				xstdname_temp(xstdname_i) = c_null_char
-			else
-				xstdname_temp(xstdname_i) = xstdname_dummy(xstdname_i:xstdname_i)
-			end if
-		end do
-		call lib_gridInqXstdname(gridID_dummy, xstdname_temp)
-		xstdname_padding = .false.
-		do xstdname_i = 1, len(xstdname_dummy)
-			if(xstdname_temp(xstdname_i) == c_null_char) xstdname_padding = .true.
-			if(xstdname_padding) then
-				xstdname_dummy(xstdname_i:xstdname_i) = ' '
-			else
-				xstdname_dummy(xstdname_i:xstdname_i) = xstdname_temp(xstdname_i)
-			end if
-		end do
-	end subroutine gridInqXstdname
-
-	subroutine gridInqYstdname(gridID_dummy, ystdname_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(inout) :: ystdname_dummy
-		character(kind = c_char) :: ystdname_temp(len(ystdname_dummy))
-		integer :: ystdname_i
-		logical :: ystdname_padding = .true.
-		interface
-			subroutine lib_gridInqYstdname(gridID_dummy, ystdname_dummy) bind(c, name = 'gridInqYstdname')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: ystdname_dummy(*)
-			end subroutine lib_gridInqYstdname
-		end interface
-		do ystdname_i = len(ystdname_dummy), 1, -1
-			if(ystdname_dummy(ystdname_i:ystdname_i) /= ' ') ystdname_padding = .false.
-			if(ystdname_padding) then
-				ystdname_temp(ystdname_i) = c_null_char
-			else
-				ystdname_temp(ystdname_i) = ystdname_dummy(ystdname_i:ystdname_i)
-			end if
-		end do
-		call lib_gridInqYstdname(gridID_dummy, ystdname_temp)
-		ystdname_padding = .false.
-		do ystdname_i = 1, len(ystdname_dummy)
-			if(ystdname_temp(ystdname_i) == c_null_char) ystdname_padding = .true.
-			if(ystdname_padding) then
-				ystdname_dummy(ystdname_i:ystdname_i) = ' '
-			else
-				ystdname_dummy(ystdname_i:ystdname_i) = ystdname_temp(ystdname_i)
-			end if
-		end do
-	end subroutine gridInqYstdname
-
-	subroutine gridDefPrec(gridID_dummy, prec_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: prec_dummy
-		interface
-			subroutine lib_gridDefPrec(gridID_dummy, prec_dummy) bind(c, name = 'gridDefPrec')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: prec_dummy
-			end subroutine lib_gridDefPrec
-		end interface
-		call lib_gridDefPrec(gridID_dummy, prec_dummy)
-	end subroutine gridDefPrec
-
-	function gridInqPrec(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqPrec(gridID_dummy) bind(c, name = 'gridInqPrec')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqPrec
-		end interface
-		result = lib_gridInqPrec(gridID_dummy)
-	end function gridInqPrec
-
-	function gridInqXval(gridID_dummy, index_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: index_dummy
-		interface
-			real(c_double) function lib_gridInqXval(gridID_dummy, index_dummy) bind(c, name = 'gridInqXval')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: index_dummy
-			end function lib_gridInqXval
-		end interface
-		result = lib_gridInqXval(gridID_dummy, index_dummy)
-	end function gridInqXval
-
-	function gridInqYval(gridID_dummy, index_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: index_dummy
-		interface
-			real(c_double) function lib_gridInqYval(gridID_dummy, index_dummy) bind(c, name = 'gridInqYval')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: index_dummy
-			end function lib_gridInqYval
-		end interface
-		result = lib_gridInqYval(gridID_dummy, index_dummy)
-	end function gridInqYval
-
-	function gridInqXinc(gridID_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			real(c_double) function lib_gridInqXinc(gridID_dummy) bind(c, name = 'gridInqXinc')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqXinc
-		end interface
-		result = lib_gridInqXinc(gridID_dummy)
-	end function gridInqXinc
-
-	function gridInqYinc(gridID_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			real(c_double) function lib_gridInqYinc(gridID_dummy) bind(c, name = 'gridInqYinc')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqYinc
-		end interface
-		result = lib_gridInqYinc(gridID_dummy)
-	end function gridInqYinc
-
-	function gridIsCircular(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridIsCircular(gridID_dummy) bind(c, name = 'gridIsCircular')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridIsCircular
-		end interface
-		result = lib_gridIsCircular(gridID_dummy)
-	end function gridIsCircular
-
-	function gridIsRotated(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridIsRotated(gridID_dummy) bind(c, name = 'gridIsRotated')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridIsRotated
-		end interface
-		result = lib_gridIsRotated(gridID_dummy)
-	end function gridIsRotated
-
-	subroutine gridDefXpole(gridID_dummy, xpole_dummy)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), value :: xpole_dummy
-		interface
-			subroutine lib_gridDefXpole(gridID_dummy, xpole_dummy) bind(c, name = 'gridDefXpole')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), value :: xpole_dummy
-			end subroutine lib_gridDefXpole
-		end interface
-		call lib_gridDefXpole(gridID_dummy, xpole_dummy)
-	end subroutine gridDefXpole
-
-	function gridInqXpole(gridID_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			real(c_double) function lib_gridInqXpole(gridID_dummy) bind(c, name = 'gridInqXpole')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqXpole
-		end interface
-		result = lib_gridInqXpole(gridID_dummy)
-	end function gridInqXpole
-
-	subroutine gridDefYpole(gridID_dummy, ypole_dummy)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), value :: ypole_dummy
-		interface
-			subroutine lib_gridDefYpole(gridID_dummy, ypole_dummy) bind(c, name = 'gridDefYpole')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), value :: ypole_dummy
-			end subroutine lib_gridDefYpole
-		end interface
-		call lib_gridDefYpole(gridID_dummy, ypole_dummy)
-	end subroutine gridDefYpole
-
-	function gridInqYpole(gridID_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			real(c_double) function lib_gridInqYpole(gridID_dummy) bind(c, name = 'gridInqYpole')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqYpole
-		end interface
-		result = lib_gridInqYpole(gridID_dummy)
-	end function gridInqYpole
-
-	subroutine gridDefAngle(gridID_dummy, angle_dummy)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), value :: angle_dummy
-		interface
-			subroutine lib_gridDefAngle(gridID_dummy, angle_dummy) bind(c, name = 'gridDefAngle')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), value :: angle_dummy
-			end subroutine lib_gridDefAngle
-		end interface
-		call lib_gridDefAngle(gridID_dummy, angle_dummy)
-	end subroutine gridDefAngle
-
-	function gridInqAngle(gridID_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			real(c_double) function lib_gridInqAngle(gridID_dummy) bind(c, name = 'gridInqAngle')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqAngle
-		end interface
-		result = lib_gridInqAngle(gridID_dummy)
-	end function gridInqAngle
-
-	function gridInqTrunc(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqTrunc(gridID_dummy) bind(c, name = 'gridInqTrunc')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqTrunc
-		end interface
-		result = lib_gridInqTrunc(gridID_dummy)
-	end function gridInqTrunc
-
-	subroutine gridDefTrunc(gridID_dummy, trunc_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: trunc_dummy
-		interface
-			subroutine lib_gridDefTrunc(gridID_dummy, trunc_dummy) bind(c, name = 'gridDefTrunc')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: trunc_dummy
-			end subroutine lib_gridDefTrunc
-		end interface
-		call lib_gridDefTrunc(gridID_dummy, trunc_dummy)
-	end subroutine gridDefTrunc
-
-	subroutine gridDefGMEnd(gridID_dummy, nd_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: nd_dummy
-		interface
-			subroutine lib_gridDefGMEnd(gridID_dummy, nd_dummy) bind(c, name = 'gridDefGMEnd')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: nd_dummy
-			end subroutine lib_gridDefGMEnd
-		end interface
-		call lib_gridDefGMEnd(gridID_dummy, nd_dummy)
-	end subroutine gridDefGMEnd
-
-	function gridInqGMEnd(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqGMEnd(gridID_dummy) bind(c, name = 'gridInqGMEnd')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqGMEnd
-		end interface
-		result = lib_gridInqGMEnd(gridID_dummy)
-	end function gridInqGMEnd
-
-	subroutine gridDefGMEni(gridID_dummy, ni_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: ni_dummy
-		interface
-			subroutine lib_gridDefGMEni(gridID_dummy, ni_dummy) bind(c, name = 'gridDefGMEni')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: ni_dummy
-			end subroutine lib_gridDefGMEni
-		end interface
-		call lib_gridDefGMEni(gridID_dummy, ni_dummy)
-	end subroutine gridDefGMEni
-
-	function gridInqGMEni(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqGMEni(gridID_dummy) bind(c, name = 'gridInqGMEni')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqGMEni
-		end interface
-		result = lib_gridInqGMEni(gridID_dummy)
-	end function gridInqGMEni
-
-	subroutine gridDefGMEni2(gridID_dummy, ni2_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: ni2_dummy
-		interface
-			subroutine lib_gridDefGMEni2(gridID_dummy, ni2_dummy) bind(c, name = 'gridDefGMEni2')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: ni2_dummy
-			end subroutine lib_gridDefGMEni2
-		end interface
-		call lib_gridDefGMEni2(gridID_dummy, ni2_dummy)
-	end subroutine gridDefGMEni2
-
-	function gridInqGMEni2(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqGMEni2(gridID_dummy) bind(c, name = 'gridInqGMEni2')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqGMEni2
-		end interface
-		result = lib_gridInqGMEni2(gridID_dummy)
-	end function gridInqGMEni2
-
-	subroutine gridDefGMEni3(gridID_dummy, ni3_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: ni3_dummy
-		interface
-			subroutine lib_gridDefGMEni3(gridID_dummy, ni3_dummy) bind(c, name = 'gridDefGMEni3')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: ni3_dummy
-			end subroutine lib_gridDefGMEni3
-		end interface
-		call lib_gridDefGMEni3(gridID_dummy, ni3_dummy)
-	end subroutine gridDefGMEni3
-
-	function gridInqGMEni3(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqGMEni3(gridID_dummy) bind(c, name = 'gridInqGMEni3')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqGMEni3
-		end interface
-		result = lib_gridInqGMEni3(gridID_dummy)
-	end function gridInqGMEni3
-
-	subroutine gridDefNumber(gridID_dummy, number_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: number_dummy
-		interface
-			subroutine lib_gridDefNumber(gridID_dummy, number_dummy) bind(c, name = 'gridDefNumber')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: number_dummy
-			end subroutine lib_gridDefNumber
-		end interface
-		call lib_gridDefNumber(gridID_dummy, number_dummy)
-	end subroutine gridDefNumber
-
-	function gridInqNumber(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqNumber(gridID_dummy) bind(c, name = 'gridInqNumber')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqNumber
-		end interface
-		result = lib_gridInqNumber(gridID_dummy)
-	end function gridInqNumber
-
-	subroutine gridDefPosition(gridID_dummy, position_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: position_dummy
-		interface
-			subroutine lib_gridDefPosition(gridID_dummy, position_dummy) bind(c, name = 'gridDefPosition')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: position_dummy
-			end subroutine lib_gridDefPosition
-		end interface
-		call lib_gridDefPosition(gridID_dummy, position_dummy)
-	end subroutine gridDefPosition
-
-	function gridInqPosition(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqPosition(gridID_dummy) bind(c, name = 'gridInqPosition')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqPosition
-		end interface
-		result = lib_gridInqPosition(gridID_dummy)
-	end function gridInqPosition
-
-	subroutine gridDefReference(gridID_dummy, reference_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(in) :: reference_dummy
-		character(kind = c_char) :: reference_temp(len(reference_dummy) + 1)
-		integer :: reference_i
-		interface
-			subroutine lib_gridDefReference(gridID_dummy, reference_dummy) bind(c, name = 'gridDefReference')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: reference_dummy(*)
-			end subroutine lib_gridDefReference
-		end interface
-		do reference_i = 1, len(reference_dummy)
-		reference_temp(reference_i) = reference_dummy(reference_i:reference_i)
-		end do
-		reference_temp(len(reference_dummy) + 1) = c_null_char
-		call lib_gridDefReference(gridID_dummy, reference_temp)
-	end subroutine gridDefReference
-
-	function gridInqReference(gridID_dummy, reference_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char, len = *), intent(inout) :: reference_dummy
-		character(kind = c_char) :: reference_temp(len(reference_dummy))
-		integer :: reference_i
-		logical :: reference_padding = .true.
-		interface
-			integer(c_int) function lib_gridInqReference(gridID_dummy, reference_dummy) bind(c, name = 'gridInqReference')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char) :: reference_dummy(*)
-			end function lib_gridInqReference
-		end interface
-		do reference_i = len(reference_dummy), 1, -1
-			if(reference_dummy(reference_i:reference_i) /= ' ') reference_padding = .false.
-			if(reference_padding) then
-				reference_temp(reference_i) = c_null_char
-			else
-				reference_temp(reference_i) = reference_dummy(reference_i:reference_i)
-			end if
-		end do
-		result = lib_gridInqReference(gridID_dummy, reference_temp)
-		reference_padding = .false.
-		do reference_i = 1, len(reference_dummy)
-			if(reference_temp(reference_i) == c_null_char) reference_padding = .true.
-			if(reference_padding) then
-				reference_dummy(reference_i:reference_i) = ' '
-			else
-				reference_dummy(reference_i:reference_i) = reference_temp(reference_i)
-			end if
-		end do
-	end function gridInqReference
-
-	subroutine gridDefUUID(gridID_dummy, uuid_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char), intent(in) :: uuid_dummy(CDI_UUID_SIZE)
-		interface
-			subroutine lib_gridDefUUID(gridID_dummy, uuid_dummy) bind(c, name = 'gridDefUUID')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char), intent(in) :: uuid_dummy(*)
-			end subroutine lib_gridDefUUID
-		end interface
-		call lib_gridDefUUID(gridID_dummy, uuid_dummy)
-	end subroutine gridDefUUID
-
-	subroutine gridInqUUID(gridID_dummy, uuid_dummy)
-		integer(c_int), value :: gridID_dummy
-		character(kind = c_char), intent(inout) :: uuid_dummy(CDI_UUID_SIZE)
-		interface
-			subroutine lib_gridInqUUID(gridID_dummy, uuid_dummy) bind(c, name = 'gridInqUUID')
-				import c_char, c_int
-				integer(c_int), value :: gridID_dummy
-				character(kind = c_char), intent(inout) :: uuid_dummy(*)
-			end subroutine lib_gridInqUUID
-		end interface
-		call lib_gridInqUUID(gridID_dummy, uuid_dummy)
-	end subroutine gridInqUUID
-
-	subroutine gridDefLCC(gridID_dummy, originLon_dummy, originLat_dummy, lonParY_dummy, lat1_dummy, lat2_dummy, xinc_dummy, yinc_dumm&
-	&y, projflag_dummy, scanflag_dummy)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), value :: originLon_dummy
-		real(c_double), value :: originLat_dummy
-		real(c_double), value :: lonParY_dummy
-		real(c_double), value :: lat1_dummy
-		real(c_double), value :: lat2_dummy
-		real(c_double), value :: xinc_dummy
-		real(c_double), value :: yinc_dummy
-		integer(c_int), value :: projflag_dummy
-		integer(c_int), value :: scanflag_dummy
-		interface
-			subroutine lib_gridDefLCC(gridID_dummy, originLon_dummy, originLat_dummy, lonParY_dummy, lat1_dummy, lat2_dummy, xinc_dummy, yin&
-			&c_dummy, projflag_dummy, scanflag_dummy) bind(c, name = 'gridDefLCC')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), value :: originLon_dummy
-				real(c_double), value :: originLat_dummy
-				real(c_double), value :: lonParY_dummy
-				real(c_double), value :: lat1_dummy
-				real(c_double), value :: lat2_dummy
-				real(c_double), value :: xinc_dummy
-				real(c_double), value :: yinc_dummy
-				integer(c_int), value :: projflag_dummy
-				integer(c_int), value :: scanflag_dummy
-			end subroutine lib_gridDefLCC
-		end interface
-		call lib_gridDefLCC(gridID_dummy, originLon_dummy, originLat_dummy, lonParY_dummy, lat1_dummy, lat2_dummy, xinc_dummy, yinc_dummy&
-		&, projflag_dummy, scanflag_dummy)
-	end subroutine gridDefLCC
-
-	subroutine gridInqLCC(gridID_dummy, originLon, originLat, lonParY, lat1, lat2, xinc, yinc, projflag, scanflag)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), optional, intent(inout) :: originLon
-		real(c_double), optional, intent(inout) :: originLat
-		real(c_double), optional, intent(inout) :: lonParY
-		real(c_double), optional, intent(inout) :: lat1
-		real(c_double), optional, intent(inout) :: lat2
-		real(c_double), optional, intent(inout) :: xinc
-		real(c_double), optional, intent(inout) :: yinc
-		integer(c_int), optional, intent(inout) :: projflag
-		integer(c_int), optional, intent(inout) :: scanflag
-		real(c_double), target :: originLon_temp
-		type(c_ptr) :: originLon_ptr
-		real(c_double), target :: originLat_temp
-		type(c_ptr) :: originLat_ptr
-		real(c_double), target :: lonParY_temp
-		type(c_ptr) :: lonParY_ptr
-		real(c_double), target :: lat1_temp
-		type(c_ptr) :: lat1_ptr
-		real(c_double), target :: lat2_temp
-		type(c_ptr) :: lat2_ptr
-		real(c_double), target :: xinc_temp
-		type(c_ptr) :: xinc_ptr
-		real(c_double), target :: yinc_temp
-		type(c_ptr) :: yinc_ptr
-		integer(c_int), target :: projflag_temp
-		type(c_ptr) :: projflag_ptr
-		integer(c_int), target :: scanflag_temp
-		type(c_ptr) :: scanflag_ptr
-		interface
-			subroutine lib_gridInqLCC(gridID_dummy, originLon, originLat, lonParY, lat1, lat2, xinc, yinc, projflag, scanflag) bind(c, name &
-			&= 'gridInqLCC')
-				import c_int, c_ptr
-				integer(c_int), value :: gridID_dummy
-				type(c_ptr), value :: originLon
-				type(c_ptr), value :: originLat
-				type(c_ptr), value :: lonParY
-				type(c_ptr), value :: lat1
-				type(c_ptr), value :: lat2
-				type(c_ptr), value :: xinc
-				type(c_ptr), value :: yinc
-				type(c_ptr), value :: projflag
-				type(c_ptr), value :: scanflag
-			end subroutine lib_gridInqLCC
-		end interface
-		originLon_ptr = c_null_ptr
-		if(present(originLon)) originLon_ptr = c_loc(originLon_temp)
-		originLat_ptr = c_null_ptr
-		if(present(originLat)) originLat_ptr = c_loc(originLat_temp)
-		lonParY_ptr = c_null_ptr
-		if(present(lonParY)) lonParY_ptr = c_loc(lonParY_temp)
-		lat1_ptr = c_null_ptr
-		if(present(lat1)) lat1_ptr = c_loc(lat1_temp)
-		lat2_ptr = c_null_ptr
-		if(present(lat2)) lat2_ptr = c_loc(lat2_temp)
-		xinc_ptr = c_null_ptr
-		if(present(xinc)) xinc_ptr = c_loc(xinc_temp)
-		yinc_ptr = c_null_ptr
-		if(present(yinc)) yinc_ptr = c_loc(yinc_temp)
-		projflag_ptr = c_null_ptr
-		if(present(projflag)) projflag_ptr = c_loc(projflag_temp)
-		scanflag_ptr = c_null_ptr
-		if(present(scanflag)) scanflag_ptr = c_loc(scanflag_temp)
-		call lib_gridInqLCC(gridID_dummy, originLon_ptr, originLat_ptr, lonParY_ptr, lat1_ptr, lat2_ptr, xinc_ptr, yinc_ptr, projflag_ptr&
-		&, scanflag_ptr)
-		if(present(originLon)) originLon = originLon_temp
-		if(present(originLat)) originLat = originLat_temp
-		if(present(lonParY)) lonParY = lonParY_temp
-		if(present(lat1)) lat1 = lat1_temp
-		if(present(lat2)) lat2 = lat2_temp
-		if(present(xinc)) xinc = xinc_temp
-		if(present(yinc)) yinc = yinc_temp
-		if(present(projflag)) projflag = projflag_temp
-		if(present(scanflag)) scanflag = scanflag_temp
-	end subroutine gridInqLCC
-
-	subroutine gridDefLcc2(gridID_dummy, earth_radius_dummy, lon_0_dummy, lat_0_dummy, lat_1_dummy, lat_2_dummy)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), value :: earth_radius_dummy
-		real(c_double), value :: lon_0_dummy
-		real(c_double), value :: lat_0_dummy
-		real(c_double), value :: lat_1_dummy
-		real(c_double), value :: lat_2_dummy
-		interface
-			subroutine lib_gridDefLcc2(gridID_dummy, earth_radius_dummy, lon_0_dummy, lat_0_dummy, lat_1_dummy, lat_2_dummy) bind(c, name = &
-			&'gridDefLcc2')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), value :: earth_radius_dummy
-				real(c_double), value :: lon_0_dummy
-				real(c_double), value :: lat_0_dummy
-				real(c_double), value :: lat_1_dummy
-				real(c_double), value :: lat_2_dummy
-			end subroutine lib_gridDefLcc2
-		end interface
-		call lib_gridDefLcc2(gridID_dummy, earth_radius_dummy, lon_0_dummy, lat_0_dummy, lat_1_dummy, lat_2_dummy)
-	end subroutine gridDefLcc2
-
-	subroutine gridInqLcc2(gridID_dummy, earth_radius, lon_0, lat_0, lat_1, lat_2)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), optional, intent(inout) :: earth_radius
-		real(c_double), optional, intent(inout) :: lon_0
-		real(c_double), optional, intent(inout) :: lat_0
-		real(c_double), optional, intent(inout) :: lat_1
-		real(c_double), optional, intent(inout) :: lat_2
-		real(c_double), target :: earth_radius_temp
-		type(c_ptr) :: earth_radius_ptr
-		real(c_double), target :: lon_0_temp
-		type(c_ptr) :: lon_0_ptr
-		real(c_double), target :: lat_0_temp
-		type(c_ptr) :: lat_0_ptr
-		real(c_double), target :: lat_1_temp
-		type(c_ptr) :: lat_1_ptr
-		real(c_double), target :: lat_2_temp
-		type(c_ptr) :: lat_2_ptr
-		interface
-			subroutine lib_gridInqLcc2(gridID_dummy, earth_radius, lon_0, lat_0, lat_1, lat_2) bind(c, name = 'gridInqLcc2')
-				import c_int, c_ptr
-				integer(c_int), value :: gridID_dummy
-				type(c_ptr), value :: earth_radius
-				type(c_ptr), value :: lon_0
-				type(c_ptr), value :: lat_0
-				type(c_ptr), value :: lat_1
-				type(c_ptr), value :: lat_2
-			end subroutine lib_gridInqLcc2
-		end interface
-		earth_radius_ptr = c_null_ptr
-		if(present(earth_radius)) earth_radius_ptr = c_loc(earth_radius_temp)
-		lon_0_ptr = c_null_ptr
-		if(present(lon_0)) lon_0_ptr = c_loc(lon_0_temp)
-		lat_0_ptr = c_null_ptr
-		if(present(lat_0)) lat_0_ptr = c_loc(lat_0_temp)
-		lat_1_ptr = c_null_ptr
-		if(present(lat_1)) lat_1_ptr = c_loc(lat_1_temp)
-		lat_2_ptr = c_null_ptr
-		if(present(lat_2)) lat_2_ptr = c_loc(lat_2_temp)
-		call lib_gridInqLcc2(gridID_dummy, earth_radius_ptr, lon_0_ptr, lat_0_ptr, lat_1_ptr, lat_2_ptr)
-		if(present(earth_radius)) earth_radius = earth_radius_temp
-		if(present(lon_0)) lon_0 = lon_0_temp
-		if(present(lat_0)) lat_0 = lat_0_temp
-		if(present(lat_1)) lat_1 = lat_1_temp
-		if(present(lat_2)) lat_2 = lat_2_temp
-	end subroutine gridInqLcc2
-
-	subroutine gridDefLaea(gridID_dummy, earth_radius_dummy, lon_0_dummy, lat_0_dummy)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), value :: earth_radius_dummy
-		real(c_double), value :: lon_0_dummy
-		real(c_double), value :: lat_0_dummy
-		interface
-			subroutine lib_gridDefLaea(gridID_dummy, earth_radius_dummy, lon_0_dummy, lat_0_dummy) bind(c, name = 'gridDefLaea')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), value :: earth_radius_dummy
-				real(c_double), value :: lon_0_dummy
-				real(c_double), value :: lat_0_dummy
-			end subroutine lib_gridDefLaea
-		end interface
-		call lib_gridDefLaea(gridID_dummy, earth_radius_dummy, lon_0_dummy, lat_0_dummy)
-	end subroutine gridDefLaea
-
-	subroutine gridInqLaea(gridID_dummy, earth_radius, lon_0, lat_0)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), optional, intent(inout) :: earth_radius
-		real(c_double), optional, intent(inout) :: lon_0
-		real(c_double), optional, intent(inout) :: lat_0
-		real(c_double), target :: earth_radius_temp
-		type(c_ptr) :: earth_radius_ptr
-		real(c_double), target :: lon_0_temp
-		type(c_ptr) :: lon_0_ptr
-		real(c_double), target :: lat_0_temp
-		type(c_ptr) :: lat_0_ptr
-		interface
-			subroutine lib_gridInqLaea(gridID_dummy, earth_radius, lon_0, lat_0) bind(c, name = 'gridInqLaea')
-				import c_int, c_ptr
-				integer(c_int), value :: gridID_dummy
-				type(c_ptr), value :: earth_radius
-				type(c_ptr), value :: lon_0
-				type(c_ptr), value :: lat_0
-			end subroutine lib_gridInqLaea
-		end interface
-		earth_radius_ptr = c_null_ptr
-		if(present(earth_radius)) earth_radius_ptr = c_loc(earth_radius_temp)
-		lon_0_ptr = c_null_ptr
-		if(present(lon_0)) lon_0_ptr = c_loc(lon_0_temp)
-		lat_0_ptr = c_null_ptr
-		if(present(lat_0)) lat_0_ptr = c_loc(lat_0_temp)
-		call lib_gridInqLaea(gridID_dummy, earth_radius_ptr, lon_0_ptr, lat_0_ptr)
-		if(present(earth_radius)) earth_radius = earth_radius_temp
-		if(present(lon_0)) lon_0 = lon_0_temp
-		if(present(lat_0)) lat_0 = lat_0_temp
-	end subroutine gridInqLaea
-
-	subroutine gridDefArea(gridID_dummy, area_vec_dummy)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), intent(in) :: area_vec_dummy(*)
-		interface
-			subroutine lib_gridDefArea(gridID_dummy, area_vec_dummy) bind(c, name = 'gridDefArea')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), intent(in) :: area_vec_dummy(*)
-			end subroutine lib_gridDefArea
-		end interface
-		call lib_gridDefArea(gridID_dummy, area_vec_dummy)
-	end subroutine gridDefArea
-
-	subroutine gridInqArea(gridID_dummy, area_vec_dummy)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), intent(inout) :: area_vec_dummy(*)
-		interface
-			subroutine lib_gridInqArea(gridID_dummy, area_vec_dummy) bind(c, name = 'gridInqArea')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), intent(inout) :: area_vec_dummy(*)
-			end subroutine lib_gridInqArea
-		end interface
-		call lib_gridInqArea(gridID_dummy, area_vec_dummy)
-	end subroutine gridInqArea
-
-	function gridHasArea(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridHasArea(gridID_dummy) bind(c, name = 'gridHasArea')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridHasArea
-		end interface
-		result = lib_gridHasArea(gridID_dummy)
-	end function gridHasArea
-
-	subroutine gridDefNvertex(gridID_dummy, nvertex_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: nvertex_dummy
-		interface
-			subroutine lib_gridDefNvertex(gridID_dummy, nvertex_dummy) bind(c, name = 'gridDefNvertex')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: nvertex_dummy
-			end subroutine lib_gridDefNvertex
-		end interface
-		call lib_gridDefNvertex(gridID_dummy, nvertex_dummy)
-	end subroutine gridDefNvertex
-
-	function gridInqNvertex(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqNvertex(gridID_dummy) bind(c, name = 'gridInqNvertex')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqNvertex
-		end interface
-		result = lib_gridInqNvertex(gridID_dummy)
-	end function gridInqNvertex
-
-	subroutine gridDefXbounds(gridID_dummy, xbounds_vec_dummy)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), intent(in) :: xbounds_vec_dummy(*)
-		interface
-			subroutine lib_gridDefXbounds(gridID_dummy, xbounds_vec_dummy) bind(c, name = 'gridDefXbounds')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), intent(in) :: xbounds_vec_dummy(*)
-			end subroutine lib_gridDefXbounds
-		end interface
-		call lib_gridDefXbounds(gridID_dummy, xbounds_vec_dummy)
-	end subroutine gridDefXbounds
-
-	function gridInqXbounds(gridID_dummy, xbounds_vec_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		real(c_double), intent(inout) :: xbounds_vec_dummy(*)
-		interface
-			integer(c_int) function lib_gridInqXbounds(gridID_dummy, xbounds_vec_dummy) bind(c, name = 'gridInqXbounds')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), intent(inout) :: xbounds_vec_dummy(*)
-			end function lib_gridInqXbounds
-		end interface
-		result = lib_gridInqXbounds(gridID_dummy, xbounds_vec_dummy)
-	end function gridInqXbounds
-
-	subroutine gridDefYbounds(gridID_dummy, ybounds_vec_dummy)
-		integer(c_int), value :: gridID_dummy
-		real(c_double), intent(in) :: ybounds_vec_dummy(*)
-		interface
-			subroutine lib_gridDefYbounds(gridID_dummy, ybounds_vec_dummy) bind(c, name = 'gridDefYbounds')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), intent(in) :: ybounds_vec_dummy(*)
-			end subroutine lib_gridDefYbounds
-		end interface
-		call lib_gridDefYbounds(gridID_dummy, ybounds_vec_dummy)
-	end subroutine gridDefYbounds
-
-	function gridInqYbounds(gridID_dummy, ybounds_vec_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		real(c_double), intent(inout) :: ybounds_vec_dummy(*)
-		interface
-			integer(c_int) function lib_gridInqYbounds(gridID_dummy, ybounds_vec_dummy) bind(c, name = 'gridInqYbounds')
-				import c_double, c_int
-				integer(c_int), value :: gridID_dummy
-				real(c_double), intent(inout) :: ybounds_vec_dummy(*)
-			end function lib_gridInqYbounds
-		end interface
-		result = lib_gridInqYbounds(gridID_dummy, ybounds_vec_dummy)
-	end function gridInqYbounds
-
-	subroutine gridDefRowlon(gridID_dummy, nrowlon_dummy, rowlon_vec_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: nrowlon_dummy
-		integer(c_int), intent(in) :: rowlon_vec_dummy(*)
-		interface
-			subroutine lib_gridDefRowlon(gridID_dummy, nrowlon_dummy, rowlon_vec_dummy) bind(c, name = 'gridDefRowlon')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: nrowlon_dummy
-				integer(c_int), intent(in) :: rowlon_vec_dummy(*)
-			end subroutine lib_gridDefRowlon
-		end interface
-		call lib_gridDefRowlon(gridID_dummy, nrowlon_dummy, rowlon_vec_dummy)
-	end subroutine gridDefRowlon
-
-	subroutine gridInqRowlon(gridID_dummy, rowlon_vec_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), intent(inout) :: rowlon_vec_dummy(*)
-		interface
-			subroutine lib_gridInqRowlon(gridID_dummy, rowlon_vec_dummy) bind(c, name = 'gridInqRowlon')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), intent(inout) :: rowlon_vec_dummy(*)
-			end subroutine lib_gridInqRowlon
-		end interface
-		call lib_gridInqRowlon(gridID_dummy, rowlon_vec_dummy)
-	end subroutine gridInqRowlon
-
-	subroutine gridChangeType(gridID_dummy, gridtype_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: gridtype_dummy
-		interface
-			subroutine lib_gridChangeType(gridID_dummy, gridtype_dummy) bind(c, name = 'gridChangeType')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: gridtype_dummy
-			end subroutine lib_gridChangeType
-		end interface
-		call lib_gridChangeType(gridID_dummy, gridtype_dummy)
-	end subroutine gridChangeType
-
-	subroutine gridDefComplexPacking(gridID_dummy, lpack_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: lpack_dummy
-		interface
-			subroutine lib_gridDefComplexPacking(gridID_dummy, lpack_dummy) bind(c, name = 'gridDefComplexPacking')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: lpack_dummy
-			end subroutine lib_gridDefComplexPacking
-		end interface
-		call lib_gridDefComplexPacking(gridID_dummy, lpack_dummy)
-	end subroutine gridDefComplexPacking
-
-	function gridInqComplexPacking(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_gridInqComplexPacking(gridID_dummy) bind(c, name = 'gridInqComplexPacking')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_gridInqComplexPacking
-		end interface
-		result = lib_gridInqComplexPacking(gridID_dummy)
-	end function gridInqComplexPacking
-
-	subroutine zaxisName(zaxistype_dummy, zaxisname_dummy)
-		integer(c_int), value :: zaxistype_dummy
-		character(kind = c_char, len = *), intent(inout) :: zaxisname_dummy
-		character(kind = c_char) :: zaxisname_temp(len(zaxisname_dummy))
-		integer :: zaxisname_i
-		logical :: zaxisname_padding = .true.
-		interface
-			subroutine lib_zaxisName(zaxistype_dummy, zaxisname_dummy) bind(c, name = 'zaxisName')
-				import c_char, c_int
-				integer(c_int), value :: zaxistype_dummy
-				character(kind = c_char) :: zaxisname_dummy(*)
-			end subroutine lib_zaxisName
-		end interface
-		do zaxisname_i = len(zaxisname_dummy), 1, -1
-			if(zaxisname_dummy(zaxisname_i:zaxisname_i) /= ' ') zaxisname_padding = .false.
-			if(zaxisname_padding) then
-				zaxisname_temp(zaxisname_i) = c_null_char
-			else
-				zaxisname_temp(zaxisname_i) = zaxisname_dummy(zaxisname_i:zaxisname_i)
-			end if
-		end do
-		call lib_zaxisName(zaxistype_dummy, zaxisname_temp)
-		zaxisname_padding = .false.
-		do zaxisname_i = 1, len(zaxisname_dummy)
-			if(zaxisname_temp(zaxisname_i) == c_null_char) zaxisname_padding = .true.
-			if(zaxisname_padding) then
-				zaxisname_dummy(zaxisname_i:zaxisname_i) = ' '
-			else
-				zaxisname_dummy(zaxisname_i:zaxisname_i) = zaxisname_temp(zaxisname_i)
-			end if
-		end do
-	end subroutine zaxisName
-
-	function zaxisCreate(zaxistype_dummy, size_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: zaxistype_dummy
-		integer(c_int), value :: size_dummy
-		interface
-			integer(c_int) function lib_zaxisCreate(zaxistype_dummy, size_dummy) bind(c, name = 'zaxisCreate')
-				import c_int
-				integer(c_int), value :: zaxistype_dummy
-				integer(c_int), value :: size_dummy
-			end function lib_zaxisCreate
-		end interface
-		result = lib_zaxisCreate(zaxistype_dummy, size_dummy)
-	end function zaxisCreate
-
-	subroutine zaxisDestroy(zaxisID_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		interface
-			subroutine lib_zaxisDestroy(zaxisID_dummy) bind(c, name = 'zaxisDestroy')
-				import c_int
-				integer(c_int), value :: zaxisID_dummy
-			end subroutine lib_zaxisDestroy
-		end interface
-		call lib_zaxisDestroy(zaxisID_dummy)
-	end subroutine zaxisDestroy
-
-	function zaxisInqType(zaxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: zaxisID_dummy
-		interface
-			integer(c_int) function lib_zaxisInqType(zaxisID_dummy) bind(c, name = 'zaxisInqType')
-				import c_int
-				integer(c_int), value :: zaxisID_dummy
-			end function lib_zaxisInqType
-		end interface
-		result = lib_zaxisInqType(zaxisID_dummy)
-	end function zaxisInqType
-
-	function zaxisInqSize(zaxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: zaxisID_dummy
-		interface
-			integer(c_int) function lib_zaxisInqSize(zaxisID_dummy) bind(c, name = 'zaxisInqSize')
-				import c_int
-				integer(c_int), value :: zaxisID_dummy
-			end function lib_zaxisInqSize
-		end interface
-		result = lib_zaxisInqSize(zaxisID_dummy)
-	end function zaxisInqSize
-
-	function zaxisDuplicate(zaxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: zaxisID_dummy
-		interface
-			integer(c_int) function lib_zaxisDuplicate(zaxisID_dummy) bind(c, name = 'zaxisDuplicate')
-				import c_int
-				integer(c_int), value :: zaxisID_dummy
-			end function lib_zaxisDuplicate
-		end interface
-		result = lib_zaxisDuplicate(zaxisID_dummy)
-	end function zaxisDuplicate
-
-	subroutine zaxisResize(zaxisID_dummy, size_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		integer(c_int), value :: size_dummy
-		interface
-			subroutine lib_zaxisResize(zaxisID_dummy, size_dummy) bind(c, name = 'zaxisResize')
-				import c_int
-				integer(c_int), value :: zaxisID_dummy
-				integer(c_int), value :: size_dummy
-			end subroutine lib_zaxisResize
-		end interface
-		call lib_zaxisResize(zaxisID_dummy, size_dummy)
-	end subroutine zaxisResize
-
-	subroutine zaxisPrint(zaxisID_dummy, index_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		integer(c_int), value :: index_dummy
-		interface
-			subroutine lib_zaxisPrint(zaxisID_dummy, index_dummy) bind(c, name = 'zaxisPrint')
-				import c_int
-				integer(c_int), value :: zaxisID_dummy
-				integer(c_int), value :: index_dummy
-			end subroutine lib_zaxisPrint
-		end interface
-		call lib_zaxisPrint(zaxisID_dummy, index_dummy)
-	end subroutine zaxisPrint
-
-	subroutine zaxisDefLevels(zaxisID_dummy, levels_vec_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		real(c_double), intent(in) :: levels_vec_dummy(*)
-		interface
-			subroutine lib_zaxisDefLevels(zaxisID_dummy, levels_vec_dummy) bind(c, name = 'zaxisDefLevels')
-				import c_double, c_int
-				integer(c_int), value :: zaxisID_dummy
-				real(c_double), intent(in) :: levels_vec_dummy(*)
-			end subroutine lib_zaxisDefLevels
-		end interface
-		call lib_zaxisDefLevels(zaxisID_dummy, levels_vec_dummy)
-	end subroutine zaxisDefLevels
-
-	subroutine zaxisInqLevels(zaxisID_dummy, levels_vec_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		real(c_double), intent(inout) :: levels_vec_dummy(*)
-		interface
-			subroutine lib_zaxisInqLevels(zaxisID_dummy, levels_vec_dummy) bind(c, name = 'zaxisInqLevels')
-				import c_double, c_int
-				integer(c_int), value :: zaxisID_dummy
-				real(c_double), intent(inout) :: levels_vec_dummy(*)
-			end subroutine lib_zaxisInqLevels
-		end interface
-		call lib_zaxisInqLevels(zaxisID_dummy, levels_vec_dummy)
-	end subroutine zaxisInqLevels
-
-	subroutine zaxisDefLevel(zaxisID_dummy, levelID_dummy, levels_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		integer(c_int), value :: levelID_dummy
-		real(c_double), value :: levels_dummy
-		interface
-			subroutine lib_zaxisDefLevel(zaxisID_dummy, levelID_dummy, levels_dummy) bind(c, name = 'zaxisDefLevel')
-				import c_double, c_int
-				integer(c_int), value :: zaxisID_dummy
-				integer(c_int), value :: levelID_dummy
-				real(c_double), value :: levels_dummy
-			end subroutine lib_zaxisDefLevel
-		end interface
-		call lib_zaxisDefLevel(zaxisID_dummy, levelID_dummy, levels_dummy)
-	end subroutine zaxisDefLevel
-
-	function zaxisInqLevel(zaxisID_dummy, levelID_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: zaxisID_dummy
-		integer(c_int), value :: levelID_dummy
-		interface
-			real(c_double) function lib_zaxisInqLevel(zaxisID_dummy, levelID_dummy) bind(c, name = 'zaxisInqLevel')
-				import c_double, c_int
-				integer(c_int), value :: zaxisID_dummy
-				integer(c_int), value :: levelID_dummy
-			end function lib_zaxisInqLevel
-		end interface
-		result = lib_zaxisInqLevel(zaxisID_dummy, levelID_dummy)
-	end function zaxisInqLevel
-
-	subroutine zaxisDefNlevRef(gridID_dummy, nhlev_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: nhlev_dummy
-		interface
-			subroutine lib_zaxisDefNlevRef(gridID_dummy, nhlev_dummy) bind(c, name = 'zaxisDefNlevRef')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: nhlev_dummy
-			end subroutine lib_zaxisDefNlevRef
-		end interface
-		call lib_zaxisDefNlevRef(gridID_dummy, nhlev_dummy)
-	end subroutine zaxisDefNlevRef
-
-	function zaxisInqNlevRef(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_zaxisInqNlevRef(gridID_dummy) bind(c, name = 'zaxisInqNlevRef')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_zaxisInqNlevRef
-		end interface
-		result = lib_zaxisInqNlevRef(gridID_dummy)
-	end function zaxisInqNlevRef
-
-	subroutine zaxisDefNumber(gridID_dummy, number_dummy)
-		integer(c_int), value :: gridID_dummy
-		integer(c_int), value :: number_dummy
-		interface
-			subroutine lib_zaxisDefNumber(gridID_dummy, number_dummy) bind(c, name = 'zaxisDefNumber')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-				integer(c_int), value :: number_dummy
-			end subroutine lib_zaxisDefNumber
-		end interface
-		call lib_zaxisDefNumber(gridID_dummy, number_dummy)
-	end subroutine zaxisDefNumber
-
-	function zaxisInqNumber(gridID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: gridID_dummy
-		interface
-			integer(c_int) function lib_zaxisInqNumber(gridID_dummy) bind(c, name = 'zaxisInqNumber')
-				import c_int
-				integer(c_int), value :: gridID_dummy
-			end function lib_zaxisInqNumber
-		end interface
-		result = lib_zaxisInqNumber(gridID_dummy)
-	end function zaxisInqNumber
-
-	subroutine zaxisDefUUID(zaxisID_dummy, uuid_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		character(kind = c_char), intent(in) :: uuid_dummy(CDI_UUID_SIZE)
-		interface
-			subroutine lib_zaxisDefUUID(zaxisID_dummy, uuid_dummy) bind(c, name = 'zaxisDefUUID')
-				import c_char, c_int
-				integer(c_int), value :: zaxisID_dummy
-				character(kind = c_char), intent(in) :: uuid_dummy(*)
-			end subroutine lib_zaxisDefUUID
-		end interface
-		call lib_zaxisDefUUID(zaxisID_dummy, uuid_dummy)
-	end subroutine zaxisDefUUID
-
-	subroutine zaxisInqUUID(zaxisID_dummy, uuid_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		character(kind = c_char), intent(inout) :: uuid_dummy(CDI_UUID_SIZE)
-		interface
-			subroutine lib_zaxisInqUUID(zaxisID_dummy, uuid_dummy) bind(c, name = 'zaxisInqUUID')
-				import c_char, c_int
-				integer(c_int), value :: zaxisID_dummy
-				character(kind = c_char), intent(inout) :: uuid_dummy(*)
-			end subroutine lib_zaxisInqUUID
-		end interface
-		call lib_zaxisInqUUID(zaxisID_dummy, uuid_dummy)
-	end subroutine zaxisInqUUID
-
-	subroutine zaxisDefName(zaxisID_dummy, name_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		interface
-			subroutine lib_zaxisDefName(zaxisID_dummy, name_dummy) bind(c, name = 'zaxisDefName')
-				import c_char, c_int
-				integer(c_int), value :: zaxisID_dummy
-				character(kind = c_char) :: name_dummy(*)
-			end subroutine lib_zaxisDefName
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		call lib_zaxisDefName(zaxisID_dummy, name_temp)
-	end subroutine zaxisDefName
-
-	subroutine zaxisInqName(zaxisID_dummy, name_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		character(kind = c_char, len = *), intent(inout) :: name_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy))
-		integer :: name_i
-		logical :: name_padding = .true.
-		interface
-			subroutine lib_zaxisInqName(zaxisID_dummy, name_dummy) bind(c, name = 'zaxisInqName')
-				import c_char, c_int
-				integer(c_int), value :: zaxisID_dummy
-				character(kind = c_char) :: name_dummy(*)
-			end subroutine lib_zaxisInqName
-		end interface
-		do name_i = len(name_dummy), 1, -1
-			if(name_dummy(name_i:name_i) /= ' ') name_padding = .false.
-			if(name_padding) then
-				name_temp(name_i) = c_null_char
-			else
-				name_temp(name_i) = name_dummy(name_i:name_i)
-			end if
-		end do
-		call lib_zaxisInqName(zaxisID_dummy, name_temp)
-		name_padding = .false.
-		do name_i = 1, len(name_dummy)
-			if(name_temp(name_i) == c_null_char) name_padding = .true.
-			if(name_padding) then
-				name_dummy(name_i:name_i) = ' '
-			else
-				name_dummy(name_i:name_i) = name_temp(name_i)
-			end if
-		end do
-	end subroutine zaxisInqName
-
-	subroutine zaxisDefLongname(zaxisID_dummy, longname_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		character(kind = c_char, len = *), intent(in) :: longname_dummy
-		character(kind = c_char) :: longname_temp(len(longname_dummy) + 1)
-		integer :: longname_i
-		interface
-			subroutine lib_zaxisDefLongname(zaxisID_dummy, longname_dummy) bind(c, name = 'zaxisDefLongname')
-				import c_char, c_int
-				integer(c_int), value :: zaxisID_dummy
-				character(kind = c_char) :: longname_dummy(*)
-			end subroutine lib_zaxisDefLongname
-		end interface
-		do longname_i = 1, len(longname_dummy)
-		longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
-		end do
-		longname_temp(len(longname_dummy) + 1) = c_null_char
-		call lib_zaxisDefLongname(zaxisID_dummy, longname_temp)
-	end subroutine zaxisDefLongname
-
-	subroutine zaxisInqLongname(zaxisID_dummy, longname_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		character(kind = c_char, len = *), intent(inout) :: longname_dummy
-		character(kind = c_char) :: longname_temp(len(longname_dummy))
-		integer :: longname_i
-		logical :: longname_padding = .true.
-		interface
-			subroutine lib_zaxisInqLongname(zaxisID_dummy, longname_dummy) bind(c, name = 'zaxisInqLongname')
-				import c_char, c_int
-				integer(c_int), value :: zaxisID_dummy
-				character(kind = c_char) :: longname_dummy(*)
-			end subroutine lib_zaxisInqLongname
-		end interface
-		do longname_i = len(longname_dummy), 1, -1
-			if(longname_dummy(longname_i:longname_i) /= ' ') longname_padding = .false.
-			if(longname_padding) then
-				longname_temp(longname_i) = c_null_char
-			else
-				longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
-			end if
-		end do
-		call lib_zaxisInqLongname(zaxisID_dummy, longname_temp)
-		longname_padding = .false.
-		do longname_i = 1, len(longname_dummy)
-			if(longname_temp(longname_i) == c_null_char) longname_padding = .true.
-			if(longname_padding) then
-				longname_dummy(longname_i:longname_i) = ' '
-			else
-				longname_dummy(longname_i:longname_i) = longname_temp(longname_i)
-			end if
-		end do
-	end subroutine zaxisInqLongname
-
-	subroutine zaxisDefUnits(zaxisID_dummy, units_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		character(kind = c_char, len = *), intent(in) :: units_dummy
-		character(kind = c_char) :: units_temp(len(units_dummy) + 1)
-		integer :: units_i
-		interface
-			subroutine lib_zaxisDefUnits(zaxisID_dummy, units_dummy) bind(c, name = 'zaxisDefUnits')
-				import c_char, c_int
-				integer(c_int), value :: zaxisID_dummy
-				character(kind = c_char) :: units_dummy(*)
-			end subroutine lib_zaxisDefUnits
-		end interface
-		do units_i = 1, len(units_dummy)
-		units_temp(units_i) = units_dummy(units_i:units_i)
-		end do
-		units_temp(len(units_dummy) + 1) = c_null_char
-		call lib_zaxisDefUnits(zaxisID_dummy, units_temp)
-	end subroutine zaxisDefUnits
-
-	subroutine zaxisInqUnits(zaxisID_dummy, units_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		character(kind = c_char, len = *), intent(inout) :: units_dummy
-		character(kind = c_char) :: units_temp(len(units_dummy))
-		integer :: units_i
-		logical :: units_padding = .true.
-		interface
-			subroutine lib_zaxisInqUnits(zaxisID_dummy, units_dummy) bind(c, name = 'zaxisInqUnits')
-				import c_char, c_int
-				integer(c_int), value :: zaxisID_dummy
-				character(kind = c_char) :: units_dummy(*)
-			end subroutine lib_zaxisInqUnits
-		end interface
-		do units_i = len(units_dummy), 1, -1
-			if(units_dummy(units_i:units_i) /= ' ') units_padding = .false.
-			if(units_padding) then
-				units_temp(units_i) = c_null_char
-			else
-				units_temp(units_i) = units_dummy(units_i:units_i)
-			end if
-		end do
-		call lib_zaxisInqUnits(zaxisID_dummy, units_temp)
-		units_padding = .false.
-		do units_i = 1, len(units_dummy)
-			if(units_temp(units_i) == c_null_char) units_padding = .true.
-			if(units_padding) then
-				units_dummy(units_i:units_i) = ' '
-			else
-				units_dummy(units_i:units_i) = units_temp(units_i)
-			end if
-		end do
-	end subroutine zaxisInqUnits
-
-	subroutine zaxisInqStdname(zaxisID_dummy, stdname_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		character(kind = c_char, len = *), intent(inout) :: stdname_dummy
-		character(kind = c_char) :: stdname_temp(len(stdname_dummy))
-		integer :: stdname_i
-		logical :: stdname_padding = .true.
-		interface
-			subroutine lib_zaxisInqStdname(zaxisID_dummy, stdname_dummy) bind(c, name = 'zaxisInqStdname')
-				import c_char, c_int
-				integer(c_int), value :: zaxisID_dummy
-				character(kind = c_char) :: stdname_dummy(*)
-			end subroutine lib_zaxisInqStdname
-		end interface
-		do stdname_i = len(stdname_dummy), 1, -1
-			if(stdname_dummy(stdname_i:stdname_i) /= ' ') stdname_padding = .false.
-			if(stdname_padding) then
-				stdname_temp(stdname_i) = c_null_char
-			else
-				stdname_temp(stdname_i) = stdname_dummy(stdname_i:stdname_i)
-			end if
-		end do
-		call lib_zaxisInqStdname(zaxisID_dummy, stdname_temp)
-		stdname_padding = .false.
-		do stdname_i = 1, len(stdname_dummy)
-			if(stdname_temp(stdname_i) == c_null_char) stdname_padding = .true.
-			if(stdname_padding) then
-				stdname_dummy(stdname_i:stdname_i) = ' '
-			else
-				stdname_dummy(stdname_i:stdname_i) = stdname_temp(stdname_i)
-			end if
-		end do
-	end subroutine zaxisInqStdname
-
-	subroutine zaxisDefPrec(zaxisID_dummy, prec_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		integer(c_int), value :: prec_dummy
-		interface
-			subroutine lib_zaxisDefPrec(zaxisID_dummy, prec_dummy) bind(c, name = 'zaxisDefPrec')
-				import c_int
-				integer(c_int), value :: zaxisID_dummy
-				integer(c_int), value :: prec_dummy
-			end subroutine lib_zaxisDefPrec
-		end interface
-		call lib_zaxisDefPrec(zaxisID_dummy, prec_dummy)
-	end subroutine zaxisDefPrec
-
-	function zaxisInqPrec(zaxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: zaxisID_dummy
-		interface
-			integer(c_int) function lib_zaxisInqPrec(zaxisID_dummy) bind(c, name = 'zaxisInqPrec')
-				import c_int
-				integer(c_int), value :: zaxisID_dummy
-			end function lib_zaxisInqPrec
-		end interface
-		result = lib_zaxisInqPrec(zaxisID_dummy)
-	end function zaxisInqPrec
-
-	subroutine zaxisDefPositive(zaxisID_dummy, positive_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		integer(c_int), value :: positive_dummy
-		interface
-			subroutine lib_zaxisDefPositive(zaxisID_dummy, positive_dummy) bind(c, name = 'zaxisDefPositive')
-				import c_int
-				integer(c_int), value :: zaxisID_dummy
-				integer(c_int), value :: positive_dummy
-			end subroutine lib_zaxisDefPositive
-		end interface
-		call lib_zaxisDefPositive(zaxisID_dummy, positive_dummy)
-	end subroutine zaxisDefPositive
-
-	function zaxisInqPositive(zaxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: zaxisID_dummy
-		interface
-			integer(c_int) function lib_zaxisInqPositive(zaxisID_dummy) bind(c, name = 'zaxisInqPositive')
-				import c_int
-				integer(c_int), value :: zaxisID_dummy
-			end function lib_zaxisInqPositive
-		end interface
-		result = lib_zaxisInqPositive(zaxisID_dummy)
-	end function zaxisInqPositive
-
-	subroutine zaxisDefLtype(zaxisID_dummy, ltype_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		integer(c_int), value :: ltype_dummy
-		interface
-			subroutine lib_zaxisDefLtype(zaxisID_dummy, ltype_dummy) bind(c, name = 'zaxisDefLtype')
-				import c_int
-				integer(c_int), value :: zaxisID_dummy
-				integer(c_int), value :: ltype_dummy
-			end subroutine lib_zaxisDefLtype
-		end interface
-		call lib_zaxisDefLtype(zaxisID_dummy, ltype_dummy)
-	end subroutine zaxisDefLtype
-
-	function zaxisInqLtype(zaxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: zaxisID_dummy
-		interface
-			integer(c_int) function lib_zaxisInqLtype(zaxisID_dummy) bind(c, name = 'zaxisInqLtype')
-				import c_int
-				integer(c_int), value :: zaxisID_dummy
-			end function lib_zaxisInqLtype
-		end interface
-		result = lib_zaxisInqLtype(zaxisID_dummy)
-	end function zaxisInqLtype
-
-	function zaxisInqLevelsPtr(zaxisID_dummy) result(result)
-		type(c_ptr) :: result
-		integer(c_int), value :: zaxisID_dummy
-		interface
-			type(c_ptr) function lib_zaxisInqLevelsPtr(zaxisID_dummy) bind(c, name = 'zaxisInqLevelsPtr')
-				import c_int, c_ptr
-				integer(c_int), value :: zaxisID_dummy
-			end function lib_zaxisInqLevelsPtr
-		end interface
-		result = lib_zaxisInqLevelsPtr(zaxisID_dummy)
-	end function zaxisInqLevelsPtr
-
-	subroutine zaxisDefVct(zaxisID_dummy, size_dummy, vct_vec_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		integer(c_int), value :: size_dummy
-		real(c_double), intent(in) :: vct_vec_dummy(*)
-		interface
-			subroutine lib_zaxisDefVct(zaxisID_dummy, size_dummy, vct_vec_dummy) bind(c, name = 'zaxisDefVct')
-				import c_double, c_int
-				integer(c_int), value :: zaxisID_dummy
-				integer(c_int), value :: size_dummy
-				real(c_double), intent(in) :: vct_vec_dummy(*)
-			end subroutine lib_zaxisDefVct
-		end interface
-		call lib_zaxisDefVct(zaxisID_dummy, size_dummy, vct_vec_dummy)
-	end subroutine zaxisDefVct
-
-	subroutine zaxisInqVct(zaxisID_dummy, vct_vec_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		real(c_double), intent(inout) :: vct_vec_dummy(*)
-		interface
-			subroutine lib_zaxisInqVct(zaxisID_dummy, vct_vec_dummy) bind(c, name = 'zaxisInqVct')
-				import c_double, c_int
-				integer(c_int), value :: zaxisID_dummy
-				real(c_double), intent(inout) :: vct_vec_dummy(*)
-			end subroutine lib_zaxisInqVct
-		end interface
-		call lib_zaxisInqVct(zaxisID_dummy, vct_vec_dummy)
-	end subroutine zaxisInqVct
-
-	function zaxisInqVctSize(zaxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: zaxisID_dummy
-		interface
-			integer(c_int) function lib_zaxisInqVctSize(zaxisID_dummy) bind(c, name = 'zaxisInqVctSize')
-				import c_int
-				integer(c_int), value :: zaxisID_dummy
-			end function lib_zaxisInqVctSize
-		end interface
-		result = lib_zaxisInqVctSize(zaxisID_dummy)
-	end function zaxisInqVctSize
-
-	function zaxisInqVctPtr(zaxisID_dummy) result(result)
-		type(c_ptr) :: result
-		integer(c_int), value :: zaxisID_dummy
-		interface
-			type(c_ptr) function lib_zaxisInqVctPtr(zaxisID_dummy) bind(c, name = 'zaxisInqVctPtr')
-				import c_int, c_ptr
-				integer(c_int), value :: zaxisID_dummy
-			end function lib_zaxisInqVctPtr
-		end interface
-		result = lib_zaxisInqVctPtr(zaxisID_dummy)
-	end function zaxisInqVctPtr
-
-	subroutine zaxisDefLbounds(zaxisID_dummy, lbounds_vec_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		real(c_double), intent(in) :: lbounds_vec_dummy(*)
-		interface
-			subroutine lib_zaxisDefLbounds(zaxisID_dummy, lbounds_vec_dummy) bind(c, name = 'zaxisDefLbounds')
-				import c_double, c_int
-				integer(c_int), value :: zaxisID_dummy
-				real(c_double), intent(in) :: lbounds_vec_dummy(*)
-			end subroutine lib_zaxisDefLbounds
-		end interface
-		call lib_zaxisDefLbounds(zaxisID_dummy, lbounds_vec_dummy)
-	end subroutine zaxisDefLbounds
-
-	function zaxisInqLbounds(zaxisID_dummy, lbounds_vec_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: zaxisID_dummy
-		real(c_double), intent(inout) :: lbounds_vec_dummy(*)
-		interface
-			integer(c_int) function lib_zaxisInqLbounds(zaxisID_dummy, lbounds_vec_dummy) bind(c, name = 'zaxisInqLbounds')
-				import c_double, c_int
-				integer(c_int), value :: zaxisID_dummy
-				real(c_double), intent(inout) :: lbounds_vec_dummy(*)
-			end function lib_zaxisInqLbounds
-		end interface
-		result = lib_zaxisInqLbounds(zaxisID_dummy, lbounds_vec_dummy)
-	end function zaxisInqLbounds
-
-	function zaxisInqLbound(zaxisID_dummy, index_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: zaxisID_dummy
-		integer(c_int), value :: index_dummy
-		interface
-			real(c_double) function lib_zaxisInqLbound(zaxisID_dummy, index_dummy) bind(c, name = 'zaxisInqLbound')
-				import c_double, c_int
-				integer(c_int), value :: zaxisID_dummy
-				integer(c_int), value :: index_dummy
-			end function lib_zaxisInqLbound
-		end interface
-		result = lib_zaxisInqLbound(zaxisID_dummy, index_dummy)
-	end function zaxisInqLbound
-
-	subroutine zaxisDefUbounds(zaxisID_dummy, ubounds_vec_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		real(c_double), intent(in) :: ubounds_vec_dummy(*)
-		interface
-			subroutine lib_zaxisDefUbounds(zaxisID_dummy, ubounds_vec_dummy) bind(c, name = 'zaxisDefUbounds')
-				import c_double, c_int
-				integer(c_int), value :: zaxisID_dummy
-				real(c_double), intent(in) :: ubounds_vec_dummy(*)
-			end subroutine lib_zaxisDefUbounds
-		end interface
-		call lib_zaxisDefUbounds(zaxisID_dummy, ubounds_vec_dummy)
-	end subroutine zaxisDefUbounds
-
-	function zaxisInqUbounds(zaxisID_dummy, ubounds_vec_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: zaxisID_dummy
-		real(c_double), intent(inout) :: ubounds_vec_dummy(*)
-		interface
-			integer(c_int) function lib_zaxisInqUbounds(zaxisID_dummy, ubounds_vec_dummy) bind(c, name = 'zaxisInqUbounds')
-				import c_double, c_int
-				integer(c_int), value :: zaxisID_dummy
-				real(c_double), intent(inout) :: ubounds_vec_dummy(*)
-			end function lib_zaxisInqUbounds
-		end interface
-		result = lib_zaxisInqUbounds(zaxisID_dummy, ubounds_vec_dummy)
-	end function zaxisInqUbounds
-
-	function zaxisInqUbound(zaxisID_dummy, index_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: zaxisID_dummy
-		integer(c_int), value :: index_dummy
-		interface
-			real(c_double) function lib_zaxisInqUbound(zaxisID_dummy, index_dummy) bind(c, name = 'zaxisInqUbound')
-				import c_double, c_int
-				integer(c_int), value :: zaxisID_dummy
-				integer(c_int), value :: index_dummy
-			end function lib_zaxisInqUbound
-		end interface
-		result = lib_zaxisInqUbound(zaxisID_dummy, index_dummy)
-	end function zaxisInqUbound
-
-	subroutine zaxisDefWeights(zaxisID_dummy, weights_vec_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		real(c_double), intent(in) :: weights_vec_dummy(*)
-		interface
-			subroutine lib_zaxisDefWeights(zaxisID_dummy, weights_vec_dummy) bind(c, name = 'zaxisDefWeights')
-				import c_double, c_int
-				integer(c_int), value :: zaxisID_dummy
-				real(c_double), intent(in) :: weights_vec_dummy(*)
-			end subroutine lib_zaxisDefWeights
-		end interface
-		call lib_zaxisDefWeights(zaxisID_dummy, weights_vec_dummy)
-	end subroutine zaxisDefWeights
-
-	function zaxisInqWeights(zaxisID_dummy, weights_vec_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: zaxisID_dummy
-		real(c_double), intent(inout) :: weights_vec_dummy(*)
-		interface
-			integer(c_int) function lib_zaxisInqWeights(zaxisID_dummy, weights_vec_dummy) bind(c, name = 'zaxisInqWeights')
-				import c_double, c_int
-				integer(c_int), value :: zaxisID_dummy
-				real(c_double), intent(inout) :: weights_vec_dummy(*)
-			end function lib_zaxisInqWeights
-		end interface
-		result = lib_zaxisInqWeights(zaxisID_dummy, weights_vec_dummy)
-	end function zaxisInqWeights
-
-	subroutine zaxisChangeType(zaxisID_dummy, zaxistype_dummy)
-		integer(c_int), value :: zaxisID_dummy
-		integer(c_int), value :: zaxistype_dummy
-		interface
-			subroutine lib_zaxisChangeType(zaxisID_dummy, zaxistype_dummy) bind(c, name = 'zaxisChangeType')
-				import c_int
-				integer(c_int), value :: zaxisID_dummy
-				integer(c_int), value :: zaxistype_dummy
-			end subroutine lib_zaxisChangeType
-		end interface
-		call lib_zaxisChangeType(zaxisID_dummy, zaxistype_dummy)
-	end subroutine zaxisChangeType
-
-	function taxisCreate(timetype_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: timetype_dummy
-		interface
-			integer(c_int) function lib_taxisCreate(timetype_dummy) bind(c, name = 'taxisCreate')
-				import c_int
-				integer(c_int), value :: timetype_dummy
-			end function lib_taxisCreate
-		end interface
-		result = lib_taxisCreate(timetype_dummy)
-	end function taxisCreate
-
-	subroutine taxisDestroy(taxisID_dummy)
-		integer(c_int), value :: taxisID_dummy
-		interface
-			subroutine lib_taxisDestroy(taxisID_dummy) bind(c, name = 'taxisDestroy')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end subroutine lib_taxisDestroy
-		end interface
-		call lib_taxisDestroy(taxisID_dummy)
-	end subroutine taxisDestroy
-
-	function taxisDuplicate(taxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: taxisID_dummy
-		interface
-			integer(c_int) function lib_taxisDuplicate(taxisID_dummy) bind(c, name = 'taxisDuplicate')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end function lib_taxisDuplicate
-		end interface
-		result = lib_taxisDuplicate(taxisID_dummy)
-	end function taxisDuplicate
-
-	subroutine taxisCopyTimestep(taxisIDdes_dummy, taxisIDsrc_dummy)
-		integer(c_int), value :: taxisIDdes_dummy
-		integer(c_int), value :: taxisIDsrc_dummy
-		interface
-			subroutine lib_taxisCopyTimestep(taxisIDdes_dummy, taxisIDsrc_dummy) bind(c, name = 'taxisCopyTimestep')
-				import c_int
-				integer(c_int), value :: taxisIDdes_dummy
-				integer(c_int), value :: taxisIDsrc_dummy
-			end subroutine lib_taxisCopyTimestep
-		end interface
-		call lib_taxisCopyTimestep(taxisIDdes_dummy, taxisIDsrc_dummy)
-	end subroutine taxisCopyTimestep
-
-	subroutine taxisDefType(taxisID_dummy, type_dummy)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), value :: type_dummy
-		interface
-			subroutine lib_taxisDefType(taxisID_dummy, type_dummy) bind(c, name = 'taxisDefType')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-				integer(c_int), value :: type_dummy
-			end subroutine lib_taxisDefType
-		end interface
-		call lib_taxisDefType(taxisID_dummy, type_dummy)
-	end subroutine taxisDefType
-
-	subroutine taxisDefVdate(taxisID_dummy, date_dummy)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), value :: date_dummy
-		interface
-			subroutine lib_taxisDefVdate(taxisID_dummy, date_dummy) bind(c, name = 'taxisDefVdate')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-				integer(c_int), value :: date_dummy
-			end subroutine lib_taxisDefVdate
-		end interface
-		call lib_taxisDefVdate(taxisID_dummy, date_dummy)
-	end subroutine taxisDefVdate
-
-	subroutine taxisDefVtime(taxisID_dummy, time_dummy)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), value :: time_dummy
-		interface
-			subroutine lib_taxisDefVtime(taxisID_dummy, time_dummy) bind(c, name = 'taxisDefVtime')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-				integer(c_int), value :: time_dummy
-			end subroutine lib_taxisDefVtime
-		end interface
-		call lib_taxisDefVtime(taxisID_dummy, time_dummy)
-	end subroutine taxisDefVtime
-
-	function taxisInqVdate(taxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: taxisID_dummy
-		interface
-			integer(c_int) function lib_taxisInqVdate(taxisID_dummy) bind(c, name = 'taxisInqVdate')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end function lib_taxisInqVdate
-		end interface
-		result = lib_taxisInqVdate(taxisID_dummy)
-	end function taxisInqVdate
-
-	function taxisInqVtime(taxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: taxisID_dummy
-		interface
-			integer(c_int) function lib_taxisInqVtime(taxisID_dummy) bind(c, name = 'taxisInqVtime')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end function lib_taxisInqVtime
-		end interface
-		result = lib_taxisInqVtime(taxisID_dummy)
-	end function taxisInqVtime
-
-	subroutine taxisDefRdate(taxisID_dummy, date_dummy)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), value :: date_dummy
-		interface
-			subroutine lib_taxisDefRdate(taxisID_dummy, date_dummy) bind(c, name = 'taxisDefRdate')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-				integer(c_int), value :: date_dummy
-			end subroutine lib_taxisDefRdate
-		end interface
-		call lib_taxisDefRdate(taxisID_dummy, date_dummy)
-	end subroutine taxisDefRdate
-
-	subroutine taxisDefRtime(taxisID_dummy, time_dummy)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), value :: time_dummy
-		interface
-			subroutine lib_taxisDefRtime(taxisID_dummy, time_dummy) bind(c, name = 'taxisDefRtime')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-				integer(c_int), value :: time_dummy
-			end subroutine lib_taxisDefRtime
-		end interface
-		call lib_taxisDefRtime(taxisID_dummy, time_dummy)
-	end subroutine taxisDefRtime
-
-	function taxisInqRdate(taxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: taxisID_dummy
-		interface
-			integer(c_int) function lib_taxisInqRdate(taxisID_dummy) bind(c, name = 'taxisInqRdate')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end function lib_taxisInqRdate
-		end interface
-		result = lib_taxisInqRdate(taxisID_dummy)
-	end function taxisInqRdate
-
-	function taxisInqRtime(taxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: taxisID_dummy
-		interface
-			integer(c_int) function lib_taxisInqRtime(taxisID_dummy) bind(c, name = 'taxisInqRtime')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end function lib_taxisInqRtime
-		end interface
-		result = lib_taxisInqRtime(taxisID_dummy)
-	end function taxisInqRtime
-
-	subroutine taxisDefFdate(taxisID_dummy, date_dummy)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), value :: date_dummy
-		interface
-			subroutine lib_taxisDefFdate(taxisID_dummy, date_dummy) bind(c, name = 'taxisDefFdate')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-				integer(c_int), value :: date_dummy
-			end subroutine lib_taxisDefFdate
-		end interface
-		call lib_taxisDefFdate(taxisID_dummy, date_dummy)
-	end subroutine taxisDefFdate
-
-	subroutine taxisDefFtime(taxisID_dummy, time_dummy)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), value :: time_dummy
-		interface
-			subroutine lib_taxisDefFtime(taxisID_dummy, time_dummy) bind(c, name = 'taxisDefFtime')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-				integer(c_int), value :: time_dummy
-			end subroutine lib_taxisDefFtime
-		end interface
-		call lib_taxisDefFtime(taxisID_dummy, time_dummy)
-	end subroutine taxisDefFtime
-
-	function taxisInqFdate(taxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: taxisID_dummy
-		interface
-			integer(c_int) function lib_taxisInqFdate(taxisID_dummy) bind(c, name = 'taxisInqFdate')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end function lib_taxisInqFdate
-		end interface
-		result = lib_taxisInqFdate(taxisID_dummy)
-	end function taxisInqFdate
-
-	function taxisInqFtime(taxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: taxisID_dummy
-		interface
-			integer(c_int) function lib_taxisInqFtime(taxisID_dummy) bind(c, name = 'taxisInqFtime')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end function lib_taxisInqFtime
-		end interface
-		result = lib_taxisInqFtime(taxisID_dummy)
-	end function taxisInqFtime
-
-	function taxisHasBounds(taxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: taxisID_dummy
-		interface
-			integer(c_int) function lib_taxisHasBounds(taxisID_dummy) bind(c, name = 'taxisHasBounds')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end function lib_taxisHasBounds
-		end interface
-		result = lib_taxisHasBounds(taxisID_dummy)
-	end function taxisHasBounds
-
-	subroutine taxisDeleteBounds(taxisID_dummy)
-		integer(c_int), value :: taxisID_dummy
-		interface
-			subroutine lib_taxisDeleteBounds(taxisID_dummy) bind(c, name = 'taxisDeleteBounds')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end subroutine lib_taxisDeleteBounds
-		end interface
-		call lib_taxisDeleteBounds(taxisID_dummy)
-	end subroutine taxisDeleteBounds
-
-	subroutine taxisDefVdateBounds(taxisID_dummy, vdate_lb_dummy, vdate_ub_dummy)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), value :: vdate_lb_dummy
-		integer(c_int), value :: vdate_ub_dummy
-		interface
-			subroutine lib_taxisDefVdateBounds(taxisID_dummy, vdate_lb_dummy, vdate_ub_dummy) bind(c, name = 'taxisDefVdateBounds')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-				integer(c_int), value :: vdate_lb_dummy
-				integer(c_int), value :: vdate_ub_dummy
-			end subroutine lib_taxisDefVdateBounds
-		end interface
-		call lib_taxisDefVdateBounds(taxisID_dummy, vdate_lb_dummy, vdate_ub_dummy)
-	end subroutine taxisDefVdateBounds
-
-	subroutine taxisDefVtimeBounds(taxisID_dummy, vtime_lb_dummy, vtime_ub_dummy)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), value :: vtime_lb_dummy
-		integer(c_int), value :: vtime_ub_dummy
-		interface
-			subroutine lib_taxisDefVtimeBounds(taxisID_dummy, vtime_lb_dummy, vtime_ub_dummy) bind(c, name = 'taxisDefVtimeBounds')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-				integer(c_int), value :: vtime_lb_dummy
-				integer(c_int), value :: vtime_ub_dummy
-			end subroutine lib_taxisDefVtimeBounds
-		end interface
-		call lib_taxisDefVtimeBounds(taxisID_dummy, vtime_lb_dummy, vtime_ub_dummy)
-	end subroutine taxisDefVtimeBounds
-
-	subroutine taxisInqVdateBounds(taxisID_dummy, vdate_lb, vdate_ub)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), optional, intent(inout) :: vdate_lb
-		integer(c_int), optional, intent(inout) :: vdate_ub
-		integer(c_int), target :: vdate_lb_temp
-		type(c_ptr) :: vdate_lb_ptr
-		integer(c_int), target :: vdate_ub_temp
-		type(c_ptr) :: vdate_ub_ptr
-		interface
-			subroutine lib_taxisInqVdateBounds(taxisID_dummy, vdate_lb, vdate_ub) bind(c, name = 'taxisInqVdateBounds')
-				import c_int, c_ptr
-				integer(c_int), value :: taxisID_dummy
-				type(c_ptr), value :: vdate_lb
-				type(c_ptr), value :: vdate_ub
-			end subroutine lib_taxisInqVdateBounds
-		end interface
-		vdate_lb_ptr = c_null_ptr
-		if(present(vdate_lb)) vdate_lb_ptr = c_loc(vdate_lb_temp)
-		vdate_ub_ptr = c_null_ptr
-		if(present(vdate_ub)) vdate_ub_ptr = c_loc(vdate_ub_temp)
-		call lib_taxisInqVdateBounds(taxisID_dummy, vdate_lb_ptr, vdate_ub_ptr)
-		if(present(vdate_lb)) vdate_lb = vdate_lb_temp
-		if(present(vdate_ub)) vdate_ub = vdate_ub_temp
-	end subroutine taxisInqVdateBounds
-
-	subroutine taxisInqVtimeBounds(taxisID_dummy, vtime_lb, vtime_ub)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), optional, intent(inout) :: vtime_lb
-		integer(c_int), optional, intent(inout) :: vtime_ub
-		integer(c_int), target :: vtime_lb_temp
-		type(c_ptr) :: vtime_lb_ptr
-		integer(c_int), target :: vtime_ub_temp
-		type(c_ptr) :: vtime_ub_ptr
-		interface
-			subroutine lib_taxisInqVtimeBounds(taxisID_dummy, vtime_lb, vtime_ub) bind(c, name = 'taxisInqVtimeBounds')
-				import c_int, c_ptr
-				integer(c_int), value :: taxisID_dummy
-				type(c_ptr), value :: vtime_lb
-				type(c_ptr), value :: vtime_ub
-			end subroutine lib_taxisInqVtimeBounds
-		end interface
-		vtime_lb_ptr = c_null_ptr
-		if(present(vtime_lb)) vtime_lb_ptr = c_loc(vtime_lb_temp)
-		vtime_ub_ptr = c_null_ptr
-		if(present(vtime_ub)) vtime_ub_ptr = c_loc(vtime_ub_temp)
-		call lib_taxisInqVtimeBounds(taxisID_dummy, vtime_lb_ptr, vtime_ub_ptr)
-		if(present(vtime_lb)) vtime_lb = vtime_lb_temp
-		if(present(vtime_ub)) vtime_ub = vtime_ub_temp
-	end subroutine taxisInqVtimeBounds
-
-	subroutine taxisDefCalendar(taxisID_dummy, calendar_dummy)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), value :: calendar_dummy
-		interface
-			subroutine lib_taxisDefCalendar(taxisID_dummy, calendar_dummy) bind(c, name = 'taxisDefCalendar')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-				integer(c_int), value :: calendar_dummy
-			end subroutine lib_taxisDefCalendar
-		end interface
-		call lib_taxisDefCalendar(taxisID_dummy, calendar_dummy)
-	end subroutine taxisDefCalendar
-
-	function taxisInqCalendar(taxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: taxisID_dummy
-		interface
-			integer(c_int) function lib_taxisInqCalendar(taxisID_dummy) bind(c, name = 'taxisInqCalendar')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end function lib_taxisInqCalendar
-		end interface
-		result = lib_taxisInqCalendar(taxisID_dummy)
-	end function taxisInqCalendar
-
-	subroutine taxisDefTunit(taxisID_dummy, tunit_dummy)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), value :: tunit_dummy
-		interface
-			subroutine lib_taxisDefTunit(taxisID_dummy, tunit_dummy) bind(c, name = 'taxisDefTunit')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-				integer(c_int), value :: tunit_dummy
-			end subroutine lib_taxisDefTunit
-		end interface
-		call lib_taxisDefTunit(taxisID_dummy, tunit_dummy)
-	end subroutine taxisDefTunit
-
-	function taxisInqTunit(taxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: taxisID_dummy
-		interface
-			integer(c_int) function lib_taxisInqTunit(taxisID_dummy) bind(c, name = 'taxisInqTunit')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end function lib_taxisInqTunit
-		end interface
-		result = lib_taxisInqTunit(taxisID_dummy)
-	end function taxisInqTunit
-
-	subroutine taxisDefForecastTunit(taxisID_dummy, tunit_dummy)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), value :: tunit_dummy
-		interface
-			subroutine lib_taxisDefForecastTunit(taxisID_dummy, tunit_dummy) bind(c, name = 'taxisDefForecastTunit')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-				integer(c_int), value :: tunit_dummy
-			end subroutine lib_taxisDefForecastTunit
-		end interface
-		call lib_taxisDefForecastTunit(taxisID_dummy, tunit_dummy)
-	end subroutine taxisDefForecastTunit
-
-	function taxisInqForecastTunit(taxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: taxisID_dummy
-		interface
-			integer(c_int) function lib_taxisInqForecastTunit(taxisID_dummy) bind(c, name = 'taxisInqForecastTunit')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end function lib_taxisInqForecastTunit
-		end interface
-		result = lib_taxisInqForecastTunit(taxisID_dummy)
-	end function taxisInqForecastTunit
-
-	subroutine taxisDefForecastPeriod(taxisID_dummy, fc_period_dummy)
-		integer(c_int), value :: taxisID_dummy
-		real(c_double), value :: fc_period_dummy
-		interface
-			subroutine lib_taxisDefForecastPeriod(taxisID_dummy, fc_period_dummy) bind(c, name = 'taxisDefForecastPeriod')
-				import c_double, c_int
-				integer(c_int), value :: taxisID_dummy
-				real(c_double), value :: fc_period_dummy
-			end subroutine lib_taxisDefForecastPeriod
-		end interface
-		call lib_taxisDefForecastPeriod(taxisID_dummy, fc_period_dummy)
-	end subroutine taxisDefForecastPeriod
-
-	function taxisInqForecastPeriod(taxisID_dummy) result(result)
-		real(c_double) :: result
-		integer(c_int), value :: taxisID_dummy
-		interface
-			real(c_double) function lib_taxisInqForecastPeriod(taxisID_dummy) bind(c, name = 'taxisInqForecastPeriod')
-				import c_double, c_int
-				integer(c_int), value :: taxisID_dummy
-			end function lib_taxisInqForecastPeriod
-		end interface
-		result = lib_taxisInqForecastPeriod(taxisID_dummy)
-	end function taxisInqForecastPeriod
-
-	subroutine taxisDefNumavg(taxisID_dummy, numavg_dummy)
-		integer(c_int), value :: taxisID_dummy
-		integer(c_int), value :: numavg_dummy
-		interface
-			subroutine lib_taxisDefNumavg(taxisID_dummy, numavg_dummy) bind(c, name = 'taxisDefNumavg')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-				integer(c_int), value :: numavg_dummy
-			end subroutine lib_taxisDefNumavg
-		end interface
-		call lib_taxisDefNumavg(taxisID_dummy, numavg_dummy)
-	end subroutine taxisDefNumavg
-
-	function taxisInqType(taxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: taxisID_dummy
-		interface
-			integer(c_int) function lib_taxisInqType(taxisID_dummy) bind(c, name = 'taxisInqType')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end function lib_taxisInqType
-		end interface
-		result = lib_taxisInqType(taxisID_dummy)
-	end function taxisInqType
-
-	function taxisInqNumavg(taxisID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: taxisID_dummy
-		interface
-			integer(c_int) function lib_taxisInqNumavg(taxisID_dummy) bind(c, name = 'taxisInqNumavg')
-				import c_int
-				integer(c_int), value :: taxisID_dummy
-			end function lib_taxisInqNumavg
-		end interface
-		result = lib_taxisInqNumavg(taxisID_dummy)
-	end function taxisInqNumavg
-
-	function tunitNamePtr(tunitID_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		integer(c_int), value :: tunitID_dummy
-		type(c_ptr) :: ptr
-		integer :: shape(1)
-		interface
-			type(c_ptr) function lib_tunitNamePtr(tunitID_dummy) bind(c, name = 'tunitNamePtr')
-				import c_int, c_ptr
-				integer(c_int), value :: tunitID_dummy
-			end function lib_tunitNamePtr
-		end interface
-		result => null()
-		ptr = lib_tunitNamePtr(tunitID_dummy)
-		if(c_associated(ptr)) then
-			shape(1) = int(lib_strlen(ptr))
-			call c_f_pointer(ptr, result, shape)
-		end if
-	end function tunitNamePtr
-
-	function institutDef(center_dummy, subcenter_dummy, name_dummy, longname_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: center_dummy
-		integer(c_int), value :: subcenter_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		character(kind = c_char, len = *), intent(in) :: longname_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		character(kind = c_char) :: longname_temp(len(longname_dummy) + 1)
-		integer :: longname_i
-		interface
-			integer(c_int) function lib_institutDef(center_dummy, subcenter_dummy, name_dummy, longname_dummy) bind(c, name = 'institutDef')
-				import c_char, c_int
-				integer(c_int), value :: center_dummy
-				integer(c_int), value :: subcenter_dummy
-				character(kind = c_char) :: name_dummy(*)
-				character(kind = c_char) :: longname_dummy(*)
-			end function lib_institutDef
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		do longname_i = 1, len(longname_dummy)
-		longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
-		end do
-		longname_temp(len(longname_dummy) + 1) = c_null_char
-		result = lib_institutDef(center_dummy, subcenter_dummy, name_temp, longname_temp)
-	end function institutDef
-
-	function institutInq(center_dummy, subcenter_dummy, name_dummy, longname_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: center_dummy
-		integer(c_int), value :: subcenter_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		character(kind = c_char, len = *), intent(in) :: longname_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		character(kind = c_char) :: longname_temp(len(longname_dummy) + 1)
-		integer :: longname_i
-		interface
-			integer(c_int) function lib_institutInq(center_dummy, subcenter_dummy, name_dummy, longname_dummy) bind(c, name = 'institutInq')
-				import c_char, c_int
-				integer(c_int), value :: center_dummy
-				integer(c_int), value :: subcenter_dummy
-				character(kind = c_char) :: name_dummy(*)
-				character(kind = c_char) :: longname_dummy(*)
-			end function lib_institutInq
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		do longname_i = 1, len(longname_dummy)
-		longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
-		end do
-		longname_temp(len(longname_dummy) + 1) = c_null_char
-		result = lib_institutInq(center_dummy, subcenter_dummy, name_temp, longname_temp)
-	end function institutInq
-
-	function institutInqNumber() result(result)
-		integer(c_int) :: result
-		interface
-			integer(c_int) function lib_institutInqNumber() bind(c, name = 'institutInqNumber')
-				import c_int
-			end function lib_institutInqNumber
-		end interface
-		result = lib_institutInqNumber()
-	end function institutInqNumber
-
-	function institutInqCenter(instID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: instID_dummy
-		interface
-			integer(c_int) function lib_institutInqCenter(instID_dummy) bind(c, name = 'institutInqCenter')
-				import c_int
-				integer(c_int), value :: instID_dummy
-			end function lib_institutInqCenter
-		end interface
-		result = lib_institutInqCenter(instID_dummy)
-	end function institutInqCenter
-
-	function institutInqSubcenter(instID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: instID_dummy
-		interface
-			integer(c_int) function lib_institutInqSubcenter(instID_dummy) bind(c, name = 'institutInqSubcenter')
-				import c_int
-				integer(c_int), value :: instID_dummy
-			end function lib_institutInqSubcenter
-		end interface
-		result = lib_institutInqSubcenter(instID_dummy)
-	end function institutInqSubcenter
-
-	function institutInqNamePtr(instID_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		integer(c_int), value :: instID_dummy
-		type(c_ptr) :: ptr
-		integer :: shape(1)
-		interface
-			type(c_ptr) function lib_institutInqNamePtr(instID_dummy) bind(c, name = 'institutInqNamePtr')
-				import c_int, c_ptr
-				integer(c_int), value :: instID_dummy
-			end function lib_institutInqNamePtr
-		end interface
-		result => null()
-		ptr = lib_institutInqNamePtr(instID_dummy)
-		if(c_associated(ptr)) then
-			shape(1) = int(lib_strlen(ptr))
-			call c_f_pointer(ptr, result, shape)
-		end if
-	end function institutInqNamePtr
-
-	function institutInqLongnamePtr(instID_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		integer(c_int), value :: instID_dummy
-		type(c_ptr) :: ptr
-		integer :: shape(1)
-		interface
-			type(c_ptr) function lib_institutInqLongnamePtr(instID_dummy) bind(c, name = 'institutInqLongnamePtr')
-				import c_int, c_ptr
-				integer(c_int), value :: instID_dummy
-			end function lib_institutInqLongnamePtr
-		end interface
-		result => null()
-		ptr = lib_institutInqLongnamePtr(instID_dummy)
-		if(c_associated(ptr)) then
-			shape(1) = int(lib_strlen(ptr))
-			call c_f_pointer(ptr, result, shape)
-		end if
-	end function institutInqLongnamePtr
-
-	function modelDef(instID_dummy, modelgribID_dummy, name_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: instID_dummy
-		integer(c_int), value :: modelgribID_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		interface
-			integer(c_int) function lib_modelDef(instID_dummy, modelgribID_dummy, name_dummy) bind(c, name = 'modelDef')
-				import c_char, c_int
-				integer(c_int), value :: instID_dummy
-				integer(c_int), value :: modelgribID_dummy
-				character(kind = c_char) :: name_dummy(*)
-			end function lib_modelDef
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		result = lib_modelDef(instID_dummy, modelgribID_dummy, name_temp)
-	end function modelDef
-
-	function modelInq(instID_dummy, modelgribID_dummy, name_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: instID_dummy
-		integer(c_int), value :: modelgribID_dummy
-		character(kind = c_char, len = *), intent(inout) :: name_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy))
-		integer :: name_i
-		logical :: name_padding = .true.
-		interface
-			integer(c_int) function lib_modelInq(instID_dummy, modelgribID_dummy, name_dummy) bind(c, name = 'modelInq')
-				import c_char, c_int
-				integer(c_int), value :: instID_dummy
-				integer(c_int), value :: modelgribID_dummy
-				character(kind = c_char) :: name_dummy(*)
-			end function lib_modelInq
-		end interface
-		do name_i = len(name_dummy), 1, -1
-			if(name_dummy(name_i:name_i) /= ' ') name_padding = .false.
-			if(name_padding) then
-				name_temp(name_i) = c_null_char
-			else
-				name_temp(name_i) = name_dummy(name_i:name_i)
-			end if
-		end do
-		result = lib_modelInq(instID_dummy, modelgribID_dummy, name_temp)
-		name_padding = .false.
-		do name_i = 1, len(name_dummy)
-			if(name_temp(name_i) == c_null_char) name_padding = .true.
-			if(name_padding) then
-				name_dummy(name_i:name_i) = ' '
-			else
-				name_dummy(name_i:name_i) = name_temp(name_i)
-			end if
-		end do
-	end function modelInq
-
-	function modelInqInstitut(modelID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: modelID_dummy
-		interface
-			integer(c_int) function lib_modelInqInstitut(modelID_dummy) bind(c, name = 'modelInqInstitut')
-				import c_int
-				integer(c_int), value :: modelID_dummy
-			end function lib_modelInqInstitut
-		end interface
-		result = lib_modelInqInstitut(modelID_dummy)
-	end function modelInqInstitut
-
-	function modelInqGribID(modelID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: modelID_dummy
-		interface
-			integer(c_int) function lib_modelInqGribID(modelID_dummy) bind(c, name = 'modelInqGribID')
-				import c_int
-				integer(c_int), value :: modelID_dummy
-			end function lib_modelInqGribID
-		end interface
-		result = lib_modelInqGribID(modelID_dummy)
-	end function modelInqGribID
-
-	function modelInqNamePtr(modelID_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		integer(c_int), value :: modelID_dummy
-		type(c_ptr) :: ptr
-		integer :: shape(1)
-		interface
-			type(c_ptr) function lib_modelInqNamePtr(modelID_dummy) bind(c, name = 'modelInqNamePtr')
-				import c_int, c_ptr
-				integer(c_int), value :: modelID_dummy
-			end function lib_modelInqNamePtr
-		end interface
-		result => null()
-		ptr = lib_modelInqNamePtr(modelID_dummy)
-		if(c_associated(ptr)) then
-			shape(1) = int(lib_strlen(ptr))
-			call c_f_pointer(ptr, result, shape)
-		end if
-	end function modelInqNamePtr
-
-	subroutine tableWriteC(filename_dummy, tableID_dummy)
-		character(kind = c_char, len = *), intent(in) :: filename_dummy
-		integer(c_int), value :: tableID_dummy
-		character(kind = c_char) :: filename_temp(len(filename_dummy) + 1)
-		integer :: filename_i
-		interface
-			subroutine lib_tableWriteC(filename_dummy, tableID_dummy) bind(c, name = 'tableWriteC')
-				import c_char, c_int
-				character(kind = c_char) :: filename_dummy(*)
-				integer(c_int), value :: tableID_dummy
-			end subroutine lib_tableWriteC
-		end interface
-		do filename_i = 1, len(filename_dummy)
-		filename_temp(filename_i) = filename_dummy(filename_i:filename_i)
-		end do
-		filename_temp(len(filename_dummy) + 1) = c_null_char
-		call lib_tableWriteC(filename_temp, tableID_dummy)
-	end subroutine tableWriteC
-
-	subroutine tableWrite(filename_dummy, tableID_dummy)
-		character(kind = c_char, len = *), intent(in) :: filename_dummy
-		integer(c_int), value :: tableID_dummy
-		character(kind = c_char) :: filename_temp(len(filename_dummy) + 1)
-		integer :: filename_i
-		interface
-			subroutine lib_tableWrite(filename_dummy, tableID_dummy) bind(c, name = 'tableWrite')
-				import c_char, c_int
-				character(kind = c_char) :: filename_dummy(*)
-				integer(c_int), value :: tableID_dummy
-			end subroutine lib_tableWrite
-		end interface
-		do filename_i = 1, len(filename_dummy)
-		filename_temp(filename_i) = filename_dummy(filename_i:filename_i)
-		end do
-		filename_temp(len(filename_dummy) + 1) = c_null_char
-		call lib_tableWrite(filename_temp, tableID_dummy)
-	end subroutine tableWrite
-
-	function tableRead(tablefile_dummy) result(result)
-		integer(c_int) :: result
-		character(kind = c_char, len = *), intent(in) :: tablefile_dummy
-		character(kind = c_char) :: tablefile_temp(len(tablefile_dummy) + 1)
-		integer :: tablefile_i
-		interface
-			integer(c_int) function lib_tableRead(tablefile_dummy) bind(c, name = 'tableRead')
-				import c_char, c_int
-				character(kind = c_char) :: tablefile_dummy(*)
-			end function lib_tableRead
-		end interface
-		do tablefile_i = 1, len(tablefile_dummy)
-		tablefile_temp(tablefile_i) = tablefile_dummy(tablefile_i:tablefile_i)
-		end do
-		tablefile_temp(len(tablefile_dummy) + 1) = c_null_char
-		result = lib_tableRead(tablefile_temp)
-	end function tableRead
-
-	function tableDef(modelID_dummy, tablenum_dummy, tablename_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: modelID_dummy
-		integer(c_int), value :: tablenum_dummy
-		character(kind = c_char, len = *), intent(in) :: tablename_dummy
-		character(kind = c_char) :: tablename_temp(len(tablename_dummy) + 1)
-		integer :: tablename_i
-		interface
-			integer(c_int) function lib_tableDef(modelID_dummy, tablenum_dummy, tablename_dummy) bind(c, name = 'tableDef')
-				import c_char, c_int
-				integer(c_int), value :: modelID_dummy
-				integer(c_int), value :: tablenum_dummy
-				character(kind = c_char) :: tablename_dummy(*)
-			end function lib_tableDef
-		end interface
-		do tablename_i = 1, len(tablename_dummy)
-		tablename_temp(tablename_i) = tablename_dummy(tablename_i:tablename_i)
-		end do
-		tablename_temp(len(tablename_dummy) + 1) = c_null_char
-		result = lib_tableDef(modelID_dummy, tablenum_dummy, tablename_temp)
-	end function tableDef
-
-	function tableInqNamePtr(tableID_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		integer(c_int), value :: tableID_dummy
-		type(c_ptr) :: ptr
-		integer :: shape(1)
-		interface
-			type(c_ptr) function lib_tableInqNamePtr(tableID_dummy) bind(c, name = 'tableInqNamePtr')
-				import c_int, c_ptr
-				integer(c_int), value :: tableID_dummy
-			end function lib_tableInqNamePtr
-		end interface
-		result => null()
-		ptr = lib_tableInqNamePtr(tableID_dummy)
-		if(c_associated(ptr)) then
-			shape(1) = int(lib_strlen(ptr))
-			call c_f_pointer(ptr, result, shape)
-		end if
-	end function tableInqNamePtr
-
-	subroutine tableDefEntry(tableID_dummy, code_dummy, name_dummy, longname_dummy, units_dummy)
-		integer(c_int), value :: tableID_dummy
-		integer(c_int), value :: code_dummy
-		character(kind = c_char, len = *), intent(in) :: name_dummy
-		character(kind = c_char, len = *), intent(in) :: longname_dummy
-		character(kind = c_char, len = *), intent(in) :: units_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy) + 1)
-		integer :: name_i
-		character(kind = c_char) :: longname_temp(len(longname_dummy) + 1)
-		integer :: longname_i
-		character(kind = c_char) :: units_temp(len(units_dummy) + 1)
-		integer :: units_i
-		interface
-			subroutine lib_tableDefEntry(tableID_dummy, code_dummy, name_dummy, longname_dummy, units_dummy) bind(c, name = 'tableDefEntry')
-				import c_char, c_int
-				integer(c_int), value :: tableID_dummy
-				integer(c_int), value :: code_dummy
-				character(kind = c_char) :: name_dummy(*)
-				character(kind = c_char) :: longname_dummy(*)
-				character(kind = c_char) :: units_dummy(*)
-			end subroutine lib_tableDefEntry
-		end interface
-		do name_i = 1, len(name_dummy)
-		name_temp(name_i) = name_dummy(name_i:name_i)
-		end do
-		name_temp(len(name_dummy) + 1) = c_null_char
-		do longname_i = 1, len(longname_dummy)
-		longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
-		end do
-		longname_temp(len(longname_dummy) + 1) = c_null_char
-		do units_i = 1, len(units_dummy)
-		units_temp(units_i) = units_dummy(units_i:units_i)
-		end do
-		units_temp(len(units_dummy) + 1) = c_null_char
-		call lib_tableDefEntry(tableID_dummy, code_dummy, name_temp, longname_temp, units_temp)
-	end subroutine tableDefEntry
-
-	function tableInq(modelID_dummy, tablenum_dummy, tablename_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: modelID_dummy
-		integer(c_int), value :: tablenum_dummy
-		character(kind = c_char, len = *), intent(in) :: tablename_dummy
-		character(kind = c_char) :: tablename_temp(len(tablename_dummy) + 1)
-		integer :: tablename_i
-		interface
-			integer(c_int) function lib_tableInq(modelID_dummy, tablenum_dummy, tablename_dummy) bind(c, name = 'tableInq')
-				import c_char, c_int
-				integer(c_int), value :: modelID_dummy
-				integer(c_int), value :: tablenum_dummy
-				character(kind = c_char) :: tablename_dummy(*)
-			end function lib_tableInq
-		end interface
-		do tablename_i = 1, len(tablename_dummy)
-		tablename_temp(tablename_i) = tablename_dummy(tablename_i:tablename_i)
-		end do
-		tablename_temp(len(tablename_dummy) + 1) = c_null_char
-		result = lib_tableInq(modelID_dummy, tablenum_dummy, tablename_temp)
-	end function tableInq
-
-	function tableInqNumber() result(result)
-		integer(c_int) :: result
-		interface
-			integer(c_int) function lib_tableInqNumber() bind(c, name = 'tableInqNumber')
-				import c_int
-			end function lib_tableInqNumber
-		end interface
-		result = lib_tableInqNumber()
-	end function tableInqNumber
-
-	function tableInqNum(tableID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: tableID_dummy
-		interface
-			integer(c_int) function lib_tableInqNum(tableID_dummy) bind(c, name = 'tableInqNum')
-				import c_int
-				integer(c_int), value :: tableID_dummy
-			end function lib_tableInqNum
-		end interface
-		result = lib_tableInqNum(tableID_dummy)
-	end function tableInqNum
-
-	function tableInqModel(tableID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: tableID_dummy
-		interface
-			integer(c_int) function lib_tableInqModel(tableID_dummy) bind(c, name = 'tableInqModel')
-				import c_int
-				integer(c_int), value :: tableID_dummy
-			end function lib_tableInqModel
-		end interface
-		result = lib_tableInqModel(tableID_dummy)
-	end function tableInqModel
-
-	subroutine tableInqPar(tableID_dummy, code_dummy, name_dummy, longname_dummy, units_dummy)
-		integer(c_int), value :: tableID_dummy
-		integer(c_int), value :: code_dummy
-		character(kind = c_char, len = *), intent(inout) :: name_dummy
-		character(kind = c_char, len = *), intent(inout) :: longname_dummy
-		character(kind = c_char, len = *), intent(inout) :: units_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy))
-		integer :: name_i
-		logical :: name_padding = .true.
-		character(kind = c_char) :: longname_temp(len(longname_dummy))
-		integer :: longname_i
-		logical :: longname_padding = .true.
-		character(kind = c_char) :: units_temp(len(units_dummy))
-		integer :: units_i
-		logical :: units_padding = .true.
-		interface
-			subroutine lib_tableInqPar(tableID_dummy, code_dummy, name_dummy, longname_dummy, units_dummy) bind(c, name = 'tableInqPar')
-				import c_char, c_int
-				integer(c_int), value :: tableID_dummy
-				integer(c_int), value :: code_dummy
-				character(kind = c_char) :: name_dummy(*)
-				character(kind = c_char) :: longname_dummy(*)
-				character(kind = c_char) :: units_dummy(*)
-			end subroutine lib_tableInqPar
-		end interface
-		do name_i = len(name_dummy), 1, -1
-			if(name_dummy(name_i:name_i) /= ' ') name_padding = .false.
-			if(name_padding) then
-				name_temp(name_i) = c_null_char
-			else
-				name_temp(name_i) = name_dummy(name_i:name_i)
-			end if
-		end do
-		do longname_i = len(longname_dummy), 1, -1
-			if(longname_dummy(longname_i:longname_i) /= ' ') longname_padding = .false.
-			if(longname_padding) then
-				longname_temp(longname_i) = c_null_char
-			else
-				longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
-			end if
-		end do
-		do units_i = len(units_dummy), 1, -1
-			if(units_dummy(units_i:units_i) /= ' ') units_padding = .false.
-			if(units_padding) then
-				units_temp(units_i) = c_null_char
-			else
-				units_temp(units_i) = units_dummy(units_i:units_i)
-			end if
-		end do
-		call lib_tableInqPar(tableID_dummy, code_dummy, name_temp, longname_temp, units_temp)
-		name_padding = .false.
-		do name_i = 1, len(name_dummy)
-			if(name_temp(name_i) == c_null_char) name_padding = .true.
-			if(name_padding) then
-				name_dummy(name_i:name_i) = ' '
-			else
-				name_dummy(name_i:name_i) = name_temp(name_i)
-			end if
-		end do
-		longname_padding = .false.
-		do longname_i = 1, len(longname_dummy)
-			if(longname_temp(longname_i) == c_null_char) longname_padding = .true.
-			if(longname_padding) then
-				longname_dummy(longname_i:longname_i) = ' '
-			else
-				longname_dummy(longname_i:longname_i) = longname_temp(longname_i)
-			end if
-		end do
-		units_padding = .false.
-		do units_i = 1, len(units_dummy)
-			if(units_temp(units_i) == c_null_char) units_padding = .true.
-			if(units_padding) then
-				units_dummy(units_i:units_i) = ' '
-			else
-				units_dummy(units_i:units_i) = units_temp(units_i)
-			end if
-		end do
-	end subroutine tableInqPar
-
-	function tableInqParCode(tableID_dummy, name_dummy, code) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: tableID_dummy
-		character(kind = c_char, len = *), intent(inout) :: name_dummy
-		integer(c_int), optional, intent(inout) :: code
-		character(kind = c_char) :: name_temp(len(name_dummy))
-		integer :: name_i
-		logical :: name_padding = .true.
-		integer(c_int), target :: code_temp
-		type(c_ptr) :: code_ptr
-		interface
-			integer(c_int) function lib_tableInqParCode(tableID_dummy, name_dummy, code) bind(c, name = 'tableInqParCode')
-				import c_char, c_int, c_ptr
-				integer(c_int), value :: tableID_dummy
-				character(kind = c_char) :: name_dummy(*)
-				type(c_ptr), value :: code
-			end function lib_tableInqParCode
-		end interface
-		do name_i = len(name_dummy), 1, -1
-			if(name_dummy(name_i:name_i) /= ' ') name_padding = .false.
-			if(name_padding) then
-				name_temp(name_i) = c_null_char
-			else
-				name_temp(name_i) = name_dummy(name_i:name_i)
-			end if
-		end do
-		code_ptr = c_null_ptr
-		if(present(code)) code_ptr = c_loc(code_temp)
-		result = lib_tableInqParCode(tableID_dummy, name_temp, code_ptr)
-		name_padding = .false.
-		do name_i = 1, len(name_dummy)
-			if(name_temp(name_i) == c_null_char) name_padding = .true.
-			if(name_padding) then
-				name_dummy(name_i:name_i) = ' '
-			else
-				name_dummy(name_i:name_i) = name_temp(name_i)
-			end if
-		end do
-		if(present(code)) code = code_temp
-	end function tableInqParCode
-
-	function tableInqParName(tableID_dummy, code_dummy, name_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: tableID_dummy
-		integer(c_int), value :: code_dummy
-		character(kind = c_char, len = *), intent(inout) :: name_dummy
-		character(kind = c_char) :: name_temp(len(name_dummy))
-		integer :: name_i
-		logical :: name_padding = .true.
-		interface
-			integer(c_int) function lib_tableInqParName(tableID_dummy, code_dummy, name_dummy) bind(c, name = 'tableInqParName')
-				import c_char, c_int
-				integer(c_int), value :: tableID_dummy
-				integer(c_int), value :: code_dummy
-				character(kind = c_char) :: name_dummy(*)
-			end function lib_tableInqParName
-		end interface
-		do name_i = len(name_dummy), 1, -1
-			if(name_dummy(name_i:name_i) /= ' ') name_padding = .false.
-			if(name_padding) then
-				name_temp(name_i) = c_null_char
-			else
-				name_temp(name_i) = name_dummy(name_i:name_i)
-			end if
-		end do
-		result = lib_tableInqParName(tableID_dummy, code_dummy, name_temp)
-		name_padding = .false.
-		do name_i = 1, len(name_dummy)
-			if(name_temp(name_i) == c_null_char) name_padding = .true.
-			if(name_padding) then
-				name_dummy(name_i:name_i) = ' '
-			else
-				name_dummy(name_i:name_i) = name_temp(name_i)
-			end if
-		end do
-	end function tableInqParName
-
-	function tableInqParLongname(tableID_dummy, code_dummy, longname_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: tableID_dummy
-		integer(c_int), value :: code_dummy
-		character(kind = c_char, len = *), intent(inout) :: longname_dummy
-		character(kind = c_char) :: longname_temp(len(longname_dummy))
-		integer :: longname_i
-		logical :: longname_padding = .true.
-		interface
-			integer(c_int) function lib_tableInqParLongname(tableID_dummy, code_dummy, longname_dummy) bind(c, name = 'tableInqParLongname')
-				import c_char, c_int
-				integer(c_int), value :: tableID_dummy
-				integer(c_int), value :: code_dummy
-				character(kind = c_char) :: longname_dummy(*)
-			end function lib_tableInqParLongname
-		end interface
-		do longname_i = len(longname_dummy), 1, -1
-			if(longname_dummy(longname_i:longname_i) /= ' ') longname_padding = .false.
-			if(longname_padding) then
-				longname_temp(longname_i) = c_null_char
-			else
-				longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
-			end if
-		end do
-		result = lib_tableInqParLongname(tableID_dummy, code_dummy, longname_temp)
-		longname_padding = .false.
-		do longname_i = 1, len(longname_dummy)
-			if(longname_temp(longname_i) == c_null_char) longname_padding = .true.
-			if(longname_padding) then
-				longname_dummy(longname_i:longname_i) = ' '
-			else
-				longname_dummy(longname_i:longname_i) = longname_temp(longname_i)
-			end if
-		end do
-	end function tableInqParLongname
-
-	function tableInqParUnits(tableID_dummy, code_dummy, units_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: tableID_dummy
-		integer(c_int), value :: code_dummy
-		character(kind = c_char, len = *), intent(inout) :: units_dummy
-		character(kind = c_char) :: units_temp(len(units_dummy))
-		integer :: units_i
-		logical :: units_padding = .true.
-		interface
-			integer(c_int) function lib_tableInqParUnits(tableID_dummy, code_dummy, units_dummy) bind(c, name = 'tableInqParUnits')
-				import c_char, c_int
-				integer(c_int), value :: tableID_dummy
-				integer(c_int), value :: code_dummy
-				character(kind = c_char) :: units_dummy(*)
-			end function lib_tableInqParUnits
-		end interface
-		do units_i = len(units_dummy), 1, -1
-			if(units_dummy(units_i:units_i) /= ' ') units_padding = .false.
-			if(units_padding) then
-				units_temp(units_i) = c_null_char
-			else
-				units_temp(units_i) = units_dummy(units_i:units_i)
-			end if
-		end do
-		result = lib_tableInqParUnits(tableID_dummy, code_dummy, units_temp)
-		units_padding = .false.
-		do units_i = 1, len(units_dummy)
-			if(units_temp(units_i) == c_null_char) units_padding = .true.
-			if(units_padding) then
-				units_dummy(units_i:units_i) = ' '
-			else
-				units_dummy(units_i:units_i) = units_temp(units_i)
-			end if
-		end do
-	end function tableInqParUnits
-
-	function tableInqParNamePtr(tableID_dummy, parID_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		integer(c_int), value :: tableID_dummy
-		integer(c_int), value :: parID_dummy
-		type(c_ptr) :: ptr
-		integer :: shape(1)
-		interface
-			type(c_ptr) function lib_tableInqParNamePtr(tableID_dummy, parID_dummy) bind(c, name = 'tableInqParNamePtr')
-				import c_int, c_ptr
-				integer(c_int), value :: tableID_dummy
-				integer(c_int), value :: parID_dummy
-			end function lib_tableInqParNamePtr
-		end interface
-		result => null()
-		ptr = lib_tableInqParNamePtr(tableID_dummy, parID_dummy)
-		if(c_associated(ptr)) then
-			shape(1) = int(lib_strlen(ptr))
-			call c_f_pointer(ptr, result, shape)
-		end if
-	end function tableInqParNamePtr
-
-	function tableInqParLongnamePtr(tableID_dummy, parID_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		integer(c_int), value :: tableID_dummy
-		integer(c_int), value :: parID_dummy
-		type(c_ptr) :: ptr
-		integer :: shape(1)
-		interface
-			type(c_ptr) function lib_tableInqParLongnamePtr(tableID_dummy, parID_dummy) bind(c, name = 'tableInqParLongnamePtr')
-				import c_int, c_ptr
-				integer(c_int), value :: tableID_dummy
-				integer(c_int), value :: parID_dummy
-			end function lib_tableInqParLongnamePtr
-		end interface
-		result => null()
-		ptr = lib_tableInqParLongnamePtr(tableID_dummy, parID_dummy)
-		if(c_associated(ptr)) then
-			shape(1) = int(lib_strlen(ptr))
-			call c_f_pointer(ptr, result, shape)
-		end if
-	end function tableInqParLongnamePtr
-
-	function tableInqParUnitsPtr(tableID_dummy, parID_dummy) result(result)
-		character(kind = c_char), dimension(:), pointer :: result
-		integer(c_int), value :: tableID_dummy
-		integer(c_int), value :: parID_dummy
-		type(c_ptr) :: ptr
-		integer :: shape(1)
-		interface
-			type(c_ptr) function lib_tableInqParUnitsPtr(tableID_dummy, parID_dummy) bind(c, name = 'tableInqParUnitsPtr')
-				import c_int, c_ptr
-				integer(c_int), value :: tableID_dummy
-				integer(c_int), value :: parID_dummy
-			end function lib_tableInqParUnitsPtr
-		end interface
-		result => null()
-		ptr = lib_tableInqParUnitsPtr(tableID_dummy, parID_dummy)
-		if(c_associated(ptr)) then
-			shape(1) = int(lib_strlen(ptr))
-			call c_f_pointer(ptr, result, shape)
-		end if
-	end function tableInqParUnitsPtr
-
-	subroutine streamDefHistory(streamID_dummy, size_dummy, history_dummy)
-		integer(c_int), value :: streamID_dummy
-		integer(c_int), value :: size_dummy
-		character(kind = c_char, len = *), intent(in) :: history_dummy
-		character(kind = c_char) :: history_temp(len(history_dummy) + 1)
-		integer :: history_i
-		interface
-			subroutine lib_streamDefHistory(streamID_dummy, size_dummy, history_dummy) bind(c, name = 'streamDefHistory')
-				import c_char, c_int
-				integer(c_int), value :: streamID_dummy
-				integer(c_int), value :: size_dummy
-				character(kind = c_char) :: history_dummy(*)
-			end subroutine lib_streamDefHistory
-		end interface
-		do history_i = 1, len(history_dummy)
-		history_temp(history_i) = history_dummy(history_i:history_i)
-		end do
-		history_temp(len(history_dummy) + 1) = c_null_char
-		call lib_streamDefHistory(streamID_dummy, size_dummy, history_temp)
-	end subroutine streamDefHistory
-
-	function streamInqHistorySize(streamID_dummy) result(result)
-		integer(c_int) :: result
-		integer(c_int), value :: streamID_dummy
-		interface
-			integer(c_int) function lib_streamInqHistorySize(streamID_dummy) bind(c, name = 'streamInqHistorySize')
-				import c_int
-				integer(c_int), value :: streamID_dummy
-			end function lib_streamInqHistorySize
-		end interface
-		result = lib_streamInqHistorySize(streamID_dummy)
-	end function streamInqHistorySize
-
-	subroutine streamInqHistoryString(streamID_dummy, history_dummy)
-		integer(c_int), value :: streamID_dummy
-		character(kind = c_char, len = *), intent(inout) :: history_dummy
-		character(kind = c_char) :: history_temp(len(history_dummy))
-		integer :: history_i
-		logical :: history_padding = .true.
-		interface
-			subroutine lib_streamInqHistoryString(streamID_dummy, history_dummy) bind(c, name = 'streamInqHistoryString')
-				import c_char, c_int
-				integer(c_int), value :: streamID_dummy
-				character(kind = c_char) :: history_dummy(*)
-			end subroutine lib_streamInqHistoryString
-		end interface
-		do history_i = len(history_dummy), 1, -1
-			if(history_dummy(history_i:history_i) /= ' ') history_padding = .false.
-			if(history_padding) then
-				history_temp(history_i) = c_null_char
-			else
-				history_temp(history_i) = history_dummy(history_i:history_i)
-			end if
-		end do
-		call lib_streamInqHistoryString(streamID_dummy, history_temp)
-		history_padding = .false.
-		do history_i = 1, len(history_dummy)
-			if(history_temp(history_i) == c_null_char) history_padding = .true.
-			if(history_padding) then
-				history_dummy(history_i:history_i) = ' '
-			else
-				history_dummy(history_i:history_i) = history_temp(history_i)
-			end if
-		end do
-	end subroutine streamInqHistoryString
-
-	subroutine gribapiLibraryVersion(major_version, minor_version, revision_version)
-		integer(c_int), optional, intent(inout) :: major_version
-		integer(c_int), optional, intent(inout) :: minor_version
-		integer(c_int), optional, intent(inout) :: revision_version
-		integer(c_int), target :: major_version_temp
-		type(c_ptr) :: major_version_ptr
-		integer(c_int), target :: minor_version_temp
-		type(c_ptr) :: minor_version_ptr
-		integer(c_int), target :: revision_version_temp
-		type(c_ptr) :: revision_version_ptr
-		interface
-			subroutine lib_gribapiLibraryVersion(major_version, minor_version, revision_version) bind(c, name = 'gribapiLibraryVersion')
-				import c_ptr
-				type(c_ptr), value :: major_version
-				type(c_ptr), value :: minor_version
-				type(c_ptr), value :: revision_version
-			end subroutine lib_gribapiLibraryVersion
-		end interface
-		major_version_ptr = c_null_ptr
-		if(present(major_version)) major_version_ptr = c_loc(major_version_temp)
-		minor_version_ptr = c_null_ptr
-		if(present(minor_version)) minor_version_ptr = c_loc(minor_version_temp)
-		revision_version_ptr = c_null_ptr
-		if(present(revision_version)) revision_version_ptr = c_loc(revision_version_temp)
-		call lib_gribapiLibraryVersion(major_version_ptr, minor_version_ptr, revision_version_ptr)
-		if(present(major_version)) major_version = major_version_temp
-		if(present(minor_version)) minor_version = minor_version_temp
-		if(present(revision_version)) revision_version = revision_version_temp
-	end subroutine gribapiLibraryVersion
+  subroutine ctrim(str)
+    character(kind = c_char, len = *), intent(inout) :: str
+    integer :: i
+
+    do i=1,len(str)
+      if (str(i:i) == c_null_char) then
+        str(i:len(str)) = ' '
+        exit
+      end if
+    end do
+  end subroutine ctrim
+
+  function c_len(s) result(i)
+    character(kind = c_char, len = *), intent(in) :: s
+    integer :: i
+
+    do i = 1, len(s)
+      if (s(i:i) == c_null_char) exit
+    end do
+    i = i - 1
+  end function
+
+  function cdiStringError(cdiErrno_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    integer(c_int), value :: cdiErrno_dummy
+    type(c_ptr) :: ptr
+    integer :: rv_shape(1)
+    interface
+      function lib_cdiStringError(cdiErrno_dummy) bind(c, name =&
+      & 'cdiStringError') result(c_result)
+        import c_int, c_ptr
+        type(c_ptr) :: c_result
+        integer(c_int), value :: cdiErrno_dummy
+      end function lib_cdiStringError
+    end interface
+    f_result => null()
+    ptr = lib_cdiStringError(cdiErrno_dummy)
+    if(c_associated(ptr)) then
+      rv_shape(1) = int(lib_strlen(ptr))
+      call c_f_pointer(ptr, f_result, rv_shape)
+    end if
+  end function cdiStringError
+
+  function cdiLibraryVersion() result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    type(c_ptr) :: ptr
+    integer :: rv_shape(1)
+    interface
+      function lib_cdiLibraryVersion() bind(c, name = 'cdiLibraryVersion')&
+      & result(c_result)
+        import c_ptr
+        type(c_ptr) :: c_result
+      end function lib_cdiLibraryVersion
+    end interface
+    f_result => null()
+    ptr = lib_cdiLibraryVersion()
+    if(c_associated(ptr)) then
+      rv_shape(1) = int(lib_strlen(ptr))
+      call c_f_pointer(ptr, f_result, rv_shape)
+    end if
+  end function cdiLibraryVersion
+
+  subroutine cdiDefGlobal(string_dummy, val_dummy)
+    character(kind = c_char, len = *), intent(in) :: string_dummy
+    integer(c_int), value :: val_dummy
+    character(kind = c_char) :: string_temp(len(string_dummy) + 1)
+    integer :: string_i
+    interface
+      subroutine lib_cdiDefGlobal(string_dummy, val_dummy) bind(c, name =&
+      & 'cdiDefGlobal')
+        import c_char, c_int
+        character(kind = c_char) :: string_dummy(*)
+        integer(c_int), value :: val_dummy
+      end subroutine lib_cdiDefGlobal
+    end interface
+    do string_i = 1, len(string_dummy)
+      string_temp(string_i) = string_dummy(string_i:string_i)
+    end do
+    string_temp(len(string_dummy) + 1) = c_null_char
+    call lib_cdiDefGlobal(string_temp, val_dummy)
+  end subroutine cdiDefGlobal
+
+  subroutine cdiParamToString(param_dummy, paramstr_dummy, maxlen_dummy)
+    integer(c_int), value :: param_dummy
+    character(kind = c_char, len = *), intent(inout) :: paramstr_dummy
+    integer(c_int), value :: maxlen_dummy
+    character(kind = c_char) :: paramstr_temp(len(paramstr_dummy) + 1)
+    integer :: paramstr_i
+    interface
+      subroutine lib_cdiParamToString(param_dummy, paramstr_dummy,&
+      & maxlen_dummy) bind(c, name = 'cdiParamToString')
+        import c_char, c_int
+        integer(c_int), value :: param_dummy
+        character(kind = c_char) :: paramstr_dummy(*)
+        integer(c_int), value :: maxlen_dummy
+      end subroutine lib_cdiParamToString
+    end interface
+    paramstr_temp(len(paramstr_dummy) + 1) = c_null_char
+    do paramstr_i = len(paramstr_dummy), 1, -1
+      if(paramstr_dummy(paramstr_i:paramstr_i) /= ' ') exit
+      paramstr_temp(paramstr_i) = c_null_char
+    end do
+    do paramstr_i = paramstr_i, 1, -1
+        paramstr_temp(paramstr_i) = paramstr_dummy(paramstr_i:paramstr_i)
+    end do
+    call lib_cdiParamToString(param_dummy, paramstr_temp, maxlen_dummy)
+    do paramstr_i = 1, len(paramstr_dummy)
+      if(paramstr_temp(paramstr_i) == c_null_char) exit
+      paramstr_dummy(paramstr_i:paramstr_i) = paramstr_temp(paramstr_i)
+    end do
+    do paramstr_i = paramstr_i, len(paramstr_dummy)
+      paramstr_dummy(paramstr_i:paramstr_i) = ' '
+    end do
+  end subroutine cdiParamToString
+
+  function cdiGetFiletype(path_dummy, byteorder_dummy) result(f_result)
+    integer(c_int) :: f_result
+    character(kind = c_char, len = *), intent(in) :: path_dummy
+    integer(c_int), intent(inout) :: byteorder_dummy
+    character(kind = c_char) :: path_temp(len(path_dummy) + 1)
+    integer :: path_i
+    interface
+      function lib_cdiGetFiletype(path_dummy, byteorder_dummy) bind(c, name =&
+      & 'cdiGetFiletype') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        character(kind = c_char) :: path_dummy(*)
+        integer(c_int), intent(inout) :: byteorder_dummy
+      end function lib_cdiGetFiletype
+    end interface
+    do path_i = 1, len(path_dummy)
+      path_temp(path_i) = path_dummy(path_i:path_i)
+    end do
+    path_temp(len(path_dummy) + 1) = c_null_char
+    f_result = lib_cdiGetFiletype(path_temp, byteorder_dummy)
+  end function cdiGetFiletype
+
+  function streamOpenRead(path_dummy) result(f_result)
+    integer(c_int) :: f_result
+    character(kind = c_char, len = *), intent(in) :: path_dummy
+    character(kind = c_char) :: path_temp(len(path_dummy) + 1)
+    integer :: path_i
+    interface
+      function lib_streamOpenRead(path_dummy) bind(c, name = 'streamOpenRead')&
+      & result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        character(kind = c_char) :: path_dummy(*)
+      end function lib_streamOpenRead
+    end interface
+    do path_i = 1, len(path_dummy)
+      path_temp(path_i) = path_dummy(path_i:path_i)
+    end do
+    path_temp(len(path_dummy) + 1) = c_null_char
+    f_result = lib_streamOpenRead(path_temp)
+  end function streamOpenRead
+
+  function streamOpenWrite(path_dummy, filetype_dummy) result(f_result)
+    integer(c_int) :: f_result
+    character(kind = c_char, len = *), intent(in) :: path_dummy
+    integer(c_int), value :: filetype_dummy
+    character(kind = c_char) :: path_temp(len(path_dummy) + 1)
+    integer :: path_i
+    interface
+      function lib_streamOpenWrite(path_dummy, filetype_dummy) bind(c, name =&
+      & 'streamOpenWrite') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        character(kind = c_char) :: path_dummy(*)
+        integer(c_int), value :: filetype_dummy
+      end function lib_streamOpenWrite
+    end interface
+    do path_i = 1, len(path_dummy)
+      path_temp(path_i) = path_dummy(path_i:path_i)
+    end do
+    path_temp(len(path_dummy) + 1) = c_null_char
+    f_result = lib_streamOpenWrite(path_temp, filetype_dummy)
+  end function streamOpenWrite
+
+  function streamOpenAppend(path_dummy) result(f_result)
+    integer(c_int) :: f_result
+    character(kind = c_char, len = *), intent(in) :: path_dummy
+    character(kind = c_char) :: path_temp(len(path_dummy) + 1)
+    integer :: path_i
+    interface
+      function lib_streamOpenAppend(path_dummy) bind(c, name =&
+      & 'streamOpenAppend') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        character(kind = c_char) :: path_dummy(*)
+      end function lib_streamOpenAppend
+    end interface
+    do path_i = 1, len(path_dummy)
+      path_temp(path_i) = path_dummy(path_i:path_i)
+    end do
+    path_temp(len(path_dummy) + 1) = c_null_char
+    f_result = lib_streamOpenAppend(path_temp)
+  end function streamOpenAppend
+
+  function streamFilename(streamID_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    integer(c_int), value :: streamID_dummy
+    type(c_ptr) :: ptr
+    integer :: rv_shape(1)
+    interface
+      function lib_streamFilename(streamID_dummy) bind(c, name =&
+      & 'streamFilename') result(c_result)
+        import c_int, c_ptr
+        type(c_ptr) :: c_result
+        integer(c_int), value :: streamID_dummy
+      end function lib_streamFilename
+    end interface
+    f_result => null()
+    ptr = lib_streamFilename(streamID_dummy)
+    if(c_associated(ptr)) then
+      rv_shape(1) = int(lib_strlen(ptr))
+      call c_f_pointer(ptr, f_result, rv_shape)
+    end if
+  end function streamFilename
+
+  function streamFilesuffix(filetype_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    integer(c_int), value :: filetype_dummy
+    type(c_ptr) :: ptr
+    integer :: rv_shape(1)
+    interface
+      function lib_streamFilesuffix(filetype_dummy) bind(c, name =&
+      & 'streamFilesuffix') result(c_result)
+        import c_int, c_ptr
+        type(c_ptr) :: c_result
+        integer(c_int), value :: filetype_dummy
+      end function lib_streamFilesuffix
+    end interface
+    f_result => null()
+    ptr = lib_streamFilesuffix(filetype_dummy)
+    if(c_associated(ptr)) then
+      rv_shape(1) = int(lib_strlen(ptr))
+      call c_f_pointer(ptr, f_result, rv_shape)
+    end if
+  end function streamFilesuffix
+
+  function cdiIterator_new(path_dummy) result(f_result)
+    type(t_CdiIterator) :: f_result
+    character(kind = c_char, len = *), intent(in) :: path_dummy
+    character(kind = c_char) :: path_temp(len(path_dummy) + 1)
+    integer :: path_i
+    interface
+      function lib_cdiIterator_new(path_dummy) bind(c, name =&
+      & 'cdiIterator_new') result(c_result)
+        import c_char, c_ptr
+        type(c_ptr) :: c_result
+        character(kind = c_char) :: path_dummy(*)
+      end function lib_cdiIterator_new
+    end interface
+    do path_i = 1, len(path_dummy)
+      path_temp(path_i) = path_dummy(path_i:path_i)
+    end do
+    path_temp(len(path_dummy) + 1) = c_null_char
+    f_result%ptr = lib_cdiIterator_new(path_temp)
+  end function cdiIterator_new
+
+  function cdiIterator_clone(me_dummy) result(f_result)
+    type(t_CdiIterator) :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    interface
+      function lib_cdiIterator_clone(me_dummy) bind(c, name =&
+      & 'cdiIterator_clone') result(c_result)
+        import c_ptr
+        type(c_ptr) :: c_result
+        type(c_ptr), value :: me_dummy
+      end function lib_cdiIterator_clone
+    end interface
+    f_result%ptr = lib_cdiIterator_clone(me_dummy%ptr)
+  end function cdiIterator_clone
+
+  function cdiIterator_serialize(me_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    type(c_ptr) :: cString
+    integer :: rv_shape(1)
+    character(kind = c_char), dimension(:), pointer :: temp
+    interface
+      function lib_cdiIterator_serialize(me_dummy) bind(c, name =&
+      & 'cdiIterator_serialize') result(c_result)
+        import c_ptr
+        type(c_ptr) :: c_result
+        type(c_ptr), value :: me_dummy
+      end function lib_cdiIterator_serialize
+    end interface
+    cString = lib_cdiIterator_serialize(me_dummy%ptr)
+    if(c_associated(cString)) then
+      rv_shape(1) = int(lib_strlen(cString))
+      call c_f_pointer(cString, temp, rv_shape)
+      allocate(f_result(rv_shape(1)))
+      f_result = temp
+      call lib_free(cString)
+    else
+      f_result => null()
+    end if
+  end function cdiIterator_serialize
+
+  function cdiIterator_deserialize(description_dummy) result(f_result)
+    type(t_CdiIterator) :: f_result
+    character(kind = c_char, len = *), intent(in) :: description_dummy
+    character(kind = c_char) :: description_temp(len(description_dummy) + 1)
+    integer :: description_i
+    interface
+      function lib_cdiIterator_deserialize(description_dummy) bind(c, name =&
+      & 'cdiIterator_deserialize') result(c_result)
+        import c_char, c_ptr
+        type(c_ptr) :: c_result
+        character(kind = c_char) :: description_dummy(*)
+      end function lib_cdiIterator_deserialize
+    end interface
+    do description_i = 1, len(description_dummy)
+      description_temp(description_i) =&
+      & description_dummy(description_i:description_i)
+    end do
+    description_temp(len(description_dummy) + 1) = c_null_char
+    f_result%ptr = lib_cdiIterator_deserialize(description_temp)
+  end function cdiIterator_deserialize
+
+  subroutine cdiIterator_delete(me_dummy)
+    type(t_CdiIterator), intent(in) :: me_dummy
+    interface
+      subroutine lib_cdiIterator_delete(me_dummy) bind(c, name =&
+      & 'cdiIterator_delete')
+        import c_ptr
+        type(c_ptr), value :: me_dummy
+      end subroutine lib_cdiIterator_delete
+    end interface
+    call lib_cdiIterator_delete(me_dummy%ptr)
+  end subroutine cdiIterator_delete
+
+  function cdiIterator_nextField(me_dummy) result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    interface
+      function lib_cdiIterator_nextField(me_dummy) bind(c, name =&
+      & 'cdiIterator_nextField') result(c_result)
+        import c_int, c_ptr
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+      end function lib_cdiIterator_nextField
+    end interface
+    f_result = lib_cdiIterator_nextField(me_dummy%ptr)
+  end function cdiIterator_nextField
+
+  function cdiIterator_inqStartTime(me_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    type(c_ptr) :: cString
+    integer :: rv_shape(1)
+    character(kind = c_char), dimension(:), pointer :: temp
+    interface
+      function lib_cdiIterator_inqStartTime(me_dummy) bind(c, name =&
+      & 'cdiIterator_inqStartTime') result(c_result)
+        import c_ptr
+        type(c_ptr) :: c_result
+        type(c_ptr), value :: me_dummy
+      end function lib_cdiIterator_inqStartTime
+    end interface
+    cString = lib_cdiIterator_inqStartTime(me_dummy%ptr)
+    if(c_associated(cString)) then
+      rv_shape(1) = int(lib_strlen(cString))
+      call c_f_pointer(cString, temp, rv_shape)
+      allocate(f_result(rv_shape(1)))
+      f_result = temp
+      call lib_free(cString)
+    else
+      f_result => null()
+    end if
+  end function cdiIterator_inqStartTime
+
+  function cdiIterator_inqEndTime(me_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    type(c_ptr) :: cString
+    integer :: rv_shape(1)
+    character(kind = c_char), dimension(:), pointer :: temp
+    interface
+      function lib_cdiIterator_inqEndTime(me_dummy) bind(c, name =&
+      & 'cdiIterator_inqEndTime') result(c_result)
+        import c_ptr
+        type(c_ptr) :: c_result
+        type(c_ptr), value :: me_dummy
+      end function lib_cdiIterator_inqEndTime
+    end interface
+    cString = lib_cdiIterator_inqEndTime(me_dummy%ptr)
+    if(c_associated(cString)) then
+      rv_shape(1) = int(lib_strlen(cString))
+      call c_f_pointer(cString, temp, rv_shape)
+      allocate(f_result(rv_shape(1)))
+      f_result = temp
+      call lib_free(cString)
+    else
+      f_result => null()
+    end if
+  end function cdiIterator_inqEndTime
+
+  function cdiIterator_inqVTime(me_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    type(c_ptr) :: cString
+    integer :: rv_shape(1)
+    character(kind = c_char), dimension(:), pointer :: temp
+    interface
+      function lib_cdiIterator_inqVTime(me_dummy) bind(c, name =&
+      & 'cdiIterator_inqVTime') result(c_result)
+        import c_ptr
+        type(c_ptr) :: c_result
+        type(c_ptr), value :: me_dummy
+      end function lib_cdiIterator_inqVTime
+    end interface
+    cString = lib_cdiIterator_inqVTime(me_dummy%ptr)
+    if(c_associated(cString)) then
+      rv_shape(1) = int(lib_strlen(cString))
+      call c_f_pointer(cString, temp, rv_shape)
+      allocate(f_result(rv_shape(1)))
+      f_result = temp
+      call lib_free(cString)
+    else
+      f_result => null()
+    end if
+  end function cdiIterator_inqVTime
+
+  function cdiIterator_inqLevelType(me_dummy, levelSelector_dummy, outName,&
+  & outLongName, outStdName, outUnit) result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    integer(c_int), value :: levelSelector_dummy
+    character(kind = c_char), pointer, optional, intent(inout) :: outName(:)
+    character(kind = c_char), pointer, optional, intent(inout) ::&
+    & outLongName(:)
+    character(kind = c_char), pointer, optional, intent(inout) :: outStdName(:)
+    character(kind = c_char), pointer, optional, intent(inout) :: outUnit(:)
+    type(c_ptr), target :: outName_cptr
+    type(c_ptr) :: outName_handle
+    integer :: outName_shape(1)
+    character(kind = c_char), pointer :: outName_fptr(:)
+    type(c_ptr), target :: outLongName_cptr
+    type(c_ptr) :: outLongName_handle
+    integer :: outLongName_shape(1)
+    character(kind = c_char), pointer :: outLongName_fptr(:)
+    type(c_ptr), target :: outStdName_cptr
+    type(c_ptr) :: outStdName_handle
+    integer :: outStdName_shape(1)
+    character(kind = c_char), pointer :: outStdName_fptr(:)
+    type(c_ptr), target :: outUnit_cptr
+    type(c_ptr) :: outUnit_handle
+    integer :: outUnit_shape(1)
+    character(kind = c_char), pointer :: outUnit_fptr(:)
+    interface
+      function lib_cdiIterator_inqLevelType(me_dummy, levelSelector_dummy,&
+      & outName, outLongName, outStdName, outUnit) bind(c, name =&
+      & 'cdiIterator_inqLevelType') result(c_result)
+        import c_int, c_ptr
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+        integer(c_int), value :: levelSelector_dummy
+        type(c_ptr), value :: outName
+        type(c_ptr), value :: outLongName
+        type(c_ptr), value :: outStdName
+        type(c_ptr), value :: outUnit
+      end function lib_cdiIterator_inqLevelType
+    end interface
+    outName_handle = c_null_ptr
+    if(present(outName)) outName_handle = c_loc(outName_cptr)
+    outLongName_handle = c_null_ptr
+    if(present(outLongName)) outLongName_handle = c_loc(outLongName_cptr)
+    outStdName_handle = c_null_ptr
+    if(present(outStdName)) outStdName_handle = c_loc(outStdName_cptr)
+    outUnit_handle = c_null_ptr
+    if(present(outUnit)) outUnit_handle = c_loc(outUnit_cptr)
+    f_result = lib_cdiIterator_inqLevelType(me_dummy%ptr, levelSelector_dummy,&
+    & outName_handle, outLongName_handle, outStdName_handle, outUnit_handle)
+    if(present(outName)) then
+      if(c_associated(outName_cptr)) then
+        outName_shape(1) = int(lib_strlen(outName_cptr))
+        call c_f_pointer(outName_cptr, outName_fptr, outName_shape)
+        allocate(outName(outName_shape(1)))
+        outName = outName_fptr
+        call lib_free(outName_cptr)
+      else
+        outName => null()
+      end if
+    end if
+    if(present(outLongName)) then
+      if(c_associated(outLongName_cptr)) then
+        outLongName_shape(1) = int(lib_strlen(outLongName_cptr))
+        call c_f_pointer(outLongName_cptr, outLongName_fptr, outLongName_shape)
+        allocate(outLongName(outLongName_shape(1)))
+        outLongName = outLongName_fptr
+        call lib_free(outLongName_cptr)
+      else
+        outLongName => null()
+      end if
+    end if
+    if(present(outStdName)) then
+      if(c_associated(outStdName_cptr)) then
+        outStdName_shape(1) = int(lib_strlen(outStdName_cptr))
+        call c_f_pointer(outStdName_cptr, outStdName_fptr, outStdName_shape)
+        allocate(outStdName(outStdName_shape(1)))
+        outStdName = outStdName_fptr
+        call lib_free(outStdName_cptr)
+      else
+        outStdName => null()
+      end if
+    end if
+    if(present(outUnit)) then
+      if(c_associated(outUnit_cptr)) then
+        outUnit_shape(1) = int(lib_strlen(outUnit_cptr))
+        call c_f_pointer(outUnit_cptr, outUnit_fptr, outUnit_shape)
+        allocate(outUnit(outUnit_shape(1)))
+        outUnit = outUnit_fptr
+        call lib_free(outUnit_cptr)
+      else
+        outUnit => null()
+      end if
+    end if
+  end function cdiIterator_inqLevelType
+
+  function cdiIterator_inqLevel(me_dummy, levelSelector_dummy, outValue1,&
+  & outValue2) result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    integer(c_int), value :: levelSelector_dummy
+    real(c_double), target, optional, intent(inout) :: outValue1
+    real(c_double), target, optional, intent(inout) :: outValue2
+    type(c_ptr) :: outValue1_cptr
+    type(c_ptr) :: outValue2_cptr
+    interface
+      function lib_cdiIterator_inqLevel(me_dummy, levelSelector_dummy,&
+      & outValue1, outValue2) bind(c, name = 'cdiIterator_inqLevel')&
+      & result(c_result)
+        import c_int, c_ptr
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+        integer(c_int), value :: levelSelector_dummy
+        type(c_ptr), value :: outValue1
+        type(c_ptr), value :: outValue2
+      end function lib_cdiIterator_inqLevel
+    end interface
+    outValue1_cptr = c_null_ptr
+    if(present(outValue1)) outValue1_cptr = c_loc(outValue1)
+    outValue2_cptr = c_null_ptr
+    if(present(outValue2)) outValue2_cptr = c_loc(outValue2)
+    f_result = lib_cdiIterator_inqLevel(me_dummy%ptr, levelSelector_dummy,&
+    & outValue1_cptr, outValue2_cptr)
+  end function cdiIterator_inqLevel
+
+  function cdiIterator_inqLevelUuid(me_dummy, outVgridNumber, outLevelCount,&
+  & outUuid) result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    integer(c_int), optional, target, intent(inout) :: outVgridNumber
+    integer(c_int), optional, target, intent(inout) :: outLevelCount
+    integer(kind = c_signed_char), target, optional, intent(inout) ::&
+    & outUuid(CDI_UUID_SIZE)
+    type(c_ptr) :: outVgridNumber_cptr
+    type(c_ptr) :: outLevelCount_cptr
+    type(c_ptr) :: outUuid_cptr
+    interface
+      function lib_cdiIterator_inqLevelUuid(me_dummy, outVgridNumber,&
+      & outLevelCount, outUuid) bind(c, name = 'cdiIterator_inqLevelUuid')&
+      & result(c_result)
+        import c_int, c_ptr
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+        type(c_ptr), value :: outVgridNumber
+        type(c_ptr), value :: outLevelCount
+        type(c_ptr), value :: outUuid
+      end function lib_cdiIterator_inqLevelUuid
+    end interface
+    outVgridNumber_cptr = c_null_ptr
+    if(present(outVgridNumber)) outVgridNumber_cptr = c_loc(outVgridNumber)
+    outLevelCount_cptr = c_null_ptr
+    if(present(outLevelCount)) outLevelCount_cptr = c_loc(outLevelCount)
+    outUuid_cptr = c_null_ptr
+    if(present(outUuid)) outUuid_cptr = c_loc(outUuid)
+    f_result = lib_cdiIterator_inqLevelUuid(me_dummy%ptr, outVgridNumber_cptr,&
+    & outLevelCount_cptr, outUuid_cptr)
+  end function cdiIterator_inqLevelUuid
+
+  function cdiIterator_inqParam(me_dummy) result(f_result)
+    type(t_CdiParam) :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    interface
+      function lib_cdiIterator_inqParam(me_dummy) bind(c, name =&
+      & 'cdiIterator_inqParam') result(c_result)
+        import c_ptr, t_CdiParam
+        type(t_CdiParam) :: c_result
+        type(c_ptr), value :: me_dummy
+      end function lib_cdiIterator_inqParam
+    end interface
+    f_result = lib_cdiIterator_inqParam(me_dummy%ptr)
+  end function cdiIterator_inqParam
+
+  function cdiIterator_inqDatatype(me_dummy) result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    interface
+      function lib_cdiIterator_inqDatatype(me_dummy) bind(c, name =&
+      & 'cdiIterator_inqDatatype') result(c_result)
+        import c_int, c_ptr
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+      end function lib_cdiIterator_inqDatatype
+    end interface
+    f_result = lib_cdiIterator_inqDatatype(me_dummy%ptr)
+  end function cdiIterator_inqDatatype
+
+  function cdiIterator_inqTsteptype(me_dummy) result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    interface
+      function lib_cdiIterator_inqTsteptype(me_dummy) bind(c, name =&
+      & 'cdiIterator_inqTsteptype') result(c_result)
+        import c_int, c_ptr
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+      end function lib_cdiIterator_inqTsteptype
+    end interface
+    f_result = lib_cdiIterator_inqTsteptype(me_dummy%ptr)
+  end function cdiIterator_inqTsteptype
+
+  function cdiIterator_inqVariableName(me_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    type(c_ptr) :: cString
+    integer :: rv_shape(1)
+    character(kind = c_char), dimension(:), pointer :: temp
+    interface
+      function lib_cdiIterator_inqVariableName(me_dummy) bind(c, name =&
+      & 'cdiIterator_inqVariableName') result(c_result)
+        import c_ptr
+        type(c_ptr) :: c_result
+        type(c_ptr), value :: me_dummy
+      end function lib_cdiIterator_inqVariableName
+    end interface
+    cString = lib_cdiIterator_inqVariableName(me_dummy%ptr)
+    if(c_associated(cString)) then
+      rv_shape(1) = int(lib_strlen(cString))
+      call c_f_pointer(cString, temp, rv_shape)
+      allocate(f_result(rv_shape(1)))
+      f_result = temp
+      call lib_free(cString)
+    else
+      f_result => null()
+    end if
+  end function cdiIterator_inqVariableName
+
+  function cdiIterator_inqGridId(me_dummy) result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    interface
+      function lib_cdiIterator_inqGridId(me_dummy) bind(c, name =&
+      & 'cdiIterator_inqGridId') result(c_result)
+        import c_int, c_ptr
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+      end function lib_cdiIterator_inqGridId
+    end interface
+    f_result = lib_cdiIterator_inqGridId(me_dummy%ptr)
+  end function cdiIterator_inqGridId
+
+  subroutine cdiIterator_readField(me_dummy, data_dummy, nmiss)
+    type(t_CdiIterator), intent(in) :: me_dummy
+    real(c_double), intent(inout) :: data_dummy(*)
+    integer(c_size_t), optional, target, intent(inout) :: nmiss
+    type(c_ptr) :: nmiss_cptr
+    interface
+      subroutine lib_cdiIterator_readField(me_dummy, data_dummy, nmiss) bind(c,&
+      & name = 'cdiIterator_readField')
+        import c_double, c_ptr
+        type(c_ptr), value :: me_dummy
+        real(c_double), intent(inout) :: data_dummy(*)
+        type(c_ptr), value :: nmiss
+      end subroutine lib_cdiIterator_readField
+    end interface
+    nmiss_cptr = c_null_ptr
+    if(present(nmiss)) nmiss_cptr = c_loc(nmiss)
+    call lib_cdiIterator_readField(me_dummy%ptr, data_dummy, nmiss_cptr)
+  end subroutine cdiIterator_readField
+
+  subroutine cdiIterator_readFieldF(me_dummy, data_dummy, nmiss)
+    type(t_CdiIterator), intent(in) :: me_dummy
+    real(c_float), intent(inout) :: data_dummy(*)
+    integer(c_size_t), optional, target, intent(inout) :: nmiss
+    type(c_ptr) :: nmiss_cptr
+    interface
+      subroutine lib_cdiIterator_readFieldF(me_dummy, data_dummy, nmiss)&
+      & bind(c, name = 'cdiIterator_readFieldF')
+        import c_float, c_ptr
+        type(c_ptr), value :: me_dummy
+        real(c_float), intent(inout) :: data_dummy(*)
+        type(c_ptr), value :: nmiss
+      end subroutine lib_cdiIterator_readFieldF
+    end interface
+    nmiss_cptr = c_null_ptr
+    if(present(nmiss)) nmiss_cptr = c_loc(nmiss)
+    call lib_cdiIterator_readFieldF(me_dummy%ptr, data_dummy, nmiss_cptr)
+  end subroutine cdiIterator_readFieldF
+
+  function cdiGribIterator_clone(me_dummy) result(f_result)
+    type(t_CdiGribIterator) :: f_result
+    type(t_CdiIterator), intent(in) :: me_dummy
+    interface
+      function lib_cdiGribIterator_clone(me_dummy) bind(c, name =&
+      & 'cdiGribIterator_clone') result(c_result)
+        import c_ptr
+        type(c_ptr) :: c_result
+        type(c_ptr), value :: me_dummy
+      end function lib_cdiGribIterator_clone
+    end interface
+    f_result%ptr = lib_cdiGribIterator_clone(me_dummy%ptr)
+  end function cdiGribIterator_clone
+
+  subroutine cdiGribIterator_delete(me_dummy)
+    type(t_CdiGribIterator), intent(in) :: me_dummy
+    interface
+      subroutine lib_cdiGribIterator_delete(me_dummy) bind(c, name =&
+      & 'cdiGribIterator_delete')
+        import c_ptr
+        type(c_ptr), value :: me_dummy
+      end subroutine lib_cdiGribIterator_delete
+    end interface
+    call lib_cdiGribIterator_delete(me_dummy%ptr)
+  end subroutine cdiGribIterator_delete
+
+  function cdiGribIterator_getLong(me_dummy, key_dummy, value_dummy)&
+  & result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiGribIterator), intent(in) :: me_dummy
+    character(kind = c_char, len = *), intent(in) :: key_dummy
+    integer(c_long), intent(inout) :: value_dummy
+    character(kind = c_char) :: key_temp(len(key_dummy) + 1)
+    integer :: key_i
+    interface
+      function lib_cdiGribIterator_getLong(me_dummy, key_dummy, value_dummy)&
+      & bind(c, name = 'cdiGribIterator_getLong') result(c_result)
+        import c_char, c_int, c_long, c_ptr
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+        character(kind = c_char) :: key_dummy(*)
+        integer(c_long), intent(inout) :: value_dummy
+      end function lib_cdiGribIterator_getLong
+    end interface
+    do key_i = 1, len(key_dummy)
+      key_temp(key_i) = key_dummy(key_i:key_i)
+    end do
+    key_temp(len(key_dummy) + 1) = c_null_char
+    f_result = lib_cdiGribIterator_getLong(me_dummy%ptr, key_temp, value_dummy)
+  end function cdiGribIterator_getLong
+
+  function cdiGribIterator_getDouble(me_dummy, key_dummy, value_dummy)&
+  & result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiGribIterator), intent(in) :: me_dummy
+    character(kind = c_char, len = *), intent(in) :: key_dummy
+    real(c_double), intent(inout) :: value_dummy
+    character(kind = c_char) :: key_temp(len(key_dummy) + 1)
+    integer :: key_i
+    interface
+      function lib_cdiGribIterator_getDouble(me_dummy, key_dummy, value_dummy)&
+      & bind(c, name = 'cdiGribIterator_getDouble') result(c_result)
+        import c_char, c_double, c_int, c_ptr
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+        character(kind = c_char) :: key_dummy(*)
+        real(c_double), intent(inout) :: value_dummy
+      end function lib_cdiGribIterator_getDouble
+    end interface
+    do key_i = 1, len(key_dummy)
+      key_temp(key_i) = key_dummy(key_i:key_i)
+    end do
+    key_temp(len(key_dummy) + 1) = c_null_char
+    f_result = lib_cdiGribIterator_getDouble(me_dummy%ptr, key_temp,&
+    & value_dummy)
+  end function cdiGribIterator_getDouble
+
+  function cdiGribIterator_getLength(me_dummy, key_dummy, value_dummy)&
+  & result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiGribIterator), intent(in) :: me_dummy
+    character(kind = c_char, len = *), intent(in) :: key_dummy
+    integer(c_size_t), intent(inout) :: value_dummy
+    character(kind = c_char) :: key_temp(len(key_dummy) + 1)
+    integer :: key_i
+    interface
+      function lib_cdiGribIterator_getLength(me_dummy, key_dummy, value_dummy)&
+      & bind(c, name = 'cdiGribIterator_getLength') result(c_result)
+        import c_char, c_int, c_ptr, c_size_t
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+        character(kind = c_char) :: key_dummy(*)
+        integer(c_size_t), intent(inout) :: value_dummy
+      end function lib_cdiGribIterator_getLength
+    end interface
+    do key_i = 1, len(key_dummy)
+      key_temp(key_i) = key_dummy(key_i:key_i)
+    end do
+    key_temp(len(key_dummy) + 1) = c_null_char
+    f_result = lib_cdiGribIterator_getLength(me_dummy%ptr, key_temp,&
+    & value_dummy)
+  end function cdiGribIterator_getLength
+
+  function cdiGribIterator_getString(me_dummy, key_dummy, value_dummy,&
+  & length_dummy) result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiGribIterator), intent(in) :: me_dummy
+    character(kind = c_char, len = *), intent(in) :: key_dummy
+    character(kind = c_char, len = *), intent(inout) :: value_dummy
+    integer(c_size_t), intent(inout) :: length_dummy
+    character(kind = c_char) :: key_temp(len(key_dummy) + 1)
+    integer :: key_i
+    character(kind = c_char) :: value_temp(len(value_dummy) + 1)
+    integer :: value_i
+    interface
+      function lib_cdiGribIterator_getString(me_dummy, key_dummy, value_dummy,&
+      & length_dummy) bind(c, name = 'cdiGribIterator_getString')&
+      & result(c_result)
+        import c_char, c_int, c_ptr, c_size_t
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+        character(kind = c_char) :: key_dummy(*)
+        character(kind = c_char) :: value_dummy(*)
+        integer(c_size_t), intent(inout) :: length_dummy
+      end function lib_cdiGribIterator_getString
+    end interface
+    do key_i = 1, len(key_dummy)
+      key_temp(key_i) = key_dummy(key_i:key_i)
+    end do
+    key_temp(len(key_dummy) + 1) = c_null_char
+    value_temp(len(value_dummy) + 1) = c_null_char
+    do value_i = len(value_dummy), 1, -1
+      if(value_dummy(value_i:value_i) /= ' ') exit
+      value_temp(value_i) = c_null_char
+    end do
+    do value_i = value_i, 1, -1
+        value_temp(value_i) = value_dummy(value_i:value_i)
+    end do
+    f_result = lib_cdiGribIterator_getString(me_dummy%ptr, key_temp,&
+    & value_temp, length_dummy)
+    do value_i = 1, len(value_dummy)
+      if(value_temp(value_i) == c_null_char) exit
+      value_dummy(value_i:value_i) = value_temp(value_i)
+    end do
+    do value_i = value_i, len(value_dummy)
+      value_dummy(value_i:value_i) = ' '
+    end do
+  end function cdiGribIterator_getString
+
+  function cdiGribIterator_getSize(me_dummy, key_dummy, value_dummy)&
+  & result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiGribIterator), intent(in) :: me_dummy
+    character(kind = c_char, len = *), intent(in) :: key_dummy
+    integer(c_size_t), intent(inout) :: value_dummy
+    character(kind = c_char) :: key_temp(len(key_dummy) + 1)
+    integer :: key_i
+    interface
+      function lib_cdiGribIterator_getSize(me_dummy, key_dummy, value_dummy)&
+      & bind(c, name = 'cdiGribIterator_getSize') result(c_result)
+        import c_char, c_int, c_ptr, c_size_t
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+        character(kind = c_char) :: key_dummy(*)
+        integer(c_size_t), intent(inout) :: value_dummy
+      end function lib_cdiGribIterator_getSize
+    end interface
+    do key_i = 1, len(key_dummy)
+      key_temp(key_i) = key_dummy(key_i:key_i)
+    end do
+    key_temp(len(key_dummy) + 1) = c_null_char
+    f_result = lib_cdiGribIterator_getSize(me_dummy%ptr, key_temp, value_dummy)
+  end function cdiGribIterator_getSize
+
+  function cdiGribIterator_getLongArray(me_dummy, key_dummy, value_dummy,&
+  & array_size_dummy) result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiGribIterator), intent(in) :: me_dummy
+    character(kind = c_char, len = *), intent(in) :: key_dummy
+    integer(c_long), intent(inout) :: value_dummy
+    integer(c_size_t), intent(inout) :: array_size_dummy
+    character(kind = c_char) :: key_temp(len(key_dummy) + 1)
+    integer :: key_i
+    interface
+      function lib_cdiGribIterator_getLongArray(me_dummy, key_dummy,&
+      & value_dummy, array_size_dummy) bind(c, name =&
+      & 'cdiGribIterator_getLongArray') result(c_result)
+        import c_char, c_int, c_long, c_ptr, c_size_t
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+        character(kind = c_char) :: key_dummy(*)
+        integer(c_long), intent(inout) :: value_dummy
+        integer(c_size_t), intent(inout) :: array_size_dummy
+      end function lib_cdiGribIterator_getLongArray
+    end interface
+    do key_i = 1, len(key_dummy)
+      key_temp(key_i) = key_dummy(key_i:key_i)
+    end do
+    key_temp(len(key_dummy) + 1) = c_null_char
+    f_result = lib_cdiGribIterator_getLongArray(me_dummy%ptr, key_temp,&
+    & value_dummy, array_size_dummy)
+  end function cdiGribIterator_getLongArray
+
+  function cdiGribIterator_getDoubleArray(me_dummy, key_dummy, value_dummy,&
+  & array_size_dummy) result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiGribIterator), intent(in) :: me_dummy
+    character(kind = c_char, len = *), intent(in) :: key_dummy
+    real(c_double), intent(inout) :: value_dummy
+    integer(c_size_t), intent(inout) :: array_size_dummy
+    character(kind = c_char) :: key_temp(len(key_dummy) + 1)
+    integer :: key_i
+    interface
+      function lib_cdiGribIterator_getDoubleArray(me_dummy, key_dummy,&
+      & value_dummy, array_size_dummy) bind(c, name =&
+      & 'cdiGribIterator_getDoubleArray') result(c_result)
+        import c_char, c_double, c_int, c_ptr, c_size_t
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+        character(kind = c_char) :: key_dummy(*)
+        real(c_double), intent(inout) :: value_dummy
+        integer(c_size_t), intent(inout) :: array_size_dummy
+      end function lib_cdiGribIterator_getDoubleArray
+    end interface
+    do key_i = 1, len(key_dummy)
+      key_temp(key_i) = key_dummy(key_i:key_i)
+    end do
+    key_temp(len(key_dummy) + 1) = c_null_char
+    f_result = lib_cdiGribIterator_getDoubleArray(me_dummy%ptr, key_temp,&
+    & value_dummy, array_size_dummy)
+  end function cdiGribIterator_getDoubleArray
+
+  function cdiGribIterator_inqEdition(me_dummy) result(f_result)
+    integer(c_int) :: f_result
+    type(t_CdiGribIterator), intent(in) :: me_dummy
+    interface
+      function lib_cdiGribIterator_inqEdition(me_dummy) bind(c, name =&
+      & 'cdiGribIterator_inqEdition') result(c_result)
+        import c_int, c_ptr
+        integer(c_int) :: c_result
+        type(c_ptr), value :: me_dummy
+      end function lib_cdiGribIterator_inqEdition
+    end interface
+    f_result = lib_cdiGribIterator_inqEdition(me_dummy%ptr)
+  end function cdiGribIterator_inqEdition
+
+  function cdiGribIterator_inqLongValue(me_dummy, key_dummy) result(f_result)
+    integer(c_long) :: f_result
+    type(t_CdiGribIterator), intent(in) :: me_dummy
+    character(kind = c_char, len = *), intent(in) :: key_dummy
+    character(kind = c_char) :: key_temp(len(key_dummy) + 1)
+    integer :: key_i
+    interface
+      function lib_cdiGribIterator_inqLongValue(me_dummy, key_dummy) bind(c,&
+      & name = 'cdiGribIterator_inqLongValue') result(c_result)
+        import c_char, c_long, c_ptr
+        integer(c_long) :: c_result
+        type(c_ptr), value :: me_dummy
+        character(kind = c_char) :: key_dummy(*)
+      end function lib_cdiGribIterator_inqLongValue
+    end interface
+    do key_i = 1, len(key_dummy)
+      key_temp(key_i) = key_dummy(key_i:key_i)
+    end do
+    key_temp(len(key_dummy) + 1) = c_null_char
+    f_result = lib_cdiGribIterator_inqLongValue(me_dummy%ptr, key_temp)
+  end function cdiGribIterator_inqLongValue
+
+  function cdiGribIterator_inqLongDefaultValue(me_dummy, key_dummy,&
+  & defaultValue_dummy) result(f_result)
+    integer(c_long) :: f_result
+    type(t_CdiGribIterator), intent(in) :: me_dummy
+    character(kind = c_char, len = *), intent(in) :: key_dummy
+    integer(c_long), value :: defaultValue_dummy
+    character(kind = c_char) :: key_temp(len(key_dummy) + 1)
+    integer :: key_i
+    interface
+      function lib_cdiGribIterator_inqLongDefaultValue(me_dummy, key_dummy,&
+      & defaultValue_dummy) bind(c, name =&
+      & 'cdiGribIterator_inqLongDefaultValue') result(c_result)
+        import c_char, c_long, c_ptr
+        integer(c_long) :: c_result
+        type(c_ptr), value :: me_dummy
+        character(kind = c_char) :: key_dummy(*)
+        integer(c_long), value :: defaultValue_dummy
+      end function lib_cdiGribIterator_inqLongDefaultValue
+    end interface
+    do key_i = 1, len(key_dummy)
+      key_temp(key_i) = key_dummy(key_i:key_i)
+    end do
+    key_temp(len(key_dummy) + 1) = c_null_char
+    f_result = lib_cdiGribIterator_inqLongDefaultValue(me_dummy%ptr, key_temp,&
+    & defaultValue_dummy)
+  end function cdiGribIterator_inqLongDefaultValue
+
+  function cdiGribIterator_inqDoubleValue(me_dummy, key_dummy) result(f_result)
+    real(c_double) :: f_result
+    type(t_CdiGribIterator), intent(in) :: me_dummy
+    character(kind = c_char, len = *), intent(in) :: key_dummy
+    character(kind = c_char) :: key_temp(len(key_dummy) + 1)
+    integer :: key_i
+    interface
+      function lib_cdiGribIterator_inqDoubleValue(me_dummy, key_dummy) bind(c,&
+      & name = 'cdiGribIterator_inqDoubleValue') result(c_result)
+        import c_char, c_double, c_ptr
+        real(c_double) :: c_result
+        type(c_ptr), value :: me_dummy
+        character(kind = c_char) :: key_dummy(*)
+      end function lib_cdiGribIterator_inqDoubleValue
+    end interface
+    do key_i = 1, len(key_dummy)
+      key_temp(key_i) = key_dummy(key_i:key_i)
+    end do
+    key_temp(len(key_dummy) + 1) = c_null_char
+    f_result = lib_cdiGribIterator_inqDoubleValue(me_dummy%ptr, key_temp)
+  end function cdiGribIterator_inqDoubleValue
+
+  function cdiGribIterator_inqDoubleDefaultValue(me_dummy, key_dummy,&
+  & defaultValue_dummy) result(f_result)
+    real(c_double) :: f_result
+    type(t_CdiGribIterator), intent(in) :: me_dummy
+    character(kind = c_char, len = *), intent(in) :: key_dummy
+    real(c_double), value :: defaultValue_dummy
+    character(kind = c_char) :: key_temp(len(key_dummy) + 1)
+    integer :: key_i
+    interface
+      function lib_cdiGribIterator_inqDoubleDefaultValue(me_dummy, key_dummy,&
+      & defaultValue_dummy) bind(c, name =&
+      & 'cdiGribIterator_inqDoubleDefaultValue') result(c_result)
+        import c_char, c_double, c_ptr
+        real(c_double) :: c_result
+        type(c_ptr), value :: me_dummy
+        character(kind = c_char) :: key_dummy(*)
+        real(c_double), value :: defaultValue_dummy
+      end function lib_cdiGribIterator_inqDoubleDefaultValue
+    end interface
+    do key_i = 1, len(key_dummy)
+      key_temp(key_i) = key_dummy(key_i:key_i)
+    end do
+    key_temp(len(key_dummy) + 1) = c_null_char
+    f_result = lib_cdiGribIterator_inqDoubleDefaultValue(me_dummy%ptr,&
+    & key_temp, defaultValue_dummy)
+  end function cdiGribIterator_inqDoubleDefaultValue
+
+  function cdiGribIterator_inqStringValue(me_dummy, key_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    type(t_CdiGribIterator), intent(in) :: me_dummy
+    character(kind = c_char, len = *), intent(in) :: key_dummy
+    character(kind = c_char) :: key_temp(len(key_dummy) + 1)
+    integer :: key_i
+    type(c_ptr) :: cString
+    integer :: rv_shape(1)
+    character(kind = c_char), dimension(:), pointer :: temp
+    interface
+      function lib_cdiGribIterator_inqStringValue(me_dummy, key_dummy) bind(c,&
+      & name = 'cdiGribIterator_inqStringValue') result(c_result)
+        import c_char, c_ptr
+        type(c_ptr) :: c_result
+        type(c_ptr), value :: me_dummy
+        character(kind = c_char) :: key_dummy(*)
+      end function lib_cdiGribIterator_inqStringValue
+    end interface
+    do key_i = 1, len(key_dummy)
+      key_temp(key_i) = key_dummy(key_i:key_i)
+    end do
+    key_temp(len(key_dummy) + 1) = c_null_char
+    cString = lib_cdiGribIterator_inqStringValue(me_dummy%ptr, key_temp)
+    if(c_associated(cString)) then
+      rv_shape(1) = int(lib_strlen(cString))
+      call c_f_pointer(cString, temp, rv_shape)
+      allocate(f_result(rv_shape(1)))
+      f_result = temp
+      call lib_free(cString)
+    else
+      f_result => null()
+    end if
+  end function cdiGribIterator_inqStringValue
+
+  subroutine vlistDefVarName(vlistID_dummy, varID_dummy, name_dummy)
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      subroutine lib_vlistDefVarName(vlistID_dummy, varID_dummy, name_dummy)&
+      & bind(c, name = 'vlistDefVarName')
+        import c_char, c_int
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: name_dummy(*)
+      end subroutine lib_vlistDefVarName
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    call lib_vlistDefVarName(vlistID_dummy, varID_dummy, name_temp)
+  end subroutine vlistDefVarName
+
+  subroutine vlistInqVarName(vlistID_dummy, varID_dummy, name_dummy)
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(inout) :: name_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      subroutine lib_vlistInqVarName(vlistID_dummy, varID_dummy, name_dummy)&
+      & bind(c, name = 'vlistInqVarName')
+        import c_char, c_int
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: name_dummy(*)
+      end subroutine lib_vlistInqVarName
+    end interface
+    name_temp(len(name_dummy) + 1) = c_null_char
+    do name_i = len(name_dummy), 1, -1
+      if(name_dummy(name_i:name_i) /= ' ') exit
+      name_temp(name_i) = c_null_char
+    end do
+    do name_i = name_i, 1, -1
+        name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    call lib_vlistInqVarName(vlistID_dummy, varID_dummy, name_temp)
+    do name_i = 1, len(name_dummy)
+      if(name_temp(name_i) == c_null_char) exit
+      name_dummy(name_i:name_i) = name_temp(name_i)
+    end do
+    do name_i = name_i, len(name_dummy)
+      name_dummy(name_i:name_i) = ' '
+    end do
+  end subroutine vlistInqVarName
+
+  function vlistCopyVarName(vlistId_dummy, varId_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    integer(c_int), value :: vlistId_dummy
+    integer(c_int), value :: varId_dummy
+    type(c_ptr) :: cString
+    integer :: rv_shape(1)
+    character(kind = c_char), dimension(:), pointer :: temp
+    interface
+      function lib_vlistCopyVarName(vlistId_dummy, varId_dummy) bind(c, name =&
+      & 'vlistCopyVarName') result(c_result)
+        import c_int, c_ptr
+        type(c_ptr) :: c_result
+        integer(c_int), value :: vlistId_dummy
+        integer(c_int), value :: varId_dummy
+      end function lib_vlistCopyVarName
+    end interface
+    cString = lib_vlistCopyVarName(vlistId_dummy, varId_dummy)
+    if(c_associated(cString)) then
+      rv_shape(1) = int(lib_strlen(cString))
+      call c_f_pointer(cString, temp, rv_shape)
+      allocate(f_result(rv_shape(1)))
+      f_result = temp
+      call lib_free(cString)
+    else
+      f_result => null()
+    end if
+  end function vlistCopyVarName
+
+  subroutine vlistDefVarStdname(vlistID_dummy, varID_dummy, stdname_dummy)
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: stdname_dummy
+    character(kind = c_char) :: stdname_temp(len(stdname_dummy) + 1)
+    integer :: stdname_i
+    interface
+      subroutine lib_vlistDefVarStdname(vlistID_dummy, varID_dummy,&
+      & stdname_dummy) bind(c, name = 'vlistDefVarStdname')
+        import c_char, c_int
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: stdname_dummy(*)
+      end subroutine lib_vlistDefVarStdname
+    end interface
+    do stdname_i = 1, len(stdname_dummy)
+      stdname_temp(stdname_i) = stdname_dummy(stdname_i:stdname_i)
+    end do
+    stdname_temp(len(stdname_dummy) + 1) = c_null_char
+    call lib_vlistDefVarStdname(vlistID_dummy, varID_dummy, stdname_temp)
+  end subroutine vlistDefVarStdname
+
+  subroutine vlistInqVarStdname(vlistID_dummy, varID_dummy, stdname_dummy)
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(inout) :: stdname_dummy
+    character(kind = c_char) :: stdname_temp(len(stdname_dummy) + 1)
+    integer :: stdname_i
+    interface
+      subroutine lib_vlistInqVarStdname(vlistID_dummy, varID_dummy,&
+      & stdname_dummy) bind(c, name = 'vlistInqVarStdname')
+        import c_char, c_int
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: stdname_dummy(*)
+      end subroutine lib_vlistInqVarStdname
+    end interface
+    stdname_temp(len(stdname_dummy) + 1) = c_null_char
+    do stdname_i = len(stdname_dummy), 1, -1
+      if(stdname_dummy(stdname_i:stdname_i) /= ' ') exit
+      stdname_temp(stdname_i) = c_null_char
+    end do
+    do stdname_i = stdname_i, 1, -1
+        stdname_temp(stdname_i) = stdname_dummy(stdname_i:stdname_i)
+    end do
+    call lib_vlistInqVarStdname(vlistID_dummy, varID_dummy, stdname_temp)
+    do stdname_i = 1, len(stdname_dummy)
+      if(stdname_temp(stdname_i) == c_null_char) exit
+      stdname_dummy(stdname_i:stdname_i) = stdname_temp(stdname_i)
+    end do
+    do stdname_i = stdname_i, len(stdname_dummy)
+      stdname_dummy(stdname_i:stdname_i) = ' '
+    end do
+  end subroutine vlistInqVarStdname
+
+  subroutine vlistDefVarLongname(vlistID_dummy, varID_dummy, longname_dummy)
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: longname_dummy
+    character(kind = c_char) :: longname_temp(len(longname_dummy) + 1)
+    integer :: longname_i
+    interface
+      subroutine lib_vlistDefVarLongname(vlistID_dummy, varID_dummy,&
+      & longname_dummy) bind(c, name = 'vlistDefVarLongname')
+        import c_char, c_int
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: longname_dummy(*)
+      end subroutine lib_vlistDefVarLongname
+    end interface
+    do longname_i = 1, len(longname_dummy)
+      longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
+    end do
+    longname_temp(len(longname_dummy) + 1) = c_null_char
+    call lib_vlistDefVarLongname(vlistID_dummy, varID_dummy, longname_temp)
+  end subroutine vlistDefVarLongname
+
+  subroutine vlistInqVarLongname(vlistID_dummy, varID_dummy, longname_dummy)
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(inout) :: longname_dummy
+    character(kind = c_char) :: longname_temp(len(longname_dummy) + 1)
+    integer :: longname_i
+    interface
+      subroutine lib_vlistInqVarLongname(vlistID_dummy, varID_dummy,&
+      & longname_dummy) bind(c, name = 'vlistInqVarLongname')
+        import c_char, c_int
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: longname_dummy(*)
+      end subroutine lib_vlistInqVarLongname
+    end interface
+    longname_temp(len(longname_dummy) + 1) = c_null_char
+    do longname_i = len(longname_dummy), 1, -1
+      if(longname_dummy(longname_i:longname_i) /= ' ') exit
+      longname_temp(longname_i) = c_null_char
+    end do
+    do longname_i = longname_i, 1, -1
+        longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
+    end do
+    call lib_vlistInqVarLongname(vlistID_dummy, varID_dummy, longname_temp)
+    do longname_i = 1, len(longname_dummy)
+      if(longname_temp(longname_i) == c_null_char) exit
+      longname_dummy(longname_i:longname_i) = longname_temp(longname_i)
+    end do
+    do longname_i = longname_i, len(longname_dummy)
+      longname_dummy(longname_i:longname_i) = ' '
+    end do
+  end subroutine vlistInqVarLongname
+
+  subroutine vlistDefVarUnits(vlistID_dummy, varID_dummy, units_dummy)
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: units_dummy
+    character(kind = c_char) :: units_temp(len(units_dummy) + 1)
+    integer :: units_i
+    interface
+      subroutine lib_vlistDefVarUnits(vlistID_dummy, varID_dummy, units_dummy)&
+      & bind(c, name = 'vlistDefVarUnits')
+        import c_char, c_int
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: units_dummy(*)
+      end subroutine lib_vlistDefVarUnits
+    end interface
+    do units_i = 1, len(units_dummy)
+      units_temp(units_i) = units_dummy(units_i:units_i)
+    end do
+    units_temp(len(units_dummy) + 1) = c_null_char
+    call lib_vlistDefVarUnits(vlistID_dummy, varID_dummy, units_temp)
+  end subroutine vlistDefVarUnits
+
+  subroutine vlistInqVarUnits(vlistID_dummy, varID_dummy, units_dummy)
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(inout) :: units_dummy
+    character(kind = c_char) :: units_temp(len(units_dummy) + 1)
+    integer :: units_i
+    interface
+      subroutine lib_vlistInqVarUnits(vlistID_dummy, varID_dummy, units_dummy)&
+      & bind(c, name = 'vlistInqVarUnits')
+        import c_char, c_int
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: units_dummy(*)
+      end subroutine lib_vlistInqVarUnits
+    end interface
+    units_temp(len(units_dummy) + 1) = c_null_char
+    do units_i = len(units_dummy), 1, -1
+      if(units_dummy(units_i:units_i) /= ' ') exit
+      units_temp(units_i) = c_null_char
+    end do
+    do units_i = units_i, 1, -1
+        units_temp(units_i) = units_dummy(units_i:units_i)
+    end do
+    call lib_vlistInqVarUnits(vlistID_dummy, varID_dummy, units_temp)
+    do units_i = 1, len(units_dummy)
+      if(units_temp(units_i) == c_null_char) exit
+      units_dummy(units_i:units_i) = units_temp(units_i)
+    end do
+    do units_i = units_i, len(units_dummy)
+      units_dummy(units_i:units_i) = ' '
+    end do
+  end subroutine vlistInqVarUnits
+
+  subroutine vlistDefVarExtra(vlistID_dummy, varID_dummy, extra_dummy)
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: extra_dummy
+    character(kind = c_char) :: extra_temp(len(extra_dummy) + 1)
+    integer :: extra_i
+    interface
+      subroutine lib_vlistDefVarExtra(vlistID_dummy, varID_dummy, extra_dummy)&
+      & bind(c, name = 'vlistDefVarExtra')
+        import c_char, c_int
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: extra_dummy(*)
+      end subroutine lib_vlistDefVarExtra
+    end interface
+    do extra_i = 1, len(extra_dummy)
+      extra_temp(extra_i) = extra_dummy(extra_i:extra_i)
+    end do
+    extra_temp(len(extra_dummy) + 1) = c_null_char
+    call lib_vlistDefVarExtra(vlistID_dummy, varID_dummy, extra_temp)
+  end subroutine vlistDefVarExtra
+
+  subroutine vlistInqVarExtra(vlistID_dummy, varID_dummy, extra_dummy)
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(inout) :: extra_dummy
+    character(kind = c_char) :: extra_temp(len(extra_dummy) + 1)
+    integer :: extra_i
+    interface
+      subroutine lib_vlistInqVarExtra(vlistID_dummy, varID_dummy, extra_dummy)&
+      & bind(c, name = 'vlistInqVarExtra')
+        import c_char, c_int
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: extra_dummy(*)
+      end subroutine lib_vlistInqVarExtra
+    end interface
+    extra_temp(len(extra_dummy) + 1) = c_null_char
+    do extra_i = len(extra_dummy), 1, -1
+      if(extra_dummy(extra_i:extra_i) /= ' ') exit
+      extra_temp(extra_i) = c_null_char
+    end do
+    do extra_i = extra_i, 1, -1
+        extra_temp(extra_i) = extra_dummy(extra_i:extra_i)
+    end do
+    call lib_vlistInqVarExtra(vlistID_dummy, varID_dummy, extra_temp)
+    do extra_i = 1, len(extra_dummy)
+      if(extra_temp(extra_i) == c_null_char) exit
+      extra_dummy(extra_i:extra_i) = extra_temp(extra_i)
+    end do
+    do extra_i = extra_i, len(extra_dummy)
+      extra_dummy(extra_i:extra_i) = ' '
+    end do
+  end subroutine vlistInqVarExtra
+
+  subroutine cdiDefAdditionalKey(string_dummy)
+    character(kind = c_char, len = *), intent(in) :: string_dummy
+    character(kind = c_char) :: string_temp(len(string_dummy) + 1)
+    integer :: string_i
+    interface
+      subroutine lib_cdiDefAdditionalKey(string_dummy) bind(c, name =&
+      & 'cdiDefAdditionalKey')
+        import c_char
+        character(kind = c_char) :: string_dummy(*)
+      end subroutine lib_cdiDefAdditionalKey
+    end interface
+    do string_i = 1, len(string_dummy)
+      string_temp(string_i) = string_dummy(string_i:string_i)
+    end do
+    string_temp(len(string_dummy) + 1) = c_null_char
+    call lib_cdiDefAdditionalKey(string_temp)
+  end subroutine cdiDefAdditionalKey
+
+  subroutine vlistDefVarIntKey(vlistID_dummy, varID_dummy, name_dummy,&
+  & value_dummy)
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    integer(c_int), value :: value_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      subroutine lib_vlistDefVarIntKey(vlistID_dummy, varID_dummy, name_dummy,&
+      & value_dummy) bind(c, name = 'vlistDefVarIntKey')
+        import c_char, c_int
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: name_dummy(*)
+        integer(c_int), value :: value_dummy
+      end subroutine lib_vlistDefVarIntKey
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    call lib_vlistDefVarIntKey(vlistID_dummy, varID_dummy, name_temp,&
+    & value_dummy)
+  end subroutine vlistDefVarIntKey
+
+  subroutine vlistDefVarDblKey(vlistID_dummy, varID_dummy, name_dummy,&
+  & value_dummy)
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    real(c_double), value :: value_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      subroutine lib_vlistDefVarDblKey(vlistID_dummy, varID_dummy, name_dummy,&
+      & value_dummy) bind(c, name = 'vlistDefVarDblKey')
+        import c_char, c_double, c_int
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: name_dummy(*)
+        real(c_double), value :: value_dummy
+      end subroutine lib_vlistDefVarDblKey
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    call lib_vlistDefVarDblKey(vlistID_dummy, varID_dummy, name_temp,&
+    & value_dummy)
+  end subroutine vlistDefVarDblKey
+
+  function vlistHasVarKey(vlistID_dummy, varID_dummy, name_dummy)&
+  & result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      function lib_vlistHasVarKey(vlistID_dummy, varID_dummy, name_dummy)&
+      & bind(c, name = 'vlistHasVarKey') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: name_dummy(*)
+      end function lib_vlistHasVarKey
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    f_result = lib_vlistHasVarKey(vlistID_dummy, varID_dummy, name_temp)
+  end function vlistHasVarKey
+
+  function vlistInqVarDblKey(vlistID_dummy, varID_dummy, name_dummy)&
+  & result(f_result)
+    real(c_double) :: f_result
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      function lib_vlistInqVarDblKey(vlistID_dummy, varID_dummy, name_dummy)&
+      & bind(c, name = 'vlistInqVarDblKey') result(c_result)
+        import c_char, c_double, c_int
+        real(c_double) :: c_result
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: name_dummy(*)
+      end function lib_vlistInqVarDblKey
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    f_result = lib_vlistInqVarDblKey(vlistID_dummy, varID_dummy, name_temp)
+  end function vlistInqVarDblKey
+
+  function vlistInqVarIntKey(vlistID_dummy, varID_dummy, name_dummy)&
+  & result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      function lib_vlistInqVarIntKey(vlistID_dummy, varID_dummy, name_dummy)&
+      & bind(c, name = 'vlistInqVarIntKey') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: name_dummy(*)
+      end function lib_vlistInqVarIntKey
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    f_result = lib_vlistInqVarIntKey(vlistID_dummy, varID_dummy, name_temp)
+  end function vlistInqVarIntKey
+
+  function vlistInqAtt(vlistID_dummy, varID_dummy, attrnum_dummy, name_dummy,&
+  & typep_dummy, lenp_dummy) result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    integer(c_int), value :: attrnum_dummy
+    character(kind = c_char, len = *), intent(inout) :: name_dummy
+    integer(c_int), intent(inout) :: typep_dummy
+    integer(c_int), intent(inout) :: lenp_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      function lib_vlistInqAtt(vlistID_dummy, varID_dummy, attrnum_dummy,&
+      & name_dummy, typep_dummy, lenp_dummy) bind(c, name = 'vlistInqAtt')&
+      & result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        integer(c_int), value :: attrnum_dummy
+        character(kind = c_char) :: name_dummy(*)
+        integer(c_int), intent(inout) :: typep_dummy
+        integer(c_int), intent(inout) :: lenp_dummy
+      end function lib_vlistInqAtt
+    end interface
+    name_temp(len(name_dummy) + 1) = c_null_char
+    do name_i = len(name_dummy), 1, -1
+      if(name_dummy(name_i:name_i) /= ' ') exit
+      name_temp(name_i) = c_null_char
+    end do
+    do name_i = name_i, 1, -1
+        name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    f_result = lib_vlistInqAtt(vlistID_dummy, varID_dummy, attrnum_dummy,&
+    & name_temp, typep_dummy, lenp_dummy)
+    do name_i = 1, len(name_dummy)
+      if(name_temp(name_i) == c_null_char) exit
+      name_dummy(name_i:name_i) = name_temp(name_i)
+    end do
+    do name_i = name_i, len(name_dummy)
+      name_dummy(name_i:name_i) = ' '
+    end do
+  end function vlistInqAtt
+
+  function vlistDelAtt(vlistID_dummy, varID_dummy, name_dummy) result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      function lib_vlistDelAtt(vlistID_dummy, varID_dummy, name_dummy) bind(c,&
+      & name = 'vlistDelAtt') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: name_dummy(*)
+      end function lib_vlistDelAtt
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    f_result = lib_vlistDelAtt(vlistID_dummy, varID_dummy, name_temp)
+  end function vlistDelAtt
+
+  function vlistDefAttInt(vlistID_dummy, varID_dummy, name_dummy, type_dummy,&
+  & len_dummy, ip_dummy) result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    integer(c_int), value :: type_dummy
+    integer(c_int), value :: len_dummy
+    integer(c_int), intent(in) :: ip_dummy(*)
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      function lib_vlistDefAttInt(vlistID_dummy, varID_dummy, name_dummy,&
+      & type_dummy, len_dummy, ip_dummy) bind(c, name = 'vlistDefAttInt')&
+      & result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: name_dummy(*)
+        integer(c_int), value :: type_dummy
+        integer(c_int), value :: len_dummy
+        integer(c_int), intent(in) :: ip_dummy(*)
+      end function lib_vlistDefAttInt
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    f_result = lib_vlistDefAttInt(vlistID_dummy, varID_dummy, name_temp,&
+    & type_dummy, len_dummy, ip_dummy)
+  end function vlistDefAttInt
+
+  function vlistDefAttFlt(vlistID_dummy, varID_dummy, name_dummy, type_dummy,&
+  & len_dummy, dp_dummy) result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    integer(c_int), value :: type_dummy
+    integer(c_int), value :: len_dummy
+    real(c_double), intent(in) :: dp_dummy(*)
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      function lib_vlistDefAttFlt(vlistID_dummy, varID_dummy, name_dummy,&
+      & type_dummy, len_dummy, dp_dummy) bind(c, name = 'vlistDefAttFlt')&
+      & result(c_result)
+        import c_char, c_double, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: name_dummy(*)
+        integer(c_int), value :: type_dummy
+        integer(c_int), value :: len_dummy
+        real(c_double), intent(in) :: dp_dummy(*)
+      end function lib_vlistDefAttFlt
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    f_result = lib_vlistDefAttFlt(vlistID_dummy, varID_dummy, name_temp,&
+    & type_dummy, len_dummy, dp_dummy)
+  end function vlistDefAttFlt
+
+  function vlistDefAttTxt(vlistID_dummy, varID_dummy, name_dummy, len_dummy,&
+  & tp_cbuf_dummy) result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    integer(c_int), value :: len_dummy
+    character(kind = c_char, len = *), intent(in) :: tp_cbuf_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    character(kind = c_char) :: tp_cbuf_temp(len(tp_cbuf_dummy) + 1)
+    integer :: tp_cbuf_i
+    interface
+      function lib_vlistDefAttTxt(vlistID_dummy, varID_dummy, name_dummy,&
+      & len_dummy, tp_cbuf_dummy) bind(c, name = 'vlistDefAttTxt')&
+      & result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: name_dummy(*)
+        integer(c_int), value :: len_dummy
+        character(kind = c_char) :: tp_cbuf_dummy(*)
+      end function lib_vlistDefAttTxt
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    do tp_cbuf_i = 1, len(tp_cbuf_dummy)
+      tp_cbuf_temp(tp_cbuf_i) = tp_cbuf_dummy(tp_cbuf_i:tp_cbuf_i)
+    end do
+    tp_cbuf_temp(len(tp_cbuf_dummy) + 1) = c_null_char
+    f_result = lib_vlistDefAttTxt(vlistID_dummy, varID_dummy, name_temp,&
+    & len_dummy, tp_cbuf_temp)
+  end function vlistDefAttTxt
+
+  function vlistInqAttInt(vlistID_dummy, varID_dummy, name_dummy, mlen_dummy,&
+  & ip_dummy) result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    integer(c_int), value :: mlen_dummy
+    integer(c_int), intent(inout) :: ip_dummy(*)
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      function lib_vlistInqAttInt(vlistID_dummy, varID_dummy, name_dummy,&
+      & mlen_dummy, ip_dummy) bind(c, name = 'vlistInqAttInt') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: name_dummy(*)
+        integer(c_int), value :: mlen_dummy
+        integer(c_int), intent(inout) :: ip_dummy(*)
+      end function lib_vlistInqAttInt
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    f_result = lib_vlistInqAttInt(vlistID_dummy, varID_dummy, name_temp,&
+    & mlen_dummy, ip_dummy)
+  end function vlistInqAttInt
+
+  function vlistInqAttFlt(vlistID_dummy, varID_dummy, name_dummy, mlen_dummy,&
+  & dp_dummy) result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    integer(c_int), value :: mlen_dummy
+    real(c_double), intent(inout) :: dp_dummy(*)
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      function lib_vlistInqAttFlt(vlistID_dummy, varID_dummy, name_dummy,&
+      & mlen_dummy, dp_dummy) bind(c, name = 'vlistInqAttFlt') result(c_result)
+        import c_char, c_double, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: name_dummy(*)
+        integer(c_int), value :: mlen_dummy
+        real(c_double), intent(inout) :: dp_dummy(*)
+      end function lib_vlistInqAttFlt
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    f_result = lib_vlistInqAttFlt(vlistID_dummy, varID_dummy, name_temp,&
+    & mlen_dummy, dp_dummy)
+  end function vlistInqAttFlt
+
+  function vlistInqAttTxt(vlistID_dummy, varID_dummy, name_dummy, mlen_dummy,&
+  & tp_cbuf_dummy) result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: vlistID_dummy
+    integer(c_int), value :: varID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    integer(c_int), value :: mlen_dummy
+    character(kind = c_char, len = *), intent(inout) :: tp_cbuf_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    character(kind = c_char) :: tp_cbuf_temp(len(tp_cbuf_dummy) + 1)
+    integer :: tp_cbuf_i
+    interface
+      function lib_vlistInqAttTxt(vlistID_dummy, varID_dummy, name_dummy,&
+      & mlen_dummy, tp_cbuf_dummy) bind(c, name = 'vlistInqAttTxt')&
+      & result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: vlistID_dummy
+        integer(c_int), value :: varID_dummy
+        character(kind = c_char) :: name_dummy(*)
+        integer(c_int), value :: mlen_dummy
+        character(kind = c_char) :: tp_cbuf_dummy(*)
+      end function lib_vlistInqAttTxt
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    tp_cbuf_temp(len(tp_cbuf_dummy) + 1) = c_null_char
+    do tp_cbuf_i = len(tp_cbuf_dummy), 1, -1
+      if(tp_cbuf_dummy(tp_cbuf_i:tp_cbuf_i) /= ' ') exit
+      tp_cbuf_temp(tp_cbuf_i) = c_null_char
+    end do
+    do tp_cbuf_i = tp_cbuf_i, 1, -1
+        tp_cbuf_temp(tp_cbuf_i) = tp_cbuf_dummy(tp_cbuf_i:tp_cbuf_i)
+    end do
+    f_result = lib_vlistInqAttTxt(vlistID_dummy, varID_dummy, name_temp,&
+    & mlen_dummy, tp_cbuf_temp)
+    do tp_cbuf_i = 1, len(tp_cbuf_dummy)
+      if(tp_cbuf_temp(tp_cbuf_i) == c_null_char) exit
+      tp_cbuf_dummy(tp_cbuf_i:tp_cbuf_i) = tp_cbuf_temp(tp_cbuf_i)
+    end do
+    do tp_cbuf_i = tp_cbuf_i, len(tp_cbuf_dummy)
+      tp_cbuf_dummy(tp_cbuf_i:tp_cbuf_i) = ' '
+    end do
+  end function vlistInqAttTxt
+
+  subroutine gridName(gridtype_dummy, gridname_dummy)
+    integer(c_int), value :: gridtype_dummy
+    character(kind = c_char, len = *), intent(inout) :: gridname_dummy
+    character(kind = c_char) :: gridname_temp(len(gridname_dummy) + 1)
+    integer :: gridname_i
+    interface
+      subroutine lib_gridName(gridtype_dummy, gridname_dummy) bind(c, name =&
+      & 'gridName')
+        import c_char, c_int
+        integer(c_int), value :: gridtype_dummy
+        character(kind = c_char) :: gridname_dummy(*)
+      end subroutine lib_gridName
+    end interface
+    gridname_temp(len(gridname_dummy) + 1) = c_null_char
+    do gridname_i = len(gridname_dummy), 1, -1
+      if(gridname_dummy(gridname_i:gridname_i) /= ' ') exit
+      gridname_temp(gridname_i) = c_null_char
+    end do
+    do gridname_i = gridname_i, 1, -1
+        gridname_temp(gridname_i) = gridname_dummy(gridname_i:gridname_i)
+    end do
+    call lib_gridName(gridtype_dummy, gridname_temp)
+    do gridname_i = 1, len(gridname_dummy)
+      if(gridname_temp(gridname_i) == c_null_char) exit
+      gridname_dummy(gridname_i:gridname_i) = gridname_temp(gridname_i)
+    end do
+    do gridname_i = gridname_i, len(gridname_dummy)
+      gridname_dummy(gridname_i:gridname_i) = ' '
+    end do
+  end subroutine gridName
+
+  function gridNamePtr(gridtype_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    integer(c_int), value :: gridtype_dummy
+    type(c_ptr) :: ptr
+    integer :: rv_shape(1)
+    interface
+      function lib_gridNamePtr(gridtype_dummy) bind(c, name = 'gridNamePtr')&
+      & result(c_result)
+        import c_int, c_ptr
+        type(c_ptr) :: c_result
+        integer(c_int), value :: gridtype_dummy
+      end function lib_gridNamePtr
+    end interface
+    f_result => null()
+    ptr = lib_gridNamePtr(gridtype_dummy)
+    if(c_associated(ptr)) then
+      rv_shape(1) = int(lib_strlen(ptr))
+      call c_f_pointer(ptr, f_result, rv_shape)
+    end if
+  end function gridNamePtr
+
+  subroutine gridDefXname(gridID_dummy, xname_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(in) :: xname_dummy
+    character(kind = c_char) :: xname_temp(len(xname_dummy) + 1)
+    integer :: xname_i
+    interface
+      subroutine lib_gridDefXname(gridID_dummy, xname_dummy) bind(c, name =&
+      & 'gridDefXname')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: xname_dummy(*)
+      end subroutine lib_gridDefXname
+    end interface
+    do xname_i = 1, len(xname_dummy)
+      xname_temp(xname_i) = xname_dummy(xname_i:xname_i)
+    end do
+    xname_temp(len(xname_dummy) + 1) = c_null_char
+    call lib_gridDefXname(gridID_dummy, xname_temp)
+  end subroutine gridDefXname
+
+  subroutine gridInqXname(gridID_dummy, xname_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(inout) :: xname_dummy
+    character(kind = c_char) :: xname_temp(len(xname_dummy) + 1)
+    integer :: xname_i
+    interface
+      subroutine lib_gridInqXname(gridID_dummy, xname_dummy) bind(c, name =&
+      & 'gridInqXname')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: xname_dummy(*)
+      end subroutine lib_gridInqXname
+    end interface
+    xname_temp(len(xname_dummy) + 1) = c_null_char
+    do xname_i = len(xname_dummy), 1, -1
+      if(xname_dummy(xname_i:xname_i) /= ' ') exit
+      xname_temp(xname_i) = c_null_char
+    end do
+    do xname_i = xname_i, 1, -1
+        xname_temp(xname_i) = xname_dummy(xname_i:xname_i)
+    end do
+    call lib_gridInqXname(gridID_dummy, xname_temp)
+    do xname_i = 1, len(xname_dummy)
+      if(xname_temp(xname_i) == c_null_char) exit
+      xname_dummy(xname_i:xname_i) = xname_temp(xname_i)
+    end do
+    do xname_i = xname_i, len(xname_dummy)
+      xname_dummy(xname_i:xname_i) = ' '
+    end do
+  end subroutine gridInqXname
+
+  subroutine gridDefXlongname(gridID_dummy, xlongname_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(in) :: xlongname_dummy
+    character(kind = c_char) :: xlongname_temp(len(xlongname_dummy) + 1)
+    integer :: xlongname_i
+    interface
+      subroutine lib_gridDefXlongname(gridID_dummy, xlongname_dummy) bind(c,&
+      & name = 'gridDefXlongname')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: xlongname_dummy(*)
+      end subroutine lib_gridDefXlongname
+    end interface
+    do xlongname_i = 1, len(xlongname_dummy)
+      xlongname_temp(xlongname_i) = xlongname_dummy(xlongname_i:xlongname_i)
+    end do
+    xlongname_temp(len(xlongname_dummy) + 1) = c_null_char
+    call lib_gridDefXlongname(gridID_dummy, xlongname_temp)
+  end subroutine gridDefXlongname
+
+  subroutine gridInqXlongname(gridID_dummy, xlongname_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(inout) :: xlongname_dummy
+    character(kind = c_char) :: xlongname_temp(len(xlongname_dummy) + 1)
+    integer :: xlongname_i
+    interface
+      subroutine lib_gridInqXlongname(gridID_dummy, xlongname_dummy) bind(c,&
+      & name = 'gridInqXlongname')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: xlongname_dummy(*)
+      end subroutine lib_gridInqXlongname
+    end interface
+    xlongname_temp(len(xlongname_dummy) + 1) = c_null_char
+    do xlongname_i = len(xlongname_dummy), 1, -1
+      if(xlongname_dummy(xlongname_i:xlongname_i) /= ' ') exit
+      xlongname_temp(xlongname_i) = c_null_char
+    end do
+    do xlongname_i = xlongname_i, 1, -1
+        xlongname_temp(xlongname_i) = xlongname_dummy(xlongname_i:xlongname_i)
+    end do
+    call lib_gridInqXlongname(gridID_dummy, xlongname_temp)
+    do xlongname_i = 1, len(xlongname_dummy)
+      if(xlongname_temp(xlongname_i) == c_null_char) exit
+      xlongname_dummy(xlongname_i:xlongname_i) = xlongname_temp(xlongname_i)
+    end do
+    do xlongname_i = xlongname_i, len(xlongname_dummy)
+      xlongname_dummy(xlongname_i:xlongname_i) = ' '
+    end do
+  end subroutine gridInqXlongname
+
+  subroutine gridDefXunits(gridID_dummy, xunits_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(in) :: xunits_dummy
+    character(kind = c_char) :: xunits_temp(len(xunits_dummy) + 1)
+    integer :: xunits_i
+    interface
+      subroutine lib_gridDefXunits(gridID_dummy, xunits_dummy) bind(c, name =&
+      & 'gridDefXunits')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: xunits_dummy(*)
+      end subroutine lib_gridDefXunits
+    end interface
+    do xunits_i = 1, len(xunits_dummy)
+      xunits_temp(xunits_i) = xunits_dummy(xunits_i:xunits_i)
+    end do
+    xunits_temp(len(xunits_dummy) + 1) = c_null_char
+    call lib_gridDefXunits(gridID_dummy, xunits_temp)
+  end subroutine gridDefXunits
+
+  subroutine gridInqXunits(gridID_dummy, xunits_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(inout) :: xunits_dummy
+    character(kind = c_char) :: xunits_temp(len(xunits_dummy) + 1)
+    integer :: xunits_i
+    interface
+      subroutine lib_gridInqXunits(gridID_dummy, xunits_dummy) bind(c, name =&
+      & 'gridInqXunits')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: xunits_dummy(*)
+      end subroutine lib_gridInqXunits
+    end interface
+    xunits_temp(len(xunits_dummy) + 1) = c_null_char
+    do xunits_i = len(xunits_dummy), 1, -1
+      if(xunits_dummy(xunits_i:xunits_i) /= ' ') exit
+      xunits_temp(xunits_i) = c_null_char
+    end do
+    do xunits_i = xunits_i, 1, -1
+        xunits_temp(xunits_i) = xunits_dummy(xunits_i:xunits_i)
+    end do
+    call lib_gridInqXunits(gridID_dummy, xunits_temp)
+    do xunits_i = 1, len(xunits_dummy)
+      if(xunits_temp(xunits_i) == c_null_char) exit
+      xunits_dummy(xunits_i:xunits_i) = xunits_temp(xunits_i)
+    end do
+    do xunits_i = xunits_i, len(xunits_dummy)
+      xunits_dummy(xunits_i:xunits_i) = ' '
+    end do
+  end subroutine gridInqXunits
+
+  subroutine gridDefYname(gridID_dummy, yname_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(in) :: yname_dummy
+    character(kind = c_char) :: yname_temp(len(yname_dummy) + 1)
+    integer :: yname_i
+    interface
+      subroutine lib_gridDefYname(gridID_dummy, yname_dummy) bind(c, name =&
+      & 'gridDefYname')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: yname_dummy(*)
+      end subroutine lib_gridDefYname
+    end interface
+    do yname_i = 1, len(yname_dummy)
+      yname_temp(yname_i) = yname_dummy(yname_i:yname_i)
+    end do
+    yname_temp(len(yname_dummy) + 1) = c_null_char
+    call lib_gridDefYname(gridID_dummy, yname_temp)
+  end subroutine gridDefYname
+
+  subroutine gridInqYname(gridID_dummy, yname_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(inout) :: yname_dummy
+    character(kind = c_char) :: yname_temp(len(yname_dummy) + 1)
+    integer :: yname_i
+    interface
+      subroutine lib_gridInqYname(gridID_dummy, yname_dummy) bind(c, name =&
+      & 'gridInqYname')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: yname_dummy(*)
+      end subroutine lib_gridInqYname
+    end interface
+    yname_temp(len(yname_dummy) + 1) = c_null_char
+    do yname_i = len(yname_dummy), 1, -1
+      if(yname_dummy(yname_i:yname_i) /= ' ') exit
+      yname_temp(yname_i) = c_null_char
+    end do
+    do yname_i = yname_i, 1, -1
+        yname_temp(yname_i) = yname_dummy(yname_i:yname_i)
+    end do
+    call lib_gridInqYname(gridID_dummy, yname_temp)
+    do yname_i = 1, len(yname_dummy)
+      if(yname_temp(yname_i) == c_null_char) exit
+      yname_dummy(yname_i:yname_i) = yname_temp(yname_i)
+    end do
+    do yname_i = yname_i, len(yname_dummy)
+      yname_dummy(yname_i:yname_i) = ' '
+    end do
+  end subroutine gridInqYname
+
+  subroutine gridDefYlongname(gridID_dummy, ylongname_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(in) :: ylongname_dummy
+    character(kind = c_char) :: ylongname_temp(len(ylongname_dummy) + 1)
+    integer :: ylongname_i
+    interface
+      subroutine lib_gridDefYlongname(gridID_dummy, ylongname_dummy) bind(c,&
+      & name = 'gridDefYlongname')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: ylongname_dummy(*)
+      end subroutine lib_gridDefYlongname
+    end interface
+    do ylongname_i = 1, len(ylongname_dummy)
+      ylongname_temp(ylongname_i) = ylongname_dummy(ylongname_i:ylongname_i)
+    end do
+    ylongname_temp(len(ylongname_dummy) + 1) = c_null_char
+    call lib_gridDefYlongname(gridID_dummy, ylongname_temp)
+  end subroutine gridDefYlongname
+
+  subroutine gridInqYlongname(gridID_dummy, ylongname_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(inout) :: ylongname_dummy
+    character(kind = c_char) :: ylongname_temp(len(ylongname_dummy) + 1)
+    integer :: ylongname_i
+    interface
+      subroutine lib_gridInqYlongname(gridID_dummy, ylongname_dummy) bind(c,&
+      & name = 'gridInqYlongname')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: ylongname_dummy(*)
+      end subroutine lib_gridInqYlongname
+    end interface
+    ylongname_temp(len(ylongname_dummy) + 1) = c_null_char
+    do ylongname_i = len(ylongname_dummy), 1, -1
+      if(ylongname_dummy(ylongname_i:ylongname_i) /= ' ') exit
+      ylongname_temp(ylongname_i) = c_null_char
+    end do
+    do ylongname_i = ylongname_i, 1, -1
+        ylongname_temp(ylongname_i) = ylongname_dummy(ylongname_i:ylongname_i)
+    end do
+    call lib_gridInqYlongname(gridID_dummy, ylongname_temp)
+    do ylongname_i = 1, len(ylongname_dummy)
+      if(ylongname_temp(ylongname_i) == c_null_char) exit
+      ylongname_dummy(ylongname_i:ylongname_i) = ylongname_temp(ylongname_i)
+    end do
+    do ylongname_i = ylongname_i, len(ylongname_dummy)
+      ylongname_dummy(ylongname_i:ylongname_i) = ' '
+    end do
+  end subroutine gridInqYlongname
+
+  subroutine gridDefYunits(gridID_dummy, yunits_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(in) :: yunits_dummy
+    character(kind = c_char) :: yunits_temp(len(yunits_dummy) + 1)
+    integer :: yunits_i
+    interface
+      subroutine lib_gridDefYunits(gridID_dummy, yunits_dummy) bind(c, name =&
+      & 'gridDefYunits')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: yunits_dummy(*)
+      end subroutine lib_gridDefYunits
+    end interface
+    do yunits_i = 1, len(yunits_dummy)
+      yunits_temp(yunits_i) = yunits_dummy(yunits_i:yunits_i)
+    end do
+    yunits_temp(len(yunits_dummy) + 1) = c_null_char
+    call lib_gridDefYunits(gridID_dummy, yunits_temp)
+  end subroutine gridDefYunits
+
+  subroutine gridInqYunits(gridID_dummy, yunits_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(inout) :: yunits_dummy
+    character(kind = c_char) :: yunits_temp(len(yunits_dummy) + 1)
+    integer :: yunits_i
+    interface
+      subroutine lib_gridInqYunits(gridID_dummy, yunits_dummy) bind(c, name =&
+      & 'gridInqYunits')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: yunits_dummy(*)
+      end subroutine lib_gridInqYunits
+    end interface
+    yunits_temp(len(yunits_dummy) + 1) = c_null_char
+    do yunits_i = len(yunits_dummy), 1, -1
+      if(yunits_dummy(yunits_i:yunits_i) /= ' ') exit
+      yunits_temp(yunits_i) = c_null_char
+    end do
+    do yunits_i = yunits_i, 1, -1
+        yunits_temp(yunits_i) = yunits_dummy(yunits_i:yunits_i)
+    end do
+    call lib_gridInqYunits(gridID_dummy, yunits_temp)
+    do yunits_i = 1, len(yunits_dummy)
+      if(yunits_temp(yunits_i) == c_null_char) exit
+      yunits_dummy(yunits_i:yunits_i) = yunits_temp(yunits_i)
+    end do
+    do yunits_i = yunits_i, len(yunits_dummy)
+      yunits_dummy(yunits_i:yunits_i) = ' '
+    end do
+  end subroutine gridInqYunits
+
+  subroutine gridInqXstdname(gridID_dummy, xstdname_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(inout) :: xstdname_dummy
+    character(kind = c_char) :: xstdname_temp(len(xstdname_dummy) + 1)
+    integer :: xstdname_i
+    interface
+      subroutine lib_gridInqXstdname(gridID_dummy, xstdname_dummy) bind(c, name&
+      & = 'gridInqXstdname')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: xstdname_dummy(*)
+      end subroutine lib_gridInqXstdname
+    end interface
+    xstdname_temp(len(xstdname_dummy) + 1) = c_null_char
+    do xstdname_i = len(xstdname_dummy), 1, -1
+      if(xstdname_dummy(xstdname_i:xstdname_i) /= ' ') exit
+      xstdname_temp(xstdname_i) = c_null_char
+    end do
+    do xstdname_i = xstdname_i, 1, -1
+        xstdname_temp(xstdname_i) = xstdname_dummy(xstdname_i:xstdname_i)
+    end do
+    call lib_gridInqXstdname(gridID_dummy, xstdname_temp)
+    do xstdname_i = 1, len(xstdname_dummy)
+      if(xstdname_temp(xstdname_i) == c_null_char) exit
+      xstdname_dummy(xstdname_i:xstdname_i) = xstdname_temp(xstdname_i)
+    end do
+    do xstdname_i = xstdname_i, len(xstdname_dummy)
+      xstdname_dummy(xstdname_i:xstdname_i) = ' '
+    end do
+  end subroutine gridInqXstdname
+
+  subroutine gridInqYstdname(gridID_dummy, ystdname_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(inout) :: ystdname_dummy
+    character(kind = c_char) :: ystdname_temp(len(ystdname_dummy) + 1)
+    integer :: ystdname_i
+    interface
+      subroutine lib_gridInqYstdname(gridID_dummy, ystdname_dummy) bind(c, name&
+      & = 'gridInqYstdname')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: ystdname_dummy(*)
+      end subroutine lib_gridInqYstdname
+    end interface
+    ystdname_temp(len(ystdname_dummy) + 1) = c_null_char
+    do ystdname_i = len(ystdname_dummy), 1, -1
+      if(ystdname_dummy(ystdname_i:ystdname_i) /= ' ') exit
+      ystdname_temp(ystdname_i) = c_null_char
+    end do
+    do ystdname_i = ystdname_i, 1, -1
+        ystdname_temp(ystdname_i) = ystdname_dummy(ystdname_i:ystdname_i)
+    end do
+    call lib_gridInqYstdname(gridID_dummy, ystdname_temp)
+    do ystdname_i = 1, len(ystdname_dummy)
+      if(ystdname_temp(ystdname_i) == c_null_char) exit
+      ystdname_dummy(ystdname_i:ystdname_i) = ystdname_temp(ystdname_i)
+    end do
+    do ystdname_i = ystdname_i, len(ystdname_dummy)
+      ystdname_dummy(ystdname_i:ystdname_i) = ' '
+    end do
+  end subroutine gridInqYstdname
+
+  subroutine gridDefReference(gridID_dummy, reference_dummy)
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(in) :: reference_dummy
+    character(kind = c_char) :: reference_temp(len(reference_dummy) + 1)
+    integer :: reference_i
+    interface
+      subroutine lib_gridDefReference(gridID_dummy, reference_dummy) bind(c,&
+      & name = 'gridDefReference')
+        import c_char, c_int
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: reference_dummy(*)
+      end subroutine lib_gridDefReference
+    end interface
+    do reference_i = 1, len(reference_dummy)
+      reference_temp(reference_i) = reference_dummy(reference_i:reference_i)
+    end do
+    reference_temp(len(reference_dummy) + 1) = c_null_char
+    call lib_gridDefReference(gridID_dummy, reference_temp)
+  end subroutine gridDefReference
+
+  function gridInqReference(gridID_dummy, reference_dummy) result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: gridID_dummy
+    character(kind = c_char, len = *), intent(inout) :: reference_dummy
+    character(kind = c_char) :: reference_temp(len(reference_dummy) + 1)
+    integer :: reference_i
+    interface
+      function lib_gridInqReference(gridID_dummy, reference_dummy) bind(c, name&
+      & = 'gridInqReference') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: gridID_dummy
+        character(kind = c_char) :: reference_dummy(*)
+      end function lib_gridInqReference
+    end interface
+    reference_temp(len(reference_dummy) + 1) = c_null_char
+    do reference_i = len(reference_dummy), 1, -1
+      if(reference_dummy(reference_i:reference_i) /= ' ') exit
+      reference_temp(reference_i) = c_null_char
+    end do
+    do reference_i = reference_i, 1, -1
+        reference_temp(reference_i) = reference_dummy(reference_i:reference_i)
+    end do
+    f_result = lib_gridInqReference(gridID_dummy, reference_temp)
+    do reference_i = 1, len(reference_dummy)
+      if(reference_temp(reference_i) == c_null_char) exit
+      reference_dummy(reference_i:reference_i) = reference_temp(reference_i)
+    end do
+    do reference_i = reference_i, len(reference_dummy)
+      reference_dummy(reference_i:reference_i) = ' '
+    end do
+  end function gridInqReference
+
+  subroutine zaxisName(zaxistype_dummy, zaxisname_dummy)
+    integer(c_int), value :: zaxistype_dummy
+    character(kind = c_char, len = *), intent(inout) :: zaxisname_dummy
+    character(kind = c_char) :: zaxisname_temp(len(zaxisname_dummy) + 1)
+    integer :: zaxisname_i
+    interface
+      subroutine lib_zaxisName(zaxistype_dummy, zaxisname_dummy) bind(c, name =&
+      & 'zaxisName')
+        import c_char, c_int
+        integer(c_int), value :: zaxistype_dummy
+        character(kind = c_char) :: zaxisname_dummy(*)
+      end subroutine lib_zaxisName
+    end interface
+    zaxisname_temp(len(zaxisname_dummy) + 1) = c_null_char
+    do zaxisname_i = len(zaxisname_dummy), 1, -1
+      if(zaxisname_dummy(zaxisname_i:zaxisname_i) /= ' ') exit
+      zaxisname_temp(zaxisname_i) = c_null_char
+    end do
+    do zaxisname_i = zaxisname_i, 1, -1
+        zaxisname_temp(zaxisname_i) = zaxisname_dummy(zaxisname_i:zaxisname_i)
+    end do
+    call lib_zaxisName(zaxistype_dummy, zaxisname_temp)
+    do zaxisname_i = 1, len(zaxisname_dummy)
+      if(zaxisname_temp(zaxisname_i) == c_null_char) exit
+      zaxisname_dummy(zaxisname_i:zaxisname_i) = zaxisname_temp(zaxisname_i)
+    end do
+    do zaxisname_i = zaxisname_i, len(zaxisname_dummy)
+      zaxisname_dummy(zaxisname_i:zaxisname_i) = ' '
+    end do
+  end subroutine zaxisName
+
+  subroutine zaxisDefName(zaxisID_dummy, name)
+    integer(c_int), value :: zaxisID_dummy
+    character(kind = c_char, len = *), optional, intent(in) :: name
+    character(kind = c_char), allocatable, target :: name_temp(:)
+    integer :: name_i
+    type(c_ptr) :: name_cptr
+    interface
+      subroutine lib_zaxisDefName(zaxisID_dummy, name) bind(c, name =&
+      & 'zaxisDefName')
+        import c_int, c_ptr
+        integer(c_int), value :: zaxisID_dummy
+        type(c_ptr), value :: name
+      end subroutine lib_zaxisDefName
+    end interface
+    if (present(name)) then
+      allocate(name_temp(len(name) + 1))
+      name_temp(len(name) + 1) = c_null_char
+      do name_i = len(name), 1, -1
+        if(name(name_i:name_i) /= ' ') exit
+        name_temp(name_i) = c_null_char
+      end do
+      do name_i = name_i, 1, -1
+          name_temp(name_i) = name(name_i:name_i)
+      end do
+      name_cptr = c_loc(name_temp)
+    else
+      name_cptr = c_null_ptr
+    end if
+    call lib_zaxisDefName(zaxisID_dummy, name_cptr)
+  end subroutine zaxisDefName
+
+  subroutine zaxisInqName(zaxisID_dummy, name_dummy)
+    integer(c_int), value :: zaxisID_dummy
+    character(kind = c_char, len = *), intent(inout) :: name_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      subroutine lib_zaxisInqName(zaxisID_dummy, name_dummy) bind(c, name =&
+      & 'zaxisInqName')
+        import c_char, c_int
+        integer(c_int), value :: zaxisID_dummy
+        character(kind = c_char) :: name_dummy(*)
+      end subroutine lib_zaxisInqName
+    end interface
+    name_temp(len(name_dummy) + 1) = c_null_char
+    do name_i = len(name_dummy), 1, -1
+      if(name_dummy(name_i:name_i) /= ' ') exit
+      name_temp(name_i) = c_null_char
+    end do
+    do name_i = name_i, 1, -1
+        name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    call lib_zaxisInqName(zaxisID_dummy, name_temp)
+    do name_i = 1, len(name_dummy)
+      if(name_temp(name_i) == c_null_char) exit
+      name_dummy(name_i:name_i) = name_temp(name_i)
+    end do
+    do name_i = name_i, len(name_dummy)
+      name_dummy(name_i:name_i) = ' '
+    end do
+  end subroutine zaxisInqName
+
+  subroutine zaxisDefLongname(zaxisID_dummy, longname)
+    integer(c_int), value :: zaxisID_dummy
+    character(kind = c_char, len = *), optional, intent(in) :: longname
+    character(kind = c_char), allocatable, target :: longname_temp(:)
+    integer :: longname_i
+    type(c_ptr) :: longname_cptr
+    interface
+      subroutine lib_zaxisDefLongname(zaxisID_dummy, longname) bind(c, name =&
+      & 'zaxisDefLongname')
+        import c_int, c_ptr
+        integer(c_int), value :: zaxisID_dummy
+        type(c_ptr), value :: longname
+      end subroutine lib_zaxisDefLongname
+    end interface
+    if (present(longname)) then
+      allocate(longname_temp(len(longname) + 1))
+      longname_temp(len(longname) + 1) = c_null_char
+      do longname_i = len(longname), 1, -1
+        if(longname(longname_i:longname_i) /= ' ') exit
+        longname_temp(longname_i) = c_null_char
+      end do
+      do longname_i = longname_i, 1, -1
+          longname_temp(longname_i) = longname(longname_i:longname_i)
+      end do
+      longname_cptr = c_loc(longname_temp)
+    else
+      longname_cptr = c_null_ptr
+    end if
+    call lib_zaxisDefLongname(zaxisID_dummy, longname_cptr)
+  end subroutine zaxisDefLongname
+
+  subroutine zaxisInqLongname(zaxisID_dummy, longname_dummy)
+    integer(c_int), value :: zaxisID_dummy
+    character(kind = c_char, len = *), intent(inout) :: longname_dummy
+    character(kind = c_char) :: longname_temp(len(longname_dummy) + 1)
+    integer :: longname_i
+    interface
+      subroutine lib_zaxisInqLongname(zaxisID_dummy, longname_dummy) bind(c,&
+      & name = 'zaxisInqLongname')
+        import c_char, c_int
+        integer(c_int), value :: zaxisID_dummy
+        character(kind = c_char) :: longname_dummy(*)
+      end subroutine lib_zaxisInqLongname
+    end interface
+    longname_temp(len(longname_dummy) + 1) = c_null_char
+    do longname_i = len(longname_dummy), 1, -1
+      if(longname_dummy(longname_i:longname_i) /= ' ') exit
+      longname_temp(longname_i) = c_null_char
+    end do
+    do longname_i = longname_i, 1, -1
+        longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
+    end do
+    call lib_zaxisInqLongname(zaxisID_dummy, longname_temp)
+    do longname_i = 1, len(longname_dummy)
+      if(longname_temp(longname_i) == c_null_char) exit
+      longname_dummy(longname_i:longname_i) = longname_temp(longname_i)
+    end do
+    do longname_i = longname_i, len(longname_dummy)
+      longname_dummy(longname_i:longname_i) = ' '
+    end do
+  end subroutine zaxisInqLongname
+
+  subroutine zaxisDefUnits(zaxisID_dummy, units)
+    integer(c_int), value :: zaxisID_dummy
+    character(kind = c_char, len = *), optional, intent(in) :: units
+    character(kind = c_char), allocatable, target :: units_temp(:)
+    integer :: units_i
+    type(c_ptr) :: units_cptr
+    interface
+      subroutine lib_zaxisDefUnits(zaxisID_dummy, units) bind(c, name =&
+      & 'zaxisDefUnits')
+        import c_int, c_ptr
+        integer(c_int), value :: zaxisID_dummy
+        type(c_ptr), value :: units
+      end subroutine lib_zaxisDefUnits
+    end interface
+    if (present(units)) then
+      allocate(units_temp(len(units) + 1))
+      units_temp(len(units) + 1) = c_null_char
+      do units_i = len(units), 1, -1
+        if(units(units_i:units_i) /= ' ') exit
+        units_temp(units_i) = c_null_char
+      end do
+      do units_i = units_i, 1, -1
+          units_temp(units_i) = units(units_i:units_i)
+      end do
+      units_cptr = c_loc(units_temp)
+    else
+      units_cptr = c_null_ptr
+    end if
+    call lib_zaxisDefUnits(zaxisID_dummy, units_cptr)
+  end subroutine zaxisDefUnits
+
+  subroutine zaxisInqUnits(zaxisID_dummy, units_dummy)
+    integer(c_int), value :: zaxisID_dummy
+    character(kind = c_char, len = *), intent(inout) :: units_dummy
+    character(kind = c_char) :: units_temp(len(units_dummy) + 1)
+    integer :: units_i
+    interface
+      subroutine lib_zaxisInqUnits(zaxisID_dummy, units_dummy) bind(c, name =&
+      & 'zaxisInqUnits')
+        import c_char, c_int
+        integer(c_int), value :: zaxisID_dummy
+        character(kind = c_char) :: units_dummy(*)
+      end subroutine lib_zaxisInqUnits
+    end interface
+    units_temp(len(units_dummy) + 1) = c_null_char
+    do units_i = len(units_dummy), 1, -1
+      if(units_dummy(units_i:units_i) /= ' ') exit
+      units_temp(units_i) = c_null_char
+    end do
+    do units_i = units_i, 1, -1
+        units_temp(units_i) = units_dummy(units_i:units_i)
+    end do
+    call lib_zaxisInqUnits(zaxisID_dummy, units_temp)
+    do units_i = 1, len(units_dummy)
+      if(units_temp(units_i) == c_null_char) exit
+      units_dummy(units_i:units_i) = units_temp(units_i)
+    end do
+    do units_i = units_i, len(units_dummy)
+      units_dummy(units_i:units_i) = ' '
+    end do
+  end subroutine zaxisInqUnits
+
+  subroutine zaxisInqStdname(zaxisID_dummy, stdname_dummy)
+    integer(c_int), value :: zaxisID_dummy
+    character(kind = c_char, len = *), intent(inout) :: stdname_dummy
+    character(kind = c_char) :: stdname_temp(len(stdname_dummy) + 1)
+    integer :: stdname_i
+    interface
+      subroutine lib_zaxisInqStdname(zaxisID_dummy, stdname_dummy) bind(c, name&
+      & = 'zaxisInqStdname')
+        import c_char, c_int
+        integer(c_int), value :: zaxisID_dummy
+        character(kind = c_char) :: stdname_dummy(*)
+      end subroutine lib_zaxisInqStdname
+    end interface
+    stdname_temp(len(stdname_dummy) + 1) = c_null_char
+    do stdname_i = len(stdname_dummy), 1, -1
+      if(stdname_dummy(stdname_i:stdname_i) /= ' ') exit
+      stdname_temp(stdname_i) = c_null_char
+    end do
+    do stdname_i = stdname_i, 1, -1
+        stdname_temp(stdname_i) = stdname_dummy(stdname_i:stdname_i)
+    end do
+    call lib_zaxisInqStdname(zaxisID_dummy, stdname_temp)
+    do stdname_i = 1, len(stdname_dummy)
+      if(stdname_temp(stdname_i) == c_null_char) exit
+      stdname_dummy(stdname_i:stdname_i) = stdname_temp(stdname_i)
+    end do
+    do stdname_i = stdname_i, len(stdname_dummy)
+      stdname_dummy(stdname_i:stdname_i) = ' '
+    end do
+  end subroutine zaxisInqStdname
+
+  subroutine zaxisDefPsName(zaxisID_dummy, psname)
+    integer(c_int), value :: zaxisID_dummy
+    character(kind = c_char, len = *), optional, intent(in) :: psname
+    character(kind = c_char), allocatable, target :: psname_temp(:)
+    integer :: psname_i
+    type(c_ptr) :: psname_cptr
+    interface
+      subroutine lib_zaxisDefPsName(zaxisID_dummy, psname) bind(c, name =&
+      & 'zaxisDefPsName')
+        import c_int, c_ptr
+        integer(c_int), value :: zaxisID_dummy
+        type(c_ptr), value :: psname
+      end subroutine lib_zaxisDefPsName
+    end interface
+    if (present(psname)) then
+      allocate(psname_temp(len(psname) + 1))
+      psname_temp(len(psname) + 1) = c_null_char
+      do psname_i = len(psname), 1, -1
+        if(psname(psname_i:psname_i) /= ' ') exit
+        psname_temp(psname_i) = c_null_char
+      end do
+      do psname_i = psname_i, 1, -1
+          psname_temp(psname_i) = psname(psname_i:psname_i)
+      end do
+      psname_cptr = c_loc(psname_temp)
+    else
+      psname_cptr = c_null_ptr
+    end if
+    call lib_zaxisDefPsName(zaxisID_dummy, psname_cptr)
+  end subroutine zaxisDefPsName
+
+  subroutine zaxisInqPsName(zaxisID_dummy, psname_dummy)
+    integer(c_int), value :: zaxisID_dummy
+    character(kind = c_char, len = *), intent(inout) :: psname_dummy
+    character(kind = c_char) :: psname_temp(len(psname_dummy) + 1)
+    integer :: psname_i
+    interface
+      subroutine lib_zaxisInqPsName(zaxisID_dummy, psname_dummy) bind(c, name =&
+      & 'zaxisInqPsName')
+        import c_char, c_int
+        integer(c_int), value :: zaxisID_dummy
+        character(kind = c_char) :: psname_dummy(*)
+      end subroutine lib_zaxisInqPsName
+    end interface
+    psname_temp(len(psname_dummy) + 1) = c_null_char
+    do psname_i = len(psname_dummy), 1, -1
+      if(psname_dummy(psname_i:psname_i) /= ' ') exit
+      psname_temp(psname_i) = c_null_char
+    end do
+    do psname_i = psname_i, 1, -1
+        psname_temp(psname_i) = psname_dummy(psname_i:psname_i)
+    end do
+    call lib_zaxisInqPsName(zaxisID_dummy, psname_temp)
+    do psname_i = 1, len(psname_dummy)
+      if(psname_temp(psname_i) == c_null_char) exit
+      psname_dummy(psname_i:psname_i) = psname_temp(psname_i)
+    end do
+    do psname_i = psname_i, len(psname_dummy)
+      psname_dummy(psname_i:psname_i) = ' '
+    end do
+  end subroutine zaxisInqPsName
+
+  function zaxisInqLbounds(zaxisID_dummy, lbounds) result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: zaxisID_dummy
+    real(c_double), target, optional, intent(inout) :: lbounds(*)
+    type(c_ptr) :: lbounds_cptr
+    interface
+      function lib_zaxisInqLbounds(zaxisID_dummy, lbounds) bind(c, name =&
+      & 'zaxisInqLbounds') result(c_result)
+        import c_int, c_ptr
+        integer(c_int) :: c_result
+        integer(c_int), value :: zaxisID_dummy
+        type(c_ptr), value :: lbounds
+      end function lib_zaxisInqLbounds
+    end interface
+    lbounds_cptr = c_null_ptr
+    if(present(lbounds)) lbounds_cptr = c_loc(lbounds)
+    f_result = lib_zaxisInqLbounds(zaxisID_dummy, lbounds_cptr)
+  end function zaxisInqLbounds
+
+  function zaxisInqUbounds(zaxisID_dummy, ubounds) result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: zaxisID_dummy
+    real(c_double), target, optional, intent(inout) :: ubounds(*)
+    type(c_ptr) :: ubounds_cptr
+    interface
+      function lib_zaxisInqUbounds(zaxisID_dummy, ubounds) bind(c, name =&
+      & 'zaxisInqUbounds') result(c_result)
+        import c_int, c_ptr
+        integer(c_int) :: c_result
+        integer(c_int), value :: zaxisID_dummy
+        type(c_ptr), value :: ubounds
+      end function lib_zaxisInqUbounds
+    end interface
+    ubounds_cptr = c_null_ptr
+    if(present(ubounds)) ubounds_cptr = c_loc(ubounds)
+    f_result = lib_zaxisInqUbounds(zaxisID_dummy, ubounds_cptr)
+  end function zaxisInqUbounds
+
+  function zaxisInqWeights(zaxisID_dummy, weights) result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: zaxisID_dummy
+    real(c_double), target, optional, intent(inout) :: weights(*)
+    type(c_ptr) :: weights_cptr
+    interface
+      function lib_zaxisInqWeights(zaxisID_dummy, weights) bind(c, name =&
+      & 'zaxisInqWeights') result(c_result)
+        import c_int, c_ptr
+        integer(c_int) :: c_result
+        integer(c_int), value :: zaxisID_dummy
+        type(c_ptr), value :: weights
+      end function lib_zaxisInqWeights
+    end interface
+    weights_cptr = c_null_ptr
+    if(present(weights)) weights_cptr = c_loc(weights)
+    f_result = lib_zaxisInqWeights(zaxisID_dummy, weights_cptr)
+  end function zaxisInqWeights
+
+  function tunitNamePtr(tunitID_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    integer(c_int), value :: tunitID_dummy
+    type(c_ptr) :: ptr
+    integer :: rv_shape(1)
+    interface
+      function lib_tunitNamePtr(tunitID_dummy) bind(c, name = 'tunitNamePtr')&
+      & result(c_result)
+        import c_int, c_ptr
+        type(c_ptr) :: c_result
+        integer(c_int), value :: tunitID_dummy
+      end function lib_tunitNamePtr
+    end interface
+    f_result => null()
+    ptr = lib_tunitNamePtr(tunitID_dummy)
+    if(c_associated(ptr)) then
+      rv_shape(1) = int(lib_strlen(ptr))
+      call c_f_pointer(ptr, f_result, rv_shape)
+    end if
+  end function tunitNamePtr
+
+  function institutDef(center_dummy, subcenter_dummy, name_dummy,&
+  & longname_dummy) result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: center_dummy
+    integer(c_int), value :: subcenter_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    character(kind = c_char, len = *), intent(in) :: longname_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    character(kind = c_char) :: longname_temp(len(longname_dummy) + 1)
+    integer :: longname_i
+    interface
+      function lib_institutDef(center_dummy, subcenter_dummy, name_dummy,&
+      & longname_dummy) bind(c, name = 'institutDef') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: center_dummy
+        integer(c_int), value :: subcenter_dummy
+        character(kind = c_char) :: name_dummy(*)
+        character(kind = c_char) :: longname_dummy(*)
+      end function lib_institutDef
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    do longname_i = 1, len(longname_dummy)
+      longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
+    end do
+    longname_temp(len(longname_dummy) + 1) = c_null_char
+    f_result = lib_institutDef(center_dummy, subcenter_dummy, name_temp,&
+    & longname_temp)
+  end function institutDef
+
+  function institutInq(center_dummy, subcenter_dummy, name_dummy,&
+  & longname_dummy) result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: center_dummy
+    integer(c_int), value :: subcenter_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    character(kind = c_char, len = *), intent(in) :: longname_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    character(kind = c_char) :: longname_temp(len(longname_dummy) + 1)
+    integer :: longname_i
+    interface
+      function lib_institutInq(center_dummy, subcenter_dummy, name_dummy,&
+      & longname_dummy) bind(c, name = 'institutInq') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: center_dummy
+        integer(c_int), value :: subcenter_dummy
+        character(kind = c_char) :: name_dummy(*)
+        character(kind = c_char) :: longname_dummy(*)
+      end function lib_institutInq
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    do longname_i = 1, len(longname_dummy)
+      longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
+    end do
+    longname_temp(len(longname_dummy) + 1) = c_null_char
+    f_result = lib_institutInq(center_dummy, subcenter_dummy, name_temp,&
+    & longname_temp)
+  end function institutInq
+
+  function institutInqNamePtr(instID_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    integer(c_int), value :: instID_dummy
+    type(c_ptr) :: ptr
+    integer :: rv_shape(1)
+    interface
+      function lib_institutInqNamePtr(instID_dummy) bind(c, name =&
+      & 'institutInqNamePtr') result(c_result)
+        import c_int, c_ptr
+        type(c_ptr) :: c_result
+        integer(c_int), value :: instID_dummy
+      end function lib_institutInqNamePtr
+    end interface
+    f_result => null()
+    ptr = lib_institutInqNamePtr(instID_dummy)
+    if(c_associated(ptr)) then
+      rv_shape(1) = int(lib_strlen(ptr))
+      call c_f_pointer(ptr, f_result, rv_shape)
+    end if
+  end function institutInqNamePtr
+
+  function institutInqLongnamePtr(instID_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    integer(c_int), value :: instID_dummy
+    type(c_ptr) :: ptr
+    integer :: rv_shape(1)
+    interface
+      function lib_institutInqLongnamePtr(instID_dummy) bind(c, name =&
+      & 'institutInqLongnamePtr') result(c_result)
+        import c_int, c_ptr
+        type(c_ptr) :: c_result
+        integer(c_int), value :: instID_dummy
+      end function lib_institutInqLongnamePtr
+    end interface
+    f_result => null()
+    ptr = lib_institutInqLongnamePtr(instID_dummy)
+    if(c_associated(ptr)) then
+      rv_shape(1) = int(lib_strlen(ptr))
+      call c_f_pointer(ptr, f_result, rv_shape)
+    end if
+  end function institutInqLongnamePtr
+
+  function modelDef(instID_dummy, modelgribID_dummy, name_dummy)&
+  & result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: instID_dummy
+    integer(c_int), value :: modelgribID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      function lib_modelDef(instID_dummy, modelgribID_dummy, name_dummy)&
+      & bind(c, name = 'modelDef') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: instID_dummy
+        integer(c_int), value :: modelgribID_dummy
+        character(kind = c_char) :: name_dummy(*)
+      end function lib_modelDef
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    f_result = lib_modelDef(instID_dummy, modelgribID_dummy, name_temp)
+  end function modelDef
+
+  function modelInq(instID_dummy, modelgribID_dummy, name_dummy)&
+  & result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: instID_dummy
+    integer(c_int), value :: modelgribID_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      function lib_modelInq(instID_dummy, modelgribID_dummy, name_dummy)&
+      & bind(c, name = 'modelInq') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: instID_dummy
+        integer(c_int), value :: modelgribID_dummy
+        character(kind = c_char) :: name_dummy(*)
+      end function lib_modelInq
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    f_result = lib_modelInq(instID_dummy, modelgribID_dummy, name_temp)
+  end function modelInq
+
+  function modelInqNamePtr(modelID_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    integer(c_int), value :: modelID_dummy
+    type(c_ptr) :: ptr
+    integer :: rv_shape(1)
+    interface
+      function lib_modelInqNamePtr(modelID_dummy) bind(c, name =&
+      & 'modelInqNamePtr') result(c_result)
+        import c_int, c_ptr
+        type(c_ptr) :: c_result
+        integer(c_int), value :: modelID_dummy
+      end function lib_modelInqNamePtr
+    end interface
+    f_result => null()
+    ptr = lib_modelInqNamePtr(modelID_dummy)
+    if(c_associated(ptr)) then
+      rv_shape(1) = int(lib_strlen(ptr))
+      call c_f_pointer(ptr, f_result, rv_shape)
+    end if
+  end function modelInqNamePtr
+
+  subroutine tableWriteC(filename_dummy, tableID_dummy)
+    character(kind = c_char, len = *), intent(in) :: filename_dummy
+    integer(c_int), value :: tableID_dummy
+    character(kind = c_char) :: filename_temp(len(filename_dummy) + 1)
+    integer :: filename_i
+    interface
+      subroutine lib_tableWriteC(filename_dummy, tableID_dummy) bind(c, name =&
+      & 'tableWriteC')
+        import c_char, c_int
+        character(kind = c_char) :: filename_dummy(*)
+        integer(c_int), value :: tableID_dummy
+      end subroutine lib_tableWriteC
+    end interface
+    do filename_i = 1, len(filename_dummy)
+      filename_temp(filename_i) = filename_dummy(filename_i:filename_i)
+    end do
+    filename_temp(len(filename_dummy) + 1) = c_null_char
+    call lib_tableWriteC(filename_temp, tableID_dummy)
+  end subroutine tableWriteC
+
+  subroutine tableWrite(filename_dummy, tableID_dummy)
+    character(kind = c_char, len = *), intent(in) :: filename_dummy
+    integer(c_int), value :: tableID_dummy
+    character(kind = c_char) :: filename_temp(len(filename_dummy) + 1)
+    integer :: filename_i
+    interface
+      subroutine lib_tableWrite(filename_dummy, tableID_dummy) bind(c, name =&
+      & 'tableWrite')
+        import c_char, c_int
+        character(kind = c_char) :: filename_dummy(*)
+        integer(c_int), value :: tableID_dummy
+      end subroutine lib_tableWrite
+    end interface
+    do filename_i = 1, len(filename_dummy)
+      filename_temp(filename_i) = filename_dummy(filename_i:filename_i)
+    end do
+    filename_temp(len(filename_dummy) + 1) = c_null_char
+    call lib_tableWrite(filename_temp, tableID_dummy)
+  end subroutine tableWrite
+
+  function tableRead(tablefile_dummy) result(f_result)
+    integer(c_int) :: f_result
+    character(kind = c_char, len = *), intent(in) :: tablefile_dummy
+    character(kind = c_char) :: tablefile_temp(len(tablefile_dummy) + 1)
+    integer :: tablefile_i
+    interface
+      function lib_tableRead(tablefile_dummy) bind(c, name = 'tableRead')&
+      & result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        character(kind = c_char) :: tablefile_dummy(*)
+      end function lib_tableRead
+    end interface
+    do tablefile_i = 1, len(tablefile_dummy)
+      tablefile_temp(tablefile_i) = tablefile_dummy(tablefile_i:tablefile_i)
+    end do
+    tablefile_temp(len(tablefile_dummy) + 1) = c_null_char
+    f_result = lib_tableRead(tablefile_temp)
+  end function tableRead
+
+  function tableDef(modelID_dummy, tablenum_dummy, tablename_dummy)&
+  & result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: modelID_dummy
+    integer(c_int), value :: tablenum_dummy
+    character(kind = c_char, len = *), intent(in) :: tablename_dummy
+    character(kind = c_char) :: tablename_temp(len(tablename_dummy) + 1)
+    integer :: tablename_i
+    interface
+      function lib_tableDef(modelID_dummy, tablenum_dummy, tablename_dummy)&
+      & bind(c, name = 'tableDef') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: modelID_dummy
+        integer(c_int), value :: tablenum_dummy
+        character(kind = c_char) :: tablename_dummy(*)
+      end function lib_tableDef
+    end interface
+    do tablename_i = 1, len(tablename_dummy)
+      tablename_temp(tablename_i) = tablename_dummy(tablename_i:tablename_i)
+    end do
+    tablename_temp(len(tablename_dummy) + 1) = c_null_char
+    f_result = lib_tableDef(modelID_dummy, tablenum_dummy, tablename_temp)
+  end function tableDef
+
+  function tableInqNamePtr(tableID_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    integer(c_int), value :: tableID_dummy
+    type(c_ptr) :: ptr
+    integer :: rv_shape(1)
+    interface
+      function lib_tableInqNamePtr(tableID_dummy) bind(c, name =&
+      & 'tableInqNamePtr') result(c_result)
+        import c_int, c_ptr
+        type(c_ptr) :: c_result
+        integer(c_int), value :: tableID_dummy
+      end function lib_tableInqNamePtr
+    end interface
+    f_result => null()
+    ptr = lib_tableInqNamePtr(tableID_dummy)
+    if(c_associated(ptr)) then
+      rv_shape(1) = int(lib_strlen(ptr))
+      call c_f_pointer(ptr, f_result, rv_shape)
+    end if
+  end function tableInqNamePtr
+
+  subroutine tableDefEntry(tableID_dummy, code_dummy, name_dummy,&
+  & longname_dummy, units_dummy)
+    integer(c_int), value :: tableID_dummy
+    integer(c_int), value :: code_dummy
+    character(kind = c_char, len = *), intent(in) :: name_dummy
+    character(kind = c_char, len = *), intent(in) :: longname_dummy
+    character(kind = c_char, len = *), intent(in) :: units_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    character(kind = c_char) :: longname_temp(len(longname_dummy) + 1)
+    integer :: longname_i
+    character(kind = c_char) :: units_temp(len(units_dummy) + 1)
+    integer :: units_i
+    interface
+      subroutine lib_tableDefEntry(tableID_dummy, code_dummy, name_dummy,&
+      & longname_dummy, units_dummy) bind(c, name = 'tableDefEntry')
+        import c_char, c_int
+        integer(c_int), value :: tableID_dummy
+        integer(c_int), value :: code_dummy
+        character(kind = c_char) :: name_dummy(*)
+        character(kind = c_char) :: longname_dummy(*)
+        character(kind = c_char) :: units_dummy(*)
+      end subroutine lib_tableDefEntry
+    end interface
+    do name_i = 1, len(name_dummy)
+      name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    name_temp(len(name_dummy) + 1) = c_null_char
+    do longname_i = 1, len(longname_dummy)
+      longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
+    end do
+    longname_temp(len(longname_dummy) + 1) = c_null_char
+    do units_i = 1, len(units_dummy)
+      units_temp(units_i) = units_dummy(units_i:units_i)
+    end do
+    units_temp(len(units_dummy) + 1) = c_null_char
+    call lib_tableDefEntry(tableID_dummy, code_dummy, name_temp, longname_temp,&
+    & units_temp)
+  end subroutine tableDefEntry
+
+  function tableInq(modelID_dummy, tablenum_dummy, tablename_dummy)&
+  & result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: modelID_dummy
+    integer(c_int), value :: tablenum_dummy
+    character(kind = c_char, len = *), intent(in) :: tablename_dummy
+    character(kind = c_char) :: tablename_temp(len(tablename_dummy) + 1)
+    integer :: tablename_i
+    interface
+      function lib_tableInq(modelID_dummy, tablenum_dummy, tablename_dummy)&
+      & bind(c, name = 'tableInq') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: modelID_dummy
+        integer(c_int), value :: tablenum_dummy
+        character(kind = c_char) :: tablename_dummy(*)
+      end function lib_tableInq
+    end interface
+    do tablename_i = 1, len(tablename_dummy)
+      tablename_temp(tablename_i) = tablename_dummy(tablename_i:tablename_i)
+    end do
+    tablename_temp(len(tablename_dummy) + 1) = c_null_char
+    f_result = lib_tableInq(modelID_dummy, tablenum_dummy, tablename_temp)
+  end function tableInq
+
+  subroutine tableInqPar(tableID_dummy, code_dummy, name_dummy, longname_dummy,&
+  & units_dummy)
+    integer(c_int), value :: tableID_dummy
+    integer(c_int), value :: code_dummy
+    character(kind = c_char, len = *), intent(inout) :: name_dummy
+    character(kind = c_char, len = *), intent(inout) :: longname_dummy
+    character(kind = c_char, len = *), intent(inout) :: units_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    character(kind = c_char) :: longname_temp(len(longname_dummy) + 1)
+    integer :: longname_i
+    character(kind = c_char) :: units_temp(len(units_dummy) + 1)
+    integer :: units_i
+    interface
+      subroutine lib_tableInqPar(tableID_dummy, code_dummy, name_dummy,&
+      & longname_dummy, units_dummy) bind(c, name = 'tableInqPar')
+        import c_char, c_int
+        integer(c_int), value :: tableID_dummy
+        integer(c_int), value :: code_dummy
+        character(kind = c_char) :: name_dummy(*)
+        character(kind = c_char) :: longname_dummy(*)
+        character(kind = c_char) :: units_dummy(*)
+      end subroutine lib_tableInqPar
+    end interface
+    name_temp(len(name_dummy) + 1) = c_null_char
+    do name_i = len(name_dummy), 1, -1
+      if(name_dummy(name_i:name_i) /= ' ') exit
+      name_temp(name_i) = c_null_char
+    end do
+    do name_i = name_i, 1, -1
+        name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    longname_temp(len(longname_dummy) + 1) = c_null_char
+    do longname_i = len(longname_dummy), 1, -1
+      if(longname_dummy(longname_i:longname_i) /= ' ') exit
+      longname_temp(longname_i) = c_null_char
+    end do
+    do longname_i = longname_i, 1, -1
+        longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
+    end do
+    units_temp(len(units_dummy) + 1) = c_null_char
+    do units_i = len(units_dummy), 1, -1
+      if(units_dummy(units_i:units_i) /= ' ') exit
+      units_temp(units_i) = c_null_char
+    end do
+    do units_i = units_i, 1, -1
+        units_temp(units_i) = units_dummy(units_i:units_i)
+    end do
+    call lib_tableInqPar(tableID_dummy, code_dummy, name_temp, longname_temp,&
+    & units_temp)
+    do name_i = 1, len(name_dummy)
+      if(name_temp(name_i) == c_null_char) exit
+      name_dummy(name_i:name_i) = name_temp(name_i)
+    end do
+    do name_i = name_i, len(name_dummy)
+      name_dummy(name_i:name_i) = ' '
+    end do
+    do longname_i = 1, len(longname_dummy)
+      if(longname_temp(longname_i) == c_null_char) exit
+      longname_dummy(longname_i:longname_i) = longname_temp(longname_i)
+    end do
+    do longname_i = longname_i, len(longname_dummy)
+      longname_dummy(longname_i:longname_i) = ' '
+    end do
+    do units_i = 1, len(units_dummy)
+      if(units_temp(units_i) == c_null_char) exit
+      units_dummy(units_i:units_i) = units_temp(units_i)
+    end do
+    do units_i = units_i, len(units_dummy)
+      units_dummy(units_i:units_i) = ' '
+    end do
+  end subroutine tableInqPar
+
+  function tableInqParCode(tableID_dummy, name_dummy, code_dummy)&
+  & result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: tableID_dummy
+    character(kind = c_char, len = *), intent(inout) :: name_dummy
+    integer(c_int), intent(inout) :: code_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      function lib_tableInqParCode(tableID_dummy, name_dummy, code_dummy)&
+      & bind(c, name = 'tableInqParCode') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: tableID_dummy
+        character(kind = c_char) :: name_dummy(*)
+        integer(c_int), intent(inout) :: code_dummy
+      end function lib_tableInqParCode
+    end interface
+    name_temp(len(name_dummy) + 1) = c_null_char
+    do name_i = len(name_dummy), 1, -1
+      if(name_dummy(name_i:name_i) /= ' ') exit
+      name_temp(name_i) = c_null_char
+    end do
+    do name_i = name_i, 1, -1
+        name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    f_result = lib_tableInqParCode(tableID_dummy, name_temp, code_dummy)
+    do name_i = 1, len(name_dummy)
+      if(name_temp(name_i) == c_null_char) exit
+      name_dummy(name_i:name_i) = name_temp(name_i)
+    end do
+    do name_i = name_i, len(name_dummy)
+      name_dummy(name_i:name_i) = ' '
+    end do
+  end function tableInqParCode
+
+  function tableInqParName(tableID_dummy, code_dummy, name_dummy)&
+  & result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: tableID_dummy
+    integer(c_int), value :: code_dummy
+    character(kind = c_char, len = *), intent(inout) :: name_dummy
+    character(kind = c_char) :: name_temp(len(name_dummy) + 1)
+    integer :: name_i
+    interface
+      function lib_tableInqParName(tableID_dummy, code_dummy, name_dummy)&
+      & bind(c, name = 'tableInqParName') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: tableID_dummy
+        integer(c_int), value :: code_dummy
+        character(kind = c_char) :: name_dummy(*)
+      end function lib_tableInqParName
+    end interface
+    name_temp(len(name_dummy) + 1) = c_null_char
+    do name_i = len(name_dummy), 1, -1
+      if(name_dummy(name_i:name_i) /= ' ') exit
+      name_temp(name_i) = c_null_char
+    end do
+    do name_i = name_i, 1, -1
+        name_temp(name_i) = name_dummy(name_i:name_i)
+    end do
+    f_result = lib_tableInqParName(tableID_dummy, code_dummy, name_temp)
+    do name_i = 1, len(name_dummy)
+      if(name_temp(name_i) == c_null_char) exit
+      name_dummy(name_i:name_i) = name_temp(name_i)
+    end do
+    do name_i = name_i, len(name_dummy)
+      name_dummy(name_i:name_i) = ' '
+    end do
+  end function tableInqParName
+
+  function tableInqParLongname(tableID_dummy, code_dummy, longname_dummy)&
+  & result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: tableID_dummy
+    integer(c_int), value :: code_dummy
+    character(kind = c_char, len = *), intent(inout) :: longname_dummy
+    character(kind = c_char) :: longname_temp(len(longname_dummy) + 1)
+    integer :: longname_i
+    interface
+      function lib_tableInqParLongname(tableID_dummy, code_dummy,&
+      & longname_dummy) bind(c, name = 'tableInqParLongname') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: tableID_dummy
+        integer(c_int), value :: code_dummy
+        character(kind = c_char) :: longname_dummy(*)
+      end function lib_tableInqParLongname
+    end interface
+    longname_temp(len(longname_dummy) + 1) = c_null_char
+    do longname_i = len(longname_dummy), 1, -1
+      if(longname_dummy(longname_i:longname_i) /= ' ') exit
+      longname_temp(longname_i) = c_null_char
+    end do
+    do longname_i = longname_i, 1, -1
+        longname_temp(longname_i) = longname_dummy(longname_i:longname_i)
+    end do
+    f_result = lib_tableInqParLongname(tableID_dummy, code_dummy,&
+    & longname_temp)
+    do longname_i = 1, len(longname_dummy)
+      if(longname_temp(longname_i) == c_null_char) exit
+      longname_dummy(longname_i:longname_i) = longname_temp(longname_i)
+    end do
+    do longname_i = longname_i, len(longname_dummy)
+      longname_dummy(longname_i:longname_i) = ' '
+    end do
+  end function tableInqParLongname
+
+  function tableInqParUnits(tableID_dummy, code_dummy, units_dummy)&
+  & result(f_result)
+    integer(c_int) :: f_result
+    integer(c_int), value :: tableID_dummy
+    integer(c_int), value :: code_dummy
+    character(kind = c_char, len = *), intent(inout) :: units_dummy
+    character(kind = c_char) :: units_temp(len(units_dummy) + 1)
+    integer :: units_i
+    interface
+      function lib_tableInqParUnits(tableID_dummy, code_dummy, units_dummy)&
+      & bind(c, name = 'tableInqParUnits') result(c_result)
+        import c_char, c_int
+        integer(c_int) :: c_result
+        integer(c_int), value :: tableID_dummy
+        integer(c_int), value :: code_dummy
+        character(kind = c_char) :: units_dummy(*)
+      end function lib_tableInqParUnits
+    end interface
+    units_temp(len(units_dummy) + 1) = c_null_char
+    do units_i = len(units_dummy), 1, -1
+      if(units_dummy(units_i:units_i) /= ' ') exit
+      units_temp(units_i) = c_null_char
+    end do
+    do units_i = units_i, 1, -1
+        units_temp(units_i) = units_dummy(units_i:units_i)
+    end do
+    f_result = lib_tableInqParUnits(tableID_dummy, code_dummy, units_temp)
+    do units_i = 1, len(units_dummy)
+      if(units_temp(units_i) == c_null_char) exit
+      units_dummy(units_i:units_i) = units_temp(units_i)
+    end do
+    do units_i = units_i, len(units_dummy)
+      units_dummy(units_i:units_i) = ' '
+    end do
+  end function tableInqParUnits
+
+  function tableInqParNamePtr(tableID_dummy, parID_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    integer(c_int), value :: tableID_dummy
+    integer(c_int), value :: parID_dummy
+    type(c_ptr) :: ptr
+    integer :: rv_shape(1)
+    interface
+      function lib_tableInqParNamePtr(tableID_dummy, parID_dummy) bind(c, name&
+      & = 'tableInqParNamePtr') result(c_result)
+        import c_int, c_ptr
+        type(c_ptr) :: c_result
+        integer(c_int), value :: tableID_dummy
+        integer(c_int), value :: parID_dummy
+      end function lib_tableInqParNamePtr
+    end interface
+    f_result => null()
+    ptr = lib_tableInqParNamePtr(tableID_dummy, parID_dummy)
+    if(c_associated(ptr)) then
+      rv_shape(1) = int(lib_strlen(ptr))
+      call c_f_pointer(ptr, f_result, rv_shape)
+    end if
+  end function tableInqParNamePtr
+
+  function tableInqParLongnamePtr(tableID_dummy, parID_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    integer(c_int), value :: tableID_dummy
+    integer(c_int), value :: parID_dummy
+    type(c_ptr) :: ptr
+    integer :: rv_shape(1)
+    interface
+      function lib_tableInqParLongnamePtr(tableID_dummy, parID_dummy) bind(c,&
+      & name = 'tableInqParLongnamePtr') result(c_result)
+        import c_int, c_ptr
+        type(c_ptr) :: c_result
+        integer(c_int), value :: tableID_dummy
+        integer(c_int), value :: parID_dummy
+      end function lib_tableInqParLongnamePtr
+    end interface
+    f_result => null()
+    ptr = lib_tableInqParLongnamePtr(tableID_dummy, parID_dummy)
+    if(c_associated(ptr)) then
+      rv_shape(1) = int(lib_strlen(ptr))
+      call c_f_pointer(ptr, f_result, rv_shape)
+    end if
+  end function tableInqParLongnamePtr
+
+  function tableInqParUnitsPtr(tableID_dummy, parID_dummy) result(f_result)
+    character(kind = c_char), dimension(:), pointer :: f_result
+    integer(c_int), value :: tableID_dummy
+    integer(c_int), value :: parID_dummy
+    type(c_ptr) :: ptr
+    integer :: rv_shape(1)
+    interface
+      function lib_tableInqParUnitsPtr(tableID_dummy, parID_dummy) bind(c, name&
+      & = 'tableInqParUnitsPtr') result(c_result)
+        import c_int, c_ptr
+        type(c_ptr) :: c_result
+        integer(c_int), value :: tableID_dummy
+        integer(c_int), value :: parID_dummy
+      end function lib_tableInqParUnitsPtr
+    end interface
+    f_result => null()
+    ptr = lib_tableInqParUnitsPtr(tableID_dummy, parID_dummy)
+    if(c_associated(ptr)) then
+      rv_shape(1) = int(lib_strlen(ptr))
+      call c_f_pointer(ptr, f_result, rv_shape)
+    end if
+  end function tableInqParUnitsPtr
+
+  subroutine streamDefHistory(streamID_dummy, size_dummy, history_dummy)
+    integer(c_int), value :: streamID_dummy
+    integer(c_int), value :: size_dummy
+    character(kind = c_char, len = *), intent(in) :: history_dummy
+    character(kind = c_char) :: history_temp(len(history_dummy) + 1)
+    integer :: history_i
+    interface
+      subroutine lib_streamDefHistory(streamID_dummy, size_dummy,&
+      & history_dummy) bind(c, name = 'streamDefHistory')
+        import c_char, c_int
+        integer(c_int), value :: streamID_dummy
+        integer(c_int), value :: size_dummy
+        character(kind = c_char) :: history_dummy(*)
+      end subroutine lib_streamDefHistory
+    end interface
+    do history_i = 1, len(history_dummy)
+      history_temp(history_i) = history_dummy(history_i:history_i)
+    end do
+    history_temp(len(history_dummy) + 1) = c_null_char
+    call lib_streamDefHistory(streamID_dummy, size_dummy, history_temp)
+  end subroutine streamDefHistory
+
+  subroutine streamInqHistoryString(streamID_dummy, history_dummy)
+    integer(c_int), value :: streamID_dummy
+    character(kind = c_char, len = *), intent(inout) :: history_dummy
+    character(kind = c_char) :: history_temp(len(history_dummy) + 1)
+    integer :: history_i
+    interface
+      subroutine lib_streamInqHistoryString(streamID_dummy, history_dummy)&
+      & bind(c, name = 'streamInqHistoryString')
+        import c_char, c_int
+        integer(c_int), value :: streamID_dummy
+        character(kind = c_char) :: history_dummy(*)
+      end subroutine lib_streamInqHistoryString
+    end interface
+    history_temp(len(history_dummy) + 1) = c_null_char
+    do history_i = len(history_dummy), 1, -1
+      if(history_dummy(history_i:history_i) /= ' ') exit
+      history_temp(history_i) = c_null_char
+    end do
+    do history_i = history_i, 1, -1
+        history_temp(history_i) = history_dummy(history_i:history_i)
+    end do
+    call lib_streamInqHistoryString(streamID_dummy, history_temp)
+    do history_i = 1, len(history_dummy)
+      if(history_temp(history_i) == c_null_char) exit
+      history_dummy(history_i:history_i) = history_temp(history_i)
+    end do
+    do history_i = history_i, len(history_dummy)
+      history_dummy(history_i:history_i) = ' '
+    end do
+  end subroutine streamInqHistoryString
 
 end module mo_cdi
diff --git a/libcdi/src/model.c b/libcdi/src/model.c
index fdd58e9..00b48ac 100644
--- a/libcdi/src/model.c
+++ b/libcdi/src/model.c
@@ -7,17 +7,18 @@
 #include "dmemory.h"
 #include "cdi.h"
 #include "cdi_int.h"
+#include "model.h"
+#include "namespace.h"
 #include "resource_handle.h"
 #include "resource_unpack.h"
-#include "namespace.h"
 #include "serialize.h"
 
 #undef  UNDEFID
 #define UNDEFID -1
 
-int ECHAM4 = UNDEFID;
-int ECHAM5 = UNDEFID;
-int COSMO  = UNDEFID;
+static int ECHAM4 = UNDEFID,
+  ECHAM5 = UNDEFID,
+  COSMO  = UNDEFID;
 
 typedef struct
 {
@@ -67,7 +68,7 @@ modelNewEntry(cdiResH resH, int instID, int modelgribID, const char *name)
 {
   model_t *modelptr;
 
-  modelptr = (model_t *) xmalloc(sizeof(model_t));
+  modelptr = (model_t *) Malloc(sizeof(model_t));
   modelDefaultValue ( modelptr );
   if (resH == CDI_UNDEFID)
     modelptr->self = reshPut(modelptr, &modelOps);
@@ -134,7 +135,7 @@ void modelInit(void)
 
 struct modelLoc
 {
-  char *name;
+  const char *name;
   int instID, modelgribID, resID;
 };
 
@@ -179,7 +180,7 @@ findModelByName(int resID, void *res, void *data)
   return CDI_APPLY_GO_ON;
 }
 
-int modelInq(int instID, int modelgribID, char *name)
+int modelInq(int instID, int modelgribID, const char *name)
 {
   modelInit ();
 
@@ -248,7 +249,7 @@ const char *modelInqNamePtr(int modelID)
 static int
 modelCompareP(void *modelptr1, void *modelptr2)
 {
-  model_t *model1 = modelptr1, *model2 = modelptr2;
+  model_t *model1 = (model_t *)modelptr1, *model2 = (model_t *)modelptr2;
   int diff = (namespaceResHDecode(model1->instID).idx
               != namespaceResHDecode(model2->instID).idx)
     | (model1->modelgribID != model2->modelgribID)
@@ -261,8 +262,8 @@ void modelDestroyP ( void * modelptr )
 {
   model_t *mp = (model_t*) modelptr;
   if (mp->name)
-    free(mp->name);
-  free(mp);
+    Free(mp->name);
+  Free(mp);
 }
 
 
@@ -326,22 +327,24 @@ modelUnpack(void *buf, int size, int *position, int originNamespace, void *conte
   serializeUnpack(buf, size, position, tempbuf, model_nints, DATATYPE_INT, context);
   if (tempbuf[3] != 0)
     {
-      name = (char *)xmalloc((size_t)tempbuf[3]);
+      name = (char *) Malloc((size_t)tempbuf[3]);
       serializeUnpack(buf, size, position,
                       name, tempbuf[3], DATATYPE_TXT, context);
     }
   else
     {
-      name = "";
+      name = (char*)"";
     }
   int targetID = namespaceAdaptKey(tempbuf[0], originNamespace);
   model_t *mp = modelNewEntry(force_id?targetID:CDI_UNDEFID,
                               namespaceAdaptKey(tempbuf[1], originNamespace),
                               tempbuf[2], name);
   if (tempbuf[3] != 0)
-    free(name);
+    Free(name);
   xassert(!force_id
           || (mp->self == namespaceAdaptKey(tempbuf[0], originNamespace)));
+  reshSetStatus(mp->self, &modelOps,
+                reshGetStatus(mp->self, &modelOps) & ~RESH_SYNC_BIT);
   return mp->self;
 }
 
diff --git a/libcdi/src/namespace.c b/libcdi/src/namespace.c
index c850c52..6232cad 100644
--- a/libcdi/src/namespace.c
+++ b/libcdi/src/namespace.c
@@ -46,8 +46,9 @@ static int activeNamespace = 0;
     { .func = (void (*)()) fileClose_serial },              \
     { .func = (void (*)()) cdiStreamOpenDefaultDelegate },  \
     { .func = (void (*)()) cdiStreamDefVlist_ },            \
+    { .func = (void (*)()) cdiStreamSetupVlist_ },          \
     { .func = (void (*)()) cdiStreamWriteVar_ },            \
-    { .func = (void (*)()) cdiStreamwriteVarChunk_ },       \
+    { .func = (void (*)()) cdiStreamWriteVarChunk_ },       \
     { .func = (void (*)()) 0 },                             \
     { .func = (void (*)()) 0 },                             \
     { .func = (void (*)()) cdiStreamCloseDefaultDelegate }, \
@@ -56,17 +57,22 @@ static int activeNamespace = 0;
     CDI_NETCDF_SWITCHES                        \
     }
 
-#if defined (SX)
+#if defined (SX) || defined (__cplusplus)
 static const union namespaceSwitchValue
   defaultSwitches_[NUM_NAMESPACE_SWITCH] = defaultSwitches;
 #endif
 
+enum namespaceStatus {
+  NAMESPACE_STATUS_INUSE,
+  NAMESPACE_STATUS_UNUSED,
+};
+
 static struct Namespace
 {
-  statusCode resStage;
+  enum namespaceStatus resStage;
   union namespaceSwitchValue switches[NUM_NAMESPACE_SWITCH];
 } initialNamespace = {
-  .resStage = STAGE_DEFINITION,
+  .resStage = NAMESPACE_STATUS_INUSE,
   .switches = defaultSwitches
 };
 
@@ -109,7 +115,7 @@ enum {
   intbits = sizeof(int) * CHAR_BIT,
   nspbits = 4,
   idxbits = intbits - nspbits,
-  nspmask = (( 1 << nspbits ) - 1) << idxbits,
+  nspmask = (int)((( (unsigned)1 << nspbits ) - 1) << idxbits),
   idxmask = ( 1 << idxbits ) - 1,
 };
 
@@ -152,7 +158,7 @@ namespaceNew()
     {
       /* namespace is already available and only needs reinitialization */
       for (unsigned i = 0; i < namespacesSize; ++i)
-        if (namespaces[i].resStage == STAGE_UNUSED)
+        if (namespaces[i].resStage == NAMESPACE_STATUS_UNUSED)
           {
             newNamespaceID = (int)i;
             break;
@@ -162,7 +168,7 @@ namespaceNew()
     {
       /* make room for additional namespace */
       struct Namespace *newNameSpaces
-        = (struct Namespace *)xmalloc(((size_t)namespacesSize + 1) * sizeof (namespaces[0]));
+        = (struct Namespace *) Malloc(((size_t)namespacesSize + 1) * sizeof (namespaces[0]));
       memcpy(newNameSpaces, namespaces, sizeof (namespaces[0]));
       namespaces = newNameSpaces;
       ++namespacesSize;
@@ -173,7 +179,7 @@ namespaceNew()
       /* make room for additional namespace */
       newNamespaceID = (int)namespacesSize;
       namespaces
-        = (struct Namespace *)xrealloc(namespaces, ((size_t)namespacesSize + 1) * sizeof (namespaces[0]));
+        = (struct Namespace *) Realloc(namespaces, ((size_t)namespacesSize + 1) * sizeof (namespaces[0]));
       ++namespacesSize;
     }
   else /* implicit: namespacesSize >= NUM_NAMESPACES */
@@ -183,15 +189,15 @@ namespaceNew()
     }
   xassert(newNamespaceID >= 0 && newNamespaceID < NUM_NAMESPACES);
   ++nNamespaces;
-  namespaces[newNamespaceID].resStage = STAGE_DEFINITION;
-#if defined (SX)
+  namespaces[newNamespaceID].resStage = NAMESPACE_STATUS_INUSE;
+#if defined (SX) || defined (__cplusplus)
   memcpy(namespaces[newNamespaceID].switches,
          defaultSwitches_,
          sizeof (namespaces[newNamespaceID].switches));
 #else
-  memcpy(namespaces[newNamespaceID].switches,
-         (union namespaceSwitchValue[NUM_NAMESPACE_SWITCH])defaultSwitches,
-         sizeof (namespaces[newNamespaceID].switches));
+    memcpy(namespaces[newNamespaceID].switches,
+           (union namespaceSwitchValue[NUM_NAMESPACE_SWITCH])defaultSwitches,
+           sizeof (namespaces[newNamespaceID].switches));
 #endif
   reshListCreate(newNamespaceID);
   NAMESPACE_UNLOCK();
@@ -206,7 +212,7 @@ namespaceDelete(int namespaceID)
   xassert(namespaceID >= 0 && (unsigned)namespaceID < namespacesSize
           && nNamespaces);
   reshListDestruct(namespaceID);
-  namespaces[namespaceID].resStage = STAGE_UNUSED;
+  namespaces[namespaceID].resStage = NAMESPACE_STATUS_UNUSED;
   --nNamespaces;
   NAMESPACE_UNLOCK();
 }
@@ -220,7 +226,7 @@ int namespaceGetNumber ()
 void namespaceSetActive ( int nId )
 {
   xassert((unsigned)nId < namespacesSize
-          && namespaces[nId].resStage != STAGE_UNUSED);
+          && namespaces[nId].resStage != NAMESPACE_STATUS_UNUSED);
   activeNamespace = nId;
 }
 
@@ -263,20 +269,6 @@ int namespaceAdaptKey2 ( int originResH )
   return namespaceIdxEncode2 ( nsp, tin.idx );
 }
 
-
-void namespaceDefResStatus ( statusCode argResStatus )
-{
-  int nsp = namespaceGetActive ();
-  namespaces[nsp].resStage = argResStatus;
-}
-
-
-statusCode namespaceInqResStatus ( void )
-{
-  int nsp = namespaceGetActive ();
-  return namespaces[nsp].resStage;
-}
-
 void namespaceSwitchSet(enum namespaceSwitch sw, union namespaceSwitchValue value)
 {
   xassert(sw > NSSWITCH_NO_SUCH_SWITCH && sw < NUM_NAMESPACE_SWITCH);
@@ -296,16 +288,16 @@ void cdiReset(void)
   NAMESPACE_INIT();
   NAMESPACE_LOCK();
   for (unsigned namespaceID = 0; namespaceID < namespacesSize; ++namespaceID)
-    if (namespaces[namespaceID].resStage != STAGE_UNUSED)
+    if (namespaces[namespaceID].resStage != NAMESPACE_STATUS_UNUSED)
       namespaceDelete((int)namespaceID);
   if (namespaces != &initialNamespace)
     {
-      free(namespaces);
+      Free(namespaces);
       namespaces = &initialNamespace;
+      namespaces[0].resStage = NAMESPACE_STATUS_UNUSED;
     }
   namespacesSize = 1;
-  nNamespaces = 1;
-  activeNamespace = 0;
+  nNamespaces = 0;
   NAMESPACE_UNLOCK();
 }
 
diff --git a/libcdi/src/namespace.h b/libcdi/src/namespace.h
index 79847ce..436a759 100644
--- a/libcdi/src/namespace.h
+++ b/libcdi/src/namespace.h
@@ -6,13 +6,6 @@
 #endif
 
 
-typedef enum {
-  STAGE_DEFINITION = 0,
-  STAGE_TIMELOOP   = 1,
-  STAGE_CLEANUP    = 2,
-  STAGE_UNUSED     = 3,
-} statusCode;
-
 typedef struct {
   int idx;
   int nsp;
@@ -31,6 +24,7 @@ enum namespaceSwitch
   NSSWITCH_FILE_CLOSE,
   NSSWITCH_STREAM_OPEN_BACKEND,
   NSSWITCH_STREAM_DEF_VLIST_,
+  NSSWITCH_STREAM_SETUP_VLIST,
   NSSWITCH_STREAM_WRITE_VAR_,
   NSSWITCH_STREAM_WRITE_VAR_CHUNK_,
   NSSWITCH_STREAM_WRITE_VAR_PART_,
@@ -56,19 +50,17 @@ union namespaceSwitchValue
 #define NSSW_FUNC(p) ((union namespaceSwitchValue){ .func = (void (*)())(p) })
 #define NSSW_DATA(p) ((union namespaceSwitchValue){ .data = (void *)(p) })
 
-int              namespaceNew();
-void             namespaceDelete(int namespaceID);
+//int              namespaceNew();
+//void             namespaceDelete(int namespaceID);
 void             namespaceCleanup      ( void );
 int              namespaceGetNumber    ( void );
-void namespaceSetActive(int namespaceID);
+//void             namespaceSetActive(int namespaceID);
 int              namespaceGetActive    ( void );
 int              namespaceIdxEncode    ( namespaceTuple_t );
 int              namespaceIdxEncode2   ( int, int );
 namespaceTuple_t namespaceResHDecode   ( int );
 int              namespaceAdaptKey     ( int originResH, int originNamespace);
 int              namespaceAdaptKey2    ( int );
-void             namespaceDefResStatus ( statusCode );
-statusCode       namespaceInqResStatus ( void );
 void namespaceSwitchSet(enum namespaceSwitch sw,
                         union namespaceSwitchValue value);
 union namespaceSwitchValue namespaceSwitchGet(enum namespaceSwitch sw);
diff --git a/libcdi/src/pio.c b/libcdi/src/pio.c
index b440c8d..1abdc6d 100644
--- a/libcdi/src/pio.c
+++ b/libcdi/src/pio.c
@@ -2,22 +2,10 @@
 #include "config.h"
 #endif
 
-
-#include <ctype.h>
-#include <yaxt.h>
-
-#include "file.h"
 #include "cdi_int.h"
-#include "namespace.h"
-
 #include "pio.h"
-#include "cdi.h"
 #include "cdipio.h"
-#include "pio_comm.h"
 #include "pio_impl.h"
-#include "pio_interface.h"
-#include "pio_rpc.h"
-#include "pio_util.h"
 
 const char *const cdiPioCmdStrTab[] = {
   "IO_Open_file",
@@ -28,147 +16,6 @@ const char *const cdiPioCmdStrTab[] = {
   "IO_Finalize"
 };
 
-char *token = "%";
-
-/***************************************************************/
-
-size_t
-cdiPioFileWrite(int fileID, const void *restrict buffer, size_t len, int tsID)
-{
-  size_t iret = 0;
-
-  switch ( commInqIOMode ())
-    {
-    case PIO_MPI:
-      iret = fwMPINONB ( fileID, tsID, buffer, len );
-      break;
-#ifndef _SX
-    case PIO_ASYNCH:
-#endif
-    case PIO_WRITER:
-      iret = pioSendWrite(fileID, tsID, buffer, len);
-      break;
-    case PIO_FPGUARD:
-      iret = fwPOSIXFPGUARDSENDRECV ( fileID, tsID, buffer, len );
-      break;
-    }
-
-  return iret;
-}
-
-/***************************************************************/
-
-int pioFileClose ( int id )
-{
-  int iret = CDI_UNDEFID;
-  switch ( commInqIOMode ())
-    {
-    case PIO_MPI:
-      iret = fcMPINONB ( id );
-      break;
-#ifndef _SX
-    case PIO_ASYNCH:
-#endif
-    case PIO_WRITER:
-      iret = pioSendClose(id);
-      break;
-    case PIO_FPGUARD:
-      iret = fcPOSIXFPGUARDSENDRECV ( id );
-      break;
-    }
-
-  return iret;
-}
-
-/***************************************************************/
-
-int pioFileOpen(const char *filename, const char *mode)
-{
-  int iret = CDI_UNDEFID;
-
-  if ((mode[0] != 'w' && mode[0] != 'W') || mode[0] == 0 || mode[1] != 0)
-    xabort("Unsupported mode \"%s\" in parallel file open.", mode);
-
-  switch ( commInqIOMode ())
-    {
-    case PIO_MPI:
-      iret = fowMPINONB ( filename );
-      break;
-#ifndef _SX
-    case PIO_ASYNCH:
-#endif
-    case PIO_WRITER:
-      iret = pioSendOpen(filename);
-      break;
-    case PIO_FPGUARD:
-      iret = fowPOSIXFPGUARDSENDRECV ( filename );
-      break;
-    }
-
-  return iret;
-}
-
-/***************************************************************/
-
-void cdiPioFileWritingInit(void (*postCommSetupActions)(void))
-{
-  int IOMode = commInqIOMode ();
-
-  commDefCommNode ();
-
-  xassert ( IOMode != PIO_NONE  || commInqSizeNode () == 1 );
-
-  switch ( IOMode )
-    {
-    case PIO_NONE:
-      commDefCommColl ( 1 );
-      commSendNodeInfo ();
-      commRecvNodeMap ();
-      commDefCommsIO ();
-      break;
-    case PIO_MPI:
-      initMPINONB(postCommSetupActions);
-      break;
-#ifndef _SX
-    case PIO_ASYNCH:
-#endif
-    case PIO_WRITER:
-      pioSendInitialize(postCommSetupActions);
-      break;
-    case PIO_FPGUARD:
-      initPOSIXFPGUARDSENDRECV(postCommSetupActions);
-      break;
-    }
-}
-
-/***************************************************************/
-
-void cdiPioFileWritingFinalize(void)
-{
-  int IOMode = commInqIOMode ();
-  switch ( IOMode )
-    {
-    case PIO_NONE:
-      break;
-    case PIO_MPI:
-      finalizeMPINONB ();
-      break;
-#ifndef _SX
-    case PIO_ASYNCH:
-#endif
-    case PIO_WRITER:
-      pioSendFinalize();
-      break;
-    case PIO_FPGUARD:
-      finalizePOSIXFPGUARDSENDRECV ();
-      break;
-    default:
-      xdebug("%s", " BACKENDCLEANUP FUNCTION NOT IMPLEMENTED YET.");
-    }
-}
-
-/***************************************************************/
-
 /*
  * Local Variables:
  * c-file-style: "Java"
diff --git a/libcdi/src/pio.h b/libcdi/src/pio.h
index b317ed1..be4aa5c 100644
--- a/libcdi/src/pio.h
+++ b/libcdi/src/pio.h
@@ -8,14 +8,8 @@
 #include <stdlib.h>
 #include <mpi.h>
 
-#include "cdi_int.h"
 
-void cdiPioFileWritingInit(void (*postCommSetupActions)(void));
-void cdiPioFileWritingFinalize(void);
-int pioFileOpen(const char *filename, const char *mode);
-int    pioFileClose    ( int );
-size_t cdiPioFileWrite(int fileID, const void *restrict buffer, size_t len,
-                       int tsID);
+extern void (*cdiPioFileWritingFinalize)(void);
 
 #endif
 /*
diff --git a/libcdi/src/pio_cdf_int.c b/libcdi/src/pio_cdf_int.c
index 4215629..fa08a0c 100644
--- a/libcdi/src/pio_cdf_int.c
+++ b/libcdi/src/pio_cdf_int.c
@@ -57,13 +57,13 @@ cdiPioCdfDefVar(int ncid, const char *name, nc_type xtype, int ndims,
 }
 
 void
-cdiPioEnableNetCDFParAccess()
+cdiPioEnableNetCDFParAccess(void)
 {
   namespaceSwitchSet(NSSWITCH_NC__CREATE, NSSW_FUNC(cdiPio_nc__create));
   namespaceSwitchSet(NSSWITCH_CDF_DEF_VAR, NSSW_FUNC(cdiPioCdfDefVar));
 }
 
-#endif
+#endif  /* defined (HAVE_NETCDF4) && defined (HAVE_PARALLEL_NC4) */
 /*
  * Local Variables:
  * c-file-style: "Java"
diff --git a/libcdi/src/pio_cdf_int.h b/libcdi/src/pio_cdf_int.h
index 741c659..d25a700 100644
--- a/libcdi/src/pio_cdf_int.h
+++ b/libcdi/src/pio_cdf_int.h
@@ -9,7 +9,17 @@
 #include "cdf_int.h"
 
 void
-cdiPioEnableNetCDFParAccess();
+cdiPioEnableNetCDFParAccess(void);
 
 #endif
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/pio_client.c b/libcdi/src/pio_client.c
index f980c4f..a8249d7 100644
--- a/libcdi/src/pio_client.c
+++ b/libcdi/src/pio_client.c
@@ -6,6 +6,9 @@
 
 #include <yaxt.h>
 
+#include "cdi.h"
+#include "cdi_int.h"
+#include "dmemory.h"
 #include "namespace.h"
 #include "taxis.h"
 
@@ -18,82 +21,105 @@
 #include "pio_util.h"
 #include "pio_serialize.h"
 
-static void
-nullPackFunc(void *obj, void *buf, int size, int *pos, void *context)
-{
-  (void)obj; (void)buf; (void)size; (void)pos; (void)context;
-}
-
-
 static int
-cdiPioClientStreamOpen(const char *filename, const char *filemode,
+cdiPioClientStreamOpen(const char *filename, char filemode,
                        int filetype, stream_t *streamptr,
                        int recordBufIsToBeCreated)
 {
-  struct winHeaderEntry header;
-  size_t filename_len;
   (void)streamptr; (void)recordBufIsToBeCreated;
-  if ( tolower ( * filemode ) == 'w' )
+  int fileID;
+  if ( filemode == 'w' )
     {
-      statusCode nspStatus = namespaceInqResStatus ();
-      switch ( nspStatus )
+      MPI_Comm comm = cdiPioInqInterComm();
+      int clientRank = commInqRankModel(),
+        numClients = cdiPioCommInqSizeClients(),
+        numColl = commInqSizeColl(),
+        collRank = cdiPioCollRank(clientRank, numClients, numColl);
+      int streamID = streamptr->self;
+      if (clientRank
+          == cdiPioClientRangeStart(collRank, numClients, numColl))
+        {
+          reshSetStatus(streamID, &streamOps,
+                        reshGetStatus(streamID, &streamOps)
+                        & ~RESH_SYNC_BIT);
+          char *msgBuffer;
+          int msgSize = 0;
+          int msgBufPos = reshPackBufferCreate(&msgBuffer, &msgSize, &comm);
+          int size;
+          size_t filename_len = strlen(filename);
+          xassert(filename_len < (size_t)(INT_MAX - msgBufPos));
+          int soHdr[3] = { streamptr->self, filetype, (int)filename_len };
+          xmpi(MPI_Pack_size(3, MPI_INT, comm, &size));
+          msgSize += size;
+          xmpi(MPI_Pack_size(1, MPI_CHAR, comm, &size));
+          msgSize += size;
+          xmpi(MPI_Pack_size((int)filename_len, MPI_CHAR, comm, &size));
+          msgSize += size;
+          /* optimize to pos + size */
+          msgBuffer = (char *)Realloc(msgBuffer, (size_t)msgSize);
+          xmpi(MPI_Pack(soHdr, 3, MPI_INT,
+                        msgBuffer, msgSize, &msgBufPos, comm));
+          xmpi(MPI_Pack(&filemode, 1, MPI_CHAR,
+                        msgBuffer, msgSize, &msgBufPos, comm));
+          xmpi(MPI_Pack((void *)filename, (int)filename_len, MPI_CHAR,
+                        msgBuffer, msgSize, &msgBufPos, comm));
+          xmpi(MPI_Sendrecv(msgBuffer, msgSize, MPI_PACKED, collRank,
+                            STREAMOPEN,
+                            &fileID, 1, MPI_INT, collRank, STREAMOPEN,
+                            comm, MPI_STATUS_IGNORE));
+          Free(msgBuffer);
+        }
+      else
+        xmpi(MPI_Recv(&fileID, 1, MPI_INT, collRank, STREAMOPEN,
+                      comm, MPI_STATUS_IGNORE));
+      if (fileID >= 0)
         {
-        case STAGE_DEFINITION:
-          streamptr->filetype = filetype;
-          break;
-        case STAGE_TIMELOOP:
-          filename_len = strlen(filename);
-          xassert(filename_len > 0 && filename_len < MAXDATAFILENAME);
-          header = (struct winHeaderEntry){
-            .id = STREAMOPEN,
-            .specific.funcArgs.newFile
-            = { .fnamelen = (int)filename_len,
-                .filetype = filetype } };
-          pioBufferFuncCall(header,
-                            &(struct memCpyDataDesc){filename,
-                                filename_len + 1}, memcpyPackFunc);
-          xdebug("WROTE FUNCTION CALL IN BUFFER OF WINS:  %s, filenamesz=%zu,"
-                 " filename=%s, filetype=%d",
-                 funcMap[(-1 - STREAMOPEN)], filename_len + 1, filename,
-                 filetype);
           streamptr->filetype = filetype;
-          break;
-        case STAGE_CLEANUP:
-          xabort ( "TRANSITION TO IO PROCESSES ALREADY FINISHED." );
-          break;
-        default:
-          xabort ( "INTERNAL ERROR" );
+          cdiPioClientStreamWinInit(streamID);
         }
     }
   else
     Error("cdiPIO read support not implemented");
-  return 1;
+  return fileID;
 }
 
 static void
 cdiPioClientStreamDefVlist_(int streamID, int vlistID)
 {
-  struct winHeaderEntry header;
-  statusCode nspStatus = namespaceInqResStatus ();
-  switch ( nspStatus )
+  cdiStreamDefVlist_(streamID, vlistID);
+  int clientRank = commInqRankModel(),
+    numClients = cdiPioCommInqSizeClients(),
+    numColl = commInqSizeColl(),
+    collRank = cdiPioCollRank(clientRank, numClients, numColl);
+  int sendRPCData
+    = (clientRank
+       == cdiPioClientRangeStart(collRank, numClients, numColl));
+  if (sendRPCData)
     {
-    case STAGE_DEFINITION:
-      break;
-    case STAGE_TIMELOOP:
-      header = (struct winHeaderEntry){
-        .id = STREAMDEFVLIST,
-        .specific.funcArgs.streamChange = { streamID, vlistID } };
-      pioBufferFuncCall(header, NULL, nullPackFunc);
-      xdebug("WROTE FUNCTION CALL IN BUFFER OF WINS:  %s, streamID=%d,"
-             " vlistID=%d", funcMap[(-1 - STREAMDEFVLIST)], streamID, vlistID);
-      break;
-    case STAGE_CLEANUP:
-      xabort ( "TRANSITION TO IO PROCESSES ALREADY FINISHED." );
-      break;
-    default:
-      xabort ( "INTERNAL ERROR" );
+      MPI_Comm comm = cdiPioInqInterComm();
+      reshSetStatus(streamID, &streamOps,
+                    reshGetStatus(streamID, &streamOps) & ~RESH_SYNC_BIT);
+      char *msgBuffer;
+      int msgSize = 0;
+      int msgBufPos = reshPackBufferCreate(&msgBuffer, &msgSize, &comm);
+      {
+        int size;
+        xmpi(MPI_Pack_size(defVlistNInts, MPI_INT, comm, &size));
+        msgSize += size;
+      }
+      /* optimize: pos + size */
+      msgBuffer = Realloc(msgBuffer, (size_t)msgSize);
+      int msgData[defVlistNInts] = { streamID, streamInqVlist(streamID) };
+      xmpi(MPI_Pack(&msgData, defVlistNInts, MPI_INT,
+                    msgBuffer, msgSize, &msgBufPos, comm));
+      xmpi(MPI_Send(msgBuffer, msgBufPos, MPI_PACKED, collRank,
+                    STREAMDEFVLIST, comm));
+      Free(msgBuffer);
     }
-  cdiStreamDefVlist_(streamID, vlistID);
+  struct collSpec cspec = { .numClients = numClients,
+                            .numServers = numColl,
+                            .sendRPCData = sendRPCData };
+  cdiPioClientStreamWinCreate(streamID, &cspec);
 }
 
 static void
@@ -136,20 +162,7 @@ static void
 cdiPioClientStreamWriteVarPart(int streamID, int varID, const void *data,
                                int nmiss, Xt_idxlist partDesc)
 {
-  switch (namespaceInqResStatus())
-    {
-    case STAGE_DEFINITION:
-      xabort("DEFINITION STAGE: PARALLEL WRITING NOT POSSIBLE.");
-      break;
-    case STAGE_TIMELOOP:
-      pioBufferPartData(streamID, varID, data, nmiss, partDesc);
-      return;
-    case STAGE_CLEANUP:
-      xabort("CLEANUP STAGE: PARALLEL WRITING NOT POSSIBLE.");
-      break;
-    default:
-      xabort("INTERNAL ERROR");
-    }
+  pioBufferPartData(streamID, varID, data, nmiss, partDesc);
 }
 
 static void
@@ -159,21 +172,8 @@ cdiPioClientStreamWriteScatteredVarPart(int streamID, int varID,
                                         const int displacements[],
                                         int nmiss, Xt_idxlist partDesc)
 {
-  switch (namespaceInqResStatus())
-    {
-    case STAGE_DEFINITION:
-      xabort("DEFINITION STAGE: PARALLEL WRITING NOT POSSIBLE.");
-      break;
-    case STAGE_TIMELOOP:
-      cdiPioBufferPartDataGather(streamID, varID, data, numBlocks,
-                                 blocklengths, displacements, nmiss, partDesc);
-      return;
-    case STAGE_CLEANUP:
-      xabort("CLEANUP STAGE: PARALLEL WRITING NOT POSSIBLE.");
-      break;
-    default:
-      xabort("INTERNAL ERROR");
-    }
+  cdiPioBufferPartDataGather(streamID, varID, data, numBlocks,
+                             blocklengths, displacements, nmiss, partDesc);
 }
 
 #if defined HAVE_LIBNETCDF
@@ -194,27 +194,35 @@ cdiPioClientStreamNOP(stream_t *streamptr)
 static void
 cdiPioClientStreamClose(stream_t *streamptr, int recordBufIsToBeDeleted)
 {
-  struct winHeaderEntry header;
-  statusCode nspStatus = namespaceInqResStatus ();
   (void)recordBufIsToBeDeleted;
-  switch ( nspStatus )
+  int streamID = streamptr->self;
+  int clientRank = commInqRankModel(),
+    numClients = cdiPioCommInqSizeClients(),
+    numColl = commInqSizeColl(),
+    collRank = cdiPioCollRank(clientRank, numClients, numColl);
+  if (clientRank
+      == cdiPioClientRangeStart(collRank, numClients, numColl))
     {
-    case STAGE_DEFINITION:
-      break;
-    case STAGE_TIMELOOP:
-      header = (struct winHeaderEntry){
-        .id = STREAMCLOSE,
-        .specific.funcArgs.streamChange
-        = { streamptr->self, CDI_UNDEFID } };
-      pioBufferFuncCall(header, NULL, nullPackFunc);
-      xdebug("WROTE FUNCTION CALL IN BUFFER OF WINS:  %s, streamID=%d",
-             funcMap[-1 - STREAMCLOSE], streamptr->self);
-      break;
-    case STAGE_CLEANUP:
-      break;
-    default:
-      xabort ( "INTERNAL ERROR" );
+      MPI_Comm comm = cdiPioInqInterComm();
+      reshSetStatus(streamID, &streamOps,
+                    reshGetStatus(streamID, &streamOps) & ~RESH_SYNC_BIT);
+      char *msgBuffer;
+      int msgSize = 0;
+      int msgBufPos = reshPackBufferCreate(&msgBuffer, &msgSize, &comm);
+      {
+        int size;
+        xmpi(MPI_Pack_size(1, MPI_INT, comm, &size));
+        msgSize += size;
+      }
+      /* optimize: pos + size */
+      msgBuffer = Realloc(msgBuffer, (size_t)msgSize);
+      xmpi(MPI_Pack(&streamptr->self, 1, MPI_INT,
+                    msgBuffer, msgSize, &msgBufPos, comm));
+      xmpi(MPI_Send(msgBuffer, msgBufPos, MPI_PACKED, collRank,
+                    STREAMCLOSE, comm));
+      Free(msgBuffer);
     }
+  cdiPioClientStreamWinDestroy(streamID);
 }
 
 static void
@@ -228,38 +236,25 @@ cdiPioTaxisPackWrap(void *data, void *buf, int size, int *pos,
 static int
 cdiPioClientStreamDefTimestep_(stream_t *streamptr, int tsID)
 {
-  struct winHeaderEntry header;
-  statusCode nspStatus = namespaceInqResStatus ();
-  int taxisID;
-  switch ( nspStatus )
-    {
-    case STAGE_DEFINITION:
-      break;
-    case STAGE_TIMELOOP:
-      taxisID = vlistInqTaxis(streamptr->vlistID);
-      header = (struct winHeaderEntry){
-        .id = STREAMDEFTIMESTEP,
-        .specific.funcArgs.streamNewTimestep = { streamptr->self, tsID } };
-      xassert(sizeof (void *) >= sizeof (int));
-      pioBufferFuncCall(header, (void *)(intptr_t)taxisID, cdiPioTaxisPackWrap);
-      break;
-    case STAGE_CLEANUP:
-      break;
-    default:
-      xabort ( "INTERNAL ERROR" );
-    }
+  int taxisID = vlistInqTaxis(streamptr->vlistID);
+  struct winHeaderEntry header = (struct winHeaderEntry){
+    .id = STREAMDEFTIMESTEP,
+    .specific.funcArgs.streamNewTimestep = { streamptr->self, tsID } };
+  xassert(sizeof (void *) >= sizeof (int));
+  pioBufferFuncCall(streamptr->self, header,
+                    (void *)(intptr_t)taxisID, cdiPioTaxisPackWrap);
   return cdiStreamDefTimestep_(streamptr, tsID);
 }
 
 void
 cdiPioClientSetup(int *pioNamespace_, int *pioNamespace)
 {
-  commEvalPhysNodes ();
-  commDefCommsIO ();
   *pioNamespace_ = *pioNamespace = namespaceNew();
   int callerCDINamespace = namespaceGetActive();
   namespaceSetActive(*pioNamespace_);
   cdiPioSerializeSetMPI();
+  namespaceSwitchSet(NSSWITCH_ABORT, NSSW_FUNC(cdiAbortC_MPI));
+  namespaceSwitchSet(NSSWITCH_WARNING, NSSW_FUNC(cdiPioWarning));
   namespaceSwitchSet(NSSWITCH_STREAM_OPEN_BACKEND,
                      NSSW_FUNC(cdiPioClientStreamOpen));
   namespaceSwitchSet(NSSWITCH_STREAM_DEF_VLIST_,
diff --git a/libcdi/src/pio_client.h b/libcdi/src/pio_client.h
index 7875064..2d3f9ce 100644
--- a/libcdi/src/pio_client.h
+++ b/libcdi/src/pio_client.h
@@ -5,3 +5,13 @@ void
 cdiPioClientSetup(int *pioNamespace_, int *pioNamespace);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/pio_comm.c b/libcdi/src/pio_comm.c
index 3e91a1b..b5cef8b 100644
--- a/libcdi/src/pio_comm.c
+++ b/libcdi/src/pio_comm.c
@@ -14,8 +14,6 @@
 
 typedef struct {
   int IOMode;
-  int nProcsIO;
-  int nProcsModel;
   int isProcIO;
 
   MPI_Comm commGlob;
@@ -23,139 +21,206 @@ typedef struct {
   int rankGlob;
   int root;
 
-  MPI_Comm commPio;
+  MPI_Comm commPio;             /* intracommunicator of PIO servers */
   int sizePio;
   int rankPio;
 
-  MPI_Comm commNode;
-  int sizeNode;
-  int rankNode;
-  char hostname [ MPI_MAX_PROCESSOR_NAME + 1 ];
-  nodeInfo_t nodeInfo;
-  int specialRankNode;
-
-  MPI_Comm commColl;
+  MPI_Comm commColl;            /* intracommunicator of collector
+                                 * subset of PIO servers only */
   int sizeColl;
   int rankColl;
 
   MPI_Comm commCalc;
   int rankCalc, sizeCalc;
 
-  MPI_Comm * commsIO;
-  int nProcsColl;
-  int * procsCollMap;
-  int * nodeSizes;
-  int * nodeMap;
+  /**
+   * communicator connecting group of clients and group of collectors
+   * notice: it is always implicit that the group of collectors is no
+   * larger than the group of clients
+   */
+  MPI_Comm pioInterComm;
+  /**
+   * group containing only the active remote
+   * processes, i.e.
+   * - on collector processes contains all processes that are a client of
+   *   the server
+   * - on client processes contains only the server process used for
+   *   data/RPC communication with this client process
+   */
+  MPI_Group remoteGroup;
+  /**
+   * Communicator containing both clients and collectors, needed since
+   * MPI_Win_create only accepts intracommunicators.
+   * Constructed such that collectors occupy the top ranks in the same
+   * sequence they have on their own communicator.
+   */
+  MPI_Comm collClientIntraComm;
 } pioInfo_t;
 
 
 static pioInfo_t * info = NULL;
 
+static void setupCollectorInterComm(pioInfo_t *p, int isCollector,
+                                    MPI_Comm localGroupComm,
+                                    int globRankOfGroupLeader[2]);
 
-static
-void pioInfoInit ( pioInfo_t * p )
+static void
+pioInfoInit(pioInfo_t *p, MPI_Comm commGlob, int clientServerRole)
 {
-  p->IOMode               = CDI_UNDEFID;
-  p->nProcsIO             = CDI_UNDEFID;
-  p->nProcsModel          = CDI_UNDEFID;
-  p->isProcIO             = CDI_UNDEFID;
-
-  p->commGlob             = MPI_COMM_NULL;
-  p->sizeGlob             = CDI_UNDEFID;
-  p->rankGlob             = CDI_UNDEFID;
-  p->root                 = CDI_UNDEFID;
-
-  p->commPio              = MPI_COMM_NULL;
-  p->sizePio              = CDI_UNDEFID;
-  p->rankPio              = -1;
-
-  p->commNode             = MPI_COMM_NULL;
-  p->sizeNode             = CDI_UNDEFID;
-  p->rankNode             = CDI_UNDEFID;
-  p->hostname[0]          = 0;
-  p->specialRankNode      = CDI_UNDEFID;
-
-  p->commColl             = MPI_COMM_NULL;
-  p->sizeColl             = CDI_UNDEFID;
-  p->rankColl             = CDI_UNDEFID;
-
-  p->commCalc             = MPI_COMM_NULL;
-  p->rankCalc             = -1;
-  p->sizeCalc             = -1;
-
-  p->commsIO              = NULL;
-  p->nodeInfo.hostID      = CDI_UNDEFID;
-  p->nodeInfo.isProcColl  = CDI_UNDEFID;
-  p->nodeInfo.nNodes      = CDI_UNDEFID;
-  p->nProcsColl           = CDI_UNDEFID;
-  p->procsCollMap         = NULL;
-  p->nodeSizes            = NULL;
-  p->nodeMap              = NULL;
-}
-
-
-void commInit ( void )
-{
-  xassert ( info == 0 );
-  info = xcalloc(1, sizeof (pioInfo_t));
-  pioInfoInit ( info );
-}
-
+  xassert(info != NULL && commGlob != MPI_COMM_NULL );
+  p->IOMode = -1;
 
-void commDestroy ( void )
-{
-  int collID;
+  xmpi(MPI_Comm_dup(commGlob, &p->commGlob));
+  xmpi(MPI_Comm_size(p->commGlob, &p->sizeGlob));
+  xmpi(MPI_Comm_rank(p->commGlob, &p->rankGlob));
+  p->root = 0;
 
-  xassert ( info != NULL );
+  p->commColl = MPI_COMM_NULL;
+  p->rankColl = -1;
 
-  if ( info->nodeMap   != NULL ) free ( info->nodeMap );
-  if ( info->nodeSizes != NULL ) free ( info->nodeSizes );
+  int isProcIO = (clientServerRole != PIO_ROLE_CLIENT),
+    isCollector = (clientServerRole & PIO_ROLE_COLLECTOR);
+  p->isProcIO = isProcIO;
 
-  if ( info->commsIO != NULL )
+  {
+    MPI_Comm temp;
+    /* key is 0 on all clients
+     *        0 on all servers that are also collectors
+     *        1 on all servers that are not collectors
+     */
+    int key = isProcIO - isCollector;
+    xmpi(MPI_Comm_split(p->commGlob, isProcIO, key, &temp));
+    enum {
+      PIO = 0, Client = 1, numGroups
+    };
+    int globRankOfGroupLeader[numGroups] = { 0, 0 };
+    if (isProcIO)
+      {
+        p->commPio = temp;
+        xmpi(MPI_Comm_rank(temp, &p->rankPio));
+        p->commCalc = MPI_COMM_NULL;
+        p->rankCalc = -1;
+        if (p->rankPio == 0)
+          globRankOfGroupLeader[PIO] = p->rankGlob;
+      }
+    else
+      {
+        p->commPio = MPI_COMM_NULL;
+        p->rankPio = -1;
+        p->commCalc = temp;
+        xmpi(MPI_Comm_rank(temp, &p->rankCalc));
+        xmpi(MPI_Comm_size(temp, &p->sizeCalc));
+        if (p->rankCalc == 0)
+          globRankOfGroupLeader[Client] = p->rankGlob;
+      }
+    int nProcsIO;
     {
-      for ( collID = 0; collID < info->nProcsColl; collID++ )
-	if ( info->commsIO[collID] != MPI_COMM_NULL )
-	  xmpi(MPI_Comm_free(info->commsIO + collID));
-      free ( info->commsIO );
-      info->commsIO = NULL;
+      enum { numGlobSums = 4 };
+      int temp[numGlobSums] = {
+        isProcIO,
+        (clientServerRole & PIO_ROLE_COLLECTOR),
+        globRankOfGroupLeader[0],
+        globRankOfGroupLeader[1]
+      };
+      xmpi(MPI_Allreduce(MPI_IN_PLACE, temp, numGlobSums, MPI_INT, MPI_SUM,
+                         commGlob));
+      p->sizePio = nProcsIO = temp[0];
+      p->sizeCalc = p->sizeGlob - nProcsIO;
+      p->sizeColl = temp[1];
+      globRankOfGroupLeader[0] = temp[2];
+      globRankOfGroupLeader[1] = temp[3];
     }
+    if (isProcIO)
+      {
+        MPI_Group pioGroup, collGroup;
+        int collRange[1][3] = { { 0, p->sizeColl - 1, 1 } };
+        xmpi(MPI_Comm_group(p->commPio, &pioGroup));
+        xmpi(MPI_Group_range_incl(pioGroup, 1, collRange, &collGroup));
+        xmpi(MPI_Comm_create(p->commPio, collGroup, &temp));
+        if (isCollector)
+          xmpi(MPI_Comm_rank(temp, &p->rankColl));
+        xmpi(MPI_Group_free(&pioGroup));
+        xmpi(MPI_Group_free(&collGroup));
+        p->commColl = temp;
+      }
+    if (isCollector || !isProcIO)
+      setupCollectorInterComm(p, isCollector, temp, globRankOfGroupLeader);
+    else /* isProcIO && !isCollector */
+      {
+        p->pioInterComm = MPI_COMM_NULL;
+        p->collClientIntraComm = MPI_COMM_NULL;
+        p->remoteGroup = MPI_GROUP_NULL;
+      }
+  }
+}
 
-  if ( info->commColl != MPI_COMM_NULL )
+/* create client <-> collector intercomm and fill-in related information */
+static void setupCollectorInterComm(pioInfo_t *p, int isCollector,
+                                    MPI_Comm localGroupComm,
+                                    int globRankOfGroupLeader[2])
+{
+  xmpi(MPI_Intercomm_create(localGroupComm, 0, p->commGlob,
+                            globRankOfGroupLeader[isCollector], 1,
+                            &p->pioInterComm));
+  xmpi(MPI_Intercomm_merge(p->pioInterComm, isCollector,
+                           &p->collClientIntraComm));
+  MPI_Group collClientGroup;
+  int remoteRanksRange[3];
+  xmpi(MPI_Comm_group(p->collClientIntraComm, &collClientGroup));
+  int numClients = p->sizeCalc,
+    numColl = p->sizeColl;
+  if (isCollector)
     {
-      xmpi ( MPI_Comm_free ( &info->commColl ));
-      info->commColl = MPI_COMM_NULL;
+      int collRank = p->rankColl;
+      remoteRanksRange[0]
+        = cdiPioClientRangeStart(collRank, numClients, numColl);
+      remoteRanksRange[1]
+        = cdiPioClientRangeStart(collRank + 1, numClients, numColl) - 1;
     }
-
-  free(info->procsCollMap);
-
-  if ( info->commNode != MPI_COMM_NULL )
+  else /* !isProcIO i.e. is client */
     {
-      xmpi ( MPI_Comm_free ( &info->commNode ));
-      info->commNode = MPI_COMM_NULL;
+      int clientRank = p->rankCalc;
+      int collRank = cdiPioCollRank(clientRank, numClients, numColl);
+      remoteRanksRange[1] = remoteRanksRange[0] = numClients + collRank;
     }
+  remoteRanksRange[2] = 1;
+  xmpi(MPI_Group_range_incl(collClientGroup, 1, &remoteRanksRange,
+                            &p->remoteGroup));
+  xmpi(MPI_Group_free(&collClientGroup));
+}
 
-  if ( info->commPio != MPI_COMM_NULL )
-    {
-      xmpi ( MPI_Comm_free ( &info->commPio ));
-      info->commPio = MPI_COMM_NULL;
-    }
 
-  free ( info );
-  info = NULL;
+
+int cdiPioCommInit(MPI_Comm commGlob, int IOMode, int clientServerRole)
+{
+  xassert(info == NULL && IOMode >= PIO_MINIOMODE && IOMode <= PIO_MAXIOMODE);
+  info = Malloc(sizeof(*info));
+  pioInfoInit(info, commGlob, clientServerRole);
+  info->IOMode = IOMode;
+  return info->sizePio;
 }
 
 
-void commDefCommGlob ( MPI_Comm c )
+void cdiPioCommFinalize(void)
 {
-  xassert ( info != NULL &&
-	   c != MPI_COMM_NULL );
+  xassert ( info != NULL );
+
+  MPI_Comm *comms[] = { &info->commGlob, &info->commPio, &info->commColl,
+                        &info->commCalc, &info->pioInterComm,
+                        &info->collClientIntraComm };
+
+  for (size_t i = 0; i < sizeof (comms) / sizeof (comms[0]); ++i)
+    if ( *comms[i] != MPI_COMM_NULL )
+      xmpi(MPI_Comm_free(comms[i]));
 
-  info->commGlob = c;
-  xmpi ( MPI_Comm_size ( c, &info->sizeGlob ));
-  xmpi ( MPI_Comm_rank ( c, &info->rankGlob ));
-  info->root = 0;
+  MPI_Group *groups[] = { &info->remoteGroup };
+  for (size_t i = 0; i < sizeof (groups) / sizeof (groups[0]); ++i)
+    if ( *groups[i] != MPI_GROUP_NULL )
+      xmpi(MPI_Group_free(groups[i]));
+
+  Free(info);
+  info = NULL;
 }
- 
 
 MPI_Comm commInqCommGlob ( void )
 {
@@ -188,23 +253,21 @@ int commInqRootGlob ( void )
   return info->root;
 }
 
-
-void commDefNProcsIO ( int n )
+int cdiPioInqCollectorOfClient(void)
 {
-  xassert ( info != NULL &&
-	   n >= 0 &&
-	   n < MAXNPROCSIO &&
-           info->commGlob != MPI_COMM_NULL );
-  info->nProcsIO = n;
-  info->nProcsModel = info->sizeGlob - info->nProcsIO;
+  xassert(info != NULL);
+  int clientRank = commInqRankModel(),
+    numClients = cdiPioCommInqSizeClients(),
+    numServers = commInqSizeColl(),
+    numClientsPerServer = (numClients + numServers - 1) / numServers,
+    collRank = clientRank / numClientsPerServer;
+  return (!info->isProcIO) ? collRank : -1;
 }
 
-
-int commInqNProcsIO ( void )
+MPI_Group cdiPioInqRemoteGroup(void)
 {
-  xassert ( info != NULL &&
-           info->nProcsIO != CDI_UNDEFID );
-  return info->nProcsIO;
+  xassert(info != NULL);
+  return info->remoteGroup;
 }
 
 
@@ -219,87 +282,33 @@ int      commInqIsProcIO     ( void )
 int commInqNProcsModel ( void )
 {
   xassert ( info != NULL &&
-           info->nProcsModel != CDI_UNDEFID );
-  return info->nProcsModel;
+           info->sizeCalc != -1 );
+  return info->sizeCalc;
 }
 
 
-void     commDefIOMode  ( int IOMode )
+int commInqIOMode(void)
 {
-  xassert(info != NULL && IOMode >= PIO_MINIOMODE && IOMode <= PIO_MAXIOMODE );
-  info->IOMode = IOMode;
+  return info != NULL ? info->IOMode : PIO_NONE;
 }
 
 
-int      commInqIOMode  ( void )
+MPI_Comm commInqCommPio  ( void )
 {
-  if (info != NULL)
-    {
-      xassert ( info->IOMode != CDI_UNDEFID );
-      return info->IOMode;
-    }
-  else
-    return PIO_NONE;
+  xassert ( info != NULL &&
+           info->commPio != MPI_COMM_NULL &&
+           info->isProcIO == 1 );
+  return info->commPio;
 }
 
-
-void     commDefCommPio  ( void )
+int commInqSizePio(void)
 {
-  int nProcsCalc;
-  MPI_Group grpAll, grpCalc, grpPio;
-  int calcRange[3], pioRange[3];
-
   xassert ( info != NULL &&
-           info->commGlob != MPI_COMM_NULL &&
-           info->IOMode  != CDI_UNDEFID &&
-           info->nProcsIO != CDI_UNDEFID );
-
-  nProcsCalc = info->sizeGlob - info->nProcsIO;
-
-  info->isProcIO = info->rankGlob >= nProcsCalc ? 1 : 0;
-
-  xmpi(MPI_Comm_group(info->commGlob, &grpAll));
-
-  calcRange[0] = 0;
-  calcRange[1] = info->sizeGlob - info->nProcsIO - 1;
-  calcRange[2] = 1;
-  xmpi(MPI_Group_range_incl(grpAll, info->nProcsIO==info->sizeGlob?0:1,
-                            &calcRange, &grpCalc));
-  xmpi(MPI_Comm_create(info->commGlob, grpCalc, &info->commCalc));
-
-  pioRange[0] = info->sizeGlob - info->nProcsIO;
-  pioRange[1] = info->sizeGlob - 1;
-  pioRange[2] = 1;
-  xmpi(MPI_Group_range_incl(grpAll, 1, &pioRange, &grpPio));
-  xmpi(MPI_Comm_create(info->commGlob, grpPio, &info->commPio));
-
-  if (info->commPio != MPI_COMM_NULL)
-    {
-      xmpi(MPI_Comm_size(info->commPio, &info->sizePio));
-      xmpi(MPI_Comm_rank(info->commPio, &info->rankPio));
-      info->sizeCalc = nProcsCalc;
-      info->rankCalc = -1;
-    }
-  else
-    {
-      info->sizePio = nProcsCalc;
-      info->rankPio = -1;
-      xmpi(MPI_Comm_size(info->commCalc, &info->sizeCalc));
-      xmpi(MPI_Comm_rank(info->commCalc, &info->rankCalc));
-    }
-  xmpi(MPI_Group_free(&grpCalc));
-  xmpi(MPI_Group_free(&grpPio));
-  xmpi(MPI_Group_free(&grpAll));
+            info->sizePio > 0);
+  return info->sizePio;
 }
 
 
-MPI_Comm commInqCommPio  ( void )
-{
-  xassert ( info != NULL &&
-           info->commPio != MPI_COMM_NULL &&
-           info->isProcIO == 1 );
-  return info->commPio;
-}
 
 
 MPI_Comm commInqCommModel ( void )
@@ -328,21 +337,12 @@ int      commInqRankModel       ( void )
   return info->rankCalc;
 }
 
-
-void     commDefCommColl  ( int isProcColl )
+int cdiPioCommInqSizeClients(void)
 {
-  xassert ( info != NULL &&
-           info->commNode != MPI_COMM_NULL &&
-           info->commColl == MPI_COMM_NULL );
-
-  info->nodeInfo.isProcColl = isProcColl;
-  xmpi ( MPI_Comm_split ( info->commNode, info->nodeInfo.isProcColl, 0, 
-                          &info->commColl ));
-  xmpi ( MPI_Comm_size ( info->commColl, &info->sizeColl ));
-  xmpi ( MPI_Comm_rank ( info->commColl, &info->rankColl )); 
+  xassert(info != NULL && info->sizeCalc >= 0);
+  return info->sizeCalc;
 }
 
-
 MPI_Comm commInqCommColl    ( void )
 {
   xassert ( info != NULL &&
@@ -351,406 +351,37 @@ MPI_Comm commInqCommColl    ( void )
 }
 
 
-int      commInqSizeColl    ( void )
+int commInqSizeColl    ( void )
 {
-  xassert ( info != NULL &&
-           info->sizeColl != CDI_UNDEFID );
-  return info->sizeColl; 
+  xassert(info != NULL &&
+          info->sizeColl >= 0);
+  return info->sizeColl;
 }
 
 
-int      commInqRankColl    ( void )
+int commInqRankColl(void)
 {
-  xassert ( info != NULL &&
-           info->rankColl != CDI_UNDEFID );
-  return info->rankColl; 
+  xassert(info != NULL);
+  return info->rankColl;
 }
 
-static int
-cmpstringp(const void *p1, const void *p2)
+MPI_Comm cdiPioInqInterComm(void)
 {
-  return strcmp(* (char * const *) p1, * (char * const *) p2);
-}
-
-void commDefCommNode ( void )
-{
-  int size;
-  char * myHost, (*allHosts)[MPI_MAX_PROCESSOR_NAME], **sortedHosts;
-
-  xassert ( info != NULL &&
-           info->commPio != MPI_COMM_NULL );
-
-  size = info->sizePio;
-
-  myHost = (char*) xmalloc(MPI_MAX_PROCESSOR_NAME);
-  {
-    int len;
-    xmpi ( MPI_Get_processor_name ( myHost, &len ));
-    xassert ( myHost[0] != '\0' );
-    strncpy(info->hostname, myHost, (size_t)len);
-    info->hostname[len] = '\0';
-  }
-
-  allHosts = xmalloc((size_t)size * MPI_MAX_PROCESSOR_NAME);
-  sortedHosts = xmalloc((size_t)size * sizeof (sortedHosts[0]));
-
-  for (int i = 0; i < size; ++i)
-    sortedHosts[i] = allHosts[i];
-
-  xmpi(MPI_Allgather(myHost, MPI_MAX_PROCESSOR_NAME, MPI_CHAR,
-                     allHosts[0], MPI_MAX_PROCESSOR_NAME,
-                     MPI_CHAR, info->commPio ));
-
-  qsort(sortedHosts, (size_t)size, sizeof (sortedHosts[0]),
-        (int (*)(const void *, const void *))cmpstringp);
-
-  {
-    int i = 1, nHosts = 1;
-    if (!strcmp(myHost, sortedHosts[0]))
-      {
-        info->nodeInfo.hostID = 1;
-      }
-    else
-      {
-        for (; i < size && strcmp(myHost, sortedHosts[i]); ++i)
-          if (strcmp(sortedHosts[i - 1], sortedHosts[i]))
-            {
-              /* new host seen, might be ours */
-              nHosts += 1;
-              if (!strcmp(sortedHosts[i], myHost))
-                info->nodeInfo.hostID = nHosts - 1;
-            }
-      }
-    for (; i < size && strcmp(myHost, sortedHosts[i]); ++i)
-      if (strcmp(sortedHosts[i - 1], sortedHosts[i]))
-        nHosts += 1;
-    info->nodeInfo.nNodes = nHosts;
-  }
-
-  xassert ( info->nodeInfo.hostID != CDI_UNDEFID );
-
-  xmpi ( MPI_Comm_split ( info->commPio, info->nodeInfo.hostID, 0, 
-                          &info->commNode ));
-  xmpi ( MPI_Comm_size ( info->commNode, &info->sizeNode ));
-  xmpi ( MPI_Comm_rank ( info->commNode, &info->rankNode ));
-  if ( info->IOMode >= PIO_MINIOMODEWITHSPECIALPROCS )
-    info->specialRankNode = info->sizeNode - 1;
-
-  free(sortedHosts);
-  free(allHosts);
-  free(myHost);
-
-  return;
+  xassert(info != NULL);
+  return info->pioInterComm;
 }
 
-
-MPI_Comm commInqCommNode    ( void )
+MPI_Comm cdiPioInqCollClientIntraComm(void)
 {
-  xassert ( info != NULL &&
-           info->commNode != MPI_COMM_NULL );
-  return info->commNode;
-} 
-
-
-int commInqSizeNode ( void )
-{
-  xassert ( info != NULL &&
-           info->sizeNode != CDI_UNDEFID );
-  return info->sizeNode;
+  xassert(info != NULL);
+  return info->collClientIntraComm;
 }
 
 
-int commInqRankNode ( void )
-{
-  xassert ( info != NULL &&
-           info->rankNode != CDI_UNDEFID );
-  return info->rankNode;
-}
-
-
-int commInqSpecialRankNode ( void )
+int commInqSpecialRank(void)
 {
   xassert ( info != NULL );
-  return info->specialRankNode;
-}
-
-
-void commSendNodeInfo ( void )
-{
-  xassert ( info != NULL &&
-           info->root                != CDI_UNDEFID &&
-           info->nodeInfo.hostID     != CDI_UNDEFID &&
-           info->nodeInfo.isProcColl != CDI_UNDEFID &&
-           info->nodeInfo.nNodes     != CDI_UNDEFID &&
-           info->commGlob            != MPI_COMM_NULL );
-  
-  xmpi ( MPI_Send ( &info->nodeInfo, sizeNodeInfo, MPI_INTEGER, 
-                    info->root, NODEINFO, info->commGlob ));
-}
-
-
-void     commRecvNodeMap    ( void )
-{
-  MPI_Status status;
-  int source; 
-
-  xassert ( info != NULL &&
-           info->commGlob    != MPI_COMM_NULL &&
-           info->rankGlob    != CDI_UNDEFID &&
-           info->nProcsModel != CDI_UNDEFID &&
-           info->nodeMap     == NULL );
-
-  source = info->root;
-
-  xmpi ( MPI_Probe ( source, NODEMAP, info->commGlob, &status ));
-  xmpi ( MPI_Get_count ( &status, MPI_INTEGER, &info->nProcsColl ));
-
-  xdebug ( "info->nProcsColl=%d", info->nProcsColl );
-
-  info->nodeMap = (int *)xmalloc((size_t)info->nProcsColl
-                                 * sizeof (info->nodeMap[0]));
-
-  xmpi ( MPI_Recv ( info->nodeMap, info->nProcsColl, MPI_INTEGER, 
-                    source, NODEMAP, info->commGlob, &status ));
-}
-
-
-void     commDefNNodes      ( int nNodes )
-{
-  xassert ( info != NULL );
-  info->nodeInfo.nNodes = nNodes;
-}
-
-
-int      commInqNNodes      ( void )
-{
-  xassert ( info != NULL &&
-           info->nodeInfo.nNodes != CDI_UNDEFID );
-  return info->nodeInfo.nNodes;
-}
-
-
-void     commEvalPhysNodes  ( void )
-{
-  nodeInfo_t * nodeInfo;
-  MPI_Status status;
-  int i, IOID, collID, size, nNodes = CDI_UNDEFID;
-  int ** p1, ** p2,  idx;
-
-  xassert ( info != NULL &&
-           info->root        != CDI_UNDEFID &&
-           info->nProcsIO    != CDI_UNDEFID &&
-           info->nProcsModel != CDI_UNDEFID &&
-           info->sizeGlob    != CDI_UNDEFID &&
-           info->rankGlob    != CDI_UNDEFID &&
-           info->commGlob    != MPI_COMM_NULL );
-
-  size = info->nProcsIO * sizeNodeInfo;
-
-  nodeInfo = (nodeInfo_t *)xmalloc((size_t)size * sizeof (int));
-
-  if ( info->rankGlob == info->root )
-    {
-      xassert ( info->rankCalc == info->root );
- 
-      for ( i = info->nProcsModel; i < info->sizeGlob; i++ )
-        {
-          IOID = i - info->nProcsModel;
-          xmpi ( MPI_Recv ( nodeInfo + IOID, sizeNodeInfo, MPI_INTEGER, i, 
-                            NODEINFO, info->commGlob, &status ));
-        }
-    }
-
-  xmpi ( MPI_Bcast ( nodeInfo, size, MPI_INTEGER, info->root, 
-                     info->commCalc ));
-
-  // consistency check, count collectors
-  for ( IOID = 0; IOID < info->nProcsIO; IOID++ )
-    {
-      if ( IOID == 0 )
-        {
-          xassert ( nodeInfo[IOID].nNodes > 0 &&
-                   nodeInfo[IOID].nNodes <= info->nProcsIO );
-          nNodes = nodeInfo[IOID].nNodes;
-        }
-      else xassert ( nodeInfo[IOID].nNodes == nNodes );         
-      xassert ( nodeInfo[IOID].hostID > 0 &&
-               nodeInfo[IOID].hostID <= nNodes );
-      if ( nodeInfo[IOID].isProcColl ) 
-        {
-          if ( info->nProcsColl == CDI_UNDEFID ) info->nProcsColl = 0;
-          info->nProcsColl++;
-        }
-    }
-
-  xdebug ( "info->nProcsColl=%d", info->nProcsColl );
-
-  xassert ( info->nProcsColl <= info->nProcsModel );
-
-  info->procsCollMap = (int *)xmalloc((size_t)info->nProcsColl
-                                      * sizeof (info->procsCollMap[0]));
-
-  // define nodeSizes
-  info->nodeInfo.nNodes = nNodes; 
-  info->nodeSizes = xcalloc((size_t)info->nodeInfo.nNodes,
-                            sizeof (info->nodeSizes[0]));
-  collID = 0;
-  for ( IOID = 0; IOID < info->nProcsIO; IOID++ )
-    if ( nodeInfo[IOID].isProcColl )
-      {
-        info->nodeSizes[nodeInfo[IOID].hostID - 1]++;
-        info->procsCollMap[collID++] = IOID + info->nProcsModel;
-      }
-
-  // define nodeMap
-  info->nodeMap = (int *)xmalloc((size_t)info->nProcsColl
-                                 * sizeof (info->nodeMap[0]));
-  // helpers
-  p1 = (int **)xmalloc((size_t)info->nodeInfo.nNodes * sizeof (p1[0]));
-  p2 = (int **)xmalloc((size_t)info->nodeInfo.nNodes * sizeof (p2[0]));
-  idx = 0;
-  for ( i = 0; i < info->nodeInfo.nNodes; i++ )
-    {
-      xassert ( idx >= 0 && idx < info->nProcsColl );
-      p1[i] = &info->nodeMap[idx];
-      p2[i] = p1[i] + info->nodeSizes[i]; 
-      idx += info->nodeSizes[i];
-    }
-  xassert ( idx == info->nProcsColl );
-
-  // rankGlob in nodeMap
-  for ( IOID = 0; IOID < info->nProcsIO; IOID++ )
-    {
-      if ( nodeInfo[IOID].isProcColl )
-        {
-          xassert ( p1[nodeInfo[IOID].hostID - 1] <  
-                   p2[nodeInfo[IOID].hostID - 1] );
-          * p1[nodeInfo[IOID].hostID - 1]++ = IOID + info->nProcsModel;
-        }
-    }
-
-  if ( info->rankGlob == info->root )
-    for ( IOID = info->nProcsModel; IOID < info->sizeGlob; IOID++ )
-      xmpi ( MPI_Send ( info->nodeMap, info->nProcsColl, MPI_INTEGER, 
-                        IOID, NODEMAP, info->commGlob ));
-  free ( p2 );
-  free ( p1 );
-  free ( nodeInfo );
-}
-
-
-int      commCollID2RankGlob      ( int collID ) 
-{
-  xassert ( info != NULL &&
-           info->nProcsColl != CDI_UNDEFID &&
-           collID >= 0 &&
-           collID < info->nProcsColl &&
-           info->nodeMap != NULL );
-  return info->nodeMap[collID];
-}
-
-
-int      commRankGlob2CollID      ( int rankGlob)
-{
-  int out = CDI_UNDEFID, collID;
-
-  xassert ( info != NULL &&
-           info->nProcsColl != CDI_UNDEFID &&
-           info->nProcsModel != CDI_UNDEFID &&
-           info->sizeGlob != CDI_UNDEFID &&
-           rankGlob >= info->nProcsModel &&
-           rankGlob <= info->sizeGlob );
-
-  for ( collID = 0; collID < info->nProcsColl; collID++ )
-    if ( info->nodeMap[collID] == rankGlob ) out = collID;
-
-  return out;
-} 
-
-
-int *    commInqNodeSizes   ( void )
-{
-  xassert ( info != NULL &&
-           info->nodeSizes != NULL );
-  return info->nodeSizes;
-}
-
-
-// collective call
-void     commDefCommsIO     ( void )
-{
-  MPI_Group groupGlob;
-  int collID, * ranks, i, currIORank;
-  char name[MAXCOMMIONAME];
-
-  xassert ( info != NULL &&
-           info->nProcsColl != CDI_UNDEFID &&
-           info->commsIO == NULL &&
-           info->nProcsModel != CDI_UNDEFID &&
-           info->commGlob != MPI_COMM_NULL );
-
-  info->commsIO = (MPI_Comm *)xmalloc((size_t)info->nProcsColl
-                                      * sizeof (info->commsIO[0]));
-  for ( collID = 0; collID < info->nProcsColl; collID++ )
-    info->commsIO[collID] = MPI_COMM_NULL;
-
-  strncpy ( name, "COMMSIO_", 8 );
-  name[MAXCOMMIONAME - 1] = '\0';
-
-  ranks = (int *)xmalloc(((size_t)info->nProcsModel + 1) * sizeof (ranks[0]));
-  for ( i = 0; i < info->nProcsModel; i++ )
-    ranks[i] = i;
-
-  xmpi ( MPI_Comm_group ( info->commGlob, &groupGlob )); 
-
-  for ( collID = 0; collID < info->nProcsColl; collID++ )
-    {
-      currIORank = info->nodeMap[collID];
-      ranks[info->nProcsModel] = currIORank;
-      MPI_Group currGroupIO;
-      xmpi(MPI_Group_incl(groupGlob, info->nProcsModel + 1,
-                          ranks, &currGroupIO));
-      xmpi(MPI_Comm_create(info->commGlob, currGroupIO,
-                           info->commsIO + collID));
-      xmpi(MPI_Group_free(&currGroupIO));
-      if ( info->rankGlob == currIORank )
-	info->commCalc = info->commsIO[collID];
-
-      // set names for debugging
-      if ( info->rankGlob < info->nProcsModel || 
-           info->rankGlob == currIORank )
-	{
-	  sprintf ( &name[8], "%d", collID ); 
-	  xmpi ( MPI_Comm_set_name ( info->commsIO[collID], name ));
-	}
-    }
-
-  if ( ddebug >= 2 )
-    {
-      if ( info->rankGlob < info->nProcsModel )
-	for ( collID = 0; collID < info->nProcsColl; collID++ ) 
-          xdebugComm ( info->commsIO + collID );
-      else if ( info->nodeInfo.isProcColl )
-	xdebugComm ( &info->commCalc );
-    }
-
-  xmpi ( MPI_Group_free ( &groupGlob ));
-  free ( ranks );
-
-  commPrint ( stdout );
-}
-
-
-MPI_Comm commInqCommsIO     ( int collID )
-{
-  xassert ( collID >= 0 &&
-           info != NULL &&
-           info->nProcsColl != CDI_UNDEFID &&
-           collID < info->nProcsColl &&
-           info->commsIO != NULL &&
-           info->commsIO[collID] != MPI_COMM_NULL );
-
-  return info->commsIO[collID];
+  return info->sizeColl;
 }
 
 
@@ -765,15 +396,13 @@ MPI_Comm commInqCommCalc    ( void )
 int      commInqNProcsColl  ( void )
 {
   xassert ( info != NULL &&
-           info->nProcsColl != CDI_UNDEFID );
-  return info->nProcsColl;
+           info->sizeColl != CDI_UNDEFID );
+  return info->sizeColl;
 }
 
 
 void commPrint ( FILE * fp )
 {
-  int i;
-
   if ( ddebug == 0 ) return;
 
   xassert ( info != NULL );
@@ -782,8 +411,6 @@ void commPrint ( FILE * fp )
   fprintf ( fp, "######## pioinfo PE%d ###########\n", info->rankGlob );
   fprintf ( fp, "#\n" );
   fprintf ( fp, "# IOMode      = %d\n", info->IOMode );
-  fprintf ( fp, "# nProcsIO    = %d\n", info->nProcsIO );
-  fprintf ( fp, "# nProcsModel = %d\n", info->nProcsModel );
   fprintf ( fp, "# isProcIO    = %d\n", info->isProcIO );
   fprintf ( fp, "#\n" );
   fprintf ( fp, "# commGlob    = %d\n", (int)MPI_Comm_c2f(info->commGlob));
@@ -795,61 +422,13 @@ void commPrint ( FILE * fp )
   fprintf ( fp, "# sizePio     = %d\n", info->sizePio );
   fprintf ( fp, "# rankPio     = %d\n", info->rankPio );
   fprintf ( fp, "#\n" );
-  fprintf ( fp, "# commNode    = %d\n", (int)MPI_Comm_c2f(info->commNode));
-  fprintf ( fp, "# sizeNode    = %d\n", info->sizeNode );
-  fprintf ( fp, "# rankNode    = %d\n", info->rankNode );
-  fprintf ( fp, "# hostname    = %s\n", info->hostname[0] == 0 ? "nn" : 
-	    info->hostname );
-  fprintf ( fp, "# specialRankNode = %d\n", info->specialRankNode );
-  fprintf ( fp, "#\n" );
   fprintf ( fp, "# commColl    = %d\n", (int)MPI_Comm_c2f(info->commColl));
   fprintf ( fp, "# sizeColl    = %d\n", info->sizeColl );
   fprintf ( fp, "# rankColl    = %d\n", info->rankColl );
   fprintf ( fp, "#\n" );
   fprintf ( fp, "# commCalc    = %d\n", (int)MPI_Comm_c2f(info->commCalc));
-  if ( info->commsIO != NULL )
-    {
-      fprintf ( fp, "#\n" );
-      for ( i = 0; i < info->nProcsColl; i++ )
-	fprintf(fp, "# commsIO[%d]  = %d\n", i,
-                (int)MPI_Comm_c2f(info->commsIO[i]));
-    }
-  else
-    fprintf ( fp, "# commsIO     = NULL\n" );
-  fprintf ( fp, "# hostID      = %d\n", info->nodeInfo.hostID );
-  fprintf ( fp, "# isProcColl  = %d\n", info->nodeInfo.isProcColl );
-  fprintf ( fp, "# nNodes      = %d\n", info->nodeInfo.nNodes );
-  fprintf ( fp, "# nProcsColl  = %d\n", info->nProcsColl );
-  if ( info->procsCollMap != NULL )
-    {
-      fprintf ( fp, "# procsCollMap   = " );
-      xassert ( info->nProcsColl != CDI_UNDEFID );
-      for ( i = 0; i < info->nProcsColl; i++ )
-        fprintf ( fp, "%d ", info->procsCollMap[i] );
-      fprintf ( fp, "\n" );
-    }
-  else     
-    fprintf ( fp, "# procsCollMap   = NULL\n" );
-  if ( info->nodeSizes != NULL )
-    {
-      fprintf ( fp, "# nodeSizes   = " );
-      xassert ( info->nodeInfo.nNodes != CDI_UNDEFID );
-      for ( i = 0; i < info->nodeInfo.nNodes; i++ )
-        fprintf ( fp, "%d ", info->nodeSizes[i] );
-      fprintf ( fp, "\n" );
-    }
-  else     
-    fprintf ( fp, "# nodeSizes   = NULL\n" );
-  if ( info->nodeMap != NULL )
-    {
-      fprintf ( fp, "# nodeMap     = " );
-      xassert ( info->nProcsColl != CDI_UNDEFID );
-      for ( i = 0; i < info->nProcsColl; i++ )
-        fprintf ( fp, "%d ", info->nodeMap[i] );
-      fprintf ( fp, "\n" );
-    }
-  else     
-    fprintf ( fp, "# nodeMap     = NULL\n" );
+  fprintf ( fp, "# sizeCalc  = %d\n", info->sizeCalc );
+  fprintf ( fp, "# rankCalc  = %d\n", info->rankCalc );
   fprintf ( fp, "#\n" );
   fprintf ( fp, "############################\n" );
   fprintf ( fp, "\n" );
diff --git a/libcdi/src/pio_comm.h b/libcdi/src/pio_comm.h
index 76bf45c..994de25 100644
--- a/libcdi/src/pio_comm.h
+++ b/libcdi/src/pio_comm.h
@@ -7,68 +7,73 @@
 
 #include <mpi.h>
 #include <stdio.h>
-#include "cdi.h"
 
-typedef struct {
-  int hostID;
-  int isProcColl;
-  int nNodes;
-} nodeInfo_t;
 
-enum { MAXNPROCSIO   = 256,
-       MAXCOMMIONAME = 12 };
+int cdiPioCommInit(MPI_Comm commGlob, int IOMode, int clientServerRole);
+void cdiPioCommFinalize(void);
 
-enum { sizeNodeInfo  = 3,
-       NODEINFO      = 1111, 
-       NODEMAP       = 2222};
-
-void     commInit               ( void );
-void     commDestroy            ( void );
-
-void     commDefCommGlob        ( MPI_Comm ); 
 MPI_Comm commInqCommGlob        ( void );
 int      commInqSizeGlob        ( void );
 int      commInqRankGlob        ( void );
 int      commInqRootGlob        ( void );
 
-void     commDefNProcsIO        ( int );
-int      commInqNProcsIO        ( void );
-int      commInqNProcsModel     ( void );
+/* returns the inter-communicator used to connect from
+ * client to server group */
+MPI_Comm cdiPioInqInterComm(void);
+
 int      commInqIsProcIO        ( void );
-void     commDefIOMode          ( int );
 int      commInqIOMode          ( void );
 
 void     commDefCommPio         ( void );
-MPI_Comm commInqCommPio         ( void );
-MPI_Comm commInqCommModel       ( void );
-int      commInqRankPio         ( void );
-int      commInqRankModel       ( void );
-
-void     commDefCommNode        ( void );
-MPI_Comm commInqCommNode        ( void );
-int      commInqSizeNode        ( void );
-int      commInqRankNode        ( void );
-int      commInqSpecialRankNode ( void );
-
-void     commDefCommColl        ( int ); 
+MPI_Comm commInqCommPio(void);
+int commInqSizePio(void);
+int commInqRankPio(void);
+
+MPI_Comm commInqCommModel(void);
+int commInqRankModel(void);
+int cdiPioCommInqSizeClients(void);
+
+int commInqSpecialRank(void);
+
+void     commDefCommColl        ( int );
 MPI_Comm commInqCommColl        ( void );
-int      commInqSizeColl        ( void ); 
-int      commInqRankColl        ( void ); 
-                                
-void     commSendNodeInfo       ( void );
-void     commRecvNodeMap        ( void );// todo switch to gatherNodeInfo inside commpio
-int *    commInqNodeSizes       ( void );
-int      commInqNNodes          ( void );
-void     commEvalPhysNodes      ( void );
-int      commCollID2RankGlob    ( int );
-int      commRankGlob2CollID    ( int );
-void     commDefCommsIO         ( void ); 
-MPI_Comm commInqCommsIO         ( int );
+int commRankGlob2CollID(int rankGlob);
+int      commInqSizeColl        ( void );
+int      commInqRankColl        ( void );
 MPI_Comm commInqCommCalc        ( void );
 int      commInqNProcsColl      ( void );
 
 void     commPrint              ( FILE * );
 
+/* query rank of collector responsible for client on inter-communicator
+ * returns -1 on server processes.
+ */
+int cdiPioInqCollectorOfClient();
+
+/* query communicator containing clients and collectors,
+ * the collectors occupy the top-ranks
+ */
+MPI_Comm cdiPioInqCollClientIntraComm(void);
+
+/* query group of corresponding processes in other group on
+   intra-communicator */
+MPI_Group cdiPioInqRemoteGroup(void);
+
+static inline int
+cdiPioCollRank(int clientRank, int numClients, int numColl)
+{
+  return (int)(((long long)clientRank * (long long)numColl
+                + (long long)(numColl - 1))
+               / numClients);
+}
+
+static inline int
+cdiPioClientRangeStart(int collRank, int numClients, int numColl)
+{
+  return (int)(((long long)collRank * (long long)numClients)
+               / (long long)numColl);
+}
+
 #endif
 /*
  * Local Variables:
diff --git a/libcdi/src/pio_conf.c b/libcdi/src/pio_conf.c
new file mode 100644
index 0000000..ffa1fa6
--- /dev/null
+++ b/libcdi/src/pio_conf.c
@@ -0,0 +1,296 @@
+#include <limits.h>
+#include <stdlib.h>
+#include <string.h>
+
+#include <yaxt.h>
+
+#include "dmemory.h"
+#include "error.h"
+#include "resource_handle.h"
+
+#include "cdipio.h"
+#include "pio_conf.h"
+
+static int cdiPioConfCompareP(void *conf1, void *conf2);
+static void cdiPioConfDestroyP(void *conf);
+static void cdiPioConfPrintP(void *cdiPioConfPtr, FILE * fp);
+
+struct intCodeStrMap
+{
+  const char text[28];
+  int code;
+};
+
+static size_t
+mapSearchStr(const struct intCodeStrMap map[], size_t mapSize,
+             const char *str)
+{
+  size_t retval = SIZE_MAX;
+  for (size_t i = 0; i < mapSize; ++i)
+    if (!strcmp(str, map[i].text))
+      {
+        retval = i;
+        break;
+      }
+  return retval;
+}
+
+static size_t
+mapSearchCode(const struct intCodeStrMap map[], size_t mapSize,
+              int code)
+{
+  size_t retval = SIZE_MAX;
+  for (size_t i = 0; i < mapSize; ++i)
+    if (code == map[i].code)
+      {
+        retval = i;
+        break;
+      }
+  return retval;
+}
+
+static const struct intCodeStrMap modeMap[] = {
+  { "PIO_NONE", PIO_NONE },
+  { "PIO_MPI", PIO_MPI },
+  { "PIO_FPGUARD", PIO_FPGUARD },
+  { "PIO_ASYNCH", PIO_ASYNCH },
+  { "PIO_WRITER", PIO_WRITER },
+  { "PIO_MPI_FW_ORDERED", PIO_MPI_FW_ORDERED },
+  { "PIO_MPI_FW_AT_ALL", PIO_MPI_FW_AT_ALL },
+  { "PIO_MPI_FW_AT_REBLOCK", PIO_MPI_FW_AT_REBLOCK },
+};
+
+int
+cdiPioStr2IOMode(const char *modeStr)
+{
+  size_t idx = mapSearchStr(modeMap, sizeof (modeMap) / sizeof (modeMap[0]),
+                            modeStr);
+  int mode = (idx != SIZE_MAX) ? modeMap[idx].code : -1;
+  return mode;
+}
+
+const char *
+cdiPioIOMode2Str(int IOMode)
+{
+  if (IOMode < PIO_MINIOMODE || IOMode > PIO_MAXIOMODE)
+    return "";
+  else
+    return modeMap[IOMode].text;
+}
+
+static const struct intCodeStrMap roleMap[] = {
+  { "PIO_ROLE_CLIENT", PIO_ROLE_CLIENT },
+  { "PIO_ROLE_COLLECTOR", PIO_ROLE_COLLECTOR },
+  { "PIO_ROLE_WRITER", PIO_ROLE_WRITER },
+  { "PIO_ROLE_WRITER_COLLECTOR", PIO_ROLE_WRITER_COLLECTOR },
+  { "PIO_ROLE_FPGUARD", PIO_ROLE_FPGUARD },
+};
+
+#if 0
+static int
+cdiPioStr2CSRole(const char *roleStr)
+{
+  size_t idx = mapSearchStr(roleMap, sizeof (roleMap) / sizeof (roleMap[0]),
+                            roleStr);
+  int role = (idx != SIZE_MAX) ? roleMap[idx].code : -1;
+  return role;
+}
+#endif
+
+static const char *
+cdiPioCSRole2Str(int role)
+{
+  size_t pos = mapSearchCode(roleMap, sizeof (roleMap) / sizeof (roleMap[0]),
+                             role);
+  const char *roleStr = (pos != SIZE_MAX) ? roleMap[pos].text : "";
+  return roleStr;
+}
+
+const resOps cdiPioConfOps = {
+  cdiPioConfCompareP,
+  cdiPioConfDestroyP,
+  cdiPioConfPrintP,
+  /* serialization of configuration is not supported */
+  0, 0, 0
+};
+
+static int
+cdiPioConfCompareP(void *p1, void *p2)
+{
+  struct cdiPioConf *a = p1, *b = p2;
+  return (a->IOMode != b->IOMode)
+    | (a->clientServerRole != b->clientServerRole)
+    | (a->partInflate != b->partInflate)
+    | (a->postCommSetupActions != b->postCommSetupActions);
+}
+
+static void
+cdiPioConfDestroyP(void *conf)
+{
+  Free(conf);
+}
+
+static void
+cdiPioConfPrintP(void *cdiPioConfPtr, FILE * fp)
+{
+  struct cdiPioConf *conf = cdiPioConfPtr;
+  const char *iomodeStr = cdiPioIOMode2Str(conf->IOMode),
+    *CSRoleStr = cdiPioCSRole2Str(conf->clientServerRole);
+  if (!iomodeStr[0])
+    iomodeStr = "(invalid!)";
+  if (!CSRoleStr[0])
+    CSRoleStr = "(invalid!)";
+  fprintf(fp, "configuration object %p\n"
+          "IOMode = %s\n"
+          "client/server = %s\n"
+          "part data imbalance = %f\n"
+          "aligning of block buffers to large pages is %sabled\n"
+          "record aggregation buffer size %zu\n"
+          "callback after setup of communication = %p\n",
+          cdiPioConfPtr, iomodeStr, CSRoleStr, conf->partInflate,
+          conf->largePageAlign ? "en" : "dis",
+          (size_t)conf->recordAggBufLimMB * 1024 * 1024,
+          (void *)conf->postCommSetupActions);
+}
+
+
+int cdiPioConfCreate(void)
+{
+  struct cdiPioConf *conf = Malloc(sizeof (*conf));
+  conf->IOMode = PIO_NONE;
+  conf->clientServerRole = PIO_ROLE_CLIENT;
+  conf->partInflate = 1.1f;
+  conf->postCommSetupActions = cdiPioNoPostCommSetup;
+  conf->largePageAlign = false;
+  conf->cacheRedists = true;
+  conf->recordAggBufLimMB = 128;
+  conf->xmap_new = xt_xmap_dist_dir_new;
+  conf->stripify = true;
+  int resH = reshPut(conf, &cdiPioConfOps);
+  /* configuration objects are never forwarded */
+  reshSetStatus(resH, &cdiPioConfOps,
+                reshGetStatus(resH, &cdiPioConfOps) & ~RESH_SYNC_BIT);
+  return resH;
+}
+
+void cdiPioConfDestroy(int confResH)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  cdiPioConfDestroyP(conf);
+  reshRemove(confResH, &cdiPioConfOps);
+}
+
+void cdiPioConfSetPartInflate(int confResH, float partInflate)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  xassert(partInflate >= 1.0f);
+  conf->partInflate = partInflate;
+}
+
+float cdiPioConfGetPartInflate(int confResH)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  return conf->partInflate;
+}
+
+void cdiPioConfSetIOMode(int confResH, int IOMode)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  conf->IOMode = IOMode;
+}
+
+int cdiPioConfGetIOMode(int confResH)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  return conf->IOMode;
+}
+
+void cdiPioConfSetCSRole(int confResH, int CSRole)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  conf->clientServerRole = CSRole;
+}
+
+int cdiPioConfGetCSRole(int confResH)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  return conf->clientServerRole;
+}
+
+void
+cdiPioConfSetPostCommSetupActions(int confResH,
+                                  void (*postCommSetupActions)(void))
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  conf->postCommSetupActions = postCommSetupActions;
+}
+
+void (*cdiPioConfGetPostCommSetupActions(int confResH))(void)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  return conf->postCommSetupActions;
+}
+
+void cdiPioConfSetLargePageAlign(int confResH, int largePageAlign)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  conf->largePageAlign = largePageAlign != 0;
+}
+
+int cdiPioConfGetLargePageAlign(int confResH)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  return conf->largePageAlign;
+}
+
+void cdiPioConfSetRedistCache(int confResH, int doCache)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  conf->cacheRedists = doCache;
+}
+
+int cdiPioConfGetRedistCache(int confResH)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  return conf->cacheRedists;
+}
+
+void cdiPioConfSetRecordAggBufLim(int confResH, int lim_mb)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  if (lim_mb > 0)
+    conf->recordAggBufLimMB = (unsigned)lim_mb;
+  else
+    Error("unexpected negative buffer size value %d requested", lim_mb);
+}
+
+int cdiPioConfGetRecordAggBufLim(int confResH)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  return (int)conf->recordAggBufLimMB;
+}
+
+void cdiPioConfSetXmapNew(int confResH, xmap_new_func_ptr xmap_new)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  conf->xmap_new = xmap_new;
+}
+
+xmap_new_func_ptr cdiPioConfGetXmapNew(int confResH)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  return conf->xmap_new;
+}
+
+void cdiPioConfSetStripeConversion(int confResH, int doConversion)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  conf->stripify = doConversion;
+}
+
+int cdiPioConfGetStripeConversion(int confResH)
+{
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  return conf->stripify;
+}
+
diff --git a/libcdi/src/pio_conf.h b/libcdi/src/pio_conf.h
new file mode 100644
index 0000000..55b209e
--- /dev/null
+++ b/libcdi/src/pio_conf.h
@@ -0,0 +1,87 @@
+#ifndef PIO_CONF_H
+#define PIO_CONF_H
+
+
+#include <stdbool.h>
+
+#include <yaxt.h>
+
+/*
+ * declare data structures and functions to manipulate/query CDI-PIO
+ * configuration object.
+ */
+
+#include "resource_handle.h"
+
+typedef Xt_xmap (*xmap_new_func_ptr)(Xt_idxlist src_idxlist,
+                                     Xt_idxlist dst_idxlist,
+                                     MPI_Comm comm);
+
+/*
+ * cdiPioConf is meant to be internal to the library and not to be
+ * used directly if possible, CDI-PIO users should rely on the
+ * corresponding functions instead.
+ */
+struct cdiPioConf {
+  int IOMode;
+  int clientServerRole;
+  float partInflate;
+  unsigned recordAggBufLimMB;
+  void (*postCommSetupActions)(void);
+  xmap_new_func_ptr xmap_new;
+  bool largePageAlign;
+  bool cacheRedists;
+  bool stripify;
+};
+
+extern const resOps cdiPioConfOps;
+
+int cdiPioConfCreate(void);
+
+void cdiPioConfDestroy(int confResH);
+
+void cdiPioConfSetPartInflate(int confResH, float partInflate);
+
+float cdiPioConfGetPartInflate(int confResH);
+
+void cdiPioConfSetIOMode(int confResH, int IOMode);
+
+int cdiPioConfGetIOMode(int confResH);
+
+void cdiPioConfSetCSRole(int confResH, int CSRole);
+
+int cdiPioConfGetCSRole(int confResH);
+
+void
+cdiPioConfSetpostCommSetupActions(int confResH,
+                                  void (*postCommSetupActions)(void));
+
+void (*cdiPioConfGetpostCommSetupActions(int confResH))(void);
+
+int
+cdiPioIOModeStr2Code(const char *modeStr);
+
+const char *
+cdiPioIOMode2Str(int IOMode);
+
+int cdiPioConfGetLargePageAlign(int confResH);
+
+void cdiPioConfSetLargePageAlign(int confResH, int largePageAlign);
+
+void cdiPioConfSetRedistCache(int confResH, int doCache);
+
+int cdiPioConfGetRedistCache(int confResH);
+
+void cdiPioConfSetRecordAggBufLim(int confResH, int lim_mb);
+
+int cdiPioConfGetRecordAggBufLim(int confResH);
+
+void cdiPioConfSetXmapNew(int confResH, xmap_new_func_ptr xmap_new);
+
+xmap_new_func_ptr cdiPioConfGetXmapNew(int confResH);
+
+void cdiPioConfSetStripeConversion(int confResH, int doConversion);
+
+int cdiPioConfGetStripeConversion(int confResH);
+
+#endif
diff --git a/libcdi/src/pio_dbuffer.c b/libcdi/src/pio_dbuffer.c
index 3338b12..d499925 100644
--- a/libcdi/src/pio_dbuffer.c
+++ b/libcdi/src/pio_dbuffer.c
@@ -13,10 +13,12 @@
 #include <unistd.h>
 #include <string.h>
 
+#include "dmemory.h"
+
 #include "pio_impl.h"
 #include "pio_util.h"
 
-bool localDebug    =false;
+static bool localDebug    =false;
 
 
 int dbuffer_init ( struct dBuffer **dbuffer, size_t size )
@@ -110,8 +112,8 @@ void dbuffer_cleanup ( struct dBuffer **dbuffer )
 
   db = *dbuffer;
 
-  free ( db->buffer );
-  free ( db );
+  Free( db->buffer );
+  Free( db );
 
   return;
 }
diff --git a/libcdi/src/pio_id_set.h b/libcdi/src/pio_id_set.h
new file mode 100644
index 0000000..1d0f878
--- /dev/null
+++ b/libcdi/src/pio_id_set.h
@@ -0,0 +1,67 @@
+#ifndef PIO_ID_LIST_H
+#define PIO_ID_LIST_H
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <limits.h>
+#include <stdlib.h>
+
+#include "cdi.h"
+#include "dmemory.h"
+
+struct idList
+{
+  int *entries;
+  size_t size;
+};
+
+#define emptyIDList ((struct idList){ NULL, 0 })
+
+static inline size_t indexOfID(const struct idList *list, int ID)
+{
+  size_t index = SIZE_MAX;
+  for (size_t i = 0; i < list->size; ++i)
+    if (list->entries[i] == ID)
+      index = i;
+  return index;
+}
+
+static inline size_t insertID(struct idList *list, int ID)
+{
+  size_t index = indexOfID(list, CDI_UNDEFID);
+  if (index == SIZE_MAX)
+    {
+      index = list->size;
+      list->entries = Realloc(list->entries,
+                               ++list->size
+                               * sizeof (list->entries[0]));
+    }
+  list->entries[index] = ID;
+  return index;
+}
+
+static inline void removeID(struct idList *list, int ID)
+{
+  size_t index = indexOfID(list, ID);
+  xassert(index != SIZE_MAX);
+  list->entries[index] = CDI_UNDEFID;
+}
+
+static inline void idSetDestroy(struct idList *list)
+{
+  free(list->entries);
+}
+
+
+#endif
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/pio_impl.h b/libcdi/src/pio_impl.h
index 8481b19..32e8390 100644
--- a/libcdi/src/pio_impl.h
+++ b/libcdi/src/pio_impl.h
@@ -9,6 +9,8 @@
 
 #include <mpi.h>
 
+#include "pio_conf.h"
+
 enum IO_Server_command
 {
   IO_Open_file,
@@ -91,19 +93,19 @@ typedef void (*elemOp)(void *elem, void *data);
 void listSetForeach(listSet *q, elemOp func, void *data);
 
 /* pio_mpinonb.c */
-int       fowMPINONB ( const char * );
-int       fcMPINONB ( int );
-size_t    fwMPINONB( int, int, const void *, size_t );
-void initMPINONB(void (*postCommSetupActions)(void));
-void      finalizeMPINONB ( void );
+void initMPINONB(void);
+
+/* pio_mpi_fw_ordered.c */
+void cdiPioFileWriteOrderedInit(void);
+
+/* pio_mpi_fw_at_all.c */
+void cdiPioFileWriteAtAllInit(void);
 
+/* pio_mpi_fw_at_reblock.c */
+void cdiPioFileWriteAtReblockInit(const struct cdiPioConf *conf);
 
 /* common functionality for file split between collectors and writer(s) */
-int pioSendClose(int);
-int pioSendOpen(const char *);
-size_t pioSendWrite(int, int, const void *, size_t);
-void pioSendInitialize(void (*postCommSetupActions)(void));
-void pioSendFinalize(void);
+void pioSendInitialize(void);
 
 
 /* pio_posixasynch.c */
@@ -112,11 +114,7 @@ void pioWriterAIO(void);
 #endif
 
 /* pio_posixfpguardsendrecv.c */
-int       fowPOSIXFPGUARDSENDRECV ( const char * );
-int       fcPOSIXFPGUARDSENDRECV ( int );
-size_t    fwPOSIXFPGUARDSENDRECV ( int, int, const void *, size_t );
-void      initPOSIXFPGUARDSENDRECV(void (*postCommSetupActions)(void));
-void      finalizePOSIXFPGUARDSENDRECV ( void );
+void      initPOSIXFPGUARDSENDRECV(void);
 
 /* pio_posixnonb.c */
 void pioWriterStdIO(void);
diff --git a/libcdi/src/pio_interface.c b/libcdi/src/pio_interface.c
index d4c67fb..9115b47 100644
--- a/libcdi/src/pio_interface.c
+++ b/libcdi/src/pio_interface.c
@@ -3,9 +3,10 @@
 #endif
 
 #include <limits.h>
+#include <stdarg.h>
+#include <stdbool.h>
 #include <stdlib.h>
 #include <stdio.h>
-#include <stdarg.h>
 
 #include <mpi.h>
 #include <yaxt.h>
@@ -17,6 +18,9 @@
 #include "namespace.h"
 #include "pio.h"
 #include "pio_client.h"
+#include "pio_conf.h"
+#include "pio_id_set.h"
+#include "pio_impl.h"
 #include "pio_serialize.h"
 #include "pio_interface.h"
 #include "pio_comm.h"
@@ -33,32 +37,36 @@ static struct rdmaWin
   size_t size;
   unsigned char *buffer, *head;
   MPI_Win win;
-  int postSet, refuseFuncCall;
-  MPI_Group ioGroup;
   int dictSize, dictDataUsed, dictRPCUsed;
+  bool postSet, refuseFuncCall;
+  /** data or meta-data updates on this stream are to be communicated */
+  bool pendingUpdate;
 } *txWin = NULL;
 
+static struct idList openStreams;
 
 const char * const funcMap[numRPCFuncs] = {
-  "streamOpen",
-  "streamDefVlist",
-  "streamClose",
   "streamDefTimestep",
 };
 
 float cdiPIOpartInflate_;
 
-/****************************************************/
+static inline void
+collWait(size_t streamIdx);
 
-static int cmp ( const void * va, const void * vb )
+static inline void
+collWaitAll()
 {
-    const int ** a, ** b;
+  size_t openStreamsSize = openStreams.size;
+  for (size_t streamIdx = 0; streamIdx < openStreamsSize; ++streamIdx)
+    if (openStreams.entries[streamIdx] != CDI_UNDEFID)
+      collWait(streamIdx);
+}
 
-  a = ( const int ** ) va;
-  b = ( const int ** ) vb;
 
-  return (( **a < **b ) - ( **a > **b ));
-}
+
+
+/****************************************************/
 
 void memcpyPackFunc(void *dataDesc, void *buf, int size, int *pos,
                     void *context)
@@ -72,444 +80,124 @@ void memcpyPackFunc(void *dataDesc, void *buf, int size, int *pos,
 
 /****************************************************/
 
-static void
-mapProblems(int problemSizes[], int * problemMapping, int nProblems,
-            int nWriter, double * w)
-{
-  int *ip[nProblems];
-  int dummy[nProblems];
-  int buckets[nWriter];
-  int currCapacity, nextCapacity;
-  double meanBucket[nWriter];
-  int sum = 0;
-  int writerIdx = 0;
-  int i, j;
-
-
-  for ( i = 0; i < nProblems; i++ )
-    {
-      ip[i] = &problemSizes[i];
-      sum += problemSizes[i];
-    }
-
-  qsort(ip, (size_t)nProblems, sizeof ( int * ), cmp );
-
-  for ( i = 0; i < nProblems; i++ )
-    dummy[i] = (int)(ip[i] - problemSizes);
-
-  for ( j = 0; j < nWriter; j++ )
-    meanBucket[j] = ( double ) sum * ( * ( w + j ));
-
-  memset(buckets, 0, sizeof (buckets));
-
-  for ( i = 0; i < nProblems; i++ )
-    {
-      currCapacity = INT_MIN;
-
-      for ( j = 0; j < nWriter; j++ )
-	{
-	  nextCapacity = (int)meanBucket[j] - ( buckets[j] + ( *ip[i] ));
-
-	  if ( nextCapacity > currCapacity )
-	    {
-	      currCapacity = nextCapacity;
-	      writerIdx = j;
-	    }
-	}
-      problemMapping[ dummy[i] ] = writerIdx;
-      buckets[writerIdx] +=  *ip[i];
-    }
-
-  if ( ddebug )
-    {
-      xprintArray3 (  "problemSizes = ", problemSizes, nProblems, DATATYPE_INT );
-      xprintArray3 ( "vector of indices, qsort of problemSizes", dummy,
-                    nProblems, DATATYPE_INT );
-      xprintArray3 ( "problemMapping", problemMapping, nProblems, DATATYPE_INT );
-      xprintArray3 ( "meanBucket", meanBucket, nWriter, DATATYPE_FLT );
-      xprintArray3 ( "actual buckets", buckets, nWriter, DATATYPE_INT );
-    }
-}
-
-/****************************************************/
-
-/**
-   @brief is encapsulated in CDI library.
-
-   @param vSizes array with number of levels for all var_t 's in order of streams
-
-   @param sSizes array with number of var_t for all stream_t 's
-
-   @param varMapping return value, array with ranks of I/O PEs assigned to var_t 's
-in order of vSizes
-
-   @param nStreams number of stream_t 's
-
-   @param nodeSizes array of number of I/O PEs on each physical nodes, increasing
-   order of ranks assumed
-
-   @param nNodes number of physical nodes hosting I/O PEs
-
-   @return
-*/
-
-static void
-varMapGen(int *vSizes, int *sSizes, int *varMapping,
-          unsigned nStreams, int *nodeSizes, int nNodes)
+struct clientBufferSetup
 {
-
-  int weightsStreams[nStreams];
-  int streamMapping[nStreams];
-  int nPEs = 0, nVars = 0;
-  int i, j, k, offset = 0, offsetN = 0;
-
-  int * weightsVarsNode;
-  int * varMappingNode;
-  int nVarsNode, summandRank = 0;
-  int nProcsColl = commInqNProcsColl ();
-
-  int buckets[nProcsColl];
-
-  for (unsigned i = 0; i < nStreams; i++ )
-    {
-      nVars += sSizes[i];
-      weightsStreams[i] = 0;
-      for ( j = 0; j < * ( sSizes + i ); j++ )
-	weightsStreams[i] += * ( vSizes + offset++ );
-    }
-
-  double *w = (double *)xmalloc((size_t)nNodes * sizeof ( double ));
-  for ( j = 0; j < nNodes; j++ )
-    nPEs += * ( nodeSizes + j );
-
-  for ( j = 0; j < nNodes; j++ )
-    w[j] = ( double ) * ( nodeSizes + j ) / ( double ) nPEs;
-
-  mapProblems(weightsStreams, streamMapping, (int)nStreams, nNodes, w);
-  free ( w );
-
-  for ( i = 0; i < nNodes; i++ )
-    {
-      nVarsNode = 0;
-      for (unsigned j = 0; j < nStreams; j++)
-	if ( * ( streamMapping + j ) == i )
-	  nVarsNode += * ( sSizes + j );
-
-      weightsVarsNode = xmalloc((size_t)nVarsNode * sizeof (int));
-      varMappingNode = xmalloc((size_t)nVarsNode * sizeof ( int ));
-      w = xmalloc((size_t)nodeSizes[i] * sizeof (double));
-      offset = 0;
-      offsetN = 0;
-
-      for (unsigned j = 0; j < nStreams; j++ )
-	if (streamMapping[j] == i)
-	  for ( k = 0; k < * ( sSizes + j ); k ++ )
-	    weightsVarsNode[offsetN++] = vSizes[offset++];
-	else
-	  offset += sSizes[j];
-
-      for ( j = 0; j < * ( nodeSizes + i ); j ++ )
-	w[j] = 1.0 / ( double ) * ( nodeSizes + i );
-
-      mapProblems ( weightsVarsNode, varMappingNode, nVarsNode,
-		    * ( nodeSizes + i ),  w );
-
-      offset = 0;
-      offsetN = 0;
-
-      for (unsigned j = 0; j < nStreams; j++)
-	if ( * ( streamMapping + j ) == i )
-	  for ( k = 0; k < * ( sSizes + j ); k ++ )
-	    * ( varMapping + offset ++ ) =
-              commCollID2RankGlob ( * ( varMappingNode + offsetN ++ ) +
-                                    summandRank );
-	else
-	  offset += * ( sSizes + j );
-
-      summandRank += * ( nodeSizes + i );
-
-      free ( w );
-      free ( varMappingNode );
-      free ( weightsVarsNode );
-    }
-
-  if ( ddebug )
-    {
-      xprintArray ( "varMapping", varMapping, nVars, DATATYPE_INT  );
-      for ( i = 0; i < nProcsColl; i++ )
-	buckets[i] = 0;
-      for ( i = 0; i < nVars; i ++ )
-	buckets[commRankGlob2CollID ( *(varMapping + i ))] += * ( vSizes + i );
-      xprintArray ( "buckets", buckets, nProcsColl, DATATYPE_INT );
-    }
-}
+  struct collSpec collectData;
+  struct clientBufSize *bufSizes;
+  size_t bufSizesCount;
+};
 
 /************************************************************************/
 
 static void
-varsMapNDeco(int nNodes, int *nodeSizes)
+modelWinFlushBuffer(size_t streamIdx)
 {
-  int nVars, * resHs, * streamSizes, * varSizes, * varMapping,
-    * collectsData;
-  int k = 0;
-  int nProcsColl = commInqNProcsColl ();
-
-  xdebug ( "START, nProcsColl=%d", nProcsColl );
-
-  unsigned nStreams = reshCountType(&streamOps);
-
-  resHs       = xmalloc(nStreams * sizeof (resHs[0]));
-  streamSizes = xmalloc(nStreams * sizeof (streamSizes[0]));
-  collectsData = xmalloc((size_t)nProcsColl * sizeof (collectsData[0]));
-  cdiStreamGetIndexList(nStreams, resHs);
-
-  for (unsigned i = 0; i < nStreams; i++ )
-    streamSizes[i] = streamInqNvars(resHs[i]);
-
-  nVars = sum_int((size_t)nStreams, streamSizes);
-  varSizes   = xcalloc((size_t)nVars, sizeof (varSizes[0]));
-  varMapping = xmalloc((size_t)nVars * sizeof (varMapping[0]));
-
-  for (unsigned i = 0; i < nStreams; i++ )
-    {
-      int vlistID = streamInqVlist(resHs[i]);
-      for (int j = 0; j < streamSizes[i]; j++ )
-        varSizes[k++] += vlistInqVarSize(vlistID, j);
-    }
-
-  xassert ( k == nVars );
-
-  varMapGen ( varSizes, streamSizes, varMapping,
-	      nStreams, nodeSizes, nNodes );
-
-  k = 0;
-  for (unsigned i = 0; i < nStreams; i++ )
-    for (int j = 0; j < * ( streamSizes + i ); j++ )
-      {
-        vlistDefVarIOrank ( streamInqVlist ( * ( resHs + i )), j,
-                            * ( varMapping + k ));
-        vlistDefVarIOrank ( streamInqVlistIDorig ( * ( resHs + i )), j,
-                            * ( varMapping + k ));
-        collectsData[commRankGlob2CollID ( varMapping[k++] )] = 1;
-      }
-
-  for (int j = 0; j < nProcsColl; j++ )
-    if ( collectsData[j] == 0 )
-      xabort("AT LEAST ONE COLLECTOR PROCESS IDLES, "
-             "CURRENTLY NOT COVERED: "
-             "PE%d collects no data",
-             commCollID2RankGlob(j));
-
-  if ( varMapping )   free ( varMapping );
-  if ( varSizes )     free ( varSizes );
-  if ( collectsData ) free ( collectsData );
-  if ( streamSizes )  free ( streamSizes );
-  if ( resHs )        free ( resHs );
-
-  xdebug("%s", "RETURN");
+  size_t numStreams = openStreams.size;
+
+  xassert(streamIdx < numStreams
+          && openStreams.entries[streamIdx] != CDI_UNDEFID
+          && txWin != NULL
+          && txWin[streamIdx].buffer != NULL);
+  memset(txWin[streamIdx].buffer, 0, txWin[streamIdx].size);
+  txWin[streamIdx].head = txWin[streamIdx].buffer
+    + (size_t)txWin[streamIdx].dictSize * sizeof (struct winHeaderEntry);
+  txWin[streamIdx].refuseFuncCall = 0;
+  txWin[streamIdx].dictDataUsed = 1;
+  txWin[streamIdx].dictRPCUsed = 0;
+  txWin[streamIdx].pendingUpdate = false;
+  txWin[streamIdx].postSet = false;
+  *(struct winHeaderEntry *)txWin[streamIdx].buffer
+    = (struct winHeaderEntry){
+    .id = HEADERSIZEMARKER,
+    .specific.headerSize = { .numDataEntries = 0, .numRPCEntries = 0 },
+  };
 }
 
-/************************************************************************/
-
-static
-void modelWinCleanup ( void )
-{
-  int collID;
-
-  xdebug("%s", "START");
-  if (txWin != NULL)
-    {
-      for ( collID = 0; collID < commInqNProcsColl (); collID ++ )
-        {
-          if (txWin[collID].postSet)
-            xmpi(MPI_Win_wait(txWin[collID].win));
-          xmpi(MPI_Win_free(&txWin[collID].win));
-          xmpi ( MPI_Free_mem ( txWin[collID].buffer ));
-          xmpi(MPI_Group_free(&txWin[collID].ioGroup));
-        }
-      free(txWin);
-    }
-
-  xdebug("%s", "RETURN. CLEANED UP MPI_WIN'S");
-}
 
 /************************************************************************/
 
-struct collDesc
-{
-  int numDataRecords, numRPCRecords;
-};
-
-static void
-modelWinDefBufferSizes(void)
+void
+cdiPioClientStreamWinInit(int streamID)
 {
-  int collID, * streamIndexList, nvars, varID;
-  size_t sumWinBufferSize = 0;
-  int nProcsColl  = commInqNProcsColl ();
-  int rankGlob    = commInqRankGlob ();
-  int root = commInqRootGlob ();
-  struct collDesc *collIndex;
-
-  xdebug("%s", "START");
-  xassert(txWin != NULL);
-
-  unsigned nstreams = reshCountType ( &streamOps );
-  streamIndexList = xmalloc((size_t)nstreams * sizeof (streamIndexList[0]));
-  collIndex = xcalloc((size_t)nProcsColl, sizeof (collIndex[0]));
-  reshGetResHListOfType ( nstreams, streamIndexList, &streamOps );
-  for (unsigned streamNo = 0; streamNo < nstreams; streamNo++ )
-    {
-      // memory required for data
-      int streamID = streamIndexList[streamNo];
-      int vlistID = streamInqVlist(streamID);
-      nvars = vlistNvars ( vlistID );
-      for ( varID = 0; varID < nvars; varID++ )
-        {
-          int collID = commRankGlob2CollID(vlistInqVarIOrank(vlistID, varID));
-          size_t collIDchunk;
-          {
-            int varSize = vlistInqVarSize(vlistID, varID);
-            int nProcsModel = commInqNProcsModel();
-            collIDchunk = (size_t)ceilf(cdiPIOpartInflate_
-                                        * (float)(varSize + nProcsModel - 1)
-                                        / (float)nProcsModel);
-          }
-          xassert ( collID != CDI_UNDEFID && collIDchunk > 0 );
-          collIndex[collID].numDataRecords += 2;
-          txWin[collID].size += (size_t)collIDchunk * sizeof (double)
-            /* re-align chunks to multiple of double size */
-            + sizeof (double) - 1
-            /* one header for data record, one for corresponding part
-             * descriptor*/
-            + 2 * sizeof (struct winHeaderEntry)
-            /* FIXME: heuristic for size of packed Xt_idxlist */
-            + sizeof (Xt_int) * collIDchunk * 3;
-        }
-
-      // memory required for the function calls encoded
-      // for remote execution
-      // once per stream and timestep for all collprocs only on the modelproc root
-      if ( rankGlob == root )
-        for ( collID = 0; collID < nProcsColl; collID++ )
-          {
-            collIndex[collID].numRPCRecords += numRPCFuncs;
-            txWin[collID].size +=
-              numRPCFuncs * sizeof (struct winHeaderEntry)
-              + MAXDATAFILENAME
-              /* data part of streamDefTimestep */
-              + (2 * CDI_MAX_NAME + sizeof (taxis_t));
-          }
-    }
-  for (collID = 0; collID < nProcsColl; ++collID)
-    {
-      int numRecords = 1 + collIndex[collID].numDataRecords
-        + collIndex[collID].numRPCRecords;
-      txWin[collID].dictSize = numRecords;
-      txWin[collID].dictDataUsed = 1;
-      txWin[collID].dictRPCUsed = 0;
-      /* account for size header */
-      txWin[collID].size += sizeof (struct winHeaderEntry);
-      txWin[collID].size = roundUpToMultiple(txWin[collID].size,
-                                             PIO_WIN_ALIGN);
-      sumWinBufferSize += (size_t)txWin[collID].size;
-    }
-  free(collIndex);
-  free ( streamIndexList );
-
-  xdebug("sumWinBufferSize=%zu, MAXWINBUFFERSIZE=%zu", sumWinBufferSize,
-         (size_t)MAXWINBUFFERSIZE);
-  xassert ( sumWinBufferSize <= (size_t)MAXWINBUFFERSIZE );
-  xdebug("%s", "RETURN");
+  size_t streamIdx = insertID(&openStreams, streamID);
+  txWin = Realloc(txWin, openStreams.size * sizeof (txWin[0]));
+  txWin[streamIdx].win = MPI_WIN_NULL;
+  txWin[streamIdx].buffer = NULL;
+  txWin[streamIdx].postSet = false;
 }
 
-
-/************************************************************************/
-
-
-static
-  void modelWinFlushBuffer ( int collID )
+void
+cdiPioClientStreamWinDestroy(int streamID)
 {
-  int nProcsColl = commInqNProcsColl ();
-
-  xassert ( collID                >= 0         &&
-            collID                < nProcsColl &&
-            txWin != NULL      &&
-            txWin[collID].buffer     != NULL      &&
-            txWin[collID].size <= MAXWINBUFFERSIZE);
-  memset(txWin[collID].buffer, 0, txWin[collID].size);
-  txWin[collID].head = txWin[collID].buffer
-    + (size_t)txWin[collID].dictSize * sizeof (struct winHeaderEntry);
-  txWin[collID].refuseFuncCall = 0;
-  txWin[collID].dictDataUsed = 1;
-  txWin[collID].dictRPCUsed = 0;
+  /* no operation on any other window must overlap this call for
+   * platforms that block the servers in MPI_Win_complete
+   */
+  collWaitAll();
+  size_t streamIdx = indexOfID(&openStreams, streamID);
+  if (txWin[streamIdx].postSet)
+    xmpi(MPI_Win_wait(txWin[streamIdx].win));
+  if (txWin[streamIdx].win != MPI_WIN_NULL)
+    xmpi(MPI_Win_free(&txWin[streamIdx].win));
+  if (txWin[streamIdx].buffer)
+    xmpi(MPI_Free_mem(txWin[streamIdx].buffer));
+  removeID(&openStreams, streamID);
 }
 
 
-/************************************************************************/
-
-
-static
-void modelWinCreate ( void )
+void
+cdiPioClientStreamWinCreate(int streamID, struct collSpec *cspec)
 {
-  int collID, ranks[1];
-  int nProcsColl = commInqNProcsColl ();
-
-  xdebug("%s", "START");
-  txWin = xcalloc((size_t)nProcsColl, sizeof (txWin[0]));
-
-  modelWinDefBufferSizes ();
-  ranks[0] = commInqNProcsModel ();
-
+  /* no operation on any other window must overlap this call for
+   * platforms that block the servers in MPI_Win_complete
+   */
+  collWaitAll();
+  struct clientBufSize bufSize
+    =  computeClientStreamBufSize(streamID, cspec);
   MPI_Info no_locks_info;
   xmpi(MPI_Info_create(&no_locks_info));
   xmpi(MPI_Info_set(no_locks_info, "no_locks", "true"));
-  for ( collID = 0; collID < nProcsColl; collID ++ )
-    {
-      xassert(txWin[collID].size > 0);
-      txWin[collID].buffer = NULL;
-      xmpi(MPI_Alloc_mem((MPI_Aint)txWin[collID].size, MPI_INFO_NULL,
-                         &txWin[collID].buffer));
-      xassert ( txWin[collID].buffer != NULL );
-      txWin[collID].head = txWin[collID].buffer
-        + (size_t)txWin[collID].dictSize * sizeof (struct winHeaderEntry);
-      xmpi(MPI_Win_create(txWin[collID].buffer, (MPI_Aint)txWin[collID].size, 1,
-                          no_locks_info, commInqCommsIO(collID),
-                          &txWin[collID].win));
-      MPI_Group commGroup;
-      xmpi(MPI_Comm_group(commInqCommsIO(collID), &commGroup));
-      xmpi(MPI_Group_incl(commGroup, 1, ranks, &txWin[collID].ioGroup));
-      xmpi(MPI_Group_free(&commGroup));
-    }
-
+  size_t streamIdx = indexOfID(&openStreams, streamID);
+  int dictSize = bufSize.numDataRecords + bufSize.numRPCRecords;
+  size_t streamBufSize = bufSize.bufSize;
+  txWin[streamIdx].dictSize = dictSize;
+  txWin[streamIdx].size = streamBufSize;
+  xmpi(MPI_Alloc_mem((MPI_Aint)streamBufSize, MPI_INFO_NULL,
+                     &txWin[streamIdx].buffer));
+  txWin[streamIdx].head = txWin[streamIdx].buffer
+    + (size_t)dictSize * sizeof (struct winHeaderEntry);
+  MPI_Comm collClientIntraComm = cdiPioInqCollClientIntraComm();
+  xmpi(MPI_Win_create(txWin[streamIdx].buffer, (MPI_Aint)streamBufSize, 1,
+                      no_locks_info, collClientIntraComm,
+                      &txWin[streamIdx].win));
+  modelWinFlushBuffer(streamIdx);
   xmpi(MPI_Info_free(&no_locks_info));
-
-  xdebug("%s", "RETURN, CREATED MPI_WIN'S");
 }
 
+
 /************************************************************************/
 
 static void
-modelWinEnqueue(int collID,
+modelWinEnqueue(size_t streamIdx,
                 struct winHeaderEntry header, const void *data,
                 valPackFunc packFunc)
 {
   struct winHeaderEntry *winDict
-    = (struct winHeaderEntry *)txWin[collID].buffer;
+    = (struct winHeaderEntry *)(void *)txWin[streamIdx].buffer;
   int targetEntry;
   if (header.id > 0 || header.id == PARTDESCMARKER)
-    targetEntry = (txWin[collID].dictDataUsed)++;
+    targetEntry = (txWin[streamIdx].dictDataUsed)++;
   else
-    targetEntry = txWin[collID].dictSize - ++(txWin[collID].dictRPCUsed);
+    targetEntry = txWin[streamIdx].dictSize - ++(txWin[streamIdx].dictRPCUsed);
   if (header.id > 0)
     {
       int offset = header.offset
-        = (int)roundUpToMultiple((size_t)(txWin[collID].head
-                                          - txWin[collID].buffer),
+        = (int)roundUpToMultiple((size_t)(txWin[streamIdx].head
+                                          - txWin[streamIdx].buffer),
                                  sizeof (double));
-      MPI_Comm comm = commInqCommsIO(collID);
-      packFunc((void *)data, txWin[collID].buffer, (int)txWin[collID].size,
+      MPI_Comm comm = cdiPioInqInterComm();
+      packFunc((void *)data, txWin[streamIdx].buffer, (int)txWin[streamIdx].size,
                &offset, &comm);
-      txWin[collID].head = txWin[collID].buffer + offset;
+      txWin[streamIdx].head = txWin[streamIdx].buffer + offset;
     }
   else if (header.id == PARTDESCMARKER)
     {
@@ -530,11 +218,11 @@ modelWinEnqueue(int collID,
           /* not yet used partition descriptor, serialize at
            * current position */
           int position = header.offset
-            = (int)(txWin[collID].head - txWin[collID].buffer);
-          MPI_Comm comm = commInqCommsIO(collID);
-          packFunc((void *)data, txWin[collID].buffer, (int)txWin[collID].size,
+            = (int)(txWin[streamIdx].head - txWin[streamIdx].buffer);
+          MPI_Comm comm = cdiPioInqInterComm();
+          packFunc((void *)data, txWin[streamIdx].buffer, (int)txWin[streamIdx].size,
                    &position, &comm);
-          txWin[collID].head = txWin[collID].buffer + position;
+          txWin[streamIdx].head = txWin[streamIdx].buffer + position;
         }
       else
         /* duplicate entries are copied only once per timestep */
@@ -543,12 +231,13 @@ modelWinEnqueue(int collID,
   else
     {
       int position = header.offset
-        = (int)(txWin[collID].head - txWin[collID].buffer);
-      MPI_Comm comm = commInqCommsIO(collID);
-      packFunc((void *)data, txWin[collID].buffer, (int)txWin[collID].size,
-               &position, &comm);
-      txWin[collID].head = txWin[collID].buffer + position;
+        = (int)(txWin[streamIdx].head - txWin[streamIdx].buffer);
+      MPI_Comm comm = cdiPioInqInterComm();
+      packFunc((void *)data, txWin[streamIdx].buffer,
+               (int)txWin[streamIdx].size, &position, &comm);
+      txWin[streamIdx].head = txWin[streamIdx].buffer + position;
     }
+  txWin[streamIdx].pendingUpdate = true;
   winDict[targetEntry] = header;
 }
 
@@ -564,37 +253,33 @@ cdiPio_xt_idxlist_pack_wrap(void *data, void *buf, int size, int *pos,
 }
 
 static inline void
-collWait(int collID)
+collWait(size_t streamIdx)
 {
-  if (txWin[collID].postSet)
+  if (txWin[streamIdx].postSet)
     {
-      xmpi(MPI_Win_wait(txWin[collID].win));
-      txWin[collID].postSet = 0;
-      modelWinFlushBuffer(collID);
+      xmpi(MPI_Win_wait(txWin[streamIdx].win));
+      modelWinFlushBuffer(streamIdx);
     }
 }
 
 static inline void
-collProbe(int collID)
+collProbe(size_t streamIdx)
 {
-  if (txWin[collID].postSet)
-    {
-      int flag;
-      xmpi(MPI_Win_test(txWin[collID].win, &flag));
-      if (flag)
-        {
-          txWin[collID].postSet = 0;
-          modelWinFlushBuffer(collID);
-        }
-    }
+  if (!txWin[streamIdx].postSet)
+    return;
+  int flag;
+  xmpi(MPI_Win_test(txWin[streamIdx].win, &flag));
+  if (flag)
+    modelWinFlushBuffer(streamIdx);
 }
 
 void
-cdiPioRDMAProgress()
+cdiPioRDMAProgress(void)
 {
-  int nProcsColl = commInqNProcsColl();
-  for (int collID = 0; collID < nProcsColl; collID++)
-    collProbe(collID);
+  size_t nStreams = openStreams.size;
+  for (size_t streamIdx = 0; streamIdx < nStreams; ++streamIdx)
+    if (openStreams.entries[streamIdx] != CDI_UNDEFID)
+      collProbe(streamIdx);
 }
 
 
@@ -603,29 +288,22 @@ pioBufferPartData_(int streamID, int varID,
                    const void *packData, valPackFunc packDataFunc,
                    int nmiss, Xt_idxlist partDesc)
 {
-  int vlistID, collID = CDI_UNDEFID;
-
-  vlistID  = streamInqVlist ( streamID );
-  collID   = commRankGlob2CollID ( vlistInqVarIOrank ( vlistID, varID ));
-  xassert ( collID         >= 0                    &&
-            collID         <  commInqNProcsColl () &&
-            txWin != NULL);
-
-  collWait(collID);
-
+  size_t streamIdx = indexOfID(&openStreams, streamID);
+  xassert(streamIdx != SIZE_MAX);
+  xassert(varID >= 0 && varID < streamInqNvars(streamID));
+  collWaitAll();
 
   struct winHeaderEntry dataHeader
     = { .id = streamID, .specific.dataRecord = { varID, nmiss }, .offset = -1 };
-  modelWinEnqueue(collID, dataHeader, packData, packDataFunc);
+  modelWinEnqueue(streamIdx, dataHeader, packData, packDataFunc);
   {
     struct winHeaderEntry partHeader
       = { .id = PARTDESCMARKER,
           .specific.partDesc = { .uid = xt_idxlist_get_uid(partDesc) },
           .offset = 0 };
-    modelWinEnqueue(collID, partHeader, partDesc, cdiPio_xt_idxlist_pack_wrap);
+    modelWinEnqueue(streamIdx, partHeader, partDesc, cdiPio_xt_idxlist_pack_wrap);
   }
-
-  txWin[collID].refuseFuncCall = 1;
+  txWin[streamIdx].refuseFuncCall = 1;
 }
 
 void
@@ -658,7 +336,8 @@ scatterGatherPackFunc(void *dataDesc, void *buf, int size, int *pos,
   unsigned numBlocks = p->numBlocks;
   const int *bls = p->blocklengths, *disps = p->displacements;
   int pos_ = *pos;
-  unsigned char *dstBuf = buf + pos_, *bufEnd = (unsigned char *)buf + size;
+  unsigned char *dstBuf = (unsigned char *)buf + pos_,
+    *bufEnd = (unsigned char *)buf + size;
   size_t elemSize = p->elemSize;
   xassert(elemSize <= SSIZE_MAX);
   const unsigned char *data = p->data;
@@ -706,30 +385,33 @@ cdiPioBufferPartDataGather(int streamID, int varID, const double *data,
 
 /************************************************************************/
 
-void pioBufferFuncCall(struct winHeaderEntry header,
+void pioBufferFuncCall(int streamID,
+                       struct winHeaderEntry header,
                        const void *data, valPackFunc dataPackFunc)
 {
-  int rankGlob = commInqRankGlob ();
-  int root = commInqRootGlob ();
-  int collID, nProcsColl = commInqNProcsColl ();
   int funcID = header.id;
+  int clientRank = commInqRankModel(),
+    numClients = cdiPioCommInqSizeClients(),
+    numColl = commInqSizeColl(),
+    collRank = cdiPioCollRank(clientRank, numClients, numColl);
 
   xassert(funcID >= MINFUNCID && funcID <= MAXFUNCID);
   xdebug("%s, func: %s", "START", funcMap[(-1 - funcID)]);
 
-  if ( rankGlob != root ) return;
+  /* FIXME: move this check to cdiPioClientSetup */
+  if (clientRank != cdiPioClientRangeStart(collRank, numClients, numColl))
+    return;
 
   xassert(txWin != NULL);
 
-  for (collID = 0; collID < nProcsColl; ++collID)
-    {
-      collWait(collID);
-      xassert(txWin[collID].dictRPCUsed + txWin[collID].dictDataUsed
-              < txWin[collID].dictSize);
-      xassert(txWin[collID].refuseFuncCall == 0);
-      modelWinEnqueue(collID, header, data, dataPackFunc);
-    }
-
+  size_t streamIdx = indexOfID(&openStreams, streamID);
+  if (streamIdx == SIZE_MAX)
+    streamIdx = insertID(&openStreams, streamID);
+  collWaitAll();
+  xassert(txWin[streamIdx].dictRPCUsed + txWin[streamIdx].dictDataUsed
+          < txWin[streamIdx].dictSize
+          && txWin[streamIdx].refuseFuncCall == 0);
+  modelWinEnqueue(streamIdx, header, data, dataPackFunc);
   xdebug("%s", "RETURN");
 }
 
@@ -741,6 +423,9 @@ cdiPioNoPostCommSetup(void)
 
 /*****************************************************************************/
 
+static int pioNamespace_ = -1;
+static int xtInitByCDI = 0;
+
 /* pioInit definition must currently compile even in non-MPI configurations */
 /**
    @brief initializes the MPI_Communicators needed for the
@@ -753,32 +438,45 @@ cdiPioNoPostCommSetup(void)
 
   commModel: calculating PEs, no I/O PEs
 
-  commsIO[i]:
-
   Collective call
 
-  @param comm MPI_Communicator of all calling PEs
-  @param nIOP number of I/O PEs
+  @param commGlob MPI_Communicator of all calling PEs
+  @param nProcsIO number of I/O PEs
   @param partInflate allow for array partitions on comute
   PE that are at most sized \f$ partInflate * \lceil arraySize /
   numComputePEs \rceil \f$
-  @param postSetupActions function which is called by all I/O servers
+  @param postCommSetupActions function which is called by all I/O servers
   after communicator split
   @return int indicating wether the calling PE is a calcutator (1) or not (0)
 */
-
-static int pioNamespace_ = -1;
-static int xtInitByCDI = 0;
-
 MPI_Comm
 pioInit(MPI_Comm commGlob, int nProcsIO, int IOMode,
         int *pioNamespace, float partInflate,
         void (*postCommSetupActions)(void))
 {
+  int confH = cdiPioConfCreate();
+  cdiPioConfSetIOMode(confH, IOMode);
+  cdiPioConfSetPartInflate(confH, partInflate);
+  cdiPioConfSetCSRole(confH, cdiPioCSRLastN(commGlob, IOMode, nProcsIO));
+  cdiPioConfSetPostCommSetupActions(confH, postCommSetupActions);
+  MPI_Comm retcomm = cdiPioInit(commGlob, confH, pioNamespace);
+  cdiPioConfDestroy(confH);
+  return retcomm;
+}
+
+static void cdiPioFileWritingInit(const struct cdiPioConf *conf);
+
+MPI_Comm
+cdiPioInit(MPI_Comm commGlob, int confResH, int *pioNamespace)
+{
   int sizeGlob;
 
+  namespaceSwitchSet(NSSWITCH_ABORT, NSSW_FUNC(cdiAbortC_MPI));
   namespaceSwitchSet(NSSWITCH_WARNING, NSSW_FUNC(cdiPioWarning));
 
+  struct cdiPioConf *conf = reshGetVal(confResH, &cdiPioConfOps);
+  int IOMode = conf->IOMode;
+
   if ( IOMode < PIO_MINIOMODE || IOMode > PIO_MAXIOMODE )
     xabort ( "IOMODE IS NOT VALID." );
 
@@ -789,21 +487,16 @@ pioInit(MPI_Comm commGlob, int nProcsIO, int IOMode,
 
   if ((xtInitByCDI = (!xt_initialized() || xt_finalized())))
     xt_initialize(commGlob);
-  commInit ();
-  commDefCommGlob ( commGlob );
+  int nProcsIO = cdiPioCommInit(commGlob, IOMode, conf->clientServerRole);
   sizeGlob = commInqSizeGlob ();
 
+
   if (((IOMode != PIO_NONE && (nProcsIO <= 0 || nProcsIO > sizeGlob - 1)))
       || (IOMode == PIO_NONE && nProcsIO != 1))
     xabort("DISTRIBUTION OF TASKS ON PROCS IS NOT VALID.\n"
            "nProcsIO=%d, sizeGlob=%d\n", nProcsIO, sizeGlob);
 
-  commDefNProcsIO ( nProcsIO );
-  commDefIOMode   ( IOMode );
-  commDefCommPio  ();
-
-  xassert(partInflate >= 1.0);
-  cdiPIOpartInflate_ = partInflate;
+  cdiPIOpartInflate_ = conf->partInflate;
 
   // JUST FOR TEST CASES WITH ONLY ONE MPI TASK
   if ( commInqSizeGlob () == 1 )
@@ -812,63 +505,98 @@ pioInit(MPI_Comm commGlob, int nProcsIO, int IOMode,
       return commInqCommGlob ();
     }
 
+  reshRemove(confResH, &cdiPioConfOps);
   if ( commInqIsProcIO ())
     {
       cdiPioSerializeSetMPI();
-      namespaceSwitchSet(NSSWITCH_ABORT, NSSW_FUNC(cdiAbortC_MPI));
-      namespaceSwitchSet(NSSWITCH_FILE_OPEN, NSSW_FUNC(pioFileOpen));
-      namespaceSwitchSet(NSSWITCH_FILE_CLOSE, NSSW_FUNC(pioFileClose));
-      cdiPioServer(postCommSetupActions);
-      namespaceNew();
-      commDestroy ();
+      conf->postCommSetupActions();
+      cdiPioFileWritingInit(conf);
+      if (commInqRankColl() >= 0)
+        {
+          cdiPioCollectorMessageLoop(conf);
+          cdiPioFileWritingFinalize();
+        }
+      cdiPioCommFinalize();
       if (xtInitByCDI)
         xt_finalize();
+      reshReplace(confResH, conf, &cdiPioConfOps);
       return MPI_COMM_NULL;
     }
   else
     cdiPioClientSetup(&pioNamespace_, pioNamespace);
 
+  reshReplace(confResH, conf, &cdiPioConfOps);
   xdebug ( "nProcsGlob=%d, RETURN", sizeGlob );
   return commInqCommModel ();
 }
 
+static void
+cdiPioFileWritingInit(const struct cdiPioConf *conf)
+{
+  int IOMode = commInqIOMode ();
+
+  xassert ( IOMode != PIO_NONE  || commInqSizeGlob() == 1 );
+
+  switch ( IOMode )
+    {
+    case PIO_NONE:
+      break;
+    case PIO_MPI:
+      initMPINONB();
+      break;
+#ifndef _SX
+    case PIO_ASYNCH:
+#endif
+    case PIO_WRITER:
+      pioSendInitialize();
+      break;
+    case PIO_FPGUARD:
+      initPOSIXFPGUARDSENDRECV();
+      break;
+    case PIO_MPI_FW_ORDERED:
+      cdiPioFileWriteOrderedInit();
+      break;
+    case PIO_MPI_FW_AT_ALL:
+      cdiPioFileWriteAtAllInit();
+      break;
+    case PIO_MPI_FW_AT_REBLOCK:
+      cdiPioFileWriteAtReblockInit(conf);
+      break;
+    }
+}
+
+static void cdiPioFileWritingFinalizeDefault(void)
+{
+  xabort("error: failed to setup file writing finalization function!");
+}
+
+void (*cdiPioFileWritingFinalize)(void) = cdiPioFileWritingFinalizeDefault;
+
 /*****************************************************************************/
 
 void  pioEndDef ( void )
 {
   char   * buffer;
   int bufferSize;
-  int rankGlob = commInqRankGlob ();
+  int clientRank = commInqRankModel(),
+    numClients = cdiPioCommInqSizeClients(),
+    numColl = commInqSizeColl(),
+    collRank = cdiPioCollRank(clientRank, numClients, numColl);
 
-  xdebug("%s", "START");
-
-  varsMapNDeco ( commInqNNodes (), commInqNodeSizes ());
-
-  if ( rankGlob < commInqNProcsColl ())
+  if (clientRank == cdiPioClientRangeStart(collRank, numClients, numColl))
     {
-      MPI_Comm comm = commInqCommsIO ( rankGlob );
+      MPI_Comm comm = cdiPioInqInterComm();
       reshPackBufferCreate(&buffer, &bufferSize, &comm);
-
-      xmpi ( MPI_Send ( buffer, bufferSize, MPI_PACKED, commInqNProcsModel (),
-                        RESOURCES, commInqCommsIO ( rankGlob )));
-
-      xdebug("%s", "SENT MESSAGE WITH TAG \"RESOURCES\"");
-
-      reshPackBufferDestroy ( &buffer );
+      xmpi(MPI_Send(buffer, bufferSize, MPI_PACKED, collRank,
+                    RESOURCES, comm));
+      reshPackBufferDestroy(&buffer);
     }
-
-  modelWinCreate ();
-  namespaceDefResStatus ( STAGE_TIMELOOP );
-  xdebug("%s", "RETURN");
 }
 
 /************************************************************************/
 
 void  pioEndTimestepping ( void )
 {
-  xdebug("%s", "START");
-  namespaceDefResStatus ( STAGE_CLEANUP );
-  xdebug("%s", "RETURN");
 }
 
 
@@ -876,14 +604,9 @@ void  pioEndTimestepping ( void )
 
 
 /**
-  @brief is invoked by the calculator PEs, to inform
-  the I/O PEs that no more data will be written.
-
-  @param
-
-  @return
-*/
-
+ * @brief is invoked by the calculator PEs, to inform
+ * the I/O PEs that no more data will be written.
+ */
 void pioFinalize ( void )
 {
   xdebug("%s", "START");
@@ -892,14 +615,18 @@ void pioFinalize ( void )
   if (pioNamespace_ == -1)
     return;
   namespaceDelete(pioNamespace_);
-  for (int collID = 0; collID < commInqNProcsColl (); collID++ )
-    {
-      xmpi(MPI_Send(NULL, 0, MPI_INT, commInqNProcsModel(),
-                    FINALIZE, commInqCommsIO ( collID )));
-      xdebug("%s", "SENT MESSAGE WITH TAG \"FINALIZE\"");
-    }
-  modelWinCleanup ();
-  commDestroy ();
+
+  int clientRank = commInqRankModel(),
+    numClients = cdiPioCommInqSizeClients(),
+    numColl = commInqSizeColl(),
+    collRank = cdiPioCollRank(clientRank, numClients, numColl);
+
+  if (clientRank == cdiPioClientRangeStart(collRank, numClients, numColl))
+    xmpi(MPI_Send(NULL, 0, MPI_INT, collRank, FINALIZE, cdiPioInqInterComm()));
+  xdebug("%s", "SENT MESSAGE WITH TAG \"FINALIZE\"");
+  Free(txWin);
+  cdiPioCommFinalize();
+  idSetDestroy(&openStreams);
   if (xtInitByCDI)
     xt_finalize();
   xdebug("%s", "RETURN");
@@ -907,41 +634,50 @@ void pioFinalize ( void )
 
  /************************************************************************/
 
-void pioWriteTimestep()
+void pioWriteTimestep(void)
 {
-  int collID, iAssert = MPI_MODE_NOPUT;
-  /* int tokenEnd = END; */
-  int rankGlob = commInqRankGlob ();
-  int nProcsColl = commInqNProcsColl ();
-  int nProcsModel = commInqNProcsModel ();
+  int clientRank = commInqRankModel(),
+    numClients = cdiPioCommInqSizeClients(),
+    numColl = commInqSizeColl(),
+    collRank = cdiPioCollRank(clientRank, numClients, numColl);
 
   xdebug("%s", "START");
 
   xassert(txWin != NULL);
 
-  if ( rankGlob < nProcsColl )
+  size_t nStreams = openStreams.size;
+  int *hasUpdates = Malloc(nStreams * sizeof (hasUpdates[0]));
+  for (size_t streamIdx = 0; streamIdx < nStreams; ++streamIdx)
     {
-      xmpi(MPI_Send(NULL, 0, MPI_INT, nProcsModel,
-                    WRITETS, commInqCommsIO(rankGlob)));
+      hasUpdates[streamIdx] = txWin[streamIdx].pendingUpdate;
+    }
+
+  if (clientRank == cdiPioClientRangeStart(collRank, numClients, numColl))
+    {
+      xmpi(MPI_Send(hasUpdates, (int)nStreams, MPI_INT,
+                    collRank, WRITETS, cdiPioInqInterComm()));
       xdebug("%s", "SENT MESSAGE WITH TAG \"WRITETS\"");
     }
 
-  for ( collID = 0; collID < nProcsColl; collID++ )
+  MPI_Group remoteGroup = cdiPioInqRemoteGroup();
+  for (size_t streamIdx = 0; streamIdx < nStreams; ++streamIdx)
     {
-      collWait(collID);
+      if (openStreams.entries[streamIdx] != CDI_UNDEFID
+          && hasUpdates[streamIdx]) { }
+      else continue;
       struct winHeaderEntry header
         = { .id = HEADERSIZEMARKER,
             .specific.headerSize
-            = { .numDataEntries = txWin[collID].dictDataUsed,
-                .numRPCEntries = txWin[collID].dictRPCUsed } };
+            = { .numDataEntries = txWin[streamIdx].dictDataUsed,
+                .numRPCEntries = txWin[streamIdx].dictRPCUsed } };
       struct winHeaderEntry *winDict
-        = (struct winHeaderEntry *)txWin[collID].buffer;
+        = (struct winHeaderEntry *)(void *)txWin[streamIdx].buffer;
       winDict[0] = header;
-
-      xmpi(MPI_Win_post(txWin[collID].ioGroup, iAssert, txWin[collID].win));
-      txWin[collID].postSet = 1;
+      xmpi(MPI_Win_post(remoteGroup, MPI_MODE_NOPUT, txWin[streamIdx].win));
+      txWin[streamIdx].postSet = true;
     }
 
+  Free(hasUpdates);
   xdebug("%s", "RETURN. messages sent, windows posted");
 }
 
diff --git a/libcdi/src/pio_interface.h b/libcdi/src/pio_interface.h
index 7ba5120..8a3b1cf 100644
--- a/libcdi/src/pio_interface.h
+++ b/libcdi/src/pio_interface.h
@@ -20,7 +20,8 @@ cdiPioBufferPartDataGather(int streamID, int varID, const double *data,
                            const int displacements[],
                            int nmiss, Xt_idxlist partDesc);
 
-void pioBufferFuncCall(struct winHeaderEntry header,
+void pioBufferFuncCall(int streamID,
+                       struct winHeaderEntry header,
                        const void *data, valPackFunc dataPackFunc);
 
 
@@ -34,6 +35,13 @@ void memcpyPackFunc(void *dataDesc, void *buf, int size, int *pos, void *context
 
 extern float cdiPIOpartInflate_;
 
+void
+cdiPioClientStreamWinInit(int streamID);
+void
+cdiPioClientStreamWinCreate(int streamID, struct collSpec *cspec);
+void
+cdiPioClientStreamWinDestroy(int streamID);
+
 #endif
 /*
  * Local Variables:
diff --git a/libcdi/src/pio_list_set.c b/libcdi/src/pio_list_set.c
index 40d5def..1f2f796 100644
--- a/libcdi/src/pio_list_set.c
+++ b/libcdi/src/pio_list_set.c
@@ -31,7 +31,7 @@ listSet *listSetNew( valDestroyFunction vD, eqPredicate kC )
 {
   listSet *myq;
 
-  myq = (listSet*) xmalloc( sizeof ( listSet ));
+  myq = (listSet*) Malloc( sizeof ( listSet ));
 
   myq->head = NULL;
   myq->tail = NULL;
@@ -55,12 +55,12 @@ listSetDelete(listSet *q)
         {
           succ = curr->next;
           ( *( q->valDestroy )) ( curr->val );
-          free ( curr );
+          Free( curr );
           curr = succ;
         }
     }
 
-  free ( q );
+  Free( q );
 
   return;
 }
@@ -78,7 +78,7 @@ listSetAdd(listSet *q, void *v)
         return -1;
   }
 
-  if ((newCons = (struct cons*) malloc(sizeof(struct cons))) == NULL)
+  if ((newCons = (struct cons*) Malloc(sizeof(struct cons))) == NULL)
     {
       perror ( "pio_listSet: listSetAdd (): Not enough memory" );
       /* FIXME: why not abort? */
@@ -112,7 +112,8 @@ listSetRemove(listSet *q, int (*predicate)(void *, void *),
         if (rem == q->tail) q->tail = NULL;
         int iret = q->valDestroy(rem->val);
         *p = rem->next;
-        free(rem);
+        q->count--;
+        Free(rem);
         return iret;
       }
   return -1;
diff --git a/libcdi/src/pio_mpi_fw_at_all.c b/libcdi/src/pio_mpi_fw_at_all.c
new file mode 100644
index 0000000..22366c9
--- /dev/null
+++ b/libcdi/src/pio_mpi_fw_at_all.c
@@ -0,0 +1,232 @@
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <inttypes.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <mpi.h>
+
+#include "cdi.h"
+#include "dmemory.h"
+#include "namespace.h"
+#include "pio.h"
+#include "pio_comm.h"
+#include "pio_impl.h"
+#include "pio_util.h"
+
+typedef struct
+{
+  MPI_File fh;
+  int fileID;
+  MPI_Offset pos;
+  char *name;
+  int collWriteSize[];
+} aFiledataM;
+
+static listSet *bibAFiledataM;
+
+static int
+fileIDTest(void *a, void *fileID)
+{
+  return ((aFiledataM *)a)->fileID == (int)(intptr_t)fileID;
+}
+
+
+/***************************************************************/
+
+static aFiledataM *
+initAFiledataFileWriteAtAll(const char *filename, size_t bs)
+{
+  MPI_Comm commPio = commInqCommPio();
+  int sizePio = commInqSizePio();
+  size_t nameSize = strlen(filename) + 1;
+  aFiledataM *of = Malloc(sizeof (*of)
+                           + sizeof (of->collWriteSize[0]) * (size_t)sizePio
+                           + nameSize);
+  of->name = (char *)((unsigned char *)of + sizeof (*of)
+                      + sizeof (of->collWriteSize[0]) * (size_t)sizePio);
+  memcpy(of->name, filename, nameSize);
+
+  MPI_Info open_info = MPI_INFO_NULL;
+  xmpi(MPI_Info_create(&open_info));
+  xmpi(MPI_Info_set(open_info, "access_style", "write_once"));
+  xmpi(MPI_Info_set(open_info, "collective_buffering", "true"));
+  /* tell IBM PE to buffer just as much as one buffer holds */
+  {
+    char buf_size_str[3*sizeof(size_t)*CHAR_BIT/8+1];
+    snprintf(buf_size_str, sizeof (buf_size_str), "%zu", bs);
+    xmpi(MPI_Info_set(open_info, "IBM_io_buffer_size", buf_size_str));
+    xmpi(MPI_Info_set(open_info, "IBM_largeblock_io", "false"));
+  }
+  xmpi(MPI_File_open(commPio, of->name,
+                     MPI_MODE_CREATE|MPI_MODE_WRONLY|MPI_MODE_UNIQUE_OPEN,
+                     open_info, &of->fh));
+  xmpi(MPI_Info_free(&open_info));
+  of->pos = 0;
+
+  return of;
+}
+
+/***************************************************************/
+
+static int
+destroyAFiledataFileWriteAtAll(void *v)
+{
+  aFiledataM *of = v;
+
+  /* close file */
+  MPI_Offset endpos, fsize;
+  endpos = of->pos;
+  xmpi(MPI_File_get_size(of->fh, &fsize));
+  /* does the file need to be truncated? */
+  MPI_Comm commPio = commInqCommPio();
+  int trailingOctets = fsize > endpos;
+  xmpi(MPI_Allreduce(MPI_IN_PLACE, &trailingOctets, 1, MPI_INT, MPI_LOR,
+                     commPio));
+  if (trailingOctets)
+    xmpi(MPI_File_set_size(of->fh, endpos));
+  int iret = MPI_File_close(&of->fh);
+
+  Free(of);
+
+  return iret == MPI_SUCCESS ? 0 : -1;
+}
+
+/***************************************************************/
+
+static bool
+compareNamesFileWriteAtAll(void *v1, void *v2)
+{
+  aFiledataM *afm1 = v1, *afm2 = v2;
+  return !strcmp(afm1->name, afm2->name);
+}
+
+/***************************************************************/
+
+static size_t
+fwFileWriteAtAll(int fileID, const void *buffer, size_t len)
+{
+  aFiledataM *of
+    = listSetGet(bibAFiledataM, fileIDTest, (void *)(intptr_t)fileID);
+  xassert(of && len <= INT_MAX);
+  MPI_Comm commPio = commInqCommPio();
+  int sizePio = commInqSizePio(),
+    rankPio = commInqRankPio();
+  /* find position to write to */
+  of->collWriteSize[rankPio] = (int)len;
+  xmpi(MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
+                     of->collWriteSize, 1, MPI_INT, commPio));
+  MPI_Offset myPos = of->pos, nextWritePos;
+  for (size_t i = 0; i < (size_t)rankPio; ++i)
+    myPos += of->collWriteSize[i];
+  nextWritePos = myPos;
+  for (size_t i = (size_t)rankPio; i < (size_t)sizePio; ++i)
+    nextWritePos += of->collWriteSize[i];
+  /* write buffer */
+  xassert(len <= INT_MAX);
+  xmpi(MPI_File_write_at_all(of->fh, myPos, (void *)buffer, (int)len,
+                             MPI_UNSIGNED_CHAR, MPI_STATUS_IGNORE));
+  of->pos = nextWritePos;
+  return len;
+}
+
+/***************************************************************/
+
+static int fcFileWriteAtAll(int fileID)
+{
+  aFiledataM *of
+    = listSetGet(bibAFiledataM, fileIDTest, (void *)(intptr_t)fileID);
+  if (!of)
+    xabort("listSet, fileID=%d not found", fileID);
+  int iret = listSetRemove(bibAFiledataM, fileIDTest, (void *)(intptr_t)fileID);
+  return iret;
+}
+
+/***************************************************************/
+static void
+elemCheck(void *q, void *nm)
+{
+  aFiledataM *afm = q;
+  const char *name = nm;
+
+  if (!strcmp(name, afm->name))
+    xabort("Filename %s has already been added to set\n", name);
+}
+
+
+static int
+fowFileWriteAtAll(const char *filename, const char *mode)
+{
+  static unsigned long buffersize = 0;
+  int id;
+  enum {
+    bcastRoot = 0
+  };
+  MPI_Comm commPio = commInqCommPio ();
+  int rankPio = commInqRankPio ();
+
+  if ((mode[0] != 'w' && mode[0] != 'W') || mode[0] == 0 || mode[1] != 0)
+    xabort("Unsupported mode \"%s\" in parallel file open.", mode);
+
+  /* broadcast buffersize to collectors ( just once, for all files )*/
+
+  if (!buffersize)
+    {
+      if (rankPio == bcastRoot)
+        buffersize = findWriteAccumBufsize();
+      xmpi(MPI_Bcast(&buffersize, 1, MPI_UNSIGNED_LONG, bcastRoot, commPio));
+    }
+
+  xdebug("buffersize=%lu", buffersize);
+
+  listSetForeach(bibAFiledataM, elemCheck, (void *)filename);
+  aFiledataM *of = initAFiledataFileWriteAtAll(filename, (size_t)buffersize);
+
+  if ((id = listSetAdd(bibAFiledataM, of)) < 0 )
+    xabort("filename %s not unique", of->name);
+
+  of->fileID = id;
+  return id;
+}
+
+/***************************************************************/
+
+static void finalizeFileWriteAtAll(void)
+{
+  if (!listSetIsEmpty(bibAFiledataM))
+    xabort("set bibAFiledataM not empty");
+  else
+    {
+      xdebug("%s", "destroy set");
+      listSetDelete(bibAFiledataM);
+    }
+}
+
+/***************************************************************/
+
+void
+cdiPioFileWriteAtAllInit(void)
+{
+  bibAFiledataM = listSetNew( destroyAFiledataFileWriteAtAll, compareNamesFileWriteAtAll );
+
+  namespaceSwitchSet(NSSWITCH_FILE_OPEN, NSSW_FUNC(fowFileWriteAtAll));
+  namespaceSwitchSet(NSSWITCH_FILE_CLOSE, NSSW_FUNC(fcFileWriteAtAll));
+  namespaceSwitchSet(NSSWITCH_FILE_WRITE, NSSW_FUNC(fwFileWriteAtAll));
+  cdiPioFileWritingFinalize = finalizeFileWriteAtAll;
+
+  if ( bibAFiledataM == NULL )
+    xabort ( "listSetNew did not succeed" );
+}
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/pio_mpi_fw_at_reblock.c b/libcdi/src/pio_mpi_fw_at_reblock.c
new file mode 100644
index 0000000..57c1901
--- /dev/null
+++ b/libcdi/src/pio_mpi_fw_at_reblock.c
@@ -0,0 +1,561 @@
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <assert.h>
+#include <errno.h>
+#include <inttypes.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+
+#include <mpi.h>
+
+#include "cdi.h"
+#include "dmemory.h"
+#include "error.h"
+#include "namespace.h"
+#include "pio.h"
+#include "pio_comm.h"
+#include "pio_conf.h"
+#include "pio_impl.h"
+#include "pio_rpc.h"
+#include "pio_util.h"
+
+enum direction {
+  INACTIVE_TX,
+  RECV,
+  SEND,
+};
+
+struct IOmsg
+{
+  int pos, len;                 /* local index of block buffer
+                                 * affected (RECV only) */
+  void *sendBuf;
+  int rank;
+  enum direction direction;
+};
+
+struct pendingBufWrite
+{
+  int pass;
+  int incoming;
+};
+
+typedef struct
+{
+  MPI_File fh;
+  int fileID;
+  int numMsg;
+  MPI_Offset pos;
+  char *name;
+  int blockSize;
+  int numBlockBuf;              /* number of block-sized buffers
+                                 * pointed to by blockBuf */
+  struct pendingBufWrite *pending; /* pendingBufWrite[i].pass
+                                    * indicates pass if non-negative,
+                                    * count gives number of
+                                    * outstanding recvs still to be
+                                    * processed for block buf i */
+  unsigned char *blockBuf;
+  int msgSize;
+  struct IOmsg *msgs;
+  MPI_Request *reqs;
+  long collWriteSize[];          /* used to allgather sizes of writes
+                                 * on different processes */
+} aFiledataM;
+
+static listSet *bibAFiledataM;
+
+
+static int
+fileIDTest(void *a, void *fileID)
+{
+  return ((aFiledataM *)a)->fileID == (int)(intptr_t)fileID;
+}
+
+
+/***************************************************************/
+
+static inline void
+initReblockPendingMsg(aFiledataM *of, size_t i)
+{
+  of->msgs[i].pos = -1;
+  of->msgs[i].len = -1;
+  of->msgs[i].sendBuf = NULL;
+  of->msgs[i].rank = -1;
+  of->msgs[i].direction = INACTIVE_TX;
+  of->reqs[i] = MPI_REQUEST_NULL;
+}
+
+static inline size_t
+gcd(size_t a, size_t b)
+{
+  while (b != 0)
+    {
+      size_t t = a;
+      a = b;
+      b = t % b;
+    }
+  return a;
+}
+
+static inline size_t
+lcm(size_t a, size_t b)
+{
+  return a / gcd(a, b) * b;
+}
+
+static bool largePageAlign;
+
+static size_t
+getXferBufAlign(const char *path)
+{
+  long align = -1L;
+#if HAVE_DECL__PC_REC_XFER_ALIGN
+  align = pathconf(path, _PC_REC_XFER_ALIGN);
+#endif
+  if (align == -1L)
+    align =
+#if HAVE_DECL_POSIX_REC_XFER_ALIGN
+      POSIX_REC_XFER_ALIGN
+#else
+      commonPageSize
+#endif
+      ;
+  return (size_t)align;
+}
+
+static aFiledataM *
+initAFiledataFileWriteAtReblock(const char *filename, size_t bufSize)
+{
+  MPI_Comm commPio = commInqCommPio();
+  int sizePio = commInqSizePio();
+  size_t nameSize = strlen(filename) + 1;
+
+  MPI_Info open_info = MPI_INFO_NULL;
+  xmpi(MPI_Info_create(&open_info));
+  xmpi(MPI_Info_set(open_info, "access_style", "write_once"));
+  xmpi(MPI_Info_set(open_info, "collective_buffering", "false"));
+  /* tell IBM PE to not buffer anything, we block-align all writes */
+  xmpi(MPI_Info_set(open_info, "IBM_io_buffer_size", "0"));
+  xmpi(MPI_Info_set(open_info, "IBM_largeblock_io", "true"));
+  MPI_File fh;
+  xmpi(MPI_File_open(commPio, (char *)filename,
+                     MPI_MODE_CREATE|MPI_MODE_WRONLY|MPI_MODE_UNIQUE_OPEN,
+                     open_info, &fh));
+  xmpi(MPI_Info_free(&open_info));
+  /* find block size of underlying file system */
+  size_t blockSize, bufBlockAlign;
+  {
+    struct stat posixstat;
+    int rc = stat(filename, &posixstat);
+    if (rc < 0)
+      {
+        perror("failed to stat file after open, block size unavailable,"
+               " assuming 4MiB");
+        posixstat.st_blksize = 4 * 1024 * 1024;
+      }
+    blockSize = (size_t)posixstat.st_blksize < SIZE_MAX
+      ? (size_t)posixstat.st_blksize
+      : SIZE_MAX/2;
+    /* prevent inefficiently small writes on granular file systems */
+#define MINBLOCKSIZE ((size_t)1 << 19)
+    if ((blockSize < MINBLOCKSIZE) & !(MINBLOCKSIZE % blockSize))
+      blockSize = MINBLOCKSIZE;
+#undef MINBLOCKSIZE
+    /* ensure block size also meets page and direct I/O buffer
+     * alignment requirements */
+    size_t pageSize = cdiPioGetPageSize(largePageAlign),
+      IOAlign = getXferBufAlign(filename);
+    bufBlockAlign = lcm(pageSize, IOAlign);
+    blockSize = lcm(blockSize, bufBlockAlign);
+  }
+  /* round bufSize to next multiple of block size and I/O alignment */
+  bufSize = roundUpToMultiple(bufSize, blockSize);
+  size_t numBlockBuf = bufSize / blockSize;
+  assert(blockSize <= INT_MAX && numBlockBuf <= INT_MAX);
+  /* never go less than double-buffering */
+  if (numBlockBuf < 2)
+    {
+      numBlockBuf = 2;
+      bufSize = blockSize * 2;
+    }
+  aFiledataM *of
+    = Malloc(sizeof (*of) + sizeof (of->collWriteSize[0]) * (size_t)sizePio
+              + nameSize);
+  of->fh = fh;
+  of->name = (char *)((unsigned char *)of + sizeof (*of)
+                      + sizeof (of->collWriteSize[0]) * (size_t)sizePio);
+  memcpy(of->name, filename, nameSize);
+  {
+    void *ptr;
+    int err = posix_memalign(&ptr, bufBlockAlign, bufSize);
+    if (!err)
+      of->blockBuf = ptr;
+    else
+      cdiAbort(__FILE__, __func__, __LINE__, "posix_memalign failed: %s",
+               strerror(errno));
+  }
+  of->pending = (struct pendingBufWrite *)
+    Malloc(numBlockBuf * sizeof (struct pendingBufWrite));
+  for (size_t i = 0; i < numBlockBuf; ++i)
+    {
+      of->pending[i].pass = -1;
+      of->pending[i].incoming = 0;
+    }
+  of->blockSize = (int)blockSize;
+  of->numBlockBuf = (int)numBlockBuf;
+  size_t numPeers = (size_t)commInqSizePio();
+  /* start with 2 sends and 2 recvs per peer simultaneously */
+  size_t msgSize = numPeers * 4;
+  assert(msgSize <= INT_MAX);
+  of->msgSize = (int)msgSize;
+  of->msgs = Malloc(sizeof (of->msgs[0]) * msgSize);
+  of->reqs = Malloc(sizeof (of->reqs[0]) * msgSize);
+  for (size_t i = 0; i < (size_t)msgSize; ++i)
+    initReblockPendingMsg(of, i);
+  of->pos = 0;
+  of->numMsg = 0;
+  return of;
+}
+
+/***************************************************************/
+
+static void
+flushReblockBuffer(aFiledataM *of, int blockBufIdx);
+
+static int
+destroyAFiledataFileWriteAtReblock(void *v)
+{
+  aFiledataM *of = v;
+
+  size_t numBlockBuf = (size_t)of->numBlockBuf;
+  /* flush pending buffers */
+  /** 1. handle all outstanding messages */
+  xmpi(MPI_Waitall(of->numMsg, of->reqs, MPI_STATUSES_IGNORE));
+  of->numMsg = 0;
+  for (size_t block = 0; block < numBlockBuf; ++block)
+    {
+      of->pending[block].incoming = 0;
+      if (of->pending[block].pass != -1)
+        flushReblockBuffer(of, (int)block);
+    }
+  /* close file */
+  MPI_Offset endpos, fsize;
+  endpos = of->pos;
+  xmpi(MPI_File_get_size(of->fh, &fsize));
+  /* does the file need to be truncated? */
+  MPI_Comm commPio = commInqCommPio();
+  int trailingOctets = fsize > endpos;
+  xmpi(MPI_Allreduce(MPI_IN_PLACE, &trailingOctets, 1, MPI_INT, MPI_LOR,
+                     commPio));
+  if (trailingOctets)
+    xmpi(MPI_File_set_size(of->fh, endpos));
+  int iret = MPI_File_close(&of->fh);
+  for (size_t i = 0; i < (size_t)of->msgSize; ++i)
+    Free(of->msgs[i].sendBuf);
+  free(of->blockBuf);
+  Free(of->msgs);
+  Free(of->reqs);
+  Free(of->pending);
+  Free(of);
+
+  return iret == MPI_SUCCESS ? 0 : -1;
+}
+
+/***************************************************************/
+
+static bool
+compareNamesFileWriteAtReblock(void *v1, void *v2)
+{
+  aFiledataM *afm1 = v1, *afm2 = v2;
+  return !strcmp(afm1->name, afm2->name);
+}
+
+/***************************************************************/
+
+static inline long
+lmin(long a, long b)
+{
+  return a < b ? a : b;
+}
+
+static void
+flushReblockBuffer(aFiledataM *of, int blockBufIdx)
+{
+  int blockSize = of->blockSize;
+  unsigned char *blockBuf = of->blockBuf + blockSize * blockBufIdx;
+  int finIdx, numMsg = of->numMsg;
+  while (of->pending[blockBufIdx].incoming)
+    {
+      /* todo: switch to MPI_Waitsome */
+      xmpi(MPI_Waitany(numMsg, of->reqs, &finIdx, MPI_STATUS_IGNORE));
+      if (finIdx != MPI_UNDEFINED)
+        {
+          int blockBufIdx = of->msgs[finIdx].pos;
+          if (blockBufIdx >= 0 && of->msgs[finIdx].direction == RECV)
+            --(of->pending[blockBufIdx].incoming);
+          else if (of->msgs[finIdx].direction == SEND)
+            Free(of->msgs[finIdx].sendBuf);
+          else
+            xabort("internal error");
+          of->msgs[finIdx] = of->msgs[numMsg - 1];
+          of->msgs[numMsg - 1].sendBuf = NULL;
+          of->reqs[finIdx] = of->reqs[numMsg - 1];
+          --numMsg;
+        }
+    }
+  int sizePio = commInqSizePio(),
+    rankPio = commInqRankPio();
+  MPI_Offset ofs = (MPI_Offset)blockSize
+    * (((MPI_Offset)of->pending[blockBufIdx].pass * (MPI_Offset)sizePio
+        * of->numBlockBuf)
+       + (MPI_Offset)blockBufIdx * (MPI_Offset)sizePio
+       + (MPI_Offset)rankPio);
+  int wsize = of->pos >= ofs + blockSize ? blockSize : (int)(of->pos - ofs);
+  xmpi(MPI_File_write_at(of->fh, ofs, blockBuf, wsize, MPI_UNSIGNED_CHAR,
+                         MPI_STATUS_IGNORE));
+  of->pending[blockBufIdx].pass = -1;
+  of->numMsg = numMsg;
+}
+
+static void
+reblockMoreMsgs(aFiledataM *of, int numMsg)
+{
+  /* optimize with MPI_Testsome */
+  if (of->msgSize == numMsg)
+    {
+      size_t newMsgSize = (size_t)numMsg * 2;
+      of->msgs = Realloc(of->msgs, sizeof (of->msgs[0]) * newMsgSize);
+      of->reqs = Realloc(of->reqs, sizeof (of->reqs[0]) * newMsgSize);
+      for (size_t i = (size_t)numMsg; i < newMsgSize; ++i)
+        initReblockPendingMsg(of, i);
+      assert(newMsgSize <= INT_MAX);
+      of->msgSize = (int)newMsgSize;
+    }
+}
+
+
+static size_t
+fwFileWriteAtReblock(int fileID, const void *buffer, size_t len)
+{
+  aFiledataM *of
+    = listSetGet(bibAFiledataM, fileIDTest, (void *)(intptr_t)fileID);
+  xassert(of && len <= INT_MAX);
+  MPI_Comm commPio = commInqCommPio();
+  int sizePio = commInqSizePio(),
+    rankPio = commInqRankPio();
+  /* find position to write to */
+  of->collWriteSize[rankPio] = (long)len;
+  xmpi(MPI_Allgather(MPI_IN_PLACE, 0, MPI_DATATYPE_NULL,
+                     of->collWriteSize, 1, MPI_LONG, commPio));
+  /* figure out which block buffers intersect locally held data and
+   * what remotely held data intersects buffers on task */
+  int blockSize = of->blockSize;
+  MPI_Offset fWOfs = of->pos;
+  int numBlockBuf = of->numBlockBuf;
+  int numMsg = of->numMsg;
+  const unsigned char *inBuf = buffer;
+  const unsigned char *directWriteBuf;
+  /* positive value iff direct write occurs */
+  int directWriteSize = -1;
+  MPI_Offset directWriteOfs;
+  for (int collRank = 0; collRank < sizePio; ++collRank)
+    if (of->collWriteSize[collRank])
+    {
+      long remaining = of->collWriteSize[collRank];
+      do {
+        MPI_Offset collBlockSize = (MPI_Offset)blockSize * (MPI_Offset)sizePio;
+        int pass = (int)(fWOfs / collBlockSize / numBlockBuf);
+        int inBlockPos =  (int)(fWOfs % (MPI_Offset)blockSize);
+        int txLen = (int)lmin(blockSize - inBlockPos, remaining);
+        int destRank = (int)(fWOfs / (MPI_Offset)blockSize) % sizePio;
+        if (txLen == blockSize)
+          {
+            /* a properly aligned portion can be written directly */
+            txLen = (int)(remaining - remaining % blockSize);
+            if (collRank == rankPio)
+              {
+                directWriteBuf = inBuf;
+                inBuf += txLen;
+                directWriteSize = txLen;
+                directWriteOfs = fWOfs;
+              }
+          }
+        else if (destRank == rankPio)
+          {
+            int blockBufIdx = (int)(fWOfs / collBlockSize) % numBlockBuf;
+            if (of->pending[blockBufIdx].pass >= 0
+                && of->pending[blockBufIdx].pass != pass)
+              {
+                of->numMsg = numMsg;
+                flushReblockBuffer(of, blockBufIdx);
+                numMsg = of->numMsg;
+              }
+            if (collRank != rankPio)
+              {
+                reblockMoreMsgs(of, numMsg);
+                /* this rank is to write out (part of) the data, but it
+                 * resides on another rank */
+                of->msgs[numMsg] = (struct IOmsg){
+                  .pos = blockBufIdx,
+                  .len = txLen,
+                  .rank = collRank,
+                  .direction = RECV,
+                };
+                xmpi(MPI_Irecv(of->blockBuf
+                               + (size_t)blockBufIdx * (size_t)blockSize
+                               + (size_t)inBlockPos,
+                               txLen, MPI_UNSIGNED_CHAR, collRank, BLOCK_XFER,
+                               commPio, of->reqs + numMsg));
+                ++numMsg;
+                ++(of->pending[blockBufIdx].incoming);
+              }
+            else /* if (collRank == rankPio) */
+              {
+                memcpy(of->blockBuf
+                       + (size_t)blockBufIdx * (size_t)blockSize
+                       + (size_t)inBlockPos,
+                       inBuf, (size_t)txLen);
+                inBuf += txLen;
+              }
+            of->pending[blockBufIdx].pass = pass;
+          }
+        else if (collRank == rankPio)
+          {
+            reblockMoreMsgs(of, numMsg);
+            /* this rank has the data and will send it to the one doing
+             * the writing */
+            of->msgs[numMsg] = (struct IOmsg){
+              .pos = -1,
+              .len = txLen,
+              .rank = destRank,
+              .direction = SEND,
+            };
+            void *restrict buf = of->msgs[numMsg].sendBuf
+              = Realloc(of->msgs[numMsg].sendBuf, (size_t)txLen);
+            memcpy(buf, inBuf, (size_t)txLen);
+            xmpi(MPI_Isend(buf, txLen, MPI_UNSIGNED_CHAR,
+                           destRank, BLOCK_XFER, commPio, of->reqs + numMsg));
+            inBuf += txLen;
+            ++numMsg;
+          }
+        fWOfs += txLen;
+        remaining -= txLen;
+      } while (remaining);
+    }
+  if (directWriteSize > -1)
+    xmpi(MPI_File_write_at(of->fh, directWriteOfs,
+                           (unsigned char *)directWriteBuf,
+                           directWriteSize, MPI_UNSIGNED_CHAR,
+                           MPI_STATUS_IGNORE));
+  of->numMsg = numMsg;
+  of->pos = fWOfs;
+  return len;
+}
+
+/***************************************************************/
+
+static int fcFileWriteAtReblock(int fileID)
+{
+  aFiledataM *of
+    = listSetGet(bibAFiledataM, fileIDTest, (void *)(intptr_t)fileID);
+  if (!of)
+    xabort("listSet, fileID=%d not found", fileID);
+  int iret = listSetRemove(bibAFiledataM, fileIDTest, (void *)(intptr_t)fileID);
+  return iret;
+}
+
+/***************************************************************/
+static void
+elemCheck(void *q, void *nm)
+{
+  aFiledataM *afm = q;
+  const char *name = nm;
+
+  if (!strcmp(name, afm->name))
+    xabort("Filename %s has already been added to set\n", name);
+}
+
+
+static int
+fowFileWriteAtReblock(const char *filename, const char *mode)
+{
+  static unsigned long buffersize = 0;
+  int id;
+  enum {
+    bcastRoot = 0
+  };
+  MPI_Comm commPio = commInqCommPio ();
+  int rankPio = commInqRankPio ();
+
+  if ((mode[0] != 'w' && mode[0] != 'W') || mode[0] == 0 || mode[1] != 0)
+    xabort("Unsupported mode \"%s\" in parallel file open.", mode);
+
+  /* broadcast buffersize to collectors ( just once, for all files )*/
+
+  if (!buffersize)
+    {
+      if (rankPio == bcastRoot)
+        buffersize = findWriteAccumBufsize();
+      xmpi(MPI_Bcast(&buffersize, 1, MPI_UNSIGNED_LONG, bcastRoot, commPio));
+    }
+
+  xdebug("buffersize=%lu", buffersize);
+
+  listSetForeach(bibAFiledataM, elemCheck, (void *)filename);
+  aFiledataM *of = initAFiledataFileWriteAtReblock(filename, (size_t)buffersize);
+
+  if ((id = listSetAdd(bibAFiledataM, of)) < 0 )
+    xabort("filename %s not unique", of->name);
+
+  of->fileID = id;
+  return id;
+}
+
+/***************************************************************/
+
+static void finalizeFileWriteAtReblock(void)
+{
+  if (!listSetIsEmpty(bibAFiledataM))
+    xabort("set bibAFiledataM not empty");
+  else
+    {
+      xdebug("%s", "destroy set");
+      listSetDelete(bibAFiledataM);
+    }
+}
+
+/***************************************************************/
+
+void
+cdiPioFileWriteAtReblockInit(const struct cdiPioConf *conf)
+{
+  bibAFiledataM = listSetNew( destroyAFiledataFileWriteAtReblock, compareNamesFileWriteAtReblock );
+  namespaceSwitchSet(NSSWITCH_FILE_OPEN, NSSW_FUNC(fowFileWriteAtReblock));
+  namespaceSwitchSet(NSSWITCH_FILE_CLOSE, NSSW_FUNC(fcFileWriteAtReblock));
+  namespaceSwitchSet(NSSWITCH_FILE_WRITE, NSSW_FUNC(fwFileWriteAtReblock));
+  cdiPioFileWritingFinalize = finalizeFileWriteAtReblock;
+
+  largePageAlign = conf->largePageAlign;
+
+  if ( bibAFiledataM == NULL )
+    xabort ( "listSetNew did not succeed" );
+}
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/pio_mpi_fw_ordered.c b/libcdi/src/pio_mpi_fw_ordered.c
new file mode 100644
index 0000000..3a6eec9
--- /dev/null
+++ b/libcdi/src/pio_mpi_fw_ordered.c
@@ -0,0 +1,211 @@
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <inttypes.h>
+#include <limits.h>
+#include <stdbool.h>
+#include <stdio.h>
+#include <string.h>
+#include <mpi.h>
+
+#include "cdi.h"
+#include "dmemory.h"
+#include "namespace.h"
+#include "pio.h"
+#include "pio_comm.h"
+#include "pio_impl.h"
+#include "pio_util.h"
+
+typedef struct
+{
+  MPI_File fh;
+  int fileID;
+  char name[];
+} aFiledataM;
+
+static listSet *bibAFiledataM;
+
+static int
+fileIDTest(void *a, void *fileID)
+{
+  return ((aFiledataM *)a)->fileID == (int)(intptr_t)fileID;
+}
+
+
+/***************************************************************/
+
+static aFiledataM *
+initAFiledataFileWriteOrdered(const char *filename, size_t bs)
+{
+  MPI_Comm commPio = commInqCommPio();
+  aFiledataM *of = Malloc(sizeof (*of) + strlen(filename) + 1);
+
+  strcpy(of->name, filename);
+
+  MPI_Info open_info = MPI_INFO_NULL;
+  xmpi(MPI_Info_create(&open_info));
+  xmpi(MPI_Info_set(open_info, "access_style", "sequential,write_once"));
+  xmpi(MPI_Info_set(open_info, "collective_buffering", "true"));
+  /* tell IBM PE to buffer just as much as one buffer holds */
+  {
+    char buf_size_str[3*sizeof(size_t)*CHAR_BIT/8+1];
+    snprintf(buf_size_str, sizeof (buf_size_str), "%zu", bs);
+    xmpi(MPI_Info_set(open_info, "IBM_io_buffer_size", buf_size_str));
+    xmpi(MPI_Info_set(open_info, "IBM_largeblock_io", "false"));
+  }
+  xmpi(MPI_File_open(commPio, of->name,
+                     MPI_MODE_CREATE|MPI_MODE_WRONLY|MPI_MODE_UNIQUE_OPEN,
+                     open_info, &of->fh));
+  xmpi(MPI_Info_free(&open_info));
+
+  return of;
+}
+
+/***************************************************************/
+
+static int
+destroyAFiledataFileWriteOrdered(void *v)
+{
+  aFiledataM *of = v;
+  /* close file */
+  MPI_Offset endpos, fsize;
+  xmpi(MPI_File_get_position_shared(of->fh, &endpos));
+  xmpi(MPI_File_get_size(of->fh, &fsize));
+  /* does the file need to be truncated? */
+  MPI_Comm commPio = commInqCommPio();
+  int trailingOctets = fsize > endpos;
+  xmpi(MPI_Allreduce(MPI_IN_PLACE, &trailingOctets, 1, MPI_INT, MPI_LOR,
+                     commPio));
+  if (trailingOctets)
+    xmpi(MPI_File_set_size(of->fh, endpos));
+  int iret = MPI_File_close(&of->fh);
+
+  Free(of);
+
+  return iret == MPI_SUCCESS ? 0 : -1;
+}
+
+/***************************************************************/
+
+static bool
+compareNamesFileWriteOrdered(void *v1, void *v2)
+{
+  aFiledataM *afm1 = v1, *afm2 = v2;
+  return !strcmp(afm1->name, afm2->name);
+}
+
+/***************************************************************/
+
+static size_t
+fwFileWriteOrdered(int fileID, const void *buffer, size_t len)
+{
+  aFiledataM *of
+    = listSetGet(bibAFiledataM, fileIDTest, (void *)(intptr_t)fileID);
+  xassert(of);
+
+  /* write buffer */
+  xassert(len <= INT_MAX);
+  MPI_Status status;
+  xmpi(MPI_File_write_ordered(of->fh, (void *)buffer, (int)len,
+                              MPI_UNSIGNED_CHAR, &status));
+  return len;
+}
+
+/***************************************************************/
+
+static int fcFileWriteOrdered(int fileID)
+{
+  aFiledataM *of
+    = listSetGet(bibAFiledataM, fileIDTest, (void *)(intptr_t)fileID);
+  if (!of)
+    xabort("listSet, fileID=%d not found", fileID);
+  int iret = listSetRemove(bibAFiledataM, fileIDTest, (void *)(intptr_t)fileID);
+  return iret;
+}
+
+/***************************************************************/
+static void
+elemCheck(void *q, void *nm)
+{
+  aFiledataM *afm = q;
+  const char *name = nm;
+
+  if (!strcmp(name, afm->name))
+    xabort("Filename %s has already been added to set\n", name);
+}
+
+
+static int
+fowFileWriteOrdered(const char *filename, const char *mode)
+{
+  static unsigned long buffersize = 0;
+  int id;
+  enum {
+    bcastRoot = 0
+  };
+  MPI_Comm commPio = commInqCommPio ();
+  int rankPio = commInqRankPio ();
+
+  if ((mode[0] != 'w' && mode[0] != 'W') || mode[0] == 0 || mode[1] != 0)
+    xabort("Unsupported mode \"%s\" in parallel file open.", mode);
+
+  /* broadcast buffersize to collectors ( just once, for all files )*/
+
+  if (!buffersize)
+    {
+      if (rankPio == bcastRoot)
+        buffersize = findWriteAccumBufsize();
+      xmpi(MPI_Bcast(&buffersize, 1, MPI_UNSIGNED_LONG, bcastRoot, commPio));
+    }
+
+  xdebug("buffersize=%lu", buffersize);
+
+  listSetForeach(bibAFiledataM, elemCheck, (void *)filename);
+  aFiledataM *of = initAFiledataFileWriteOrdered(filename, (size_t)buffersize);
+
+  if ((id = listSetAdd(bibAFiledataM, of)) < 0 )
+    xabort("filename %s not unique", of->name);
+
+  of->fileID = id;
+  return id;
+}
+
+/***************************************************************/
+
+static void finalizeFileWriteOrdered(void)
+{
+  if (!listSetIsEmpty(bibAFiledataM))
+    xabort("set bibAFiledataM not empty");
+  else
+    {
+      xdebug("%s", "destroy set");
+      listSetDelete(bibAFiledataM);
+    }
+}
+
+/***************************************************************/
+
+void
+cdiPioFileWriteOrderedInit(void)
+{
+  bibAFiledataM = listSetNew( destroyAFiledataFileWriteOrdered, compareNamesFileWriteOrdered );
+
+  namespaceSwitchSet(NSSWITCH_FILE_OPEN, NSSW_FUNC(fowFileWriteOrdered));
+  namespaceSwitchSet(NSSWITCH_FILE_CLOSE, NSSW_FUNC(fcFileWriteOrdered));
+  namespaceSwitchSet(NSSWITCH_FILE_WRITE, NSSW_FUNC(fwFileWriteOrdered));
+  cdiPioFileWritingFinalize = finalizeFileWriteOrdered;
+
+  if ( bibAFiledataM == NULL )
+    xabort ( "listSetNew did not succeed" );
+}
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/pio_mpinonb.c b/libcdi/src/pio_mpinonb.c
index b87eeae..3fa422f 100644
--- a/libcdi/src/pio_mpinonb.c
+++ b/libcdi/src/pio_mpinonb.c
@@ -3,6 +3,7 @@
 #endif
 
 #include <inttypes.h>
+#include <limits.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <string.h>
@@ -10,6 +11,7 @@
 
 #include "cdi.h"
 #include "dmemory.h"
+#include "namespace.h"
 #include "pio.h"
 #include "pio_comm.h"
 #include "pio_impl.h"
@@ -42,11 +44,8 @@ fileIDTest(void *a, void *fileID)
 
 static aFiledataM *initAFiledataMPINONB ( const char *filename, size_t bs )
 {
-  aFiledataM *of = NULL;
-  int iret;
-  MPI_Comm commNode = commInqCommNode ();
-
-  of = (aFiledataM*) xmalloc(sizeof (*of) + strlen(filename) + 1);
+  MPI_Comm commPio = commInqCommPio();
+  aFiledataM *of = (aFiledataM *)Malloc(sizeof (*of) + strlen(filename) + 1);
 
   strcpy(of->name, filename);
   of->size = bs;
@@ -54,8 +53,7 @@ static aFiledataM *initAFiledataMPINONB ( const char *filename, size_t bs )
   of->db2 = NULL;
 
   /* init output buffer */
-
-  iret = dbuffer_init ( &( of->db1 ), of->size );
+  int iret = dbuffer_init ( &( of->db1 ), of->size );
   iret += dbuffer_init ( &( of->db2 ), of->size );
 
   if ( iret > 0 ) xabort ( "dbuffer_init did not succeed" );
@@ -64,9 +62,19 @@ static aFiledataM *initAFiledataMPINONB ( const char *filename, size_t bs )
 
   of->tsID = CDI_UNDEFID;
 
-  /* open file */
-  xmpi(MPI_File_open(commNode, of->name, MPI_MODE_CREATE|MPI_MODE_WRONLY,
-                     MPI_INFO_NULL, &( of->fh )));
+
+  MPI_Info open_info = MPI_INFO_NULL;
+  /* tell IBM PE to buffer just as much as one buffer holds */
+  {
+    xmpi(MPI_Info_create(&open_info));
+    char buf_size_str[3*sizeof(size_t)*CHAR_BIT/8+1];
+    snprintf(buf_size_str, sizeof (buf_size_str), "%zu", bs);
+    xmpi(MPI_Info_set(open_info, "IBM_io_buffer_size", buf_size_str));
+    xmpi(MPI_Info_set(open_info, "IBM_largeblock_io", "true"));
+  }
+  xmpi(MPI_File_open(commPio, of->name, MPI_MODE_CREATE|MPI_MODE_WRONLY,
+                     open_info, &of->fh));
+  xmpi(MPI_Info_free(&open_info));
   of->request = MPI_REQUEST_NULL;
   of->finished = false;
 
@@ -81,17 +89,16 @@ destroyAFiledataMPINONB(void *v)
   int iret = 0;
   aFiledataM *of;
   MPI_Status status;
-  int rankNode = commInqRankNode ();
   MPI_Offset endpos;
 
   of = (aFiledataM * ) v;
 
-  xdebug ( "IOPE%d: close file %d, name=\"%s\"",
-           rankNode, of->fileID, of->name );
+  xdebug("IOPE%d: close file %d, name=\"%s\"", commInqRankGlob(), of->fileID,
+         of->name);
 
   /* close file */
   xmpi(MPI_Wait(&of->request, &status));
-  xmpi(MPI_Barrier(commInqCommNode()));
+  xmpi(MPI_Barrier(commInqCommPio()));
   xmpi(MPI_File_get_position_shared(of->fh, &endpos));
   xmpi(MPI_File_set_size(of->fh, endpos));
   iret = MPI_File_close ( & ( of->fh ));
@@ -101,10 +108,9 @@ destroyAFiledataMPINONB(void *v)
   dbuffer_cleanup ( & ( of->db1 ));
   dbuffer_cleanup ( & ( of->db2 ));
 
-  free ( of );
+  Free( of );
 
-  xdebug ( "IOPE%d: closed file, cleaned up, return",
-           rankNode );
+  xdebug("IOPE%d: closed file, cleaned up, return", commInqRankGlob());
 
   return iret == MPI_SUCCESS ? 0 : -1;
 }
@@ -125,7 +131,6 @@ writeMPINONB(aFiledataM *of)
 {
   int amount;
   MPI_Status status;
-  int rankNode = commInqRankNode ();
   int fileID = of->fileID;
 
   /* write buffer */
@@ -134,8 +139,8 @@ writeMPINONB(aFiledataM *of)
 
   if ( amount == 0 ) return;
 
-  xdebug3 ( "IOPI%d: Write buffer, size %d bytes, in",
-           rankNode, amount );
+  xdebug3("IOPI%d: Write buffer, size %d bytes, in",
+          commInqRankGlob(), amount);
 
   xmpi ( MPI_Wait ( & ( of->request ), &status ));
   xmpi(MPI_File_iwrite_shared(of->fh, of->db->buffer, amount, MPI_UNSIGNED_CHAR,
@@ -148,14 +153,14 @@ writeMPINONB(aFiledataM *of)
 
   if ( of->db == of->db1 )
     {
-        xdebug3 ( "IOPE%d: fileID=%d, change to buffer 2 ...",
-                 rankNode, fileID );
+        xdebug3("IOPE%d: fileID=%d, change to buffer 2 ...",
+                commInqRankGlob(), fileID);
       of->db =  of->db2;
     }
   else
     {
-        xdebug3 ( "IOPE%d: fileID=%d, change to buffer 1 ...",
-                  rankNode, fileID );
+        xdebug3("IOPE%d: fileID=%d, change to buffer 1 ...",
+                commInqRankGlob(), fileID);
       of->db =  of->db1;
     }
 
@@ -164,12 +169,13 @@ writeMPINONB(aFiledataM *of)
 
 /***************************************************************/
 
-size_t fwMPINONB ( int fileID, int tsID, const void *buffer, size_t len )
+static size_t
+fwMPINONB(int fileID, const void *buffer, size_t len, int tsID)
 {
   int error = 0;
   int filled = 0;
   aFiledataM *of;
-  int rankNode = commInqRankNode ();
+  int rankPio = commInqRankPio ();
 
   of = listSetGet(bibAFiledataM, fileIDTest, (void *)(intptr_t)fileID);
   xassert(of);
@@ -178,19 +184,19 @@ size_t fwMPINONB ( int fileID, int tsID, const void *buffer, size_t len )
 
   if (flush)
     {
-      xdebug3("IOPE%d: tsID = %d, flush buffer", rankNode, tsID);
+      xdebug3("IOPE%d: tsID = %d, flush buffer", rankPio, tsID);
       writeMPINONB(of);
       of->tsID = tsID;
       MPI_Status status;
       xmpi(MPI_Wait(&(of->request), &status));
-      xmpi(MPI_Barrier(commInqCommNode()));
+      xmpi(MPI_Barrier(commInqCommPio()));
     }
 
   filled = dbuffer_push ( of->db, ( unsigned char * ) buffer, len );
 
-  xdebug3 ( "IOPE%d: fileID = %d, tsID = %d,"
-           " pushed data on buffer, filled = %d",
-           rankNode, fileID, tsID, filled );
+  xdebug3("IOPE%d: fileID = %d, tsID = %d,"
+          " pushed data on buffer, filled = %d",
+          rankPio, fileID, tsID, filled);
 
   if ( filled == 1 )
     {
@@ -212,19 +218,19 @@ size_t fwMPINONB ( int fileID, int tsID, const void *buffer, size_t len )
 
 /***************************************************************/
 
-int fcMPINONB ( int fileID )
+static int fcMPINONB(int fileID)
 {
   aFiledataM *of;
-  int rankNode = commInqRankNode ();
 
   xdebug("IOPE%d: write buffer, close file and cleanup, in %d",
-         rankNode, fileID );
+         commInqRankPio(), fileID );
 
   if (!(of = listSetGet(bibAFiledataM, fileIDTest, (void *)(intptr_t)fileID)))
     xabort("listSet, fileID=%d not found", fileID);
 
   writeMPINONB(of);
-
+  MPI_Status status;
+  xmpi(MPI_Wait(&(of->request), &status));
   /* remove file element */
   int iret = listSetRemove(bibAFiledataM, fileIDTest, (void *)(intptr_t)fileID);
   return iret;
@@ -242,43 +248,46 @@ elemCheck(void *q, void *nm)
 }
 
 
-int fowMPINONB ( const char *filename )
+static int
+fowMPINONB(const char *filename, const char *mode)
 {
-  static aFiledataM *of;
   static unsigned long buffersize = 0;
   int id;
   enum {
     bcastRoot = 0
   };
-  MPI_Comm commNode = commInqCommNode ();
-  int rankNode = commInqRankNode ();
+  MPI_Comm commPio = commInqCommPio ();
+  int rankPio = commInqRankPio ();
+
+  if ((mode[0] != 'w' && mode[0] != 'W') || mode[0] == 0 || mode[1] != 0)
+    xabort("Unsupported mode \"%s\" in parallel file open.", mode);
 
   /* broadcast buffersize to collectors ( just once, for all files )*/
 
   if (!buffersize)
     {
-      if (rankNode == bcastRoot)
+      if (rankPio == bcastRoot)
         buffersize = findWriteAccumBufsize();
-      xmpi(MPI_Bcast(&buffersize, 1, MPI_UNSIGNED_LONG, bcastRoot, commNode));
+      xmpi(MPI_Bcast(&buffersize, 1, MPI_UNSIGNED_LONG, bcastRoot, commPio));
     }
 
   xdebug("buffersize=%ld", buffersize);
 
   listSetForeach(bibAFiledataM, elemCheck, (void *)filename);
-  of = initAFiledataMPINONB(filename, (size_t)buffersize);
+  aFiledataM *of = initAFiledataMPINONB(filename, (size_t)buffersize);
 
   if ((id = listSetAdd(bibAFiledataM, of)) < 0 )
     xabort("filename %s not unique", of->name);
 
   xdebug("IOPE%d: name=%s, init and added aFiledataM, return id = %d",
-         rankNode, filename, id);
+         rankPio, filename, id);
   of->fileID = id;
   return id;
 }
 
 /***************************************************************/
 
-void finalizeMPINONB(void)
+static void finalizeMPINONB(void)
 {
   if (!listSetIsEmpty(bibAFiledataM))
     xabort("set bibAFiledataM not empty");
@@ -292,15 +301,15 @@ void finalizeMPINONB(void)
 /***************************************************************/
 
 void
-initMPINONB(void (*postCommSetupActions)(void))
+initMPINONB(void)
 {
-  commDefCommColl ( 1 );
-  commSendNodeInfo ();
-  commRecvNodeMap ();
-  commDefCommsIO ();
-  postCommSetupActions();
   bibAFiledataM = listSetNew( destroyAFiledataMPINONB, compareNamesMPINONB );
 
+  namespaceSwitchSet(NSSWITCH_FILE_OPEN, NSSW_FUNC(fowMPINONB));
+  namespaceSwitchSet(NSSWITCH_FILE_CLOSE, NSSW_FUNC(fcMPINONB));
+  namespaceSwitchSet(NSSWITCH_FILE_WRITE, NSSW_FUNC(fwMPINONB));
+  cdiPioFileWritingFinalize = finalizeMPINONB;
+
   if ( bibAFiledataM == NULL )
     xabort ( "listSetNew did not succeed" );
 }
diff --git a/libcdi/src/pio_posixasynch.c b/libcdi/src/pio_posixasynch.c
index caf1dc3..43ab495 100644
--- a/libcdi/src/pio_posixasynch.c
+++ b/libcdi/src/pio_posixasynch.c
@@ -1,6 +1,6 @@
-/* 
-   todo  
-   README: specialRank Pe closes down, when all output files are closed    
+/*
+   todo
+   README: specialRank Pe closes down, when all output files are closed
 */
 #ifdef HAVE_CONFIG_H
 #  include "config.h"
@@ -27,8 +27,6 @@
 #include "pio_util.h"
 #include "dmemory.h"
 
-extern char *token;
-
 typedef struct
 {
   struct dBuffer *fb;
@@ -60,7 +58,7 @@ initBFiledataPA(char *filename, size_t bs, int nc)
   xdebug ( "filename=%s, buffersize=%zu, ncollectors=%d, nPrefetchStreams=%d",
            filename, bs, nc, nPrefStreams );
 
-  bfd = (bFiledataPA*) xmalloc( sizeof (*bfd) + strlen(filename) + 1);
+  bfd = (bFiledataPA*) Malloc( sizeof (*bfd) + strlen(filename) + 1);
   strcpy(bfd->name, filename);
 
   if (( bfd->handle = open ( bfd->name, O_CREAT | O_WRONLY, 0666 )) == -1 )
@@ -68,18 +66,18 @@ initBFiledataPA(char *filename, size_t bs, int nc)
 
   dbuffer_init(&(bfd->fb), (size_t)nPrefStreams * bs);
 
-  bfd->ctrlBlks = xcalloc((size_t)nPrefStreams, sizeof (bfd->ctrlBlks[0]));
+  bfd->ctrlBlks = Calloc((size_t)nPrefStreams, sizeof (bfd->ctrlBlks[0]));
 
   for (int i = 0; i < nPrefStreams; i++ )
     {
       bfd->ctrlBlks[i].aio_fildes     = bfd->handle;
       bfd->ctrlBlks[i].aio_buf = bfd->fb->buffer + (size_t)i * bs;
       bfd->ctrlBlks[i].aio_reqprio    = 0;
-      bfd->ctrlBlks[i].aio_sigevent.sigev_notify = SIGEV_NONE;   
+      bfd->ctrlBlks[i].aio_sigevent.sigev_notify = SIGEV_NONE;
     }
-  
+
   bfd->nextOpIndex = 0;
-  bfd->prefIndex = 0; 
+  bfd->prefIndex = 0;
   bfd->offset = 0;
   bfd->activeCollectors = nc;
 
@@ -131,8 +129,8 @@ destroyBFiledataPA ( void *v )
 
   dbuffer_cleanup ( &( bfd->fb ));
 
-  free(bfd->ctrlBlks);
-  free(bfd);
+  Free(bfd->ctrlBlks);
+  Free(bfd);
 
   xdebug("%s", "closed file and cleaned up, return");
 
@@ -158,7 +156,7 @@ writePA(bFiledataPA *bfd, size_t amount)
   ssize_t iret;
 
   xdebug ( "file %s, in", bfd->name );
-  
+
   bfd->ctrlBlks[bfd->currOpIndex].aio_nbytes = amount;
   bfd->ctrlBlks[bfd->currOpIndex].aio_offset = bfd->offset;
 
@@ -172,18 +170,18 @@ writePA(bFiledataPA *bfd, size_t amount)
            "iret=aio_write()=%d",
            bfd->name, bfd->ctrlBlks[bfd->currOpIndex].aio_nbytes,
            bfd->ctrlBlks[bfd->currOpIndex].aio_offset, (int)iret );
-   
-  if ( iret == -1 ) 
+
+  if ( iret == -1 )
     {
       xabort ( "did not succeed writing buffer" );
     }
   else
     xdebug ( "buffer written to %s",  bfd->name );
-     
+
   bfd->offset += (off_t)amount;
   bfd->prefIndex ++;
 
-  if ( bfd->prefIndex >= nPrefStreams ) 
+  if ( bfd->prefIndex >= nPrefStreams )
     {
       ccBP[0] = ( bfd->ctrlBlks + bfd->nextOpIndex );
       do
@@ -217,22 +215,21 @@ elemCheck(void *q, void *nm)
 
 void pioWriterAIO(void)
 {
-  bFiledataPA *bfd; 
+  bFiledataPA *bfd;
   listSet * bibBFiledataPA;
-  MPI_Comm commNode = commInqCommNode ();
-  int nProcsCollNode = commInqSizeNode () - commInqSizeColl ();
-  bool * sentFinalize, doFinalize;
+  MPI_Comm commPio = commInqCommPio ();
+  int nProcsColl = commInqSizeColl ();
 
   if ( nPrefStreams < 1 ) xabort("USAGE: # PREFETCH STREAMS >= 1");
-  xdebug ( "nProcsCollNode=%d on this node", nProcsCollNode );
- 
+  xdebug ( "nProcsColl=%d ", nProcsColl );
+
   bibBFiledataPA = listSetNew(destroyBFiledataPA, compareNamesBPA);
-  sentFinalize = xcalloc((size_t)nProcsCollNode, sizeof (sentFinalize[0]));
-  
+  bool *sentFinalize = Calloc((size_t)nProcsColl, sizeof (sentFinalize[0]));
+
   for ( ;; )
     {
       MPI_Status status;
-      xmpiStat(MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, commNode,
+      xmpiStat(MPI_Probe(MPI_ANY_SOURCE, MPI_ANY_TAG, commPio,
                          &status ), &status);
 
       int source = status.MPI_SOURCE;
@@ -250,17 +247,17 @@ void pioWriterAIO(void)
 	{
       	case IO_Open_file:
           {
-            char *messageBuffer = xmalloc((size_t)messagesize
-                                          * sizeof (messageBuffer[0]));
-            char *pMB = messageBuffer;
+            unsigned char *messageBuffer = Malloc((size_t)messagesize
+                                                   * sizeof (messageBuffer[0])),
+              *pMB = messageBuffer;
 
             xmpi(MPI_Recv(messageBuffer, messagesize, MPI_UNSIGNED_CHAR, source,
-                          tag, commNode, &status ));
+                          tag, commPio, &status ));
 
-            char *filename = strtok(pMB, token);
+            char *filename = (char *)pMB;
             pMB += (strlen(filename) + 1);
-            char *temp = strtok(pMB, token);
-            long buffersize =  strtol(temp, NULL, 16);
+            char *temp = (char *)pMB;
+            long buffersize = strtol(temp, NULL, 16);
             pMB += (strlen(temp) + 1);
             size_t amount = (size_t)(messageBuffer + messagesize - pMB);
 
@@ -271,7 +268,7 @@ void pioWriterAIO(void)
                                    (void *)(intptr_t)rtag.id)))
               {
                 listSetForeach(bibBFiledataPA, elemCheck, filename);
-                bfd = initBFiledataPA(filename, (size_t)buffersize, nProcsCollNode);
+                bfd = initBFiledataPA(filename, (size_t)buffersize, nProcsColl);
                 int id;
                 if ((id = listSetAdd(bibBFiledataPA, bfd)) < 0)
                   xabort("fileID=%d not unique", rtag.id);
@@ -289,7 +286,7 @@ void pioWriterAIO(void)
 
             writePA(bfd, amount);
 
-            free(messageBuffer);
+            Free(messageBuffer);
           }
 	  break;
 
@@ -306,7 +303,7 @@ void pioWriterAIO(void)
 	  bfd->nextOpIndex = ( bfd->nextOpIndex + 1 ) % nPrefStreams;
 
 	  xmpi(MPI_Recv((void *)bfd->ctrlBlks[bfd->currOpIndex].aio_buf,
-                        messagesize, MPI_UNSIGNED_CHAR, source, tag, commNode,
+                        messagesize, MPI_UNSIGNED_CHAR, source, tag, commPio,
                         &status));
 	  writePA(bfd, (size_t)messagesize);
 	  break;
@@ -326,13 +323,13 @@ void pioWriterAIO(void)
 
 	  xmpi(MPI_Recv((void *)bfd->ctrlBlks[bfd->currOpIndex].aio_buf,
                         messagesize, MPI_UNSIGNED_CHAR,
-                        source, tag, commNode, &status));
+                        source, tag, commPio, &status));
 
 	  writePA(bfd, (size_t)messagesize);
 
 	  if ( ! --(bfd->activeCollectors))
 	    {
-              xdebug ( "all are finished with file %d, delete node", rtag.id);
+              xdebug ( "all are finished with file %d, delete entry", rtag.id);
               listSetRemove(bibBFiledataPA, fileIDTest,
                             (void *)(intptr_t)rtag.id);
 	    }
@@ -341,10 +338,10 @@ void pioWriterAIO(void)
           {
             int buffer, collID;
 
-            xmpi ( MPI_Recv ( &buffer, 1, MPI_INT, source, tag, commNode, &status ));
+            xmpi ( MPI_Recv ( &buffer, 1, MPI_INT, source, tag, commPio, &status ));
             sentFinalize[source] = true;
-            doFinalize = true;
-            for ( collID = 0; collID < nProcsCollNode; collID++ )
+            bool doFinalize = true;
+            for ( collID = 0; collID < nProcsColl; collID++ )
               doFinalize &= sentFinalize[collID];
             if ( doFinalize )
               {
@@ -356,7 +353,7 @@ void pioWriterAIO(void)
                            " return");
                     listSetDelete(bibBFiledataPA);
                   }
-                free(sentFinalize);
+                Free(sentFinalize);
                 return;
               }
           }
diff --git a/libcdi/src/pio_posixfpguardsendrecv.c b/libcdi/src/pio_posixfpguardsendrecv.c
index 2a20275..64493a7 100644
--- a/libcdi/src/pio_posixfpguardsendrecv.c
+++ b/libcdi/src/pio_posixfpguardsendrecv.c
@@ -1,6 +1,6 @@
-/* 
-   todo 
-   build in control, for consistance of pairs filename / filenumber 
+/*
+   todo
+   build in control, for consistance of pairs filename / filenumber
    ( pioOpenFile member name, recv in tmpbuffer, if(!uniqueName(q,v,n))abort )
 */
 
@@ -15,11 +15,13 @@
 
 #include <mpi.h>
 
+#include "cdi.h"
+#include "dmemory.h"
+#include "namespace.h"
 #include "pio.h"
 #include "pio_comm.h"
 #include "pio_impl.h"
 #include "pio_util.h"
-#include "dmemory.h"
 
 typedef struct
 {
@@ -61,7 +63,7 @@ fileIDCmpB(void *a, void *b)
 static listSet *bibAFiledataPF;
 
 /***************************************************************/
-  
+
 static aFiledataPF *initAFiledataPF ( const char *key, size_t bs)
 {
   aFiledataPF *afd;
@@ -69,14 +71,14 @@ static aFiledataPF *initAFiledataPF ( const char *key, size_t bs)
   int iret;
 
   len = strlen(key);
-  afd = xcalloc(1, sizeof (*afd) + len + 1);
+  afd = Calloc(1, sizeof (*afd) + len + 1);
   strcpy(afd->name, key);
   afd->tsID = 0;
 
   /* init output buffer */
 
   xdebug ( " name=%s, init output buffer",  afd->name );
-   
+
   iret = dbuffer_init(&(afd->db1), bs);
   iret += dbuffer_init(&(afd->db2), bs);
 
@@ -85,10 +87,10 @@ static aFiledataPF *initAFiledataPF ( const char *key, size_t bs)
 
   afd->db = afd->db1;
 
-  /* open file */ 
+  /* open file */
   xdebug ( "name=%s, open file",  afd->name );
 
-  if ( ( afd->fp = fopen ( afd->name, "w" )) == NULL ) 
+  if ( ( afd->fp = fopen ( afd->name, "w" )) == NULL )
     xabort("Failed to open %s", afd->name);
 
   afd->command = IO_Open_file;
@@ -101,7 +103,7 @@ initBFiledataPF(int fileID, int nc)
 {
   bFiledataPF *bfd;
   size_t bfdSize = sizeof (bFiledataPF) + (size_t)nc * sizeof (bool);
-  bfd = xcalloc(1, bfdSize);
+  bfd = Calloc(1, bfdSize);
   bfd->offset = 0;
   bfd->finished = false;
   bfd->fileID = fileID;
@@ -127,7 +129,7 @@ destroyAFiledataPF(void *v)
   dbuffer_cleanup(&(afd->db1));
   dbuffer_cleanup(&(afd->db2));
 
-  free(afd);
+  Free(afd);
 
   return iret;
 }
@@ -139,8 +141,8 @@ destroyBFiledataPF(void *v)
 {
   int iret = 0;
   bFiledataPF *bfd = (bFiledataPF * ) v;
-  
-  free ( bfd );
+
+  Free ( bfd );
 
   return iret;
 }
@@ -163,24 +165,24 @@ fpgPOSIXFPGUARDSENDRECV(void)
   int i, source, iret;
   struct fileOpTag rtag;
   MPI_Status status;
-  bFiledataPF *bfd; 
+  bFiledataPF *bfd;
   listSet *bibBFiledataPF;
   long amount;
-  MPI_Comm commNode = commInqCommNode ();
-  int nProcsCollNode =  commInqSizeNode () - commInqSizeColl ();
+  MPI_Comm commPio = commInqCommPio();
+  int nProcsColl =  commInqSizeColl();
   bool * sentFinalize, doFinalize = false;
 
-  xdebug ( "ncollectors=%d on this node", nProcsCollNode );
-  
+  xdebug ( "ncollectors=%d", nProcsColl );
+
   bibBFiledataPF = listSetNew( destroyBFiledataPF, fileIDCmpB);
-  sentFinalize = xcalloc((size_t)nProcsCollNode, sizeof (sentFinalize[0]));
+  sentFinalize = Calloc((size_t)nProcsColl, sizeof (sentFinalize[0]));
 
   for ( ;; )
     {
-      xmpi ( MPI_Probe ( MPI_ANY_SOURCE, MPI_ANY_TAG, commNode, &status ));
+      xmpi ( MPI_Probe ( MPI_ANY_SOURCE, MPI_ANY_TAG, commPio, &status ));
       source = status.MPI_SOURCE;
       rtag = decodeFileOpTag(status.MPI_TAG);
-      
+
       xdebug("receive message from source=%d, id=%d, command=%d ( %s )",
              source, rtag.id, rtag.command, cdiPioCmdStrTab[rtag.command]);
 
@@ -191,7 +193,7 @@ fpgPOSIXFPGUARDSENDRECV(void)
           if (!(bfd = listSetGet(bibBFiledataPF, fileIDTestB,
                                  (void *)(intptr_t)rtag.id)))
 	    {
-	      bfd = initBFiledataPF(rtag.id, nProcsCollNode);
+	      bfd = initBFiledataPF(rtag.id, nProcsColl);
 
 	      if ((iret = listSetAdd(bibBFiledataPF, bfd)) < 0)
 		xabort("fileID=%d not unique", rtag.id);
@@ -199,14 +201,14 @@ fpgPOSIXFPGUARDSENDRECV(void)
 	    }
 
           xdebug("id=%d, command=%d ( %s ), send offset=%ld", rtag.id,
-                 rtag.command, cdiPioCmdStrTab[rtag.command], bfd->offset);
+rtag.command, cdiPioCmdStrTab[rtag.command], bfd->offset);
 
 	  xmpi ( MPI_Sendrecv ( &( bfd->offset ), 1, MPI_LONG, source,  status.MPI_TAG,
                                 &amount, 1, MPI_LONG, source,  status.MPI_TAG,
-                                commNode, &status ));
+                                commPio, &status ));
+
+	  bfd->offset += amount;
 
-	  bfd->offset += amount; 
- 
           xdebug("id=%d, command=%d ( %s ), recv amount=%ld, set offset=%ld",
                  rtag.id, rtag.command, cdiPioCmdStrTab[rtag.command], amount,
                  bfd->offset);
@@ -224,7 +226,7 @@ fpgPOSIXFPGUARDSENDRECV(void)
 
 	  xmpi ( MPI_Sendrecv ( &( bfd->offset ), 1, MPI_LONG, source,  status.MPI_TAG,
                                 &amount, 1, MPI_LONG, source,  status.MPI_TAG,
-                                commNode, &status ));
+                                commPio, &status ));
 
 	  bfd->offset += amount;
 
@@ -245,7 +247,7 @@ fpgPOSIXFPGUARDSENDRECV(void)
 
 	  xmpi ( MPI_Sendrecv ( &( bfd->offset ), 1, MPI_LONG, source,  status.MPI_TAG,
                                 &amount, 1, MPI_LONG, source,  status.MPI_TAG,
-                                commNode, &status ));
+                                commPio, &status ));
 
 	  bfd->offset += amount;
 
@@ -254,10 +256,10 @@ fpgPOSIXFPGUARDSENDRECV(void)
                  bfd->offset);
 
 
-	  bfd->nfinished[source] = true;  
+	  bfd->nfinished[source] = true;
 	  bfd->finished          = true;
-	  
-	  for ( i = 0; i < nProcsCollNode; i++ )
+
+	  for ( i = 0; i < nProcsColl; i++ )
 	    if ( !( bfd->nfinished[i] ))
 	      {
 		bfd->finished = false;
@@ -269,14 +271,14 @@ fpgPOSIXFPGUARDSENDRECV(void)
                           (void *)(intptr_t)rtag.id);
           break;
         case IO_Finalize:
-          {  
-            int buffer = CDI_UNDEFID, collID; 
+          {
+            int buffer = CDI_UNDEFID, collID;
 
             xmpi ( MPI_Recv ( &buffer, 1, MPI_INT, source, status.MPI_TAG,
-                              commNode, &status ));
+                              commPio, &status ));
             sentFinalize[source] = true;
             doFinalize = true;
-            for ( collID = 0; collID < nProcsCollNode; collID++ )
+            for ( collID = 0; collID < nProcsColl; collID++ )
               doFinalize &= sentFinalize[collID];
             if ( doFinalize )
               {
@@ -287,7 +289,7 @@ fpgPOSIXFPGUARDSENDRECV(void)
                     xdebug("%s", "destroy set");
                     listSetDelete(bibBFiledataPF);
                   }
-                free(sentFinalize);
+                Free(sentFinalize);
                 return;
               }
           }
@@ -296,7 +298,7 @@ fpgPOSIXFPGUARDSENDRECV(void)
           xabort ( "COMMAND NOT IMPLEMENTED" );
 	}
     }
-}   
+}
 
 //*******************************************************
 
@@ -308,51 +310,52 @@ writePF(aFiledataPF *afd)
   long amountL;
   int error, tag;
   MPI_Status status;
-  int specialRank = commInqSpecialRankNode ();
-  MPI_Comm commNode = commInqCommNode ();
-  
+  /* FIXME: pretend there's only one special rank for now */
+  int specialRank = commInqSizePio() - 1;
+  MPI_Comm commPio = commInqCommPio();
+
   /* send buffersize, recv offset */
 
   amount = dbuffer_data_size ( afd->db );
   amountL = ( long ) amount;
   int id = afd->fileID;
   tag = encodeFileOpTag(id, afd->command);
-  
+
   xmpi ( MPI_Sendrecv ( &amountL, 1, MPI_LONG, specialRank, tag,
                         &offset, 1, MPI_LONG, specialRank, tag,
-                        commNode, &status ));
-  xdebug ( "id=%d, command=%d, amount=%zu, send amountL=%ld, recv offset=%ld", 
+                        commPio, &status ));
+  xdebug ( "id=%d, command=%d, amount=%zu, send amountL=%ld, recv offset=%ld",
            id, afd->command, amount, amountL, offset );
-  
+
   /* write buffer */
-  
+
   if (( error = fseek ( afd->fp, offset, SEEK_SET )) != 0 )
     xabort ( "did not succeed seeking fp" );
 
-  if (( written = 
+  if (( written =
 	fwrite ( afd->db->buffer, sizeof ( char ), amount, afd->fp )) !=
       amount )
     xabort("fileId=%d, expect to write %zu byte, written %zu byte",
            id, amount, written);
- 
+
   xdebug("written %zu bytes in file %d with offset %ld",
          written, id, offset);
-  
+
   /* change outputBuffer */
-  
+
   dbuffer_reset ( afd->db );
-  
+
   if ( afd->db == afd->db1 )
     {
       xdebug ( "id=%d, change to buffer 2 ...", id );
       afd->db =  afd->db2;
     }
-  else 
+  else
     {
       xdebug ( "id=%d, change to buffer 1 ...", id );
       afd->db =  afd->db1;
     }
-  
+
   afd->command = IO_Set_fp;
 }
 
@@ -362,7 +365,7 @@ writePF(aFiledataPF *afd)
 static void
 defTimestepPF(aFiledataPF *afd, int tsID)
 {
-  if ( afd == NULL || tsID < 0 || tsID != afd->tsID + 1 ) 
+  if ( afd == NULL || tsID < 0 || tsID != afd->tsID + 1 )
     xabort ( " defTimestepPF() didn't succeed." );
   afd->tsID = tsID;
 }
@@ -378,7 +381,8 @@ flushOp(aFiledataPF *a, int tsID)
 }
 
 
-size_t fwPOSIXFPGUARDSENDRECV( int fileID, int tsID, const void *buffer, size_t len )
+static size_t
+fwPOSIXFPGUARDSENDRECV(int fileID, const void *buffer, size_t len, int tsID)
 {
   int error = 0;
   int filled = 0;
@@ -391,35 +395,36 @@ size_t fwPOSIXFPGUARDSENDRECV( int fileID, int tsID, const void *buffer, size_t
     {
       xdebug("fileID %d, tsID = %d, flush buffer", fileID, tsID);
       flushOp(afd, tsID);
-      xmpi ( MPI_Barrier ( commInqCommColl ())); 
+      xmpi ( MPI_Barrier ( commInqCommColl ()));
     }
 
   filled = dbuffer_push(afd->db, ( unsigned char * ) buffer, len);
 
-  xdebug ( "fileID = %d, tsID = %d, pushed data on buffer, filled = %d", 
-           fileID, tsID, filled ); 
+  xdebug ( "fileID = %d, tsID = %d, pushed data on buffer, filled = %d",
+           fileID, tsID, filled );
 
-  if ( filled == 1 ) 
+  if ( filled == 1 )
     {
       if ( flush )
 	error = filled;
       else
 	{
 	  writePF(afd);
-     
+
 	  error = dbuffer_push ( afd->db, ( unsigned char * ) buffer, len );
 	}
     }
-  
+
   if ( error == 1 )
     xabort("did not succeed filling output buffer, fileID=%d", fileID);
-  
+
   return len;
 }
 
 /***************************************************************/
 
-int fcPOSIXFPGUARDSENDRECV ( int id )
+static int
+fcPOSIXFPGUARDSENDRECV(int id)
 {
   aFiledataPF *afd;
   int iret;
@@ -450,12 +455,15 @@ elemCheck(void *q, void *nm)
     xabort("Filename %s has already been added to set\n", name);
 }
 
-int fowPOSIXFPGUARDSENDRECV ( const char *filename )
+static int
+fowPOSIXFPGUARDSENDRECV(const char *filename, const char *mode)
 {
   int id;
   enum {
     bcastRoot = 0
   };
+  if ((mode[0] != 'w' && mode[0] != 'W') || mode[0] == 0 || mode[1] != 0)
+    xabort("Unsupported mode \"%s\" in parallel file open.", mode);
   aFiledataPF *afd;
   static unsigned long buffersize = 0;
 
@@ -481,12 +489,12 @@ int fowPOSIXFPGUARDSENDRECV ( const char *filename )
   {
     long offset, amount = 0L;
     int tag = encodeFileOpTag(afd->fileID, afd->command);
-    int specialRank = commInqSpecialRankNode ();
+    int specialRank = commInqSpecialRank ();
     MPI_Status status;
-    MPI_Comm commNode = commInqCommNode ();
+    MPI_Comm commPio = commInqCommPio ();
     xmpi(MPI_Sendrecv(&amount, 1, MPI_LONG, specialRank, tag,
                       &offset, 1, MPI_LONG, specialRank, tag,
-                      commNode, &status));
+                      commPio, &status));
   }
   afd->command = IO_Set_fp;
   return id;
@@ -494,13 +502,13 @@ int fowPOSIXFPGUARDSENDRECV ( const char *filename )
 
 /***************************************************************/
 
-void
+static void
 finalizePOSIXFPGUARDSENDRECV(void)
 {
   int buffer = 0, tag = encodeFileOpTag(0, IO_Finalize);
 
-  xmpi(MPI_Send(&buffer, 1, MPI_INT, commInqSpecialRankNode(),
-                tag, commInqCommNode()));
+  xmpi(MPI_Send(&buffer, 1, MPI_INT, commInqSpecialRank(),
+                tag, commInqCommPio()));
 
   if (!listSetIsEmpty(bibAFiledataPF))
     xabort("set bibAFiledataM not empty");
@@ -514,21 +522,27 @@ finalizePOSIXFPGUARDSENDRECV(void)
 /***************************************************************/
 
 void
-initPOSIXFPGUARDSENDRECV(void (*postCommSetupActions)(void))
+initPOSIXFPGUARDSENDRECV(void)
 {
-  if ( commInqSizeNode () < 2 ) 
-    xabort ( "USAGE: # IO PROCESSES ON A PHYSICAL NODE >= 2" );
-
-  int isCollector = commInqRankNode () != commInqSpecialRankNode ();
-  commDefCommColl(isCollector);
-  commSendNodeInfo ();
-  commRecvNodeMap ();
-  commDefCommsIO ();
-  postCommSetupActions();
+  int numIOServers = commInqSizePio();
+  if (numIOServers < 2)
+    xabort("error: # of I/O processes must be >= 2 for mode, but is %d",
+           numIOServers);
+
+  int isCollector = commInqRankColl() != -1;
   if (!isCollector)
     fpgPOSIXFPGUARDSENDRECV ();
   else
-    bibAFiledataPF = listSetNew( destroyAFiledataPF, compareNamesAPF );
+    {
+      namespaceSwitchSet(NSSWITCH_FILE_OPEN,
+                         NSSW_FUNC(fowPOSIXFPGUARDSENDRECV));
+      namespaceSwitchSet(NSSWITCH_FILE_CLOSE,
+                         NSSW_FUNC(fcPOSIXFPGUARDSENDRECV));
+      namespaceSwitchSet(NSSWITCH_FILE_WRITE,
+                         NSSW_FUNC(fwPOSIXFPGUARDSENDRECV));
+      cdiPioFileWritingFinalize = finalizePOSIXFPGUARDSENDRECV;
+      bibAFiledataPF = listSetNew(destroyAFiledataPF, compareNamesAPF);
+    }
 }
 
 /*
diff --git a/libcdi/src/pio_posixnonb.c b/libcdi/src/pio_posixnonb.c
index 182f977..c16ea30 100644
--- a/libcdi/src/pio_posixnonb.c
+++ b/libcdi/src/pio_posixnonb.c
@@ -8,15 +8,14 @@
 #include <unistd.h>
 #include <mpi.h>
 
+#include "cdi.h"
+#include "dmemory.h"
+
 #include "pio.h"
 #include "pio_comm.h"
 #include "pio_impl.h"
 #include "pio_util.h"
 
-#include "dmemory.h"
-
-extern char *token;
-
 typedef struct
 {
   struct dBuffer *fb;
@@ -41,10 +40,10 @@ initBFiledataP(char *filename, size_t bs, int nc, int fileID)
 
   xdebug ( "filename=%s, buffersize=%lu, ncollectors=%d", filename, bs, nc );
 
-  bfp = xmalloc(sizeof (*bfp) + strlen(filename) + 1);
+  bfp = Malloc(sizeof (*bfp) + strlen(filename) + 1);
   strcpy(bfp->name, filename);
 
-  if (( bfp->fp = fopen ( filename, "w" )) == NULL ) 
+  if (( bfp->fp = fopen ( filename, "w" )) == NULL )
     xabort("Failed to open %s", bfp->name);
   int fd = fileno(bfp->fp);
   ftruncate(fd, (off_t)0);
@@ -77,7 +76,7 @@ destroyBFiledataP(void *v)
 
   dbuffer_cleanup ( &( bfp->fb ));
 
-  free(bfp);
+  Free(bfp);
 
   xdebug("%s", "cleaned up, return");
 
@@ -124,33 +123,31 @@ elemCheck(void *q, void *nm)
 void
 pioWriterStdIO(void)
 {
-  bFiledataP *bfd; 
+  bFiledataP *bfd;
   listSet * bibBFiledataP;
-  size_t amount, buffersize;
-  char *messageBuffer = NULL;
-  char *pMB, *filename, *temp;
+  size_t amount;
   int messagesize, source, tag, id;
   struct fileOpTag rtag;
   MPI_Status status;
-  MPI_Comm commNode = commInqCommNode ();
-  int nProcsCollNode = commInqSizeNode () - commInqSizeColl ();
+  MPI_Comm commPio = commInqCommPio ();
+  int nProcsColl = commInqSizeColl ();
   bool * sentFinalize, doFinalize;
 
-  xdebug ( "ncollectors=%d on this node", nProcsCollNode );
+  xdebug ( "ncollectors=%d", nProcsColl );
 
   bibBFiledataP = listSetNew(destroyBFiledataP, compareNamesBP);
-  sentFinalize = xcalloc((size_t)nProcsCollNode, sizeof (sentFinalize[0]));
-  
+  sentFinalize = Calloc((size_t)nProcsColl, sizeof (sentFinalize[0]));
+
   for ( ;; )
-    {  
-        
-      xmpiStat ( MPI_Probe ( MPI_ANY_SOURCE, MPI_ANY_TAG, commNode, 
+    {
+
+      xmpiStat ( MPI_Probe ( MPI_ANY_SOURCE, MPI_ANY_TAG, commPio,
                              &status ), &status );
-      
-      
+
+
       source = status.MPI_SOURCE;
       tag    = status.MPI_TAG;
-      
+
       rtag = decodeFileOpTag(tag);
 
       xmpi(MPI_Get_count(&status, MPI_UNSIGNED_CHAR, &messagesize));
@@ -162,48 +159,45 @@ pioWriterStdIO(void)
       switch (rtag.command)
 	{
       	case IO_Open_file:
+          {
+            char *messageBuffer
+              = Malloc((size_t)messagesize * sizeof (messageBuffer[0]));
+            char *pMB = messageBuffer;
+            xmpi(MPI_Recv(messageBuffer, messagesize, MPI_UNSIGNED_CHAR,
+                          source, tag, commPio, &status));
 
-	  messageBuffer
-            = xmalloc((size_t)messagesize * sizeof (messageBuffer[0]));
-    	  pMB = messageBuffer;
-
-	  xmpi(MPI_Recv(messageBuffer, messagesize, MPI_UNSIGNED_CHAR,
-                        source, tag, commNode, &status));
-
-	  xdebug("%s", "after recv, in loop");
-	  
-	  filename = strtok ( pMB, token );
-	  pMB += ( strlen ( filename ) + 1 );
-	  temp =  strtok ( pMB, token );
-          buffersize = (size_t)strtol(temp, NULL, 16);
-	  pMB += ( strlen ( temp ) + 1 );
-	  amount = (size_t)(messageBuffer + messagesize - pMB);
-	  
-	  xdebug("command %s, filename=%s, buffersize=%zu, amount=%zu",
-                 cdiPioCmdStrTab[rtag.command], filename, buffersize, amount);
-	  
-	  
-          if (!(bfd = listSetGet(bibBFiledataP, fileIDTest,
-                               (void *)(intptr_t)rtag.id)))
-	    {
-	      listSetForeach(bibBFiledataP, elemCheck, filename);
-	      bfd = initBFiledataP(filename, buffersize, nProcsCollNode,
-                                   rtag.id);
-	      
-	      if ((id = listSetAdd(bibBFiledataP, bfd)) < 0)
-                xabort("fileID=%d not unique", rtag.id);
-              bfd->fileID = id;
-	    }
-	  else
-	    if (strcmp(filename, bfd->name) != 0)
-              xabort("filename is not consistent, fileID=%d", rtag.id);
+            xdebug("%s", "after recv, in loop");
 
-	  memcpy(bfd->fb->buffer, pMB, amount);
+            char *filename = pMB;
+            pMB += (strlen(filename) + 1);
+            char *temp = pMB;
+            long buffersize = strtol(temp, NULL, 16);
+            pMB += (strlen(temp) + 1);
+            size_t amount = (size_t)(messageBuffer + messagesize - pMB);
 
-	  writeP(bfd, amount);
-	  
-	  free ( messageBuffer );
+            xdebug("command %s, filename=%s, buffersize=%ld, amount=%zu",
+                   cdiPioCmdStrTab[rtag.command], filename, buffersize, amount);
+
+
+            if (!(bfd = listSetGet(bibBFiledataP, fileIDTest,
+                                   (void *)(intptr_t)rtag.id)))
+              {
+                listSetForeach(bibBFiledataP, elemCheck, filename);
+                bfd = initBFiledataP(filename, (size_t)buffersize, nProcsColl,
+                                     rtag.id);
+                if ((id = listSetAdd(bibBFiledataP, bfd)) < 0)
+                  xabort("fileID=%d not unique", rtag.id);
+                bfd->fileID = id;
+              }
+            else
+              if (strcmp(filename, bfd->name) != 0)
+                xabort("filename is not consistent, fileID=%d", rtag.id);
+            memcpy(bfd->fb->buffer, pMB, amount);
+
+            writeP(bfd, amount);
 
+            Free(messageBuffer);
+          }
 	  break;
 
 	case IO_Send_buffer:
@@ -218,7 +212,7 @@ pioWriterStdIO(void)
                  rtag.id, bfd->name);
 
 	  xmpi(MPI_Recv(bfd->fb->buffer, messagesize, MPI_UNSIGNED_CHAR,
-                        source, tag, commNode, &status));
+                        source, tag, commPio, &status));
 
 	  writeP(bfd, amount);
 	  break;
@@ -238,7 +232,7 @@ pioWriterStdIO(void)
                  cdiPioCmdStrTab[rtag.command], rtag.id, bfd->name, amount);
 
 	  xmpi(MPI_Recv(bfd->fb->buffer, messagesize, MPI_UNSIGNED_CHAR,
-                        source, tag, commNode, &status));
+                        source, tag, commPio, &status));
 
 	  writeP ( bfd, amount );
 
@@ -253,18 +247,18 @@ pioWriterStdIO(void)
           {
             int buffer = CDI_UNDEFID, collID;
 
-            xmpi ( MPI_Recv ( &buffer, 1, MPI_INT, source, tag, commNode, &status ));
-            
+            xmpi ( MPI_Recv ( &buffer, 1, MPI_INT, source, tag, commPio, &status ));
+
             sentFinalize[source] = true;
             doFinalize = true;
-            
-            for ( collID = 0; collID < nProcsCollNode; collID++ )
-              if ( !sentFinalize[collID] ) 
+
+            for ( collID = 0; collID < nProcsColl; collID++ )
+              if ( !sentFinalize[collID] )
                 {
                   doFinalize = false;
                   break;
                 }
-            
+
             if ( doFinalize )
               {
                 if (!listSetIsEmpty(bibBFiledataP))
@@ -275,7 +269,7 @@ pioWriterStdIO(void)
                            " return");
                     listSetDelete(bibBFiledataP);
                   }
-                free(sentFinalize);
+                Free(sentFinalize);
                 return;
               }
           }
diff --git a/libcdi/src/pio_record_send.c b/libcdi/src/pio_record_send.c
index 432b9c0..e26681d 100644
--- a/libcdi/src/pio_record_send.c
+++ b/libcdi/src/pio_record_send.c
@@ -6,12 +6,12 @@
 #include <stdlib.h>
 
 #include "cdipio.h"
+#include "dmemory.h"
+#include "namespace.h"
+#include "pio.h"
 #include "pio_comm.h"
 #include "pio_impl.h"
 #include "pio_util.h"
-#include "dmemory.h"
-
-extern char *token;
 
 typedef struct
 {
@@ -43,7 +43,7 @@ initRemoteFileBuf(const char *filename, size_t bs)
   xdebug ( "filename=%s, buffersize=%zu, in", filename, bs );
 
   len = strlen(filename);
-  afp = xmalloc(sizeof (remoteFileBuf) + len + 1);
+  afp = Malloc(sizeof (remoteFileBuf) + len + 1);
   strcpy(afp->name, filename);
   afp->size = bs;
   afp->tsID = 0;
@@ -78,7 +78,7 @@ destroyRemoteFileBuf(void *v)
   dbuffer_cleanup(&afp->db1);
   dbuffer_cleanup(&afp->db2);
 
-  free(afp);
+  Free(afp);
 
   xdebug("%s", "cleaned up, return");
 
@@ -112,7 +112,7 @@ sendP(remoteFileBuf *afd, int id)
 
   /* FIXME: amount > INT_MAX unhandled */
   xmpi(MPI_Issend(afd->db->buffer, (int)amount, MPI_UNSIGNED_CHAR,
-                  commInqSpecialRankNode(), tag, commInqCommNode(),
+                  commInqSizePio() - 1, tag, commInqCommPio(),
                   &afd->request));
 
   /* change outputBuffer */
@@ -148,8 +148,8 @@ flushOp(remoteFileBuf *fb, int tsID)
 }
 
 
-size_t
-pioSendWrite(int id, int tsID, const void *buffer, size_t len)
+static size_t
+pioSendWrite(int id, const void *buffer, size_t len, int tsID)
 {
   int error = 0;
   int flush = 0;
@@ -195,7 +195,7 @@ pioSendWrite(int id, int tsID, const void *buffer, size_t len)
 }
 
 
-int
+static int
 pioSendClose(int id)
 {
   remoteFileBuf *afd;
@@ -216,9 +216,11 @@ pioSendClose(int id)
   return iret;
 }
 
-int
-pioSendOpen(const char *filename)
+static int
+pioSendOpen(const char *filename, const char *mode)
 {
+  if ((mode[0] != 'w' && mode[0] != 'W') || mode[0] == 0 || mode[1] != 0)
+    xabort("Unsupported mode \"%s\" in parallel file open.", mode);
   remoteFileBuf *afd;
   static unsigned long buffersize = 0;
   int id, iret;
@@ -248,40 +250,36 @@ pioSendOpen(const char *filename)
          filename, id);
 
   /* put filename, id and buffersize on buffer */
-  iret = dbuffer_push ( afd->db, filename, strlen ( filename ));
-  xassert(iret == 0);
-  iret = dbuffer_push ( afd->db, token, 1);
+  iret = dbuffer_push(afd->db, filename, strlen(filename) + 1);
   xassert(iret == 0);
   sprintf ( message,"%lX", buffersize);
-  iret = dbuffer_push ( afd->db, message, strlen ( message ));
-  xassert(iret == 0);
-  iret = dbuffer_push ( afd->db, token, 1);
+  iret = dbuffer_push(afd->db, message, strlen(message) + 1);
   xassert(iret == 0);
 
   if ( ddebug )
     {
       size_t l = strlen(filename) + strlen(message) + 2;
-      char *temp = xmalloc(l + 1);
+      char *temp = Malloc(l + 1);
       strncpy(temp, (char *)afd->db->buffer, l);
       temp[l] = '\0';
       xdebug("filename=%s, put Open file message on buffer:\n%s,\t return",
              filename, temp);
-      free(temp);
+      Free(temp);
     }
   sendP(afd, afd->fileID);
   xmpi(MPI_Barrier(commCollectors));
   return id;
 }
 
-void
+static void
 pioSendFinalize(void)
 {
-  int buffer = 0, tag, specialRank = commInqSpecialRankNode ();
-  MPI_Comm commNode = commInqCommNode ();
+  int buffer = 0, tag, specialRank = commInqSizePio() - 1;
+  MPI_Comm commPio = commInqCommPio();
 
   tag = encodeFileOpTag(0, IO_Finalize);
 
-  xmpi(MPI_Send(&buffer, 1, MPI_INT, specialRank, tag, commNode));
+  xmpi(MPI_Send(&buffer, 1, MPI_INT, specialRank, tag, commPio));
   xdebug("%s", "SENT MESSAGE WITH TAG \"IO_FINALIZE\" TO SPECIAL PROCESS");
 
   if (!listSetIsEmpty(bibRemoteFileBuf))
@@ -294,18 +292,14 @@ pioSendFinalize(void)
 }
 
 void
-pioSendInitialize(void (*postCommSetupActions)(void))
+pioSendInitialize(void)
 {
-  if (commInqSizeNode() < 2)
-    xabort ( "USAGE: # IO PROCESSES ON A PHYSICAL NODE >= 2" );
+  int numIOServers = commInqSizePio();
+  if (numIOServers < 2)
+    xabort("error: # of I/O processes must be >= 2 for mode, but is %d",
+           numIOServers);
 
-
-  int isCollector = commInqRankNode () != commInqSpecialRankNode ();
-  commDefCommColl(isCollector);
-  commSendNodeInfo();
-  commRecvNodeMap();
-  commDefCommsIO();
-  postCommSetupActions();
+  int isCollector = commInqRankColl() != -1;
   if (!isCollector)
     switch ( commInqIOMode ())
       {
@@ -317,7 +311,13 @@ pioSendInitialize(void (*postCommSetupActions)(void))
         break;
       }
   else
-    bibRemoteFileBuf = listSetNew(destroyRemoteFileBuf, compareNames);
+    {
+      namespaceSwitchSet(NSSWITCH_FILE_OPEN, NSSW_FUNC(pioSendOpen));
+      namespaceSwitchSet(NSSWITCH_FILE_CLOSE, NSSW_FUNC(pioSendClose));
+      namespaceSwitchSet(NSSWITCH_FILE_WRITE, NSSW_FUNC(pioSendWrite));
+      cdiPioFileWritingFinalize = pioSendFinalize;
+      bibRemoteFileBuf = listSetNew(destroyRemoteFileBuf, compareNames);
+    }
 }
 
 /*
diff --git a/libcdi/src/pio_roles.c b/libcdi/src/pio_roles.c
new file mode 100644
index 0000000..1946e28
--- /dev/null
+++ b/libcdi/src/pio_roles.c
@@ -0,0 +1,132 @@
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <stdlib.h>
+
+#include "cdipio.h"
+#include "error.h"
+#include "pio_util.h"
+
+static int
+cdiPioCSRSelectRange(MPI_Comm commSuper, int IOMode,
+                     int clientRangeStart, int clientRangeEnd,
+                     int specialRank);
+
+int
+cdiPioCSRLastN(MPI_Comm commSuper, int IOMode, int nProcsIO)
+{
+  int commSize;
+  xmpi(MPI_Comm_size(commSuper, &commSize));
+  return cdiPioCSRSelectRange(commSuper, IOMode, 0, commSize - nProcsIO - 1,
+                              commSize - 1);
+}
+
+int
+cdiPioCSRFirstN(MPI_Comm commSuper, int IOMode, int nProcsIO)
+{
+  int commSize;
+  xmpi(MPI_Comm_size(commSuper, &commSize));
+  return cdiPioCSRSelectRange(commSuper, IOMode, nProcsIO, commSize - 1,
+                              nProcsIO - 1);
+}
+
+static int
+cdiPioCSRSelectRange(MPI_Comm commSuper, int IOMode,
+                     int clientRangeStart, int clientRangeEnd,
+                     int specialRank)
+{
+  int commRank, commSize;
+  xmpi(MPI_Comm_size(commSuper, &commSize));
+  xmpi(MPI_Comm_rank(commSuper, &commRank));
+  int role;
+  switch (IOMode)
+  {
+  case PIO_NONE:
+    xassert(commRank == 0 && commSize == 1);
+    role = PIO_NONE;
+    break;
+  case PIO_MPI:
+  case PIO_MPI_FW_ORDERED:
+  case PIO_MPI_FW_AT_ALL:
+  case PIO_MPI_FW_AT_REBLOCK:
+    role = (commRank >= clientRangeStart && commRank <= clientRangeEnd)
+      ? PIO_ROLE_CLIENT : PIO_ROLE_WRITER_COLLECTOR;
+    break;
+  case PIO_WRITER:
+  case PIO_ASYNCH:
+    role = (commRank >= clientRangeStart && commRank <= clientRangeEnd)
+      ? PIO_ROLE_CLIENT : ((commRank == specialRank)
+                           ? PIO_ROLE_WRITER
+                           : PIO_ROLE_COLLECTOR);
+    break;
+  case PIO_FPGUARD:
+    role = (commRank >= clientRangeStart && commRank <= clientRangeEnd)
+      ? PIO_ROLE_CLIENT : ((commRank == specialRank)
+                           ? PIO_ROLE_FPGUARD
+                           : PIO_ROLE_WRITER_COLLECTOR);
+    break;
+  default:
+    xabort("Invalid mode requested %d", IOMode);
+  }
+  return role;
+}
+
+int
+cdiPioCSRBalanced(MPI_Comm commSuper, int IOMode, int nProcsIO)
+{
+  int commRank, commSize, numClients, clientsPerCollectorMin,
+    clientsPerCollectorMax, rest;
+  xmpi(MPI_Comm_size(commSuper, &commSize));
+  xmpi(MPI_Comm_rank(commSuper, &commRank));
+  numClients = commSize - nProcsIO;
+  int role, specialRole = PIO_ROLE_FPGUARD,
+    collType = PIO_ROLE_WRITER_COLLECTOR;
+  switch (IOMode)
+  {
+  case PIO_NONE:
+    xassert(commRank == 0 && commSize == 1);
+    role = PIO_NONE;
+    break;
+  case PIO_MPI:
+  case PIO_MPI_FW_ORDERED:
+  case PIO_MPI_FW_AT_ALL:
+  case PIO_MPI_FW_AT_REBLOCK:
+    clientsPerCollectorMin = numClients / nProcsIO;
+    rest = numClients % nProcsIO;
+    clientsPerCollectorMax = clientsPerCollectorMin + (rest != 0);
+    if (commRank == commSize - 1)
+      role = PIO_ROLE_WRITER_COLLECTOR;
+    else if (commRank <= (clientsPerCollectorMax + 1) * (nProcsIO - rest))
+      role = ((commRank + 1) % (clientsPerCollectorMax + 1)) != 0
+        ? PIO_ROLE_CLIENT : PIO_ROLE_WRITER_COLLECTOR;
+    else
+      role = ((commRank - clientsPerCollectorMax * (nProcsIO - rest) + 1)
+              % (clientsPerCollectorMin + 1)) != 0
+        ? PIO_ROLE_CLIENT : PIO_ROLE_WRITER_COLLECTOR;
+    break;
+  case PIO_WRITER:
+  case PIO_ASYNCH:
+    specialRole = PIO_ROLE_WRITER;
+    collType = PIO_ROLE_COLLECTOR;
+    /* fallthrough intentional */
+  case PIO_FPGUARD:
+    clientsPerCollectorMin = numClients / (nProcsIO - 1);
+    rest = numClients % nProcsIO;
+    clientsPerCollectorMax = clientsPerCollectorMin + (rest != 0);
+    if (commRank == commSize - 1)
+      role = specialRole;
+    else if (commRank <= clientsPerCollectorMax * (nProcsIO - 1 - rest))
+      role = (commRank + 1 % (clientsPerCollectorMax + 1)) != 0
+        ? PIO_ROLE_CLIENT : collType;
+    else
+      role = ((commRank - clientsPerCollectorMax * (nProcsIO - 1 - rest) + 1)
+              % (clientsPerCollectorMin + 1)) != 0
+        ? PIO_ROLE_CLIENT : collType;
+    break;
+  default:
+    xabort("Invalid mode requested %d", IOMode);
+  }
+  return role;
+}
+
diff --git a/libcdi/src/pio_rpc.c b/libcdi/src/pio_rpc.c
new file mode 100644
index 0000000..4c7a838
--- /dev/null
+++ b/libcdi/src/pio_rpc.c
@@ -0,0 +1,60 @@
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <math.h>
+#include <stdbool.h>
+
+#include "cdi.h"
+#include "resource_handle.h"
+/* FIXME: no longer needed when taxis updates are sent as separate data */
+#include "taxis.h"
+
+#include "pio_interface.h"
+#include "pio_rpc.h"
+
+
+
+struct clientBufSize
+computeClientStreamBufSize(int streamID, const struct collSpec *collector)
+{
+  /* 1 record is filled in last to indicate number of records in total */
+  struct clientBufSize rmaSizeSpec
+    = { .bufSize = sizeof (struct winHeaderEntry), .numDataRecords = 1, .numRPCRecords = 0 };
+  int vlistID = streamInqVlist(streamID);
+  size_t nvars = (size_t)vlistNvars(vlistID);
+  for (size_t varID = 0; varID < nvars; ++varID)
+    {
+      size_t chunkSize;
+      {
+        int varSize = vlistInqVarSize(vlistID, (int)varID);
+        chunkSize = (size_t)ceilf(cdiPIOpartInflate_
+                                    * (float)varSize
+                                    / (float)collector->numClients);
+      }
+      rmaSizeSpec.numDataRecords += 2;
+      rmaSizeSpec.bufSize += chunkSize * sizeof (double)
+        /* re-align chunk to multiple of double size */
+        + sizeof (double) - 1
+        /* one header for data record, one for corresponding part
+         * descriptor*/
+        + 2 * sizeof (struct winHeaderEntry)
+        /* FIXME: heuristic for size of packed Xt_idxlist */
+        + sizeof (Xt_int) * chunkSize * 3;
+    }
+
+  // memory required for the function calls encoded
+  // for remote execution
+  // once per stream and timestep for each collector process
+  // from one model process
+  if (collector->sendRPCData)
+    {
+      rmaSizeSpec.numRPCRecords = numRPCFuncs;
+      rmaSizeSpec.bufSize +=
+        numRPCFuncs * sizeof (struct winHeaderEntry)
+        /* data part of streamDefTimestep */
+        + (2 * CDI_MAX_NAME + sizeof (taxis_t));
+    }
+  rmaSizeSpec.bufSize = roundUpToMultiple(rmaSizeSpec.bufSize, PIO_WIN_ALIGN);
+  return rmaSizeSpec;
+}
diff --git a/libcdi/src/pio_rpc.h b/libcdi/src/pio_rpc.h
index 9e66c4a..f96ee64 100644
--- a/libcdi/src/pio_rpc.h
+++ b/libcdi/src/pio_rpc.h
@@ -5,32 +5,35 @@
 #  include "config.h"
 #endif
 
+#include <stdbool.h>
+
 #include <mpi.h>
 #include <yaxt.h>
 
-typedef enum
-  {
-    FINALIZE,
-    RESOURCES,
-    WINCREATE,
-    WRITETS,
-    COLLBUFTX,
-    COLLBUFNMISS,
-  } command;
+enum collectorCommandTags {
+  FINALIZE,
+  RESOURCES,
+  STREAMOPEN,
+  STREAMCLOSE,
+  STREAMDEFVLIST,
+  WRITETS,
+  BLOCK_XFER,
+};
 
 #define MAXWINBUFFERSIZE ((size_t)2048 * 1024 * 1024)
 
 enum
 {
-  numRPCFuncs = 4,
-  STREAMOPEN = -1,
-  STREAMDEFVLIST = -2,
-  STREAMCLOSE = -3,
-  STREAMDEFTIMESTEP = -4,
+  numRPCFuncs = 1,
+  STREAMDEFTIMESTEP = -1,
   HEADERSIZEMARKER = -numRPCFuncs - 1,
   PARTDESCMARKER = -numRPCFuncs - 2,
 };
-enum { MAXDATAFILENAME = 256, MINFUNCID = -numRPCFuncs, MAXFUNCID = -1 };
+enum {
+  MINFUNCID = -numRPCFuncs,
+  MAXFUNCID = -1,
+  defVlistNInts = 2,
+};
 extern const char * const funcMap[numRPCFuncs];
 
 struct headerSize
@@ -47,16 +50,8 @@ union funcArgs
 {
   struct
   {
-    int streamID, vlistID;
-  } streamChange;
-  struct
-  {
     int streamID, tsID;
   } streamNewTimestep;
-  struct
-  {
-    int fnamelen, filetype;
-  } newFile;
 };
 
 /* Describes offset and ID of serialized partition descriptor.
@@ -92,6 +87,22 @@ enum
   PIO_WIN_ALIGN = sizeof (double),
 };
 
+struct clientBufSize
+{
+  size_t bufSize;
+  int numDataRecords, numRPCRecords;
+};
+
+struct collSpec
+{
+  int numClients;
+  int numServers;
+  bool sendRPCData;
+};
+
+struct clientBufSize
+computeClientStreamBufSize(int streamID, const struct collSpec *collector);
+
 #endif
 
 /*
diff --git a/libcdi/src/pio_serialize.c b/libcdi/src/pio_serialize.c
index 009caf3..6cbbfe3 100644
--- a/libcdi/src/pio_serialize.c
+++ b/libcdi/src/pio_serialize.c
@@ -43,7 +43,7 @@ lookupDt(int datatype)
   abort();
 }
 
-#if CDI_DT_MATCH_NEEDED
+#ifdef CDI_DT_MATCH_NEEDED
 static int dtDictMatchComplete = 0;
 
 static inline void
@@ -97,9 +97,9 @@ serializeUnpackMPI(void *buf, int buf_size, int *position,
                   dtDict[lookupDt(datatype)].mpidt, *(MPI_Comm *)context));
 }
 
-void cdiPioSerializeSetMPI()
+void cdiPioSerializeSetMPI(void)
 {
-#if CDI_DT_MATCH_NEEDED
+#ifdef CDI_DT_MATCH_NEEDED
   if (!dtDictMatchComplete)
     setupDtDict();
 #endif
diff --git a/libcdi/src/pio_serialize.h b/libcdi/src/pio_serialize.h
index 74d6a87..fb8aca9 100644
--- a/libcdi/src/pio_serialize.h
+++ b/libcdi/src/pio_serialize.h
@@ -1,6 +1,16 @@
 #ifndef SERIALIZE_PIO_H
 #define SERIALIZE_PIO_H
 /* switch current namespace to use MPI serialization */
-void cdiPioSerializeSetMPI();
+void cdiPioSerializeSetMPI(void);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/pio_server.c b/libcdi/src/pio_server.c
index 8180d7f..e203a74 100644
--- a/libcdi/src/pio_server.c
+++ b/libcdi/src/pio_server.c
@@ -20,15 +20,17 @@
 
 #include "cdi.h"
 #include "cdipio.h"
+#include "cdi_int.h"
 #include "dmemory.h"
 #include "namespace.h"
 #include "taxis.h"
 #include "pio.h"
 #include "pio_comm.h"
+#include "pio_conf.h"
+#include "pio_id_set.h"
 #include "pio_interface.h"
 #include "pio_rpc.h"
 #include "pio_util.h"
-#include "cdi_int.h"
 #ifndef HAVE_NETCDF_PAR_H
 #define MPI_INCLUDED
 #endif
@@ -39,15 +41,62 @@
 #include "vlist_var.h"
 
 
-static struct
+struct clientBuf
 {
   size_t size;
-  unsigned char *buffer;
+  unsigned char *mem;
   int dictSize;
-} *rxWin = NULL;
+};
+
+struct streamMemLayout
+{
+  Xt_uid varPartIdxListUID;
+  size_t offset;
+};
+
+struct cacheRedist {
+  Xt_redist redist;
+  int sliceSize;
+};
+
+static struct
+{
+  MPI_Win getWin;
+  struct clientBuf *clientBuf;
+#if defined HAVE_LIBNETCDF && ! defined HAVE_PARALLEL_NC4
+  int ownerRank;
+#endif
+  /* put data for description of last layout from RMA GET here */
+  struct streamMemLayout *prevLayout;
+  size_t numRetained;
+  struct cacheRedist *retained;
+  size_t aggBufSize, aggBufUsed;
+  void *aggBuf;
+} *rxWin;
+
+static struct idList openStreams, openFiles;
+
+struct recordWrite
+{
+  int varID, level;
+  size_t dataSize;
+};
+
+struct streamMapping {
+  int numVars;
+  /* data entry varMap[i] contains data for variable i or -1 if no
+   * data entry for i has been transferred */
+  int *varMap;
+  /* numLvls[i] number of levels written for variable i or 0 if
+   * variable is not written to this timestep */
+  int *numLvlsW;
+  /* nMiss[i] = missing values were provided for variable i */
+  int *hasMissing;
+  int numWrittenRecords;
+  struct streamMemLayout *layout;
+  struct recordWrite writtenRecords[];
+};
 
-static MPI_Win getWin = MPI_WIN_NULL;
-static MPI_Group groupModel = MPI_GROUP_NULL;
 
 #ifdef HAVE_PARALLEL_NC4
 /* prime factorization of number of pio collectors */
@@ -57,183 +106,72 @@ static int numPioPrimes;
 
 /************************************************************************/
 
-static
-void serverWinCleanup ()
+static void
+cdiPioServerStreamWinDestroy(size_t streamIdx)
 {
-  if (getWin != MPI_WIN_NULL)
-    xmpi(MPI_Win_free(&getWin));
-  if (rxWin)
+  if (rxWin[streamIdx].getWin != MPI_WIN_NULL)
     {
-      free(rxWin[0].buffer);
-      free(rxWin);
+      Free(rxWin[streamIdx].clientBuf[0].mem);
+      xmpi(MPI_Win_free(&rxWin[streamIdx].getWin));
     }
-
-  xdebug("%s", "cleaned up mpi_win");
 }
 
- /************************************************************************/
+static int numClients_, *clientRanks_;
 
-static size_t
-collDefBufferSizes()
+static void
+setupClientRanks(void)
 {
-  int *streamIndexList, vlistID, nvars, varID, iorank;
-  int modelID;
-  size_t sumGetBufferSizes = 0;
-  int rankGlob = commInqRankGlob ();
-  int nProcsModel = commInqNProcsModel ();
-  int root = commInqRootGlob ();
-
-  xassert(rxWin != NULL);
-
-  unsigned nstreams = reshCountType ( &streamOps );
-  streamIndexList = xmalloc((size_t)nstreams * sizeof (streamIndexList[0]));
-  reshGetResHListOfType ( nstreams, streamIndexList, &streamOps );
-  for (unsigned streamNo = 0; streamNo < nstreams; streamNo++)
-    {
-      // space required for data
-      vlistID = streamInqVlist ( streamIndexList[streamNo] );
-      nvars = vlistNvars ( vlistID );
-      for ( varID = 0; varID < nvars; varID++ )
-        {
-          iorank = vlistInqVarIOrank ( vlistID, varID );
-          xassert ( iorank != CDI_UNDEFID );
-          if ( iorank == rankGlob )
-            {
-              for ( modelID = 0; modelID < nProcsModel; modelID++ )
-                {
-                  int decoChunk;
-                  {
-                    int varSize = vlistInqVarSize(vlistID, varID);
-                    int nProcsModel = commInqNProcsModel();
-                    decoChunk =
-                      (int)ceilf(cdiPIOpartInflate_
-                                 * (float)(varSize + nProcsModel - 1)
-                                 / (float)nProcsModel);
-                  }
-                  xassert ( decoChunk > 0 );
-                  rxWin[modelID].size += (size_t)decoChunk * sizeof (double)
-                    /* re-align chunks to multiple of double size */
-                    + sizeof (double) - 1
-                    /* one header for data record, one for
-                     * corresponding part descriptor*/
-                    + 2 * sizeof (struct winHeaderEntry)
-                    /* FIXME: heuristic for size of packed Xt_idxlist */
-                    + sizeof (Xt_int) * (size_t)decoChunk * 3;
-                  rxWin[modelID].dictSize += 2;
-                }
-            }
-        }
-      // space required for the 3 function calls streamOpen, streamDefVlist, streamClose 
-      // once per stream and timestep for all collprocs only on the modelproc root
-      rxWin[root].size += numRPCFuncs * sizeof (struct winHeaderEntry)
-        /* serialized filename */
-        + MAXDATAFILENAME
-        /* data part of streamDefTimestep */
-        + (2 * CDI_MAX_NAME + sizeof (taxis_t));
-      rxWin[root].dictSize += numRPCFuncs;
-    }
-  free ( streamIndexList );
-
-  for ( modelID = 0; modelID < nProcsModel; modelID++ )
-    {
-      /* account for size header */
-      rxWin[modelID].dictSize += 1;
-      rxWin[modelID].size += sizeof (struct winHeaderEntry);
-      rxWin[modelID].size = roundUpToMultiple(rxWin[modelID].size,
-                                              PIO_WIN_ALIGN);
-      sumGetBufferSizes += (size_t)rxWin[modelID].size;
-    }
-  xassert ( sumGetBufferSizes <= MAXWINBUFFERSIZE );
-  return sumGetBufferSizes;
+  MPI_Group clientGroup = cdiPioInqRemoteGroup();
+  xmpi(MPI_Group_size(clientGroup, &numClients_));
+  clientRanks_ = Malloc((size_t)numClients_ * sizeof (clientRanks_[0]));
+  int *ranks = Malloc((size_t)numClients_ * sizeof (ranks[0]));
+  for (int i = 0; i < numClients_; ++i)
+    ranks[i] = i;
+  MPI_Comm collClientIntraComm = cdiPioInqCollClientIntraComm();
+  MPI_Group groupCollClient;
+  xmpi(MPI_Comm_group(collClientIntraComm, &groupCollClient));
+  xmpi(MPI_Group_translate_ranks(clientGroup, numClients_, ranks,
+                                 groupCollClient, clientRanks_));
+  xmpi(MPI_Group_free(&groupCollClient));
+  Free(ranks);
 }
 
- /************************************************************************/
-
 static void
-serverWinCreate(void)
+cdiPioServerStreamWinCreate(size_t streamIdx, MPI_Info no_locks_info,
+                            MPI_Comm collClientIntraComm,
+                            struct clientBufSize *bufSizes)
 {
-  int ranks[1], modelID;
-  MPI_Comm commCalc = commInqCommCalc ();
-  MPI_Group groupCalc;
-  int nProcsModel = commInqNProcsModel ();
-  MPI_Info no_locks_info;
-  xmpi(MPI_Info_create(&no_locks_info));
-  xmpi(MPI_Info_set(no_locks_info, "no_locks", "true"));
-
-  xmpi(MPI_Win_create(MPI_BOTTOM, 0, 1, no_locks_info, commCalc, &getWin));
-
-  /* target group */
-  ranks[0] = nProcsModel;
-  xmpi ( MPI_Comm_group ( commCalc, &groupCalc ));
-  xmpi ( MPI_Group_excl ( groupCalc, 1, ranks, &groupModel ));
-
-  rxWin = xcalloc((size_t)nProcsModel, sizeof (rxWin[0]));
-  size_t totalBufferSize = collDefBufferSizes();
-  rxWin[0].buffer = (unsigned char*) xmalloc(totalBufferSize);
-  size_t ofs = 0;
-  for ( modelID = 1; modelID < nProcsModel; modelID++ )
+  xmpi(MPI_Win_create(MPI_BOTTOM, 0, 1, no_locks_info, collClientIntraComm,
+                      &rxWin[streamIdx].getWin));
+  size_t streamBufferSize = 0;
+  for (size_t i = 0; i < (size_t)numClients_; ++i)
     {
-      ofs += rxWin[modelID - 1].size;
-      rxWin[modelID].buffer = rxWin[0].buffer + ofs;
+      streamBufferSize +=
+        (rxWin[streamIdx].clientBuf[i].size = bufSizes[i].bufSize);
+      rxWin[streamIdx].clientBuf[i].dictSize
+        = bufSizes[i].numDataRecords + bufSizes[i].numRPCRecords;
     }
-
-  xmpi(MPI_Info_free(&no_locks_info));
-
-  xdebug("%s", "created mpi_win, allocated getBuffer");
+  rxWin[streamIdx].clientBuf[0].mem = Malloc(streamBufferSize);
+  for (size_t i = 1; i < (size_t)numClients_; ++i)
+    rxWin[streamIdx].clientBuf[i].mem
+      = rxWin[streamIdx].clientBuf[i-1].mem + bufSizes[i-1].bufSize;
 }
 
+
 /************************************************************************/
 
 static void
-readFuncCall(struct winHeaderEntry *header)
+readFuncCall(struct winHeaderEntry *header, size_t streamIdx)
 {
-  int root = commInqRootGlob ();
   int funcID = header->id;
   union funcArgs *funcArgs = &(header->specific.funcArgs);
 
   xassert(funcID >= MINFUNCID && funcID <= MAXFUNCID);
   switch ( funcID )
     {
-    case STREAMCLOSE:
-      {
-        int streamID
-          = namespaceAdaptKey2(funcArgs->streamChange.streamID);
-        streamClose(streamID);
-        xdebug("READ FUNCTION CALL FROM WIN:  %s, streamID=%d,"
-               " closed stream",
-               funcMap[(-1 - funcID)], streamID);
-      }
-      break;
-    case STREAMOPEN:
-      {
-        size_t filenamesz = (size_t)funcArgs->newFile.fnamelen;
-        xassert ( filenamesz > 0 && filenamesz < MAXDATAFILENAME );
-        const char *filename
-          = (const char *)(rxWin[root].buffer + header->offset);
-        xassert(filename[filenamesz] == '\0');
-        int filetype = funcArgs->newFile.filetype;
-        int streamID = streamOpenWrite(filename, filetype);
-        xassert(streamID != CDI_ELIBNAVAIL);
-        xdebug("READ FUNCTION CALL FROM WIN:  %s, filenamesz=%zu,"
-               " filename=%s, filetype=%d, OPENED STREAM %d",
-               funcMap[(-1 - funcID)], filenamesz, filename,
-               filetype, streamID);
-      }
-      break;
-    case STREAMDEFVLIST:
-      {
-        int streamID
-          = namespaceAdaptKey2(funcArgs->streamChange.streamID);
-        int vlistID = namespaceAdaptKey2(funcArgs->streamChange.vlistID);
-        streamDefVlist(streamID, vlistID);
-        xdebug("READ FUNCTION CALL FROM WIN:  %s, streamID=%d,"
-               " vlistID=%d, called streamDefVlist ().",
-               funcMap[(-1 - funcID)], streamID, vlistID);
-      }
-      break;
     case STREAMDEFTIMESTEP:
       {
-        MPI_Comm commCalc = commInqCommCalc ();
+        MPI_Comm pioInterComm = cdiPioInqInterComm();
         int streamID = funcArgs->streamNewTimestep.streamID;
         int originNamespace = namespaceResHDecode(streamID).nsp;
         streamID = namespaceAdaptKey2(streamID);
@@ -241,8 +179,9 @@ readFuncCall(struct winHeaderEntry *header)
           = vlistInqTaxis(streamInqVlist(streamID));
         int position = header->offset;
         int changedTaxisID
-          = taxisUnpack((char *)rxWin[root].buffer, (int)rxWin[root].size,
-                        &position, originNamespace, &commCalc, 0);
+          = taxisUnpack((char *)rxWin[streamIdx].clientBuf[0].mem,
+                        (int)rxWin[streamIdx].clientBuf[0].size,
+                        &position, originNamespace, &pioInterComm, 0);
         taxis_t *oldTaxisPtr = taxisPtr(oldTaxisID);
         taxis_t *changedTaxisPtr = taxisPtr(changedTaxisID);
         ptaxisCopy(oldTaxisPtr, changedTaxisPtr);
@@ -258,92 +197,99 @@ readFuncCall(struct winHeaderEntry *header)
 /************************************************************************/
 
 static void
-resizeVarGatherBuf(int vlistID, int varID, double **buf, int *bufSize)
+resizeVarGatherBuf(int size, double **buf, int *bufSize)
 {
-  int size = vlistInqVarSize(vlistID, varID);
   if (size <= *bufSize) ; else
-    *buf = xrealloc(*buf, (size_t)(*bufSize = size) * sizeof (buf[0][0]));
+    *buf = Realloc(*buf, (size_t)(*bufSize = size) * sizeof (buf[0][0]));
 }
 
-static void
-gatherArray(int root, int nProcsModel, int headerIdx,
-            int vlistID,
-            double *gatherBuf, int *nmiss)
+static Xt_redist
+buildVarRedist(int headerIdx, size_t streamIdx,
+               /* index list representing the data elements gathered on
+                * this rank */
+               Xt_idxlist dstList,
+               const struct cdiPioConf *conf)
 {
-  struct winHeaderEntry *winDict
-    = (struct winHeaderEntry *)rxWin[root].buffer;
-  int streamID = winDict[headerIdx].id;
+  const struct clientBuf *restrict clientBuf = rxWin[streamIdx].clientBuf;
+  const struct winHeaderEntry *winDict
+    = (struct winHeaderEntry *)clientBuf[0].mem;
+  int streamID = openStreams.entries[streamIdx];
   int varID = winDict[headerIdx].specific.dataRecord.varID;
-  int varShape[3] = { 0, 0, 0 };
-  cdiPioQueryVarDims(varShape, vlistID, varID);
-  Xt_int varShapeXt[3];
-  static const Xt_int origin[3] = { 0, 0, 0 };
-  for (unsigned i = 0; i < 3; ++i)
-    varShapeXt[i] = varShape[i];
-  int varSize = varShape[0] * varShape[1] * varShape[2];
   struct Xt_offset_ext *partExts
-    = xmalloc((size_t)nProcsModel * sizeof (partExts[0]));
-  Xt_idxlist *part = xmalloc((size_t)nProcsModel * sizeof (part[0]));
-  MPI_Comm commCalc = commInqCommCalc();
-  {
-    int nmiss_ = 0;
-    for (int modelID = 0; modelID < nProcsModel; modelID++)
-      {
-        struct dataRecord *dataHeader
-          = &((struct winHeaderEntry *)
-              rxWin[modelID].buffer)[headerIdx].specific.dataRecord;
-        int position =
-          ((struct winHeaderEntry *)rxWin[modelID].buffer)[headerIdx + 1].offset;
-        xassert(namespaceAdaptKey2(((struct winHeaderEntry *)
-                                    rxWin[modelID].buffer)[headerIdx].id)
-                == streamID
-                && dataHeader->varID == varID
-                && ((struct winHeaderEntry *)
-                    rxWin[modelID].buffer)[headerIdx + 1].id == PARTDESCMARKER
-                && position > 0
-                && ((size_t)position
-                    >= sizeof (struct winHeaderEntry) * (size_t)rxWin[modelID].dictSize)
-                && ((size_t)position < rxWin[modelID].size));
-        part[modelID] = xt_idxlist_unpack(rxWin[modelID].buffer,
-                                          (int)rxWin[modelID].size,
-                                          &position, commCalc);
-        unsigned partSize = (unsigned)xt_idxlist_get_num_indices(part[modelID]);
-        size_t charOfs = (size_t)((rxWin[modelID].buffer
-                                   + ((struct winHeaderEntry *)
-                                      rxWin[modelID].buffer)[headerIdx].offset)
-                                  - rxWin[0].buffer);
-        xassert(charOfs % sizeof (double) == 0
-                && charOfs / sizeof (double) + partSize <= INT_MAX);
-        int elemOfs = (int)(charOfs / sizeof (double));
-        partExts[modelID].start = elemOfs;
-        partExts[modelID].size = (int)partSize;
-        partExts[modelID].stride = 1;
-        nmiss_ += dataHeader->nmiss;
-      }
-    *nmiss = nmiss_;
-  }
-  Xt_idxlist srcList = xt_idxlist_collection_new(part, nProcsModel);
-  for (int modelID = 0; modelID < nProcsModel; modelID++)
-    xt_idxlist_delete(part[modelID]);
-  free(part);
-  Xt_xmap gatherXmap;
-  {
-    Xt_idxlist dstList
-      = xt_idxsection_new(0, 3, varShapeXt, varShapeXt, origin);
-    struct Xt_com_list full = { .list = dstList, .rank = 0 };
-    gatherXmap = xt_xmap_intersection_new(1, &full, 1, &full, srcList, dstList,
-                                          MPI_COMM_SELF);
-    xt_idxlist_delete(dstList);
-  }
+    = Malloc((size_t)numClients_ * sizeof (partExts[0]));
+  Xt_idxlist *part = Malloc((size_t)numClients_ * sizeof (part[0]));
+  MPI_Comm pioInterComm = cdiPioInqInterComm(),
+    collComm = commInqCommColl();
+  for (size_t clientIdx = 0; clientIdx < (size_t)numClients_; ++clientIdx)
+    {
+      unsigned char *clientMem = clientBuf[clientIdx].mem;
+      struct dataRecord *dataHeader
+        = &((struct winHeaderEntry *)clientMem)[headerIdx].specific.dataRecord;
+      int position = ((struct winHeaderEntry *)clientMem)[headerIdx + 1].offset;
+      xassert(namespaceAdaptKey2(((struct winHeaderEntry *)
+                                  clientMem)[headerIdx].id)
+              == streamID
+              && dataHeader->varID == varID
+              && (((struct winHeaderEntry *)clientMem)[headerIdx + 1].id
+                  == PARTDESCMARKER)
+              && position > 0
+              && ((size_t)position
+                  >= sizeof (struct winHeaderEntry)
+                  * (size_t)clientBuf[clientIdx].dictSize)
+              && ((size_t)position < clientBuf[clientIdx].size));
+      part[clientIdx]
+        = xt_idxlist_unpack(clientMem, (int)clientBuf[clientIdx].size,
+                            &position, pioInterComm);
+      unsigned partSize
+        = (unsigned)xt_idxlist_get_num_indices(part[clientIdx]);
+      size_t charOfs = (size_t)((clientMem
+                                 + ((struct winHeaderEntry *)
+                                    clientMem)[headerIdx].offset)
+                                - clientBuf[0].mem);
+      xassert(charOfs % sizeof (double) == 0
+              && charOfs / sizeof (double) + partSize <= INT_MAX);
+      int elemOfs = (int)(charOfs / sizeof (double));
+      partExts[clientIdx].start = elemOfs;
+      partExts[clientIdx].size = (int)partSize;
+      partExts[clientIdx].stride = 1;
+    }
+  Xt_idxlist srcList = xt_idxlist_collection_new(part, numClients_);
+  for (size_t clientIdx = 0; clientIdx < (size_t)numClients_; ++clientIdx)
+    xt_idxlist_delete(part[clientIdx]);
+  Free(part);
+  if (conf->stripify)
+    {
+      Xt_idxlist srcListStriped = xt_idxstripes_from_idxlist_new(srcList);
+      xt_idxlist_delete(srcList);
+      srcList = srcListStriped;
+    }
+  Xt_xmap gatherXmap = conf->xmap_new(srcList, dstList, collComm);
   xt_idxlist_delete(srcList);
-
-  struct Xt_offset_ext gatherExt = { .start = 0, .size = varSize, .stride = 1 };
-  Xt_redist gatherRedist
-    = xt_redist_p2p_ext_new(gatherXmap, nProcsModel, partExts, 1, &gatherExt,
+  struct Xt_offset_ext gatherExt
+    = { .start = 0,
+        .size = xt_idxlist_get_num_indices(dstList),
+        .stride = 1 };
+  Xt_redist varRedist
+    = xt_redist_p2p_ext_new(gatherXmap, numClients_, partExts, 1, &gatherExt,
                             MPI_DOUBLE);
   xt_xmap_delete(gatherXmap);
-  xt_redist_s_exchange1(gatherRedist, rxWin[0].buffer, gatherBuf);
-  free(partExts);
+  Free(partExts);
+  return varRedist;
+}
+
+
+static void
+gatherArray(int headerIdx, size_t streamIdx,
+            double *gatherBuf,
+            /* index list representing the data elements gathered on
+             * this rank */
+            Xt_idxlist dstList,
+            const struct cdiPioConf *conf)
+{
+  Xt_redist gatherRedist = buildVarRedist(headerIdx, streamIdx,
+                                          dstList, conf);
+  xt_redist_s_exchange1(gatherRedist,
+                        rxWin[streamIdx].clientBuf[0].mem, gatherBuf);
   xt_redist_delete(gatherRedist);
 }
 
@@ -358,6 +304,38 @@ xyzGridSize(struct xyzDims dims)
   return dims.sizes[0] * dims.sizes[1] * dims.sizes[2];
 }
 
+static Xt_idxlist
+buildVarSlicesIdxList(int vlistID, int varID, int startLvl, int numLvl)
+{
+  int varShape[3] = { 0, 0, 0 };
+  cdiPioQueryVarDims(varShape, vlistID, varID);
+  /* int varSize = varShape[0] * varShape[1] * varShape[2]; */
+  Xt_int varShapeXt[3],
+    origin[3] = { startLvl >= 0 ? (Xt_int)startLvl:0, 0, 0 };
+  int sliceShape[3];
+  for (unsigned i = 0; i < 3; ++i)
+    varShapeXt[2 - i] = (Xt_int)varShape[i];
+  sliceShape[0] = numLvl >= 0 ? numLvl : (int)varShape[2];
+  sliceShape[1] = varShape[1];
+  sliceShape[2] = varShape[0];
+  return xt_idxsection_new(0, 3, varShapeXt, sliceShape, origin);
+}
+
+static int
+countVarChunkMissingVals(int vlistID, int varID,
+                         struct streamMapping *mapping,
+                         int chunkLen, const double *restrict data)
+{
+  int nmiss = 0;
+  if (mapping->hasMissing[varID])
+    {
+      double missval = vlistInqVarMissval(vlistID, varID);
+      for (size_t i = 0; i < (size_t)chunkLen; ++i)
+        nmiss += (data[i] == missval);
+    }
+  return nmiss;
+}
+
 #ifdef HAVE_PARALLEL_NC4
 static void
 queryVarBounds(struct PPM_extent varShape[3], int vlistID, int varID)
@@ -414,16 +392,93 @@ myVarPart(struct PPM_extent varShape[3], struct xyzDims collGrid,
   PPM_uniform_partition_nd(3, varShape, collGrid.sizes,
                            myCollGridCoord, myPart);
 }
+
+/* collective writing variant */
+static void
+writeNetCDFStream(size_t streamIdx,
+                  struct streamMapping *mapping,
+                  double **data_, int *currentDataBufSize,
+                  const struct cdiPioConf *conf)
+{
+  int nvars = mapping->numVars;
+  int *restrict varMap = mapping->varMap;
+  int streamID = openStreams.entries[streamIdx],
+    vlistID = streamInqVlist(streamID);
+  for (int varID = 0; varID < nvars; ++varID)
+    if (mapping->numLvlsW[varID])
+      {
+        struct PPM_extent varShape[3];
+        queryVarBounds(varShape, vlistID, varID);
+        struct xyzDims collGrid = varDimsCollGridMatch(varShape);
+        xdebug("writing varID %d with dimensions: "
+               "x=%d, y=%d, z=%d,\n"
+               "found distribution with dimensions:"
+               " x=%d, y=%d, z=%d.", varID,
+               varShape[0].size, varShape[1].size, varShape[2].size,
+               collGrid.sizes[0], collGrid.sizes[1],
+               collGrid.sizes[2]);
+        struct PPM_extent varChunk[3];
+        myVarPart(varShape, collGrid, varChunk);
+        int myChunk[3][2];
+        for (int i = 0; i < 3; ++i)
+          {
+            myChunk[i][0] = PPM_extent_start(varChunk[i]);
+            myChunk[i][1] = PPM_extent_end(varChunk[i]);
+          }
+        xdebug("Writing chunk { { %d, %d }, { %d, %d },"
+               " { %d, %d } }", myChunk[0][0], myChunk[0][1],
+               myChunk[1][0], myChunk[1][1], myChunk[2][0],
+               myChunk[2][1]);
+        Xt_int varSize[3];
+        for (int i = 0; i < 3; ++i)
+          varSize[2 - i] = varShape[i].size;
+        Xt_idxlist preWriteChunk;
+        /* prepare yaxt descriptor for write chunk */
+        {
+          Xt_int preWriteChunkStart[3];
+          int preWriteChunkSize[3];
+          for (int i = 0; i < 3; ++i)
+            {
+              preWriteChunkStart[2 - i] = (Xt_int)varChunk[i].first;
+              preWriteChunkSize[2 - i] = (int)varChunk[i].size;
+            }
+          preWriteChunk = xt_idxsection_new(0, 3, varSize,
+                                            preWriteChunkSize,
+                                            preWriteChunkStart);
+        }
+        resizeVarGatherBuf(xt_idxlist_get_num_indices(preWriteChunk),
+                           data_, currentDataBufSize);
+        double *restrict data = *data_;
+        /* transpose data into write deco */
+        {
+          int headerIdx = varMap[varID];
+          gatherArray(headerIdx, streamIdx, data, preWriteChunk, conf);
+          xt_idxlist_delete(preWriteChunk);
+        }
+        /* count missing values if appropriate */
+        int nmiss
+          = countVarChunkMissingVals(vlistID, varID, mapping,
+                                     PPM_extents_size(3, varChunk),
+                                     data);
+        /* write chunk */
+        streamWriteVarChunk(streamID, varID,
+                            (const int (*)[2])myChunk, data,
+                            nmiss);
+      }
+}
+
 #elif defined (HAVE_LIBNETCDF)
 /* needed for writing when some files are only written to by a single process */
 /* cdiOpenFileMap(fileID) gives the writer process */
-int cdiPioSerialOpenFileMap(int streamID)
+static int cdiPioSerialOpenFileMap(int streamID)
 {
-  return stream_to_pointer(streamID)->ownerRank;
+  size_t streamIdx = indexOfID(&openStreams, streamID);
+  xassert(streamIdx < SIZE_MAX);
+  return rxWin[streamIdx].ownerRank;
 }
 /* for load-balancing purposes, count number of files per process */
 /* cdiOpenFileCounts[rank] gives number of open files rank has to himself */
-static int *cdiSerialOpenFileCount = NULL;
+static int *cdiSerialOpenFileCount;
 
 static int
 cdiPioNextOpenRank()
@@ -467,209 +522,590 @@ cdiPioServerCdfDefVars(stream_t *streamptr)
     cdfDefVars(streamptr);
 }
 
-#endif
+static void
+writeNetCDFStream(size_t streamIdx,
+                  struct streamMapping *mapping,
+                  double **data_, int *currentDataBufSize,
+                  const struct cdiPioConf *conf)
+{
+  int nvars = mapping->numVars;
+  int *restrict varMap = mapping->varMap,
+    *restrict numLvlsW = mapping->numLvlsW;
+  /* determine process which has stream open (writer) and
+   * which has data for which variable (var owner)
+   * three cases need to be distinguished */
+  int streamID = openStreams.entries[streamIdx],
+    vlistID = streamInqVlist(streamID);
+  int writerRank = cdiPioSerialOpenFileMap(streamID);
+  int collRank = commInqRankColl();
+  for (int varID = 0; varID < nvars; ++varID)
+    if (numLvlsW[varID])
+      {
+        int varSize;
+        Xt_idxlist dstList;
+        if (writerRank == collRank)
+          {
+            dstList = buildVarSlicesIdxList(vlistID, varID, -1, -1);
+            varSize = xt_idxlist_get_num_indices(dstList);
+            resizeVarGatherBuf(varSize, data_, currentDataBufSize);
+          }
+        else
+          {
+            varSize = 0;
+            dstList = xt_idxempty_new();
+          }
+        double *restrict data = *data_;
+        int headerIdx = varMap[varID];
+        gatherArray(headerIdx, streamIdx, data, dstList, conf);
+        if (writerRank == collRank)
+          {
+            int nmiss = countVarChunkMissingVals(vlistID, varID,
+                                                 mapping, varSize, data);
+            streamWriteVar(streamID, varID, data, nmiss);
+          }
+        xt_idxlist_delete(dstList);
+      }
+}
 
-struct streamMapping {
-  int streamID, filetype;
-  int firstHeaderIdx, lastHeaderIdx;
-  int numVars, *varMap;
-};
+#endif
 
-struct streamMap
+static inline struct winHeaderEntry *
+winDictEntry(size_t streamIdx, size_t client, size_t entry)
 {
-  struct streamMapping *entries;
-  int numEntries;
-};
+  return ((struct winHeaderEntry *)rxWin[streamIdx].clientBuf[client].mem)
+    + entry;
+}
 
-static int
-smCmpStreamID(const void *a_, const void *b_)
+static struct streamMemLayout *
+getLayout(size_t streamIdx)
 {
-  const struct streamMapping *a = a_, *b = b_;
-  int streamIDa = a->streamID, streamIDb = b->streamID;
-  return (streamIDa > streamIDb) - (streamIDa < streamIDb);
+  int streamID = openStreams.entries[streamIdx];
+  size_t numClients = (size_t)numClients_;
+  int vlistID = streamInqVlist(streamID);
+  size_t numVars = (size_t)vlistNvars(vlistID);
+  struct streamMemLayout (*layout)[numVars]
+    = Calloc(numClients * numVars, sizeof (layout[0]));
+  size_t numDataEntries
+    = (size_t)(winDictEntry(streamIdx, 0, 0)->specific.headerSize.numDataEntries);
+  for (size_t client = 0; client < numClients; ++client)
+    for (size_t headerIdx = 1; headerIdx < numDataEntries; headerIdx += 2)
+      {
+        xassert(namespaceAdaptKey2(winDictEntry(streamIdx, client,
+                                                headerIdx)->id) == streamID);
+        struct winHeaderEntry *varHeader
+          = winDictEntry(streamIdx, client, headerIdx);
+        size_t varID = (size_t)varHeader[0].specific.dataRecord.varID;
+        size_t offset = (size_t)varHeader[0].offset;
+        Xt_uid uid = varHeader[1].specific.partDesc.uid;
+        layout[client][varID] = (struct streamMemLayout){
+          .varPartIdxListUID = uid, .offset = offset };
+      }
+  return *layout;
 }
 
-static inline int
-inventorizeStream(struct streamMapping *streamMap, int numStreamIDs,
-                  int *sizeStreamMap_, int streamID, int headerIdx)
+/* build inventory of written variables for stream */
+static struct streamMapping *
+streamMappingNew(size_t streamIdx, struct winHeaderEntry *winDict,
+                 const struct cdiPioConf *conf)
 {
-  int sizeStreamMap = *sizeStreamMap_;
-  if (numStreamIDs < sizeStreamMap) ; else
-    {
-      streamMap = xrealloc(streamMap,
-                           (size_t)(sizeStreamMap *= 2)
-                           * sizeof (streamMap[0]));
-      *sizeStreamMap_ = sizeStreamMap;
-    }
-  streamMap[numStreamIDs].streamID = streamID;
-  streamMap[numStreamIDs].firstHeaderIdx = headerIdx;
-  streamMap[numStreamIDs].lastHeaderIdx = headerIdx;
-  streamMap[numStreamIDs].numVars = -1;
-  int filetype = streamInqFiletype(streamID);
-  streamMap[numStreamIDs].filetype = filetype;
-  if (filetype == FILETYPE_NC || filetype == FILETYPE_NC2
-      || filetype == FILETYPE_NC4)
+  int streamID = openStreams.entries[streamIdx];
+  int numDataEntries = winDict[0].specific.headerSize.numDataEntries;
+  int vlistID = streamInqVlist(streamID);
+  int numVars = vlistNvars(vlistID);
+  /* varMap[i] == index of header if variable i is written to,
+   * numLvlsW[i] == number of levels of variable i or 0 if not written
+   */
+  int *restrict varMap = Calloc((size_t)numVars * 4, sizeof (varMap[0])),
+    *restrict hasMissing = varMap + numVars,
+    *restrict numLvlsW = varMap + 2 * numVars,
+    *restrict hasMissing_ = varMap + 3 * numVars;
+  for (int headerIdx = 1; headerIdx < numDataEntries; headerIdx += 2)
     {
-      int vlistID = streamInqVlist(streamID);
-      int nvars = vlistNvars(vlistID);
-      streamMap[numStreamIDs].numVars = nvars;
-      streamMap[numStreamIDs].varMap
-        = xmalloc(sizeof (streamMap[numStreamIDs].varMap[0]) * (size_t)nvars);
-      for (int i = 0; i < nvars; ++i)
-        streamMap[numStreamIDs].varMap[i] = -1;
+      xassert(namespaceAdaptKey2(winDict[headerIdx].id) == streamID);
+      int varID = winDict[headerIdx].specific.dataRecord.varID;
+      /* ensure a variable has not been enqueued twice */
+      /* FIXME: this could better be ensured on client */
+      xassert(varID < numVars && varID >= 0 && varMap[varID] == 0);
+      varMap[varID] = headerIdx;
+      hasMissing[varID] += winDict[headerIdx].specific.dataRecord.nmiss;
     }
-  return numStreamIDs + 1;
+  /* set numLvlsW[i] to 1 if varMap[i] != 0 on any collector,
+   * also sets hasMissing_[i] to global reduction of hasMissing[i] */
+  xmpi(MPI_Allreduce(varMap, numLvlsW, 2 * numVars, MPI_INT,
+                     MPI_LOR, commInqCommColl()));
+  /* now find numbers of levels for each variable written anywhere */
+  size_t numWrittenRecords = 0;
+  for (int varID = 0; varID < numVars; ++varID)
+    if (numLvlsW[varID])
+      numWrittenRecords
+        += (size_t)(numLvlsW[varID]
+                    = zaxisInqSize(vlistInqVarZaxis(vlistID, varID)));
+  struct streamMapping *result
+    = Malloc(sizeof (*result)
+              + numWrittenRecords * sizeof (result->writtenRecords[0])
+              + (size_t)numVars * 3 * sizeof (result->varMap[0]));
+  result->varMap
+    = (void *)((unsigned char *)result + sizeof (*result)
+               + numWrittenRecords * sizeof (result->writtenRecords[0]));
+  result->numLvlsW = result->varMap + numVars;
+  result->hasMissing = result->varMap + 2 * numVars;
+  {
+    size_t j = (size_t)-1;
+    /* initialized to shut up gcc, loop logic ensures initialization
+     * at least once */
+    size_t recordDataSize = 0;
+    int lastVarID = -1;
+    for (int varID = 0; varID < numVars; ++varID)
+      {
+        size_t numLvl = (size_t)(result->numLvlsW[varID] = numLvlsW[varID]);
+        if (varID != lastVarID)
+          {
+            int varShape[3];
+            cdiPioQueryVarDims(varShape, vlistID, varID);
+            recordDataSize = (size_t)varShape[0] * (size_t)varShape[1]
+              * sizeof (double);
+            lastVarID = varID;
+          }
+        result->varMap[varID] = varMap[varID];
+        result->hasMissing[varID] = hasMissing_[varID];
+        for (size_t lvl = 0; lvl < numLvl; ++lvl)
+          result->writtenRecords[++j]
+            = (struct recordWrite){ .varID = varID, .level = (int)lvl,
+                                    .dataSize = recordDataSize};
+      }
+  }
+  result->numVars = numVars;
+  result->numWrittenRecords = (int)numWrittenRecords;
+  Free(varMap);
+  result->layout = conf->cacheRedists ? getLayout(streamIdx) : NULL;
+  return result;
 }
 
-static inline int
-streamIsInList(struct streamMapping *streamMap, int numStreamIDs,
-               int streamIDQuery)
+static void
+streamMappingDelete(struct streamMapping **mapping)
 {
-  int p = 0;
-  for (int i = 0; i < numStreamIDs; ++i)
-    p |= streamMap[i].streamID == streamIDQuery;
-  return p;
+  Free((*mapping)->layout);
+  Free(*mapping);
+  *mapping = NULL;
 }
 
-static struct streamMap
-buildStreamMap(struct winHeaderEntry *winDict)
+static inline void
+destructRetained(struct cacheRedist *restrict retained, size_t numRetained)
 {
-  int streamIDOld = CDI_UNDEFID;
-  int oldStreamIdx = CDI_UNDEFID;
-  int filetype = FILETYPE_UNDEF;
-  int sizeStreamMap = 16;
-  struct streamMapping *streamMap
-    = xmalloc((size_t)sizeStreamMap * sizeof (streamMap[0]));
-  int numDataEntries = winDict[0].specific.headerSize.numDataEntries;
-  int numStreamIDs = 0;
-  /* find streams written on this process */
-  for (int headerIdx = 1; headerIdx < numDataEntries; headerIdx += 2)
+  for (size_t i = 0; i < (size_t)numRetained; ++i)
+    xt_redist_delete(retained[i].redist);
+}
+
+static inline bool
+handleRedistCache(size_t streamIdx,
+                  struct streamMapping *restrict mapping,
+                  size_t numPasses, int vlistID, MPI_Comm collComm)
+{
+  bool reuseRedists = false;
+  if (!rxWin[streamIdx].retained)
+    {
+      rxWin[streamIdx].retained
+        = Malloc(numPasses * sizeof (*rxWin[streamIdx].retained));
+      rxWin[streamIdx].numRetained = numPasses;
+      rxWin[streamIdx].prevLayout = mapping->layout;
+      mapping->layout = NULL;
+    }
+  else
     {
-      int streamID
-        = winDict[headerIdx].id
-        = namespaceAdaptKey2(winDict[headerIdx].id);
-      xassert(streamID > 0);
-      if (streamID != streamIDOld)
+      size_t numClients = (size_t)numClients_,
+        numVars = (size_t)vlistNvars(vlistID);
+      reuseRedists
+        = !memcmp(mapping->layout, rxWin[streamIdx].prevLayout,
+                  numClients * numVars
+                  * sizeof (mapping->layout[0]));
+      if (!reuseRedists)
         {
-          for (int i = numStreamIDs - 1; i >= 0; --i)
-            if ((streamIDOld = streamMap[i].streamID) == streamID)
-              {
-                oldStreamIdx = i;
-                goto streamIDInventorized;
-              }
-          oldStreamIdx = numStreamIDs;
-          streamIDOld = streamID;
-          numStreamIDs = inventorizeStream(streamMap, numStreamIDs,
-                                           &sizeStreamMap, streamID, headerIdx);
+          Free(rxWin[streamIdx].prevLayout);
+          rxWin[streamIdx].prevLayout = mapping->layout;
+          mapping->layout = NULL;
         }
-      streamIDInventorized:
-      filetype = streamMap[oldStreamIdx].filetype;
-      streamMap[oldStreamIdx].lastHeaderIdx = headerIdx;
-      if (filetype == FILETYPE_NC || filetype == FILETYPE_NC2
-          || filetype == FILETYPE_NC4)
+      {
+        int temp = reuseRedists;
+        xmpi(MPI_Allreduce(MPI_IN_PLACE, &temp, 1, MPI_INT, MPI_LAND,
+                           collComm));
+        reuseRedists = temp;
+      }
+      if (!reuseRedists)
         {
-          int varID = winDict[headerIdx].specific.dataRecord.varID;
-          streamMap[oldStreamIdx].varMap[varID] = headerIdx;
+          destructRetained(rxWin[streamIdx].retained,
+                           rxWin[streamIdx].numRetained);
+          rxWin[streamIdx].retained
+            = Realloc(rxWin[streamIdx].retained,
+                       numPasses * sizeof (*rxWin[streamIdx].retained));
+          rxWin[streamIdx].numRetained = numPasses;
         }
     }
-  /* join with list of streams written to in total */
-  {
-    int *streamIDs, *streamIsWritten;
-    unsigned numTotalStreamIDs = reshCountType(&streamOps);
-    streamIDs = xmalloc(2 * sizeof (streamIDs[0]) * (size_t)numTotalStreamIDs);
-    cdiStreamGetIndexList(numTotalStreamIDs, streamIDs);
-    streamIsWritten = streamIDs + numTotalStreamIDs;
-    for (unsigned i = 0; i < numTotalStreamIDs; ++i)
-      streamIsWritten[i] = streamIsInList(streamMap, numStreamIDs,
-                                          streamIDs[i]);
-    /* Find what streams are written to at all on any process */
-    xmpi(MPI_Allreduce(MPI_IN_PLACE, streamIsWritten, (int)numTotalStreamIDs,
-                       MPI_INT, MPI_BOR, commInqCommColl()));
-    /* append streams written to on other tasks to mapping */
-    for (unsigned i = 0; i < numTotalStreamIDs; ++i)
-      if (streamIsWritten[i] && !streamIsInList(streamMap, numStreamIDs,
-                                                streamIDs[i]))
-        numStreamIDs = inventorizeStream(streamMap, numStreamIDs,
-                                         &sizeStreamMap, streamIDs[i], -1);
-
-    free(streamIDs);
-  }
-  /* sort written streams by streamID */
-  streamMap = xrealloc(streamMap, sizeof (streamMap[0]) * (size_t)numStreamIDs);
-  qsort(streamMap, (size_t)numStreamIDs, sizeof (streamMap[0]), smCmpStreamID);
-  return (struct streamMap){ .entries = streamMap, .numEntries = numStreamIDs };
+  return reuseRedists;
 }
 
-static void
-writeGribStream(struct winHeaderEntry *winDict, struct streamMapping *mapping,
-                double **data_, int *currentDataBufSize, int root,
-                int nProcsModel)
+/* denote what will be aggregated at a single process */
+struct passPlan
 {
-  int streamID = mapping->streamID;
-  int headerIdx, lastHeaderIdx = mapping->lastHeaderIdx;
-  int vlistID = streamInqVlist(streamID);
-  if (lastHeaderIdx < 0)
+  unsigned recordAggStart, recordAggEnd;
+  int varStart, varEnd;
+};
+
+void
+deco1D_CCP(size_t n, const size_t weightPfxSums[n],
+           size_t nparts, size_t separators[nparts + 1]);
+
+/**
+ * @param[out] passes pointer to pointer to 2-dimensional array of
+ * records of dimensions $number of passes \cdot number of collectors$,
+ * where $(*passes)[pass][i]$ details the records written by collector
+ * rank \a i
+ * @return number of passes
+ */
+static size_t
+planPasses(size_t streamIdx, const struct streamMapping *mapping,
+           const struct cdiPioConf *conf, size_t collSize,
+           struct passPlan (**passes_)[collSize])
+{
+  (void)streamIdx;
+  size_t numPasses = 0;
+  size_t recordAggBufLim = conf->recordAggBufLimMB * 1024 * 1024,
+    totalAggBufSpace = recordAggBufLim * collSize,
+    totalWritten = 0;
+  /* find total size of data written for the stream and build prefix sums */
+  size_t numWrittenRecords = (size_t)mapping->numWrittenRecords;
+
+  if (numWrittenRecords == 0)
+    return 0;
+  size_t *restrict recordDataSizePfxSums
+    = Malloc((numWrittenRecords + 1 + collSize + 1)
+              * sizeof (*recordDataSizePfxSums)),
+    *restrict recordSeparations = recordDataSizePfxSums + numWrittenRecords + 1;
+  const struct recordWrite *restrict writtenRecords
+    = mapping->writtenRecords;
+
+  recordDataSizePfxSums[0] = 0;
+  for (size_t i = 0; i < numWrittenRecords; ++i)
+    {
+      size_t recordDataSize = writtenRecords[i].dataSize;
+      recordDataSizePfxSums[i + 1]
+        = recordDataSizePfxSums[i] + recordDataSize;
+      totalWritten += recordDataSize;
+    }
+  /* move if into loop for handling last pass */
+  if (totalWritten < totalAggBufSpace)
     {
-      /* write zero bytes to trigger synchronization code in fileWrite */
-      cdiPioFileWrite(streamInqFileID(streamID), NULL, 0,
-                      streamInqCurTimestepID(streamID));
+      /* don't go to limit of some tasks where a single pass will be
+       * sufficient to write everything, compute load-balancing
+       * instead */
+      numPasses = 1;
+      struct passPlan *passes = Malloc(sizeof (*passes) * collSize);
+      deco1D_CCP(numWrittenRecords, recordDataSizePfxSums,
+                 collSize, recordSeparations);
+      for (size_t rank = 0; rank < collSize; ++rank)
+        {
+          size_t startRecord = recordSeparations[rank],
+            lastRecord = recordSeparations[rank + 1] - 1;
+          passes[rank] = (struct passPlan){
+            .recordAggStart = (unsigned)startRecord,
+            .recordAggEnd = (unsigned)lastRecord,
+            .varStart = writtenRecords[startRecord].varID,
+            .varEnd = writtenRecords[lastRecord].varID,
+          };
+        }
+      *passes_ = (struct passPlan(*)[collSize])passes;
     }
   else
-    for (headerIdx = mapping->firstHeaderIdx;
-         headerIdx <= lastHeaderIdx;
-         headerIdx += 2)
-      if (streamID == winDict[headerIdx].id)
+    {
+      /* aggregate as many records on each task to fill up to
+       * recordAggLim data bytes, but use at least one, unless none
+       * remain */
+      size_t firstRecordOfPass = 0, curRecord;
+      struct passPlan (*passes)[collSize] = NULL;
+      do
         {
-          int varID = winDict[headerIdx].specific.dataRecord.varID;
-          int size = vlistInqVarSize(vlistID, varID);
-          int nmiss;
-          resizeVarGatherBuf(vlistID, varID, data_, currentDataBufSize);
-          double *data = *data_;
-          gatherArray(root, nProcsModel, headerIdx,
-                      vlistID, data, &nmiss);
-          streamWriteVar(streamID, varID, data, nmiss);
-          if ( ddebug > 2 )
+          size_t taskBegin = firstRecordOfPass;
+          curRecord = firstRecordOfPass - 1;
+          passes = Realloc(passes, sizeof (*passes) * (numPasses + 1));
+          for (size_t rank = 0; rank < collSize; ++rank)
             {
-              char text[1024];
-              sprintf(text, "streamID=%d, var[%d], size=%d",
-                      streamID, varID, size);
-              xprintArray(text, data, size, DATATYPE_FLT);
+              size_t recordAggBufSize = 0;
+              while (curRecord + 1 < numWrittenRecords
+                     && ((recordAggBufSize
+                          + writtenRecords[curRecord + 1].dataSize)
+                         < recordAggBufLim))
+                recordAggBufSize += writtenRecords[++curRecord].dataSize;
+              if (curRecord == taskBegin - 1
+                  && curRecord + 1 < numWrittenRecords)
+                ++curRecord;
+              passes[numPasses][rank] = (struct passPlan){
+                .recordAggStart = (unsigned)taskBegin,
+                .recordAggEnd = (unsigned)curRecord,
+                .varStart = writtenRecords[taskBegin].varID,
+                .varEnd = writtenRecords[curRecord].varID,
+              };
+              taskBegin = curRecord + 1;
             }
+          ++numPasses, firstRecordOfPass = curRecord + 1;
         }
+      while (curRecord + 1 < numWrittenRecords);
+      *passes_ = passes;
+    }
+  Free(recordDataSizePfxSums);
+  return numPasses;
+}
+
+static inline unsigned
+umax(unsigned a, unsigned b)
+{
+  return a >= b ? a : b;
+}
+
+static inline unsigned
+umin(unsigned a, unsigned b)
+{
+  return a <= b ? a : b;
+}
+
+static inline size_t
+szmin(size_t a, size_t b)
+{
+  return a <= b ? a : b;
+}
+
+static inline size_t
+szmax(size_t a, size_t b)
+{
+  return a >= b ? a : b;
+}
+
+static size_t
+aggBufAppend(int fileID, const void *restrict ptr, size_t size)
+{
+  size_t fileIdx = indexOfID(&openFiles, fileID),
+    aggBufSize = rxWin[fileIdx].aggBufSize,
+    aggBufUsed = rxWin[fileIdx].aggBufUsed;
+  void *restrict aggBuf = rxWin[fileIdx].aggBuf;
+  if (aggBufUsed + size > aggBufSize)
+    rxWin[fileIdx].aggBuf = aggBuf
+      = Realloc(aggBuf, (rxWin[fileIdx].aggBufSize = aggBufUsed + size));
+  memcpy((unsigned char *)aggBuf + aggBufUsed, ptr, size);
+  rxWin[fileIdx].aggBufUsed = aggBufUsed + size;
+  return size;
 }
 
-#ifdef HAVE_NETCDF4
 static void
-buildWrittenVars(struct streamMapping *mapping, int **varIsWritten_,
-                 int myCollRank, MPI_Comm collComm)
+aggBufFlush(size_t streamIdx,
+            size_t (*cdiPioFileWrite)(int, const void *restrict, size_t, int))
 {
-  int nvars = mapping->numVars;
-  int *varMap = mapping->varMap;
-  int *varIsWritten = *varIsWritten_
-    = xrealloc(*varIsWritten_, sizeof (*varIsWritten) * (size_t)nvars);
-  for (int varID = 0; varID < nvars; ++varID)
-    varIsWritten[varID] = ((varMap[varID] != -1)
-                           ?myCollRank+1 : 0);
-  xmpi(MPI_Allreduce(MPI_IN_PLACE, varIsWritten, nvars,
-                     MPI_INT, MPI_BOR, collComm));
+  int fileID = openFiles.entries[streamIdx];
+  int streamID = openStreams.entries[streamIdx];
+  cdiPioFileWrite(fileID, rxWin[streamIdx].aggBuf, rxWin[streamIdx].aggBufUsed,
+                  streamInqCurTimestepID(streamID));
+  rxWin[streamIdx].aggBufUsed = 0;
 }
-#endif
 
-static void readGetBuffers()
+static void
+writeGribStream(size_t streamIdx,
+                struct streamMapping *mapping,
+                double **data_, int *currentDataBufSize,
+                const struct cdiPioConf *conf)
 {
-  int nProcsModel = commInqNProcsModel ();
-  int root        = commInqRootGlob ();
-#ifdef HAVE_NETCDF4
-  int myCollRank = commInqRankColl();
+  const struct clientBuf *restrict clientBuf = rxWin[streamIdx].clientBuf;
+  int streamID = openStreams.entries[streamIdx];
+  int vlistID = streamInqVlist(streamID);
+  int fileID = streamInqFileID(streamID);
   MPI_Comm collComm = commInqCommColl();
-#endif
+  size_t collSize = (size_t)commInqSizeColl();
+  size_t collRank = (size_t)commInqRankColl();
+  struct passPlan (*passes)[collSize] = NULL;
+  size_t numPasses = planPasses(streamIdx, mapping, conf, collSize, &passes);
+  Xt_redist *varRedists = NULL;
+  struct recordWrite *restrict writtenRecords = mapping->writtenRecords;
+  size_t (*cdiPioFileWrite)(int fileID, const void *restrict buffer,
+                            size_t len, int tsID)
+    = (size_t (*)(int, const void *restrict, size_t, int))
+    namespaceSwitchGet(NSSWITCH_FILE_WRITE).func;
+  bool reuseRedists = conf->cacheRedists != 0
+    ? handleRedistCache(streamIdx, mapping, (size_t)numPasses, vlistID, collComm)
+    : false;
+  struct cacheRedist *restrict retained = rxWin[streamIdx].retained;
+  struct {
+    int varID;
+    unsigned recordStart, recordEnd;
+  } *varsInPass = NULL;
+  MPI_Aint *displ = NULL;
+  for (size_t pass = 0; pass < numPasses; ++pass)
+    {
+      unsigned base = passes[pass][0].recordAggStart;
+      size_t numRecordsInPass = passes[pass][collSize - 1].recordAggEnd
+        - base + 1;
+      size_t maxVarsInPass = (size_t)(passes[pass][collSize - 1].varEnd
+                                      - passes[pass][0].varStart + 1);
+      varsInPass
+        = Realloc(varsInPass, sizeof (*varsInPass)
+                   * szmin(numRecordsInPass, maxVarsInPass));
+      /* establish variables involved in this pass */
+      size_t numVarsInPass = 1;
+      varsInPass[0].recordStart = base;
+      int lastSeenVarID =
+        varsInPass[0].varID = writtenRecords[base].varID;
+      for (size_t i = 1; i < numRecordsInPass; ++i)
+        if (lastSeenVarID != writtenRecords[base + i].varID)
+          {
+            varsInPass[numVarsInPass - 1].recordEnd = (unsigned)(base + i - 1);
+            varsInPass[numVarsInPass].varID
+              = lastSeenVarID = writtenRecords[base + i].varID;
+            varsInPass[numVarsInPass].recordStart = (unsigned)(base + i);
+            ++numVarsInPass;
+          }
+      varsInPass[numVarsInPass - 1].recordEnd
+        = (unsigned)(base + numRecordsInPass - 1);
+      varRedists = Realloc(varRedists, numVarsInPass * sizeof (*varRedists));
+      size_t myRecordStart = passes[pass][collRank].recordAggStart,
+        myRecordEnd = passes[pass][collRank].recordAggEnd;
+      size_t myAggSize = 0;
+      /* build or fetch from cache redists for all variables involved in current write pass */
+      Xt_redist compositePassRedist;
+      if (reuseRedists)
+        {
+          compositePassRedist = retained[pass].redist;
+          myAggSize = (size_t)retained[pass].sliceSize;
+        }
+      else
+        {
+          int myVarStart = passes[pass][collRank].varStart,
+            myVarEnd = passes[pass][collRank].varEnd;
+          displ = Realloc(displ, sizeof (*displ) * (numVarsInPass * 2 + 1));
+          memset(displ, 0, sizeof (*displ) * (numVarsInPass + 1));
+          for (unsigned varIdx = 0; varIdx < numVarsInPass; ++varIdx)
+            {
+              int varID = varsInPass[varIdx].varID;
+              Xt_idxlist dstList;
+              /* is this process writing part of this variable? */
+              if (myRecordStart <= myRecordEnd
+                  && myVarStart <= varID && myVarEnd >= varID)
+                {
+                  size_t myVarRecordStart
+                    = writtenRecords[myRecordStart].varID == varID
+                    ? myRecordStart : varsInPass[varIdx].recordStart;
+                  size_t myLevelStart
+                    = (size_t)writtenRecords[myVarRecordStart].level;
+                  size_t myVarRecordEnd
+                    = writtenRecords[myRecordEnd].varID == varID
+                    ? myRecordEnd : (size_t)varsInPass[varIdx].recordEnd;
+                  size_t myNumLevels
+                    = (size_t)writtenRecords[myVarRecordEnd].level
+                    - myLevelStart + 1;
+                  dstList
+                    = buildVarSlicesIdxList(vlistID, varID, (int)myLevelStart,
+                                            (int)myNumLevels);
+                  size_t sliceSize = (size_t)xt_idxlist_get_num_indices(dstList);
+                  assert(sliceSize * sizeof (double)
+                         == (writtenRecords[myVarRecordStart].dataSize
+                             * myNumLevels));
+                  myAggSize += sliceSize;
+                }
+              else
+                {
+                  dstList = xt_idxempty_new();
+                }
+              displ[numVarsInPass + varIdx + 1]
+                = (MPI_Aint)(sizeof (double) * myAggSize);
+              varRedists[varIdx] = buildVarRedist(mapping->varMap[varID],
+                                                  streamIdx, dstList, conf);
+              xt_idxlist_delete(dstList);
+            }
+          /* merge all redists for current pass */
+          if (numVarsInPass > 1)
+            {
+              compositePassRedist
+                = xt_redist_collection_static_new(varRedists,
+                                                  (int)numVarsInPass,
+                                                  displ, displ + numVarsInPass,
+                                                  collComm);
+              /* free individual redists */
+              for (size_t varIdx = 0; varIdx < numVarsInPass; ++varIdx)
+                xt_redist_delete(varRedists[varIdx]);
+            }
+          else
+            compositePassRedist = varRedists[0];
+          if (conf->cacheRedists)
+            {
+              retained[pass].redist = compositePassRedist;
+              retained[pass].sliceSize = (int)myAggSize;
+            }
+        }
+      /* resize gather buffer if needed */
+      resizeVarGatherBuf((int)myAggSize, data_, currentDataBufSize);
+      /* execute composite redist */
+      xt_redist_s_exchange1(compositePassRedist, clientBuf[0].mem, *data_);
+      /* delete composite redist */
+      if (!conf->cacheRedists)
+        xt_redist_delete(compositePassRedist);
+
+      /* append encoded data records from this pass to buffer written later */
+      /* todo: develop better heuristic for buffer size */
+      if (sizeof (double) * myAggSize > rxWin[streamIdx].aggBufSize)
+        {
+          Free(rxWin[streamIdx].aggBuf);
+          size_t aggBufSize = szmax((size_t)conf->recordAggBufLimMB
+                                    * (size_t)1024 * (size_t)1024,
+                                    sizeof (double) * myAggSize);
+          if (posix_memalign(&rxWin[streamIdx].aggBuf,
+                             cdiPioGetPageSize(conf->largePageAlign),
+                             aggBufSize) == 0) ;
+          else
+            rxWin[streamIdx].aggBuf = Malloc(aggBufSize);
+        }
+      namespaceSwitchSet(NSSWITCH_FILE_WRITE, NSSW_FUNC(aggBufAppend));
+      /* write records to aggregation buffer */
+      if (myRecordStart <= myRecordEnd)
+      {
+        size_t varIdx = (size_t)-1;
+        int varID = -1;
+        size_t base = 0;
+        const double *data = *data_;
+        for (size_t recordIdx = myRecordStart;
+             recordIdx <= myRecordEnd;
+             ++recordIdx)
+          {
+            int level = writtenRecords[recordIdx].level;
+            int prevVarID = varID;
+            varID = writtenRecords[recordIdx].varID;
+            varIdx += varID != prevVarID;
+            size_t recordSize = writtenRecords[recordIdx].dataSize;
+            size_t nvals = recordSize / sizeof (double);
+            int nmiss
+              = countVarChunkMissingVals(vlistID, varID, mapping, (int)nvals,
+                                         data + base);
+            streamWriteVarSlice(streamID, varID, level, data + base, nmiss);
+            base += nvals;
+          }
+        aggBufFlush(streamIdx, cdiPioFileWrite);
+      }
+      else
+        /* write zero bytes to trigger synchronization code in fileWrite */
+        cdiPioFileWrite(fileID, NULL, 0,
+                        streamInqCurTimestepID(streamID));
+      namespaceSwitchSet(NSSWITCH_FILE_WRITE, NSSW_FUNC(cdiPioFileWrite));
+    }
+  Free(displ);
+  Free(varRedists);
+  Free(varsInPass);
+  Free(passes);
+}
+
+static void
+readGetBuffers(size_t streamIdx, const struct cdiPioConf *conf)
+{
+  int streamID = openStreams.entries[streamIdx];
   xdebug("%s", "START");
 
   struct winHeaderEntry *winDict
-    = (struct winHeaderEntry *)rxWin[root].buffer;
+    = (struct winHeaderEntry *)rxWin[streamIdx].clientBuf[0].mem;
   xassert(winDict[0].id == HEADERSIZEMARKER);
   {
-    int dictSize = rxWin[root].dictSize,
+    int dictSize = rxWin[streamIdx].clientBuf[0].dictSize,
       firstNonRPCEntry = dictSize - winDict[0].specific.headerSize.numRPCEntries - 1,
       headerIdx,
       numFuncCalls = 0;
@@ -680,305 +1116,108 @@ static void readGetBuffers()
         xassert(winDict[headerIdx].id >= MINFUNCID
                 && winDict[headerIdx].id <= MAXFUNCID);
         ++numFuncCalls;
-        readFuncCall(winDict + headerIdx);
+        readFuncCall(winDict + headerIdx, streamIdx);
       }
     xassert(numFuncCalls == winDict[0].specific.headerSize.numRPCEntries);
   }
   /* build list of streams, data was transferred for */
   {
-    struct streamMap map = buildStreamMap(winDict);
+    struct streamMapping *map = streamMappingNew(streamIdx, winDict, conf);
+    /* TODO: build list of rma buffer layout here to check if caching
+     * can be done */
     double *data = NULL;
-#ifdef HAVE_NETCDF4
-    int *varIsWritten = NULL;
-#endif
-#if defined (HAVE_PARALLEL_NC4)
-    double *writeBuf = NULL;
-#endif
     int currentDataBufSize = 0;
-    for (int streamIdx = 0; streamIdx < map.numEntries; ++streamIdx)
-      {
-        int streamID = map.entries[streamIdx].streamID;
-        int vlistID = streamInqVlist(streamID);
-        int filetype = map.entries[streamIdx].filetype;
+    int filetype = streamInqFiletype(streamID);
 
-        switch (filetype)
-          {
-          case FILETYPE_GRB:
-          case FILETYPE_GRB2:
-            writeGribStream(winDict, map.entries + streamIdx,
-                            &data, &currentDataBufSize,
-                            root, nProcsModel);
-            break;
+    switch (filetype)
+      {
+      case FILETYPE_GRB:
+      case FILETYPE_GRB2:
+        writeGribStream(streamIdx, map, &data, &currentDataBufSize, conf);
+        break;
 #ifdef HAVE_NETCDF4
-          case FILETYPE_NC:
-          case FILETYPE_NC2:
-          case FILETYPE_NC4:
-#ifdef HAVE_PARALLEL_NC4
-            /* HAVE_PARALLE_NC4 implies having ScalES-PPM and yaxt */
-            {
-              int nvars = map.entries[streamIdx].numVars;
-              int *varMap = map.entries[streamIdx].varMap;
-              buildWrittenVars(map.entries + streamIdx, &varIsWritten,
-                               myCollRank, collComm);
-              for (int varID = 0; varID < nvars; ++varID)
-                if (varIsWritten[varID])
-                  {
-                    struct PPM_extent varShape[3];
-                    queryVarBounds(varShape, vlistID, varID);
-                    struct xyzDims collGrid = varDimsCollGridMatch(varShape);
-                    xdebug("writing varID %d with dimensions: "
-                           "x=%d, y=%d, z=%d,\n"
-                           "found distribution with dimensions:"
-                           " x=%d, y=%d, z=%d.", varID,
-                           varShape[0].size, varShape[1].size, varShape[2].size,
-                           collGrid.sizes[0], collGrid.sizes[1],
-                           collGrid.sizes[2]);
-                    struct PPM_extent varChunk[3];
-                    myVarPart(varShape, collGrid, varChunk);
-                    int myChunk[3][2];
-                    for (int i = 0; i < 3; ++i)
-                      {
-                        myChunk[i][0] = PPM_extent_start(varChunk[i]);
-                        myChunk[i][1] = PPM_extent_end(varChunk[i]);
-                      }
-                    xdebug("Writing chunk { { %d, %d }, { %d, %d },"
-                           " { %d, %d } }", myChunk[0][0], myChunk[0][1],
-                           myChunk[1][0], myChunk[1][1], myChunk[2][0],
-                           myChunk[2][1]);
-                    Xt_int varSize[3];
-                    for (int i = 0; i < 3; ++i)
-                      varSize[2 - i] = varShape[i].size;
-                    Xt_idxlist preRedistChunk, preWriteChunk;
-                    /* prepare yaxt descriptor for current data
-                       distribution after collect */
-                    int nmiss;
-                    if (varMap[varID] == -1)
-                      {
-                        preRedistChunk = xt_idxempty_new();
-                        xdebug("%s", "I got none\n");
-                      }
-                    else
-                      {
-                        Xt_int preRedistStart[3] = { 0, 0, 0 };
-                        preRedistChunk
-                          = xt_idxsection_new(0, 3, varSize, varSize,
-                                              preRedistStart);
-                        resizeVarGatherBuf(vlistID, varID, &data,
-                                           &currentDataBufSize);
-                        int headerIdx = varMap[varID];
-                        gatherArray(root, nProcsModel, headerIdx,
-                                    vlistID, data, &nmiss);
-                        xdebug("%s", "I got all\n");
-                      }
-                    MPI_Bcast(&nmiss, 1, MPI_INT, varIsWritten[varID] - 1,
-                              collComm);
-                    /* prepare yaxt descriptor for write chunk */
-                    {
-                      Xt_int preWriteChunkStart[3], preWriteChunkSize[3];
-                      for (int i = 0; i < 3; ++i)
-                        {
-                          preWriteChunkStart[2 - i] = varChunk[i].first;
-                          preWriteChunkSize[2 - i] = varChunk[i].size;
-                        }
-                      preWriteChunk = xt_idxsection_new(0, 3, varSize,
-                                                        preWriteChunkSize,
-                                                        preWriteChunkStart);
-                    }
-                    /* prepare redistribution */
-                    {
-                      Xt_xmap xmap = xt_xmap_all2all_new(preRedistChunk,
-                                                         preWriteChunk,
-                                                         collComm);
-                      Xt_redist redist = xt_redist_p2p_new(xmap, MPI_DOUBLE);
-                      xt_idxlist_delete(preRedistChunk);
-                      xt_idxlist_delete(preWriteChunk);
-                      xt_xmap_delete(xmap);
-                      writeBuf = (double*) xrealloc(writeBuf,
-                                                    sizeof (double)
-                                                    * PPM_extents_size(3, varChunk));
-                      xt_redist_s_exchange1(redist, data, writeBuf);
-                      xt_redist_delete(redist);
-                    }
-                    /* write chunk */
-                    streamWriteVarChunk(streamID, varID,
-                                        (const int (*)[2])myChunk, writeBuf,
-                                        nmiss);
-                  }
-            }
-#else
-            /* determine process which has stream open (writer) and
-             * which has data for which variable (var owner)
-             * three cases need to be distinguished */
-            {
-              int nvars = map.entries[streamIdx].numVars;
-              int *varMap = map.entries[streamIdx].varMap;
-              buildWrittenVars(map.entries + streamIdx, &varIsWritten,
-                               myCollRank, collComm);
-              int writerRank;
-              if ((writerRank = cdiPioSerialOpenFileMap(streamID))
-                  == myCollRank)
-                {
-                  for (int varID = 0; varID < nvars; ++varID)
-                    if (varIsWritten[varID])
-                      {
-                        int nmiss;
-                        int size = vlistInqVarSize(vlistID, varID);
-                        resizeVarGatherBuf(vlistID, varID, &data,
-                                           &currentDataBufSize);
-                        int headerIdx = varMap[varID];
-                        if (varIsWritten[varID] == myCollRank + 1)
-                          {
-                            /* this process has the full array and will
-                             * write it */
-                            xdebug("gathering varID=%d for direct writing",
-                                   varID);
-                            gatherArray(root, nProcsModel, headerIdx,
-                                        vlistID, data, &nmiss);
-                          }
-                        else
-                          {
-                            /* another process has the array and will
-                             * send it over */
-                            MPI_Status stat;
-                            xdebug("receiving varID=%d for writing from"
-                                   " process %d",
-                                   varID, varIsWritten[varID] - 1);
-                            xmpiStat(MPI_Recv(&nmiss, 1, MPI_INT,
-                                              varIsWritten[varID] - 1,
-                                              COLLBUFNMISS,
-                                              collComm, &stat), &stat);
-                            xmpiStat(MPI_Recv(data, size, MPI_DOUBLE,
-                                              varIsWritten[varID] - 1,
-                                              COLLBUFTX,
-                                              collComm, &stat), &stat);
-                          }
-                        streamWriteVar(streamID, varID, data, nmiss);
-                      }
-                }
-              else
-                for (int varID = 0; varID < nvars; ++varID)
-                  if (varIsWritten[varID] == myCollRank + 1)
-                    {
-                      /* this process has the full array and another
-                       * will write it */
-                      int nmiss;
-                      int size = vlistInqVarSize(vlistID, varID);
-                      resizeVarGatherBuf(vlistID, varID, &data,
-                                         &currentDataBufSize);
-                      int headerIdx = varMap[varID];
-                      gatherArray(root, nProcsModel, headerIdx,
-                                  vlistID, data, &nmiss);
-                      MPI_Request req;
-                      MPI_Status stat;
-                      xdebug("sending varID=%d for writing to"
-                             " process %d",
-                             varID, writerRank);
-                      xmpi(MPI_Isend(&nmiss, 1, MPI_INT,
-                                     writerRank, COLLBUFNMISS,
-                                     collComm, &req));
-                      xmpi(MPI_Send(data, size, MPI_DOUBLE,
-                                    writerRank, COLLBUFTX,
-                                    collComm));
-                      xmpiStat(MPI_Wait(&req, &stat), &stat);
-                    }
-            }
-#endif
-            break;
+      case FILETYPE_NC:
+      case FILETYPE_NC2:
+      case FILETYPE_NC4:
+        writeNetCDFStream(streamIdx, map, &data, &currentDataBufSize, conf);
+        break;
 #endif
-          default:
-            xabort("unhandled filetype in parallel I/O.");
-          }
+      default:
+        xabort("unhandled filetype in parallel I/O.");
       }
-#ifdef HAVE_NETCDF4
-    free(varIsWritten);
-#ifdef HAVE_PARALLEL_NC4
-    free(writeBuf);
-#endif
-#endif
-    free(map.entries);
-    free(data);
+    streamMappingDelete(&map);
+    Free(map);
+    Free(data);
   }
   xdebug("%s", "RETURN");
-} 
+}
 
 /************************************************************************/
 
 
 static
-void clearModelWinBuffer(int modelID)
+void clearModelWinBuffer(size_t streamIdx)
 {
-  int nProcsModel = commInqNProcsModel ();
-
-  xassert((unsigned)modelID < (unsigned)nProcsModel &&
-          rxWin != NULL && rxWin[modelID].buffer != NULL &&
-          rxWin[modelID].size > 0 &&
-          rxWin[modelID].size <= MAXWINBUFFERSIZE );
-  memset(rxWin[modelID].buffer, 0, rxWin[modelID].size);
+  xassert(streamIdx < openStreams.size &&
+          rxWin != NULL && rxWin[streamIdx].clientBuf[0].mem != NULL);
+  size_t bufSizeTotal = (size_t)(rxWin[streamIdx].clientBuf[numClients_ - 1].mem
+                                 - rxWin[streamIdx].clientBuf[0].mem)
+    + rxWin[streamIdx].clientBuf[numClients_ - 1].size;
+  memset(rxWin[streamIdx].clientBuf[0].mem, 0, bufSizeTotal);
 }
 
 
 /************************************************************************/
 
 
-static
-void getTimeStepData()
+static void
+getTimeStepData(int *streamActivity, const struct cdiPioConf *conf)
 {
-  int modelID;
-  char text[1024];
-  int nProcsModel = commInqNProcsModel ();
-  void *getWinBaseAddr;
-  int attrFound;
+  MPI_Group clientGroup = cdiPioInqRemoteGroup();
 
   xdebug("%s", "START");
 
-  for ( modelID = 0; modelID < nProcsModel; modelID++ )
-    clearModelWinBuffer(modelID);
-  // todo put in correct lbs and ubs
-  xmpi(MPI_Win_start(groupModel, 0, getWin));
-  xmpi(MPI_Win_get_attr(getWin, MPI_WIN_BASE, &getWinBaseAddr, &attrFound));
-  xassert(attrFound);
-  for ( modelID = 0; modelID < nProcsModel; modelID++ )
-    {
-      xdebug("modelID=%d, nProcsModel=%d, rxWin[%d].size=%zu,"
-             " getWin=%p, sizeof(int)=%u",
-             modelID, nProcsModel, modelID, rxWin[modelID].size,
-             getWinBaseAddr, (unsigned)sizeof(int));
-      /* FIXME: this needs to use MPI_PACK for portability */
-      xmpi(MPI_Get(rxWin[modelID].buffer, (int)rxWin[modelID].size,
-                   MPI_UNSIGNED_CHAR, modelID, 0,
-                   (int)rxWin[modelID].size, MPI_UNSIGNED_CHAR, getWin));
-    }
-  xmpi ( MPI_Win_complete ( getWin ));
-
-  if ( ddebug > 2 )
-    for ( modelID = 0; modelID < nProcsModel; modelID++ )
+  for (size_t streamIdx = 0; streamIdx < openStreams.size; ++streamIdx)
+    if (streamActivity[streamIdx])
       {
-        sprintf(text, "rxWin[%d].size=%zu from PE%d rxWin[%d].buffer",
-                modelID, rxWin[modelID].size, modelID, modelID);
-        xprintArray(text, rxWin[modelID].buffer,
-                    (int)(rxWin[modelID].size / sizeof (double)),
-                    DATATYPE_FLT);
+        clearModelWinBuffer(streamIdx);
+        // todo put in correct lbs and ubs
+        xmpi(MPI_Win_start(clientGroup, 0, rxWin[streamIdx].getWin));
+        /* FIXME: this needs to use MPI_PACKED for portability */
+        for (size_t i = 0; i < (size_t)numClients_; ++i)
+          xmpi(MPI_Get(rxWin[streamIdx].clientBuf[i].mem,
+                       (int)rxWin[streamIdx].clientBuf[i].size, MPI_UNSIGNED_CHAR,
+                       clientRanks_[i], 0,
+                       (int)rxWin[streamIdx].clientBuf[i].size, MPI_UNSIGNED_CHAR,
+                       rxWin[streamIdx].getWin));
+        xmpi(MPI_Win_complete(rxWin[streamIdx].getWin));
       }
-  readGetBuffers();
+
+  for (size_t streamIdx = 0; streamIdx < openStreams.size; ++streamIdx)
+    if (streamActivity[streamIdx])
+      readGetBuffers(streamIdx, conf);
 
   xdebug("%s", "RETURN");
 }
 
 /************************************************************************/
 
-#if defined (HAVE_LIBNETCDF) && ! defined (HAVE_PARALLEL_NC4)
 static int
-cdiPioStreamCDFOpenWrap(const char *filename, const char *filemode,
-                        int filetype, stream_t *streamptr,
-                        int recordBufIsToBeCreated)
+cdiPioServerStreamOpen(const char *filename, char filemode,
+                       int filetype, stream_t *streamptr,
+                       int recordBufIsToBeCreated)
 {
+  int fileID;
+#if defined HAVE_LIBNETCDF && ! defined HAVE_PARALLEL_NC4
+  /* Only needs initialization to shut up gcc */
+  int rank = -1;
+#endif
   switch (filetype)
     {
+#if defined HAVE_LIBNETCDF && ! defined HAVE_PARALLEL_NC4
     case FILETYPE_NC4:
     case FILETYPE_NC4C:
       {
-        /* Only needs initialization to shut up gcc */
-        int rank = -1, fileID;
         int ioMode = commInqIOMode();
         if (ioMode == PIO_NONE
             || commInqRankColl() == (rank = cdiPioNextOpenRank()))
@@ -989,43 +1228,88 @@ cdiPioStreamCDFOpenWrap(const char *filename, const char *filemode,
           streamptr->filetype = filetype;
         if (ioMode != PIO_NONE)
           xmpi(MPI_Bcast(&fileID, 1, MPI_INT, rank, commInqCommColl()));
-        streamptr->ownerRank = rank;
         cdiPioOpenFileOnRank(rank);
-        return fileID;
       }
+      break;
+#endif
     default:
-      return cdiStreamOpenDefaultDelegate(filename, filemode, filetype,
-                                          streamptr, recordBufIsToBeCreated);
+      fileID = cdiStreamOpenDefaultDelegate(filename, filemode, filetype,
+                                            streamptr, recordBufIsToBeCreated);
+    }
+  if (fileID >= 0)
+    {
+      size_t oldNumStreams = openStreams.size;
+      size_t streamIdx = insertID(&openStreams, streamptr->self);
+      size_t fileIdx = insertID(&openFiles, fileID);
+      xassert(fileIdx == streamIdx);
+      size_t numStreams = openStreams.size;
+      struct clientBuf *oldClientBufs = rxWin ? rxWin[0].clientBuf : NULL;
+      rxWin = Realloc(rxWin, numStreams * sizeof (rxWin[0]));
+      struct clientBuf *restrict newClientBufs
+        = Realloc(oldClientBufs, sizeof (rxWin[0].clientBuf[0])
+                   * (size_t)numClients_ * numStreams);
+      if (newClientBufs != oldClientBufs)
+        for (size_t i = 0; i < numStreams; ++i)
+          rxWin[i].clientBuf = newClientBufs + i * (size_t)numClients_;
+      else if (oldNumStreams < numStreams)
+        for (size_t i = oldNumStreams; i < numStreams; ++i)
+          rxWin[i].clientBuf = newClientBufs + i * (size_t)numClients_;
+      rxWin[streamIdx].getWin = MPI_WIN_NULL;
+      rxWin[streamIdx].prevLayout = NULL;
+      rxWin[streamIdx].retained = NULL;
+      rxWin[streamIdx].numRetained = 0;
+      rxWin[streamIdx].aggBufSize = 0;
+      rxWin[streamIdx].aggBufUsed = 0;
+      rxWin[streamIdx].aggBuf = NULL;
+#if defined HAVE_LIBNETCDF && ! defined HAVE_PARALLEL_NC4
+      rxWin[streamIdx].ownerRank = rank;
+#endif
     }
+  return fileID;
 }
 
 static void
-cdiPioStreamCDFCloseWrap(stream_t *streamptr, int recordBufIsToBeDeleted)
+cdiPioServerStreamClose(stream_t *streamptr, int recordBufIsToBeDeleted)
 {
   int fileID   = streamptr->fileID;
   int filetype = streamptr->filetype;
   if ( fileID == CDI_UNDEFID )
     Warning("File %s not open!", streamptr->filename);
   else
-    switch (filetype)
-      {
-      case FILETYPE_NC:
-      case FILETYPE_NC2:
-      case FILETYPE_NC4:
-      case FILETYPE_NC4C:
+    {
+      switch (filetype)
         {
-          int rank, rankOpen = cdiPioSerialOpenFileMap(streamptr->self);
-          if (commInqIOMode() == PIO_NONE
-              || ((rank = commInqRankColl()) == rankOpen))
-            cdiStreamCloseDefaultDelegate(streamptr, recordBufIsToBeDeleted);
-          cdiPioCloseFileOnRank(rankOpen);
+#if defined (HAVE_LIBNETCDF) && ! defined (HAVE_PARALLEL_NC4)
+        case FILETYPE_NC:
+        case FILETYPE_NC2:
+        case FILETYPE_NC4:
+        case FILETYPE_NC4C:
+          {
+            int rank, rankOpen = cdiPioSerialOpenFileMap(streamptr->self);
+            if (commInqIOMode() == PIO_NONE
+                || ((rank = commInqRankColl()) == rankOpen))
+              cdiStreamCloseDefaultDelegate(streamptr, recordBufIsToBeDeleted);
+            cdiPioCloseFileOnRank(rankOpen);
+          }
           break;
+#endif
+        default:
+          cdiStreamCloseDefaultDelegate(streamptr, recordBufIsToBeDeleted);
         }
-      default:
-        cdiStreamCloseDefaultDelegate(streamptr, recordBufIsToBeDeleted);
-      }
+      int streamID = streamptr->self;
+      size_t streamIdx = indexOfID(&openStreams, streamID);
+      destructRetained(rxWin[streamIdx].retained,
+                       rxWin[streamIdx].numRetained);
+      Free(rxWin[streamIdx].retained);
+      Free(rxWin[streamIdx].prevLayout);
+      Free(rxWin[streamIdx].aggBuf);
+      cdiPioServerStreamWinDestroy(streamIdx);
+      removeID(&openStreams, streamID);
+      removeID(&openFiles, fileID);
+    }
 }
 
+#if defined (HAVE_LIBNETCDF) && ! defined (HAVE_PARALLEL_NC4)
 static void
 cdiPioCdfDefTimestep(stream_t *streamptr, int tsID)
 {
@@ -1035,127 +1319,187 @@ cdiPioCdfDefTimestep(stream_t *streamptr, int tsID)
           == (rankOpen = cdiPioSerialOpenFileMap(streamID))))
     cdfDefTimestep(streamptr, tsID);
 }
-
 #endif
 
-/**
-  @brief is encapsulated in CDI library and run on I/O PEs.
+static void
+cdiPioRecvStreamOpen(void *buffer, int size, int *pos, MPI_Comm pioInterComm)
+{
+  int clientStreamID, filetype, fname_len;
+  {
+    int soHdr[3];
+    xmpi(MPI_Unpack(buffer, size, pos,
+                    soHdr, 3, MPI_INT, pioInterComm));
+    clientStreamID = soHdr[0];
+    filetype = soHdr[1];
+    fname_len = soHdr[2];
+  }
+  char filemode;
+  xmpi(MPI_Unpack(buffer, size, pos,
+                  &filemode, 1, MPI_CHAR, pioInterComm));
+  MPI_Request *requests = Malloc((size_t)numClients_ * sizeof (requests[0])
+                                  + (size_t)fname_len + 1);
+  char *filename = (char *)((unsigned char *)requests
+                            + (size_t)numClients_ * sizeof (requests[0]));
+  xmpi(MPI_Unpack(buffer, size, pos,
+                  filename, fname_len, MPI_CHAR, pioInterComm));
+  filename[fname_len] = '\0';
+  xassert(filemode == 'w');
+  int serverStreamID = namespaceAdaptKey2(clientStreamID);
+  int curStatus = reshGetStatus(serverStreamID, &streamOps);
+  xassert(!(curStatus & RESH_IN_USE_BIT));
+  int streamID = streamOpenID(filename, filemode, filetype, serverStreamID);
+  int fileID = (streamID >= 0) ? streamInqFileID(streamID) : streamID;
+  for (size_t i = 0; i < (size_t)numClients_; ++i)
+    xmpi(MPI_Isend(&fileID, 1, MPI_INT, clientRanks_[i], STREAMOPEN,
+                   pioInterComm, requests + i));
+  xmpi(MPI_Waitall(numClients_, requests, MPI_STATUSES_IGNORE));
+  Free(requests);
+}
 
-  @param
+static void
+cdiPioRecvStreamClose(void *buffer, int size, int *pos, MPI_Comm pioInterComm)
+{
+  int clientStreamID;
+  xmpi(MPI_Unpack(buffer, size, pos,
+                  &clientStreamID, 1, MPI_INT, pioInterComm));
+  int serverStreamID = namespaceAdaptKey2(clientStreamID);
+  streamClose(serverStreamID);
+}
 
-  @return
-*/
+static void
+cdiPioRecvStreamDefVlist(void *buffer, int size, int *pos,
+                         MPI_Comm pioInterComm)
+{
+  int serverStreamID, serverVlistID;
+  {
+    int msgData[defVlistNInts];
+    xmpi(MPI_Unpack(buffer, size, pos,
+                    &msgData, defVlistNInts, MPI_INT, pioInterComm));
+    serverStreamID = namespaceAdaptKey2(msgData[0]);
+    serverVlistID = namespaceAdaptKey2(msgData[1]);
+  }
+  cdiStreamSetupVlist(stream_to_pointer(serverStreamID), serverVlistID);
+  MPI_Info no_locks_info;
+  xmpi(MPI_Info_create(&no_locks_info));
+  xmpi(MPI_Info_set(no_locks_info, "no_locks", "true"));
+  size_t streamIdx = indexOfID(&openStreams, serverStreamID);
+  int numClients = cdiPioCommInqSizeClients(),
+    numColl = commInqSizeColl();
+  struct collSpec collectorData = {
+    .numClients = numClients,
+    .numServers = numColl,
+    .sendRPCData = 1,
+  };
+  struct clientBufSize bufSizes[numClients_];
+  bufSizes[0] = computeClientStreamBufSize(serverStreamID, &collectorData);
+  collectorData.sendRPCData = 0;
+  for (size_t i = 1; i < (size_t)numClients_; ++i)
+    bufSizes[i] = computeClientStreamBufSize(serverStreamID, &collectorData);
+  cdiPioServerStreamWinCreate(streamIdx, no_locks_info,
+                              cdiPioInqCollClientIntraComm(), bufSizes);
+  xmpi(MPI_Info_free(&no_locks_info));
+
+}
 
-void cdiPioServer(void (*postCommSetupActions)(void))
+
+/**
+ * @brief is encapsulated in CDI library and run on I/O PEs.
+ */
+
+void cdiPioCollectorMessageLoop(const struct cdiPioConf *conf)
 {
-  int nProcsModel=commInqNProcsModel();
-  static int nfinished = 0;
-  MPI_Comm commCalc;
   MPI_Status status;
 
   xdebug("%s", "START");
 
-  cdiPioFileWritingInit(postCommSetupActions);
-  if (commInqRankNode() == commInqSpecialRankNode())
-    return;
-  commCalc = commInqCommCalc ();
+  MPI_Comm pioInterComm = cdiPioInqInterComm();
+  namespaceSwitchSet(NSSWITCH_STREAM_OPEN_BACKEND,
+                     NSSW_FUNC(cdiPioServerStreamOpen));
+  namespaceSwitchSet(NSSWITCH_STREAM_CLOSE_BACKEND,
+                     NSSW_FUNC(cdiPioServerStreamClose));
 #ifdef HAVE_PARALLEL_NC4
   cdiPioEnableNetCDFParAccess();
   numPioPrimes = PPM_prime_factorization_32((uint32_t)commInqSizeColl(),
                                             &pioPrimes);
 #elif defined (HAVE_LIBNETCDF)
-  cdiSerialOpenFileCount = xcalloc(sizeof (cdiSerialOpenFileCount[0]),
+  cdiSerialOpenFileCount = Calloc(sizeof (cdiSerialOpenFileCount[0]),
                                    (size_t)commInqSizeColl());
-  namespaceSwitchSet(NSSWITCH_STREAM_OPEN_BACKEND,
-                     NSSW_FUNC(cdiPioStreamCDFOpenWrap));
-  namespaceSwitchSet(NSSWITCH_STREAM_CLOSE_BACKEND,
-                     NSSW_FUNC(cdiPioStreamCDFCloseWrap));
   namespaceSwitchSet(NSSWITCH_CDF_DEF_TIMESTEP,
                      NSSW_FUNC(cdiPioCdfDefTimestep));
   namespaceSwitchSet(NSSWITCH_CDF_STREAM_SETUP,
                      NSSW_FUNC(cdiPioServerCdfDefVars));
 #endif
-  namespaceSwitchSet(NSSWITCH_FILE_WRITE,
-                     NSSW_FUNC(cdiPioFileWrite));
 
+  int *streamActivity = NULL;
+  setupClientRanks();
   for ( ;; )
     {
-      xmpi ( MPI_Probe ( MPI_ANY_SOURCE, MPI_ANY_TAG, commCalc, &status ));
-      
+      xmpi ( MPI_Probe ( MPI_ANY_SOURCE, MPI_ANY_TAG, pioInterComm, &status ));
+
       int source = status.MPI_SOURCE;
       int tag = status.MPI_TAG;
-      
+
       switch ( tag )
         {
         case FINALIZE:
-          xdebugMsg(tag, source, nfinished);
-          xmpi(MPI_Recv(NULL, 0, MPI_INT, source, tag, commCalc, &status));
-          xdebug("%s", "RECEIVED MESSAGE WITH TAG \"FINALIZE\"");
-          nfinished++;
-          xdebug("nfinished=%d, nProcsModel=%d", nfinished, nProcsModel);
-          if ( nfinished == nProcsModel )
+          xmpi(MPI_Recv(NULL, 0, MPI_INT, source, tag, pioInterComm, &status));
+          for (size_t streamIdx = 0; streamIdx < openStreams.size; ++streamIdx)
             {
-              {
-                unsigned nStreams = reshCountType(&streamOps);
-
-                if ( nStreams > 0 )
-                  {
-                    int *resHs = xmalloc(nStreams * sizeof (resHs[0]));
-                    cdiStreamGetIndexList(nStreams, resHs);
-                    for (unsigned streamNo = 0; streamNo < nStreams; ++streamNo)
-                      streamClose(resHs[streamNo]);
-                    free(resHs);
-                  }
-              }
-              cdiPioFileWritingFinalize();
-              serverWinCleanup();
+              int streamID = openStreams.entries[streamIdx];
+              if (streamID != CDI_UNDEFID)
+                streamClose(streamID);
+            }
+          if (rxWin)
+            {
+              Free(rxWin[0].clientBuf);
+              Free(rxWin);
+            }
+          idSetDestroy(&openStreams);
+          idSetDestroy(&openFiles);
+          Free(streamActivity);
+          Free(clientRanks_);
 #ifdef HAVE_PARALLEL_NC4
-              free(pioPrimes);
+          Free(pioPrimes);
+#elif defined (HAVE_LIBNETCDF)
+          Free(cdiSerialOpenFileCount);
 #endif
-              /* listDestroy(); */
-              xdebug("%s", "RETURN");
-              return;
-            }
-	  
-          break;
-          
+          xdebug("%s", "RETURN");
+          return;
+        case STREAMOPEN:
+        case STREAMCLOSE:
+        case STREAMDEFVLIST:
 	case RESOURCES:
           {
             int size;
-            xdebugMsg(tag, source, nfinished);
-            xmpi(MPI_Get_count(&status, MPI_CHAR, &size));
-            char *buffer = xmalloc((size_t)size);
+            xmpi(MPI_Get_count(&status, MPI_PACKED, &size));
+            char *buffer = Malloc((size_t)size);
             xmpi(MPI_Recv(buffer, size, MPI_PACKED, source,
-                          tag, commCalc, &status));
-            xdebug("%s", "RECEIVED MESSAGE WITH TAG \"RESOURCES\"");
-            reshUnpackResources(buffer, size, &commCalc);
-            xdebug("%s", "");
-            free(buffer);
-            int rankGlob = commInqRankGlob();
-            if ( ddebug > 0 && rankGlob == nProcsModel)
+                          tag, pioInterComm, &status));
+            int pos = reshUnpackResources(buffer, size, &pioInterComm);
+            switch (tag)
               {
-                static const char baseName[] = "reshListIOServer.",
-                  suffix[] = ".txt";
-                /* 9 digits for rank at most */
-                char buf[sizeof (baseName) + 9 + sizeof (suffix) + 1];
-                snprintf(buf, sizeof (buf), "%s%d%s", baseName, rankGlob,
-                         suffix);
-                FILE *fp = fopen(buf, "w");
-                xassert(fp);
-                reshListPrint(fp);
-                fclose(fp);
+              case STREAMOPEN:
+                cdiPioRecvStreamOpen(buffer, size, &pos, pioInterComm);
+                break;
+              case STREAMCLOSE:
+                cdiPioRecvStreamClose(buffer, size, &pos, pioInterComm);
+                break;
+              case STREAMDEFVLIST:
+                cdiPioRecvStreamDefVlist(buffer, size, &pos, pioInterComm);
+                break;
               }
+            Free(buffer);
+            streamActivity = Realloc(streamActivity, openStreams.size
+                                     * sizeof (streamActivity[0]));
           }
-          serverWinCreate ();
-	  break;
+          break;
 	case WRITETS:
           {
-            xdebugMsg(tag, source, nfinished);
-            xmpi(MPI_Recv(NULL, 0, MPI_INT, source,
-                          tag, commCalc, &status));
+            xmpi(MPI_Recv(streamActivity, (int)openStreams.size,
+                          MPI_INT, source, tag, pioInterComm, &status));
             xdebug("RECEIVED MESSAGE WITH TAG \"WRITETS\": source=%d",
                    source);
-            getTimeStepData();
+            getTimeStepData(streamActivity, conf);
           }
 	  break;
 
diff --git a/libcdi/src/pio_server.h b/libcdi/src/pio_server.h
index 2adcba2..2d1029f 100644
--- a/libcdi/src/pio_server.h
+++ b/libcdi/src/pio_server.h
@@ -7,7 +7,9 @@
 
 #include <mpi.h>
 
-void cdiPioServer(void (*postCommSetupActions)(void));
+#include "pio_conf.h"
+
+void cdiPioCollectorMessageLoop(const struct cdiPioConf *conf);
 
 #endif
 /*
diff --git a/libcdi/src/pio_util.c b/libcdi/src/pio_util.c
index 07ae4dd..c1dd898 100644
--- a/libcdi/src/pio_util.c
+++ b/libcdi/src/pio_util.c
@@ -8,15 +8,16 @@
 #include <stdlib.h>
 #include <string.h>
 
+#include <unistd.h>
+
 #include "pio_util.h"
 #include "cdi.h"
 #include "dmemory.h"
 
 static
-char commands[][13] = { "FINALIZE\0",
-                        "RESOURCES\0",
-                        "WINCREATE\0",
-                        "WRITETS\0"};
+char commands[][13] = { "FINALIZE",
+                        "RESOURCES",
+                        "WRITETS"};
 
 /*****************************************************************************/
 void
@@ -78,9 +79,9 @@ void pcdiXMPIStat ( int iret, const char *filename, int line, MPI_Status *status
 
   if ( iret == MPI_ERR_IN_STATUS )
     {
+      fprintf ( stderr, "------- checking error in request ----------\n" );
       switch ( status->MPI_ERROR )
         {
-          fprintf ( stderr, "------- checking error in request ----------\n" );
         case MPI_SUCCESS :
           fprintf ( stderr, "-------- mpi_success -----------\n" );
           break;
@@ -104,34 +105,6 @@ void pcdiXMPIStat ( int iret, const char *filename, int line, MPI_Status *status
 
 /****************************************************/
 
-void pcdiDebugComm ( const char *filename, const char *functionname, int line, MPI_Comm *comm )
-{
-  int rank = -1, size, len, rankGlob = -1;
-  char *name;
-
-  name = ( char * ) xmalloc ( MPI_MAX_OBJECT_NAME );
-  memset ( name, 0, ( MPI_MAX_OBJECT_NAME ) * sizeof ( char ));
-  MPI_Comm_get_name ( * comm, name, &len );
-  MPI_Comm_size ( * comm, &size );
-  {
-    int init_flag = 0, finished_flag = 0;
-    if (MPI_Initialized(&init_flag) == MPI_SUCCESS && init_flag
-        && MPI_Finalized(&finished_flag) == MPI_SUCCESS && !finished_flag)
-      {
-        MPI_Comm_rank(*comm, &rank);
-        MPI_Comm_rank(MPI_COMM_WORLD, &rankGlob);
-      }
-  }
-  fprintf ( stdout,
-            "pe%d in %s, %s, line %d: comm: name=%s, size=%d, rank=%d\n",
-            rankGlob, functionname, filename, line,
-            name, size, rank );
-  free ( name );
-
-}
-
-/****************************************************/
-
 void pcdiDebugMsg ( const char * cdiPioDebugString, const char *filename,
                     const char *functionname, int line, int tag, int source,
                     int nfinished )
@@ -159,7 +132,7 @@ void pcdiDebugMsg2 ( const char *filename, const char *functionname, int line,
 
 /****************************************************/
 
-void printArray ( const char * cdiPioDebugString, char * ps, const void * array, int n,
+void printArray ( const char *cdiPioDebugString, const char *ps, const void *array, int n,
                   int datatype, const char * funname, const char * filename, int line )
 {
   int i;
@@ -223,11 +196,83 @@ cdiPioQueryVarDims(int varShape[3], int vlistID, int varID)
   return (varShape[2] == 1)?2:3;
 }
 
+size_t
+cdiPioGetPageSize(bool largePageAlign)
+{
+  long pagesize = -1L;
+  bool nameAssigned = false;
+#if HAVE_DECL__SC_LARGE_PAGESIZE || HAVE_DECL__SC_PAGE_SIZE || HAVE_DECL__SC_PAGESIZE
+  int name;
+#if HAVE_DECL__SC_LARGE_PAGESIZE
+  if (largePageAlign)
+    {
+      name = _SC_LARGE_PAGESIZE;
+      nameAssigned = true;
+    }
+  else
+#endif
+    {
+#if HAVE_DECL__SC_PAGESIZE || HAVE_DECL__SC_PAGE_SIZE
+      name =
+#if HAVE_DECL__SC_PAGESIZE
+        _SC_PAGESIZE
+#elif HAVE_DECL__SC_PAGE_SIZE
+        _SC_PAGE_SIZE
+#endif
+        ;
+      nameAssigned = true;
+#endif
+    }
+  if (nameAssigned)
+    pagesize = sysconf(name);
+#endif
+  if (pagesize == -1L)
+    pagesize =
+#if HAVE_DECL_PAGESIZE
+      PAGESIZE
+#elif HAVE_DECL_PAGE_SIZE
+      PAGE_SIZE
+#else
+      commonPageSize
+#endif
+      ;
+  return (size_t)pagesize;
+}
+
+
+
+void
+deco1D_CCP(size_t nelems, const size_t *restrict weightPfxSums,
+           size_t nparts, size_t *restrict separators)
+{
+  separators[0] = 0;
+  separators[nparts] = nelems;
+  size_t i = 0, k = 1;
+  size_t weightTotal = weightPfxSums[nelems];
+  while (k < nparts)
+    {
+      size_t target = k * weightTotal / nparts;
+      do {
+        ++i;
+      } while (i < nelems && weightPfxSums[i] < target);
+      separators[k] = i;
+      ++k;
+      --i;
+    }
+  /* todo: implement h2 and dp+ algorithms from
+   * A. Pınar, C. Aykanat
+   * Fast optimal load balancing algorithms for 1D partitioning
+   */
+}
+
+
+
 /****************************************************/
 /*
  * Local Variables:
  * c-file-style: "Java"
  * c-basic-offset: 2
+ * coding: utf-8
  * indent-tabs-mode: nil
  * show-trailing-whitespace: t
  * require-trailing-newline: t
diff --git a/libcdi/src/pio_util.h b/libcdi/src/pio_util.h
index 6b47354..20d887a 100644
--- a/libcdi/src/pio_util.h
+++ b/libcdi/src/pio_util.h
@@ -69,11 +69,6 @@ void pcdiXMPI(int iret, const char *, int);
 void pcdiXMPIStat ( int, const char *, int, MPI_Status * );
 #define xmpiStat(ret,stat) pcdiXMPIStat ( ret, __FILE__, __LINE__, stat )
 
-void pcdiDebugComm ( const char *filename, const char *functionname, int line, \
-                     MPI_Comm *comm );
-#define xdebugComm(comm)\
-  if ( ddebug ) pcdiDebugComm (  __FILE__, __func__, __LINE__, comm )
-
 void pcdiDebugMsg ( const char * cdiDebugString, const char *filename, const char *functionname, int line, \
                     int tag, int source, int nfinished );
 #define xdebugMsg(tag,source,nfinished) \
@@ -95,7 +90,7 @@ sum_int(size_t n, int *a)
 }
 
 
-void printArray ( const char *, char *, const void *, int, int, const char *, const char *, int );
+void printArray ( const char *, const char *, const void *, int, int, const char *, const char *, int );
 #define xprintArray(ps,array,n,datatype)                                \
   if ( ddebug )                                                         \
       printArray ( debugString, ps, array, n, datatype,  __func__, __FILE__, __LINE__ )
@@ -110,6 +105,15 @@ void printArray ( const char *, char *, const void *, int, int, const char *, co
 int
 cdiPioQueryVarDims(int varShape[3], int vlistID, int varID);
 
+enum {
+  /* 8192 is known to work on most systems (4096 isn't on Alpha) */
+  commonPageSize = 8192,
+};
+
+size_t
+cdiPioGetPageSize(bool largePageAlign);
+
+
 #endif
 /*
  * Local Variables:
diff --git a/libcdi/src/proprietarySystemWorkarounds.c b/libcdi/src/proprietarySystemWorkarounds.c
deleted file mode 100644
index 3c3f741..0000000
--- a/libcdi/src/proprietarySystemWorkarounds.c
+++ /dev/null
@@ -1,45 +0,0 @@
-#include "proprietarySystemWorkarounds.h"
-#include "dmemory.h"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdarg.h>
-#include <errno.h>
-
-char* myStrDup(const char* string)
-{
-  char* result = xmalloc(strlen(string) + 1);
-  if(result)
-    {
-      strcpy(result, string);
-    }
-  else
-    {
-      errno = ENOMEM;
-    }
-  return result;
-}
-
-char* myAsprintf(char* format, ...)
-{
-  va_list args;
-  int size = 64;
-  char *buffer = xmalloc(size);
-  int nchars;
-  //Try to print in the allocated space.
-  va_start(args, format);
-  nchars = vsnprintf(buffer, size, format, args);
-  va_end(args);
-  if (nchars >= size)
-    {
-      //Reallocate buffer now that we know how much space is needed.
-      size = nchars + 1;
-      buffer = xrealloc(buffer, size);
-      va_start(args, format);
-      vsnprintf(buffer, size, format, args);
-      va_end(args);
-    }
-  return buffer;
-}
-
diff --git a/libcdi/src/proprietarySystemWorkarounds.h b/libcdi/src/proprietarySystemWorkarounds.h
deleted file mode 100644
index ee3151e..0000000
--- a/libcdi/src/proprietarySystemWorkarounds.h
+++ /dev/null
@@ -1,8 +0,0 @@
-#ifndef INCLUDE_GUARD_CDI_PROPRIETARY_SYSTEM_WORKAROUNDS_H
-#define INCLUDE_GUARD_CDI_PROPRIETARY_SYSTEM_WORKAROUNDS_H
-
-char* myStrDup(const char* string);      //This exactly implements the standardized behavior of strdup().
-
-char* myAsprintf(char* format, ...) __attribute__((format(printf, 1, 2)));       //This implementation differs from standard asprintf() function in the way the resulting string pointer is returned.
-
-#endif
diff --git a/libcdi/src/referenceCounting.c b/libcdi/src/referenceCounting.c
index 3b5172f..b5c3d5e 100644
--- a/libcdi/src/referenceCounting.c
+++ b/libcdi/src/referenceCounting.c
@@ -1,5 +1,6 @@
 #include "referenceCounting.h"
 
+#include "dmemory.h"
 #include "error.h"
 
 void cdiRefObject_construct(CdiReferencedObject* me)
@@ -21,8 +22,22 @@ void cdiRefObject_release(CdiReferencedObject* me)
   if(oldCount == 1)
     {
       me->destructor(me);
-      free(me);
+      Free(me);
     }
 }
 
-void cdiRefObject_destruct(CdiReferencedObject* me) { /* Empty for now, but that's no reason not to call it! */ }
+void cdiRefObject_destruct(CdiReferencedObject* me)
+{
+  (void)me;
+  /* Empty for now, but that's no reason not to call it! */
+}
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/referenceCounting.h b/libcdi/src/referenceCounting.h
index 6df196c..8a8c645 100644
--- a/libcdi/src/referenceCounting.h
+++ b/libcdi/src/referenceCounting.h
@@ -9,7 +9,7 @@
 /*
 This is a base class for all objects that need reference counting.
 A CdiReferencedObject has a reference count of one when it is constructed, refObjectRetain() increments the reference count, refObject Release() decrements it.
-When the reference count reaches zero, the destructor function is called before the memory of the object is deallocated with free().
+When the reference count reaches zero, the destructor function is called before the memory of the object is deallocated with Free().
 
 >>> Warning <<<
 This code is currently not thread-safe.
@@ -36,3 +36,13 @@ void cdiRefObject_release(CdiReferencedObject* me);
 void cdiRefObject_destruct(CdiReferencedObject* me);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/resource_handle.c b/libcdi/src/resource_handle.c
index 5c6cfdd..0685d61 100644
--- a/libcdi/src/resource_handle.c
+++ b/libcdi/src/resource_handle.c
@@ -118,7 +118,7 @@ listInitResources(int nsp)
   xassert(nsp < resHListSize && nsp >= 0);
   int size = resHList[nsp].size = MIN_LIST_SIZE;
   xassert(resHList[nsp].resources == NULL);
-  resHList[nsp].resources = (listElem_t*) xcalloc(MIN_LIST_SIZE, sizeof(listElem_t));
+  resHList[nsp].resources = (listElem_t*) Calloc(MIN_LIST_SIZE, sizeof(listElem_t));
   listElem_t *p = resHList[nsp].resources;
 
   for (int i = 0; i < size; i++ )
@@ -152,7 +152,7 @@ reshListCreate(int namespaceID)
   LIST_LOCK();
   if (resHListSize <= namespaceID)
     {
-      resHList = (struct resHList_t *)xrealloc(resHList, (size_t)(namespaceID + 1) * sizeof (resHList[0]));
+      resHList = (struct resHList_t *) Realloc(resHList, (size_t)(namespaceID + 1) * sizeof (resHList[0]));
       for (int i = resHListSize; i <= namespaceID; ++i)
         reshListClearEntry(i);
       resHListSize = namespaceID + 1;
@@ -179,7 +179,7 @@ reshListDestruct(int namespaceID)
           if (listElem->status & RESH_IN_USE_BIT)
             listElem->res.v.ops->valDestroy(listElem->res.v.val);
         }
-      free(resHList[namespaceID].resources);
+      Free(resHList[namespaceID].resources);
       resHList[namespaceID].resources = NULL;
       reshListClearEntry(namespaceID);
     }
@@ -196,7 +196,7 @@ static void listDestroy ( void )
     if (resHList[i-1].resources)
       namespaceDelete(i-1);
   resHListSize = 0;
-  free(resHList);
+  Free(resHList);
   resHList = NULL;
   cdiReset();
   LIST_UNLOCK();
@@ -235,7 +235,7 @@ void listSizeExtend()
   int oldSize = resHList[nsp].size;
   size_t newListSize = (size_t)oldSize + MIN_LIST_SIZE;
 
-  resHList[nsp].resources = (listElem_t*) xrealloc(resHList[nsp].resources,
+  resHList[nsp].resources = (listElem_t*) Realloc(resHList[nsp].resources,
                                                    newListSize * sizeof(listElem_t));
 
   listElem_t *r = resHList[nsp].resources;
@@ -423,7 +423,6 @@ reshGetElem(const char *caller, const char* expressionString, cdiResH resH, cons
   return listElem;
 }
 
-
 void *reshGetValue(const char * caller, const char* expressionString, cdiResH resH, const resOps * ops)
 {
   return reshGetElem(caller, expressionString, resH, ops)->res.v.val;
@@ -431,7 +430,7 @@ void *reshGetValue(const char * caller, const char* expressionString, cdiResH re
 
 /**************************************************************/
 
-void reshGetResHListOfType(unsigned numIDs, int resHs[numIDs], const resOps *ops)
+void reshGetResHListOfType(unsigned numIDs, int resHs[], const resOps *ops)
 {
   xassert ( resHs && ops );
 
@@ -584,7 +583,7 @@ void reshPackBufferDestroy ( char ** buffer )
 
 /**************************************************************/
 
-void reshPackBufferCreate(char **packBuffer, int *packBufferSize, void *context)
+int reshPackBufferCreate(char **packBuffer, int *packBufferSize, void *context)
 {
   int i, packBufferPos = 0;
   int end = END;
@@ -596,7 +595,7 @@ void reshPackBufferCreate(char **packBuffer, int *packBufferSize, void *context)
   int nsp = namespaceGetActive ();
 
   int pBSize = *packBufferSize = getPackBufferSize(context);
-  char *pB = *packBuffer = (char *)xcalloc(1, (size_t)pBSize);
+  char *pB = *packBuffer = (char *) Malloc((size_t)pBSize);
 
   {
     int header[resHPackHeaderNInt] = { START, nsp };
@@ -631,6 +630,7 @@ void reshPackBufferCreate(char **packBuffer, int *packBufferSize, void *context)
   LIST_UNLOCK();
 
   serializePack(&end, 1,  DATATYPE_INT, pB, pBSize, &packBufferPos, context);
+  return packBufferPos;
 }
 
 /**************************************************************/
@@ -643,7 +643,7 @@ void reshSetStatus ( cdiResH resH, const resOps * ops, int status )
   namespaceTuple_t nspT;
   listElem_t * listElem;
 
-  xassert(ops && (status & RESH_IN_USE_BIT));
+  xassert((ops != NULL) ^ !(status & RESH_IN_USE_BIT));
 
   LIST_INIT(1);
 
@@ -660,7 +660,8 @@ void reshSetStatus ( cdiResH resH, const resOps * ops, int status )
   xassert ( resHList[nsp].resources );
   listElem = resHList[nsp].resources + nspT.idx;
 
-  xassert ( listElem->res.v.ops == ops );
+  xassert((!ops || (listElem->res.v.ops == ops))
+          && (listElem->status & RESH_IN_USE_BIT) == (status & RESH_IN_USE_BIT));
 
   listElem->status = status;
 
@@ -674,8 +675,6 @@ int reshGetStatus ( cdiResH resH, const resOps * ops )
   int nsp;
   namespaceTuple_t nspT;
 
-  xassert ( ops );
-
   LIST_INIT(1);
 
   LIST_LOCK();
@@ -694,7 +693,7 @@ int reshGetStatus ( cdiResH resH, const resOps * ops )
 
   LIST_UNLOCK();
 
-  xassert(listElem && elemOps == ops);
+  xassert(listElem && (!(listElem->status & RESH_IN_USE_BIT) || elemOps == ops));
 
   return listElem->status;
 }
diff --git a/libcdi/src/resource_handle.h b/libcdi/src/resource_handle.h
index b2c376d..88264ad 100644
--- a/libcdi/src/resource_handle.h
+++ b/libcdi/src/resource_handle.h
@@ -62,8 +62,7 @@ unsigned reshCountType(const resOps *resTypeOps);
 void * reshGetValue(const char* caller, const char* expressionString, cdiResH id, const resOps* ops);
 #define reshGetVal(resH, ops)  reshGetValue(__func__, #resH, resH, ops)
 
-
-void reshGetResHListOfType(unsigned numIDs, int IDs[numIDs], const resOps *ops);
+void reshGetResHListOfType(unsigned numIDs, int IDs[], const resOps *ops);
 
 enum cdiApplyRet {
   CDI_APPLY_ERROR = -1,
@@ -79,7 +78,7 @@ cdiResHFilterApply(const resOps *p,
                                             void *data),
                    void *data);
 
-void   reshPackBufferCreate ( char **, int *, void *context );
+int reshPackBufferCreate(char **packBuf, int *packBufSize, void *context);
 void   reshPackBufferDestroy ( char ** );
 int    reshResourceGetPackSize_intern(int resh, const resOps *ops, void *context, const char* caller, const char* expressionString);
 #define reshResourceGetPackSize(resh, ops, context) reshResourceGetPackSize_intern(resh, ops, context, __func__, #resh)
diff --git a/libcdi/src/resource_unpack.c b/libcdi/src/resource_unpack.c
index b05b6e0..dd9cef8 100644
--- a/libcdi/src/resource_unpack.c
+++ b/libcdi/src/resource_unpack.c
@@ -18,14 +18,14 @@
 
 /*****************************************************************************/
 
-void reshUnpackResources(char * unpackBuffer, int unpackBufferSize,
-                         void *context)
+int reshUnpackResources(char * unpackBuffer, int unpackBufferSize,
+                        void *context)
 {
   int updateType, resH, originNamespace;
   int unpackBufferPos = 0;
   int numAssociations = 0, sizeAssociations = 16;
   struct streamAssoc *associations
-    = (struct streamAssoc *)xmalloc(sizeof (associations[0])
+    = (struct streamAssoc *) Malloc(sizeof (associations[0])
                                     * (size_t)sizeAssociations);
 
   {
@@ -67,7 +67,7 @@ void reshUnpackResources(char * unpackBuffer, int unpackBufferSize,
 	case STREAM:
           if (sizeAssociations == numAssociations)
             associations
-              = xrealloc(associations,
+              = (struct streamAssoc *) Realloc(associations,
                          sizeof (associations[0]) * (size_t)(sizeAssociations *= 2));
 	  associations[numAssociations]
             = streamUnpack(unpackBuffer, unpackBufferSize, &unpackBufferPos,
@@ -81,7 +81,9 @@ void reshUnpackResources(char * unpackBuffer, int unpackBufferSize,
         case RESH_DELETE:
           serializeUnpack(unpackBuffer, unpackBufferSize, &unpackBufferPos,
                           &resH, 1, DATATYPE_INT, context);
-          reshDestroy(namespaceAdaptKey(resH, originNamespace));
+          resH = namespaceAdaptKey(resH, originNamespace);
+          reshDestroy(resH);
+          reshSetStatus(resH, NULL, RESH_UNUSED);
           break;
 	default:
 	  xabort("Invalid/unexpected serialization type %d or transfer error!",
@@ -92,11 +94,10 @@ void reshUnpackResources(char * unpackBuffer, int unpackBufferSize,
     {
       cdiStreamSetupVlist(stream_to_pointer(associations[i].streamID),
                           namespaceAdaptKey(associations[i].vlistID,
-                                            originNamespace),
-                          namespaceAdaptKey(associations[i].vlistIDorig,
                                             originNamespace));
     }
-  free(associations);
+  Free(associations);
+  return unpackBufferPos;
 }
 
 /*
diff --git a/libcdi/src/resource_unpack.h b/libcdi/src/resource_unpack.h
index 3d924d6..db49951 100644
--- a/libcdi/src/resource_unpack.h
+++ b/libcdi/src/resource_unpack.h
@@ -18,7 +18,17 @@ enum
   END       = 99999999
 };
 
-void reshUnpackResources(char * unpackBuffer, int unpackBufferSize,
-                         void *context);
+int reshUnpackResources(char * unpackBuffer, int unpackBufferSize,
+                        void *context);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/serialize.c b/libcdi/src/serialize.c
index badf140..8f7ffbc 100644
--- a/libcdi/src/serialize.c
+++ b/libcdi/src/serialize.c
@@ -95,3 +95,13 @@ void serializeUnpackInCore(const void *buf, int buf_size, int *position,
   pos += size;
   *position = pos;
 }
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/serialize.h b/libcdi/src/serialize.h
index 71de8ad..ba363a0 100644
--- a/libcdi/src/serialize.h
+++ b/libcdi/src/serialize.h
@@ -53,12 +53,12 @@ serializeStrTabPack(const char **strTab, int numStr,
   xassert(numStr >= 0);
   for (size_t i = 0; i < (size_t)numStr; ++i)
   {
-    size_t len = strlen(strTab[i]);
-    serializePack(&(int){(int)len}, 1, DATATYPE_INT,
+    int len = (int)strlen(strTab[i]);
+    serializePack(&len, 1, DATATYPE_INT,
                   buf, buf_size, position, context);
-    serializePack(strTab[i], (int)len, DATATYPE_TXT,
+    serializePack(strTab[i], len, DATATYPE_TXT,
                   buf, buf_size, position, context);
-    d ^= cdiCheckSum(DATATYPE_TXT, (int)len, strTab[i]);
+    d ^= cdiCheckSum(DATATYPE_TXT, len, strTab[i]);
   }
   serializePack(&d, 1, DATATYPE_UINT32,
                 buf, buf_size, position, context);
@@ -78,7 +78,7 @@ serializeStrTabUnpack(const void *buf, int buf_size, int *position,
       serializeUnpack(buf, buf_size, position,
                       strTab[i], len, DATATYPE_TXT, context);
       strTab[i][len] = '\0';
-      d2 ^= cdiCheckSum(DATATYPE_TXT, (size_t)len, strTab[i]);
+      d2 ^= cdiCheckSum(DATATYPE_TXT, len, strTab[i]);
     }
   serializeUnpack(buf, buf_size, position,
                   &d, 1, DATATYPE_UINT32, context);
diff --git a/libcdi/src/service.h b/libcdi/src/service.h
index 1fbe0f0..eeb830a 100644
--- a/libcdi/src/service.h
+++ b/libcdi/src/service.h
@@ -21,19 +21,19 @@ void srvDebug(int debug);
 
 int  srvCheckFiletype(int fileID, int *swap);
 
-srvrec_t *srvNew(void);
-void srvDelete(srvrec_t *srvp);
+void *srvNew(void);
+void srvDelete(void *srv);
 
-int  srvRead(int fileID, srvrec_t *srvp);
-void srvWrite(int fileID, srvrec_t *srvp);
+int  srvRead(int fileID, void *srv);
+void srvWrite(int fileID, void *srv);
 
-int  srvInqHeader(srvrec_t *srvp, int *header);
-int  srvInqDataSP(srvrec_t *srvp, float *data);
-int  srvInqDataDP(srvrec_t *srvp, double *data);
+int  srvInqHeader(void *srv, int *header);
+int  srvInqDataSP(void *srv, float *data);
+int  srvInqDataDP(void *srv, double *data);
 
-int  srvDefHeader(srvrec_t *srvp, const int *header);
-int  srvDefDataSP(srvrec_t *srvp, const float *data);
-int  srvDefDataDP(srvrec_t *srvp, const double *data);
+int  srvDefHeader(void *srv, const int *header);
+int  srvDefDataSP(void *srv, const float *data);
+int  srvDefDataDP(void *srv, const double *data);
 
 
 #endif  /* _SERVICE_H */
diff --git a/libcdi/src/servicelib.c b/libcdi/src/servicelib.c
index a632f7a..7c7ba99 100644
--- a/libcdi/src/servicelib.c
+++ b/libcdi/src/servicelib.c
@@ -2,20 +2,18 @@
 #  include "config.h"
 #endif
 
-#ifdef HAVE_LIBSERVICE
-
 #include <stdio.h>
+#include <stdlib.h>
 #include <stdarg.h>
 #include <string.h>
 #include <ctype.h>
 
 #include "dmemory.h"
-
 #include "service.h"
 #include "error.h"
 #include "file.h"
 #include "binary.h"
-#include "stream_fcommon.h"
+#include "exse.h"
 #include "swap.h"
 
 
@@ -32,20 +30,19 @@ static int srvDefaultDprec = 0;
 /*
  * A version string.
  */
-
 #undef  LIBVERSION
-#define LIBVERSION      1.3.2
+#define LIBVERSION      1.4.0
 #define XSTRING(x)	#x
 #define STRING(x)	XSTRING(x)
-static const char srv_libvers[] = STRING(LIBVERSION) " of "__DATE__" "__TIME__;
+static const char srv_libvers[] = STRING(LIBVERSION) " of " __DATE__" " __TIME__;
 
 const char *srvLibraryVersion(void)
 {
-  return (srv_libvers);
+  return srv_libvers;
 }
 
 
-int SRV_Debug = 0;    /* If set to 1, debugging */
+static int SRV_Debug = 0;    /* If set to 1, debugging */
 
 
 void srvDebug(int debug)
@@ -56,22 +53,19 @@ void srvDebug(int debug)
     Message("debug level %d", debug);
 }
 
-
+static
 void srvLibInit()
 {
-  char *envString;
-  char *envName = "SRV_PRECISION";
-
+  const char *envName = "SRV_PRECISION";
 
-  envString = getenv(envName);
+  char *envString = getenv(envName);
   if ( envString )
     {
-      int pos;
       int nrun;
       if ( strlen(envString) == 2 ) nrun = 1;
       else                          nrun = 2;
 
-      pos = 0;
+      int pos = 0;
       while ( nrun-- )
 	{
 	  switch ( tolower((int) envString[pos]) )
@@ -80,8 +74,8 @@ void srvLibInit()
 	      {
 		switch ( (int) envString[pos+1] )
 		  {
-		  case '4': srvDefaultHprec = SINGLE_PRECISION; break;
-		  case '8': srvDefaultHprec = DOUBLE_PRECISION; break;
+		  case '4': srvDefaultHprec = EXSE_SINGLE_PRECISION; break;
+		  case '8': srvDefaultHprec = EXSE_DOUBLE_PRECISION; break;
 		  default:
 		    Message("Invalid digit in %s: %s", envName, envString);
 		  }
@@ -91,8 +85,8 @@ void srvLibInit()
 	      {
 		switch ( (int) envString[pos+1] )
 		  {
-		  case '4': srvDefaultDprec = SINGLE_PRECISION; break;
-		  case '8': srvDefaultDprec = DOUBLE_PRECISION; break;
+		  case '4': srvDefaultDprec = EXSE_SINGLE_PRECISION; break;
+		  case '8': srvDefaultDprec = EXSE_DOUBLE_PRECISION; break;
 		  default:
 		    Message("Invalid digit in %s: %s", envName, envString);
 		  }
@@ -111,7 +105,7 @@ void srvLibInit()
   initSrvLib = 1;
 }
 
-
+static
 void srvInit(srvrec_t *srvp)
 {
   srvp->checked    = 0;
@@ -124,44 +118,42 @@ void srvInit(srvrec_t *srvp)
 }
 
 
-srvrec_t *srvNew(void)
+void *srvNew(void)
 {
-  srvrec_t *srvp;
-
   if ( ! initSrvLib ) srvLibInit();
 
-  srvp = (srvrec_t *) malloc(sizeof(srvrec_t));
+  srvrec_t *srvp = (srvrec_t *) Malloc(sizeof(srvrec_t));
 
   srvInit(srvp);
 
-  return (srvp);
+  return (void*)srvp;
 }
 
 
-void srvDelete(srvrec_t *srvp)
+void srvDelete(void *srv)
 {
+  srvrec_t *srvp = (srvrec_t *) srv;
+
   if ( srvp )
     {
-      if ( srvp->buffer ) free(srvp->buffer);
-      free(srvp);
+      if ( srvp->buffer ) Free(srvp->buffer);
+      Free(srvp);
     }
 }
 
 
 int srvCheckFiletype(int fileID, int *swap)
 {
-  size_t blocklen = 0;
-  size_t sblocklen = 0;
   size_t data = 0;
   size_t dimx = 0, dimy = 0;
   size_t fact = 0;
   int found = 0;
   unsigned char buffer[72], *pbuf;
 
-  if ( fileRead(fileID, buffer, 4) != 4 ) return (found);
+  if ( fileRead(fileID, buffer, 4) != 4 ) return found;
 
-  blocklen  = (size_t) get_UINT32(buffer);
-  sblocklen = (size_t) get_SUINT32(buffer);
+  size_t blocklen  = (size_t) get_UINT32(buffer);
+  size_t sblocklen = (size_t) get_SUINT32(buffer);
 
   if ( SRV_Debug )
     Message("blocklen = %d sblocklen = %d", blocklen, sblocklen);
@@ -170,7 +162,7 @@ int srvCheckFiletype(int fileID, int *swap)
     {
      *swap = 0;
       fact = blocklen>>3;
-      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return found;
       pbuf = buffer+4*fact;      dimx = (size_t) get_UINT32(pbuf);
       pbuf = buffer+5*fact;      dimy = (size_t) get_UINT32(pbuf);
       pbuf = buffer+blocklen+4;  data = (size_t) get_UINT32(pbuf);
@@ -179,7 +171,7 @@ int srvCheckFiletype(int fileID, int *swap)
     {
      *swap = 0;
       fact = blocklen>>3;
-      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, blocklen+8) != blocklen+8 ) return found;
       pbuf = buffer+4*fact;      dimx = (size_t) get_UINT64(pbuf);
       pbuf = buffer+5*fact;      dimy = (size_t) get_UINT64(pbuf);
       pbuf = buffer+blocklen+4;  data = (size_t) get_UINT32(pbuf);
@@ -188,7 +180,7 @@ int srvCheckFiletype(int fileID, int *swap)
     {
      *swap = 1;
       fact = sblocklen>>3;
-      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return found;
       pbuf = buffer+4*fact;       dimx = (size_t) get_SUINT32(pbuf);
       pbuf = buffer+5*fact;       dimy = (size_t) get_SUINT32(pbuf);
       pbuf = buffer+sblocklen+4;  data = (size_t) get_SUINT32(pbuf);
@@ -197,7 +189,7 @@ int srvCheckFiletype(int fileID, int *swap)
     {
      *swap = 1;
       fact = sblocklen>>3;
-      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return (found);
+      if ( fileRead(fileID, buffer, sblocklen+8) != sblocklen+8 ) return found;
       pbuf = buffer+4*fact;       dimx = (size_t) get_SUINT64(pbuf);
       pbuf = buffer+5*fact;       dimy = (size_t) get_SUINT64(pbuf);
       pbuf = buffer+sblocklen+4;  data = (size_t) get_SUINT32(pbuf);
@@ -214,29 +206,29 @@ int srvCheckFiletype(int fileID, int *swap)
       Message("dimx = %lu dimy = %lu data = %lu", dimx, dimy, data);
     }
 
-  return (found);
+  return found;
 }
 
 
-int srvInqHeader(srvrec_t *srvp, int *header)
+int srvInqHeader(void *srv, int *header)
 {
-  size_t i;
+  srvrec_t *srvp = (srvrec_t *) srv;
 
-  for ( i = 0; i < SRV_HEADER_LEN; i++ )
+  for ( size_t i = 0; i < SRV_HEADER_LEN; i++ )
     header[i] = srvp->header[i];
-  
+
   if ( SRV_Debug )
     Message("datasize = %lu", srvp->datasize);
 
-  return (0);
+  return 0;
 }
 
 
-int srvDefHeader(srvrec_t *srvp, const int *header)
+int srvDefHeader(void *srv, const int *header)
 {
-  size_t i;
+  srvrec_t *srvp = (srvrec_t *) srv;
 
-  for ( i = 0; i < SRV_HEADER_LEN; i++ )
+  for ( size_t i = 0; i < SRV_HEADER_LEN; i++ )
     srvp->header[i] = header[i];
 
   srvp->datasize = (size_t)(header[4] * header[5]);
@@ -244,28 +236,22 @@ int srvDefHeader(srvrec_t *srvp, const int *header)
   if ( SRV_Debug )
     Message("datasize = %lu", srvp->datasize);
 
-  return (0);
+  return 0;
 }
 
-
+static
 int srvInqData(srvrec_t *srvp, int prec, void *data)
 {
-  size_t datasize;
   size_t i;
   int ierr = 0;
-  int dprec;
-  void *buffer;
   int byteswap = srvp->byteswap;
-
-  datasize = srvp->datasize;
-
-  buffer = srvp->buffer;
-
-  dprec = srvp->dprec;
+  size_t datasize = srvp->datasize;
+  void *buffer = srvp->buffer;
+  int dprec = srvp->dprec;
 
   switch ( dprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	if ( sizeof(FLT32) == 4 )
 	  {
@@ -274,7 +260,7 @@ int srvInqData(srvrec_t *srvp, int prec, void *data)
 	    if ( dprec == prec )
 	      memcpy(data, buffer, datasize*sizeof(FLT32));
 	    else
-	      for (i = 0; i < datasize; i++)
+	      for ( i = 0; i < datasize; i++ )
 		((double *) data)[i] = (double) ((float *) buffer)[i];
 	  }
 	else
@@ -283,7 +269,7 @@ int srvInqData(srvrec_t *srvp, int prec, void *data)
 	  }
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
 	if ( sizeof(FLT64) == 8 )
 	  {
 	    if ( byteswap ) swap8byte(buffer, datasize);
@@ -291,7 +277,7 @@ int srvInqData(srvrec_t *srvp, int prec, void *data)
 	    if ( dprec == prec )
 	      memcpy(data, buffer, datasize*sizeof(FLT64));
 	    else
-	      for (i = 0; i < datasize; i++)
+	      for ( i = 0; i < datasize; i++ )
 		((float *) data)[i] = (float) ((double *) buffer)[i];
 	  }
 	else
@@ -306,30 +292,28 @@ int srvInqData(srvrec_t *srvp, int prec, void *data)
       }
     }
 
-  return (ierr);
+  return ierr;
 }
 
 
-int srvInqDataSP(srvrec_t *srvp, float *data)
+int srvInqDataSP(void *srv, float *data)
 {
-  return (srvInqData(srvp, SINGLE_PRECISION, (void *) data));
+  return srvInqData((srvrec_t *)srv, EXSE_SINGLE_PRECISION, (void *) data);
 }
 
 
-int srvInqDataDP(srvrec_t *srvp, double *data)
+int srvInqDataDP(void *srv, double *data)
 {
-  return (srvInqData(srvp, DOUBLE_PRECISION, (void *) data));
+  return srvInqData((srvrec_t *)srv, EXSE_DOUBLE_PRECISION, (void *) data);
 }
 
 
-int srvDefData(srvrec_t *srvp, int prec, const void *data)
+static int
+srvDefData(void *srv, int prec, const void *data)
 {
-  size_t datasize;
-  size_t blocklen;
-  size_t buffersize;
+  srvrec_t *srvp = (srvrec_t *) srv;
   size_t i;
   int dprec, hprec;
-  int *header;
   void *buffer;
 
   if ( srvDefaultDprec ) dprec = srvDefaultDprec;
@@ -346,20 +330,20 @@ int srvDefData(srvrec_t *srvp, int prec, const void *data)
 
   srvp->hprec = hprec;
 
-  header = srvp->header;
+  int *header = srvp->header;
 
-  datasize = (size_t)(header[4] * header[5]);
-  blocklen = datasize * (size_t)dprec;
+  size_t datasize = (size_t)(header[4] * header[5]);
+  size_t blocklen = datasize * (size_t)dprec;
 
   srvp->datasize = datasize;
 
-  buffersize = srvp->buffersize;
+  size_t buffersize = srvp->buffersize;
 
   if ( buffersize != blocklen )
     {
       buffersize = blocklen;
       buffer = srvp->buffer;
-      buffer = realloc(buffer, buffersize);
+      buffer = Realloc(buffer, buffersize);
       srvp->buffer = buffer;
       srvp->buffersize = buffersize;
     }
@@ -368,22 +352,22 @@ int srvDefData(srvrec_t *srvp, int prec, const void *data)
 
   switch ( dprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	if ( dprec == prec )
 	  memcpy(buffer, data, datasize*sizeof(FLT32));
 	else
-	  for (i = 0; i < datasize; i++)
+	  for ( i = 0; i < datasize; i++ )
 	    ((float *) buffer)[i] = (float) ((double *) data)[i];
 
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
 	if ( dprec == prec )
 	  memcpy(buffer, data, datasize*sizeof(FLT64));
 	else
-	  for (i = 0; i < datasize; i++)
+	  for ( i = 0; i < datasize; i++ )
 	    ((double *) buffer)[i] = (double) ((float *) data)[i];
 
 	break;
@@ -395,30 +379,31 @@ int srvDefData(srvrec_t *srvp, int prec, const void *data)
       }
     }
 
-  return (0);
+  return 0;
 }
 
 
-int srvDefDataSP(srvrec_t *srvp, const float *data)
+int srvDefDataSP(void *srv, const float *data)
 {
-  return (srvDefData(srvp, SINGLE_PRECISION, (void *) data));
+  return srvDefData(srv, EXSE_SINGLE_PRECISION, (void *) data);
 }
 
 
-int srvDefDataDP(srvrec_t *srvp, const double *data)
+int srvDefDataDP(void *srv, const double *data)
 {
-  return (srvDefData(srvp, DOUBLE_PRECISION, (void *) data));
+  return srvDefData(srv, EXSE_DOUBLE_PRECISION, (void *) data);
 }
 
 
-int srvRead(int fileID, srvrec_t *srvp)
+int srvRead(int fileID, void *srv)
 {
-  size_t datasize;
-  size_t blocklen, blocklen2;
+  srvrec_t *srvp = (srvrec_t *) srv;
   size_t i;
-  char tempheader[64];
+  union {
+    INT32 i32[SRV_HEADER_LEN];
+    INT64 i64[SRV_HEADER_LEN];
+  } tempheader;
   void *buffer;
-  int byteswap;
   int status;
 
   if ( ! srvp->checked )
@@ -428,12 +413,12 @@ int srvRead(int fileID, srvrec_t *srvp)
       srvp->checked = 1;
     }
 
-  byteswap = srvp->byteswap;
+  int byteswap = srvp->byteswap;
 
   /* read header record */
-  blocklen = binReadF77Block(fileID, byteswap);
+  size_t blocklen = binReadF77Block(fileID, byteswap);
 
-  if ( fileEOF(fileID) ) return (-1);
+  if ( fileEOF(fileID) ) return -1;
 
   if ( SRV_Debug )
     Message("blocklen = %lu", blocklen);
@@ -444,21 +429,21 @@ int srvRead(int fileID, srvrec_t *srvp)
 
   switch ( hprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
-	binReadInt32(fileID, byteswap, SRV_HEADER_LEN, (INT32 *) tempheader);
+	binReadInt32(fileID, byteswap, SRV_HEADER_LEN, tempheader.i32);
 
 	for ( i = 0; i < SRV_HEADER_LEN; i++ )
-          srvp->header[i] = (int) ((INT32 *) tempheader)[i];
+          srvp->header[i] = (int)tempheader.i32[i];
 
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
-	binReadInt64(fileID, byteswap, SRV_HEADER_LEN, (INT64 *) tempheader);
+	binReadInt64(fileID, byteswap, SRV_HEADER_LEN, tempheader.i64);
 
 	for ( i = 0; i < SRV_HEADER_LEN; i++ )
-          srvp->header[i] = (int) ((INT64 *) tempheader)[i];
+          srvp->header[i] = (int)tempheader.i64[i];
 
 	break;
       }
@@ -469,12 +454,12 @@ int srvRead(int fileID, srvrec_t *srvp)
       }
     }
 
-  blocklen2 = binReadF77Block(fileID, byteswap);
+  size_t blocklen2 = binReadF77Block(fileID, byteswap);
 
   if ( blocklen2 != blocklen )
     {
       Warning("Header blocklen differ (blocklen1=%d; blocklen2=%d)!", blocklen, blocklen2);
-      if ( blocklen2 != 0 ) return (-1);
+      if ( blocklen2 != 0 ) return -1;
     }
 
   srvp->datasize = (size_t)(srvp->header[4] * srvp->header[5]);
@@ -490,23 +475,23 @@ int srvRead(int fileID, srvrec_t *srvp)
     {
       buffersize = blocklen;
       buffer = srvp->buffer;
-      buffer = realloc(buffer, buffersize);
+      buffer = Realloc(buffer, buffersize);
       srvp->buffer = buffer;
       srvp->buffersize = buffersize;
     }
   else
     buffer = srvp->buffer;
 
-  datasize = srvp->datasize;
+  size_t datasize = srvp->datasize;
 
   size_t dprec = blocklen / datasize;
 
   srvp->dprec = (int)dprec;
 
-  if ( dprec != SINGLE_PRECISION && dprec != DOUBLE_PRECISION )
+  if ( dprec != EXSE_SINGLE_PRECISION && dprec != EXSE_DOUBLE_PRECISION )
     {
       Warning("Unexpected data precision %d", dprec);
-      return (-1);
+      return -1;
     }
 
   fileRead(fileID, buffer, blocklen);
@@ -516,50 +501,49 @@ int srvRead(int fileID, srvrec_t *srvp)
   if ( blocklen2 != blocklen )
     {
       Warning("Data blocklen differ (blocklen1=%d; blocklen2=%d)!", blocklen, blocklen2);
-      if ( blocklen2 != 0 ) return (-1);
+      if ( blocklen2 != 0 ) return -1;
     }
 
-  return (0);
+  return 0;
 }
 
 
-void srvWrite(int fileID, srvrec_t *srvp)
+void srvWrite(int fileID, void *srv)
 {
-  size_t datasize;
-  size_t blocklen;
+  srvrec_t *srvp = (srvrec_t *) srv;
   size_t i;
-  int dprec, hprec;
-  char tempheader[64];
-  int *header;
-  void *buffer;
+  union
+  {
+    INT32 i32[SRV_HEADER_LEN];
+    INT64 i64[SRV_HEADER_LEN];
+  } tempheader;
   int byteswap = srvp->byteswap;
-
-  dprec  = srvp->dprec;
-  hprec  = srvp->hprec;
-  header = srvp->header;
+  int dprec  = srvp->dprec;
+  int hprec  = srvp->hprec;
+  int *restrict header = srvp->header;
 
   /* write header record */
-  blocklen = SRV_HEADER_LEN * (size_t)hprec;
+  size_t blocklen = SRV_HEADER_LEN * (size_t)hprec;
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
   switch ( hprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	for (i = 0; i < SRV_HEADER_LEN; i++)
-          ((INT32 *) tempheader)[i] = (INT32) header[i];
+          tempheader.i32[i] = (INT32) header[i];
 
-	binWriteInt32(fileID, byteswap, SRV_HEADER_LEN, (INT32 *) tempheader);
+	binWriteInt32(fileID, byteswap, SRV_HEADER_LEN, tempheader.i32);
 
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
 	for (i = 0; i < SRV_HEADER_LEN; i++)
-          ((INT64 *) tempheader)[i] = (INT64) header[i];
+          tempheader.i64[i] = (INT64) header[i];
 
-	binWriteInt64(fileID, byteswap, SRV_HEADER_LEN, (INT64 *) tempheader);
+	binWriteInt64(fileID, byteswap, SRV_HEADER_LEN, tempheader.i64);
 
 	break;
       }
@@ -572,23 +556,23 @@ void srvWrite(int fileID, srvrec_t *srvp)
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
-  datasize = (size_t)(header[4] * header[5]);
+  size_t datasize = (size_t)(header[4] * header[5]);
   blocklen = datasize * (size_t)dprec;
 
   binWriteF77Block(fileID, byteswap, blocklen);
 
   srvp->datasize = datasize;
 
-  buffer = srvp->buffer;
+  void *buffer = srvp->buffer;
 
   switch ( dprec )
     {
-    case SINGLE_PRECISION:
+    case EXSE_SINGLE_PRECISION:
       {
 	binWriteFlt32(fileID, byteswap, datasize, (FLT32 *) buffer);
 	break;
       }
-    case DOUBLE_PRECISION:
+    case EXSE_DOUBLE_PRECISION:
       {
 	binWriteFlt64(fileID, byteswap, datasize, (FLT64 *) buffer);
 	break;
@@ -611,4 +595,3 @@ void srvWrite(int fileID, srvrec_t *srvp)
  * require-trailing-newline: t
  * End:
  */
-#endif  /* HAVE_LIBSERVICE */
diff --git a/libcdi/src/stream.c b/libcdi/src/stream.c
index 79931f3..068fb55 100644
--- a/libcdi/src/stream.c
+++ b/libcdi/src/stream.c
@@ -10,6 +10,7 @@
 #include <stdio.h>
 #include <string.h>
 
+#include "binary.h"
 #include "cdi.h"
 #include "cdi_int.h"
 #include "cdi_cksum.h"
@@ -56,29 +57,25 @@ const resOps streamOps = {
 
 
 
-
-#undef  IsBigendian
-#define IsBigendian()  ( u_byteorder.c[sizeof(long) - 1] )
-
-
 static
 int getByteorder(int byteswap)
 {
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
   int byteorder = -1;
 
-  if ( IsBigendian() )
-    {
-      if ( byteswap ) byteorder = CDI_LITTLEENDIAN;
-      else            byteorder = CDI_BIGENDIAN;
-    }
-  else
+  switch (HOST_ENDIANNESS)
     {
-      if ( byteswap ) byteorder = CDI_BIGENDIAN;
-      else            byteorder = CDI_LITTLEENDIAN;
+    case CDI_BIGENDIAN:
+      byteorder = byteswap ? CDI_LITTLEENDIAN : CDI_BIGENDIAN;
+      break;
+    case CDI_LITTLEENDIAN:
+      byteorder = byteswap ? CDI_BIGENDIAN : CDI_LITTLEENDIAN;
+      break;
+    /* FIXME: does not currently adjust for PDP endianness */
+    case CDI_PDPENDIAN:
+    default:
+      Error("unhandled endianness");
     }
-
-  return (byteorder);
+  return byteorder;
 }
 
 // used also in CDO
@@ -206,16 +203,19 @@ int streamInqFiletype(int streamID)
 
 int getByteswap(int byteorder)
 {
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
-  int byteswap = 0;
+  int byteswap = -1;
 
-  if ( IsBigendian() )
+  switch (byteorder)
     {
-      if ( byteorder == CDI_LITTLEENDIAN ) byteswap = TRUE;
-    }
-  else
-    {
-      if ( byteorder == CDI_BIGENDIAN ) byteswap = TRUE;
+    case CDI_BIGENDIAN:
+    case CDI_LITTLEENDIAN:
+    case CDI_PDPENDIAN:
+      byteswap = (HOST_ENDIANNESS != byteorder);
+      break;
+    case -1:
+      break;
+    default:
+      Error("unexpected byteorder %d query!", byteorder);
     }
 
   return (byteswap);
@@ -239,13 +239,12 @@ with the file format type @func{FILETYPE_SRV}, @func{FILETYPE_EXT} or @func{FILE
 */
 void streamDefByteorder(int streamID, int byteorder)
 {
-  int filetype;
   stream_t *streamptr = stream_to_pointer(streamID);
 
   stream_check_ptr(__func__, streamptr);
 
   streamptr->byteorder = byteorder;
-  filetype = streamptr->filetype;
+  int filetype = streamptr->filetype;
 
   switch (filetype)
     {
@@ -423,7 +422,7 @@ int cdiInqContents(stream_t * streamptr)
   return (status);
 }
 
-int cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
+int cdiStreamOpenDefaultDelegate(const char *filename, char filemode,
                                  int filetype, stream_t *streamptr,
                                  int recordBufIsToBeCreated)
 {
@@ -434,11 +433,11 @@ int cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
     case FILETYPE_GRB:
     case FILETYPE_GRB2:
       {
-        fileID = gribOpen(filename, filemode);
+        fileID = gribOpen(filename, (char [2]){filemode, 0});
         if ( fileID < 0 ) fileID = CDI_ESYSTEM;
         if (recordBufIsToBeCreated)
           {
-            streamptr->record = (Record *) malloc(sizeof(Record));
+            streamptr->record = (Record *) Malloc(sizeof(Record));
             streamptr->record->buffer = NULL;
           }
         break;
@@ -447,11 +446,11 @@ int cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
 #if  defined  (HAVE_LIBSERVICE)
     case FILETYPE_SRV:
       {
-        fileID = fileOpen(filename, filemode);
+        fileID = fileOpen(filename, (char [2]){filemode, 0});
         if ( fileID < 0 ) fileID = CDI_ESYSTEM;
         if (recordBufIsToBeCreated)
           {
-            streamptr->record = (Record *) malloc(sizeof(Record));
+            streamptr->record = (Record *) Malloc(sizeof(Record));
             streamptr->record->buffer = NULL;
             streamptr->record->exsep  = srvNew();
           }
@@ -461,11 +460,11 @@ int cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
 #if  defined  (HAVE_LIBEXTRA)
     case FILETYPE_EXT:
       {
-        fileID = fileOpen(filename, filemode);
+        fileID = fileOpen(filename, (char [2]){filemode, 0});
         if ( fileID < 0 ) fileID = CDI_ESYSTEM;
         if (recordBufIsToBeCreated)
           {
-            streamptr->record = (Record *) malloc(sizeof(Record));
+            streamptr->record = (Record *) Malloc(sizeof(Record));
             streamptr->record->buffer = NULL;
             streamptr->record->exsep  = extNew();
           }
@@ -475,11 +474,11 @@ int cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
 #if  defined  (HAVE_LIBIEG)
     case FILETYPE_IEG:
       {
-        fileID = fileOpen(filename, filemode);
+        fileID = fileOpen(filename, (char [2]){filemode, 0});
         if ( fileID < 0 ) fileID = CDI_ESYSTEM;
         if (recordBufIsToBeCreated)
           {
-            streamptr->record = (Record *) malloc(sizeof(Record));
+            streamptr->record = (Record *) Malloc(sizeof(Record));
             streamptr->record->buffer = NULL;
             streamptr->record->exsep   = iegNew();
           }
@@ -489,18 +488,18 @@ int cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
 #if  defined  (HAVE_LIBNETCDF)
     case FILETYPE_NC:
       {
-        fileID = cdfOpen(filename, filemode);
+        fileID = cdfOpen(filename, (char [2]){filemode, 0});
         break;
       }
     case FILETYPE_NC2:
       {
-        fileID = cdfOpen64(filename, filemode);
+        fileID = cdfOpen64(filename, (char [2]){filemode, 0});
         break;
       }
     case FILETYPE_NC4:
     case FILETYPE_NC4C:
       {
-        fileID = cdf4Open(filename, filemode, &filetype);
+        fileID = cdf4Open(filename, (char [2]){filemode, 0}, &filetype);
         break;
       }
 #endif
@@ -517,26 +516,26 @@ int cdiStreamOpenDefaultDelegate(const char *filename, const char *filemode,
 }
 
 
-static int
-streamOpenID(const char *filename, const char *filemode, int filetype,
+int
+streamOpenID(const char *filename, char filemode, int filetype,
              int resH)
 {
   int fileID = CDI_UNDEFID;
   int status;
 
   if ( CDI_Debug )
-    Message("Open %s mode %c file %s", strfiletype(filetype), (int) *filemode,
+    Message("Open %s mode %c file %s", strfiletype(filetype), filemode,
             filename?filename:"(NUL)");
 
-  if ( ! filename || ! filemode || filetype < 0 ) return (CDI_EINVAL);
+  if ( ! filename || filetype < 0 ) return (CDI_EINVAL);
 
   stream_t *streamptr = stream_new_entry(resH);
   int streamID = CDI_ESYSTEM;
 
   {
-    int (*streamOpenDelegate)(const char *filename, const char *filemode,
+    int (*streamOpenDelegate)(const char *filename, char filemode,
                               int filetype, stream_t *streamptr, int recordBufIsToBeCreated)
-      = (int (*)(const char *, const char *, int, stream_t *, int))
+      = (int (*)(const char *, char, int, stream_t *, int))
       namespaceSwitchGet(NSSWITCH_STREAM_OPEN_BACKEND).func;
 
     fileID = streamOpenDelegate(filename, filemode, filetype, streamptr, 1);
@@ -544,7 +543,7 @@ streamOpenID(const char *filename, const char *filemode, int filetype,
 
   if (fileID < 0)
     {
-      free(streamptr->record);
+      Free(streamptr->record);
       stream_delete_entry(streamptr);
       streamID = fileID;
     }
@@ -554,11 +553,11 @@ streamOpenID(const char *filename, const char *filemode, int filetype,
 
       if ( streamID < 0 ) return (CDI_ELIMIT);
 
-      streamptr->filemode = tolower(*filemode);
+      streamptr->filemode = filemode;
       streamptr->filename = strdupx(filename);
       streamptr->fileID   = fileID;
 
-      if ( streamptr->filemode == 'r' )
+      if ( filemode == 'r' )
 	{
 	  int vlistID = vlistCreate();
 	  if ( vlistID < 0 ) return(CDI_ELIMIT);
@@ -575,9 +574,11 @@ streamOpenID(const char *filename, const char *filemode, int filetype,
   return (streamID);
 }
 
-int streamOpen(const char *filename, const char *filemode, int filetype)
+static int streamOpen(const char *filename, const char *filemode, int filetype)
 {
-  return streamOpenID(filename, filemode, filetype, CDI_UNDEFID);
+  if (!filemode || strlen(filemode) != 1) return CDI_EINVAL;
+  return streamOpenID(filename, (char)tolower(filemode[0]),
+                      filetype, CDI_UNDEFID);
 }
 
 static int streamOpenA(const char *filename, const char *filemode, int filetype)
@@ -595,12 +596,12 @@ static int streamOpenA(const char *filename, const char *filemode, int filetype)
   if ( ! filename || ! filemode || filetype < 0 ) return (CDI_EINVAL);
 
   {
-    int (*streamOpenDelegate)(const char *filename, const char *filemode,
+    int (*streamOpenDelegate)(const char *filename, char filemode,
                               int filetype, stream_t *streamptr, int recordBufIsToBeCreated)
-      = (int (*)(const char *, const char *, int, stream_t *, int))
+      = (int (*)(const char *, char, int, stream_t *, int))
       namespaceSwitchGet(NSSWITCH_STREAM_OPEN_BACKEND).func;
 
-    fileID = streamOpenDelegate(filename, "r", filetype, streamptr, 1);
+    fileID = streamOpenDelegate(filename, 'r', filetype, streamptr, 1);
   }
 
   if ( fileID == CDI_UNDEFID || fileID == CDI_ELIBNAVAIL || fileID == CDI_ESYSTEM ) return (fileID);
@@ -822,8 +823,6 @@ int streamOpenWrite(const char *filename, int filetype)
 static
 void streamDefaultValue ( stream_t * streamptr )
 {
-  int i;
-
   streamptr->self              = CDI_UNDEFID;
   streamptr->accesstype        = CDI_UNDEFID;
   streamptr->accessmode        = 0;
@@ -861,15 +860,16 @@ void streamDefaultValue ( stream_t * streamptr )
 
   basetimeInit(&streamptr->basetime);
 
+  int i;
   for ( i = 0; i < MAX_GRIDS_PS; i++ ) streamptr->xdimID[i]   = CDI_UNDEFID;
   for ( i = 0; i < MAX_GRIDS_PS; i++ ) streamptr->ydimID[i]   = CDI_UNDEFID;
   for ( i = 0; i < MAX_ZAXES_PS; i++ ) streamptr->zaxisID[i]  = CDI_UNDEFID;
+  for ( i = 0; i < MAX_ZAXES_PS; i++ ) streamptr->nczvarID[i] = CDI_UNDEFID;
   for ( i = 0; i < MAX_GRIDS_PS; i++ ) streamptr->ncxvarID[i] = CDI_UNDEFID;
   for ( i = 0; i < MAX_GRIDS_PS; i++ ) streamptr->ncyvarID[i] = CDI_UNDEFID;
   for ( i = 0; i < MAX_GRIDS_PS; i++ ) streamptr->ncavarID[i] = CDI_UNDEFID;
 
   streamptr->gribContainers    = NULL;
-  streamptr->vlistIDorig       = CDI_UNDEFID;
 }
 
 
@@ -879,7 +879,7 @@ static stream_t *stream_new_entry(int resH)
 
   cdiInitialize(); /* ***************** make MT version !!! */
 
-  streamptr = (stream_t *) xmalloc(sizeof(stream_t));
+  streamptr = (stream_t *) Malloc(sizeof(stream_t));
   streamDefaultValue ( streamptr );
   if (resH == CDI_UNDEFID)
     streamptr->self = reshPut(streamptr, &streamOps);
@@ -959,6 +959,15 @@ cdiStreamCloseDefaultDelegate(stream_t *streamptr, int recordBufIsToBeDeleted)
 }
 
 
+static void deallocate_sleveltable_t(sleveltable_t *entry)
+{
+  if (entry->recordID) Free(entry->recordID);
+  if (entry->lindex)   Free(entry->lindex);
+  entry->recordID = NULL;
+  entry->lindex   = NULL;
+}
+
+
 /*
 @Function  streamClose
 @Title     Close an open dataset
@@ -975,7 +984,6 @@ The function @func{streamClose} closes an open dataset.
 void streamClose(int streamID)
 {
   int index;
-  int vlistID;
   stream_t *streamptr = stream_to_pointer(streamID);
 
   stream_check_ptr(__func__, streamptr);
@@ -983,7 +991,7 @@ void streamClose(int streamID)
   if ( CDI_Debug )
     Message("streamID = %d filename = %s", streamID, streamptr->filename);
 
-  vlistID  = streamptr->vlistID;
+  int vlistID  = streamptr->vlistID;
 
   void (*streamCloseDelegate)(stream_t *streamptr, int recordBufIsToBeDeleted)
     = (void (*)(stream_t *, int))
@@ -994,35 +1002,40 @@ void streamClose(int streamID)
   if ( streamptr->record )
     {
       if ( streamptr->record->buffer )
-        free(streamptr->record->buffer);
+        Free(streamptr->record->buffer);
 
-      free(streamptr->record);
+      Free(streamptr->record);
     }
 
   streamptr->filetype = 0;
-  if ( streamptr->filename ) free(streamptr->filename);
+  if ( streamptr->filename ) Free(streamptr->filename);
 
   for ( index = 0; index < streamptr->nvars; index++ )
     {
-      if ( streamptr->vars[index].level )
-	free(streamptr->vars[index].level);
-      if ( streamptr->vars[index].lindex )
-	free(streamptr->vars[index].lindex);
+      sleveltable_t *pslev = streamptr->vars[index].recordTable;
+      unsigned nsub = streamptr->vars[index].subtypeSize >= 0
+        ? (unsigned)streamptr->vars[index].subtypeSize : 0U;
+      for (size_t isub=0; isub < nsub; isub++)
+        {
+          deallocate_sleveltable_t(pslev + isub);
+        }
+      if (pslev) Free(pslev);
     }
-  free(streamptr->vars);
+  Free(streamptr->vars);
+  streamptr->vars = NULL;
 
   for ( index = 0; index < streamptr->ntsteps; ++index )
     {
       if ( streamptr->tsteps[index].records )
-	free(streamptr->tsteps[index].records);
+        Free(streamptr->tsteps[index].records);
       if ( streamptr->tsteps[index].recIDs )
-	free(streamptr->tsteps[index].recIDs);
+        Free(streamptr->tsteps[index].recIDs);
       taxisDestroyKernel(&streamptr->tsteps[index].taxis);
     }
 
-  if ( streamptr->tsteps ) free(streamptr->tsteps);
+  if ( streamptr->tsteps ) Free(streamptr->tsteps);
 
-  if ( streamptr->basetime.timevar_cache ) free(streamptr->basetime.timevar_cache);
+  if ( streamptr->basetime.timevar_cache ) Free(streamptr->basetime.timevar_cache);
 
   if ( vlistID != -1 )
     {
@@ -1046,7 +1059,7 @@ static void stream_delete_entry(stream_t *streamptr)
   xassert ( streamptr );
 
   idx = streamptr->self;
-  free ( streamptr );
+  Free( streamptr );
   reshRemove ( idx, &streamOps );
 
   if ( CDI_Debug )
@@ -1121,7 +1134,7 @@ void streamSync(int streamID)
 
 int cdiStreamDefTimestep_(stream_t *streamptr, int tsID)
 {
-  int taxisID;
+  int taxisID = 0;
 
   if ( CDI_Debug )
     Message("streamID = %d  tsID = %d", streamptr->self, tsID);
@@ -1342,7 +1355,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
     case FILETYPE_GRB2:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("grbReadVar not implemented for memtype float!");
-        grbReadVarDP(streamptr, varID, data, nmiss);
+        grbReadVarDP(streamptr, varID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -1350,7 +1363,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
     case FILETYPE_SRV:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("srvReadVar not implemented for memtype float!");
-        srvReadVarDP(streamptr, varID, data, nmiss);
+        srvReadVarDP(streamptr, varID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -1358,7 +1371,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
     case FILETYPE_EXT:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("extReadVar not implemented for memtype float!");
-        extReadVarDP(streamptr, varID, data, nmiss);
+        extReadVarDP(streamptr, varID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -1366,7 +1379,7 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
     case FILETYPE_IEG:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("iegReadVar not implemented for memtype float!");
-        iegReadVarDP(streamptr, varID, data, nmiss);
+        iegReadVarDP(streamptr, varID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -1377,9 +1390,9 @@ void cdiStreamReadVar(int streamID, int varID, int memtype, void *data, int *nmi
     case FILETYPE_NC4C:
       {
         if ( memtype == MEMTYPE_FLOAT )
-          cdfReadVarSP(streamptr, varID, data, nmiss);
+          cdfReadVarSP(streamptr, varID, (float *)data, nmiss);
         else
-          cdfReadVarDP(streamptr, varID, data, nmiss);
+          cdfReadVarDP(streamptr, varID, (double *)data, nmiss);
 
 	break;
       }
@@ -1444,6 +1457,8 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
   check_parg(data);
 
   stream_t *streamptr = stream_to_pointer(streamID);
+  if (subtypeInqActiveIndex(streamptr->vars[varID].subtypeID) != 0)
+    Error("Writing of non-trivial subtypes not yet implemented!");
 
   stream_check_ptr(__func__, streamptr);
 
@@ -1466,7 +1481,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
     case FILETYPE_SRV:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("srvWriteVar not implemented for memtype float!");
-        srvWriteVarDP(streamptr, varID, data);
+        srvWriteVarDP(streamptr, varID, (double *)data);
 	break;
       }
 #endif
@@ -1474,7 +1489,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
     case FILETYPE_EXT:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("extWriteVar not implemented for memtype float!");
-        extWriteVarDP(streamptr, varID, data);
+        extWriteVarDP(streamptr, varID, (double *)data);
 	break;
       }
 #endif
@@ -1482,7 +1497,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
     case FILETYPE_IEG:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("iegWriteVar not implemented for memtype float!");
-        iegWriteVarDP(streamptr, varID, data);
+        iegWriteVarDP(streamptr, varID, (double *)data);
 	break;
       }
 #endif
@@ -1493,7 +1508,7 @@ void cdiStreamWriteVar_(int streamID, int varID, int memtype, const void *data,
     case FILETYPE_NC4C:
       {
 	if ( streamptr->accessmode == 0 ) cdfEndDef(streamptr);
-        cdf_write_var(streamptr, varID, memtype, data, nmiss);
+        cdf_write_var(streamptr, varID, memtype, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -1583,7 +1598,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
     case FILETYPE_GRB2:
       {
         if ( memtype == MEMTYPE_FLOAT ) return 1;
-        grbReadVarSliceDP(streamptr, varID, levelID, data, nmiss);
+        grbReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -1591,7 +1606,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
     case FILETYPE_SRV:
       {
         if ( memtype == MEMTYPE_FLOAT ) return 1;
-        srvReadVarSliceDP(streamptr, varID, levelID, data, nmiss);
+        srvReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -1599,7 +1614,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
     case FILETYPE_EXT:
       {
         if ( memtype == MEMTYPE_FLOAT ) return 1;
-        extReadVarSliceDP(streamptr, varID, levelID, data, nmiss);
+        extReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -1607,7 +1622,7 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
     case FILETYPE_IEG:
       {
         if ( memtype == MEMTYPE_FLOAT ) return 1;
-        iegReadVarSliceDP(streamptr, varID, levelID, data, nmiss);
+        iegReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
 	break;
       }
 #endif
@@ -1618,9 +1633,9 @@ int cdiStreamReadVarSlice(int streamID, int varID, int levelID, int memtype, voi
     case FILETYPE_NC4C:
       {
         if ( memtype == MEMTYPE_FLOAT )
-          cdfReadVarSliceSP(streamptr, varID, levelID, data, nmiss);
+          cdfReadVarSliceSP(streamptr, varID, levelID, (float *)data, nmiss);
         else
-          cdfReadVarSliceDP(streamptr, varID, levelID, data, nmiss);
+          cdfReadVarSliceDP(streamptr, varID, levelID, (double *)data, nmiss);
         break;
       }
 #endif
@@ -1683,15 +1698,15 @@ from an open dataset.
 */
 void streamReadVarSliceF(int streamID, int varID, int levelID, float *data, int *nmiss)
 {
-  if ( cdiStreamReadVarSlice(streamID, varID,levelID, MEMTYPE_FLOAT, data, nmiss) )
+  if ( cdiStreamReadVarSlice(streamID, varID, levelID, MEMTYPE_FLOAT, data, nmiss) )
     {
       // In case the file format does not support single precision reading,
       // we fall back to double precision reading, converting the data on the fly.
       size_t elementCount = (size_t)gridInqSize(vlistInqVarGrid(streamInqVlist(streamID), varID));
-      double* conversionBuffer = malloc(elementCount * sizeof(*conversionBuffer));
+      double *conversionBuffer = (double *) Malloc(elementCount * sizeof(*conversionBuffer));
       streamReadVarSlice(streamID, varID, levelID, conversionBuffer, nmiss);
       for (size_t i = elementCount; i--; ) data[i] = (float)conversionBuffer[i];
-      free(conversionBuffer);
+      Free(conversionBuffer);
     }
 }
 
@@ -1703,6 +1718,8 @@ void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, c
   check_parg(data);
 
   stream_t *streamptr = stream_to_pointer(streamID);
+  if (subtypeInqActiveIndex(streamptr->vars[varID].subtypeID) != 0)
+    Error("Writing of non-trivial subtypes not yet implemented!");
 
   stream_check_ptr(__func__, streamptr);
 
@@ -1725,7 +1742,7 @@ void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, c
     case FILETYPE_SRV:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("srvWriteVarSlice not implemented for memtype float!");
-        srvWriteVarSliceDP(streamptr, varID, levelID, data);
+        srvWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
 	break;
       }
 #endif
@@ -1733,7 +1750,7 @@ void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, c
     case FILETYPE_EXT:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("extWriteVarSlice not implemented for memtype float!");
-        extWriteVarSliceDP(streamptr, varID, levelID, data);
+        extWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
 	break;
       }
 #endif
@@ -1741,7 +1758,7 @@ void cdiStreamWriteVarSlice(int streamID, int varID, int levelID, int memtype, c
     case FILETYPE_IEG:
       {
         if ( memtype == MEMTYPE_FLOAT ) Error("iegWriteVarSlice not implemented for memtype float!");
-        iegWriteVarSliceDP(streamptr, varID, levelID, data);
+        iegWriteVarSliceDP(streamptr, varID, levelID, (double *)data);
 	break;
       }
 #endif
@@ -1822,7 +1839,7 @@ streamWriteVarChunk(int streamID, int varID,
 
 /* single image implementation */
 void
-cdiStreamwriteVarChunk_(int streamID, int varID, int memtype,
+cdiStreamWriteVarChunk_(int streamID, int varID, int memtype,
                         const int rect[][2], const void *data, int nmiss)
 {
   if ( CDI_Debug ) Message("streamID = %d varID = %d", streamID, varID);
@@ -1871,6 +1888,7 @@ cdiStreamwriteVarChunk_(int streamID, int varID, int memtype,
     }
 }
 
+#if 0
 void streamWriteContents(int streamID, char *cname)
 {
   stream_t *streamptr = stream_to_pointer(streamID);
@@ -1966,6 +1984,7 @@ void streamWriteContents(int streamID, char *cname)
 
   fclose(cnp);
 }
+#endif
 
 // This function is used in CDO!
 off_t streamNvals(int streamID)
@@ -2007,7 +2026,7 @@ cdiStreamDefVlist_(int streamID, int vlistID)
   stream_check_ptr(__func__, streamptr);
 
   if ( streamptr->vlistID == CDI_UNDEFID )
-    cdiStreamSetupVlist(streamptr, vlistDuplicate(vlistID), vlistID);
+    cdiStreamSetupVlist(streamptr, vlistDuplicate(vlistID));
   else
     Warning("vlist already defined for %s!", streamptr->filename);
 }
@@ -2038,16 +2057,6 @@ int streamInqVlist(int streamID)
 }
 
 
-int streamInqVlistIDorig(int streamID)
-{
-  stream_t *streamptr = stream_to_pointer(streamID);
-
-  stream_check_ptr(__func__, streamptr);
-
-  return (streamptr->vlistIDorig);
-}
-
-
 void streamDefCompType(int streamID, int comptype)
 {
   stream_t *streamptr = stream_to_pointer(streamID);
@@ -2104,9 +2113,10 @@ int streamInqFileID(int streamID)
   return (streamptr->fileID);
 }
 
+
 void cdiDefAccesstype(int streamID, int type)
 {
-  stream_t *streamptr = reshGetVal(streamID, &streamOps);
+  stream_t *streamptr = (stream_t *)reshGetVal(streamID, &streamOps);
 
   if ( streamptr->accesstype == CDI_UNDEFID )
     {
@@ -2120,9 +2130,7 @@ void cdiDefAccesstype(int streamID, int type)
 
 int cdiInqAccesstype(int streamID)
 {
-  stream_t *streamptr;
-
-  streamptr = ( stream_t *) reshGetVal ( streamID, &streamOps );
+  stream_t *streamptr = (stream_t *) reshGetVal ( streamID, &streamOps );
 
   return (streamptr->accesstype);
 }
@@ -2133,24 +2141,33 @@ int streamTxCode(void)
   return STREAM;
 }
 
+void
+cdiStreamSetupVlist(stream_t *streamptr, int vlistID)
+{
+  void (*myStreamSetupVlist)(stream_t *streamptr, int vlistID)
+    = (void (*)(stream_t *, int))
+    namespaceSwitchGet(NSSWITCH_STREAM_SETUP_VLIST).func;
+  myStreamSetupVlist(streamptr, vlistID);
+}
 
-void cdiStreamSetupVlist(stream_t *streamptr, int vlistID, int vlistIDorig)
+void
+cdiStreamSetupVlist_(stream_t *streamptr, int vlistID)
 {
   vlist_lock(vlistID);
   int nvars = vlistNvars(vlistID);
   streamptr->vlistID = vlistID;
-  streamptr->vlistIDorig = vlistIDorig;
   for (int varID = 0; varID < nvars; varID++ )
     {
-      int gridID  = vlistInqVarGrid(vlistID, varID);
-      int zaxisID = vlistInqVarZaxis(vlistID, varID);
-      stream_new_var(streamptr, gridID, zaxisID);
+      int gridID    = vlistInqVarGrid(vlistID, varID);
+      int zaxisID   = vlistInqVarZaxis(vlistID, varID);
+      int tilesetID = vlistInqVarSubtype(vlistID, varID);
+      stream_new_var(streamptr, gridID, zaxisID, tilesetID);
       if ( streamptr->have_missval )
         vlistDefVarMissval(vlistID, varID,
                            vlistInqVarMissval(vlistID, varID));
     }
 
-  if (streamptr->filemode == 'w' )
+  if (streamptr->filemode == 'w')
     switch (streamptr->filetype)
       {
 #ifdef HAVE_LIBNETCDF
@@ -2174,14 +2191,14 @@ void cdiStreamSetupVlist(stream_t *streamptr, int vlistID, int vlistIDorig)
 }
 
 
-void cdiStreamGetIndexList(unsigned numIDs, int IDs[numIDs])
+void cdiStreamGetIndexList(unsigned numIDs, int *IDs)
 {
   reshGetResHListOfType(numIDs, IDs, &streamOps);
 }
 
 int streamInqNvars ( int streamID )
 {
-  stream_t *streamptr = reshGetVal(streamID, &streamOps);
+  stream_t *streamptr = (stream_t *)reshGetVal(streamID, &streamOps);
   return streamptr->nvars;
 }
 
@@ -2199,8 +2216,6 @@ static int streamCompareP(void * streamptr1, void * streamptr2)
   xassert ( s2 );
 
   if ( s1->filetype  != s2->filetype  ) return differ;
-  if (  namespaceAdaptKey2 ( s1->vlistIDorig ) !=
-	namespaceAdaptKey2 ( s2->vlistIDorig )) return differ;
   if ( s1->byteorder != s2->byteorder ) return differ;
   if ( s1->comptype  != s2->comptype  ) return differ;
   if ( s1->complevel != s2->complevel ) return differ;
@@ -2234,53 +2249,46 @@ void streamPrintP   ( void * streamptr, FILE * fp )
 
   if ( !sp ) return;
 
-  fprintf ( fp, "#\n");
-  fprintf ( fp, "# streamID %d\n", sp->self);
-  fprintf ( fp, "#\n");
-  fprintf ( fp, "self          = %d\n", sp->self );
-  fprintf ( fp, "accesstype    = %d\n", sp->accesstype );
-  fprintf ( fp, "accessmode    = %d\n", sp->accessmode );
-  fprintf ( fp, "filetype      = %d\n", sp->filetype );
-  fprintf ( fp, "byteorder     = %d\n", sp->byteorder );
-  fprintf ( fp, "fileID        = %d\n", sp->fileID );
-  fprintf ( fp, "filemode      = %d\n", sp->filemode );
-  fprintf ( fp, "//off_t numvals;\n" );
-  fprintf ( fp, "filename      = %s\n", sp->filename );
-  fprintf ( fp, "//Record   *record;\n" );
-  fprintf ( fp, "nrecs         = %d\n", sp->nrecs );
-  fprintf ( fp, "nvars         = %d\n", sp->nvars );
-  fprintf ( fp, "//svarinfo_t *vars;\n" );
-  fprintf ( fp, "varsAllocated = %d\n", sp->varsAllocated );
-  fprintf ( fp, "curTsID       = %d\n", sp->curTsID );
-  fprintf ( fp, "rtsteps       = %d\n", sp->rtsteps );
-  fprintf ( fp, "//long ntsteps;\n" );
-  fprintf ( fp, "//  tsteps_t   *tsteps;\n" );
-  fprintf ( fp, "tstepsTableSize= %d\n", sp->tstepsTableSize );
-  fprintf ( fp, "tstepsNextID  = %d\n", sp->tstepsNextID );
-  fprintf ( fp, "//basetime_t  basetime;\n" );
-  fprintf ( fp, "ncmode        = %d\n", sp->ncmode );
-  fprintf ( fp, "vlistID       = %d\n", sp->vlistID );
-  fprintf ( fp, "//  int       xdimID[MAX_GRIDS_PS];\n" );
-  fprintf ( fp, "//  int       ydimID[MAX_GRIDS_PS];\n" );
-  fprintf ( fp, "//  int       zaxisID[MAX_ZAXES_PS];\n" );
-  fprintf ( fp, "//  int       ncxvarID[MAX_GRIDS_PS];\n" );
-  fprintf ( fp, "//  int       ncyvarID[MAX_GRIDS_PS];\n" );
-  fprintf ( fp, "//  int       ncavarID[MAX_GRIDS_PS];\n" );
-  fprintf ( fp, "historyID     = %d\n", sp->historyID );
-  fprintf ( fp, "globalatts    = %d\n", sp->globalatts );
-  fprintf ( fp, "localatts     = %d\n", sp->localatts );
-  fprintf ( fp, "//  VCT       vct;\n" );
-  fprintf ( fp, "unreduced     = %d\n", sp->unreduced );
-  fprintf ( fp, "sortname      = %d\n", sp->sortname );
-  fprintf ( fp, "have_missval  = %d\n", sp->have_missval );
-  fprintf ( fp, "ztype         = %d\n", sp->comptype );
-  fprintf ( fp, "zlevel        = %d\n", sp->complevel );
-  fprintf ( fp, "//  void    **gribContainers;\n" );
-  fprintf ( fp, "vlistIDorig   = %d\n", sp->vlistIDorig );
+  fprintf(fp, "#\n"
+          "# streamID %d\n"
+          "#\n"
+          "self          = %d\n"
+          "accesstype    = %d\n"
+          "accessmode    = %d\n"
+          "filetype      = %d\n"
+          "byteorder     = %d\n"
+          "fileID        = %d\n"
+          "filemode      = %d\n"
+          "filename      = %s\n"
+          "nrecs         = %d\n"
+          "nvars         = %d\n"
+          "varsAllocated = %d\n"
+          "curTsID       = %d\n"
+          "rtsteps       = %d\n"
+          "ntsteps       = %ld\n"
+          "tstepsTableSize= %d\n"
+          "tstepsNextID  = %d\n"
+          "ncmode        = %d\n"
+          "vlistID       = %d\n"
+          "historyID     = %d\n"
+          "globalatts    = %d\n"
+          "localatts     = %d\n"
+          "unreduced     = %d\n"
+          "sortname      = %d\n"
+          "have_missval  = %d\n"
+          "ztype         = %d\n"
+          "zlevel        = %d\n",
+          sp->self, sp->self, sp->accesstype, sp->accessmode,
+          sp->filetype, sp->byteorder, sp->fileID, sp->filemode,
+          sp->filename, sp->nrecs, sp->nvars, sp->varsAllocated,
+          sp->curTsID, sp->rtsteps, sp->ntsteps, sp->tstepsTableSize,
+          sp->tstepsNextID, sp->ncmode, sp->vlistID, sp->historyID,
+          sp->globalatts, sp->localatts, sp->unreduced, sp->sortname,
+          sp->have_missval, sp->comptype, sp->complevel);
 }
 
 enum {
-  streamNint = 11,
+  streamNint = 10,
 };
 
 static int
@@ -2304,17 +2312,16 @@ streamPack(void * streamptr, void * packBuffer, int packBufferSize,
   stream_t * streamP = ( stream_t * ) streamptr;
   int intBuffer[streamNint];
 
-  intBuffer[0]  = streamP->self;
-  intBuffer[1]  = streamP->filetype;
-  intBuffer[2]  = (int)strlen(streamP->filename) + 1;
-  intBuffer[3]  = streamP->vlistID;
-  intBuffer[4]  = streamP->vlistIDorig;
-  intBuffer[5]  = streamP->byteorder;
-  intBuffer[6]  = streamP->comptype;
-  intBuffer[7]  = streamP->complevel;
-  intBuffer[8]  = streamP->unreduced;
-  intBuffer[9]  = streamP->sortname;
-  intBuffer[10] = streamP->have_missval;
+  intBuffer[0] = streamP->self;
+  intBuffer[1] = streamP->filetype;
+  intBuffer[2] = (int)strlen(streamP->filename) + 1;
+  intBuffer[3] = streamP->vlistID;
+  intBuffer[4] = streamP->byteorder;
+  intBuffer[5] = streamP->comptype;
+  intBuffer[6] = streamP->complevel;
+  intBuffer[7] = streamP->unreduced;
+  intBuffer[8] = streamP->sortname;
+  intBuffer[9] = streamP->have_missval;
 
   serializePack(intBuffer, streamNint, DATATYPE_INT, packBuffer, packBufferSize, packBufferPos, context);
   uint32_t d = cdiCheckSum(DATATYPE_INT, streamNint, intBuffer);
@@ -2330,7 +2337,7 @@ struct streamAssoc
 streamUnpack(char * unpackBuffer, int unpackBufferSize,
              int * unpackBufferPos, int originNamespace, void *context)
 {
-  int intBuffer[streamNint], streamID;
+  int intBuffer[streamNint];
   uint32_t d;
   char filename[CDI_MAX_NAME];
 
@@ -2347,19 +2354,22 @@ streamUnpack(char * unpackBuffer, int unpackBufferSize,
   serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                   &d, 1, DATATYPE_UINT32, context);
   xassert(d == cdiCheckSum(DATATYPE_TXT, intBuffer[2], filename));
-  int targetStreamID = namespaceAdaptKey(intBuffer[0], originNamespace);
-  streamID = streamOpenID(filename, "w", intBuffer[1], targetStreamID);
+  int targetStreamID = namespaceAdaptKey(intBuffer[0], originNamespace),
+    streamID = streamOpenID(filename, 'w', intBuffer[1], targetStreamID);
   xassert(streamID >= 0 && targetStreamID == streamID);
-  streamDefByteorder(streamID, intBuffer[5]);
-  streamDefCompType(streamID, intBuffer[6]);
-  streamDefCompLevel(streamID, intBuffer[7]);
+  streamDefByteorder(streamID, intBuffer[4]);
+  streamDefCompType(streamID, intBuffer[5]);
+  streamDefCompLevel(streamID, intBuffer[6]);
   stream_t *streamptr = stream_to_pointer(streamID);
-  streamptr->unreduced = intBuffer[8];
-  streamptr->sortname = intBuffer[9];
-  streamptr->have_missval = intBuffer[10];
-  struct streamAssoc retval = { streamID, intBuffer[3], intBuffer[4] };
+  streamptr->unreduced = intBuffer[7];
+  streamptr->sortname = intBuffer[8];
+  streamptr->have_missval = intBuffer[9];
+  struct streamAssoc retval = { streamID, intBuffer[3] };
   return retval;
 }
+
+
+
 /*
  * Local Variables:
  * c-file-style: "Java"
diff --git a/libcdi/src/stream_cdf.c b/libcdi/src/stream_cdf.c
index 5b98b3f..a832b97 100644
--- a/libcdi/src/stream_cdf.c
+++ b/libcdi/src/stream_cdf.c
@@ -21,11 +21,13 @@
 #include "gaussgrid.h"
 #include "cdi_int.h"
 #include "stream_cdf.h"
+#include "cdf.h"
 #include "cdf_int.h"
 #include "varscan.h"
 #include "vlist.h"
 
 //#define PROJECTION_TEST
+extern int CDI_cmor_mode;
 
 #undef  UNDEFID
 #define UNDEFID  CDI_UNDEFID
@@ -36,6 +38,8 @@ static void cdfDefGlobalAtts(stream_t *streamptr);
 static void cdfDefLocalAtts(stream_t *streamptr);
 #endif
 
+#define  BNDS_NAME  "bnds"
+
 #define  X_AXIS  1
 #define  Y_AXIS  2
 #define  Z_AXIS  3
@@ -58,8 +62,8 @@ ncdim_t;
 typedef struct {
   int      ncid;
   int      ignore;
-  int      isvar;
-  int      islon;
+  short    isvar;
+  short    islon;
   int      islat;
   int      islev;
   int      istime;
@@ -70,6 +74,8 @@ typedef struct {
   int      tabnum;
   int      climatology;
   int      bounds;
+  int      lformula;
+  int      lformulaterms;
   int      gridID;
   int      zaxisID;
   int      gridtype;
@@ -81,6 +87,7 @@ typedef struct {
   int      yvarid;
   int      zvarid;
   int      tvarid;
+  int      psvarid;
   int      ncoordvars;
   int      coordvarids[MAX_COORDVARS];
   int      nauxvars;
@@ -102,12 +109,12 @@ typedef struct {
   int      chunked;
   int      chunktype;
   int      natts;
-  int     *atts;
   int      deflate;
   int      lunsigned;
   int      lvalidrange;
-  size_t   vlen;
-  double  *vdata;
+  int     *atts;
+  size_t   vctsize;
+  double  *vct;
   double   missval;
   double   fillval;
   double   addoffset;
@@ -176,7 +183,7 @@ int isTimeAxisUnits(const char *timeunits)
   int status = FALSE;
 
   size_t len = strlen(timeunits);
-  tu = xmalloc((len+1)*sizeof(char));
+  tu = (char *) Malloc((len+1)*sizeof(char));
   memcpy(tu, timeunits, (len+1) * sizeof(char));
   ptu = tu;
 
@@ -200,7 +207,7 @@ int isTimeAxisUnits(const char *timeunits)
         }
     }
 
-  free(tu);
+  Free(tu);
 
   return (status);
 }
@@ -301,7 +308,7 @@ int setBaseTime(const char *timeunits, taxis_t *taxis)
   int timeunit;
 
   size_t len = strlen(timeunits);
-  tu = xmalloc((len+1) * sizeof (char));
+  tu = (char *) Malloc((len+1) * sizeof (char));
   memcpy(tu, timeunits, (len+1) * sizeof (char));
   ptu = tu;
 
@@ -358,7 +365,7 @@ int setBaseTime(const char *timeunits, taxis_t *taxis)
   (*taxis).type = timetype;
   (*taxis).unit = timeunit;
 
-  free(tu);
+  Free(tu);
 
   if ( CDI_Debug )
     Message("timetype = %d  unit = %d", timetype, timeunit);
@@ -367,7 +374,7 @@ int setBaseTime(const char *timeunits, taxis_t *taxis)
 }
 
 static
-void cdfGetAttInt(int fileID, int ncvarid, char *attname, int attlen, int *attint)
+void cdfGetAttInt(int fileID, int ncvarid, const char *attname, int attlen, int *attint)
 {
   nc_type atttype;
   size_t nc_attlen;
@@ -382,7 +389,7 @@ void cdfGetAttInt(int fileID, int ncvarid, char *attname, int attlen, int *attin
       int *pintatt = NULL;
 
       if ( (int)nc_attlen > attlen )
-        pintatt = (int *) malloc(nc_attlen * sizeof (int));
+        pintatt = (int *) Malloc(nc_attlen * sizeof (int));
       else
         pintatt = attint;
 
@@ -391,7 +398,7 @@ void cdfGetAttInt(int fileID, int ncvarid, char *attname, int attlen, int *attin
       if ( (int)nc_attlen > attlen )
         {
           memcpy(attint, pintatt, (size_t)attlen * sizeof (int));
-          free(pintatt);
+          Free(pintatt);
         }
     }
 }
@@ -412,7 +419,7 @@ void cdfGetAttDouble(int fileID, int ncvarid, char *attname, int attlen, double
       double *pdoubleatt = NULL;
 
       if ( (int)nc_attlen > attlen )
-        pdoubleatt = (double *) malloc(nc_attlen * sizeof (double));
+        pdoubleatt = (double *) Malloc(nc_attlen * sizeof (double));
       else
         pdoubleatt = attdouble;
 
@@ -421,13 +428,13 @@ void cdfGetAttDouble(int fileID, int ncvarid, char *attname, int attlen, double
       if ( (int)nc_attlen > attlen )
         {
           memcpy(attdouble, pdoubleatt, (size_t)attlen * sizeof (double));
-          free(pdoubleatt);
+          Free(pdoubleatt);
         }
     }
 }
 
 static
-void cdfGetAttText(int fileID, int ncvarid, char *attname, int attlen, char *atttext)
+void cdfGetAttText(int fileID, int ncvarid,const char *attname, int attlen, char *atttext)
 {
   nc_type atttype;
   size_t nc_attlen;
@@ -465,7 +472,7 @@ void cdfGetAttText(int fileID, int ncvarid, char *attname, int attlen, char *att
           if ( ssize > (size_t)attlen ) ssize = (size_t)attlen;
           memcpy(atttext, attbuf, ssize);
           atttext[ssize - 1] = 0;
-          free(attbuf);
+          Free(attbuf);
         }
       else
         {
@@ -487,7 +494,7 @@ int xtypeIsText(int xtype)
     isText = TRUE;
 #endif
 
-  return (isText);
+  return isText;
 }
 
 static
@@ -572,7 +579,7 @@ resizeBuf(void **buf, size_t *bufSize, size_t reqSize)
 {
   if (reqSize > *bufSize)
     {
-      *buf = xrealloc(*buf, reqSize);
+      *buf = Realloc(*buf, reqSize);
       *bufSize = reqSize;
     }
   return *buf;
@@ -618,10 +625,17 @@ void defineAttributes(int vlistID, int varID, int fileID, int ncvarID)
           double *attflt = (double *)resizeBuf(&attBuf, &attBufSize, attSize);
           vlistInqAttFlt(vlistID, varID, attname, attlen, attflt);
           len = (size_t)attlen;
-          cdf_put_att_double(fileID, ncvarID, attname, atttype == DATATYPE_FLT32 ? NC_FLOAT : NC_DOUBLE, len, attflt);
+          if ( atttype == DATATYPE_FLT32 )
+            {
+              float attflt_sp[len];
+              for ( size_t i = 0; i < len; ++i ) attflt_sp[i] = (float)attflt[i];
+              cdf_put_att_float(fileID, ncvarID, attname, NC_FLOAT, len, attflt_sp);
+            }
+          else
+            cdf_put_att_double(fileID, ncvarID, attname, NC_DOUBLE, len, attflt);
         }
     }
-  free(attBuf);
+  Free(attBuf);
 }
 
 
@@ -636,13 +650,13 @@ void cdfCopyRecord(stream_t *streamptr2, stream_t *streamptr1)
   int gridID   = vlistInqVarGrid(vlistID1, ivarID);
   int datasize = gridInqSize(gridID);
 
-  double *data = xmalloc((size_t)datasize * sizeof (double));
+  double *data = (double *) Malloc((size_t)datasize * sizeof (double));
 
   int nmiss;
   cdfReadRecord(streamptr1, data, &nmiss);
   cdf_write_record(streamptr2, memtype, data, nmiss);
 
-  free(data);
+  Free(data);
 }
 
 /* not used
@@ -894,13 +908,13 @@ int cdfDefTimeBounds(int fileID, int nctimevarid, int nctimedimid, char* taxis_n
 
   /* fprintf(stderr, "time has bounds\n"); */
 
-  if ( nc_inq_dimid(fileID, "bnds", &dims[1]) != NC_NOERR )
-    cdf_def_dim(fileID, "bnds", 2, &dims[1]);
+  if ( nc_inq_dimid(fileID, BNDS_NAME, &dims[1]) != NC_NOERR )
+    cdf_def_dim(fileID, BNDS_NAME, 2, &dims[1]);
 
   if ( taxis->climatology )
     {
-      strcpy(tmpstr, "climatology");
-      strcat(tmpstr, "_bnds");
+      strcpy(tmpstr, "climatology_");
+      strcat(tmpstr, BNDS_NAME);
       cdf_def_var(fileID, tmpstr, NC_DOUBLE, 2, dims, &time_bndsid);
 
       cdf_put_att_text(fileID, nctimevarid, "climatology", strlen(tmpstr), tmpstr);
@@ -908,7 +922,8 @@ int cdfDefTimeBounds(int fileID, int nctimevarid, int nctimedimid, char* taxis_n
   else
     {
       strcpy(tmpstr, taxis_name);
-      strcat(tmpstr, "_bnds");
+      strcat(tmpstr, "_");
+      strcat(tmpstr, BNDS_NAME);
       cdf_def_var(fileID, tmpstr, NC_DOUBLE, 2, dims, &time_bndsid);
 
       cdf_put_att_text(fileID, nctimevarid, "bounds", strlen(tmpstr), tmpstr);
@@ -933,20 +948,17 @@ void cdfDefTimeUnits(char *unitstr, taxis_t* taxis0, taxis_t* taxis)
     }
   else
     {
-      int year, month, day, hour, minute, second;
-      int rdate, rtime;
-      int timeunit;
-
-      timeunit = taxis->unit;
+      int timeunit = taxis->unit;
       if ( timeunit == -1 ) timeunit = TUNIT_HOUR;
-      rdate    = taxis->rdate;
-      rtime    = taxis->rtime;
+      int rdate    = taxis->rdate;
+      int rtime    = taxis->rtime;
       if ( rdate == -1 )
         {
           rdate  = taxis->vdate;
           rtime  = taxis->vtime;
         }
 
+      int year, month, day, hour, minute, second;
       cdiDecodeDate(rdate, &year, &month, &day);
       cdiDecodeTime(rtime, &hour, &minute, &second);
 
@@ -956,7 +968,7 @@ void cdfDefTimeUnits(char *unitstr, taxis_t* taxis0, taxis_t* taxis)
 	   timeunit == TUNIT_6HOURS  ||
 	   timeunit == TUNIT_12HOURS ) timeunit = TUNIT_HOUR;
 
-      sprintf(unitstr, "%s since %d-%02d-%02d %02d:%02d:%02d",
+      sprintf(unitstr, "%s since %d-%d-%d %02d:%02d:%02d",
               tunitNamePtr(timeunit), year, month, day, hour, minute, second);
     }
 }
@@ -1000,7 +1012,6 @@ void cdfDefCalendar(int fileID, int ncvarid, int calendar)
 static
 void cdfDefTime(stream_t* streamptr)
 {
-  int fileID;
   int time_varid;
   int time_dimid;
   int time_bndsid = -1;
@@ -1008,18 +1019,15 @@ void cdfDefTime(stream_t* streamptr)
   char tmpstr[CDI_MAX_NAME];
   char default_name[] = "time";
   char* taxis_name = default_name;
-  size_t len;
-  taxis_t* taxis;
 
   if ( streamptr->basetime.ncvarid != UNDEFID ) return;
 
-  fileID = streamptr->fileID;
+  int fileID = streamptr->fileID;
 
   if ( streamptr->ncmode == 0 ) streamptr->ncmode = 1;
-
   if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
 
-  taxis = &streamptr->tsteps[0].taxis;
+  taxis_t *taxis = &streamptr->tsteps[0].taxis;
 
   if ( taxis->name && taxis->name[0] ) taxis_name = taxis->name;
 
@@ -1044,7 +1052,7 @@ void cdfDefTime(stream_t* streamptr)
 
   cdfDefTimeUnits(unitstr, &streamptr->tsteps[0].taxis, taxis);
 
-  len = strlen(unitstr);
+  size_t len = strlen(unitstr);
   if ( len )
     {
       cdf_put_att_text(fileID, time_varid, "units", len, unitstr);
@@ -1083,6 +1091,8 @@ void cdfDefTime(stream_t* streamptr)
       if ( len ) cdf_put_att_text(fileID, leadtimeid, "units", len, unitstr);
     }
 
+  cdf_put_att_text(fileID, time_varid, "axis", 1, "T");
+
   if ( streamptr->ncmode == 2 ) cdf_enddef(fileID);
 }
 
@@ -1510,8 +1520,8 @@ void cdfDefXaxis(stream_t *streamptr, int gridID, int ndims)
           if ( gridInqXboundsPtr(gridID) || gridInqYboundsPtr(gridID) )
             {
               size_t nvertex = 2;
-              if ( nc_inq_dimid(fileID, "bnds", &nvdimID) != NC_NOERR )
-                cdf_def_dim(fileID, "bnds", nvertex, &nvdimID);
+              if ( nc_inq_dimid(fileID, BNDS_NAME, &nvdimID) != NC_NOERR )
+                cdf_def_dim(fileID, BNDS_NAME, nvertex, &nvdimID);
             }
         }
 
@@ -1530,7 +1540,8 @@ void cdfDefXaxis(stream_t *streamptr, int gridID, int ndims)
 
           if ( gridInqXboundsPtr(gridID) && nvdimID != UNDEFID )
             {
-              strcat(axisname, "_bnds");
+              strcat(axisname, "_");
+              strcat(axisname, BNDS_NAME);
               dimIDs[0] = dimID;
               dimIDs[1] = nvdimID;
               cdf_def_var(fileID, axisname, (nc_type) xtype, 2, dimIDs, &ncbvarid);
@@ -1640,8 +1651,8 @@ void cdfDefYaxis(stream_t *streamptr, int gridID, int ndims)
           if ( gridInqXboundsPtr(gridID) || gridInqYboundsPtr(gridID) )
             {
               size_t nvertex = 2;
-              if ( nc_inq_dimid(fileID, "bnds", &nvdimID) != NC_NOERR )
-                cdf_def_dim(fileID, "bnds", nvertex, &nvdimID);
+              if ( nc_inq_dimid(fileID, BNDS_NAME, &nvdimID) != NC_NOERR )
+                cdf_def_dim(fileID, BNDS_NAME, nvertex, &nvdimID);
             }
         }
 
@@ -1660,7 +1671,8 @@ void cdfDefYaxis(stream_t *streamptr, int gridID, int ndims)
 
           if ( gridInqYboundsPtr(gridID) && nvdimID != UNDEFID )
             {
-              strcat(axisname, "_bnds");
+              strcat(axisname, "_");
+              strcat(axisname, BNDS_NAME);
               dimIDs[0] = dimID;
               dimIDs[1] = nvdimID;
               cdf_def_var(fileID, axisname, (nc_type) xtype, 2, dimIDs, &ncbvarid);
@@ -1796,8 +1808,8 @@ void cdfDefCurvilinear(stream_t *streamptr, int gridID)
       if ( gridInqXboundsPtr(gridID) || gridInqYboundsPtr(gridID) )
         {
           size_t nvertex = 4;
-          if ( nc_inq_dimid(fileID, "vertices", &nvdimID) != NC_NOERR )
-            cdf_def_dim(fileID, "vertices", nvertex, &nvdimID);
+          if ( nc_inq_dimid(fileID, "nv4", &nvdimID) != NC_NOERR )
+            cdf_def_dim(fileID, "nv4", nvertex, &nvdimID);
         }
 
       dimIDs[0] = ydimID;
@@ -1820,7 +1832,8 @@ void cdfDefCurvilinear(stream_t *streamptr, int gridID)
 
           if ( gridInqXboundsPtr(gridID) && nvdimID != UNDEFID )
             {
-              strcat(xaxisname, "_vertices");
+              strcat(xaxisname, "_");
+              strcat(xaxisname, BNDS_NAME);
               dimIDs[0] = ydimID;
               dimIDs[1] = xdimID;
               dimIDs[2] = nvdimID;
@@ -1848,7 +1861,8 @@ void cdfDefCurvilinear(stream_t *streamptr, int gridID)
 
           if ( gridInqYboundsPtr(gridID) && nvdimID != UNDEFID )
             {
-              strcat(yaxisname, "_vertices");
+              strcat(yaxisname, "_");
+              strcat(yaxisname, BNDS_NAME);
               dimIDs[0] = ydimID;
               dimIDs[1] = xdimID;
               dimIDs[2] = nvdimID;
@@ -1861,16 +1875,16 @@ void cdfDefCurvilinear(stream_t *streamptr, int gridID)
 
       if ( gridInqAreaPtr(gridID) )
         {
-          char yaxisname[] = "cell_area";
-          char units[] = "m2";
-          char longname[] = "area of grid cell";
-          char stdname[] = "cell_area";
+          static const char yaxisname_[] = "cell_area";
+          static const char units[] = "m2";
+          static const char longname[] = "area of grid cell";
+          static const char stdname[] = "cell_area";
 
-          cdf_def_var(fileID, yaxisname, (nc_type) xtype, 2, dimIDs, &ncavarid);
+          cdf_def_var(fileID, yaxisname_, (nc_type) xtype, 2, dimIDs, &ncavarid);
 
-          cdf_put_att_text(fileID, ncavarid, "standard_name", strlen(stdname), stdname);
-          cdf_put_att_text(fileID, ncavarid, "long_name", strlen(longname), longname);
-          cdf_put_att_text(fileID, ncavarid, "units", strlen(units), units);
+          cdf_put_att_text(fileID, ncavarid, "standard_name", sizeof (stdname) - 1, stdname);
+          cdf_put_att_text(fileID, ncavarid, "long_name", sizeof (longname) - 1, longname);
+          cdf_put_att_text(fileID, ncavarid, "units", sizeof (units) - 1, units);
         }
 
       cdf_enddef(fileID);
@@ -2206,7 +2220,8 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID)
               int dimIDs[2];
               dimIDs[0] = dimID;
               dimIDs[1] = nvdimID;
-              strcat(xaxisname, "_vertices");
+              strcat(xaxisname, "_");
+              strcat(xaxisname, BNDS_NAME);
               cdf_def_var(fileID, xaxisname, (nc_type) xtype, 2, dimIDs, &ncbxvarid);
               cdfGridCompress(fileID, ncbxvarid, (int)dimlen, streamptr->filetype, streamptr->comptype);
 
@@ -2231,7 +2246,8 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID)
               int dimIDs[2];
               dimIDs[0] = dimID;
               dimIDs[1] = nvdimID;
-              strcat(yaxisname, "_vertices");
+              strcat(yaxisname, "_");
+              strcat(yaxisname, BNDS_NAME);
               cdf_def_var(fileID, yaxisname, (nc_type) xtype, 2, dimIDs, &ncbyvarid);
               cdfGridCompress(fileID, ncbyvarid, (int)dimlen, streamptr->filetype, streamptr->comptype);
 
@@ -2241,16 +2257,16 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID)
 
       if ( gridInqAreaPtr(gridID) )
         {
-          char yaxisname[] = "cell_area";
-          char units[] = "m2";
-          char longname[] = "area of grid cell";
-          char stdname[] = "cell_area";
+          static const char yaxisname_[] = "cell_area";
+          static const char units[] = "m2";
+          static const char longname[] = "area of grid cell";
+          static const char stdname[] = "cell_area";
 
-          cdf_def_var(fileID, yaxisname, (nc_type) xtype, 1, &dimID, &ncavarid);
+          cdf_def_var(fileID, yaxisname_, (nc_type) xtype, 1, &dimID, &ncavarid);
 
-          cdf_put_att_text(fileID, ncavarid, "standard_name", strlen(stdname), stdname);
-          cdf_put_att_text(fileID, ncavarid, "long_name", strlen(longname), longname);
-          cdf_put_att_text(fileID, ncavarid, "units", strlen(units), units);
+          cdf_put_att_text(fileID, ncavarid, "standard_name", sizeof (stdname) - 1, stdname);
+          cdf_put_att_text(fileID, ncavarid, "long_name", sizeof (longname) - 1, longname);
+          cdf_put_att_text(fileID, ncavarid, "units", sizeof (units) - 1, units);
         }
 
       cdf_enddef(fileID);
@@ -2269,17 +2285,13 @@ void cdfDefUnstructured(stream_t *streamptr, int gridID)
   streamptr->ncavarID[gridindex] = ncavarid;
 }
 
-
 static
-void cdfDefVCT(stream_t *streamptr, int zaxisID)
+void cdf_def_vct_echam(stream_t *streamptr, int zaxisID)
 {
-  int type;
+  int type = zaxisInqType(zaxisID);
 
-  type = zaxisInqType(zaxisID);
   if ( type == ZAXIS_HYBRID || type == ZAXIS_HYBRID_HALF )
     {
-      int i;
-      int fileID;
       int ilev = zaxisInqVctSize(zaxisID)/2;
       int mlev = ilev - 1;
       size_t start;
@@ -2302,7 +2314,7 @@ void cdfDefVCT(stream_t *streamptr, int zaxisID)
           return;
         }
 
-      fileID = streamptr->fileID;
+      int fileID = streamptr->fileID;
 
       if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
 
@@ -2344,7 +2356,7 @@ void cdfDefVCT(stream_t *streamptr, int zaxisID)
       cdf_put_var_double(fileID, hyaiid, vctptr);
       cdf_put_var_double(fileID, hybiid, vctptr+ilev);
 
-      for ( i = 0; i < mlev; i++ )
+      for ( int i = 0; i < mlev; i++ )
         {
           start = (size_t)i;
           mval = (vctptr[i] + vctptr[i+1]) * 0.5;
@@ -2355,6 +2367,277 @@ void cdfDefVCT(stream_t *streamptr, int zaxisID)
     }
 }
 
+static
+void cdf_def_vct_cf(stream_t *streamptr, int zaxisID, int nclevID, int ncbndsID)
+{
+  int type = zaxisInqType(zaxisID);
+
+  if ( type == ZAXIS_HYBRID || type == ZAXIS_HYBRID_HALF )
+    {
+      int ilev = zaxisInqVctSize(zaxisID)/2;
+      int mlev = ilev - 1;
+      int hyaiid = 0, hybiid = 0, hyamid, hybmid;
+      char tmpname[CDI_MAX_NAME];
+
+      if ( streamptr->vct.ilev > 0 )
+        {
+          if ( streamptr->vct.ilev != ilev )
+            Error("more than one VCT for each file unsupported!");
+          return;
+        }
+
+      if ( ilev == 0 )
+        {
+          Warning("VCT missing");
+          return;
+        }
+
+      int fileID = streamptr->fileID;
+
+      if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
+
+      int dimIDs[2];
+      dimIDs[0] = nclevID;
+      dimIDs[1] = ncbndsID;
+
+      streamptr->vct.mlev   = mlev;
+      streamptr->vct.ilev   = ilev;
+      streamptr->vct.mlevID = nclevID;
+      streamptr->vct.ilevID = nclevID;
+
+      cdf_def_var(fileID, "ap", NC_DOUBLE, 1, dimIDs,  &hyamid);
+      cdf_def_var(fileID, "b",  NC_DOUBLE, 1, dimIDs,  &hybmid);
+
+      strcpy(tmpname, "vertical coordinate formula term: ap(k)");
+      cdf_put_att_text(fileID, hyamid, "long_name", strlen(tmpname), tmpname);
+      strcpy(tmpname, "Pa");
+      cdf_put_att_text(fileID, hyamid, "units", strlen(tmpname), tmpname);
+      strcpy(tmpname, "vertical coordinate formula term: b(k)");
+      cdf_put_att_text(fileID, hybmid, "long_name", strlen(tmpname), tmpname);
+      strcpy(tmpname, "1");
+      cdf_put_att_text(fileID, hybmid, "units", strlen(tmpname), tmpname);
+
+      if ( ncbndsID != -1 )
+        {
+          cdf_def_var(fileID, "ap_bnds", NC_DOUBLE, 2, dimIDs, &hyaiid);
+          cdf_def_var(fileID, "b_bnds",  NC_DOUBLE, 2, dimIDs, &hybiid);
+
+          strcpy(tmpname, "vertical coordinate formula term: ap(k+1/2)");
+          cdf_put_att_text(fileID, hyaiid, "long_name", strlen(tmpname), tmpname);
+          strcpy(tmpname, "Pa");
+          cdf_put_att_text(fileID, hyaiid, "units", strlen(tmpname), tmpname);
+          strcpy(tmpname, "vertical coordinate formula term: b(k+1/2)");
+          cdf_put_att_text(fileID, hybiid, "long_name", strlen(tmpname), tmpname);
+          strcpy(tmpname, "1");
+          cdf_put_att_text(fileID, hybiid, "units", strlen(tmpname), tmpname);
+        }
+
+      cdf_enddef(fileID);
+      streamptr->ncmode = 2;
+
+      const double *vctptr = zaxisInqVctPtr(zaxisID);
+      double tarray[ilev*2];
+
+      if ( ncbndsID != -1 )
+        {
+          for ( int i = 0; i < mlev; ++i )
+            {
+              tarray[2*i  ] = vctptr[i];
+              tarray[2*i+1] = vctptr[i+1];
+            }
+          cdf_put_var_double(fileID, hyaiid, tarray);
+
+          for ( int i = 0; i < mlev; ++i )
+            {
+              tarray[2*i  ] = vctptr[ilev+i];
+              tarray[2*i+1] = vctptr[ilev+i+1];
+            }
+          cdf_put_var_double(fileID, hybiid, tarray);
+        }
+
+      for ( int i = 0; i < mlev; ++i )
+        tarray[i] = (vctptr[i] + vctptr[i+1]) * 0.5;
+      cdf_put_var_double(fileID, hyamid, tarray);
+
+      for ( int i = 0; i < mlev; ++i )
+        tarray[i] = (vctptr[ilev+i] + vctptr[ilev+i+1]) * 0.5;
+      cdf_put_var_double(fileID, hybmid, tarray);
+    }
+}
+
+static
+void cdf_def_zaxis_hybrid_echam(stream_t *streamptr, int type, int ncvarid, int zaxisID, int zaxisindex, int xtype, size_t dimlen, int *dimID, char *axisname)
+{
+  char tmpname[CDI_MAX_NAME];
+  int fileID  = streamptr->fileID;
+
+  if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
+
+  cdf_def_dim(fileID, axisname, dimlen, dimID);
+  cdf_def_var(fileID, axisname, (nc_type) xtype, 1, dimID,  &ncvarid);
+
+  strcpy(tmpname, "hybrid_sigma_pressure");
+  cdf_put_att_text(fileID, ncvarid, "standard_name", strlen(tmpname), tmpname);
+
+  if ( type == ZAXIS_HYBRID )
+    {
+      strcpy(tmpname, "hybrid level at layer midpoints");
+      cdf_put_att_text(fileID, ncvarid, "long_name", strlen(tmpname), tmpname);
+      strcpy(tmpname, "hyam hybm (mlev=hyam+hybm*aps)");
+      cdf_put_att_text(fileID, ncvarid, "formula", strlen(tmpname), tmpname);
+      strcpy(tmpname, "ap: hyam b: hybm ps: aps");
+      cdf_put_att_text(fileID, ncvarid, "formula_terms", strlen(tmpname), tmpname);
+    }
+  else
+    {
+      strcpy(tmpname, "hybrid level at layer interfaces");
+      cdf_put_att_text(fileID, ncvarid, "long_name", strlen(tmpname), tmpname);
+      strcpy(tmpname, "hyai hybi (ilev=hyai+hybi*aps)");
+      cdf_put_att_text(fileID, ncvarid, "formula", strlen(tmpname), tmpname);
+      strcpy(tmpname, "ap: hyai b: hybi ps: aps");
+      cdf_put_att_text(fileID, ncvarid, "formula_terms", strlen(tmpname), tmpname);
+    }
+
+  strcpy(tmpname, "level");
+  cdf_put_att_text(fileID, ncvarid, "units", strlen(tmpname), tmpname);
+  strcpy(tmpname, "down");
+  cdf_put_att_text(fileID, ncvarid, "positive", strlen(tmpname), tmpname);
+
+  cdf_enddef(fileID);
+  streamptr->ncmode = 2;
+
+  cdf_put_var_double(fileID, ncvarid, zaxisInqLevelsPtr(zaxisID));
+
+  cdf_def_vct_echam(streamptr, zaxisID);
+
+  if ( *dimID == UNDEFID )
+    {
+      if ( type == ZAXIS_HYBRID )
+        streamptr->zaxisID[zaxisindex] = streamptr->vct.mlevID;
+      else
+        streamptr->zaxisID[zaxisindex] = streamptr->vct.ilevID;
+    }
+}
+
+static
+void cdf_def_zaxis_hybrid_cf(stream_t *streamptr, int type, int ncvarid, int zaxisID, int zaxisindex, int xtype, size_t dimlen, int *dimID, char *axisname)
+{
+  char psname[CDI_MAX_NAME];
+  psname[0] = 0;
+  zaxisInqPsName(zaxisID, psname);
+  if ( psname[0] == 0 ) strcpy(psname, "ps");
+
+  int fileID = streamptr->fileID;
+  if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
+
+  strcpy(axisname, "lev");
+
+  cdf_def_dim(fileID, axisname, dimlen, dimID);
+  cdf_def_var(fileID, axisname, (nc_type) xtype, 1, dimID,  &ncvarid);
+
+  char tmpname[CDI_MAX_NAME];
+  strcpy(tmpname, "atmosphere_hybrid_sigma_pressure_coordinate");
+  cdf_put_att_text(fileID, ncvarid, "standard_name", strlen(tmpname), tmpname);
+
+  strcpy(tmpname, "hybrid sigma pressure coordinate");
+  cdf_put_att_text(fileID, ncvarid, "long_name", strlen(tmpname), tmpname);
+  strcpy(tmpname, "p = ap + b*ps");
+  cdf_put_att_text(fileID, ncvarid, "formula", strlen(tmpname), tmpname);
+  strcpy(tmpname, "ap: ap b: b ps: ");
+  strcat(tmpname, psname);
+  cdf_put_att_text(fileID, ncvarid, "formula_terms", strlen(tmpname), tmpname);
+
+  strcpy(tmpname, "1");
+  cdf_put_att_text(fileID, ncvarid, "units", strlen(tmpname), tmpname);
+  strcpy(tmpname, "Z");
+  cdf_put_att_text(fileID, ncvarid, "axis", strlen(tmpname), tmpname);
+  strcpy(tmpname, "down");
+  cdf_put_att_text(fileID, ncvarid, "positive", strlen(tmpname), tmpname);
+
+  int ncbvarid = UNDEFID;
+  int nvdimID = UNDEFID;
+
+  double lbounds[dimlen], ubounds[dimlen], levels[dimlen];
+
+  zaxisInqLevels(zaxisID, levels);
+
+  if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
+    {
+      zaxisInqLbounds(zaxisID, lbounds);
+      zaxisInqUbounds(zaxisID, ubounds);
+    }
+  else
+    {
+      for ( size_t i = 0; i < dimlen; ++i ) lbounds[i] = levels[i];
+      for ( size_t i = 0; i < dimlen-1; ++i ) ubounds[i] = levels[i+1];
+      ubounds[dimlen-1] = levels[dimlen-1] + 1;
+    }
+
+  //if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
+    {
+      int dimIDs[2];
+      size_t nvertex = 2;
+      if ( nc_inq_dimid(fileID, BNDS_NAME, &nvdimID) != NC_NOERR )
+        cdf_def_dim(fileID, BNDS_NAME, nvertex, &nvdimID);
+
+      if ( nvdimID != UNDEFID )
+        {
+          strcat(axisname, "_");
+          strcat(axisname, BNDS_NAME);
+          dimIDs[0] = *dimID;
+          dimIDs[1] = nvdimID;
+          cdf_def_var(fileID, axisname, (nc_type) xtype, 2, dimIDs, &ncbvarid);
+          cdf_put_att_text(fileID, ncvarid, "bounds", strlen(axisname), axisname);
+
+          strcpy(tmpname, "atmosphere_hybrid_sigma_pressure_coordinate");
+          cdf_put_att_text(fileID, ncbvarid, "standard_name", strlen(tmpname), tmpname);
+
+          strcpy(tmpname, "p = ap + b*ps");
+          cdf_put_att_text(fileID, ncbvarid, "formula", strlen(tmpname), tmpname);
+          strcpy(tmpname, "ap: ap_bnds b: b_bnds ps: ");
+          strcat(tmpname, psname);
+          cdf_put_att_text(fileID, ncbvarid, "formula_terms", strlen(tmpname), tmpname);
+
+          strcpy(tmpname, "1");
+          cdf_put_att_text(fileID, ncbvarid, "units", strlen(tmpname), tmpname);
+        }
+    }
+
+  cdf_enddef(fileID);
+  streamptr->ncmode = 2;
+
+  cdf_put_var_double(fileID, ncvarid, levels);
+
+  if ( ncbvarid != UNDEFID )
+    {
+      double zbounds[2*dimlen];
+      for ( size_t i = 0; i < dimlen; ++i )
+        {
+          zbounds[2*i  ] = lbounds[i];
+          zbounds[2*i+1] = ubounds[i];
+        }
+      cdf_put_var_double(fileID, ncbvarid, zbounds);
+    }
+
+  cdf_def_vct_cf(streamptr, zaxisID, *dimID, nvdimID);
+
+  if ( *dimID == UNDEFID )
+    {
+      if ( type == ZAXIS_HYBRID )
+        streamptr->zaxisID[zaxisindex] = streamptr->vct.mlevID;
+      else
+        streamptr->zaxisID[zaxisindex] = streamptr->vct.ilevID;
+    }
+}
+
+static
+void cdf_def_zaxis_hybrid(stream_t *streamptr, int type, int ncvarid, int zaxisID, int zaxisindex, int xtype, size_t dimlen, int *dimID, char *axisname)
+{
+  if ( (!CDI_cmor_mode && cdiConvention == CDI_CONVENTION_ECHAM) || type == ZAXIS_HYBRID_HALF )
+    cdf_def_zaxis_hybrid_echam(streamptr, type, ncvarid, zaxisID, zaxisindex, xtype, dimlen, dimID, axisname);
+  else
+    cdf_def_zaxis_hybrid_cf(streamptr, type, ncvarid, zaxisID, zaxisindex, xtype, dimlen, dimID, axisname);
+}
 
 static
 void cdfDefZaxis(stream_t *streamptr, int zaxisID)
@@ -2369,31 +2652,40 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
   int zaxisID0;
   int dimID = UNDEFID;
   int dimIDs[2];
-  int fileID;
   size_t len;
   int ncvarid = UNDEFID, ncbvarid = UNDEFID;
   int nvdimID = UNDEFID;
-  int type;
-  int nzaxis;
   int ilevel = 0;
-  int vlistID;
-  int zaxisindex;
   int xtype = NC_DOUBLE;
   int positive;
 
   if ( zaxisInqPrec(zaxisID) == DATATYPE_FLT32 ) xtype = NC_FLOAT;
 
-  vlistID = streamptr->vlistID;
-  fileID  = streamptr->fileID;
+  int vlistID = streamptr->vlistID;
+  int fileID  = streamptr->fileID;
 
-  zaxisindex = vlistZaxisIndex(vlistID, zaxisID);
+  int zaxisindex = vlistZaxisIndex(vlistID, zaxisID);
 
-  nzaxis = vlistNzaxis(vlistID);
+  int nzaxis = vlistNzaxis(vlistID);
 
   size_t dimlen = (size_t)zaxisInqSize(zaxisID);
-  type   = zaxisInqType(zaxisID);
+  int type   = zaxisInqType(zaxisID);
+
+  int is_scalar = FALSE;
+  if ( dimlen == 1 )
+    {
+      is_scalar = zaxisInqScalar(zaxisID);
+      if ( !is_scalar && CDI_cmor_mode )
+        {
+          is_scalar = TRUE;
+          zaxisDefScalar(zaxisID);
+        }
+    }
 
-  if (dimlen == 1)
+  int ndims = 1;
+  if ( is_scalar ) ndims = 0;
+
+  if ( dimlen == 1 )
     switch (type)
       {
       case ZAXIS_SURFACE:
@@ -2445,7 +2737,7 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
             {
               if ( ilevel )
                 {
-                  /* check that the name does not exist for other grids */
+                  /* check that the name does not exist for other zaxes */
                   for ( index = 0; index < nzaxis; index++ )
                     {
                       zaxisID0 = vlistZaxis(vlistID, index);
@@ -2475,82 +2767,19 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
 
       if ( type == ZAXIS_HYBRID || type == ZAXIS_HYBRID_HALF )
         {
-          if ( type == ZAXIS_HYBRID )
-            {
-	      if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
-
-	      cdf_def_dim(fileID, axisname, dimlen, &dimID);
-	      cdf_def_var(fileID, axisname, (nc_type) xtype, 1, &dimID,  &ncvarid);
-
-	      strcpy(tmpname, "hybrid_sigma_pressure");
-	      cdf_put_att_text(fileID, ncvarid, "standard_name", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "hybrid level at layer midpoints");
-	      cdf_put_att_text(fileID, ncvarid, "long_name", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "level");
-	      cdf_put_att_text(fileID, ncvarid, "units", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "down");
-	      cdf_put_att_text(fileID, ncvarid, "positive", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "hyam hybm (mlev=hyam+hybm*aps)");
-	      cdf_put_att_text(fileID, ncvarid, "formula", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "ap: hyam b: hybm ps: aps");
-	      cdf_put_att_text(fileID, ncvarid, "formula_terms", strlen(tmpname), tmpname);
-	      /*
-	      strcpy(tmpname, "ilev");
-	      cdf_put_att_text(fileID, ncvarid, "borders", strlen(tmpname), tmpname);
-	      */
-	      cdf_enddef(fileID);
-	      streamptr->ncmode = 2;
-
-	      cdf_put_var_double(fileID, ncvarid, zaxisInqLevelsPtr(zaxisID));
-            }
-
-          if ( type == ZAXIS_HYBRID_HALF )
-            {
-	      if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
-
-	      cdf_def_dim(fileID, axisname, dimlen, &dimID);
-	      cdf_def_var(fileID, axisname, (nc_type) xtype, 1, &dimID,  &ncvarid);
-
-	      strcpy(tmpname, "hybrid_sigma_pressure");
-	      cdf_put_att_text(fileID, ncvarid, "standard_name", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "hybrid level at layer interfaces");
-	      cdf_put_att_text(fileID, ncvarid, "long_name", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "level");
-	      cdf_put_att_text(fileID, ncvarid, "units", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "down");
-	      cdf_put_att_text(fileID, ncvarid, "positive", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "hyai hybi (ilev=hyai+hybi*aps)");
-	      cdf_put_att_text(fileID, ncvarid, "formula", strlen(tmpname), tmpname);
-	      strcpy(tmpname, "ap: hyai b: hybi ps: aps");
-	      cdf_put_att_text(fileID, ncvarid, "formula_terms", strlen(tmpname), tmpname);
-
-	      cdf_enddef(fileID);
-	      streamptr->ncmode = 2;
-
-	      cdf_put_var_double(fileID, ncvarid, zaxisInqLevelsPtr(zaxisID));
-            }
-
-          cdfDefVCT(streamptr, zaxisID);
-
-          if ( dimID == UNDEFID )
-            {
-              if ( type == ZAXIS_HYBRID )
-                streamptr->zaxisID[zaxisindex] = streamptr->vct.mlevID;
-              else
-                streamptr->zaxisID[zaxisindex] = streamptr->vct.ilevID;
-            }
+          cdf_def_zaxis_hybrid(streamptr, type, ncvarid, zaxisID, zaxisindex, xtype, dimlen, &dimID, axisname);
         }
       else
         {
           if ( streamptr->ncmode == 2 ) cdf_redef(fileID);
 
-          cdf_def_dim(fileID, axisname, dimlen, &dimID);
+          if ( ndims ) cdf_def_dim(fileID, axisname, dimlen, &dimID);
 
           zaxisInqLongname(zaxisID, longname);
           zaxisInqUnits(zaxisID, units);
           zaxisInqStdname(zaxisID, stdname);
 
-          cdf_def_var(fileID, axisname, (nc_type) xtype, 1, &dimID, &ncvarid);
+          cdf_def_var(fileID, axisname, (nc_type) xtype, ndims, &dimID, &ncvarid);
 
           if ( (len = strlen(stdname)) )
             cdf_put_att_text(fileID, ncvarid, "standard_name", len, stdname);
@@ -2576,15 +2805,16 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
 	  if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
             {
               size_t nvertex = 2;
-	      if ( nc_inq_dimid(fileID, "bnds", &nvdimID) != NC_NOERR )
-		cdf_def_dim(fileID, "bnds", nvertex, &nvdimID);
+	      if ( nc_inq_dimid(fileID, BNDS_NAME, &nvdimID) != NC_NOERR )
+		cdf_def_dim(fileID, BNDS_NAME, nvertex, &nvdimID);
 
 	      if ( nvdimID != UNDEFID )
 		{
-		  strcat(axisname, "_bnds");
-		  dimIDs[0] = dimID;
-		  dimIDs[1] = nvdimID;
-		  cdf_def_var(fileID, axisname, (nc_type) xtype, 2, dimIDs, &ncbvarid);
+		  strcat(axisname, "_");
+		  strcat(axisname, BNDS_NAME);
+		  if ( ndims ) dimIDs[0] = dimID;
+		  dimIDs[ndims] = nvdimID;
+		  cdf_def_var(fileID, axisname, (nc_type) xtype, ndims+1, dimIDs, &ncbvarid);
 		  cdf_put_att_text(fileID, ncvarid, "bounds", strlen(axisname), axisname);
 		}
 	    }
@@ -2596,27 +2826,19 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
 
           if ( ncbvarid != UNDEFID )
 	    {
-	      double *zbounds, *lbounds, *ubounds;
-
-	      lbounds = (double *) malloc(dimlen*sizeof(double));
-	      ubounds = (double *) malloc(dimlen*sizeof(double));
-	      zbounds = (double *) malloc(2*dimlen*sizeof(double));
-
+              double lbounds[dimlen], ubounds[dimlen], zbounds[2*dimlen];
 	      zaxisInqLbounds(zaxisID, lbounds);
 	      zaxisInqUbounds(zaxisID, ubounds);
-
-	      for (size_t i = 0; i < dimlen; ++i )
+	      for ( size_t i = 0; i < dimlen; ++i )
 		{
 		  zbounds[2*i  ] = lbounds[i];
 		  zbounds[2*i+1] = ubounds[i];
 		}
 
 	      cdf_put_var_double(fileID, ncbvarid, zbounds);
-
-	      free(zbounds);
-	      free(ubounds);
-	      free(lbounds);
 	    }
+
+          if ( ndims == 0 ) streamptr->nczvarID[zaxisindex] = ncvarid;
         }
     }
 
@@ -2624,27 +2846,23 @@ void cdfDefZaxis(stream_t *streamptr, int zaxisID)
     streamptr->zaxisID[zaxisindex] = dimID;
 }
 
-
 static
 void cdfDefPole(stream_t *streamptr, int gridID)
 {
-  int fileID;
   int ncvarid = UNDEFID;
-  int ncerr;
-  double xpole, ypole, angle;
   char varname[] = "rotated_pole";
   char mapname[] = "rotated_latitude_longitude";
 
-  fileID  = streamptr->fileID;
+  int fileID  = streamptr->fileID;
 
-  ypole = gridInqYpole(gridID);
-  xpole = gridInqXpole(gridID);
-  angle = gridInqAngle(gridID);
+  double ypole = gridInqYpole(gridID);
+  double xpole = gridInqXpole(gridID);
+  double angle = gridInqAngle(gridID);
 
   cdf_redef(fileID);
 
-  ncerr = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
-  if ( ncerr == NC_NOERR )
+  int ncerrcode = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
+  if ( ncerrcode == NC_NOERR )
     {
       cdf_put_att_text(fileID, ncvarid, "grid_mapping_name", strlen(mapname), mapname);
       cdf_put_att_double(fileID, ncvarid, "grid_north_pole_latitude", NC_DOUBLE, 1, &ypole);
@@ -2660,21 +2878,18 @@ void cdfDefPole(stream_t *streamptr, int gridID)
 static
 void cdfDefMapping(stream_t *streamptr, int gridID)
 {
-  int fileID;
   int ncvarid = UNDEFID;
-  int ncerr;
+  int fileID  = streamptr->fileID;
 
   if ( gridInqType(gridID) == GRID_SINUSOIDAL )
     {
       char varname[] = "sinusoidal";
       char mapname[] = "sinusoidal";
 
-      fileID  = streamptr->fileID;
-
       cdf_redef(fileID);
 
-      ncerr = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
-      if ( ncerr == NC_NOERR )
+      int ncerrcode = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
+      if ( ncerrcode == NC_NOERR )
         {
           cdf_put_att_text(fileID, ncvarid, "grid_mapping_name", strlen(mapname), mapname);
           /*
@@ -2690,12 +2905,10 @@ void cdfDefMapping(stream_t *streamptr, int gridID)
       char varname[] = "laea";
       char mapname[] = "lambert_azimuthal_equal_area";
 
-      fileID  = streamptr->fileID;
-
       cdf_redef(fileID);
 
-      ncerr = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
-      if ( ncerr == NC_NOERR )
+      int ncerrcode = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
+      if ( ncerrcode == NC_NOERR )
         {
           double a, lon_0, lat_0;
 
@@ -2714,12 +2927,10 @@ void cdfDefMapping(stream_t *streamptr, int gridID)
       char varname[] = "Lambert_Conformal";
       char mapname[] = "lambert_conformal_conic";
 
-      fileID  = streamptr->fileID;
-
       cdf_redef(fileID);
 
-      ncerr = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
-      if ( ncerr == NC_NOERR )
+      int ncerrcode = nc_def_var(fileID, varname, (nc_type) NC_CHAR, 0, NULL, &ncvarid);
+      if ( ncerrcode == NC_NOERR )
         {
           double radius, lon_0, lat_0, lat_1, lat_2;
 
@@ -2749,16 +2960,12 @@ void cdfDefMapping(stream_t *streamptr, int gridID)
 static
 void cdfDefGrid(stream_t *streamptr, int gridID)
 {
-  int gridtype, size;
-  int gridindex;
-  int vlistID;
-
-  vlistID = streamptr->vlistID;
-  gridindex = vlistGridIndex(vlistID, gridID);
+  int vlistID = streamptr->vlistID;
+  int gridindex = vlistGridIndex(vlistID, gridID);
   if ( streamptr->xdimID[gridindex] != UNDEFID ) return;
 
-  gridtype = gridInqType(gridID);
-  size     = gridInqSize(gridID);
+  int gridtype = gridInqType(gridID);
+  int size     = gridInqSize(gridID);
 
   if ( CDI_Debug )
     Message("gridtype = %d  size = %d", gridtype, size);
@@ -2849,63 +3056,49 @@ void cdfDefGrid(stream_t *streamptr, int gridID)
     }
 }
 
-
 static
 int cdfDefVar(stream_t *streamptr, int varID)
 {
   int ncvarid = -1;
-  int fileID;
-  int xid = UNDEFID, yid = UNDEFID, zid = UNDEFID, tid = UNDEFID;
+  int xid = UNDEFID, yid = UNDEFID;
   size_t xsize = 0, ysize = 0;
-  int code, param, gridID, zaxisID;
-  int pnum, pcat, pdis;
   char varname[CDI_MAX_NAME];
-  const char *name = NULL;
-  const char *longname = NULL;
-  const char *stdname = NULL;
-  const char *units = NULL;
   int dims[4];
   int lchunk = FALSE;
-  int chunktype;
   size_t chunks[4] = {0,0,0,0};
-  int tableID;
   int ndims = 0;
-  int tsteptype;
-  int xtype, dtype;
-  int gridtype, gridsize;
-  int gridindex, zaxisindex;
   int tablenum;
-  int vlistID;
   int dimorder[3];
   size_t iax = 0;
   char axis[5];
   int ensID, ensCount, forecast_type;
   int retval;
 
-  fileID  = streamptr->fileID;
+  int fileID  = streamptr->fileID;
 
   if ( CDI_Debug )
     Message("streamID = %d, fileID = %d, varID = %d", streamptr->self, fileID, varID);
 
   if ( streamptr->vars[varID].ncvarid != UNDEFID )
-    return (streamptr->vars[varID].ncvarid);
+    return streamptr->vars[varID].ncvarid;
 
-  vlistID   = streamptr->vlistID;
-  gridID    = vlistInqVarGrid(vlistID, varID);
-  zaxisID   = vlistInqVarZaxis(vlistID, varID);
-  tsteptype = vlistInqVarTsteptype(vlistID, varID);
-  code      = vlistInqVarCode(vlistID, varID);
-  param     = vlistInqVarParam(vlistID, varID);
+  int vlistID   = streamptr->vlistID;
+  int gridID    = vlistInqVarGrid(vlistID, varID);
+  int zaxisID   = vlistInqVarZaxis(vlistID, varID);
+  int tsteptype = vlistInqVarTsteptype(vlistID, varID);
+  int code      = vlistInqVarCode(vlistID, varID);
+  int param     = vlistInqVarParam(vlistID, varID);
+  int pnum, pcat, pdis;
   cdiDecodeParam(param, &pnum, &pcat, &pdis);
 
-  chunktype = vlistInqVarChunkType(vlistID, varID);
+  int chunktype = vlistInqVarChunkType(vlistID, varID);
 
   vlistInqVarDimorder(vlistID, varID, &dimorder);
 
-  gridsize  = gridInqSize(gridID);
+  int gridsize  = gridInqSize(gridID);
   if ( gridsize > 1 ) lchunk = TRUE;
-  gridtype  = gridInqType(gridID);
-  gridindex = vlistGridIndex(vlistID, gridID);
+  int gridtype  = gridInqType(gridID);
+  int gridindex = vlistGridIndex(vlistID, gridID);
   if ( gridtype != GRID_TRAJECTORY )
     {
       xid = streamptr->xdimID[gridindex];
@@ -2914,8 +3107,10 @@ int cdfDefVar(stream_t *streamptr, int varID)
       if ( yid != UNDEFID ) cdf_inq_dimlen(fileID, yid, &ysize);
     }
 
-  zaxisindex = vlistZaxisIndex(vlistID, zaxisID);
-  zid = streamptr->zaxisID[zaxisindex];
+  int zaxisindex = vlistZaxisIndex(vlistID, zaxisID);
+  int zid = streamptr->zaxisID[zaxisindex];
+  int zaxis_is_scalar = FALSE;
+  if ( zid == UNDEFID ) zaxis_is_scalar = zaxisInqScalar(zaxisID);
 
   if ( dimorder[0] != 3 ) lchunk = FALSE; /* ZYX and ZXY */
 
@@ -2925,7 +3120,7 @@ int cdfDefVar(stream_t *streamptr, int varID)
       Error("Internal problem, dimension order missing!");
     }
 
-  tid = streamptr->basetime.ncdimid;
+  int tid = streamptr->basetime.ncdimid;
 
   if ( tsteptype != TSTEP_CONSTANT )
     {
@@ -2974,12 +3169,12 @@ int cdfDefVar(stream_t *streamptr, int varID)
   if ( CDI_Debug )
     fprintf(stderr, "chunktype %d  chunks %d %d %d %d\n", chunktype, (int)chunks[0], (int)chunks[1], (int)chunks[2], (int)chunks[3]);
 
-  tableID  = vlistInqVarTable(vlistID, varID);
+  int tableID  = vlistInqVarTable(vlistID, varID);
 
-  name     = vlistInqVarNamePtr(vlistID, varID);
-  longname = vlistInqVarLongnamePtr(vlistID, varID);
-  stdname  = vlistInqVarStdnamePtr(vlistID, varID);
-  units    = vlistInqVarUnitsPtr(vlistID, varID);
+  const char *name     = vlistInqVarNamePtr(vlistID, varID);
+  const char *longname = vlistInqVarLongnamePtr(vlistID, varID);
+  const char *stdname  = vlistInqVarStdnamePtr(vlistID, varID);
+  const char *units    = vlistInqVarUnitsPtr(vlistID, varID);
 
   if ( name     == NULL )     name = tableInqParNamePtr(tableID, code);
   if ( longname == NULL ) longname = tableInqParLongnamePtr(tableID, code);
@@ -3022,11 +3217,6 @@ int cdfDefVar(stream_t *streamptr, int varID)
     }
   else
     {
-      int checkname;
-      int iz;
-      int status;
-      char *varname2;
-
       if ( code < 0 ) code = -code;
       if ( pnum < 0 ) pnum = -pnum;
 
@@ -3035,16 +3225,16 @@ int cdfDefVar(stream_t *streamptr, int varID)
       else
 	sprintf(varname, "param%d.%d.%d", pnum, pcat, pdis);
 
-      varname2 = varname+strlen(varname);
+      char *varname2 = varname+strlen(varname);
 
-      checkname = TRUE;
-      iz = 0;
+      int checkname = TRUE;
+      int iz = 0;
 
       while ( checkname )
         {
           if ( iz ) sprintf(varname2, "_%d", iz+1);
 
-          status = nc_inq_varid(fileID, varname, &ncvarid);
+          int status = nc_inq_varid(fileID, varname, &ncvarid);
           if ( status != NC_NOERR ) checkname = FALSE;
 
           if ( checkname ) iz++;
@@ -3059,8 +3249,8 @@ int cdfDefVar(stream_t *streamptr, int varID)
 
   /* if ( streamptr->ncmode == 2 ) cdf_redef(fileID); */
 
-  dtype = vlistInqVarDatatype(vlistID, varID);
-  xtype = cdfDefDatatype(dtype, streamptr->filetype);
+  int dtype = vlistInqVarDatatype(vlistID, varID);
+  int xtype = cdfDefDatatype(dtype, streamptr->filetype);
 
   cdf_def_var(fileID, name, (nc_type) xtype, ndims, dims, &ncvarid);
 
@@ -3151,6 +3341,20 @@ int cdfDefVar(stream_t *streamptr, int varID)
         cdf_put_att_int(fileID, ncvarid, "table", NC_INT, 1, &tablenum);
     }
 
+  char coordinates[CDI_MAX_NAME];
+  coordinates[0] = 0;
+
+  if ( zaxis_is_scalar )
+    {
+      int nczvarID = streamptr->nczvarID[zaxisindex];
+      if ( nczvarID != CDI_UNDEFID )
+        {
+          size_t len = strlen(coordinates);
+          if ( len ) coordinates[len++] = ' ';
+          cdf_inq_varname(fileID, nczvarID, coordinates+len);
+        }
+    }
+
   if ( gridtype != GRID_GENERIC && gridtype != GRID_LONLAT  && gridtype != GRID_CURVILINEAR )
     {
       size_t len = strlen(gridNamePtr(gridtype));
@@ -3185,53 +3389,43 @@ int cdfDefVar(stream_t *streamptr, int varID)
     }
   else if ( gridtype == GRID_LONLAT && xid == UNDEFID && yid == UNDEFID && gridsize == 1 )
     {
-      char coordinates[CDI_MAX_NAME] = "";
-      int ncxvarID, ncyvarID;
-      int gridindex;
-      size_t len;
-
-      gridindex = vlistGridIndex(vlistID, gridID);
-      ncxvarID = streamptr->ncxvarID[gridindex];
-      ncyvarID = streamptr->ncyvarID[gridindex];
-      if ( ncxvarID != CDI_UNDEFID )
-        cdf_inq_varname(fileID, ncxvarID, coordinates);
-      len = strlen(coordinates);
+      int ncxvarID = streamptr->ncxvarID[gridindex];
+      int ncyvarID = streamptr->ncyvarID[gridindex];
       if ( ncyvarID != CDI_UNDEFID )
         {
+          size_t len = strlen(coordinates);
           if ( len ) coordinates[len++] = ' ';
           cdf_inq_varname(fileID, ncyvarID, coordinates+len);
         }
-      len = strlen(coordinates);
-      if ( len )
-        cdf_put_att_text(fileID, ncvarid, "coordinates", len, coordinates);
+      if ( ncxvarID != CDI_UNDEFID )
+        {
+          size_t len = strlen(coordinates);
+          if ( len ) coordinates[len++] = ' ';
+          cdf_inq_varname(fileID, ncxvarID, coordinates+len);
+        }
     }
   else if ( gridtype == GRID_UNSTRUCTURED || gridtype == GRID_CURVILINEAR )
     {
-      char coordinates[CDI_MAX_NAME] = "";
       char cellarea[CDI_MAX_NAME] = "area: ";
-      int ncxvarID, ncyvarID, ncavarID;
-      int gridindex;
-      size_t len;
-
-      gridindex = vlistGridIndex(vlistID, gridID);
-      ncxvarID = streamptr->ncxvarID[gridindex];
-      ncyvarID = streamptr->ncyvarID[gridindex];
-      ncavarID = streamptr->ncavarID[gridindex];
-      if ( ncxvarID != CDI_UNDEFID )
-        cdf_inq_varname(fileID, ncxvarID, coordinates);
-      len = strlen(coordinates);
+      int ncxvarID = streamptr->ncxvarID[gridindex];
+      int ncyvarID = streamptr->ncyvarID[gridindex];
+      int ncavarID = streamptr->ncavarID[gridindex];
       if ( ncyvarID != CDI_UNDEFID )
         {
+          size_t len = strlen(coordinates);
           if ( len ) coordinates[len++] = ' ';
           cdf_inq_varname(fileID, ncyvarID, coordinates+len);
         }
-      len = strlen(coordinates);
-      if ( len )
-        cdf_put_att_text(fileID, ncvarid, "coordinates", len, coordinates);
+      if ( ncxvarID != CDI_UNDEFID )
+        {
+          size_t len = strlen(coordinates);
+          if ( len ) coordinates[len++] = ' ';
+          cdf_inq_varname(fileID, ncxvarID, coordinates+len);
+        }
 
       if ( ncavarID != CDI_UNDEFID )
         {
-          len = strlen(cellarea);
+          size_t len = strlen(cellarea);
           cdf_inq_varname(fileID, ncavarID, cellarea+len);
           len = strlen(cellarea);
           cdf_put_att_text(fileID, ncvarid, "cell_measures", len, cellarea);
@@ -3247,13 +3441,15 @@ int cdfDefVar(stream_t *streamptr, int varID)
   else if ( gridtype == GRID_SPECTRAL || gridtype == GRID_FOURIER )
     {
       int gridTruncation = gridInqTrunc(gridID);
-
       axis[iax++] = '-';
       axis[iax++] = '-';
       cdf_put_att_text(fileID, ncvarid, "axis", iax, axis);
       cdf_put_att_int(fileID, ncvarid, "truncation", NC_INT, 1, &gridTruncation);
     }
 
+  size_t len = strlen(coordinates);
+  if ( len ) cdf_put_att_text(fileID, ncvarid, "coordinates", len, coordinates);
+
   /*  if ( xtype == NC_BYTE || xtype == NC_SHORT || xtype == NC_INT ) */
     {
       int laddoffset, lscalefactor;
@@ -3334,7 +3530,7 @@ int cdfDefVar(stream_t *streamptr, int varID)
 
   /* if ( streamptr->ncmode == 2 ) cdf_enddef(fileID); */
 
-  return (ncvarid);
+  return ncvarid;
 }
 
 static
@@ -3607,7 +3803,6 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
   const float *pdata_sp = (const float *) data;
   float *mdata_sp = NULL;
   float *sdata_sp = NULL;
-  extern int CDF_Debug;
 
   /*  if ( dtype == DATATYPE_INT8 || dtype == DATATYPE_INT16 || dtype == DATATYPE_INT32 ) */
     {
@@ -3626,7 +3821,7 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
         {
           if ( memtype == MEMTYPE_FLOAT )
             {
-              mdata_sp = (float *) malloc((size_t)nvals*sizeof(float));
+              mdata_sp = (float *) Malloc((size_t)nvals*sizeof(float));
               memcpy(mdata_sp, pdata_sp, (size_t)nvals * sizeof (float));
               pdata_sp = mdata_sp;
 
@@ -3656,7 +3851,7 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
             }
           else
             {
-              mdata_dp = (double *) malloc((size_t)nvals * sizeof(double));
+              mdata_dp = (double *) Malloc((size_t)nvals * sizeof(double));
               memcpy(mdata_dp, pdata_dp, (size_t)nvals * sizeof(double));
               pdata_dp = mdata_dp;
 
@@ -3689,7 +3884,7 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
             {
               if ( mdata_sp == NULL )
                 {
-                  mdata_sp = (float *) malloc((size_t)nvals * sizeof(float));
+                  mdata_sp = (float *) Malloc((size_t)nvals * sizeof(float));
                   memcpy(mdata_sp, pdata_sp, (size_t)nvals * sizeof(float));
                   pdata_sp = mdata_sp;
                 }
@@ -3711,7 +3906,7 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
             {
               if ( mdata_dp == NULL )
                 {
-                  mdata_dp = (double *) malloc((size_t)nvals * sizeof (double));
+                  mdata_dp = (double *) Malloc((size_t)nvals * sizeof (double));
                   memcpy(mdata_dp, pdata_dp, (size_t)nvals * sizeof (double));
                   pdata_dp = mdata_dp;
                 }
@@ -3755,7 +3950,7 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
         {
           /* malloc and the loop imply nvals >= ysize * xsize,
            * but that is not checked and the types don't match */
-          sdata_sp = (float *)xmalloc((size_t)nvals * sizeof (float));
+          sdata_sp = (float *) Malloc((size_t)nvals * sizeof (float));
           for ( size_t j = 0; j < ysize; ++j )
             for ( size_t i = 0; i < xsize; ++i )
               sdata_sp[i*ysize+j] = pdata_sp[j*xsize+i];
@@ -3763,7 +3958,7 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
         }
       else
         {
-          sdata_dp = (double *)xmalloc((size_t)nvals * sizeof (double));
+          sdata_dp = (double *) Malloc((size_t)nvals * sizeof (double));
           for ( size_t j = 0; j < ysize; ++j )
             for ( size_t i = 0; i < xsize; ++i )
               sdata_dp[i*ysize+j] = pdata_dp[j*xsize+i];
@@ -3776,10 +3971,10 @@ cdf_write_var_data(int fileID, int vlistID, int varID, int ncvarid, int dtype, l
   else
     cdf_put_vara_double(fileID, ncvarid, start, count, pdata_dp);
 
-  if ( mdata_dp ) free(mdata_dp);
-  if ( sdata_dp ) free(sdata_dp);
-  if ( mdata_sp ) free(mdata_sp);
-  if ( sdata_sp ) free(sdata_sp);
+  if ( mdata_dp ) Free(mdata_dp);
+  if ( sdata_dp ) Free(sdata_dp);
+  if ( mdata_sp ) Free(mdata_sp);
+  if ( sdata_sp ) Free(sdata_sp);
 }
 
 
@@ -4003,14 +4198,36 @@ void transpose2dArrayDP(size_t inWidth, size_t inHeight, double* data)
 {
   const size_t cacheBlockSize = 256;    // Purely an optimization parameter. Current value of 32 means we are handling 8kB blocks,
                                        // which should be a decent compromise on many architectures.
-  double (*temp)[inWidth] = malloc(inHeight*sizeof(*temp));
+  
+#ifdef __cplusplus
+  double *temp[inHeight];
+  double *out[inWidth];
+  
+  temp[0] =  (double *) Malloc(inHeight * inWidth * sizeof(double));
+  out[0] = data;
+  
+  for(int i = 0; i < inWidth; i++)
+  {
+    out[i] = out[0] + (inHeight * i);
+  }
+
+  for(int i = 1; i < inHeight; i++)
+  {
+    temp[i] = temp[0] + (inWidth * i);
+  }
+  memcpy(temp[0], data, inHeight * inWidth * sizeof(double));
+#else
+  double (*temp)[inWidth] = (double (*)[inWidth]) Malloc(inHeight*sizeof(*temp));
   double (*out)[inHeight] = (double (*)[inHeight])data;
   memcpy(temp, data, inHeight*sizeof(*temp));
+#endif
+  
   /*
   for ( size_t y = 0; y < inHeight; ++y )
     for ( size_t x = 0; x < inWidth; ++x )
       out[x][y] = temp[y][x];
   */
+
   for ( size_t yBlock = 0; yBlock < inHeight; yBlock += cacheBlockSize )
     {
       for ( size_t xBlock = 0; xBlock < inWidth; xBlock += cacheBlockSize )
@@ -4025,7 +4242,7 @@ void transpose2dArrayDP(size_t inWidth, size_t inHeight, double* data)
         }
     }
 
-  free(temp);
+  Free(temp[0]);
 }
 
 static
@@ -4033,14 +4250,28 @@ void transpose2dArraySP(size_t inWidth, size_t inHeight, float* data)
 {
   const size_t cacheBlockSize = 256;    // Purely an optimization parameter. Current value of 32 means we are handling 8kB blocks,
                                        // which should be a decent compromise on many architectures.
-  float (*temp)[inWidth] = malloc(inHeight*sizeof(*temp));
+  
+#ifndef __cplusplus 
+  float (*temp)[inWidth] = (float (*)[inWidth]) Malloc(inHeight*sizeof(*temp));
   float (*out)[inHeight] = (float (*)[inHeight])data;
   memcpy(temp, data, inHeight*sizeof(*temp));
+  #else
+  float *temp[inWidth];
+  temp[0] =  (float *) Malloc(inWidth * inHeight * sizeof(float));
+  for(int i = 1; i < inHeight; i++)
+  {
+    temp[i] = temp[0] + (inWidth * i);
+  }
+
+  float **out = (float **)data;
+#endif
+  
   /*
   for ( size_t y = 0; y < inHeight; ++y )
     for ( size_t x = 0; x < inWidth; ++x )
       out[x][y] = temp[y][x];
   */
+  
   for ( size_t yBlock = 0; yBlock < inHeight; yBlock += cacheBlockSize )
     {
       for ( size_t xBlock = 0; xBlock < inWidth; xBlock += cacheBlockSize )
@@ -4055,7 +4286,7 @@ void transpose2dArraySP(size_t inWidth, size_t inHeight, float* data)
         }
     }
 
-  free(temp);
+  Free(temp);
 }
 
 static
@@ -4190,6 +4421,7 @@ void cdfGetSliceSlapDescription(stream_t *streamptr, int varId, int levelId, boo
     Error("Internal error, variable %s has an unsupported array structure!", vlistInqVarNamePtr(vlistId, varId));
 }
 
+
 void cdfReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
 {
   if ( CDI_Debug ) Message("streamID = %d  varID = %d", streamptr->self, varID);
@@ -4221,6 +4453,7 @@ void cdfReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
   *nmiss = (int)nmiss_;
 }
 
+
 void cdfReadVarSP(stream_t *streamptr, int varID, float *data, int *nmiss)
 {
   if ( CDI_Debug ) Message("streamID = %d  varID = %d", streamptr->self, varID);
@@ -4252,6 +4485,7 @@ void cdfReadVarSP(stream_t *streamptr, int varID, float *data, int *nmiss)
   *nmiss = (int)nmiss_;
 }
 
+
 void cdfReadVarSliceDP(stream_t *streamptr, int varID, int levelID, double *data, int *nmiss)
 {
   size_t start[4];
@@ -4274,11 +4508,11 @@ void cdfReadVarSliceDP(stream_t *streamptr, int varID, int levelID, double *data
 
   if ( vlistInqVarDatatype(vlistID, varID) == DATATYPE_FLT32 )
     {
-      float *data_fp = (float *)xmalloc(gridsize*sizeof(*data_fp));
+      float *data_fp = (float *) Malloc(gridsize*sizeof(*data_fp));
       cdf_get_vara_float(fileID, ncvarid, start, count, data_fp);
       for ( size_t i = 0; i < gridsize; i++ )
         data[i] = (double) data_fp[i];
-      free(data_fp);
+      Free(data_fp);
     }
   else if ( vlistInqVarDatatype(vlistID, varID) == DATATYPE_UINT8 )
     {
@@ -4332,11 +4566,11 @@ void cdfReadVarSliceSP(stream_t *streamptr, int varID, int levelID, float *data,
 
   if ( vlistInqVarDatatype(vlistID, varID) == DATATYPE_FLT64 )
     {
-      double *data_dp = (double *)xmalloc(gridsize*sizeof(*data_dp));
+      double *data_dp = (double *) Malloc(gridsize*sizeof(*data_dp));
       cdf_get_vara_double(fileID, ncvarid, start, count, data_dp);
       for ( size_t i = 0; i < gridsize; i++ )
         data[i] = (float) data_dp[i];
-      free(data_dp);
+      Free(data_dp);
     }
   else if ( vlistInqVarDatatype(vlistID, varID) == DATATYPE_UINT8 )
     {
@@ -4488,12 +4722,12 @@ void cdfCreateRecords(stream_t *streamptr, int tsID)
 
       streamptr->nrecs += nrecs;
 
-      destTstep->records    = (record_t *)xmalloc((size_t)nrecs*sizeof(record_t));
+      destTstep->records    = (record_t *) Malloc((size_t)nrecs*sizeof(record_t));
       destTstep->nrecs      = nrecs;
       destTstep->nallrecs   = nrecs;
       destTstep->recordSize = nrecs;
       destTstep->curRecID   = UNDEFID;
-      destTstep->recIDs     = (int *)xmalloc((size_t)nvrecs*sizeof (int));;
+      destTstep->recIDs     = (int *) Malloc((size_t)nvrecs*sizeof (int));;
       for ( recID = 0; recID < nvrecs; recID++ ) destTstep->recIDs[recID] = recID;
 
       record_t *records = destTstep->records;
@@ -4526,7 +4760,7 @@ void cdfCreateRecords(stream_t *streamptr, int tsID)
 
       streamptr->nrecs += nvrecs;
 
-      destTstep->records    = (record_t *) xmalloc((size_t)nrecs*sizeof(record_t));
+      destTstep->records    = (record_t *) Malloc((size_t)nrecs*sizeof(record_t));
       destTstep->nrecs      = nvrecs;
       destTstep->nallrecs   = nrecs;
       destTstep->recordSize = nrecs;
@@ -4536,7 +4770,7 @@ void cdfCreateRecords(stream_t *streamptr, int tsID)
 
       if ( nvrecs )
         {
-          destTstep->recIDs = (int *) xmalloc((size_t)nvrecs * sizeof (int));
+          destTstep->recIDs = (int *) Malloc((size_t)nvrecs * sizeof (int));
           vrecID = 0;
           for ( recID = 0; recID < nrecs; recID++ )
             {
@@ -4556,7 +4790,7 @@ void cdfCreateRecords(stream_t *streamptr, int tsID)
 
       streamptr->nrecs += nvrecs;
 
-      destTstep->records    = (record_t *) xmalloc((size_t)nrecs*sizeof(record_t));
+      destTstep->records    = (record_t *) Malloc((size_t)nrecs*sizeof(record_t));
       destTstep->nrecs      = nvrecs;
       destTstep->nallrecs   = nrecs;
       destTstep->recordSize = nrecs;
@@ -4564,7 +4798,7 @@ void cdfCreateRecords(stream_t *streamptr, int tsID)
 
       memcpy(destTstep->records, sourceTstep->records, (size_t)nrecs*sizeof(record_t));
 
-      destTstep->recIDs     = (int *) xmalloc((size_t)nvrecs * sizeof(int));
+      destTstep->recIDs     = (int *) Malloc((size_t)nvrecs * sizeof(int));
 
       memcpy(destTstep->recIDs, streamptr->tsteps[1].recIDs, (size_t)nvrecs*sizeof(int));
     }
@@ -4627,9 +4861,7 @@ int cdfTimeDimID(int fileID, int ndims, int nvars)
 static
 void init_ncdims(long ndims, ncdim_t *ncdims)
 {
-  long ncdimid;
-
-  for ( ncdimid = 0; ncdimid < ndims; ncdimid++ )
+  for ( long ncdimid = 0; ncdimid < ndims; ncdimid++ )
     {
       ncdims[ncdimid].ncvarid      = UNDEFID;
       ncdims[ncdimid].dimtype      = UNDEFID;
@@ -4641,9 +4873,7 @@ void init_ncdims(long ndims, ncdim_t *ncdims)
 static
 void init_ncvars(long nvars, ncvar_t *ncvars)
 {
-  long ncvarid;
-
-  for ( ncvarid = 0; ncvarid < nvars; ++ncvarid )
+  for ( long ncvarid = 0; ncvarid < nvars; ++ncvarid )
     {
       ncvars[ncvarid].ncid            = UNDEFID;
       ncvars[ncvarid].ignore          = FALSE;
@@ -4660,6 +4890,8 @@ void init_ncvars(long nvars, ncvar_t *ncvars)
       ncvars[ncvarid].calendar        = FALSE;
       ncvars[ncvarid].climatology     = FALSE;
       ncvars[ncvarid].bounds          = UNDEFID;
+      ncvars[ncvarid].lformula        = FALSE;
+      ncvars[ncvarid].lformulaterms   = FALSE;
       ncvars[ncvarid].gridID          = UNDEFID;
       ncvars[ncvarid].zaxisID         = UNDEFID;
       ncvars[ncvarid].gridtype        = UNDEFID;
@@ -4671,6 +4903,7 @@ void init_ncvars(long nvars, ncvar_t *ncvars)
       ncvars[ncvarid].yvarid          = UNDEFID;
       ncvars[ncvarid].zvarid          = UNDEFID;
       ncvars[ncvarid].tvarid          = UNDEFID;
+      ncvars[ncvarid].psvarid         = UNDEFID;
       ncvars[ncvarid].ncoordvars      = 0;
       for ( int i = 0; i < MAX_COORDVARS; ++i )
         ncvars[ncvarid].coordvarids[i]  = UNDEFID;
@@ -4682,8 +4915,8 @@ void init_ncvars(long nvars, ncvar_t *ncvars)
       ncvars[ncvarid].xtype           = 0;
       ncvars[ncvarid].ndims           = 0;
       ncvars[ncvarid].gmapid          = UNDEFID;
-      ncvars[ncvarid].vlen            = 0;
-      ncvars[ncvarid].vdata           = NULL;
+      ncvars[ncvarid].vctsize         = 0;
+      ncvars[ncvarid].vct             = NULL;
       ncvars[ncvarid].truncation      = 0;
       ncvars[ncvarid].position        = 0;
       ncvars[ncvarid].positive        = 0;
@@ -4712,6 +4945,36 @@ void init_ncvars(long nvars, ncvar_t *ncvars)
 }
 
 static
+void cdfSetVar(ncvar_t *ncvars, int ncvarid, short isvar)
+{
+  if ( ncvars[ncvarid].isvar != UNDEFID &&
+       ncvars[ncvarid].isvar != isvar   &&
+       ncvars[ncvarid].warn  == FALSE )
+    {
+      if ( ! ncvars[ncvarid].ignore )
+        Warning("Inconsistent variable definition for %s!", ncvars[ncvarid].name);
+
+      ncvars[ncvarid].warn = TRUE;
+      isvar = FALSE;
+    }
+
+  ncvars[ncvarid].isvar = isvar;
+}
+
+static
+void cdfSetDim(ncvar_t *ncvars, int ncvarid, int dimid, int dimtype)
+{
+  if ( ncvars[ncvarid].dimtype[dimid] != UNDEFID &&
+       ncvars[ncvarid].dimtype[dimid] != dimtype )
+    {
+      Warning("Inconsistent dimension definition for %s! dimid = %d;  type = %d;  newtype = %d",
+              ncvars[ncvarid].name, dimid, ncvars[ncvarid].dimtype[dimid], dimtype);
+    }
+
+  ncvars[ncvarid].dimtype[dimid] = dimtype;
+}
+
+static
 int isLonAxis(const char *units, const char *stdname)
 {
   int status = FALSE;
@@ -4763,7 +5026,7 @@ int isLatAxis(const char *units, const char *stdname)
       int ioff = 6;
       if ( lc_units[ioff] == 's' ) ioff++;
       if ( lc_units[ioff] == '_' ) ioff++;
-      if ( lc_units[ioff] == 'n' ) status = TRUE;
+      if ( lc_units[ioff] == 'n' || lc_units[ioff] == 's' ) status = TRUE;
     }
 
   return (status);
@@ -4792,7 +5055,7 @@ int isDBLAxis(/*const char *units,*/ const char *longname)
 static
 int unitsIsMeter(const char *units)
 {
-  return (*units == 'm' && (strcmp(units, "m") == 0 || strncmp(units, "meter", 5) == 0));
+  return (units[0] == 'm' && (!units[1] || strncmp(units, "meter", 5) == 0));
 }
 
 static
@@ -4843,11 +5106,123 @@ int unitsIsPressure(const char *units)
       status = TRUE;
     }
 
-  return (status);
+  return status;
+}
+
+static
+void scan_hybrid_formula(int ncid, int ncfvarid, int *apvarid, int *bvarid, int *psvarid)
+{
+  *apvarid = -1;
+  *bvarid  = -1;
+  *psvarid = -1;
+  const int attstringlen = 8192; char attstring[8192];
+  cdfGetAttText(ncid, ncfvarid, "formula", attstringlen, attstring);
+  if ( strcmp(attstring, "p = ap + b*ps") == 0 )
+    {
+      int lstop = FALSE;
+      int dimvarid;
+      cdfGetAttText(ncid, ncfvarid, "formula_terms", attstringlen, attstring);
+      char *pstring = attstring;
+
+      for ( int i = 0; i < 3; i++ )
+        {
+          while ( isspace((int) *pstring) ) pstring++;
+          if ( *pstring == 0 ) break;
+          char *tagname = pstring;
+          while ( !isspace((int) *pstring) && *pstring != 0 ) pstring++;
+          if ( *pstring == 0 ) lstop = TRUE;
+          *pstring++ = 0;
+
+          while ( isspace((int) *pstring) ) pstring++;
+          if ( *pstring == 0 ) break;
+          char *varname = pstring;
+          while ( !isspace((int) *pstring) && *pstring != 0 ) pstring++;
+          if ( *pstring == 0 ) lstop = TRUE;
+          *pstring++ = 0;
+
+          int status = nc_inq_varid(ncid, varname, &dimvarid);
+          if ( status == NC_NOERR )
+            {
+              if      ( strcmp(tagname, "ap:") == 0 ) *apvarid = dimvarid;
+              else if ( strcmp(tagname, "b:")  == 0 ) *bvarid  = dimvarid;
+              else if ( strcmp(tagname, "ps:") == 0 ) *psvarid = dimvarid;
+            }
+          else if ( strcmp(tagname, "ps:") != 0 )
+            {
+              Warning("%s - %s", nc_strerror(status), varname);
+            }
+
+          if ( lstop ) break;
+        }
+    }
+}
+
+static
+int isHybridSigmaPressureCoordinate(int ncid, int ncvarid, ncvar_t *ncvars, const ncdim_t *ncdims)
+{
+  int status = FALSE;
+  int ncfvarid = ncvarid;
+  ncvar_t *ncvar = &ncvars[ncvarid];
+
+  if ( strcmp(ncvar->stdname, "atmosphere_hybrid_sigma_pressure_coordinate") == 0 )
+    {
+      cdiConvention = CDI_CONVENTION_CF;
+
+      status = TRUE;
+      ncvar->zaxistype = ZAXIS_HYBRID;
+      int dimid = ncvar->dimids[0];
+      size_t dimlen = ncdims[dimid].len;
+
+      int apvarid1 = -1, bvarid1 = -1, psvarid1 = -1;
+      if ( ncvars[ncfvarid].lformula && ncvars[ncfvarid].lformulaterms )
+        scan_hybrid_formula(ncid, ncfvarid, &apvarid1, &bvarid1, &psvarid1);
+      if ( apvarid1 != -1 ) ncvars[apvarid1].isvar = FALSE;
+      if ( bvarid1  != -1 ) ncvars[bvarid1].isvar  = FALSE;
+      if ( psvarid1 != -1 ) ncvar->psvarid = psvarid1;
+
+      if ( ncvar->bounds != UNDEFID && ncvars[ncvar->bounds].lformula && ncvars[ncvar->bounds].lformulaterms )
+        {
+          ncfvarid = ncvar->bounds;
+          int apvarid2 = -1, bvarid2 = -1, psvarid2 = -1;
+          if ( ncvars[ncfvarid].lformula && ncvars[ncfvarid].lformulaterms )
+            scan_hybrid_formula(ncid, ncfvarid, &apvarid2, &bvarid2, &psvarid2);
+          if ( apvarid2 != -1 && bvarid2 != -1 )
+            {
+              ncvars[apvarid2].isvar = FALSE;
+              ncvars[bvarid2].isvar  = FALSE;
+
+              if ( dimid == ncvars[apvarid2].dimids[0] && ncdims[ncvars[apvarid2].dimids[1]].len == 2 )
+                {
+                  double abuf[dimlen*2], bbuf[dimlen*2];
+                  cdf_get_var_double(ncid, apvarid2, abuf);
+                  cdf_get_var_double(ncid, bvarid2, bbuf);
+                  /*
+                  for ( int i = 0; i < dimlen; ++i )
+                    printf("%d  %g %g    %g %g\n", i, abuf[i*2], abuf[i*2+1], bbuf[i*2], bbuf[i*2+1]);
+                  */
+                  size_t vctsize = (dimlen+1)*2;
+                  double *vct = (double *) Malloc(vctsize * sizeof(double));
+                  for ( size_t i = 0; i < dimlen; ++i )
+                    {
+                      vct[i] = abuf[i*2];
+                      vct[i+dimlen+1] = bbuf[i*2];
+                    }
+                  vct[dimlen]     = abuf[dimlen*2-1];
+                  vct[dimlen*2+1] = bbuf[dimlen*2-1];
+
+                  ncvar->vct = vct;
+                  ncvar->vctsize = vctsize;
+                }
+            }
+        }
+    }
+
+  return status;
 }
 
+
 static
-int isGaussGrid(size_t ysize, double yinc, double *yvals)
+int isGaussGrid(size_t ysize, double yinc, const double *yvals)
 {
   int lgauss = FALSE;
   double *yv, *yw;
@@ -4855,10 +5230,10 @@ int isGaussGrid(size_t ysize, double yinc, double *yvals)
   if ( IS_EQUAL(yinc, 0) && ysize > 2 ) /* check if gaussian */
     {
       size_t i;
-      yv = (double *) malloc(ysize*sizeof(double));
-      yw = (double *) malloc(ysize*sizeof(double));
+      yv = (double *) Malloc(ysize*sizeof(double));
+      yw = (double *) Malloc(ysize*sizeof(double));
       gaussaw(yv, yw, ysize);
-      free(yw);
+      Free(yw);
       for ( i = 0; i < ysize; i++ )
         yv[i] = asin(yv[i])/M_PI*180.0;
 
@@ -4878,47 +5253,14 @@ int isGaussGrid(size_t ysize, double yinc, double *yvals)
           if ( i == ysize ) lgauss = TRUE;
         }
 
-      free(yv);
+      Free(yv);
     }
 
   return (lgauss);
 }
 
 static
-void cdfSetVar(ncvar_t *ncvars, int ncvarid, int isvar)
-{
-  if ( isvar != TRUE && isvar != FALSE )
-    Error("Internal problem! var %s undefined", ncvars[ncvarid].name);
-
-  if ( ncvars[ncvarid].isvar != UNDEFID &&
-       ncvars[ncvarid].isvar != isvar   &&
-       ncvars[ncvarid].warn  == FALSE )
-    {
-      if ( ! ncvars[ncvarid].ignore )
-        Warning("Inconsistent variable definition for %s!", ncvars[ncvarid].name);
-
-      ncvars[ncvarid].warn = TRUE;
-      isvar = FALSE;
-    }
-
-  ncvars[ncvarid].isvar = isvar;
-}
-
-static
-void cdfSetDim(ncvar_t *ncvars, int ncvarid, int dimid, int dimtype)
-{
-  if ( ncvars[ncvarid].dimtype[dimid] != UNDEFID &&
-       ncvars[ncvarid].dimtype[dimid] != dimtype )
-    {
-      Warning("Inconsistent dimension definition for %s! dimid = %d;  type = %d;  newtype = %d",
-              ncvars[ncvarid].name, dimid, ncvars[ncvarid].dimtype[dimid], dimtype);
-    }
-
-  ncvars[ncvarid].dimtype[dimid] = dimtype;
-}
-
-static
-void printNCvars(ncvar_t *ncvars, int nvars, const char *oname)
+void printNCvars(const ncvar_t *ncvars, int nvars, const char *oname)
 {
   char axis[7];
   int ncvarid, i;
@@ -4975,8 +5317,6 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
   int nvdims, nvatts;
   int *dimidsp;
   int iatt;
-  int i;
-  int tablenum;
   nc_type xtype, atttype;
   size_t attlen;
   char name[CDI_MAX_NAME];
@@ -4984,8 +5324,9 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
   const int attstringlen = 8192; char attstring[8192];
 
   int nchecked_vars = 0;
-  char *checked_vars[9];
-  for ( i = 0; i < 9; ++i ) checked_vars[i] = NULL;
+  enum { max_check_vars = 9 };
+  char *checked_vars[max_check_vars];
+  for ( int i = 0; i < max_check_vars; ++i ) checked_vars[i] = NULL;
 
   for ( int ncvarid = 0; ncvarid < nvars; ncvarid++ )
     {
@@ -5094,6 +5435,7 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
             }
           else if ( strcmp(attname, "table") == 0 && !xtypeIsText(atttype) )
             {
+              int tablenum;
               cdfGetAttInt(ncid, ncvarid, attname, 1, &tablenum);
               if ( tablenum > 0 )
                 {
@@ -5226,12 +5568,9 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
             }
           else if ( strcmp(attname, "climatology") == 0 && xtypeIsText(atttype) )
             {
-              int status, ncboundsid;
-
               cdfGetAttText(ncid, ncvarid, attname, attstringlen, attstring);
-
-              status = nc_inq_varid(ncid, attstring, &ncboundsid);
-
+              int ncboundsid;
+              int status = nc_inq_varid(ncid, attstring, &ncboundsid);
               if ( status == NC_NOERR )
                 {
                   ncvars[ncvarid].climatology = TRUE;
@@ -5242,14 +5581,11 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
               else
                 Warning("%s - %s", nc_strerror(status), attstring);
             }
-          else if ( strcmp(attname, "bounds") == 0 && xtypeIsText(atttype) )
+          else if ( xtypeIsText(atttype) && strcmp(attname, "bounds") == 0 )
             {
-              int status, ncboundsid;
-
               cdfGetAttText(ncid, ncvarid, attname, attstringlen, attstring);
-
-              status = nc_inq_varid(ncid, attstring, &ncboundsid);
-
+              int ncboundsid;
+              int status = nc_inq_varid(ncid, attstring, &ncboundsid);
               if ( status == NC_NOERR )
                 {
                   ncvars[ncvarid].bounds = ncboundsid;
@@ -5259,12 +5595,20 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
               else
                 Warning("%s - %s", nc_strerror(status), attstring);
             }
+          else if ( xtypeIsText(atttype) && strcmp(attname, "formula_terms") == 0 )
+            {
+              ncvars[ncvarid].lformulaterms = TRUE;
+            }
+          else if ( xtypeIsText(atttype) && strcmp(attname, "formula") == 0 )
+            {
+              ncvars[ncvarid].lformula = TRUE;
+            }
           else if ( strcmp(attname, "cell_measures") == 0 && xtypeIsText(atttype) )
             {
-              char *pstring, *cell_measures = NULL, *cell_var = NULL;
+              char *cell_measures = NULL, *cell_var = NULL;
 
               cdfGetAttText(ncid, ncvarid, attname, attstringlen, attstring);
-              pstring = attstring;
+              char *pstring = attstring;
 
               while ( isspace((int) *pstring) ) pstring++;
               cell_measures = pstring;
@@ -5280,10 +5624,8 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
               */
               if ( memcmp(cell_measures, "area", 4) == 0 )
                 {
-                  int status;
                   int nc_cell_id;
-
-                  status = nc_inq_varid(ncid, cell_var, &nc_cell_id);
+                  int status = nc_inq_varid(ncid, cell_var, &nc_cell_id);
                   if ( status == NC_NOERR )
                     {
                       ncvars[ncvarid].cellarea = nc_cell_id;
@@ -5327,15 +5669,14 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
           else if ( (strcmp(attname, "associate")  == 0 || strcmp(attname, "coordinates") == 0) && xtypeIsText(atttype) )
             {
               int status;
-              char *pstring, *varname = NULL;
+              char *varname = NULL;
               int lstop = FALSE;
               int dimvarid;
-              extern int cdiIgnoreAttCoordinates;
 
               cdfGetAttText(ncid, ncvarid, attname, attstringlen, attstring);
-              pstring = attstring;
+              char *pstring = attstring;
 
-              for ( i = 0; i < MAX_COORDVARS; i++ )
+              for ( int i = 0; i < MAX_COORDVARS; i++ )
                 {
                   while ( isspace((int) *pstring) ) pstring++;
                   if ( *pstring == 0 ) break;
@@ -5362,7 +5703,7 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
 
                       if ( k == nchecked_vars )
                         {
-                          if ( nchecked_vars < 9 ) checked_vars[nchecked_vars++] = strdup(varname);
+                          if ( nchecked_vars < max_check_vars ) checked_vars[nchecked_vars++] = strdup(varname);
                           Warning("%s - %s", nc_strerror(status), varname);
                         }
                     }
@@ -5375,15 +5716,14 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
           else if ( (strcmp(attname, "auxiliary_variable") == 0) && xtypeIsText(atttype) )
             {
               int status;
-              char *pstring, *varname = NULL;
+              char *varname = NULL;
               int lstop = FALSE;
               int dimvarid;
-              extern int cdiIgnoreAttCoordinates;
 
               cdfGetAttText(ncid, ncvarid, attname, attstringlen, attstring);
-              pstring = attstring;
+              char *pstring = attstring;
 
-              for ( i = 0; i < MAX_AUXVARS; i++ )
+              for ( int i = 0; i < MAX_AUXVARS; i++ )
                 {
                   while ( isspace((int) *pstring) ) pstring++;
                   if ( *pstring == 0 ) break;
@@ -5412,12 +5752,9 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
             }
           else if ( strcmp(attname, "grid_mapping") == 0 && xtypeIsText(atttype) )
             {
-              int status;
-              int nc_gmap_id;
-
               cdfGetAttText(ncid, ncvarid, attname, attstringlen, attstring);
-
-              status = nc_inq_varid(ncid, attstring, &nc_gmap_id);
+              int nc_gmap_id;
+              int status = nc_inq_varid(ncid, attstring, &nc_gmap_id);
               if ( status == NC_NOERR )
                 {
                   ncvars[ncvarid].gmapid = nc_gmap_id;
@@ -5544,14 +5881,22 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
               cdfGetAttText(ncid, ncvarid, attname, attstringlen, attstring);
 	      attlen = strlen(attstring);
 
-	      if ( (int) attlen > nvdims )
+	      if ( (int) attlen > nvdims && nvdims > 0 && attlen > 1 )
 		{
-		  if ( nvdims > 0 )
 		    Warning("Unexpected axis attribute length for %s, ignored!", name);
 		}
+              else if ( nvdims == 0 && attlen == 1 )
+                {
+                  if ( attstring[0] == 'z' || attstring[0] == 'Z' )
+                    {
+                      cdfSetVar(ncvars, ncvarid, FALSE);
+                      ncvars[ncvarid].islev = TRUE;
+                    }
+                }
 	      else
 		{
 		  strtolower(attstring);
+                  int i;
 		  for ( i = 0; i < (int)attlen; ++i )
 		    {
 		      if ( attstring[i] != '-' && attstring[i] != 't' && attstring[i] != 'z' &&
@@ -5562,7 +5907,7 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
 			}
 		    }
 
-		  if ( i == (int) attlen && (int) attlen == nvdims)
+		  if ( i == (int) attlen && (int) attlen == nvdims )
 		    {
 		      while ( attlen-- )
 			{
@@ -5573,14 +5918,14 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
 			    }
 			  else if ( (int) attstring[attlen] == 'z' )
 			    {
-			      ncvars[ncvarid].zdim = dimidsp[attlen];
-			      cdfSetDim(ncvars, ncvarid, (int)attlen, Z_AXIS);
-
-			      if ( ncvars[ncvarid].ndims == 1 )
-				{
-				  cdfSetVar(ncvars, ncvarid, FALSE);
-				  ncdims[ncvars[ncvarid].dimids[0]].dimtype = Z_AXIS;
-				}
+                              ncvars[ncvarid].zdim = dimidsp[attlen];
+                              cdfSetDim(ncvars, ncvarid, (int)attlen, Z_AXIS);
+
+                              if ( ncvars[ncvarid].ndims == 1 )
+                                {
+                                  cdfSetVar(ncvars, ncvarid, FALSE);
+                                  ncdims[ncvars[ncvarid].dimids[0]].dimtype = Z_AXIS;
+                                }
 			    }
 			  else if ( (int) attstring[attlen] == 'y' )
 			    {
@@ -5615,7 +5960,7 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
 	      int temp;
 
 	      if( ncvars[ncvarid].ensdata == NULL )
-		ncvars[ncvarid].ensdata = (ensinfo_t *) malloc( sizeof( ensinfo_t ) );
+		ncvars[ncvarid].ensdata = (ensinfo_t *) Malloc( sizeof( ensinfo_t ) );
 
 	      cdfGetAttInt(ncid, ncvarid, attname, 1, &temp);
 
@@ -5632,7 +5977,7 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
 	    {
 	      if ( ncvars[ncvarid].natts == 0 )
 		ncvars[ncvarid].atts
-                  = (int *)xmalloc((size_t)nvatts * sizeof (int));
+                  = (int *) Malloc((size_t)nvatts * sizeof (int));
 
 	      ncvars[ncvarid].atts[ncvars[ncvarid].natts++] = iatt;
 	      /*
@@ -5664,7 +6009,7 @@ void cdfScanVarAttributes(int nvars, ncvar_t *ncvars, ncdim_t *ncdims,
 	}
     }
 
-  for ( i = 0; i < 9; ++i ) if ( checked_vars[i] ) free(checked_vars[i]);
+  for ( int i = 0; i < max_check_vars; ++i ) if ( checked_vars[i] ) Free(checked_vars[i]);
 }
 
 static
@@ -5743,7 +6088,7 @@ void setDimType(int nvars, ncvar_t *ncvars, ncdim_t *ncdims)
 
 /* verify coordinate vars - first scan (dimname == varname) */
 static
-void verify_coordinate_vars_1(int ndims, ncdim_t *ncdims, ncvar_t *ncvars, int timedimid)
+void verify_coordinate_vars_1(int ncid, int ndims, ncdim_t *ncdims, ncvar_t *ncvars, int timedimid)
 {
   int ncdimid, ncvarid;
 
@@ -5759,6 +6104,8 @@ void verify_coordinate_vars_1(int ndims, ncdim_t *ncdims, ncvar_t *ncvars, int t
 	      continue;
 	    }
 
+          if ( isHybridSigmaPressureCoordinate(ncid, ncvarid, ncvars, ncdims) ) continue;
+
 	  if ( ncvars[ncvarid].units[0] != 0 )
 	    {
 	      if ( isLonAxis(ncvars[ncvarid].units, ncvars[ncvarid].stdname) )
@@ -5804,6 +6151,13 @@ void verify_coordinate_vars_1(int ndims, ncdim_t *ncdims, ncvar_t *ncvars, int t
 		    ncvars[ncvarid].zaxistype = ZAXIS_HEIGHT;
 		}
 	    }
+          else
+            {
+              if ( (strcmp(ncvars[ncvarid].longname, "generalized_height") == 0 ||
+                    strcmp(ncvars[ncvarid].longname, "generalized height") == 0) &&
+                   strcmp(ncvars[ncvarid].stdname, "height") == 0 )
+                  ncvars[ncvarid].zaxistype = ZAXIS_REFERENCE;
+            }
 
 	  if ( ncvars[ncvarid].islon == FALSE && ncvars[ncvarid].longname[0] != 0 &&
                ncvars[ncvarid].islat == FALSE && ncvars[ncvarid].longname[1] != 0 )
@@ -5968,7 +6322,6 @@ static
 void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nvars, ncvar_t *ncvars, int timedimid, unsigned char *uuidOfHGrid, char *gridfile, int number_of_grid_used)
 {
   int ncvarid, ncvarid2;
-  int ndims;
   int nbdims;
   int i;
   int nvatts;
@@ -5977,7 +6330,6 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
   grid_t grid;
   grid_t proj;
   int gridindex;
-  size_t size = 0, xsize, ysize, np;
   char name[CDI_MAX_NAME];
   int iatt;
   int ltwarn = TRUE;
@@ -5994,13 +6346,11 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 	  int xvarid = -1, yvarid = -1;
 	  int islon = 0, islat = 0;
 	  int nxdims = 0, nydims = 0;
+          size_t size = 0, np = 0;
+          size_t xsize = 0, ysize = 0;
 	  double xinc = 0, yinc = 0;
 
-	  xsize = 0;
-	  ysize = 0;
-          np    = 0;
-
-	  ndims = ncvars[ncvarid].ndims;
+	  int ndims = ncvars[ncvarid].ndims;
 	  for ( i = 0; i < ndims; i++ )
 	    {
 	      if ( ncvars[ncvarid].dimtype[i] == X_AXIS && nxdims < 2 )
@@ -6066,7 +6416,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 	    }
 
 	  if ( ncvars[ncvarid].gridtype == UNDEFID || ncvars[ncvarid].gridtype == GRID_GENERIC )
-	    if ( xdimid != UNDEFID && xdimid == ydimid ) ncvars[ncvarid].gridtype = GRID_UNSTRUCTURED;
+	    if ( xdimid != UNDEFID && xdimid == ydimid && nydims == 0 ) ncvars[ncvarid].gridtype = GRID_UNSTRUCTURED;
 
 	  grid_init(&grid);
 	  grid_init(&proj);
@@ -6151,12 +6501,10 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 		      size = xsize*ysize;
 		      /* Check size of 2 dimensional coordinate variables */
 		      {
-			int dimid;
-			size_t dimsize1, dimsize2;
-			dimid = ncvars[xvarid].dimids[ndims-2];
-			dimsize1 = ncdims[dimid].len;
+			int dimid = ncvars[xvarid].dimids[ndims-2];
+			size_t dimsize1 = ncdims[dimid].len;
 			dimid = ncvars[xvarid].dimids[ndims-1];
-			dimsize2 = ncdims[dimid].len;
+			size_t dimsize2 = ncdims[dimid].len;
 			if ( dimsize1*dimsize2 == size ) skipvar = FALSE;
 		      }
 		    }
@@ -6165,10 +6513,8 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 		      size = xsize;
 		      /* Check size of 1 dimensional coordinate variables */
 		      {
-			int dimid;
-			size_t dimsize;
-			dimid = ncvars[xvarid].dimids[0];
-			dimsize = ncdims[dimid].len;
+			int dimid = ncvars[xvarid].dimids[0];
+			size_t dimsize = ncdims[dimid].len;
 			if ( dimsize == size ) skipvar = FALSE;
 		      }
 		    }
@@ -6187,7 +6533,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
                     }
 
 		  if ( ncvars[xvarid].xtype == NC_FLOAT ) grid.prec = DATATYPE_FLT32;
-		  grid.xvals = (double *) malloc(size*sizeof(double));
+		  grid.xvals = (double *) Malloc(size*sizeof(double));
 
 		  if ( ltgrid )
 		    cdf_get_vara_double(ncvars[xvarid].ncid, xvarid, start, count, grid.xvals);
@@ -6264,7 +6610,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
                     }
 
 		  if ( ncvars[yvarid].xtype == NC_FLOAT ) grid.prec = DATATYPE_FLT32;
-		  grid.yvals = (double *) malloc(size*sizeof(double));
+		  grid.yvals = (double *) Malloc(size*sizeof(double));
 
 		  if ( ltgrid )
 		    cdf_get_vara_double(ncvars[yvarid].ncid, yvarid, start, count, grid.yvals);
@@ -6351,7 +6697,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 			  {
 			    nvertex = ncdims[ncvars[ncvars[xvarid].bounds].dimids[nbdims-1]].len;
 			    grid.nvertex = (int) nvertex;
-			    grid.xbounds = (double *) malloc(nvertex*size*sizeof(double));
+			    grid.xbounds = (double *) Malloc(nvertex*size*sizeof(double));
 			    cdf_get_var_double(ncvars[xvarid].ncid, ncvars[xvarid].bounds, grid.xbounds);
 			  }
 		      }
@@ -6370,7 +6716,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 			      Warning("nvertex problem! nvertex x %d, nvertex y %d",
 				      grid.nvertex, (int) nvertex);
 			    */
-			    grid.ybounds = (double *) malloc(nvertex*size*sizeof(double));
+			    grid.ybounds = (double *) Malloc(nvertex*size*sizeof(double));
 			    cdf_get_var_double(ncvars[yvarid].ncid, ncvars[yvarid].bounds, grid.ybounds);
 			  }
 		      }
@@ -6378,7 +6724,7 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 
 		if ( ncvars[ncvarid].cellarea != UNDEFID )
 		  {
-		    grid.area = (double *) malloc(size*sizeof(double));
+		    grid.area = (double *) Malloc(size*sizeof(double));
 		    cdf_get_var_double(ncvars[ncvarid].ncid, ncvars[ncvarid].cellarea, grid.area);
 		  }
 
@@ -6677,54 +7023,61 @@ void define_all_grids(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 /* define all input zaxes */
 static
 void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nvars, ncvar_t *ncvars,
-		      size_t vctsize, double *vct, unsigned char *uuidOfVGrid)
+		      size_t vctsize_echam, double *vct_echam, unsigned char *uuidOfVGrid)
 {
   int ncvarid, ncvarid2;
-  int i, ilev, ndims;
+  int i, ilev;
   int zaxisindex;
-  int zprec;
   int nbdims, nvertex, nlevel;
-  int positive = 0;
+  int psvarid = -1;
   char *pname, *plongname, *punits;
+  size_t vctsize = vctsize_echam;
+  double *vct = vct_echam;
 
   for ( ncvarid = 0; ncvarid < nvars; ncvarid++ )
     {
       if ( ncvars[ncvarid].isvar == TRUE && ncvars[ncvarid].zaxisID == UNDEFID )
 	{
+          int is_scalar = FALSE;
 	  int with_bounds = FALSE;
 	  int zdimid = UNDEFID;
 	  int zvarid = UNDEFID;
 	  int zsize = 1;
 	  double *lbounds = NULL;
 	  double *ubounds = NULL;
-	  int zaxisType;
 
-          positive = 0;
+          int positive = 0;
+	  int ndims = ncvars[ncvarid].ndims;
 
-	  ndims = ncvars[ncvarid].ndims;
-	  for ( i = 0; i < ndims; i++ )
-	    {
-	      if ( ncvars[ncvarid].dimtype[i] == Z_AXIS )
-		zdimid = ncvars[ncvarid].dimids[i];
-	    }
+          if ( ncvars[ncvarid].zvarid != -1 && ncvars[ncvars[ncvarid].zvarid].ndims == 0 )
+            {
+              zvarid = ncvars[ncvarid].zvarid;
+              is_scalar = TRUE;
+            }
+          else
+            {
+              for ( i = 0; i < ndims; i++ )
+                {
+                  if ( ncvars[ncvarid].dimtype[i] == Z_AXIS )
+                    zdimid = ncvars[ncvarid].dimids[i];
+                }
 
-	  if ( zdimid != UNDEFID )
-	    {
-	      zvarid = ncdims[zdimid].ncvarid;
-	      zsize  = (int)ncdims[zdimid].len;
-	    }
+              if ( zdimid != UNDEFID )
+                {
+                  zvarid = ncdims[zdimid].ncvarid;
+                  zsize  = (int)ncdims[zdimid].len;
+                }
+            }
 
 	  if ( CDI_Debug ) Message("nlevs = %d", zsize);
 
-	  double *zvar = (double *)xmalloc((size_t)zsize * sizeof (double));
-
-	  zaxisType = UNDEFID;
+	  double *zvar = (double *) Malloc((size_t)zsize * sizeof (double));
 
+	  int zaxisType = UNDEFID;
 	  if ( zvarid != UNDEFID ) zaxisType = ncvars[zvarid].zaxistype;
-
 	  if ( zaxisType == UNDEFID )  zaxisType = ZAXIS_GENERIC;
 
-	  zprec = DATATYPE_FLT64;
+	  int zprec = DATATYPE_FLT64;
 
 	  if ( zvarid != UNDEFID )
 	    {
@@ -6739,6 +7092,15 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 		if ( pname[len-2] == '_' && isdigit((int) pname[len-1]) )
 		  pname[len-2] = 0;
 	      */
+              psvarid = -1;
+              if ( zaxisType == ZAXIS_HYBRID && ncvars[zvarid].vct )
+                {
+                  vct = ncvars[zvarid].vct;
+                  vctsize = ncvars[zvarid].vctsize;
+
+                  if ( ncvars[zvarid].psvarid != -1 ) psvarid = ncvars[zvarid].psvarid;
+                }
+
 	      cdf_get_var_double(ncvars[zvarid].ncid, zvarid, zvar);
 
 	      if ( ncvars[zvarid].bounds != UNDEFID )
@@ -6750,18 +7112,16 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 		      nvertex = (int)ncdims[ncvars[ncvars[zvarid].bounds].dimids[1]].len;
 		      if ( nlevel == zsize && nvertex == 2 )
 			{
-			  double *zbounds;
 			  with_bounds = TRUE;
-			  zbounds = (double *) malloc(2*(size_t)nlevel*sizeof(double));
-			  lbounds = (double *) malloc((size_t)nlevel*sizeof(double));
-			  ubounds = (double *) malloc((size_t)nlevel*sizeof(double));
+			  lbounds = (double *) Malloc((size_t)nlevel*sizeof(double));
+			  ubounds = (double *) Malloc((size_t)nlevel*sizeof(double));
+			  double zbounds[2*nlevel];
 			  cdf_get_var_double(ncvars[zvarid].ncid, ncvars[zvarid].bounds, zbounds);
 			  for ( i = 0; i < nlevel; ++i )
 			    {
 			      lbounds[i] = zbounds[i*2];
 			      ubounds[i] = zbounds[i*2+1];
 			    }
-			  free(zbounds);
 			}
 		    }
 		}
@@ -6802,11 +7162,14 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
               zaxisDefUUID(ncvars[ncvarid].zaxisID, uuidOfVGrid);
             }
 
+          if ( zaxisType == ZAXIS_HYBRID && psvarid != -1 ) zaxisDefPsName(ncvars[ncvarid].zaxisID, ncvars[psvarid].name);
+
           if ( positive > 0 ) zaxisDefPositive(ncvars[ncvarid].zaxisID, positive);
+          if ( is_scalar ) zaxisDefScalar(ncvars[ncvarid].zaxisID);
 
-	  free(zvar);
-	  free(lbounds);
-	  free(ubounds);
+	  Free(zvar);
+	  Free(lbounds);
+	  Free(ubounds);
 
 	  zaxisindex = vlistZaxisIndex(vlistID, ncvars[ncvarid].zaxisID);
 	  streamptr->zaxisID[zaxisindex]  = zdimid;
@@ -6815,22 +7178,32 @@ void define_all_zaxes(stream_t *streamptr, int vlistID, ncdim_t *ncdims, int nva
 	    Message("zaxisID %d %d %s", ncvars[ncvarid].zaxisID, ncvarid, ncvars[ncvarid].name);
 
 	  for ( ncvarid2 = ncvarid+1; ncvarid2 < nvars; ncvarid2++ )
-	    if ( ncvars[ncvarid2].isvar == TRUE && ncvars[ncvarid2].zaxisID == UNDEFID && ncvars[ncvarid2].zaxistype == UNDEFID )
+	    if ( ncvars[ncvarid2].isvar == TRUE && ncvars[ncvarid2].zaxisID == UNDEFID /*&& ncvars[ncvarid2].zaxistype == UNDEFID*/ )
 	      {
-		int zdimid2 = -1;
+                int zvarid2 = UNDEFID;
+                if ( ncvars[ncvarid2].zvarid != UNDEFID && ncvars[ncvars[ncvarid2].zvarid].ndims == 0 )
+                  zvarid2 = ncvars[ncvarid2].zvarid;
+
+		int zdimid2 = UNDEFID;
 		ndims = ncvars[ncvarid2].ndims;
 		for ( i = 0; i < ndims; i++ )
 		  {
 		    if ( ncvars[ncvarid2].dimtype[i] == Z_AXIS )
 		      zdimid2 = ncvars[ncvarid2].dimids[i];
 		  }
-		if ( zdimid == zdimid2 )
+
+		if ( zdimid == zdimid2 /* && zvarid == zvarid2 */)
 		  {
-		    if ( CDI_Debug )
-		      Message("zaxisID %d %d %s",
-			      ncvars[ncvarid].zaxisID, ncvarid2, ncvars[ncvarid2].name);
-		    ncvars[ncvarid2].zaxisID = ncvars[ncvarid].zaxisID;
-		  }
+                    if ( (zdimid != UNDEFID && ncvars[ncvarid2].zaxistype == UNDEFID) ||
+                         (zdimid == UNDEFID && zvarid != UNDEFID && zvarid == zvarid2) ||
+                         (zdimid == UNDEFID && zaxisType == ncvars[ncvarid2].zaxistype) ||
+                         (zdimid == UNDEFID && zvarid2 == UNDEFID && ncvars[ncvarid2].zaxistype == UNDEFID) )
+                      {
+                        if ( CDI_Debug )
+                          Message("zaxisID %d %d %s", ncvars[ncvarid].zaxisID, ncvarid2, ncvars[ncvarid2].name);
+                        ncvars[ncvarid2].zaxisID = ncvars[ncvarid].zaxisID;
+                      }
+                  }
 	      }
 	}
     }
@@ -6857,7 +7230,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
   if ( streamptr->sortname )
     {
       struct varinfo *varInfo
-        = (struct varinfo *)xmalloc((size_t)nvars * sizeof (struct varinfo));
+        = (struct varinfo *) Malloc((size_t)nvars * sizeof (struct varinfo));
 
       for ( int varID = 0; varID < nvars; varID++ )
 	{
@@ -6870,18 +7243,16 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 	{
 	  varids[varID] = varInfo[varID].ncvarid;
 	}
-      free(varInfo);
+      Free(varInfo);
     }
 
   for ( int varID1 = 0; varID1 < nvars; varID1++ )
     {
-      int gridID, zaxisID;
-
       int ncvarid = varids[varID1];
-      gridID  = ncvars[ncvarid].gridID;
-      zaxisID = ncvars[ncvarid].zaxisID;
+      int gridID  = ncvars[ncvarid].gridID;
+      int zaxisID = ncvars[ncvarid].zaxisID;
 
-      stream_new_var(streamptr, gridID, zaxisID);
+      stream_new_var(streamptr, gridID, zaxisID, CDI_UNDEFID);
       int varID = vlistDefVar(vlistID, gridID, zaxisID, ncvars[ncvarid].tsteptype);
 
 #if  defined  (HAVE_NETCDF4)
@@ -6900,8 +7271,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
       if ( ncvars[ncvarid].code != UNDEFID )  vlistDefVarCode(vlistID, varID, ncvars[ncvarid].code);
       if ( ncvars[ncvarid].code != UNDEFID )
 	{
-	  int param;
-	  param = cdiEncodeParam(ncvars[ncvarid].code, ncvars[ncvarid].tabnum, 255);
+	  int param = cdiEncodeParam(ncvars[ncvarid].code, ncvars[ncvarid].tabnum, 255);
 	  vlistDefVarParam(vlistID, varID, param);
 	}
       if ( ncvars[ncvarid].longname[0] )  vlistDefVarLongname(vlistID, varID, ncvars[ncvarid].longname);
@@ -6987,7 +7357,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
           vlistDefVarEnsemble( vlistID, varID, ncvars[ncvarid].ensdata->ens_index,
                                ncvars[ncvarid].ensdata->ens_count,
                                ncvars[ncvarid].ensdata->forecast_init_type );
-          free(ncvars[ncvarid].ensdata);
+          Free(ncvars[ncvarid].ensdata);
           ncvars[ncvarid].ensdata = NULL;
         }
 
@@ -7021,23 +7391,21 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 
 	      if ( attrtype == NC_SHORT || attrtype == NC_INT )
 		{
-		  int *attint = (int *) malloc(attlen*sizeof(int));
+		  int attint[attlen];
 		  cdfGetAttInt(ncid, ncvarid, attname, (int)attlen, attint);
 		  if ( attrtype == NC_SHORT )
 		    vlistDefAttInt(vlistID, varID, attname, DATATYPE_INT16, (int)attlen, attint);
 		  else
 		    vlistDefAttInt(vlistID, varID, attname, DATATYPE_INT32, (int)attlen, attint);
-		  free(attint);
 		}
 	      else if ( attrtype == NC_FLOAT || attrtype == NC_DOUBLE )
 		{
-		  double *attflt = (double *) malloc(attlen*sizeof(double));
+		  double attflt[attlen];
 		  cdfGetAttDouble(ncid, ncvarid, attname, (int)attlen, attflt);
 		  if ( attrtype == NC_FLOAT )
 		    vlistDefAttFlt(vlistID, varID, attname, DATATYPE_FLT32, (int)attlen, attflt);
 		  else
 		    vlistDefAttFlt(vlistID, varID, attname, DATATYPE_FLT64, (int)attlen, attflt);
-		  free(attflt);
 		}
 	      else if ( xtypeIsText(attrtype) )
 		{
@@ -7050,16 +7418,18 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 		}
 	    }
 
-	  free(ncvars[ncvarid].atts);
+	  if (ncvars[ncvarid].vct) Free(ncvars[ncvarid].vct);
+	  if (ncvars[ncvarid].atts) Free(ncvars[ncvarid].atts);
+          ncvars[ncvarid].vct = NULL;
           ncvars[ncvarid].atts = NULL;
 	}
     }
 
   /* release mem of not freed attributes */
   for ( int ncvarid = 0; ncvarid < num_ncvars; ncvarid++ )
-    if ( ncvars[ncvarid].atts ) free(ncvars[ncvarid].atts);
+    if ( ncvars[ncvarid].atts ) Free(ncvars[ncvarid].atts);
 
-  if ( varids ) free(varids);
+  if ( varids ) Free(varids);
 
   for ( int varID = 0; varID < nvars; varID++ )
     {
@@ -7072,7 +7442,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 	      if ( memcmp("var", pname, 3) == 0 )
 		{
 		  vlistDefVarCode(vlistID, varID, atoi(pname+3));
-		  vlistDestroyVarName(vlistID, varID);
+                  // vlistDestroyVarName(vlistID, varID);
 		}
 	    }
 	  else if ( len > 4 && isdigit((int) pname[4]) )
@@ -7080,7 +7450,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 	      if ( memcmp("code", pname, 4) == 0 )
 		{
 		  vlistDefVarCode(vlistID, varID, atoi(pname+4));
-		  vlistDestroyVarName(vlistID, varID);
+		  // vlistDestroyVarName(vlistID, varID);
 		}
 	    }
 	  else if ( len > 5 && isdigit((int) pname[5]) )
@@ -7090,7 +7460,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 		  int pnum = -1, pcat = 255, pdis = 255;
 		  sscanf(pname+5, "%d.%d.%d", &pnum, &pcat, &pdis);
 		  vlistDefVarParam(vlistID, varID, cdiEncodeParam(pnum, pcat, pdis));
-		  vlistDestroyVarName(vlistID, varID);
+                  // vlistDestroyVarName(vlistID, varID);
 		}
 	    }
 	}
@@ -7098,9 +7468,9 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 
   for ( int varID = 0; varID < nvars; varID++ )
     {
-      int instID  = vlistInqVarInstitut(vlistID, varID);
-      int modelID = vlistInqVarModel(vlistID, varID);
-      int tableID = vlistInqVarTable(vlistID, varID);
+      int varInstID  = vlistInqVarInstitut(vlistID, varID);
+      int varModelID = vlistInqVarModel(vlistID, varID);
+      int varTableID = vlistInqVarTable(vlistID, varID);
       int code = vlistInqVarCode(vlistID, varID);
       if ( cdiDefaultTableID != UNDEFID )
 	{
@@ -7110,7 +7480,7 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 	      vlistDestroyVarLongname(vlistID, varID);
 	      vlistDestroyVarUnits(vlistID, varID);
 
-	      if ( tableID != UNDEFID )
+	      if ( varTableID != UNDEFID )
 		{
 		  vlistDefVarName(vlistID, varID, tableInqParNamePtr(cdiDefaultTableID, code));
 		  if ( tableInqParLongnamePtr(cdiDefaultTableID, code) )
@@ -7120,16 +7490,16 @@ void define_all_vars(stream_t *streamptr, int vlistID, int instID, int modelID,
 		}
 	      else
 		{
-		  tableID = cdiDefaultTableID;
+		  varTableID = cdiDefaultTableID;
 		}
 	    }
 
-	  if ( cdiDefaultModelID != UNDEFID ) modelID = cdiDefaultModelID;
-	  if ( cdiDefaultInstID  != UNDEFID ) instID  = cdiDefaultInstID;
+	  if ( cdiDefaultModelID != UNDEFID ) varModelID = cdiDefaultModelID;
+	  if ( cdiDefaultInstID  != UNDEFID ) varInstID  = cdiDefaultInstID;
 	}
-      if ( instID  != UNDEFID ) vlistDefVarInstitut(vlistID, varID, instID);
-      if ( modelID != UNDEFID ) vlistDefVarModel(vlistID, varID, modelID);
-      if ( tableID != UNDEFID ) vlistDefVarTable(vlistID, varID, tableID);
+      if ( varInstID  != UNDEFID ) vlistDefVarInstitut(vlistID, varID, varInstID);
+      if ( varModelID != UNDEFID ) vlistDefVarModel(vlistID, varID, varModelID);
+      if ( varTableID != UNDEFID ) vlistDefVarTable(vlistID, varID, varTableID);
     }
 }
 
@@ -7230,26 +7600,22 @@ void scan_global_attributes(int fileID, int vlistID, stream_t *streamptr, int ng
 	    }
  	  else
             {
-              int *attint;
-              attint = (int *) malloc(attlen*sizeof(int));
+              int attint[attlen];
               cdfGetAttInt(fileID, NC_GLOBAL, attname, (int)attlen, attint);
               if ( xtype == NC_SHORT )
                 vlistDefAttInt(vlistID, CDI_GLOBAL, attname, DATATYPE_INT16, (int)attlen, attint);
               else
                 vlistDefAttInt(vlistID, CDI_GLOBAL, attname, DATATYPE_INT32, (int)attlen, attint);
-              free(attint);
             }
         }
       else if ( xtype == NC_FLOAT || xtype == NC_DOUBLE )
 	{
-	  double *attflt;
-	  attflt = (double *) malloc(attlen*sizeof(double));
+	  double attflt[attlen];
 	  cdfGetAttDouble(fileID, NC_GLOBAL, attname, (int)attlen, attflt);
 	  if ( xtype == NC_FLOAT )
 	    vlistDefAttFlt(vlistID, CDI_GLOBAL, attname, DATATYPE_FLT32, (int)attlen, attflt);
 	  else
 	    vlistDefAttFlt(vlistID, CDI_GLOBAL, attname, DATATYPE_FLT64, (int)attlen, attflt);
-	  free(attflt);
 	}
     }
 }
@@ -7340,7 +7706,7 @@ void find_time_vars(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimid,
             if ( ncvarid != streamptr->basetime.ncvarid &&
                  ncvars[ncvarid].ndims == 2 &&
                  timedimid == ncvars[ncvarid].dimids[0] &&
-                 !xtypeIsText(ncvars[ncvarid].xtype) &&
+                 xtypeIsText(ncvars[ncvarid].xtype) &&
                  ncdims[ncvars[ncvarid].dimids[1]].len == 19 )
               {
                 streamptr->basetime.ncvarid = ncvarid;
@@ -7382,6 +7748,52 @@ void find_time_vars(int nvars, ncvar_t *ncvars, ncdim_t *ncdims, int timedimid,
     }
 }
 
+static
+void read_vct_echam(int fileID, int nvars, ncvar_t *ncvars, ncdim_t *ncdims, double **vct, size_t *pvctsize)
+{
+  /* find ECHAM VCT */
+  int nvcth_id = UNDEFID, vcta_id = UNDEFID, vctb_id = UNDEFID;
+
+  for ( int ncvarid = 0; ncvarid < nvars; ncvarid++ )
+    {
+      if ( ncvars[ncvarid].ndims == 1 )
+        {
+          size_t len = strlen(ncvars[ncvarid].name);
+          if ( len == 4 && ncvars[ncvarid].name[0] == 'h' && ncvars[ncvarid].name[1] == 'y' )
+            {
+              if ( ncvars[ncvarid].name[2] == 'a' && ncvars[ncvarid].name[3] == 'i' ) // hyai
+                {
+                  vcta_id = ncvarid;
+                  nvcth_id = ncvars[ncvarid].dimids[0];
+                  ncvars[ncvarid].isvar = FALSE;
+                }
+              else if ( ncvars[ncvarid].name[2] == 'b' && ncvars[ncvarid].name[3] == 'i' ) //hybi
+                {
+                  vctb_id = ncvarid;
+                  nvcth_id = ncvars[ncvarid].dimids[0];
+                  ncvars[ncvarid].isvar = FALSE;
+                }
+              else if ( (ncvars[ncvarid].name[2] == 'a' || ncvars[ncvarid].name[2] == 'b') && ncvars[ncvarid].name[3] == 'm' )
+                {
+                  ncvars[ncvarid].isvar = FALSE; // hyam or hybm
+                }
+            }
+	}
+    }
+
+  /* read VCT */
+  if ( nvcth_id != UNDEFID && vcta_id != UNDEFID && vctb_id != UNDEFID )
+    {
+      size_t vctsize = ncdims[nvcth_id].len;
+      vctsize *= 2;
+      *vct = (double *) Malloc(vctsize*sizeof(double));
+      cdf_get_var_double(fileID, vcta_id, *vct);
+      cdf_get_var_double(fileID, vctb_id, *vct+vctsize/2);
+      *pvctsize = vctsize;
+    }
+}
+
+
 int cdfInqContents(stream_t *streamptr)
 {
   int ndims, nvars, ngatts, unlimdimid;
@@ -7396,9 +7808,6 @@ int cdfInqContents(stream_t *streamptr)
   int time_climatology = FALSE;
   int leadtime_id = UNDEFID;
   int nvars_data;
-  int nvcth_id = UNDEFID, vcta_id = UNDEFID, vctb_id = UNDEFID;
-  size_t vctsize = 0;
-  double *vct = NULL;
   int instID  = UNDEFID;
   int modelID = UNDEFID;
   int taxisID;
@@ -7440,13 +7849,13 @@ int cdfInqContents(stream_t *streamptr)
     }
 
   /* alloc ncdims */
-  ncdims = (ncdim_t *)xmalloc((size_t)ndims * sizeof (ncdim_t));
+  ncdims = (ncdim_t *) Malloc((size_t)ndims * sizeof (ncdim_t));
   init_ncdims(ndims, ncdims);
 
   if ( nvars > 0 )
     {
       /* alloc ncvars */
-      ncvars = (ncvar_t *)xmalloc((size_t)nvars * sizeof (ncvar_t));
+      ncvars = (ncvar_t *) Malloc((size_t)nvars * sizeof (ncvar_t));
       init_ncvars(nvars, ncvars);
 
       for ( ncvarid = 0; ncvarid < nvars; ++ncvarid )
@@ -7487,7 +7896,7 @@ int cdfInqContents(stream_t *streamptr)
     }
 
   /* scan global attributes */
-  scan_global_attributes(fileID, vlistID, streamptr, ngatts, &instID, &modelID, &ucla_les, 
+  scan_global_attributes(fileID, vlistID, streamptr, ngatts, &instID, &modelID, &ucla_les,
                          uuidOfHGrid, uuidOfVGrid, gridfile, &number_of_grid_used);
 
   /* find time dim */
@@ -7620,7 +8029,7 @@ int cdfInqContents(stream_t *streamptr)
     }
 
   /* verify coordinate vars - first scan (dimname == varname) */
-  verify_coordinate_vars_1(ndims, ncdims, ncvars, timedimid);
+  verify_coordinate_vars_1(fileID, ndims, ncdims, ncvars, timedimid);
 
   /* verify coordinate vars - second scan (all other variables) */
   verify_coordinate_vars_2(nvars, ncvars);
@@ -7691,57 +8100,25 @@ int cdfInqContents(stream_t *streamptr)
   /* set dim type */
   setDimType(nvars, ncvars, ncdims);
 
-  /* find VCT */
-  for ( ncvarid = 0; ncvarid < nvars; ncvarid++ )
-    {
-      if ( ncvars[ncvarid].ndims == 1 )
-	{
-	  if ( memcmp(ncvars[ncvarid].name, "hyai", 4) == 0 )
-	    {
-	      vcta_id = ncvarid;
-	      nvcth_id = ncvars[ncvarid].dimids[0];
-              ncvars[ncvarid].isvar = FALSE;
-	      continue;
-	    }
-	  if ( memcmp(ncvars[ncvarid].name, "hybi", 4) == 0 )
-	    {
-	      vctb_id = ncvarid;
-	      nvcth_id = ncvars[ncvarid].dimids[0];
-              ncvars[ncvarid].isvar = FALSE;
-	      continue;
-	    }
+  /* read ECHAM VCT if present */
+  size_t vctsize = 0;
+  double *vct = NULL;
+  read_vct_echam(fileID, nvars, ncvars, ncdims, &vct, &vctsize);
 
-	  if      ( memcmp(ncvars[ncvarid].name, "hyam", 4) == 0 ) ncvars[ncvarid].isvar = FALSE;
-	  else if ( memcmp(ncvars[ncvarid].name, "hybm", 4) == 0 ) ncvars[ncvarid].isvar = FALSE;
-	}
-    }
 
   if ( CDI_Debug ) printNCvars(ncvars, nvars, "define_all_grids");
 
-
   /* define all grids */
   define_all_grids(streamptr, vlistID, ncdims, nvars, ncvars, timedimid, uuidOfHGrid, gridfile, number_of_grid_used);
 
 
-  /* read VCT */
-  if ( nvcth_id != UNDEFID && vcta_id != UNDEFID && vctb_id != UNDEFID )
-    {
-      vctsize = ncdims[nvcth_id].len;
-      vctsize *= 2;
-      vct = (double *) malloc(vctsize*sizeof(double));
-      cdf_get_var_double(fileID, vcta_id, vct);
-      cdf_get_var_double(fileID, vctb_id, vct+vctsize/2);
-    }
-
-
   /* define all zaxes */
   define_all_zaxes(streamptr, vlistID, ncdims, nvars, ncvars, vctsize, vct, uuidOfVGrid);
+  if ( vct ) Free(vct);
 
 
-  if ( vct ) free(vct);
-
   /* select vars */
-  varids = (int *)xmalloc((size_t)nvars * sizeof (int));
+  varids = (int *) Malloc((size_t)nvars * sizeof (int));
   nvarids = 0;
   for ( ncvarid = 0; ncvarid < nvars; ncvarid++ )
     if ( ncvars[ncvarid].isvar == TRUE ) varids[nvarids++] = ncvarid;
@@ -7771,15 +8148,15 @@ int cdfInqContents(stream_t *streamptr)
   cdiCreateTimesteps(streamptr);
 
   /* time varID */
-  ncvarid = streamptr->basetime.ncvarid;
+  int nctimevarid = streamptr->basetime.ncvarid;
 
   if ( time_has_units )
     {
       taxis_t *taxis = &streamptr->tsteps[0].taxis;
 
-      if ( setBaseTime(ncvars[ncvarid].units, taxis) == 1 )
+      if ( setBaseTime(ncvars[nctimevarid].units, taxis) == 1 )
         {
-          ncvarid = UNDEFID;
+          nctimevarid = UNDEFID;
           streamptr->basetime.ncvarid = UNDEFID;
         }
 
@@ -7803,23 +8180,21 @@ int cdfInqContents(stream_t *streamptr)
       if ( time_climatology ) streamptr->tsteps[0].taxis.climatology = TRUE;
     }
 
-  if ( ncvarid != UNDEFID )
+  if ( nctimevarid != UNDEFID )
     {
       taxis_t *taxis = &streamptr->tsteps[0].taxis;
-      ptaxisDefName(taxis, ncvars[ncvarid].name);
-      if ( ncvars[ncvarid].longname[0] )
-        ptaxisDefLongname(taxis, ncvars[ncvarid].longname);
+      ptaxisDefName(taxis, ncvars[nctimevarid].name);
+      if ( ncvars[nctimevarid].longname[0] )
+        ptaxisDefLongname(taxis, ncvars[nctimevarid].longname);
     }
 
-  if ( ncvarid != UNDEFID )
-    if ( ncvars[ncvarid].calendar == TRUE )
+  if ( nctimevarid != UNDEFID )
+    if ( ncvars[nctimevarid].calendar == TRUE )
       {
-        enum {
-          attstringlen = 8192,
-        };
+        enum {attstringlen = 8192};
         char attstring[attstringlen];
 
-	cdfGetAttText(fileID, ncvarid, "calendar", attstringlen, attstring);
+	cdfGetAttText(fileID, nctimevarid, "calendar", attstringlen, attstring);
 	strtolower(attstring);
 
 	if ( memcmp(attstring, "standard", 8)  == 0 ||
@@ -7865,12 +8240,19 @@ int cdfInqContents(stream_t *streamptr)
       calendar = CALENDAR_STANDARD;
     }
 
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic warning "-Wstrict-overflow"
+#endif
   if ( calendar != UNDEFID )
     {
       taxis_t *taxis = &streamptr->tsteps[0].taxis;
       taxis->calendar = calendar;
       taxisDefCalendar(taxisID, calendar);
     }
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 5)
+#pragma GCC diagnostic pop
+#endif
 
   vlistDefTaxis(vlistID, taxisID);
 
@@ -7882,10 +8264,10 @@ int cdfInqContents(stream_t *streamptr)
   cdfCreateRecords(streamptr, 0);
 
   /* free ncdims */
-  free(ncdims);
+  Free(ncdims);
 
   /* free ncvars */
-  free(ncvars);
+  Free(ncvars);
 
   return (0);
 }
@@ -7946,6 +8328,7 @@ double get_timevalue(int fileID, int nctimevarid, int tsID, timecache_t *tcache)
   return timevalue;
 }
 
+
 int cdfInqTimestep(stream_t * streamptr, int tsID)
 {
   long nrecs = 0;
@@ -7982,7 +8365,7 @@ int cdfInqTimestep(stream_t * streamptr, int tsID)
 #if defined (USE_TIMECACHE)
               if ( streamptr->basetime.timevar_cache == NULL )
                 {
-                  streamptr->basetime.timevar_cache = (timecache_t *) malloc(MAX_TIMECACHE_SIZE*sizeof(timecache_t));
+                  streamptr->basetime.timevar_cache = (timecache_t *) Malloc(MAX_TIMECACHE_SIZE*sizeof(timecache_t));
                   streamptr->basetime.timevar_cache->size = 0;
                   streamptr->basetime.timevar_cache->maxvals = streamptr->ntsteps;
                 }
@@ -8046,8 +8429,6 @@ void cdfEndDef(stream_t *streamptr)
 
       if ( streamptr->ncmode == 2 )
         {
-          extern size_t CDI_netcdf_hdr_pad;
-
           if ( CDI_netcdf_hdr_pad == 0UL )
             cdf_enddef(fileID);
           else
@@ -8192,36 +8573,34 @@ void cdfInqHistoryString(stream_t *streamptr, char *history)
 
 void cdfDefVars(stream_t *streamptr)
 {
-  /* int  nvars, ncvarid; */
-
   int vlistID = streamptr->vlistID;
   if ( vlistID == UNDEFID )
     Error("Internal problem! vlist undefined for streamptr %p", streamptr);
 
-  /* nvars  = vlistNvars(vlistID); */
   int ngrids = vlistNgrids(vlistID);
   int nzaxis = vlistNzaxis(vlistID);
   /*
   if ( vlistHasTime(vlistID) ) cdfDefTime(streamptr);
   */
-  if (ngrids > 0)
-    for (size_t index = 0; index < (size_t)ngrids; index++ )
+  if ( ngrids > 0 )
+    for ( int index = 0; index < ngrids; index++ )
       {
-        int gridID = vlistGrid(vlistID, (int)index);
+        int gridID = vlistGrid(vlistID, index);
         cdfDefGrid(streamptr, gridID);
       }
 
-  if (nzaxis > 0)
-    for (size_t index = 0; index < (size_t)nzaxis; index++ )
+  if ( nzaxis > 0 )
+    for ( int index = 0; index < nzaxis; index++ )
       {
-        int zaxisID = vlistZaxis(vlistID, (int)index);
+        int zaxisID = vlistZaxis(vlistID, index);
         if ( streamptr->zaxisID[index] == UNDEFID ) cdfDefZaxis(streamptr, zaxisID);
       }
-  /*
-    define time first!!!
-  for (varID = 0; varID < nvars; varID++ )
+
+  /* define time first!!!
+    int nvars  = vlistNvars(vlistID);
+  for ( int varID = 0; varID < nvars; varID++ )
     {
-      ncvarid = cdfDefVar(streamptr, varID);
+      int ncvarid = cdfDefVar(streamptr, varID);
     }
   */
 }
diff --git a/libcdi/src/stream_cgribex.c b/libcdi/src/stream_cgribex.c
index c8f2419..693c772 100644
--- a/libcdi/src/stream_cgribex.c
+++ b/libcdi/src/stream_cgribex.c
@@ -2,6 +2,7 @@
 #  include "config.h"
 #endif
 
+#include <limits.h>
 #include <stdio.h>
 // #include <float.h>  /* FLT_EPSILON */
 
@@ -13,13 +14,12 @@
 #include "datetime.h"
 #include "vlist.h"
 #include "stream_grb.h"
+#include "stream_cgribex.h"
 
 #if  defined  (HAVE_LIBCGRIBEX)
 #  include "cgribex.h"
 #endif
 
-extern int cdiInventoryMode;
-
 typedef struct {
   int param;
   int level1;
@@ -348,7 +348,7 @@ void cgribexGetGrid(stream_t *streamptr, int *isec2, double *fsec2, int *isec4,
       grid->isRotated = TRUE;
       grid->ypole     = - ISEC2_LatSP*0.001;
       grid->xpole     =   ISEC2_LonSP*0.001 - 180;
-      grid->angle     = FSEC2_RotAngle;
+      grid->angle     = - FSEC2_RotAngle;
     }
 
   grid->xvals = NULL;
@@ -405,10 +405,11 @@ void cgribexAddRecord(stream_t * streamptr, int param, int *isec1, int *isec2, d
   if ( datatype <  0 ) datatype = DATATYPE_PACK;
 
   varAddRecord(recID, param, gridID, zaxistype, lbounds, level1, level2, 0, 0,
-	       datatype, &varID, &levelID, tsteptype, numavg, ISEC1_LevelType, -1, NULL, NULL, NULL, NULL);
+	       datatype, &varID, &levelID, tsteptype, numavg, ISEC1_LevelType, -1,
+               NULL, NULL, NULL, NULL, NULL, NULL);
 
-  (*record).varID   = (short)varID;
-  (*record).levelID = (short)levelID;
+  record->varID   = (short)varID;
+  record->levelID = (short)levelID;
 
   varDefCompType(varID, comptype);
 
@@ -577,18 +578,15 @@ cgribexScanTsConstAdjust(stream_t *streamptr, taxis_t *taxis)
 
 int cgribexScanTimestep1(stream_t * streamptr)
 {
-  int *isec0, *isec1, *isec2, *isec3, *isec4;
   double fsec2[512], fsec3[2], *fsec4 = NULL;
   int lmv = 0, iret = 0;
   off_t recpos = 0;
-  unsigned char *gribbuffer = NULL;
+  void *gribbuffer = NULL;
   size_t buffersize = 0;
   int rstatus;
-  int fileID;
   int param = 0;
   int level1 = 0, level2 = 0, vdate = 0, vtime = 0;
-  DateTime datetime, datetime0;
-  int tsID;
+  DateTime datetime, datetime0 = { LONG_MIN, LONG_MIN };
   size_t readsize;
   unsigned nrecords, recID;
   int nrecs_scanned = 0;
@@ -598,29 +596,27 @@ int cgribexScanTimestep1(stream_t * streamptr)
   int warn_numavg = TRUE;
   int taxisID = -1;
   int rdate = 0, rtime = 0, tunit = 0, fcast = 0;
-  taxis_t *taxis;
   int vlistID;
   int comptype;
   long unzipsize;
   char paramstr[32];
-  extern int cdiSkipRecords;
   int nskip = cdiSkipRecords;
 
   streamptr->curTsID = 0;
 
-  isec0 = streamptr->record->sec0;
-  isec1 = streamptr->record->sec1;
-  isec2 = streamptr->record->sec2;
-  isec3 = streamptr->record->sec3;
-  isec4 = streamptr->record->sec4;
+  int *isec0 = streamptr->record->sec0;
+  int *isec1 = streamptr->record->sec1;
+  int *isec2 = streamptr->record->sec2;
+  int *isec3 = streamptr->record->sec3;
+  int *isec4 = streamptr->record->sec4;
 
-  tsID  = tstepsNewEntry(streamptr);
-  taxis = &streamptr->tsteps[tsID].taxis;
+  int tsID  = tstepsNewEntry(streamptr);
+  taxis_t *taxis = &streamptr->tsteps[tsID].taxis;
 
   if ( tsID != 0 )
     Error("Internal problem! tstepsNewEntry returns %d", tsID);
 
-  fileID = streamptr->fileID;
+  int fileID = streamptr->fileID;
 
   while ( nskip-- > 0 )
     {
@@ -649,22 +645,22 @@ int cgribexScanTimestep1(stream_t * streamptr)
       if ( (size_t)recsize > buffersize )
 	{
 	  buffersize = (size_t)recsize;
-	  gribbuffer = (unsigned char *)xrealloc(gribbuffer, buffersize);
+	  gribbuffer = Realloc(gribbuffer, buffersize);
 	}
 
       readsize = (size_t)recsize;
-      rstatus = gribRead(fileID, gribbuffer, &readsize);
+      rstatus = gribRead(fileID, (unsigned char *)gribbuffer, &readsize);
       if ( rstatus ) break;
 
       comptype = COMPRESS_NONE;
-      if ( gribGetZip(recsize, gribbuffer, &unzipsize) > 0 )
+      if ( gribGetZip(recsize, (unsigned char *)gribbuffer, &unzipsize) > 0 )
 	{
 	  comptype = COMPRESS_SZIP;
 	  unzipsize += 100; /* need 0 to 1 bytes for rounding of bds */
 	  if ( buffersize < (size_t)unzipsize )
 	    {
 	      buffersize = (size_t)unzipsize;
-	      gribbuffer = (unsigned char *) realloc(gribbuffer, buffersize);
+	      gribbuffer = Realloc(gribbuffer, buffersize);
 	    }
 	}
 
@@ -700,9 +696,7 @@ int cgribexScanTimestep1(stream_t * streamptr)
 	{
 	  datetime.date  = vdate;
 	  datetime.time  = vtime;
-
 	  compvar_t compVar = cgribexVarSet(param, level1, level2, ISEC1_LevelType, ISEC1_TimeRange);
-
 	  for ( recID = 0; recID < nrecs; recID++ )
 	    {
 	      if ( cgribexVarCompare(compVar, streamptr->tsteps[0].records[recID], 0) == 0 ) break;
@@ -712,7 +706,7 @@ int cgribexScanTimestep1(stream_t * streamptr)
 	    {
 	      if ( recID < nrecs ) break;
 	      if ( warn_time )
-		if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) != 0 )
+		if ( datetimeCmp(datetime, datetime0) != 0 )
 		  {
                     gribWarning("Inconsistent verification time!", nrecs_scanned, tsID+1, paramstr, level1, level2);
 		    warn_time = FALSE;
@@ -720,7 +714,7 @@ int cgribexScanTimestep1(stream_t * streamptr)
 	    }
 	  else
 	    {
-	      if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) != 0 ) break;
+	      if ( datetimeCmp(datetime, datetime0) != 0 ) break;
 
 	      if ( recID < nrecs )
 		{
@@ -784,10 +778,10 @@ int cgribexScanTimestep1(stream_t * streamptr)
     {
       streamptr->tsteps[0].recordSize = (int)nrecords;
       streamptr->tsteps[0].records =
-      (record_t *) realloc(streamptr->tsteps[0].records, nrecords*sizeof(record_t));
+      (record_t *) Realloc(streamptr->tsteps[0].records, nrecords*sizeof(record_t));
     }
 
-  streamptr->tsteps[0].recIDs = (int *) malloc(nrecords*sizeof(int));
+  streamptr->tsteps[0].recIDs = (int *) Malloc(nrecords*sizeof(int));
   streamptr->tsteps[0].nrecs = (int)nrecords;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[0].recIDs[recID] = (int)recID;
@@ -805,57 +799,48 @@ int cgribexScanTimestep1(stream_t * streamptr)
 int cgribexScanTimestep2(stream_t * streamptr)
 {
   int rstatus = 0;
-  int *isec0, *isec1, *isec2, *isec3, *isec4;
   double fsec2[512], fsec3[2], *fsec4 = NULL;
   int lmv = 0, iret = 0;
   off_t recpos = 0;
-  unsigned char *gribbuffer = NULL;
-  size_t buffersize = 0;
-  int fileID;
   int param = 0;
   int level1 = 0, level2 = 0, vdate = 0, vtime = 0;
-  DateTime datetime, datetime0;
-  int tsID;
+  DateTime datetime, datetime0 = { LONG_MIN, LONG_MIN };
   int varID, gridID;
   size_t readsize;
-  int nrecords, nrecs, recID, rindex;
-  int nrecs_scanned = 0;
+  int nrecs, recID;
   long recsize = 0;
   int warn_numavg = TRUE;
   int tsteptype;
-  int taxisID = -1;
-  taxis_t *taxis;
-  int vlistID;
   long unzipsize;
   char paramstr[32];
 
   streamptr->curTsID = 1;
 
-  isec0 = streamptr->record->sec0;
-  isec1 = streamptr->record->sec1;
-  isec2 = streamptr->record->sec2;
-  isec3 = streamptr->record->sec3;
-  isec4 = streamptr->record->sec4;
+  int *isec0 = streamptr->record->sec0;
+  int *isec1 = streamptr->record->sec1;
+  int *isec2 = streamptr->record->sec2;
+  int *isec3 = streamptr->record->sec3;
+  int *isec4 = streamptr->record->sec4;
 
-  fileID  = streamptr->fileID;
-  vlistID = streamptr->vlistID;
-  taxisID = vlistInqTaxis(vlistID);
+  int fileID  = streamptr->fileID;
+  int vlistID = streamptr->vlistID;
+  int taxisID = vlistInqTaxis(vlistID);
 
-  gribbuffer = (unsigned char *) streamptr->record->buffer;
-  buffersize = streamptr->record->buffersize;
+  void *gribbuffer = streamptr->record->buffer;
+  size_t buffersize = streamptr->record->buffersize;
 
-  tsID = streamptr->rtsteps;
+  int tsID = streamptr->rtsteps;
   if ( tsID != 1 )
     Error("Internal problem! unexpected timestep %d", tsID+1);
 
-  taxis = &streamptr->tsteps[tsID].taxis;
+  taxis_t *taxis = &streamptr->tsteps[tsID].taxis;
 
   fileSetPos(fileID, streamptr->tsteps[tsID].position, SEEK_SET);
 
   cdi_create_records(streamptr, tsID);
 
-  nrecords = streamptr->tsteps[tsID].nallrecs;
-  if ( nrecords ) streamptr->tsteps[1].recIDs = (int *)xmalloc((size_t)nrecords * sizeof(int));
+  int nrecords = streamptr->tsteps[tsID].nallrecs;
+  if ( nrecords ) streamptr->tsteps[1].recIDs = (int *) Malloc((size_t)nrecords * sizeof(int));
   streamptr->tsteps[1].nrecs = 0;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[1].recIDs[recID] = -1;
@@ -867,8 +852,8 @@ int cgribexScanTimestep2(stream_t * streamptr)
       streamptr->tsteps[tsID].records[recID].size     =	streamptr->tsteps[0].records[recID].size;
     }
 
-  nrecs_scanned = nrecords;
-  rindex = 0;
+  int nrecs_scanned = nrecords;
+  int rindex = 0;
   while ( TRUE )
     {
       if ( rindex > nrecords ) break;
@@ -883,20 +868,20 @@ int cgribexScanTimestep2(stream_t * streamptr)
       if ( (size_t)recsize > buffersize )
 	{
 	  buffersize = (size_t)recsize;
-	  gribbuffer = (unsigned char *)xrealloc(gribbuffer, buffersize);
+	  gribbuffer = Realloc(gribbuffer, buffersize);
 	}
 
       readsize = (size_t)recsize;
-      rstatus = gribRead(fileID, gribbuffer, &readsize);
+      rstatus = gribRead(fileID, (unsigned char *)gribbuffer, &readsize);
       if ( rstatus ) break;
 
-      if ( gribGetZip(recsize, gribbuffer, &unzipsize) > 0 )
+      if ( gribGetZip(recsize, (unsigned char *)gribbuffer, &unzipsize) > 0 )
 	{
 	  unzipsize += 100; /* need 0 to 1 bytes for rounding of bds */
 	  if ( buffersize < (size_t)unzipsize )
 	    {
 	      buffersize = (size_t)unzipsize;
-	      gribbuffer = (unsigned char *) realloc(gribbuffer, buffersize);
+	      gribbuffer = Realloc(gribbuffer, buffersize);
 	    }
 	}
 
@@ -985,7 +970,7 @@ int cgribexScanTimestep2(stream_t * streamptr)
 	{
 	  if ( streamptr->tsteps[tsID].records[recID].used )
 	    {
-	      if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) != 0 ) break;
+	      if ( datetimeCmp(datetime, datetime0) != 0 ) break;
 
               gribWarning("Parameter already exist, skipped!", nrecs_scanned, tsID+1, paramstr, level1, level2);
 	      continue;
@@ -1062,12 +1047,12 @@ int cgribexScanTimestep(stream_t * streamptr)
   int lmv = 0, iret = 0;
   long recsize = 0;
   off_t recpos = 0;
-  unsigned char *gribbuffer;
+  void *gribbuffer;
   size_t buffersize = 0;
   int fileID;
   int param = 0;
   int level1 = 0, level2 = 0, vdate = 0, vtime = 0;
-  DateTime datetime, datetime0;
+  DateTime datetime, datetime0 = { LONG_MIN, LONG_MIN };
   int vrecID, recID;
   int warn_numavg = TRUE;
   size_t readsize;
@@ -1097,7 +1082,7 @@ int cgribexScanTimestep(stream_t * streamptr)
 
   if ( streamptr->tsteps[tsID].recordSize == 0 )
     {
-      gribbuffer = (unsigned char *) streamptr->record->buffer;
+      gribbuffer = streamptr->record->buffer;
       buffersize = streamptr->record->buffersize;
 
       cdi_create_records(streamptr, tsID);
@@ -1105,7 +1090,7 @@ int cgribexScanTimestep(stream_t * streamptr)
       nrecs = streamptr->tsteps[1].nrecs;
 
       streamptr->tsteps[tsID].nrecs = nrecs;
-      streamptr->tsteps[tsID].recIDs = (int *)xmalloc((size_t)nrecs * sizeof (int));
+      streamptr->tsteps[tsID].recIDs = (int *) Malloc((size_t)nrecs * sizeof (int));
       for ( recID = 0; recID < nrecs; recID++ )
 	streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
 
@@ -1129,13 +1114,13 @@ int cgribexScanTimestep(stream_t * streamptr)
 	  if ( recsize > 0 && (size_t)recsize > buffersize )
 	    {
 	      buffersize = (size_t)recsize;
-	      gribbuffer = (unsigned char *) realloc(gribbuffer, buffersize);
+	      gribbuffer = Realloc(gribbuffer, buffersize);
 	    }
 
 	  if ( rindex >= nrecs ) break;
 
 	  readsize = (size_t)recsize;
-	  rstatus = gribRead(fileID, gribbuffer, &readsize);
+	  rstatus = gribRead(fileID, (unsigned char *)gribbuffer, &readsize);
 	  if ( rstatus )
 	    {
 	      Warning("Inconsistent timestep %d (GRIB record %d/%d)!", tsID+1, rindex+1,
@@ -1143,13 +1128,13 @@ int cgribexScanTimestep(stream_t * streamptr)
 	      break;
 	    }
 
-	  if ( gribGetZip(recsize, gribbuffer, &unzipsize) > 0 )
+	  if ( gribGetZip(recsize, (unsigned char *)gribbuffer, &unzipsize) > 0 )
 	    {
 	      unzipsize += 100; /* need 0 to 1 bytes for rounding of bds */
 	      if ( buffersize < (size_t)unzipsize )
 		{
 		  buffersize = (size_t)unzipsize;
-		  gribbuffer = (unsigned char *) realloc(gribbuffer, buffersize);
+		  gribbuffer = Realloc(gribbuffer, buffersize);
 		}
 	    }
 
@@ -1238,13 +1223,13 @@ int cgribexScanTimestep(stream_t * streamptr)
 	    {
 	      if ( streamptr->tsteps[tsID].records[recID].used )
 		{
-		  char paramstr[32];
-		  cdiParamToString(param, paramstr, sizeof(paramstr));
+		  char paramstr_[32];
+		  cdiParamToString(param, paramstr_, sizeof(paramstr_));
 
-		  if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) != 0 ) break;
+		  if ( datetimeCmp(datetime, datetime0) != 0 ) break;
 
 		  if ( CDI_Debug )
-                    gribWarning("Parameter already exist, skipped!", nrecs_scanned, tsID+1, paramstr, level1, level2);
+                    gribWarning("Parameter already exist, skipped!", nrecs_scanned, tsID+1, paramstr_, level1, level2);
 
 		  continue;
 		}
@@ -1338,7 +1323,7 @@ int cgribexDecode(unsigned char *gribbuffer, int gribsize, double *data, int gri
   FSEC3_MissVal = missval;
 
   gribExDP(isec0, isec1, isec2, fsec2, isec3, fsec3, isec4, data,
-	   gridsize, (int *) gribbuffer, gribsize, &iword, hoper, &iret);
+	   gridsize, (int *)(void *)gribbuffer, gribsize, &iword, hoper, &iret);
 
   if ( ISEC1_Sec2Or3Flag & 64 )
     *nmiss = ISEC4_NumValues - ISEC4_NumNonMissValues;
@@ -1421,7 +1406,7 @@ void cgribexDefParam(int *isec1, int param)
   static bool lwarn_pnum = true;
   if ( pnum > 255 && lwarn_pnum )
     {
-      Warning("Parameter number %d out of bounds (1-255), set to %d!", pnum, pnum%256);
+      Warning("Parameter number %d out of range (1-255), set to %d!", pnum, pnum%256);
       lwarn_pnum = false;
       pnum = pnum%256;
     }
@@ -1449,7 +1434,7 @@ int cgribexDefTimerange(int tsteptype, int factor, int calendar,
 
   (void) julday_sub(julday1, secofday1, julday2, secofday2, &days, &secs);
 
-  if ( !(int) fmod(days*86400.0 + secs, factor) )
+  if ( !(int)(fmod(days*86400.0 + secs, factor)) )
     {
       ip = (int) ((days*86400.0 + secs)/factor);
 
@@ -1760,7 +1745,9 @@ void cgribexDefGrid(int *isec1, int *isec2, double *fsec2, int *isec4, int gridI
 	  {
 	    ISEC2_LatSP = - (int)lround(gridInqYpole(gridID) * 1000);
 	    ISEC2_LonSP =   (int)lround((gridInqXpole(gridID) + 180) * 1000);
-            FSEC2_RotAngle = gridInqAngle(gridID);
+            double angle = gridInqAngle(gridID);
+            if ( fabs(angle) > 0 ) angle = -angle;
+            FSEC2_RotAngle = angle;
 	  }
 
 	/* East -> West */
@@ -1875,7 +1862,7 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
     case ZAXIS_SURFACE:
       {
 	ISEC1_LevelType = GRIB1_LTYPE_SURFACE;
-	ISEC1_Level1    = (int) zaxisInqLevel(zaxisID, levelID);
+	ISEC1_Level1    = (int)(zaxisInqLevel(zaxisID, levelID));
 	ISEC1_Level2    = 0;
 	break;
       }
@@ -1924,7 +1911,7 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
     case ZAXIS_MEANSEA:
       {
 	ISEC1_LevelType = GRIB1_LTYPE_MEANSEA;
-	ISEC1_Level1    = (int) zaxisInqLevel(zaxisID, levelID);
+	ISEC1_Level1    = (int)(zaxisInqLevel(zaxisID, levelID));
 	ISEC1_Level2    = 0;
 	break;
       }
@@ -1936,13 +1923,13 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
 	if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
 	  {
 	    ISEC1_LevelType = GRIB1_LTYPE_HYBRID_LAYER;
-	    ISEC1_Level1    = (int) zaxisInqLbound(zaxisID, levelID);
-	    ISEC1_Level2    = (int) zaxisInqUbound(zaxisID, levelID);
+	    ISEC1_Level1    = (int)(zaxisInqLbound(zaxisID, levelID));
+	    ISEC1_Level2    = (int)(zaxisInqUbound(zaxisID, levelID));
 	  }
 	else
 	  {
 	    ISEC1_LevelType = GRIB1_LTYPE_HYBRID;
-	    ISEC1_Level1    = (int) zaxisInqLevel(zaxisID, levelID);
+	    ISEC1_Level1    = (int)(zaxisInqLevel(zaxisID, levelID));
 	    ISEC1_Level2    = 0;
 	  }
 
@@ -1978,7 +1965,7 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
 	  Warning("Pressure level of %f Pa is below zero!", level);
 
 	zaxisInqUnits(zaxisID, units);
-	if ( memcmp(units, "Pa", 2) != 0 ) level *= 100;
+	if ( (units[0] != 'P') | (units[1] != 'a') ) level *= 100;
 
 	ilevel = (int) level;
 	if ( level < 32768 && (level < 100 || modf(level/100, &dum) > 0) )
@@ -2022,8 +2009,8 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
 	if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
 	  {
 	    ISEC1_LevelType = GRIB1_LTYPE_SIGMA_LAYER;
-	    ISEC1_Level1    = (int) zaxisInqLbound(zaxisID, levelID);
-	    ISEC1_Level2    = (int) zaxisInqUbound(zaxisID, levelID);
+	    ISEC1_Level1    = (int)(zaxisInqLbound(zaxisID, levelID));
+	    ISEC1_Level2    = (int)(zaxisInqUbound(zaxisID, levelID));
 	  }
 	else
 	  {
@@ -2044,10 +2031,10 @@ void cgribexDefLevel(int *isec1, int *isec2, double *fsec2, int zaxisID, int lev
 
 	zaxisInqUnits(zaxisID, units);
 
-        if      ( memcmp(units, "mm", 2) == 0 ) factor =   0.1;
-        else if ( memcmp(units, "cm", 2) == 0 ) factor =   1;
-        else if ( memcmp(units, "dm", 2) == 0 ) factor =  10;
-        else                                    factor = 100; // meter
+        if      ( units[0] == 'm' && units[1] == 'm' ) factor =   0.1;
+        else if ( units[0] == 'c' && units[1] == 'm' ) factor =   1;
+        else if ( units[0] == 'd' && units[1] == 'm' ) factor =  10;
+        else                                           factor = 100; // meter
 
 	if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
 	  {
@@ -2226,10 +2213,10 @@ size_t cgribexEncode(int memtype, int varID, int levelID, int vlistID, int gridI
 
   if ( memtype == MEMTYPE_FLOAT )
     gribExSP(isec0, isec1, isec2, fsec2f, isec3, fsec3f, isec4, (float*) data,
-             (int)datasize, (int *) gribbuffer, gribsize, &iword, "C", &iret);
+             (int)datasize, (int *)(void *)gribbuffer, gribsize, &iword, "C", &iret);
   else
     gribExDP(isec0, isec1, isec2, fsec2, isec3, fsec3, isec4, (double*) data,
-             (int)datasize, (int *) gribbuffer, gribsize, &iword, "C", &iret);
+             (int)datasize, (int *)(void *)gribbuffer, gribsize, &iword, "C", &iret);
 
   if ( iret ) Error("Problem during GRIB encode (errno = %d)!", iret);
 
diff --git a/libcdi/src/stream_ext.c b/libcdi/src/stream_ext.c
index a12b556..0aaa821 100644
--- a/libcdi/src/stream_ext.c
+++ b/libcdi/src/stream_ext.c
@@ -2,6 +2,7 @@
 #  include "config.h"
 #endif
 
+#include <limits.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -80,7 +81,7 @@ int extInqRecord(stream_t *streamptr, int *varID, int *levelID)
   int zaxisID = -1;
   int header[4];
   int vlistID;
-  extrec_t *extp = (extrec_t*) streamptr->record->exsep;
+  void *extp = streamptr->record->exsep;
 
   vlistID = streamptr->vlistID;
   fileID  = streamptr->fileID;
@@ -118,7 +119,7 @@ void extReadRecord(stream_t *streamptr, double *data, int *nmiss)
   int varID, gridID;
   int i, size;
   double missval;
-  extrec_t *extp = (extrec_t*) streamptr->record->exsep;
+  void *extp = streamptr->record->exsep;
 
   vlistID = streamptr->vlistID;
   fileID  = streamptr->fileID;
@@ -195,7 +196,7 @@ void extDefRecord(stream_t *streamptr)
 void extWriteRecord(stream_t *streamptr, const double *data)
 {
   int fileID = streamptr->fileID;
-  extrec_t *extp = (extrec_t*) streamptr->record->exsep;
+  void *extp = streamptr->record->exsep;
 
   extDefDataDP(extp, data);
   extWrite(fileID, extp);
@@ -238,7 +239,8 @@ void extAddRecord(stream_t *streamptr, int param, int level, int xysize,
   leveltype = ZAXIS_GENERIC;
 
   varAddRecord(recID, param, gridID, leveltype, 0, level, 0, 0, 0,
-	       extInqDatatype(prec, number), &varID, &levelID, TSTEP_INSTANT, 0, 0, -1, NULL, NULL, NULL, NULL);
+	       extInqDatatype(prec, number), &varID, &levelID, TSTEP_INSTANT, 0, 0, -1,
+               NULL, NULL, NULL, NULL, NULL, NULL);
 
   (*record).varID   = (short)varID;
   (*record).levelID = (short)levelID;
@@ -260,7 +262,7 @@ void extScanTimestep1(stream_t *streamptr)
   int rxysize = 0;
   int param = 0;
   int rcode = 0, rlevel = 0, vdate = 0, vtime = 0;
-  DateTime datetime, datetime0;
+  DateTime datetime0 = { LONG_MIN, LONG_MIN };
   int tsID;
   int varID;
   long recsize;
@@ -311,8 +313,6 @@ void extScanTimestep1(stream_t *streamptr)
 	}
       else
 	{
-	  datetime.date = vdate;
-	  datetime.time = vtime;
 	  compVar.param = param;
           compVar.level = rlevel;
 	  for ( recID = 0; recID < nrecs; recID++ )
@@ -323,7 +323,8 @@ void extScanTimestep1(stream_t *streamptr)
 	      if ( memcmp(&compVar0, &compVar, sizeof(extcompvar_t)) == 0 ) break;
 	    }
 	  if ( recID < nrecs ) break;
-	  if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) )
+	  DateTime datetime = { .date = vdate, .time = vtime};
+	  if ( datetimeCmp(datetime, datetime0) )
 	    Warning("Inconsistent verification time for code %d level %d", rcode, rlevel);
 	}
 
@@ -354,10 +355,10 @@ void extScanTimestep1(stream_t *streamptr)
     {
       streamptr->tsteps[0].recordSize = nrecords;
       streamptr->tsteps[0].records =
-        (record_t *)xrealloc(streamptr->tsteps[0].records, (size_t)nrecords * sizeof (record_t));
+        (record_t *) Realloc(streamptr->tsteps[0].records, (size_t)nrecords * sizeof (record_t));
     }
 
-  streamptr->tsteps[0].recIDs = (int *)xmalloc((size_t)nrecords * sizeof (int));
+  streamptr->tsteps[0].recIDs = (int *) Malloc((size_t)nrecords * sizeof (int));
   streamptr->tsteps[0].nrecs = nrecords;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[0].recIDs[recID] = recID;
@@ -402,7 +403,7 @@ int extScanTimestep2(stream_t *streamptr)
   taxis_t *taxis;
   int vlistID;
   extcompvar_t compVar, compVar0;
-  extrec_t *extp = (extrec_t*) streamptr->record->exsep;
+  void *extp = streamptr->record->exsep;
 
   streamptr->curTsID = 1;
 
@@ -420,7 +421,7 @@ int extScanTimestep2(stream_t *streamptr)
   cdi_create_records(streamptr, tsID);
 
   nrecords = streamptr->tsteps[0].nallrecs;
-  streamptr->tsteps[1].recIDs = xmalloc((size_t)nrecords * sizeof (int));
+  streamptr->tsteps[1].recIDs = (int *) Malloc((size_t)nrecords * sizeof (int));
   streamptr->tsteps[1].nrecs = 0;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[1].recIDs[recID] = -1;
@@ -574,7 +575,7 @@ long extScanTimestep(stream_t *streamptr)
   int recID;
   int rindex, nrecs = 0;
   extcompvar_t compVar, compVar0;
-  extrec_t *extp = (extrec_t*) streamptr->record->exsep;
+  void *extp = streamptr->record->exsep;
   /*
   if ( CDI_Debug )
     {
@@ -595,7 +596,7 @@ long extScanTimestep(stream_t *streamptr)
       nrecs = streamptr->tsteps[1].nrecs;
 
       streamptr->tsteps[tsID].nrecs = nrecs;
-      streamptr->tsteps[tsID].recIDs = (int *)xmalloc((size_t)nrecs * sizeof (int));
+      streamptr->tsteps[tsID].recIDs = (int *) Malloc((size_t)nrecs * sizeof (int));
       for ( recID = 0; recID < nrecs; recID++ )
 	streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
 
@@ -721,11 +722,12 @@ void extReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
   int recID;
   int i;
   double missval;
-  extrec_t *extp = (extrec_t*) streamptr->record->exsep;
+  void *extp = streamptr->record->exsep;
 
   vlistID  = streamptr->vlistID;
   fileID   = streamptr->fileID;
-  nlevs    = streamptr->vars[varID].nlevs;
+  /* NOTE: tiles are not supported here! */
+  nlevs    = streamptr->vars[varID].recordTable[0].nlevs;
   missval  = vlistInqVarMissval(vlistID, varID);
   gridID   = vlistInqVarGrid(vlistID, varID);
   gridsize = gridInqSize(gridID);
@@ -738,7 +740,8 @@ void extReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
 
   for (levID = 0; levID < nlevs; levID++)
     {
-      recID = streamptr->vars[varID].level[levID];
+      /* NOTE: tiles are not supported here! */
+      recID = streamptr->vars[varID].recordTable[0].recordID[levID];
       recpos = streamptr->tsteps[tsid].records[recID].position;
       fileSetPos(fileID, recpos, SEEK_SET);
       extRead(fileID, extp);
@@ -779,11 +782,12 @@ void extReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data,
   int recID;
   int i;
   double missval;
-  extrec_t *extp = (extrec_t*) streamptr->record->exsep;
+  void *extp = streamptr->record->exsep;
 
   vlistID  = streamptr->vlistID;
   fileID   = streamptr->fileID;
-  nlevs    = streamptr->vars[varID].nlevs;
+  /* NOTE: tiles are not supported here! */
+  nlevs    = streamptr->vars[varID].recordTable[0].nlevs;
   missval  = vlistInqVarMissval(vlistID, varID);
   gridID   = vlistInqVarGrid(vlistID, varID);
   gridsize = gridInqSize(gridID);
@@ -795,7 +799,8 @@ void extReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data,
 
   currentfilepos = fileGetPos(fileID);
 
-  recID = streamptr->vars[varID].level[levID];
+  /* NOTE: tiles are not supported here! */
+  recID = streamptr->vars[varID].recordTable[0].recordID[levID];
   recpos = streamptr->tsteps[tsid].records[recID].position;
   fileSetPos(fileID, recpos, SEEK_SET);
   extRead(fileID, extp);
diff --git a/libcdi/src/stream_fcommon.c b/libcdi/src/stream_fcommon.c
index bd335c5..7198c90 100644
--- a/libcdi/src/stream_fcommon.c
+++ b/libcdi/src/stream_fcommon.c
@@ -1,5 +1,6 @@
 #include <stdlib.h>
 
+#include "cdi_int.h"
 #include "dmemory.h"
 #include "file.h"
 #include "stream_fcommon.h"
@@ -20,7 +21,7 @@ void streamFCopyRecord(stream_t *streamptr2, stream_t *streamptr1,
   if (fileSetPos(fileID1, recpos, SEEK_SET) != 0)
     Error("Cannot seek input file for %s record copy!", container_name);
 
-  char *buffer = xmalloc(recsize);
+  char *buffer = (char *) Malloc(recsize);
 
   if (fileRead(fileID1, buffer, recsize) != recsize)
     Error("Failed to read record from %s file for copying!", container_name);
@@ -28,7 +29,7 @@ void streamFCopyRecord(stream_t *streamptr2, stream_t *streamptr1,
   if (fileWrite(fileID2, buffer, recsize) != recsize)
     Error("Failed to write record to %s file when copying!", container_name);
 
-  free(buffer);
+  Free(buffer);
 }
 
 /*
diff --git a/libcdi/src/stream_fcommon.h b/libcdi/src/stream_fcommon.h
index 2296e54..f021f86 100644
--- a/libcdi/src/stream_fcommon.h
+++ b/libcdi/src/stream_fcommon.h
@@ -5,11 +5,6 @@
 #include "cdi_int.h"
 #endif
 
-enum {
-  SINGLE_PRECISION = 4,
-  DOUBLE_PRECISION = 8,
-};
-
 void streamFCopyRecord(stream_t *streamptr2, stream_t *streamptr1,
                        const char *container_name);
 
diff --git a/libcdi/src/stream_grb.c b/libcdi/src/stream_grb.c
index a4ef190..f619ab1 100644
--- a/libcdi/src/stream_grb.c
+++ b/libcdi/src/stream_grb.c
@@ -17,6 +17,7 @@
 #include "namespace.h"
 
 
+
 int grib1ltypeToZaxisType(int grib_ltype)
 {
   int zaxistype = ZAXIS_GENERIC;
@@ -219,7 +220,7 @@ int grbDecode(int filetype, unsigned char *gribbuffer, int gribsize, double *dat
 }
 
 
-int grbUnzipRecord(unsigned char *gribbuffer, size_t *gribsize)
+static int grbUnzipRecord(unsigned char *gribbuffer, size_t *gribsize)
 {
   int zip = 0;
   int izip;
@@ -247,7 +248,7 @@ int grbUnzipRecord(unsigned char *gribbuffer, size_t *gribsize)
 	  if ( itmpbuffersize < igribsize )
 	    {
 	      itmpbuffersize = igribsize;
-	      itmpbuffer = (unsigned char *) realloc(itmpbuffer, itmpbuffersize);
+	      itmpbuffer = (unsigned char *) Realloc(itmpbuffer, itmpbuffersize);
 	    }
 
 	  memcpy(itmpbuffer, gribbuffer, itmpbuffersize);
@@ -256,7 +257,7 @@ int grbUnzipRecord(unsigned char *gribbuffer, size_t *gribsize)
 
 	  ogribsize = (size_t)gribUnzip(gribbuffer, unzipsize, itmpbuffer, (long)igribsize);
 
-	  free(itmpbuffer);
+	  Free(itmpbuffer);
 
 	  if ( ogribsize <= 0 ) Error("Decompression problem!");
 	}
@@ -307,21 +308,20 @@ void grbReadRecord(stream_t * streamptr, double *data, int *nmiss)
 static
 int grbScanTimestep1(stream_t * streamptr)
 {
-  int status;
-  int filetype;
-
-  filetype  = streamptr->filetype;
+  int status = CDI_EUFTYPE;
 
 #if  defined  (HAVE_LIBCGRIBEX)
+  int filetype  = streamptr->filetype;
+
   if ( filetype == FILETYPE_GRB )
-    {
-      status = cgribexScanTimestep1(streamptr);
-    }
+    status = cgribexScanTimestep1(streamptr);
+#endif
+#if defined(HAVE_LIBCGRIBEX) && defined (HAVE_LIBGRIB_API)
   else
 #endif
-    {
-      status = gribapiScanTimestep1(streamptr);
-    }
+#ifdef HAVE_LIBGRIB_API
+    status = gribapiScanTimestep1(streamptr);
+#endif
 
   return (status);
 }
@@ -329,12 +329,11 @@ int grbScanTimestep1(stream_t * streamptr)
 static
 int grbScanTimestep2(stream_t * streamptr)
 {
-  int status = 0;
-  int filetype;
-
-  filetype  = streamptr->filetype;
+  int status = CDI_EUFTYPE;
 
 #if  defined  (HAVE_LIBCGRIBEX)
+  int filetype = streamptr->filetype;
+
   if ( filetype == FILETYPE_GRB )
     {
       status = cgribexScanTimestep2(streamptr);
@@ -375,6 +374,7 @@ int grbScanTimestep(stream_t * streamptr)
 }
 
 
+#if  defined  (HAVE_LIBGRIB)
 int grbInqContents(stream_t * streamptr)
 {
   int fileID;
@@ -392,7 +392,7 @@ int grbInqContents(stream_t * streamptr)
 
   return (status);
 }
-
+#endif
 
 int grbInqTimestep(stream_t * streamptr, int tsID)
 {
@@ -439,20 +439,21 @@ void grbReadVarDP(stream_t * streamptr, int varID, double *data, int *nmiss)
   int fileID  = streamptr->fileID;
   int tsID    = streamptr->curTsID;
 
-  int nlevs    = streamptr->vars[varID].nlevs;
   int gridID   = vlistInqVarGrid(vlistID, varID);
   int gridsize = gridInqSize(gridID);
 
-  if ( CDI_Debug )
-    Message("nlevs = %d gridID = %d gridsize = %d", nlevs, gridID, gridsize);
-
   off_t currentfilepos = fileGetPos(fileID);
 
+
+  int isub     = subtypeInqActiveIndex(streamptr->vars[varID].subtypeID);
+  int nlevs    = streamptr->vars[varID].recordTable[0].nlevs;
+  if ( CDI_Debug )
+    Message("nlevs = %d gridID = %d gridsize = %d", nlevs, gridID, gridsize);
   *nmiss = 0;
   for (int levelID = 0; levelID < nlevs; levelID++ )
     {
-      int recID   = streamptr->vars[varID].level[levelID];
-      off_t recpos  = streamptr->tsteps[tsID].records[recID].position;
+      int    recID   = streamptr->vars[varID].recordTable[isub].recordID[levelID];
+      off_t  recpos  = streamptr->tsteps[tsID].records[recID].position;
       size_t recsize = streamptr->tsteps[tsID].records[recID].size;
 
       fileSetPos(fileID, recpos, SEEK_SET);
@@ -466,7 +467,7 @@ void grbReadVarDP(stream_t * streamptr, int varID, double *data, int *nmiss)
       streamptr->tsteps[tsID].records[recID].zip = grbUnzipRecord(gribbuffer, &recsize);
 
       grbDecode(filetype, gribbuffer, (int)recsize, &data[levelID*gridsize], gridsize,
-		streamptr->unreduced, &imiss, missval, vlistID, varID);
+                streamptr->unreduced, &imiss, missval, vlistID, varID);
 
       *nmiss += imiss;
     }
@@ -493,8 +494,11 @@ void grbReadVarSliceDP(stream_t * streamptr, int varID, int levelID, double *dat
 
   off_t currentfilepos = fileGetPos(fileID);
 
-  int recID   = streamptr->vars[varID].level[levelID];
-  off_t recpos  = streamptr->tsteps[tsID].records[recID].position;
+  int    isub    = subtypeInqActiveIndex(streamptr->vars[varID].subtypeID);
+
+
+  int    recID   = streamptr->vars[varID].recordTable[isub].recordID[levelID];
+  off_t  recpos  = streamptr->tsteps[tsID].records[recID].position;
   size_t recsize = streamptr->tsteps[tsID].records[recID].size;
 
   if ( recsize == 0 )
@@ -526,7 +530,7 @@ size_t grbEncode(int filetype, int memtype, int varID, int levelID, int vlistID,
   if ( filetype == FILETYPE_GRB )
     {
       size_t gribbuffersize = datasize*4+3000;
-      *gribbuffer = (unsigned char *) malloc(gribbuffersize);
+      *gribbuffer = (unsigned char *) Malloc(gribbuffersize);
 
       nbytes = cgribexEncode(memtype, varID, levelID, vlistID, gridID, zaxisID,
 			     date, time, tsteptype, numavg,
@@ -563,7 +567,7 @@ size_t grbSzip(int filetype, unsigned char *gribbuffer, size_t gribbuffersize)
   static int lszip_warn = 1;
 
   buffersize = gribbuffersize + 1000; /* compressed record can be greater than source record */
-  buffer = (unsigned char *) malloc(buffersize);
+  buffer = (unsigned char *) Malloc(buffersize);
 
   /*  memcpy(buffer, gribbuffer, gribbuffersize); */
 
@@ -578,7 +582,7 @@ size_t grbSzip(int filetype, unsigned char *gribbuffer, size_t gribbuffersize)
       nbytes = gribbuffersize;
     }
 
-  free(buffer);
+  Free(buffer);
 
   return (nbytes);
 }
@@ -621,7 +625,7 @@ void grb_write_var_slice(stream_t *streamptr, int varID, int levelID, int memtyp
   size_t datasize = (size_t)gridInqSize(gridID);
   /*
   gribbuffersize = datasize*4+3000;
-  gribbuffer = (unsigned char *) malloc(gribbuffersize);
+  gribbuffer = (unsigned char *) Malloc(gribbuffersize);
   */
 #if  defined  (HAVE_LIBCGRIBEX)
   if ( filetype == FILETYPE_GRB )
@@ -668,7 +672,7 @@ void grb_write_var_slice(stream_t *streamptr, int varID, int levelID, int memtyp
       Error("Failed to write GRIB slice!");
     }
 
-  if ( gribbuffer ) free(gribbuffer);
+  if ( gribbuffer ) Free(gribbuffer);
 }
 
 
@@ -711,7 +715,7 @@ void grbCopyRecord(stream_t * streamptr2, stream_t * streamptr1)
   /* round up recsize to next multiple of 8 */
   size_t gribbuffersize = ((recsize + 7U) & ~7U);
 
-  unsigned char *gribbuffer = xmalloc(gribbuffersize);
+  unsigned char *gribbuffer = (unsigned char *) Malloc(gribbuffersize);
 
   if (fileRead(fileID1, gribbuffer, recsize) != recsize)
     Error("Could not read GRIB record for copying!");
@@ -737,7 +741,7 @@ void grbCopyRecord(stream_t * streamptr2, stream_t * streamptr1)
       Error("Could not write record for copying!");
     }
 
-  free(gribbuffer);
+  Free(gribbuffer);
 }
 
 
diff --git a/libcdi/src/stream_gribapi.c b/libcdi/src/stream_gribapi.c
index d479208..6f29a05 100644
--- a/libcdi/src/stream_gribapi.c
+++ b/libcdi/src/stream_gribapi.c
@@ -2,6 +2,7 @@
 #  include "config.h"
 #endif
 
+#include <limits.h>
 #include <stdio.h>
 
 #include "dmemory.h"
@@ -15,6 +16,7 @@
 #include "vlist.h"
 #include "stream_grb.h"
 #include "calendar.h"
+#include "subtype.h"
 
 
 #if  defined  (HAVE_LIBGRIB_API)
@@ -26,6 +28,10 @@
 
 extern int cdiInventoryMode;
 
+#if  defined  (HAVE_LIBGRIB_API)
+static const var_tile_t dummy_tiles = { -1, -1, -1, -1, -1, -1 };
+#endif
+
 typedef struct {
   int param;
   int level1;
@@ -33,37 +39,13 @@ typedef struct {
   int ltype;
   int tsteptype;
   char name[32];
-} compvar2_t;
-
-
-#if  defined  (HAVE_LIBGRIB_API)
-static
-int my_grib_set_double(grib_handle* h, const char* key, double val)
-{
-  if ( cdiGribApiDebug )
-    fprintf(stderr, "grib_set_double(\tgrib_handle* h, \"%s\", %f)\n", key, val);
 
-  return grib_set_double(h, key, val);
-}
+  var_tile_t tiles;
 
-static
-int my_grib_set_long(grib_handle* h, const char* key, long val)
-{
-  if ( cdiGribApiDebug )
-    fprintf(stderr, "grib_set_long(  \tgrib_handle* h, \"%s\", %ld)\n", key, val);
-
-  return grib_set_long(h, key, val);
-}
+} compvar2_t;
 
-static
-int my_grib_set_string(grib_handle* h, const char* key, const char* val, size_t* length)
-{
-  if ( cdiGribApiDebug )
-    fprintf(stderr, "grib_set_string(\tgrib_handle* h, \"%s\", \"%s\")\n", key, val);
-
-  return grib_set_string(h, key, val, length);
-}
 
+#if  defined  (HAVE_LIBGRIB_API)
 static
 int gribapiGetZaxisType(long editionNumber, int grib_ltype)
 {
@@ -139,24 +121,29 @@ int gribapiGetTimeUnits(grib_handle *gh)
 }
 
 static
-int gribapiGetEndStep(grib_handle *gh, int startStep, int timeunits)
+void gribapiGetSteps(grib_handle *gh, int timeunits, int *startStep, int *endStep)
 {
-  int endStep = startStep;
   int timeunits2 = timeunits;
-
   long unitsOfTime;
   int status = grib_get_long(gh, "stepUnits", &unitsOfTime);
   if ( status == 0 ) timeunits2 = getTimeunits(unitsOfTime);
   //timeunits2 = gribapiGetTimeUnits(gh);
 
   long lpar;
-  status = grib_get_long(gh, "endStep", &lpar);
+  status = grib_get_long(gh, "forecastTime", &lpar);
+  if ( status == 0 ) *startStep = (int) lpar;
+  else
+    {
+      status = grib_get_long(gh, "startStep", &lpar);
+      if ( status == 0 )
+        *startStep = (int) (((double)lpar * timeunit_factor(timeunits, timeunits2)) + 0.5);
+    }
 
+  *endStep = *startStep;
+  status = grib_get_long(gh, "endStep", &lpar);
   if ( status == 0 )
-    endStep = (int) (((double)lpar * timeunit_factor(timeunits, timeunits2)) + 0.5);
-  // printf("%d %d %d %d %d %g\n", startStep, endStep, lpar, timeunits, timeunits2, timeunit_factor(timeunits, timeunits2));
-
-  return (endStep);
+    *endStep = (int) (((double)lpar * timeunit_factor(timeunits, timeunits2)) + 0.5);
+  // printf("%d %d %d %d %d %g\n", *startStep, *endStep, lpar, timeunits, timeunits2, timeunit_factor(timeunits, timeunits2));
 }
 
 static
@@ -184,8 +171,6 @@ int gribapiGetValidityDateTime(grib_handle *gh, int *vdate, int *vtime)
   int timeUnits, startStep = 0, endStep;
   int tstepRange = 0;
   int range;
-  int status;
-  long lpar;
   long sigofrtime = 3;
 
   if ( gribEditionNumber(gh) > 1 )
@@ -205,10 +190,8 @@ int gribapiGetValidityDateTime(grib_handle *gh, int *vdate, int *vtime)
     {
       gribapiGetDataDateTime(gh, &rdate, &rtime);
 
-      status = grib_get_long(gh, "forecastTime", &lpar);
-      if ( status == 0 ) startStep = (int) lpar;
       timeUnits = gribapiGetTimeUnits(gh);
-      endStep = gribapiGetEndStep(gh, startStep, timeUnits);
+      gribapiGetSteps(gh, timeUnits, &startStep, &endStep);
 
       range = endStep - startStep;
 
@@ -331,7 +314,7 @@ static
 int calcLevel(int level_sf, long factor, long level)
 {
   double result = 0;
-  if(level != GRIB_MISSING_LONG) result = level*grib2ScaleFactor(factor);
+  if(level != GRIB_MISSING_LONG) result = (double)level*grib2ScaleFactor(factor);
   if(level_sf) result *= level_sf;
   return (int)result;
 }
@@ -400,7 +383,7 @@ void grib2GetLevel(grib_handle *gh, int *leveltype1, int *leveltype2, int *lboun
 }
 
 static
-void gribGetLevel(grib_handle *gh, int* leveltype1, int* leveltype2, int* lbounds, int* level1, int* level2, int* level_sf, int* level_unit)
+void gribGetLevel(grib_handle *gh, int* leveltype1, int* leveltype2, int* lbounds, int* level1, int* level2, int* level_sf, int* level_unit, var_tile_t* tiles)
 {
   if ( gribEditionNumber(gh) <= 1 )
     {
@@ -412,6 +395,14 @@ void gribGetLevel(grib_handle *gh, int* leveltype1, int* leveltype2, int* lbound
   else
     {
       grib2GetLevel(gh, leveltype1, leveltype2, lbounds, level1, level2, level_sf, level_unit);
+
+      /* read in tiles attributes (if there are any) */
+      tiles->tileindex = (int)gribGetLongDefault(gh, cdiSubtypeAttributeName[SUBTYPE_ATT_TILEINDEX], -1);
+      tiles->totalno_of_tileattr_pairs = (int)gribGetLongDefault(gh, cdiSubtypeAttributeName[SUBTYPE_ATT_TOTALNO_OF_TILEATTR_PAIRS], -1);
+      tiles->tileClassification = (int)gribGetLongDefault(gh, cdiSubtypeAttributeName[SUBTYPE_ATT_TILE_CLASSIFICATION], -1);
+      tiles->numberOfTiles = (int)gribGetLongDefault(gh, cdiSubtypeAttributeName[SUBTYPE_ATT_NUMBER_OF_TILES], -1);
+      tiles->numberOfAttributes = (int)gribGetLongDefault(gh, cdiSubtypeAttributeName[SUBTYPE_ATT_NUMBER_OF_ATTR], -1);
+      tiles->attribute = (int)gribGetLongDefault(gh, cdiSubtypeAttributeName[SUBTYPE_ATT_TILEATTRIBUTE], -1);
     }
 }
 
@@ -420,7 +411,12 @@ void gribapiGetString(grib_handle *gh, const char *key, char *string, size_t len
 {
   string[0] = 0;
 
-  GRIB_CHECK(grib_get_string(gh, key, string, &length), 0);
+  int ret = grib_get_string(gh, key, string, &length);
+  if (ret != 0)
+    {
+      fprintf(stderr, "grib_get_string(gh, \"%s\", ...) failed!\n", key);
+      GRIB_CHECK(ret, 0);
+    }
   if      ( length == 8 && memcmp(string, "unknown", length) == 0 ) string[0] = 0;
   else if ( length == 2 && memcmp(string, "~", length)       == 0 ) string[0] = 0;
 }
@@ -429,31 +425,26 @@ void gribapiGetString(grib_handle *gh, const char *key, char *string, size_t len
 static
 void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
                       size_t recsize, off_t position, int datatype, int comptype, const char *varname,
-                      int leveltype1, int leveltype2, int lbounds, int level1, int level2, int level_sf, int level_unit)
+                      int leveltype1, int leveltype2, int lbounds, int level1, int level2, int level_sf, int level_unit,
+                      const var_tile_t *tiles, int lread_additional_keys)
 {
-  int zaxistype;
-  int gridID = CDI_UNDEFID, varID;
+  int varID;
   int levelID = 0;
-  int tsID, recID;
-  int numavg;
-  int tsteptype;
-  record_t *record;
   grid_t grid;
-  int vlistID;
   long lpar;
   int status;
   char stdname[CDI_MAX_NAME], longname[CDI_MAX_NAME], units[CDI_MAX_NAME];
   size_t vlen;
   long ens_index = 0, ens_count = 0, ens_forecast_type = 0;
 
-  vlistID = streamptr->vlistID;
-  tsID    = streamptr->curTsID;
-  recID   = recordNewEntry(streamptr, tsID);
-  record  = &streamptr->tsteps[tsID].records[recID];
+  int vlistID = streamptr->vlistID;
+  int tsID    = streamptr->curTsID;
+  int recID   = recordNewEntry(streamptr, tsID);
+  record_t *record  = &streamptr->tsteps[tsID].records[recID];
 
-  tsteptype = gribapiGetTsteptype(gh);
+  int tsteptype = gribapiGetTsteptype(gh);
   // numavg  = ISEC1_AvgNum;
-  numavg  = 0;
+  int numavg  = 0;
 
   // fprintf(stderr, "param %d %d %d %d\n", param, level1, level2, leveltype1);
 
@@ -464,6 +455,8 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
   (*record).ilevel2   = level2;
   (*record).ltype     = leveltype1;
   (*record).tsteptype = tsteptype;
+  if ( tiles ) (*record).tiles = *tiles;
+  else         (*record).tiles = dummy_tiles;
 
   //FIXME: This may leave the variable name unterminated (which is the behavior that I found in the code).
   //       I don't know precisely how this field is used, so I did not change this behavior to avoid regressions,
@@ -479,35 +472,34 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
 
   gribapiGetGrid(gh, &grid);
 
-  gridID = varDefGrid(vlistID, &grid, 0);
+  int gridID = varDefGrid(vlistID, &grid, 0);
 
-  zaxistype = gribapiGetZaxisType(gribEditionNumber(gh), leveltype1);
+  int zaxistype = gribapiGetZaxisType(gribEditionNumber(gh), leveltype1);
 
   switch (zaxistype)
     {
     case ZAXIS_HYBRID:
     case ZAXIS_HYBRID_HALF:
       {
-        int vctsize;
+        size_t vctsize;
         size_t dummy;
         double *vctptr;
 
         GRIB_CHECK(grib_get_long(gh, "NV", &lpar), 0);
-        /* FIXME: assert(lpar >= INT_MIN && lpar <= INT_MAX) */
-        vctsize = (int)lpar;
+        /* FIXME: assert(lpar >= 0) */
+        vctsize = (size_t)lpar;
         if ( vctsize > 0 )
           {
-            vctptr = (double *) malloc(vctsize*sizeof(double));
-            dummy = (size_t)vctsize;
+            vctptr = (double *) Malloc(vctsize*sizeof(double));
+            dummy = vctsize;
             GRIB_CHECK(grib_get_double_array(gh, "pv", vctptr, &dummy), 0);
-            varDefVCT((size_t)vctsize, vctptr);
-            free(vctptr);
+            varDefVCT(vctsize, vctptr);
+            Free(vctptr);
           }
         break;
       }
     case ZAXIS_REFERENCE:
       {
-        size_t len;
         unsigned char uuid[CDI_UUID_SIZE];
         long ltmp;
         long nhlev, nvgrid;
@@ -521,7 +513,7 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
         nhlev = ltmp;
         GRIB_CHECK(grib_get_long(gh, "numberOfVGridUsed", &ltmp), 0);
         nvgrid = ltmp;
-        len = (size_t)CDI_UUID_SIZE;
+        size_t len = (size_t)CDI_UUID_SIZE;
         memset(uuid, 0, CDI_UUID_SIZE);
         GRIB_CHECK(grib_get_bytes(gh, "uuidOfVGrid", uuid, &len), 0);
         varDefZAxisReference((int) nhlev, (int) nvgrid, uuid);
@@ -552,12 +544,14 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
     }
   // fprintf(stderr, "param %d name %s %s %s\n", param, name, longname, units);
 
+  /* add the previously read record data to the (intermediate) list of records */
+  int tile_index = -1;
   varAddRecord(recID, param, gridID, zaxistype, lbounds, level1, level2, level_sf, level_unit,
 	       datatype, &varID, &levelID, tsteptype, numavg, leveltype1, leveltype2,
-	       varname, stdname, longname, units);
+	       varname, stdname, longname, units, tiles, &tile_index);
 
-  (*record).varID   = (short)varID;
-  (*record).levelID = (short)levelID;
+  record->varID   = (short)varID;
+  record->levelID = (short)levelID;
 
   varDefCompType(varID, comptype);
 
@@ -589,23 +583,15 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
   long   lval;
   double dval;
 
-  /* we read the additional keys for the first variable record only. */
-  int linitial_field = (varOptGribNentries(varID) == 0);
-
-  for ( i = 0; i < cdiNAdditionalGRIBKeys; i++ )
-    {
-      if ( linitial_field )
-	{
-	  if ( grib_get_long(gh, cdiAdditionalGRIBKeys[i], &lval) == 0 )
-            varDefOptGribInt(varID, lval, cdiAdditionalGRIBKeys[i]);
-	}
-      if ( linitial_field )
-	{
-	  if ( grib_get_double(gh, cdiAdditionalGRIBKeys[i], &dval) == 0 )
-            varDefOptGribDbl(varID, dval, cdiAdditionalGRIBKeys[i]);
-	}
-      /* note: if the key is not defined, we do not throw an error! */
-    }
+  if (lread_additional_keys)
+    for ( i = 0; i < cdiNAdditionalGRIBKeys; i++ )
+      {
+        /* note: if the key is not defined, we do not throw an error! */
+        if ( grib_get_long(gh, cdiAdditionalGRIBKeys[i], &lval) == 0 )
+          varDefOptGribInt(varID, tile_index, lval, cdiAdditionalGRIBKeys[i]);
+        if ( grib_get_double(gh, cdiAdditionalGRIBKeys[i], &dval) == 0 )
+          varDefOptGribDbl(varID, tile_index, dval, cdiAdditionalGRIBKeys[i]);
+      }
 
   if ( varInqInst(varID) == CDI_UNDEFID )
     {
@@ -662,8 +648,8 @@ void gribapiAddRecord(stream_t * streamptr, int param, grib_handle *gh,
 }
 #endif
 
-static
-compvar2_t gribapiVarSet(int param, int level1, int level2, int leveltype, int tsteptype, char *name)
+static compvar2_t gribapiVarSet(int param, int level1, int level2, int leveltype, 
+                                int tsteptype, char *name, var_tile_t tiles_data)
 {
   compvar2_t compVar;
   size_t maxlen = sizeof(compVar.name);
@@ -677,23 +663,23 @@ compvar2_t gribapiVarSet(int param, int level1, int level2, int leveltype, int t
   compVar.tsteptype = tsteptype;
   memset(compVar.name, 0, maxlen);
   memcpy(compVar.name, name, len);
+  compVar.tiles = tiles_data;
 
   return (compVar);
 }
 #endif
 
+#ifdef HAVE_LIBGRIB_API
 static
 int gribapiVarCompare(compvar2_t compVar, record_t record, int flag)
 {
   compvar2_t compVar0;
-  size_t maxlen = sizeof(compVar.name);
-
   compVar0.param     = record.param;
   compVar0.level1    = record.ilevel;
   compVar0.level2    = record.ilevel2;
   compVar0.ltype     = record.ltype;
   compVar0.tsteptype = record.tsteptype;
-  memcpy(compVar0.name, record.varname, maxlen);
+  memcpy(compVar0.name, record.varname, sizeof(compVar.name));
 
   if ( flag == 0 )
     {
@@ -701,22 +687,23 @@ int gribapiVarCompare(compvar2_t compVar, record_t record, int flag)
       if ( compVar0.tsteptype == TSTEP_INSTANT3 && compVar.tsteptype == TSTEP_INSTANT  ) compVar0.tsteptype = TSTEP_INSTANT;
     }
 
+  compVar0.tiles = record.tiles;
+
   int rstatus = memcmp(&compVar0, &compVar, sizeof(compvar2_t));
 
   return (rstatus);
 }
 
-static void ensureBufferSize(size_t requiredSize, size_t* curSize, unsigned char** buffer) {
+static void ensureBufferSize(size_t requiredSize, size_t* curSize, unsigned char **buffer) {
   if ( *curSize < requiredSize )
     {
       *curSize = requiredSize;
-      *buffer = realloc(*buffer, *curSize);
+      *buffer = (unsigned char *) Realloc(*buffer, *curSize);
     }
 }
 
-#if  defined  (HAVE_LIBGRIB_API)
 static
-grib_handle* gribapiGetDiskRepresentation(long recsize, size_t* buffersize, unsigned char** gribbuffer, int* outDatatype, int* outCompressionType, long* outUnzipsize)
+grib_handle* gribapiGetDiskRepresentation(size_t recsize, size_t* buffersize, unsigned char** gribbuffer, int* outDatatype, int* outCompressionType, long* outUnzipsize)
 {
   int lieee = FALSE;
 
@@ -736,10 +723,10 @@ grib_handle* gribapiGetDiskRepresentation(long recsize, size_t* buffersize, unsi
     }
   else
     {
-      if( gribGetZip(recsize, *gribbuffer, outUnzipsize) > 0 )
+      if( gribGetZip((long)recsize, *gribbuffer, outUnzipsize) > 0 )
         {
           *outCompressionType = COMPRESS_SZIP;
-          ensureBufferSize(*outUnzipsize + 100, buffersize, gribbuffer);
+          ensureBufferSize((size_t)*outUnzipsize + 100, buffersize, gribbuffer);
         }
       else
         {
@@ -767,9 +754,10 @@ grib_handle* gribapiGetDiskRepresentation(long recsize, size_t* buffersize, unsi
 }
 #endif
 
+#if  defined  (HAVE_LIBGRIB_API)
 typedef enum { CHECKTIME_OK, CHECKTIME_SKIP, CHECKTIME_STOP, CHECKTIME_INCONSISTENT } checkTimeResult;
 static checkTimeResult checkTime(stream_t* streamptr, compvar2_t compVar, const DateTime* verificationTime, const DateTime* expectedVTime) {
-  //First determine whether the current record exists already.
+  // First determine whether the current record exists already.
   int recID = 0;
   for ( ; recID < streamptr->nrecs; recID++ )
     {
@@ -777,10 +765,10 @@ static checkTimeResult checkTime(stream_t* streamptr, compvar2_t compVar, const
     }
   int recordExists = recID < streamptr->nrecs;
 
-  //Then we need to know whether the verification time is consistent.
+  // Then we need to know whether the verification time is consistent.
   int consistentTime = !memcmp(verificationTime, expectedVTime, sizeof(*verificationTime));
 
-  //Finally, we make a decision.
+  // Finally, we make a decision.
   if ( cdiInventoryMode == 1 )
     {
       if ( recordExists ) return CHECKTIME_STOP;
@@ -791,8 +779,10 @@ static checkTimeResult checkTime(stream_t* streamptr, compvar2_t compVar, const
       if ( !consistentTime ) return CHECKTIME_STOP;
       if ( recordExists ) return CHECKTIME_SKIP;
     }
+
   return CHECKTIME_OK;
 }
+#endif
 
 #define gribWarning(text, nrecs, timestep, varname, param, level1, level2) do \
   { \
@@ -802,9 +792,9 @@ static checkTimeResult checkTime(stream_t* streamptr, compvar2_t compVar, const
   } \
 while(0)
 
+#if  defined  (HAVE_LIBGRIB_API)
 int gribapiScanTimestep1(stream_t * streamptr)
 {
-#if  defined  (HAVE_LIBGRIB_API)
   off_t recpos = 0;
   unsigned char *gribbuffer = NULL;
   size_t buffersize = 0;
@@ -825,7 +815,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
 
   int fileID = streamptr->fileID;
 
-  int nrecs = 0;
+  unsigned nrecs = 0;
   while ( TRUE )
     {
       int level1 = 0, level2 = 0;
@@ -840,7 +830,7 @@ int gribapiScanTimestep1(stream_t * streamptr)
       ensureBufferSize(recsize, &buffersize, &gribbuffer);
 
       size_t readsize = recsize;
-      int rstatus = gribRead(fileID, gribbuffer, &readsize);        //Search for next 'GRIB', read the following record, and position file offset after it.
+      int rstatus = gribRead(fileID, gribbuffer, &readsize); //Search for next 'GRIB', read the following record, and position file offset after it.
       if ( rstatus ) break;
 
       int datatype, comptype = 0;
@@ -852,13 +842,15 @@ int gribapiScanTimestep1(stream_t * streamptr)
 
       int param = gribapiGetParam(gh);
       int leveltype1 = -1, leveltype2 = -1, lbounds, level_sf, level_unit;
-      gribGetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit);
+      var_tile_t tiles = dummy_tiles;
+      gribGetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit, &tiles);
 
       char varname[256];
       varname[0] = 0;
       gribapiGetString(gh, "shortName", varname, sizeof(varname));
 
       int tsteptype = gribapiGetTsteptype(gh);
+
       int vdate = 0, vtime = 0;
       gribapiGetValidityDateTime(gh, &vdate, &vtime);
       DateTime datetime = { .date = vdate, .time = vtime };
@@ -866,9 +858,9 @@ int gribapiScanTimestep1(stream_t * streamptr)
       printf("%d %d %d\n", vdate, vtime, leveltype1);
       */
 
-      if( datetime0.date == 10101 && datetime0.time == 0 )
+      if ( datetime0.date == 10101 && datetime0.time == 0 )
         {
-          if( memcmp(&datetime, &datetime0, sizeof(datetime)) || !nrecs )       //Do we really need this condition? I have included it in order not to change the number of times gribapiGetDataDateTime() etc. get called. But if those are sideeffect-free, this condition should be removed.
+          if( datetimeCmp(datetime, datetime0) || !nrecs )       //Do we really need this condition? I have included it in order not to change the number of times gribapiGetDataDateTime() etc. get called. But if those are sideeffect-free, this condition should be removed.
             {
               datetime0 = datetime;
 
@@ -879,19 +871,19 @@ int gribapiScanTimestep1(stream_t * streamptr)
             }
         }
 
-      if(nrecs)
+      if ( nrecs )
         {
-          checkTimeResult result = checkTime(streamptr, gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname), &datetime, &datetime0);
-          if(result == CHECKTIME_STOP)
+          checkTimeResult result = checkTime(streamptr, gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname, tiles), &datetime, &datetime0);
+          if ( result == CHECKTIME_STOP )
             {
               break;
             }
-          else if(result == CHECKTIME_SKIP)
+          else if ( result == CHECKTIME_SKIP )
             {
               gribWarning("Parameter already exist, skipped!", nrecs_scanned, tsID+1, varname, param, level1, level2);
               continue;
             }
-          else if(result == CHECKTIME_INCONSISTENT && warn_time)
+          else if ( result == CHECKTIME_INCONSISTENT && warn_time )
             {
               gribWarning("Inconsistent verification time!", nrecs_scanned, tsID+1, varname, param, level1, level2);
               warn_time = FALSE;
@@ -919,12 +911,14 @@ int gribapiScanTimestep1(stream_t * streamptr)
         {
           char paramstr[32];
           cdiParamToString(param, paramstr, sizeof(paramstr));
-          Message("%4d %8d name=%s id=%s ltype=%d lev1=%d lev2=%d vdate=%d vtime=%d",
+          Message("%4u %8d name=%s id=%s ltype=%d lev1=%d lev2=%d vdate=%d vtime=%d",
                 nrecs, (int)recpos, varname, paramstr, leveltype1, level1, level2, vdate, vtime);
         }
 
+      var_tile_t *ptiles = NULL;
+      if ( memcmp(&tiles, &dummy_tiles, sizeof(var_tile_t)) != 0 ) ptiles = &tiles;
       gribapiAddRecord(streamptr, param, gh, recsize, recpos, datatype, comptype, varname,
-                       leveltype1, leveltype2, lbounds, level1, level2, level_sf, level_unit);
+                       leveltype1, leveltype2, lbounds, level1, level2, level_sf, level_unit, ptiles, 1);
 
       grib_handle_delete(gh);
       gh = NULL;
@@ -964,10 +958,10 @@ int gribapiScanTimestep1(stream_t * streamptr)
     {
       streamptr->tsteps[0].recordSize = nrecords;
       streamptr->tsteps[0].records =
-      (record_t *) realloc(streamptr->tsteps[0].records, nrecords*sizeof(record_t));
+        (record_t *) Realloc(streamptr->tsteps[0].records, (size_t)nrecords*sizeof(record_t));
     }
 
-  streamptr->tsteps[0].recIDs = (int *) malloc(nrecords*sizeof(int));
+  streamptr->tsteps[0].recIDs = (int *) Malloc((size_t)nrecords*sizeof(int));
   streamptr->tsteps[0].nrecs = nrecords;
   for ( int recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[0].recIDs[recID] = recID;
@@ -996,13 +990,10 @@ int gribapiScanTimestep1(stream_t * streamptr)
             }
         }
     }
-#else
-  (void)streamptr;
-  Error("GRIB_API support not compiled in!");
-#endif
 
   return (0);
 }
+#endif
 
 
 #ifdef HAVE_LIBGRIB_API
@@ -1010,10 +1001,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
 {
   int rstatus = 0;
   off_t recpos = 0;
-  unsigned char *gribbuffer = NULL;
-  size_t buffersize = 0;
-  int fileID;
-  DateTime datetime0;
+  DateTime datetime0 = { LONG_MIN, LONG_MIN };
   // int gridID;
   int recID;
   //  int warn_numavg = TRUE;
@@ -1021,12 +1009,12 @@ int gribapiScanTimestep2(stream_t * streamptr)
 
   streamptr->curTsID = 1;
 
-  fileID  = streamptr->fileID;
+  int fileID  = streamptr->fileID;
   int vlistID = streamptr->vlistID;
   int taxisID = vlistInqTaxis(vlistID);
 
-  gribbuffer = (unsigned char *) streamptr->record->buffer;
-  buffersize = streamptr->record->buffersize;
+  unsigned char *gribbuffer = (unsigned char *) streamptr->record->buffer;
+  size_t buffersize = streamptr->record->buffersize;
 
   int tsID = streamptr->rtsteps;
   if ( tsID != 1 )
@@ -1039,7 +1027,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
   cdi_create_records(streamptr, tsID);
 
   int nrecords = streamptr->tsteps[tsID].nallrecs;
-  streamptr->tsteps[1].recIDs = (int *) malloc(nrecords*sizeof(int));
+  streamptr->tsteps[1].recIDs = (int *) Malloc((size_t)nrecords*sizeof(int));
   streamptr->tsteps[1].nrecs = 0;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[1].recIDs[recID] = -1;
@@ -1070,7 +1058,8 @@ int gribapiScanTimestep2(stream_t * streamptr)
       if ( rstatus ) break;
 
       long unzipsize;
-      if ( gribGetZip((long)recsize, gribbuffer, &unzipsize) > 0 ) ensureBufferSize(unzipsize + 100, &buffersize, &gribbuffer);
+      if ( gribGetZip((long)recsize, gribbuffer, &unzipsize) > 0 )
+        ensureBufferSize((size_t)unzipsize + 100, &buffersize, &gribbuffer);
 
       nrecs_scanned++;
       gh = grib_handle_new_from_message(NULL, (void *) gribbuffer, recsize);
@@ -1078,7 +1067,8 @@ int gribapiScanTimestep2(stream_t * streamptr)
 
       int param = gribapiGetParam(gh);
       int level1 = 0, level2 = 0, leveltype1, leveltype2, lbounds, level_sf, level_unit;
-      gribGetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit);
+      var_tile_t tiles = dummy_tiles;
+      gribGetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit, &tiles);
 
       char varname[256];
       varname[0] = 0;
@@ -1128,7 +1118,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
         .time = vtime
       };
 
-      compvar2_t compVar = gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname);
+      compvar2_t compVar = gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname, tiles);
 
       for ( recID = 0; recID < nrecords; recID++ )
         if ( gribapiVarCompare(compVar, streamptr->tsteps[tsID].records[recID], 0) == 0 ) break;
@@ -1144,7 +1134,7 @@ int gribapiScanTimestep2(stream_t * streamptr)
           if ( cdiInventoryMode == 1 ) break;
           else
 	    {
-	      if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) != 0 ) break;
+	      if ( datetimeCmp(datetime, datetime0) != 0 ) break;
 
               gribWarning("Parameter already exist, skipped!", nrecs_scanned, tsID+1, varname, param, level1, level2);
 	      continue;
@@ -1259,7 +1249,7 @@ int gribapiScanTimestep(stream_t * streamptr)
       nrecs = streamptr->tsteps[1].nrecs;
 
       streamptr->tsteps[tsID].nrecs = nrecs;
-      streamptr->tsteps[tsID].recIDs = (int *) malloc(nrecs*sizeof(int));
+      streamptr->tsteps[tsID].recIDs = (int *) Malloc((size_t)nrecs*sizeof(int));
       for ( recID = 0; recID < nrecs; recID++ )
 	streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
 
@@ -1270,7 +1260,7 @@ int gribapiScanTimestep(stream_t * streamptr)
       int nrecs_scanned = streamptr->tsteps[0].nallrecs + streamptr->tsteps[1].nrecs*(tsID-1);    //Only used for debug output.
       int rindex = 0;
       off_t recpos = 0;
-      DateTime datetime0;
+      DateTime datetime0 = { LONG_MIN, LONG_MIN };
       grib_handle *gh = NULL;
       char varname[256];
       while ( TRUE )
@@ -1298,7 +1288,8 @@ int gribapiScanTimestep(stream_t * streamptr)
 	    }
 
           long unzipsize;
-	  if ( gribGetZip((long)recsize, gribbuffer, &unzipsize) > 0 ) ensureBufferSize(unzipsize + 100, &buffersize, &gribbuffer);
+	  if ( gribGetZip((long)recsize, gribbuffer, &unzipsize) > 0 )
+            ensureBufferSize((size_t)unzipsize + 100, &buffersize, &gribbuffer);
 
           nrecs_scanned++;
 	  gh = grib_handle_new_from_message(NULL, (void *) gribbuffer, recsize);
@@ -1306,7 +1297,8 @@ int gribapiScanTimestep(stream_t * streamptr)
 
           int param = gribapiGetParam(gh);
           int level1 = 0, level2 = 0, leveltype1, leveltype2 = -1, lbounds, level_sf, level_unit;
-          gribGetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit);
+          var_tile_t tiles = dummy_tiles;
+          gribGetLevel(gh, &leveltype1, &leveltype2, &lbounds, &level1, &level2, &level_sf, &level_unit, &tiles);
 
           varname[0] = 0;
 	  gribapiGetString(gh, "shortName", varname, sizeof(varname));
@@ -1358,7 +1350,7 @@ int gribapiScanTimestep(stream_t * streamptr)
 
           int tsteptype = gribapiGetTsteptype(gh);
 
-          compvar2_t compVar = gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname);
+          compvar2_t compVar = gribapiVarSet(param, level1, level2, leveltype1, tsteptype, varname, tiles);
 
 	  for ( vrecID = 0; vrecID < nrecs; vrecID++ )
 	    {
@@ -1380,7 +1372,7 @@ int gribapiScanTimestep(stream_t * streamptr)
 	    {
 	      if ( streamptr->tsteps[tsID].records[recID].used )
 		{
-		  if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) != 0 ) break;
+		  if ( datetimeCmp(datetime, datetime0) != 0 ) break;
 
 		  if ( CDI_Debug )
                     gribWarning("Parameter already exist, skipped!", nrecs_scanned, tsID+1, varname, param, level1, level2);
@@ -1471,8 +1463,7 @@ int gribapiDecode(unsigned char *gribbuffer, int gribsize, double *data, int gri
   int status = 0;
   long lpar;
   long numberOfPoints;
-  size_t datasize, dummy, recsize;
-  grib_handle *gh = NULL;
+  size_t datasize;
 
   UNUSED(vlistID);
   UNUSED(varID);
@@ -1488,8 +1479,8 @@ int gribapiDecode(unsigned char *gribbuffer, int gribsize, double *data, int gri
 	}
     }
 
-  recsize = (size_t)gribsize;
-  gh = grib_handle_new_from_message(NULL, (void *) gribbuffer, recsize);
+  size_t recsize = (size_t)gribsize;
+  grib_handle *gh = grib_handle_new_from_message(NULL, (void *) gribbuffer, recsize);
   GRIB_CHECK(my_grib_set_double(gh, "missingValue", missval), 0);
 
   /* get the size of the values array*/
@@ -1500,12 +1491,11 @@ int gribapiDecode(unsigned char *gribbuffer, int gribsize, double *data, int gri
 
   if ( gridsize != (int) datasize )
     Error("Internal problem: gridsize(%d) != datasize(%d)!", gridsize, datasize);
-  dummy = datasize;
+  size_t dummy = datasize;
   GRIB_CHECK(grib_get_double_array(gh, "values", data, &dummy), 0);
 
-  int gridtype;
   GRIB_CHECK(grib_get_long(gh, "gridDefinitionTemplateNumber", &lpar), 0);
-  gridtype = (int) lpar;
+  int gridtype = (int) lpar;
 
   *nmiss = 0;
   if ( gridtype < 50 || gridtype > 53 )
@@ -1597,6 +1587,14 @@ void gribapiDefParam(int editionNumber, grib_handle *gh, int param, const char *
     {
       if ( pnum < 0 ) pnum = -pnum;
 
+      static bool lwarn_pnum = true;
+      if ( pnum > 255 && lwarn_pnum )
+        {
+          Warning("Parameter number %d out of range (1-255), set to %d!", pnum, pnum%256);
+          lwarn_pnum = false;
+          pnum = pnum%256;
+        }
+
       if ( editionNumber <= 1 )
 	{
           static bool lwarn_pdis = true;
@@ -1608,14 +1606,6 @@ void gribapiDefParam(int editionNumber, grib_handle *gh, int param, const char *
               lwarn_pdis = false;
 	    }
 
-          static bool lwarn_pnum = true;
-          if ( pnum > 255 && lwarn_pnum )
-            {
-              Warning("Parameter number %d out of bounds (1-255), set to %d!", pnum, pnum%256);
-              lwarn_pnum = false;
-              pnum = pnum%256;
-            }
-
 	  GRIB_CHECK(my_grib_set_long(gh, "table2Version",        pcat), 0);
 	  GRIB_CHECK(my_grib_set_long(gh, "indicatorOfParameter", pnum), 0);
 	}
@@ -1671,7 +1661,7 @@ void gribapiDefStepUnits(grib_handle *gh, int timeunit, int proDefTempNum, int g
     {
       GRIB_CHECK(my_grib_set_long(gh, "stepUnits", unitsOfTime), 0);
       if ( proDefTempNum == 8 || proDefTempNum == 11 )
-        GRIB_CHECK(my_grib_set_long(gh, "indicatorOfUnitForTimeRange", unitsOfTime), 0);
+        GRIB_CHECK(my_grib_set_long(gh, "indicatorOfUnitOfTimeRange", unitsOfTime), 0);
       GRIB_CHECK(my_grib_set_long(gh, "indicatorOfUnitOfTimeRange", unitsOfTime), 0);
     }
 }
@@ -1681,21 +1671,32 @@ int gribapiDefSteptype(int editionNumber, grib_handle *gh, int productDefinition
 {
   long proDefTempNum = 0;
   size_t len = 64;
-  char stepType[len];
-
-  switch ( tsteptype )
+  const char *stepType;
+
+  static struct {
+    long productionTemplate;
+    const char sname[8];
+  } ts_tab[] = {
+    [TSTEP_INSTANT] = {  0, "instant" },
+    [TSTEP_AVG] = { 8, "avg" },
+    [TSTEP_ACCUM] = {  8, "accum" },
+    [TSTEP_MAX] = {  8, "max" },
+    [TSTEP_MIN] = {  8, "min" },
+    [TSTEP_DIFF] = {  8, "diff" },
+    [TSTEP_RMS] = {  8, "rms" },
+    [TSTEP_SD] = {  8, "sd" },
+    [TSTEP_COV] = { 8, "cov" },
+    [TSTEP_RATIO] = {  8, "ratio" }
+  };
+  if (tsteptype >= TSTEP_INSTANT && tsteptype <= TSTEP_RATIO)
+    {
+      stepType = ts_tab[tsteptype].sname;
+      proDefTempNum = ts_tab[tsteptype].productionTemplate;
+    }
+  else
     {
-    case TSTEP_AVG:      strcpy(stepType, "avg");     proDefTempNum = 8; break;
-    case TSTEP_ACCUM:    strcpy(stepType, "accum");   proDefTempNum = 8; break;
-    case TSTEP_MAX:      strcpy(stepType, "max");     proDefTempNum = 8; break;
-    case TSTEP_MIN:      strcpy(stepType, "min");     proDefTempNum = 8; break;
-    case TSTEP_DIFF:     strcpy(stepType, "diff");    proDefTempNum = 8; break;
-    case TSTEP_RMS:      strcpy(stepType, "rms");     proDefTempNum = 8; break;
-    case TSTEP_SD:       strcpy(stepType, "sd");      proDefTempNum = 8; break;
-    case TSTEP_COV:      strcpy(stepType, "cov");     proDefTempNum = 8; break;
-    case TSTEP_RATIO:    strcpy(stepType, "ratio");   proDefTempNum = 8; break;
-    case TSTEP_INSTANT:  strcpy(stepType, "instant"); proDefTempNum = 0; break;
-    default:             strcpy(stepType, "instant"); proDefTempNum = 0; break;
+      stepType = "instant";
+      proDefTempNum = 0;
     }
 
   if ( typeOfGeneratingProcess == 4 )
@@ -1735,7 +1736,6 @@ int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rti
   int status = -1;
   int year, month, day, hour, minute, second;
   int julday1, secofday1, julday2, secofday2, days, secs;
-  int factor;
   long startStep = 0, endStep;
 
   cdiDecodeDate(rdate, &year, &month, &day);
@@ -1750,7 +1750,7 @@ int gribapiDefDateTimeRel(int editionNumber, grib_handle *gh, int rdate, int rti
 
   (void) julday_sub(julday1, secofday1, julday2, secofday2, &days, &secs);
 
-  factor = getTimeunitFactor(timeunit);
+  int factor = getTimeunitFactor(timeunit);
 
   if ( !(int) fmod(days*86400.0 + secs, factor) )
     {
@@ -1828,15 +1828,12 @@ void gribapiDefTime(int editionNumber, int productDefinitionTemplate, int typeOf
 static
 void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype, int lieee, int datatype, int nmiss, int gcinit)
 {
-  int gridtype;
   int status;
   static short lwarn = TRUE;
-  size_t len;
-  char *mesg;
 
   UNUSED(nmiss);
 
-  gridtype = gridInqType(gridID);
+  int gridtype = gridInqType(gridID);
 
   if ( editionNumber <= 1 )
     if ( gridtype == GRID_GME || gridtype == GRID_UNSTRUCTURED )
@@ -1888,17 +1885,20 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
         {
           if ( comptype == COMPRESS_JPEG )
             {
-              mesg = "grid_jpeg"; len = strlen(mesg);
+              static const char mesg[] = "grid_jpeg";
+              size_t len = sizeof (mesg) - 1;
               GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
             }
           else if ( comptype == COMPRESS_SZIP )
             {
-              mesg = "grid_ccsds"; len = strlen(mesg);
+              static const char mesg[] = "grid_ccsds";
+              size_t len = sizeof (mesg) - 1;
               GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
             }
           else
             {
-              mesg = "grid_simple"; len = strlen(mesg);
+              static const char mesg[] = "grid_simple";
+              size_t len = sizeof (mesg) - 1;
               GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
             }
         }
@@ -1920,22 +1920,26 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 
 	if ( gridtype == GRID_GAUSSIAN )
 	  {
-	    mesg = "regular_gg"; len = strlen(mesg);
+            static const char mesg[] = "regular_gg";
+            size_t len = sizeof (mesg) -1;
 	    GRIB_CHECK(my_grib_set_string(gh, "gridType", mesg, &len), 0);
 	  }
 	else if ( gridtype == GRID_GAUSSIAN_REDUCED )
 	  {
-	    mesg = "reduced_gg"; len = strlen(mesg);
+            static const char mesg[] = "reduced_gg";
+            size_t len = sizeof (mesg) -1;
 	    GRIB_CHECK(my_grib_set_string(gh, "gridType", mesg, &len), 0);
 	  }
 	else if ( gridtype == GRID_LONLAT && gridIsRotated(gridID) )
 	  {
-	    mesg = "rotated_ll"; len = strlen(mesg);
+            static const char mesg[] = "rotated_ll";
+            size_t len = sizeof (mesg) -1;
 	    GRIB_CHECK(my_grib_set_string(gh, "gridType", mesg, &len), 0);
 	  }
 	else
 	  {
-	    mesg = "regular_ll"; len = strlen(mesg);
+            static const char mesg[] = "regular_ll";
+            size_t len = sizeof (mesg) -1;
 	    GRIB_CHECK(my_grib_set_string(gh, "gridType", mesg, &len), 0);
 	  }
 
@@ -1949,15 +1953,15 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 
 	    nlon = 0;
 
-	    rowlon = (int *) malloc(nlat*sizeof(int));
-	    pl     = (long *) malloc(nlat*sizeof(long));
+	    rowlon = (int *) Malloc((size_t)nlat*sizeof(int));
+	    pl     = (long *) Malloc((size_t)nlat*sizeof(long));
 	    gridInqRowlon(gridID, rowlon);
 	    for ( i = 0; i < nlat; ++i ) pl[i] = rowlon[i];
 
 	    // GRIB_CHECK(my_grib_set_long_array(gh, "pl", pl, nlat), 0);
 
-	    free(pl);
-	    free(rowlon);
+	    Free(pl);
+	    Free(rowlon);
 	  }
 	else
 	  {
@@ -2036,8 +2040,9 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 	    ypole = gridInqYpole(gridID);
 	    angle = gridInqAngle(gridID);
 	    /* change from north to south pole */
-	    ypole = -ypole;
+	    if ( fabs(ypole) > 0 ) ypole = -ypole;
 	    xpole =  xpole + 180;
+            if ( fabs(angle) > 0 ) angle = -angle;
 	    GRIB_CHECK(my_grib_set_double(gh, "latitudeOfSouthernPoleInDegrees",  ypole), 0);
 	    GRIB_CHECK(my_grib_set_double(gh, "longitudeOfSouthernPoleInDegrees", xpole), 0);
 	    GRIB_CHECK(my_grib_set_double(gh, "angleOfRotation", angle), 0);
@@ -2053,7 +2058,8 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 
         if ( lieee )
           {
-            mesg = "grid_ieee"; len = strlen(mesg);
+            static const char mesg[] = "grid_ieee";
+            size_t len = sizeof (mesg) -1;
             GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
 
 	    if ( datatype == DATATYPE_FLT64 )
@@ -2065,17 +2071,20 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 	  {
             if ( comptype == COMPRESS_JPEG )
               {
-                mesg = "grid_jpeg"; len = strlen(mesg);
+                static const char mesg[] = "grid_jpeg";
+                size_t len = sizeof (mesg) -1;
                 GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
               }
             else if ( comptype == COMPRESS_SZIP )
               {
-                mesg = "grid_ccsds"; len = strlen(mesg);
+                static const char mesg[] = "grid_ccsds";
+                size_t len = sizeof (mesg) -1;
                 GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
               }
             else
               {
-                mesg = "grid_simple"; len = strlen(mesg);
+                static const char mesg[] = "grid_simple";
+                size_t len = sizeof (mesg) -1;
                 GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
               }
 	  }
@@ -2094,14 +2103,17 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 	gridInqLCC(gridID, &originLon, &originLat, &lonParY, &lat1, &lat2, &xincm, &yincm,
 		   &projflag, &scanflag);
 
-        mesg = "lambert"; len = strlen(mesg);
+        static const char mesg[] = "lambert";
+        size_t len = sizeof (mesg) -1;
         GRIB_CHECK(my_grib_set_string(gh, "gridType", mesg, &len), 0);
 
 	GRIB_CHECK(my_grib_set_long(gh, "Nx", xsize), 0);
 	GRIB_CHECK(my_grib_set_long(gh, "Ny", ysize), 0);
 
-	GRIB_CHECK(my_grib_set_double(gh, "DxInMetres", lround(xincm)), 0);
-	GRIB_CHECK(my_grib_set_double(gh, "DyInMetres", lround(yincm)), 0);
+        /* FIXME: lround should probably be round here */
+	GRIB_CHECK(my_grib_set_double(gh, "DxInMetres", (double)lround(xincm)), 0);
+        /* FIXME: lround should probably be round here */
+	GRIB_CHECK(my_grib_set_double(gh, "DyInMetres", (double)lround(yincm)), 0);
 	GRIB_CHECK(my_grib_set_double(gh, "longitudeOfFirstGridPointInDegrees", originLon), 0);
 	GRIB_CHECK(my_grib_set_double(gh, "latitudeOfFirstGridPointInDegrees", originLat), 0);
 	GRIB_CHECK(my_grib_set_double(gh, "LoVInDegrees", lonParY), 0);
@@ -2123,7 +2135,8 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
       {
 	int trunc = gridInqTrunc(gridID);
 
-	mesg = "sh"; len = strlen(mesg);
+        static const char mesg[] = "sh";
+        size_t len = sizeof (mesg) -1;
 	GRIB_CHECK(my_grib_set_string(gh, "gridType", mesg, &len), 0);
 
 	GRIB_CHECK(my_grib_set_long(gh, "J", trunc), 0);
@@ -2136,13 +2149,15 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
           {
             printf("spectral_ieee\n");
             if ( editionNumber == 2 ) GRIB_CHECK(my_grib_set_long(gh, "numberOfValues", gridInqSize(gridID)), 0);
-            mesg = "spectral_ieee"; len = strlen(mesg);
+            static const char mesg[] = "spectral_ieee";
+            size_t len = sizeof (mesg) -1;
             GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
           }
         else */ if ( gridInqComplexPacking(gridID) )
 	  {
 	    if ( editionNumber == 2 ) GRIB_CHECK(my_grib_set_long(gh, "numberOfValues", gridInqSize(gridID)), 0);
-	    mesg = "spectral_complex"; len = strlen(mesg);
+            static const char mesg[] = "spectral_complex";
+            size_t len = sizeof (mesg) -1;
 	    GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
 
 	    GRIB_CHECK(my_grib_set_long(gh, "JS", 20), 0);
@@ -2151,7 +2166,8 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 	  }
 	else
 	  {
-	    mesg = "spectral_simple"; len = strlen(mesg);
+            static const char mesg[] = "spectral_simple";
+            size_t len = sizeof (mesg) -1;
 	    GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
 	  }
 
@@ -2173,7 +2189,8 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 
         if ( comptype == COMPRESS_SZIP )
           {
-            mesg = "grid_ccsds"; len = strlen(mesg);
+            static const char mesg[] = "grid_ccsds";
+            size_t len = sizeof (mesg) -1;
             GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
           }
 
@@ -2200,7 +2217,7 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
             if ( number < 0 ) number = 0;
 	    GRIB_CHECK(my_grib_set_long(gh, "numberOfGridUsed", number), 0);
 	    GRIB_CHECK(my_grib_set_long(gh, "numberOfGridInReference", position), 0);
-            len = CDI_UUID_SIZE;
+            size_t len = CDI_UUID_SIZE;
             gridInqUUID(gridID, uuid);
 	    if (grib_set_bytes(gh, "uuidOfHGrid", uuid, &len) != 0)
 	      Warning("Can't write UUID!");
@@ -2208,7 +2225,8 @@ void gribapiDefGrid(int editionNumber, grib_handle *gh, int gridID, int comptype
 
         if ( comptype == COMPRESS_SZIP )
           {
-            mesg = "grid_ccsds"; len = strlen(mesg);
+            static const char mesg[] = "grid_ccsds";
+            size_t len = sizeof (mesg) -1;
             GRIB_CHECK(my_grib_set_string(gh, "packingType", mesg, &len), 0);
           }
 
@@ -2272,7 +2290,7 @@ void grib2DefLevel(grib_handle *gh, int gcinit, long leveltype1, long leveltype2
 }
 
 static
-void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID, int levelID, int gcinit)
+void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID, int levelID, int gcinit, int proddef_template_num)
 {
   int lbounds = 0;
   static int warning = 1;
@@ -2322,7 +2340,15 @@ void gribapiDefLevel(int editionNumber, grib_handle *gh, int param, int zaxisID,
           }
         else
           {
-            grib2DefLevel(gh, gcinit, grib2ltype, grib2ltype, lbounds, level, dlevel1, dlevel2);
+            /* PRODUCT DEFINITION TEMPLATE NUMBER 32:
+
+               "Analysis or forecast at a horizontal level or in a horizontal layer at a point
+                in time for simulate (synthetic) satellite data"
+
+               The key/value pairs that are set in "grib2DefLevel" do not exist for this template.
+            */
+            if ( proddef_template_num != 32 )
+              grib2DefLevel(gh, gcinit, grib2ltype, grib2ltype, lbounds, level, dlevel1, dlevel2);
           }
 
 	break;
@@ -2583,7 +2609,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
 #if defined(GRIBAPIENCODETEST)
   grib_handle *gh = (grib_handle *) gribHandleNew(editionNumber);
 #else
-  grib_handle *gh = gc->gribHandle;
+  grib_handle *gh = (struct grib_handle *)gc->gribHandle;
 #endif
   GRIB_CHECK(grib_get_long(gh, "editionNumber", &editionNumber), 0);
 
@@ -2607,7 +2633,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
   if ( ! gc->init ) gribapiDefInstitut(gh, vlistID, varID);
   if ( ! gc->init ) gribapiDefModel(gh, vlistID, varID);
 
-  if ( ! gc->init ) gribapiDefParam(editionNumber, gh, param, name, stdname);
+  if ( ! gc->init ) gribapiDefParam((int)editionNumber, gh, param, name, stdname);
 
   if ( editionNumber == 2 && (datatype == DATATYPE_FLT32 || datatype == DATATYPE_FLT64) ) lieee = TRUE;
 
@@ -2620,50 +2646,48 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
 
   gribapiDefGrid((int)editionNumber, gh, gridID, comptype, lieee, datatype, nmiss, gc->init);
 
-  gribapiDefLevel((int)editionNumber, gh, param, zaxisID, levelID, gc->init);
-
-  /* ---------------------------------- */
-  /* Local change: 2013-01-28, FP (DWD) */
-  /* ---------------------------------- */
+  gribapiDefLevel((int)editionNumber, gh, param, zaxisID, levelID, gc->init, productDefinitionTemplate);
 
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
   //if (!gc->init)
   {
-    for ( int i=0; i<vlistptr->vars[varID].opt_grib_dbl_nentries; i++ )
-      {
-        if ( vlistptr->vars[varID].opt_grib_dbl_update[i] )
-          {
-            //DR: Fix for multi-level fields (otherwise only the 1st level is correct)
-            if ( zaxisInqSize(zaxisID)==(levelID+1) ) vlistptr->vars[varID].opt_grib_dbl_update[i] = FALSE;
-            int ret = my_grib_set_double(gh, vlistptr->vars[varID].opt_grib_dbl_keyword[i],
-                                         vlistptr->vars[varID].opt_grib_dbl_val[i]);
-            if (ret != 0) {
-              fprintf(stderr, "key \"%s\"  :   value = %g\n",
-                      vlistptr->vars[varID].opt_grib_dbl_keyword[i],
-                      vlistptr->vars[varID].opt_grib_dbl_val[i]);
-            }
-            GRIB_CHECK(ret, 0);
-          }
-      }
-    for ( int i=0; i<vlistptr->vars[varID].opt_grib_int_nentries; i++ )
+    int ret = 0;
+
+    /* NOTE: Optional key/value pairs: Note that we do not distinguish
+     *       between tiles here! */
+
+    for ( int i=0; i<vlistptr->vars[varID].opt_grib_nentries; i++ )
       {
-        if ( vlistptr->vars[varID].opt_grib_int_update[i] )
+        if ( vlistptr->vars[varID].opt_grib_kvpair[i].update )
           {
             //DR: Fix for multi-level fields (otherwise only the 1st level is correct)
-            if ( zaxisInqSize(zaxisID)==(levelID+1) ) vlistptr->vars[varID].opt_grib_int_update[i] = FALSE;
-            int ret = my_grib_set_long(gh, vlistptr->vars[varID].opt_grib_int_keyword[i],
-                                       vlistptr->vars[varID].opt_grib_int_val[i]);
-            if (ret != 0) {
-              fprintf(stderr, "key \"%s\"  :   value = %d\n",
-                      vlistptr->vars[varID].opt_grib_int_keyword[i],
-                      vlistptr->vars[varID].opt_grib_int_val[i]);
-            }
-            GRIB_CHECK(ret, 0);
+            if ( zaxisInqSize(zaxisID)==(levelID+1) )
+              vlistptr->vars[varID].opt_grib_kvpair[i].update = FALSE;
+
+            if (vlistptr->vars[varID].opt_grib_kvpair[i].data_type == t_double)
+              {
+                if ( CDI_Debug )
+                  Message("key \"%s\"  :   double value = %g\n",
+                          vlistptr->vars[varID].opt_grib_kvpair[i].keyword,
+                          vlistptr->vars[varID].opt_grib_kvpair[i].dbl_val);
+                my_grib_set_double(gh, vlistptr->vars[varID].opt_grib_kvpair[i].keyword,
+                                   vlistptr->vars[varID].opt_grib_kvpair[i].dbl_val);
+                GRIB_CHECK(ret, 0);
+                }
+            if (vlistptr->vars[varID].opt_grib_kvpair[i].data_type == t_int)
+              {
+                if ( CDI_Debug )
+                  Message("key \"%s\"  :   integer value = %d\n",
+                          vlistptr->vars[varID].opt_grib_kvpair[i].keyword,
+                          vlistptr->vars[varID].opt_grib_kvpair[i].int_val);
+                my_grib_set_long(gh, vlistptr->vars[varID].opt_grib_kvpair[i].keyword,
+                                 (long) vlistptr->vars[varID].opt_grib_kvpair[i].int_val);
+                GRIB_CHECK(ret, 0);
+              }
           }
       }
   }
 
-
   if ( nmiss > 0 )
     {
       GRIB_CHECK(my_grib_set_long(gh, "bitmapPresent", 1), 0);
@@ -2676,7 +2700,7 @@ size_t gribapiEncode(int varID, int levelID, int vlistID, int gridID, int zaxisI
   GRIB_CHECK(grib_get_message(gh, (const void **)&dummy, &recsize), 0);
   recsize += 512; /* add some space for possible filling */
   *gribbuffersize = recsize;
-  *gribbuffer = (unsigned char *) malloc(*gribbuffersize);
+  *gribbuffer = (unsigned char *) Malloc(*gribbuffersize);
 
   /* get a copy of the coded message */
   GRIB_CHECK(grib_get_message_copy(gh, *gribbuffer, &recsize), 0);
diff --git a/libcdi/src/stream_gribapi.h b/libcdi/src/stream_gribapi.h
index 6c136bd..d3ff963 100644
--- a/libcdi/src/stream_gribapi.h
+++ b/libcdi/src/stream_gribapi.h
@@ -1,10 +1,6 @@
 #ifndef _STREAM_GRIBAPI_H
 #define _STREAM_GRIBAPI_H
 
-#ifndef  _CDI_INT_H
-#include "cdi_int.h"
-#endif
-
 int gribapiScanTimestep1(stream_t * streamptr);
 int gribapiScanTimestep2(stream_t * streamptr);
 int gribapiScanTimestep(stream_t * streamptr);
diff --git a/libcdi/src/stream_history.c b/libcdi/src/stream_history.c
index 864a68a..b06ea79 100644
--- a/libcdi/src/stream_history.c
+++ b/libcdi/src/stream_history.c
@@ -29,7 +29,7 @@ void streamDefHistory(int streamID, int length, const char *history)
                * history argument directly? */
 	      histstring = strdupx(history);
 	      cdfDefHistory(streamptr, length, histstring);
-	      free(histstring);
+	      Free(histstring);
 	    }
 	}
     }
diff --git a/libcdi/src/stream_ieg.c b/libcdi/src/stream_ieg.c
index efa4809..b798514 100644
--- a/libcdi/src/stream_ieg.c
+++ b/libcdi/src/stream_ieg.c
@@ -2,6 +2,8 @@
 #  include "config.h"
 #endif
 
+#include <limits.h>
+#include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -37,7 +39,7 @@ typedef struct {
 } IEGCOMPVAR;
 
 
-int iegInqDatatype(int prec)
+static int iegInqDatatype(int prec)
 {
   int datatype;
 
@@ -48,7 +50,7 @@ int iegInqDatatype(int prec)
 }
 
 
-int iegDefDatatype(int datatype)
+static int iegDefDatatype(int datatype)
 {
   int prec;
 
@@ -110,7 +112,7 @@ void iegReadRecord(stream_t *streamptr, double *data, int *nmiss)
   int varID, gridID;
   int i, size;
   double missval;
-  iegrec_t *iegp = (iegrec_t*) streamptr->record->exsep;
+  void *iegp = streamptr->record->exsep;
 
   vlistID = streamptr->vlistID;
   fileID  = streamptr->fileID;
@@ -199,7 +201,7 @@ int iegGetZaxisType(int iegleveltype)
 }
 
 
-void iegDefTime(int *pdb, int date, int time, int taxisID)
+static void iegDefTime(int *pdb, int date, int time, int taxisID)
 {
   int year, month, day, hour, minute, second;
   int timetype = -1;
@@ -227,30 +229,38 @@ void iegDefTime(int *pdb, int date, int time, int taxisID)
   pdb[5] = 128;
 }
 
-static
-int calc_resfac(double xfirst, double xlast, double xinc, double yfirst, double ylast, double yinc)
+/* find smallest power of 10 in [1000,10000000] that upon
+ * multiplication results in fractional part close to zero for all
+ * arguments */
+static double
+calc_resfac(double xfirst, double xlast, double xinc, double yfirst, double ylast, double yinc)
 {
-  int i, j;
-  int iresfac = 1000;
-  int ifact;
-  int ifacarr[5] = {1000, 10000, 100000, 1000000, 10000000};
-  double vals[6] = {xfirst, xlast, xinc, yfirst, ylast, yinc};
-
-  for ( j = 0; j < 5; ++j )
+  double resfac = 1000.0;
+  enum {
+    nPwrOf10 = 5,
+    nMultTests = 6,
+  };
+  static const double scaleFactors[nPwrOf10]
+    = { 1000, 10000, 100000, 1000000, 10000000 };
+  double vals[nMultTests] = { xfirst, xlast, xinc, yfirst, ylast, yinc };
+
+  for (size_t j = 0; j < nPwrOf10; ++j )
     {
-      ifact = ifacarr[j];
-      for ( i = 0; i < 6; ++i )
+      double scaleBy = scaleFactors[j];
+      bool fractionalScale = false;
+      for (size_t i = 0; i < nMultTests; ++i )
         {
-          if ( fabs(vals[i]*ifact - round(vals[i]*ifact)) > FLT_EPSILON ) break;
+          fractionalScale = fractionalScale
+            || fabs(vals[i]*scaleBy - round(vals[i]*scaleBy)) > FLT_EPSILON;
         }
-      if ( i == 6 )
+      if ( !fractionalScale )
         {
-          iresfac = ifact;
+          resfac = scaleBy;
           break;
         }
     }
 
-  return (iresfac);
+  return (resfac);
 }
 
 static
@@ -327,8 +337,8 @@ void iegDefGrid(int *gdb, int gridID)
       else
 	IEG_G_GridType(gdb) = 0;
 
-      int iresfac = calc_resfac(xfirst, xlast, xinc, yfirst, ylast, yinc);
-      double resfac = (double) iresfac;
+      double resfac = calc_resfac(xfirst, xlast, xinc, yfirst, ylast, yinc);
+      int iresfac = (int)resfac;
       if ( iresfac == 1000 ) iresfac = 0;
 
       IEG_G_ResFac(gdb)   = iresfac;
@@ -412,7 +422,7 @@ void iegDefLevel(int *pdb, int *gdb, double *vct, int zaxisID, int levelID)
       {
 	IEG_P_LevelType(pdb) = IEG_LTYPE_SURFACE;
 	IEG_P_Level1(pdb)    = 0;
-	IEG_P_Level2(pdb)    = (int) zaxisInqLevel(zaxisID, levelID);
+	IEG_P_Level2(pdb)    = (int)(zaxisInqLevel(zaxisID, levelID));
 	break;
       }
     case ZAXIS_HYBRID:
@@ -422,14 +432,14 @@ void iegDefLevel(int *pdb, int *gdb, double *vct, int zaxisID, int levelID)
 	if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
 	  {
 	    IEG_P_LevelType(pdb) = IEG_LTYPE_HYBRID_LAYER;
-	    IEG_P_Level1(pdb)    = (int) zaxisInqLbound(zaxisID, levelID);
-	    IEG_P_Level2(pdb)    = (int) zaxisInqUbound(zaxisID, levelID);
+	    IEG_P_Level1(pdb)    = (int)(zaxisInqLbound(zaxisID, levelID));
+	    IEG_P_Level2(pdb)    = (int)(zaxisInqUbound(zaxisID, levelID));
 	  }
 	else
 	  {
 	    IEG_P_LevelType(pdb) = IEG_LTYPE_HYBRID;
 	    IEG_P_Level1(pdb)    = 0;
-	    IEG_P_Level2(pdb)    = (int) zaxisInqLevel(zaxisID, levelID);
+	    IEG_P_Level2(pdb)    = (int)(zaxisInqLevel(zaxisID, levelID));
 	  }
 
 	vctsize = zaxisInqVctSize(zaxisID);
@@ -511,8 +521,8 @@ void iegDefLevel(int *pdb, int *gdb, double *vct, int zaxisID, int levelID)
 	if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
 	  {
 	    IEG_P_LevelType(pdb) = IEG_LTYPE_LANDDEPTH_LAYER;
-	    IEG_P_Level1(pdb)    = (int) zaxisInqLbound(zaxisID, levelID);
-	    IEG_P_Level2(pdb)    = (int) zaxisInqUbound(zaxisID, levelID);
+	    IEG_P_Level1(pdb)    = (int)(zaxisInqLbound(zaxisID, levelID));
+	    IEG_P_Level2(pdb)    = (int)(zaxisInqUbound(zaxisID, levelID));
 	  }
 	else
 	  {
@@ -771,7 +781,8 @@ void iegAddRecord(stream_t *streamptr, int param, int *pdb, int *gdb, double *vc
   datatype = iegInqDatatype(prec);
 
   varAddRecord(recID, param, gridID, leveltype, lbounds, level1, level2, 0, 0,
-	       datatype, &varID, &levelID, TSTEP_INSTANT, 0, 0, -1, NULL, NULL, NULL, NULL);
+	       datatype, &varID, &levelID, TSTEP_INSTANT, 0, 0, -1,
+               NULL, NULL, NULL, NULL, NULL, NULL);
 
   record->varID   = (short)varID;
   record->levelID = (short)levelID;
@@ -813,7 +824,7 @@ void iegCmpRecord(stream_t *streamptr, int tsID, int recID, off_t position, int
 }
 #endif
 
-void iegDateTime(int *pdb, int *date, int *time)
+static void iegDateTime(int *pdb, int *date, int *time)
 {
   int ryear, rmonth, rday, rhour, rminute;
 
@@ -840,7 +851,7 @@ void iegScanTimestep1(stream_t *streamptr)
   int tabnum;
   int param = 0;
   int rcode = 0, rlevel = 0, vdate = 0, vtime = 0;
-  DateTime datetime, datetime0;
+  DateTime datetime0 = { LONG_MIN, LONG_MIN };
   int tsID;
   int varID;
   size_t recsize;
@@ -895,8 +906,6 @@ void iegScanTimestep1(stream_t *streamptr)
 	}
       else
 	{
-	  datetime.date = vdate;
-	  datetime.time = vtime;
 	  compVar.param = param;
           compVar.level = rlevel;
 	  for ( recID = 0; recID < nrecs; recID++ )
@@ -907,7 +916,8 @@ void iegScanTimestep1(stream_t *streamptr)
 	      if ( memcmp(&compVar0, &compVar, sizeof(IEGCOMPVAR)) == 0 ) break;
 	    }
 	  if ( recID < nrecs ) break;
-	  if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) )
+	  DateTime datetime = { .date = vdate, .time = vtime};
+	  if ( datetimeCmp(datetime, datetime0) )
 	    Warning("Inconsistent verification time for param %d level %d", param, rlevel);
 	}
 
@@ -938,11 +948,11 @@ void iegScanTimestep1(stream_t *streamptr)
     {
       streamptr->tsteps[0].recordSize = nrecords;
       streamptr->tsteps[0].records =
-	(record_t *)xrealloc(streamptr->tsteps[0].records,
+	(record_t *) Realloc(streamptr->tsteps[0].records,
                              (size_t)nrecords * sizeof (record_t));
     }
 
-  streamptr->tsteps[0].recIDs = (int *)xmalloc((size_t)nrecords * sizeof (int));
+  streamptr->tsteps[0].recIDs = (int *) Malloc((size_t)nrecords * sizeof (int));
   streamptr->tsteps[0].nrecs = nrecords;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[0].recIDs[recID] = recID;
@@ -1005,7 +1015,7 @@ int iegScanTimestep2(stream_t *streamptr)
   cdi_create_records(streamptr, tsID);
 
   nrecords = streamptr->tsteps[0].nallrecs;
-  streamptr->tsteps[1].recIDs = (int *)xmalloc((size_t)nrecords * sizeof(int));
+  streamptr->tsteps[1].recIDs = (int *) Malloc((size_t)nrecords * sizeof(int));
   streamptr->tsteps[1].nrecs = 0;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[1].recIDs[recID] = -1;
@@ -1190,7 +1200,7 @@ long iegScanTimestep(stream_t *streamptr)
 
       streamptr->tsteps[tsID].nrecs = nrecs;
       streamptr->tsteps[tsID].recIDs
-        = (int *)xmalloc((size_t)nrecs * sizeof (int));
+        = (int *) Malloc((size_t)nrecs * sizeof (int));
       for ( recID = 0; recID < nrecs; recID++ )
 	streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
 
@@ -1317,11 +1327,12 @@ void iegReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
   int recID;
   int i;
   double missval;
-  iegrec_t *iegp = (iegrec_t*) streamptr->record->exsep;
+  void *iegp = streamptr->record->exsep;
 
   vlistID  = streamptr->vlistID;
   fileID   = streamptr->fileID;
-  nlevs    = streamptr->vars[varID].nlevs;
+  /* NOTE: tiles are not supported here! */
+  nlevs    = streamptr->vars[varID].recordTable[0].nlevs;
   missval  = vlistInqVarMissval(vlistID, varID);
   gridID   = vlistInqVarGrid(vlistID, varID);
   gridsize = gridInqSize(gridID);
@@ -1334,7 +1345,8 @@ void iegReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
 
   for (levID = 0; levID < nlevs; levID++)
     {
-      recID = streamptr->vars[varID].level[levID];
+      /* NOTE: tiles are not supported here! */
+      recID = streamptr->vars[varID].recordTable[0].recordID[levID];
       recpos = streamptr->tsteps[tsid].records[recID].position;
       fileSetPos(fileID, recpos, SEEK_SET);
       iegRead(fileID, iegp);
@@ -1361,11 +1373,12 @@ void iegReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data,
   int recID;
   int i;
   double missval;
-  iegrec_t *iegp = (iegrec_t*) streamptr->record->exsep;
+  void *iegp = streamptr->record->exsep;
 
   vlistID  = streamptr->vlistID;
   fileID   = streamptr->fileID;
-  nlevs    = streamptr->vars[varID].nlevs;
+  /* NOTE: tiles are not supported here! */
+  nlevs    = streamptr->vars[varID].recordTable[0].nlevs;
   missval  = vlistInqVarMissval(vlistID, varID);
   gridID   = vlistInqVarGrid(vlistID, varID);
   gridsize = gridInqSize(gridID);
@@ -1377,7 +1390,8 @@ void iegReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data,
 
   currentfilepos = fileGetPos(fileID);
 
-  recID = streamptr->vars[varID].level[levID];
+  /* NOTE: tiles are not supported here! */
+  recID = streamptr->vars[varID].recordTable[0].recordID[levID];
   recpos = streamptr->tsteps[tsid].records[recID].position;
   fileSetPos(fileID, recpos, SEEK_SET);
   iegRead(fileID, iegp);
diff --git a/libcdi/src/stream_record.c b/libcdi/src/stream_record.c
index 073b0cf..3316cc4 100644
--- a/libcdi/src/stream_record.c
+++ b/libcdi/src/stream_record.c
@@ -2,6 +2,7 @@
 #  include "config.h"
 #endif
 
+#include <limits.h>
 #include <stdio.h>
 #include <string.h>
 
@@ -27,13 +28,14 @@ void recordInitEntry(record_t *record)
   record->varID    = CDI_UNDEFID;
   record->levelID  = CDI_UNDEFID;
   memset(record->varname, 0, sizeof(record->varname));
+  memset(&record->tiles, 0, sizeof(record->tiles));
 }
 
 
 int recordNewEntry(stream_t *streamptr, int tsID)
 {
-  int recordID = 0;
-  int recordSize = streamptr->tsteps[tsID].recordSize;
+  size_t recordID = 0;
+  size_t recordSize = (size_t)streamptr->tsteps[tsID].recordSize;
   record_t *records = streamptr->tsteps[tsID].records;
   /*
     Look for a free slot in record.
@@ -41,44 +43,33 @@ int recordNewEntry(stream_t *streamptr, int tsID)
   */
   if ( ! recordSize )
     {
-      int i;
       recordSize = 1;   /*  <<<<----  */
-      records = (record_t *)xmalloc((size_t)recordSize * sizeof (record_t));
-      if ( records == NULL )
-	{
-          Message("recordSize = %d", recordSize);
-	  SysError("Allocation of records failed");
-	}
+      records = (record_t *) Malloc(recordSize * sizeof (record_t));
 
-      for ( i = 0; i < recordSize; i++ )
+      for ( size_t i = 0; i < recordSize; i++ )
 	records[i].used = CDI_UNDEFID;
     }
   else
     {
-      while ( recordID < recordSize )
-	{
-	  if ( records[recordID].used == CDI_UNDEFID ) break;
-	  recordID++;
-	}
+      while ( recordID < recordSize
+              && records[recordID].used != CDI_UNDEFID )
+        ++recordID;
     }
   /*
     If the table overflows, double its size.
   */
   if ( recordID == recordSize )
     {
-      int i;
-
-      recordSize = 2*recordSize;
-      records    = (record_t *)xrealloc(records,
-                                        (size_t)recordSize * sizeof (record_t));
-      if ( records == NULL )
-	{
-          Message("recordSize = %d", recordSize);
-	  SysError("Reallocation of records failed");
-	}
-      recordID = recordSize/2;
-
-      for ( i = recordID; i < recordSize; i++ )
+      if (recordSize <= INT_MAX / 2)
+        recordSize *= 2;
+      else if (recordSize < INT_MAX)
+        recordSize = INT_MAX;
+      else
+        Error("Cannot handle this many records!\n");
+      records = (record_t *) Realloc(records,
+                                     recordSize * sizeof (record_t));
+
+      for ( size_t i = recordID; i < recordSize; i++ )
 	records[i].used = CDI_UNDEFID;
     }
 
@@ -86,16 +77,16 @@ int recordNewEntry(stream_t *streamptr, int tsID)
 
   records[recordID].used = 1;
 
-  streamptr->tsteps[tsID].recordSize = recordSize;
+  streamptr->tsteps[tsID].recordSize = (int)recordSize;
   streamptr->tsteps[tsID].records    = records;
 
-  return (recordID);
+  return (int)recordID;
 }
 
 static
 void cdiInitRecord(stream_t *streamptr)
 {
-  streamptr->record = (Record *) malloc(sizeof(Record));
+  streamptr->record = (Record *) Malloc(sizeof(Record));
 
   streamptr->record->param      = 0;
   streamptr->record->level      = 0;
@@ -136,7 +127,8 @@ void streamInqRecord(int streamID, int *varID, int *levelID)
   *varID   = streamptr->tsteps[tsID].records[recID].varID;
   int lindex = streamptr->tsteps[tsID].records[recID].levelID;
 
-  *levelID = streamptr->vars[*varID].lindex[lindex];
+  int isub = subtypeInqActiveIndex(streamptr->vars[*varID].subtypeID);
+  *levelID = streamptr->vars[*varID].recordTable[isub].lindex[lindex];
 
   if ( CDI_Debug )
     Message("tsID = %d, recID = %d, varID = %d, levelID = %d\n", tsID, recID, *varID, *levelID);
@@ -178,7 +170,7 @@ void streamDefRecord(int streamID, int varID, int levelID)
   int gridID  = vlistInqVarGrid(vlistID, varID);
   int zaxisID = vlistInqVarZaxis(vlistID, varID);
   int param   = vlistInqVarParam(vlistID, varID);
-  int level   = (int) zaxisInqLevel(zaxisID, levelID);
+  int level   = (int)(zaxisInqLevel(zaxisID, levelID));
 
   streamptr->record->varID    = varID;
   streamptr->record->levelID  = levelID;
@@ -438,8 +430,8 @@ void cdi_create_records(stream_t *streamptr, int tsID)
   unsigned nrecords, maxrecords;
   record_t *records;
 
-  tsteps_t* sourceTstep = streamptr->tsteps;
-  tsteps_t* destTstep = sourceTstep + tsID;
+  tsteps_t *sourceTstep = streamptr->tsteps;
+  tsteps_t *destTstep = sourceTstep + tsID;
 
   if ( destTstep->records ) return;
 
@@ -450,7 +442,8 @@ void cdi_create_records(stream_t *streamptr, int tsID)
       maxrecords = 0;
       int nvars = streamptr->nvars;
       for ( int varID = 0; varID < nvars; varID++)
-	maxrecords += (unsigned)streamptr->vars[varID].nlevs;
+        for (int isub=0; isub<streamptr->vars[varID].subtypeSize; isub++)
+          maxrecords += (unsigned)streamptr->vars[varID].recordTable[isub].nlevs;
     }
   else
     {
@@ -480,7 +473,7 @@ void cdi_create_records(stream_t *streamptr, int tsID)
   //  printf("tsID, nrecords %d %d\n", tsID, nrecords);
 
   if ( maxrecords > 0 )
-    records = (record_t *) malloc(maxrecords * sizeof(record_t));
+    records = (record_t *) Malloc(maxrecords*sizeof(record_t));
   else
     records = NULL;
 
@@ -499,7 +492,7 @@ void cdi_create_records(stream_t *streamptr, int tsID)
 
       for ( unsigned recID = 0; recID < maxrecords; recID++ )
 	{
-          record_t* curRecord = &sourceTstep->records[recID];
+          record_t *curRecord = &sourceTstep->records[recID];
           destTstep->records[recID].used = curRecord->used;
           if ( curRecord->used != CDI_UNDEFID && curRecord->varID != -1 ) /* curRecord->varID = -1 for write mode !!! */
             {
diff --git a/libcdi/src/stream_srv.c b/libcdi/src/stream_srv.c
index da62efb..ef89486 100644
--- a/libcdi/src/stream_srv.c
+++ b/libcdi/src/stream_srv.c
@@ -36,7 +36,7 @@ typedef struct {
 } SRVCOMPVAR;
 
 
-int srvInqDatatype(int prec)
+static int srvInqDatatype(int prec)
 {
   int datatype;
 
@@ -47,7 +47,7 @@ int srvInqDatatype(int prec)
 }
 
 
-int srvDefDatatype(int datatype)
+static int srvDefDatatype(int datatype)
 {
   int prec;
 
@@ -72,7 +72,7 @@ int srvInqRecord(stream_t *streamptr, int *varID, int *levelID)
   int zaxisID = -1;
   int header[8];
   int vlistID;
-  srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
+  void *srvp = streamptr->record->exsep;
 
   vlistID = streamptr->vlistID;
   fileID  = streamptr->fileID;
@@ -110,7 +110,7 @@ void srvReadRecord(stream_t *streamptr, double *data, int *nmiss)
   int varID, gridID;
   int i, size;
   double missval;
-  srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
+  void *srvp = streamptr->record->exsep;
 
   vlistID = streamptr->vlistID;
   fileID  = streamptr->fileID;
@@ -195,10 +195,9 @@ void srvDefRecord(stream_t *streamptr)
 void srvWriteRecord(stream_t *streamptr, const double *data)
 {
   int fileID = streamptr->fileID;
-  srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
+  void *srvp = streamptr->record->exsep;
 
   srvDefDataDP(srvp, data);
-
   srvWrite(fileID, srvp);
 }
 
@@ -235,9 +234,9 @@ void srv_add_record(stream_t *streamptr, int param, int level, int xsize, int ys
 
   int levelID = 0;
   int varID;
-
   varAddRecord(recID, param, gridID, leveltype, 0, level, 0, 0, 0,
-	       datatype, &varID, &levelID, TSTEP_INSTANT, 0, 0, -1, NULL, NULL, NULL, NULL);
+	       datatype, &varID, &levelID, TSTEP_INSTANT, 0, 0, -1,
+               NULL, NULL, NULL, NULL, NULL, NULL);
 
   xassert(varID <= SHRT_MAX && levelID <= SHRT_MAX);
   record->varID   = (short)varID;
@@ -261,7 +260,7 @@ void srvScanTimestep1(stream_t *streamptr)
   int rxsize = 0, rysize = 0;
   int param = 0;
   int rcode = 0, rlevel = 0, vdate = 0, vtime = 0;
-  DateTime datetime, datetime0;
+  DateTime datetime0 = { LONG_MIN, LONG_MIN };
   int tsID;
   int varID;
   off_t recpos;
@@ -269,7 +268,6 @@ void srvScanTimestep1(stream_t *streamptr)
   int taxisID = -1;
   taxis_t *taxis;
   int vlistID;
-  SRVCOMPVAR compVar, compVar0;
   srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
 
   streamptr->curTsID = 0;
@@ -313,19 +311,13 @@ void srvScanTimestep1(stream_t *streamptr)
 	}
       else
 	{
-	  datetime.date = vdate;
-	  datetime.time = vtime;
-	  compVar.param = param;
-          compVar.level = rlevel;
 	  for ( recID = 0; recID < nrecs; recID++ )
-	    {
-	      compVar0.param = streamptr->tsteps[0].records[recID].param;
-	      compVar0.level = streamptr->tsteps[0].records[recID].ilevel;
-
-	      if ( memcmp(&compVar0, &compVar, sizeof(SRVCOMPVAR)) == 0 ) break;
-	    }
+            if (    streamptr->tsteps[0].records[recID].param  == param
+                 && streamptr->tsteps[0].records[recID].ilevel == rlevel )
+              break;
 	  if ( recID < nrecs ) break;
-	  if ( memcmp(&datetime, &datetime0, sizeof(DateTime)) )
+	  DateTime datetime = { .date = vdate, .time = vtime };
+	  if ( datetimeCmp(datetime, datetime0) )
 	    Warning("Inconsistent verification time for code %d level %d", rcode, rlevel);
 	}
 
@@ -356,11 +348,11 @@ void srvScanTimestep1(stream_t *streamptr)
     {
       streamptr->tsteps[0].recordSize = nrecords;
       streamptr->tsteps[0].records =
-	(record_t *)xrealloc(streamptr->tsteps[0].records,
+	(record_t *) Realloc(streamptr->tsteps[0].records,
                              (size_t)nrecords * sizeof(record_t));
     }
 
-  streamptr->tsteps[0].recIDs = (int *)xmalloc((size_t)nrecords * sizeof (int));
+  streamptr->tsteps[0].recIDs = (int *) Malloc((size_t)nrecords * sizeof (int));
   streamptr->tsteps[0].nrecs = nrecords;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[0].recIDs[recID] = recID;
@@ -404,7 +396,7 @@ int srvScanTimestep2(stream_t *streamptr)
   taxis_t *taxis;
   int vlistID;
   SRVCOMPVAR compVar, compVar0;
-  srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
+  void *srvp = streamptr->record->exsep;
 
   streamptr->curTsID = 1;
 
@@ -422,7 +414,7 @@ int srvScanTimestep2(stream_t *streamptr)
   cdi_create_records(streamptr, tsID);
 
   nrecords = streamptr->tsteps[0].nallrecs;
-  streamptr->tsteps[1].recIDs = (int *)xmalloc((size_t)nrecords * sizeof (int));
+  streamptr->tsteps[1].recIDs = (int *) Malloc((size_t)nrecords * sizeof (int));
   streamptr->tsteps[1].nrecs = 0;
   for ( recID = 0; recID < nrecords; recID++ )
     streamptr->tsteps[1].recIDs[recID] = -1;
@@ -574,8 +566,7 @@ long srvScanTimestep(stream_t *streamptr)
   off_t recpos = 0;
   int recID;
   int rindex, nrecs = 0;
-  SRVCOMPVAR compVar, compVar0;
-  srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
+  void *srvp = streamptr->record->exsep;
   /*
   if ( CDI_Debug )
     {
@@ -596,7 +587,7 @@ long srvScanTimestep(stream_t *streamptr)
       nrecs = streamptr->tsteps[1].nrecs;
 
       streamptr->tsteps[tsID].nrecs = nrecs;
-      streamptr->tsteps[tsID].recIDs = (int *)xmalloc((size_t)nrecs * sizeof (int));
+      streamptr->tsteps[tsID].recIDs = (int *) Malloc((size_t)nrecs * sizeof (int));
       for ( recID = 0; recID < nrecs; recID++ )
 	streamptr->tsteps[tsID].recIDs[recID] = streamptr->tsteps[1].recIDs[recID];
 
@@ -637,12 +628,8 @@ long srvScanTimestep(stream_t *streamptr)
 	      taxis->vtime = vtime;
 	    }
 
-	  compVar.param  = param;
-          compVar.level  = rlevel;
-	  compVar0.param = streamptr->tsteps[tsID].records[recID].param;
-	  compVar0.level = streamptr->tsteps[tsID].records[recID].ilevel;
-
-	  if ( memcmp(&compVar0, &compVar, sizeof(SRVCOMPVAR)) != 0 )
+          if (    param  != streamptr->tsteps[tsID].records[recID].param
+               || rlevel != streamptr->tsteps[tsID].records[recID].ilevel )
 	    {
 	      Message("tsID = %d recID = %d param = %3d new %3d  level = %3d new %3d",
 		      tsID, recID,
@@ -723,11 +710,12 @@ void srvReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
   int recID;
   int i;
   double missval;
-  srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
+  void *srvp = streamptr->record->exsep;
 
   vlistID  = streamptr->vlistID;
   fileID   = streamptr->fileID;
-  nlevs    = streamptr->vars[varID].nlevs;
+  /* NOTE: tiles are not supported here! */
+  nlevs    = streamptr->vars[varID].recordTable[0].nlevs;
   missval  = vlistInqVarMissval(vlistID, varID);
   gridID   = vlistInqVarGrid(vlistID, varID);
   gridsize = gridInqSize(gridID);
@@ -740,7 +728,8 @@ void srvReadVarDP(stream_t *streamptr, int varID, double *data, int *nmiss)
 
   for (levID = 0; levID < nlevs; levID++)
     {
-      recID = streamptr->vars[varID].level[levID];
+      /* NOTE: tiles are not supported here! */
+      recID = streamptr->vars[varID].recordTable[0].recordID[levID];
       recpos = streamptr->tsteps[tsid].records[recID].position;
       fileSetPos(fileID, recpos, SEEK_SET);
       if (srvRead(fileID, srvp) < 0)
@@ -770,11 +759,12 @@ void srvReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data,
   int recID;
   int i;
   double missval;
-  srvrec_t *srvp = (srvrec_t*) streamptr->record->exsep;
+  void *srvp = streamptr->record->exsep;
 
   vlistID  = streamptr->vlistID;
   fileID   = streamptr->fileID;
-  nlevs    = streamptr->vars[varID].nlevs;
+  /* NOTE: tiles are not supported here! */
+  nlevs    = streamptr->vars[varID].recordTable[0].nlevs;
   missval  = vlistInqVarMissval(vlistID, varID);
   gridID   = vlistInqVarGrid(vlistID, varID);
   gridsize = gridInqSize(gridID);
@@ -786,7 +776,8 @@ void srvReadVarSliceDP(stream_t *streamptr, int varID, int levID, double *data,
 
   currentfilepos = fileGetPos(fileID);
 
-  recID = streamptr->vars[varID].level[levID];
+  /* NOTE: tiles are not supported here! */
+  recID = streamptr->vars[varID].recordTable[0].recordID[levID];
   recpos = streamptr->tsteps[tsid].records[recID].position;
   fileSetPos(fileID, recpos, SEEK_SET);
   if (srvRead(fileID, srvp) < 0)
diff --git a/libcdi/src/stream_var.c b/libcdi/src/stream_var.c
index ca6f959..79e0c6b 100644
--- a/libcdi/src/stream_var.c
+++ b/libcdi/src/stream_var.c
@@ -11,18 +11,27 @@
 #include "cdi_int.h"
 
 
+static void streamvar_init_recordtable(stream_t *streamptr, int varID, int isub)
+{
+  streamptr->vars[varID].recordTable[isub].nlevs    = 0;
+  streamptr->vars[varID].recordTable[isub].recordID = NULL;
+  streamptr->vars[varID].recordTable[isub].lindex   = NULL;
+}
+
+
 static
 void streamvar_init_entry(stream_t *streamptr, int varID)
 {
   streamptr->vars[varID].ncvarid      = CDI_UNDEFID;
   streamptr->vars[varID].defmiss      = 0;
-  streamptr->vars[varID].nlevs        = 0;
-  streamptr->vars[varID].level        = NULL;
-  streamptr->vars[varID].lindex       = NULL;
+
+  streamptr->vars[varID].subtypeSize  = 0;
+  streamptr->vars[varID].recordTable  = NULL;
 
   streamptr->vars[varID].gridID       = CDI_UNDEFID;
   streamptr->vars[varID].zaxisID      = CDI_UNDEFID;
   streamptr->vars[varID].tsteptype    = CDI_UNDEFID;
+  streamptr->vars[varID].subtypeID    = CDI_UNDEFID;
 }
 
 static
@@ -44,7 +53,7 @@ int streamvar_new_entry(stream_t *streamptr)
 
       streamvarSize = 2;
       streamvar
-        = (svarinfo_t *)xmalloc((size_t)streamvarSize * sizeof(svarinfo_t));
+        = (svarinfo_t *) Malloc((size_t)streamvarSize * sizeof(svarinfo_t));
       if ( streamvar == NULL )
 	{
           Message("streamvarSize = %d", streamvarSize);
@@ -71,7 +80,7 @@ int streamvar_new_entry(stream_t *streamptr)
 
       streamvarSize = 2*streamvarSize;
       streamvar
-        = (svarinfo_t *)xrealloc(streamvar,
+        = (svarinfo_t *) Realloc(streamvar,
                                  (size_t)streamvarSize * sizeof (svarinfo_t));
       if ( streamvar == NULL )
 	{
@@ -90,43 +99,60 @@ int streamvar_new_entry(stream_t *streamptr)
   streamvar_init_entry(streamptr, varID);
 
   streamptr->vars[varID].isUsed = TRUE;
-
   return (varID);
 }
 
 
-int stream_new_var(stream_t *streamptr, int gridID, int zaxisID)
+static void
+allocate_record_table_entry(stream_t *streamptr, int varID, int subID, int nlevs)
 {
-  int varID;
-  int *level;
-  int *lindex;
-  int nlevs;
-  int levID;
+  int *level    = (int *) Malloc((size_t)nlevs * sizeof (int));
+  int *lindex   = (int *) Malloc((size_t)nlevs * sizeof (int));
+
+  for (int levID = 0; levID < nlevs; levID++ )
+    {
+      level[levID]    = CDI_UNDEFID;
+      lindex[levID]   = levID;
+    }
 
+  streamptr->vars[varID].recordTable[subID].nlevs    = nlevs;
+  streamptr->vars[varID].recordTable[subID].recordID = level;
+  streamptr->vars[varID].recordTable[subID].lindex   = lindex;
+}
+
+
+int stream_new_var(stream_t *streamptr, int gridID, int zaxisID, int tilesetID)
+{
   if ( CDI_Debug )
     Message("gridID = %d  zaxisID = %d", gridID, zaxisID);
 
-  varID = streamvar_new_entry(streamptr);
+  int varID = streamvar_new_entry(streamptr);
+  int nlevs = zaxisInqSize(zaxisID);
 
   streamptr->nvars++;
 
   streamptr->vars[varID].gridID  = gridID;
   streamptr->vars[varID].zaxisID = zaxisID;
 
-  nlevs = zaxisInqSize(zaxisID);
-
-  level  = (int *)xmalloc((size_t)nlevs * sizeof (int));
-  lindex = (int *)xmalloc((size_t)nlevs * sizeof (int));
-
-  for ( levID = 0; levID < nlevs; levID++ )
-    level[levID] = CDI_UNDEFID;
-
-  for ( levID = 0; levID < nlevs; levID++ )
-    lindex[levID] = levID;
-
-  streamptr->vars[varID].nlevs  = nlevs;
-  streamptr->vars[varID].level  = level;
-  streamptr->vars[varID].lindex = lindex;
+  int nsub = 1;
+  if (tilesetID != CDI_UNDEFID)
+    nsub = subtypeInqSize(tilesetID); /* e.g. no of tiles */
+  if ( CDI_Debug )
+    Message("varID %d: create %d tiles with %d level(s), zaxisID=%d", varID, nsub, nlevs,zaxisID);
+  streamptr->vars[varID].recordTable = (sleveltable_t *) Malloc((size_t)nsub * sizeof (sleveltable_t));
+  if( streamptr->vars[varID].recordTable == NULL )
+    SysError("Allocation of leveltable failed!");
+  streamptr->vars[varID].subtypeSize = nsub;
+
+  for (int isub=0; isub<nsub; isub++) {
+    streamvar_init_recordtable(streamptr, varID, isub);
+    allocate_record_table_entry(streamptr, varID, isub, nlevs);
+    if ( CDI_Debug )
+      Message("streamptr->vars[varID].recordTable[isub].recordID[0]=%d",
+              streamptr->vars[varID].recordTable[isub].recordID[0]);
+  }
+
+  streamptr->vars[varID].subtypeID = tilesetID;
 
   return (varID);
 }
diff --git a/libcdi/src/subtype.c b/libcdi/src/subtype.c
new file mode 100644
index 0000000..70cdf0d
--- /dev/null
+++ b/libcdi/src/subtype.c
@@ -0,0 +1,868 @@
+/* Subroutines and data structures for storing "subtypes".             */
+/*                                                                     */
+/* A subtype is, for example, a list of TILES. This can be interpreted */
+/* as an additional axis like the vertical axis.                       */
+/*                                                                     */
+/* @author 02/2015 F. Prill, DWD                                       */
+/*                                                                     */
+/*  DATA LAYOUT:                                                       */
+/*                                                                     */
+/*  A subtype contains several "subtype entries", each of which        */
+/*  contains a linked list of subtype attributes.                      */
+/*                                                                     */
+/*  The number of subtype entries is not specified in advance, but the */
+/*  list of entries is itself dynamically growing. There is no         */
+/*  guaranteed ordering of the entries, therefore each entry must be   */
+/*  identifiable by its attributes.                                    */
+/*                                                                     */
+/*  [subtype_t]                                                        */
+/*      |                                                              */
+/*      |------- globals                  [subtype_entry_t]            */
+/*      |          |--- atts              [subtype_attr_t]             */
+/*      |                                                              */
+/*      |------- entries                                               */
+/*                 |- entry #0                                         */
+/*                 |  |--- atts              [subtype_attr_t]          */
+/*                 |- entry #1                                         */
+/*                 |  |--- atts              [subtype_attr_t]          */
+/*                 |- entry #2                                         */
+/*                 .  |--- atts              [subtype_attr_t]          */
+/*                 .                                                   */
+
+#if defined (HAVE_CONFIG_H)
+#  include "config.h"
+#endif
+
+#include "cdi.h"
+#include "cdi_int.h"
+#include "dmemory.h"
+#include "subtype.h"
+#include "vlist.h"
+
+/* Literal constants corresponding to the different subtypes of the
+   enumeration "subtype_kind". */
+static const char* subtypeName[] = {
+  "tileset"
+};
+
+const char * const cdiSubtypeAttributeName[] = {
+  "tileIndex",
+  "totalNumberOfTileAttributePairs",
+  "tileClassification",
+  "numberOfTiles",
+  "numberOfTileAttributes",
+  "tileAttribute"
+};
+
+
+/* prototypes: */
+static int    subtypeCompareP    (subtype_t *z1, subtype_t *z2);
+static void   subtypeDestroyP    ( void * subtype_ptr );
+static void   subtypePrintP      ( void * subtype_ptr, FILE * fp );
+static int    subtypeGetPackSize ( void * subtype_ptr, void *context);
+static void   subtypePack        ( void * subtype_ptr, void * buffer, int size, int *pos, void *context);
+static int    subtypeTxCode      ( void );
+
+static const resOps subtypeOps = {
+  (int (*) (void *, void *)) subtypeCompareP,
+  (void (*)(void *))         subtypeDestroyP,
+  (void (*)(void *, FILE *)) subtypePrintP,
+  (int (*) (void *, void *)) subtypeGetPackSize,
+                             subtypePack,
+                             subtypeTxCode
+};
+
+enum {
+  differ = 1,
+};
+
+
+
+/* ------------------------------------------------------------------- */
+/* SUBROUTINES FOR ATTRIBUTE LISTS				       */
+/* ------------------------------------------------------------------- */
+
+
+static int attribute_to_index(const char *key)
+{
+  if (key == NULL)  Error("Internal error!");
+  for (int i=0; i<nSubtypeAttributes; i++)
+    if ( strcmp(key, cdiSubtypeAttributeName[i]) == 0 ) return i;
+  return -1;
+}
+
+
+
+/*
+  @Function  subtypeAttrNewList
+  @Title     Create new linked list of subtype attributes.
+  @EndFunction
+*/
+static struct subtype_attr_t* subtypeAttrNewList(struct subtype_entry_t* head, int key, int val)
+{
+  if (head == NULL)  Error("Internal error!");
+  struct subtype_attr_t *ptr = (struct subtype_attr_t*) Malloc(sizeof(struct subtype_attr_t));
+  if(NULL == ptr)  Error("Node creation failed");
+  ptr->key   = key;
+  ptr->val   = val;
+  ptr->next  = NULL;
+
+  head->atts = ptr;
+  return ptr;
+}
+
+
+/*
+  @Function  subtypeAttrInsert
+
+  @Title Add subtype attribute to linked list, s.t. the result is a
+         smallest-to-largest ordered list.
+  @EndFunction
+*/
+static struct subtype_attr_t* subtypeAttrInsert(struct subtype_entry_t* head, int key, int val)
+{
+  if (head == NULL)  Error("Internal error!");
+  if (head->atts == NULL)  return (subtypeAttrNewList(head, key, val));
+
+  /* create new attribute */
+  struct subtype_attr_t* ptr = (struct subtype_attr_t*) Malloc(sizeof(struct subtype_attr_t));
+  if(NULL == ptr)    Error("Node creation failed");
+
+  ptr->key   = key;
+  ptr->val   = val;
+  ptr->next  = NULL;
+
+  /* find the right place for insertion: */
+  if (head->atts->key >= key) {
+    /* insert at position 0 */
+    ptr->next = head->atts;
+    head->atts = ptr;
+  } else {
+    struct subtype_attr_t** predec = &head->atts;
+    while (((*predec)->next != NULL) && ((*predec)->next->key < key)) {
+      predec = &((*predec)->next);
+    }
+    ptr->next = (*predec)->next;
+    (*predec)->next = ptr;  
+  }
+  return ptr;
+}
+
+
+/* Recursively free a linked list with attributes. */
+static void subtypeAttrDestroy(struct subtype_attr_t* head)
+{
+  if (head == NULL) return;
+  subtypeAttrDestroy(head->next);
+  Free(head);
+  head = NULL; 
+}
+
+
+/* Find an attribute in linked list by its key or return NULL
+   otherwise. */
+static struct subtype_attr_t* subtypeAttrFind(struct subtype_attr_t* head, int key)
+{
+  if (head == NULL) 
+    return NULL;
+  else if (head->key == key)
+    return head;
+  else
+    return subtypeAttrFind(head->next, key);
+}
+
+
+/* Recursively compares two subtype attribute lists under the implicit
+   assumptions that both lists are ordered by their keys and that keys
+   are unique. */
+static int subtypeAttsCompare(struct subtype_attr_t *a1, struct subtype_attr_t *a2)
+{
+  if ((a1 == NULL) && (a2 == NULL)) 
+    return 0;
+  else if ((a1 == NULL) && (a2 != NULL)) 
+    {
+      return differ;
+    }
+  else if ((a1 != NULL) && (a2 == NULL)) 
+    {
+      return differ;
+    }
+
+  if (a1->key != a2->key) 
+    {
+      return differ;
+    }
+  if (a1->val != a2->val)
+    return differ;
+    
+  return subtypeAttsCompare(a1->next, a2->next);
+}
+
+
+/* (Recursively) duplicate linked list of attributes. */
+static void subtypeAttsDuplicate(struct subtype_attr_t *a1, struct subtype_entry_t* dst)
+{
+  if (a1 == NULL)  return;
+  /* duplicate "a1->key", "a1->val" */
+  subtypeAttsDuplicate(a1->next, dst);
+  (void) subtypeAttrInsert(dst, a1->key, a1->val);
+}
+
+
+
+/* ------------------------------------------------------------------- */
+/* SUBROUTINES FOR LIST OF ENTRIES				       */
+/* ------------------------------------------------------------------- */
+
+
+/*
+  @Function  subtypeEntryNewList
+  @Title     Create new linked list of subtype entries.
+  @EndFunction
+*/
+static struct subtype_entry_t* subtypeEntryNewList(subtype_t* head)
+{
+  struct subtype_entry_t *ptr = (struct subtype_entry_t*) Malloc(sizeof(struct subtype_entry_t));
+  if(NULL == ptr)  Error("Node creation failed");
+  ptr->atts      = NULL;
+  ptr->next      = NULL;
+  head->entries  = ptr;
+  head->nentries = 0;
+  ptr->self      = head->nentries++;
+  return ptr;
+}
+
+
+/*
+  @Function  subtypeEntryInsert
+
+  @Title Add subtype entry to the head of a linked list.
+  @EndFunction
+*/
+struct subtype_entry_t* subtypeEntryInsert(subtype_t* head)
+{
+  if (head == NULL)  Error("Internal error!");
+  if (head->entries == NULL)  return (subtypeEntryNewList(head));
+
+  /* create new entry */
+  struct subtype_entry_t* ptr = (struct subtype_entry_t*) Malloc(sizeof(struct subtype_entry_t));
+  if(NULL == ptr)    Error("Node creation failed");
+
+  ptr->atts     = NULL;
+  ptr->self     = head->nentries++;
+
+  /* find the right place for insertion: */
+  if (head->entries->self >= ptr->self) {
+    /* insert at position 0 */
+    ptr->next     = head->entries;
+    head->entries = ptr;
+  } else {
+    struct subtype_entry_t** predec = &head->entries;
+    while (((*predec)->next != NULL) && ((*predec)->next->self < ptr->self)) {
+      predec = &((*predec)->next);
+    }
+    ptr->next = (*predec)->next;
+    (*predec)->next = ptr;  
+  }
+  return ptr;
+}
+
+
+/*
+  @Function  subtypeEntryAppend
+
+  @Title Append subtype entry to the end of a linked list.
+  @EndFunction
+*/
+static struct subtype_entry_t* subtypeEntryAppend(subtype_t* head)
+{
+  if (head == NULL)  Error("Internal error!");
+  if (head->entries == NULL)  return (subtypeEntryNewList(head));
+
+  /* create new entry */
+  struct subtype_entry_t* ptr = (struct subtype_entry_t*) Malloc(sizeof(struct subtype_entry_t));
+  if(NULL == ptr)    Error("Node creation failed");
+
+  ptr->atts     = NULL;
+  ptr->next     = NULL;
+  ptr->self     = head->nentries++;
+
+  /* find last position of linked list */
+  struct subtype_entry_t* prec_ptr = head->entries;
+  while (prec_ptr->next != NULL)
+    prec_ptr = prec_ptr->next;
+
+  prec_ptr->next  = ptr;
+  return ptr;
+}
+
+
+/* Recursively free a list of subtype entries. */
+static void subtypeEntryDestroy(struct subtype_entry_t *entry)
+{
+  if (entry == NULL) return;
+  subtypeEntryDestroy(entry->next);
+  subtypeAttrDestroy(entry->atts);
+  Free(entry);
+  entry = NULL;
+}
+
+
+/* Compares two subtype entries. */
+static int subtypeEntryCompare(struct subtype_entry_t *e1, struct subtype_entry_t *e2)
+{
+  if (e1 == NULL)  Error("Internal error!");
+  if (e2 == NULL)  Error("Internal error!");
+  return 
+    (e1->self == e2->self) && 
+    subtypeAttsCompare(e1->atts, e2->atts);
+}
+
+
+/* (Recursively) duplicate list of entries. */
+static void subtypeEntryDuplicate(struct subtype_entry_t *a1, subtype_t* dst)
+{
+  if (a1 == NULL) return;
+  /* append entry to dst pointer */
+  struct subtype_entry_t *ptr = subtypeEntryAppend(dst);
+  /* duplicate attributes */
+  subtypeAttsDuplicate(a1->atts, ptr);
+  ptr->self = a1->self;
+  /* call next link in linked list */
+  subtypeEntryDuplicate(a1->next, dst);
+}
+
+
+
+/* ------------------------------------------------------------------- */
+/* SUBROUTINES FOR THE SUBTYPE ITSELF				       */
+/* ------------------------------------------------------------------- */
+
+/* Print-out subtype data structure together with its attributes. */
+static void subtypePrintKernel(subtype_t *subtype_ptr, FILE *fp)
+{
+  if (subtype_ptr == NULL)  Error("Internal error!");
+  fprintf(fp, "# %s (subtype ID %d)\n", subtypeName[subtype_ptr->subtype], subtype_ptr->self);
+  /* print global attributes of this subtype */
+  struct subtype_attr_t* ptr = subtype_ptr->globals.atts;
+  if (ptr != NULL)  fprintf(fp, "#\n# global attributes:\n");
+  while (ptr != NULL) {
+    fprintf(fp, "#   %-40s   (%2d) : %d\n", cdiSubtypeAttributeName[ptr->key], ptr->key, ptr->val);    
+    ptr = ptr->next;
+  } 
+  /* print attributes for each subtype */
+  fprintf(fp, "# %d local entries:\n", subtype_ptr->nentries);
+  struct subtype_entry_t *entry = subtype_ptr->entries;
+  while (entry != NULL) {
+    fprintf(fp, "# subtype entry %d\n", entry->self);
+    ptr = entry->atts;
+    if (ptr != NULL)  fprintf(fp, "#   attributes:\n");
+    while (ptr != NULL) {
+      fprintf(fp, "#     %-40s (%2d) : %d\n", cdiSubtypeAttributeName[ptr->key], ptr->key, ptr->val);    
+      ptr = ptr->next;
+    } 
+    entry = entry->next;
+  }
+  fprintf(fp, "\n");
+}
+
+
+/* Compares two subtype data structures. Pointer version of this
+   method. */
+static int subtypeCompareP(subtype_t *s1, subtype_t *s2)
+{
+  xassert(s1 && s2);
+  if (s1->subtype != s2->subtype) return differ;
+  if (subtypeEntryCompare(&s1->globals, &s2->globals) != 0) return differ;
+
+  struct subtype_entry_t *entry1 = s1->entries;
+  struct subtype_entry_t *entry2 = s2->entries;
+  while ((entry1 != NULL) && (entry2 != NULL)) {
+    if (subtypeEntryCompare(entry1, entry2) != 0)  return differ;
+    entry1 = entry1->next;
+    entry2 = entry2->next;
+  }
+  /* compare list lengths: */
+  if ((entry1 != NULL) || (entry2 != NULL))  return differ;
+  return 0;
+}
+
+
+/* Clean up data structure. */
+static void subtypeDestroyP(void *ptr)
+{
+  subtype_t *subtype_ptr = (subtype_t*) ptr;
+  /* destroy global attributes */
+  subtypeAttrDestroy(subtype_ptr->globals.atts);
+  /* destroy list of subtype entries */
+  subtypeEntryDestroy(subtype_ptr->entries);
+  subtype_ptr->entries = NULL;
+  Free(subtype_ptr);
+  subtype_ptr = NULL;
+}
+
+
+/* Non-static wrapper function for "subtypeDestroyP". */
+void subtypeDestroyPtr(void *ptr)
+{
+  subtypeDestroyP(ptr);
+}
+
+
+/* Non-static wrapper function for "subtypeCompareP". */
+int subtypeComparePtr(int s1_ID, subtype_t *s2)
+{
+  subtype_t *subtype_ptr = (subtype_t *)reshGetVal(s1_ID, &subtypeOps);
+  if (subtype_ptr == NULL)  Error("Internal error");
+  return subtypeCompareP(subtype_ptr,s2);
+}
+
+
+/* Print-out subtype data structure together with its attributes.
+   Pointer version of this method. */
+static void subtypePrintP(void * subtype_ptr, FILE * fp)
+{  subtypePrintKernel((subtype_t *)subtype_ptr, fp); }
+
+
+
+/* Print-out subtype data structure together with its attributes. */
+void subtypePrintPtr(subtype_t* subtype_ptr)
+{
+  subtypePrintKernel(subtype_ptr, stdout);
+}
+
+
+/* Fill subtype data structure with default values. */
+static void subtypeDefaultValue(subtype_t *subtype_ptr)
+{
+  if (subtype_ptr == NULL)  Error("Internal error!");
+  subtype_ptr->self                 = CDI_UNDEFID;
+  subtype_ptr->nentries             = 0;
+  subtype_ptr->entries              = NULL;
+  subtype_ptr->globals.atts         = NULL;
+  subtype_ptr->globals.next         = NULL;
+  subtype_ptr->globals.self         = -1;
+  subtype_ptr->active_subtype_index = 0;
+}
+
+
+void subtypeAllocate(subtype_t **subtype_ptr2, int subtype)
+{
+  /* allocate new subtype */
+  (*subtype_ptr2) = (subtype_t *) Malloc(sizeof(subtype_t));
+  subtype_t* subtype_ptr = *subtype_ptr2;
+  subtypeDefaultValue(subtype_ptr);
+  subtype_ptr->subtype = subtype;
+  subtype_ptr->self    = CDI_UNDEFID;
+}
+
+
+/* Create a copy of an existing subtype data structure. */
+void subtypeDuplicate(subtype_t *subtype_ptr, subtype_t **dst_ptr)
+{
+  if (subtype_ptr == NULL)  Error("Internal error!");
+  subtypeAllocate(dst_ptr, subtype_ptr->subtype);
+  subtype_t *dst = (*dst_ptr);
+  /* create duplicate of subtype globals */
+  subtypeAttsDuplicate(subtype_ptr->globals.atts, &dst->globals);
+  dst->globals.self = subtype_ptr->globals.self;
+  /* create duplicate of subtype entries */
+  subtypeEntryDuplicate( subtype_ptr->entries, dst);
+}
+
+
+/* Register subtype object at resource handler. */
+int subtypePush(subtype_t *subtype_ptr)
+{
+  if (subtype_ptr == NULL)  Error("Internal error!");
+  subtype_ptr->self = reshPut(subtype_ptr, &subtypeOps);
+  return subtype_ptr->self; /* subtypeID */
+}
+
+
+
+/* Sets an attribute for a subtype (for example a set of TILES). If
+   the attribute has already been defined, then its value is
+   overwritten. */
+void subtypeDefGlobalDataP(subtype_t *subtype_ptr, int key, int val)
+{
+  if (subtype_ptr == NULL)  Error("Internal error!");
+  /* find entry in linked list or append otherwise */
+  struct subtype_attr_t* att_ptr = subtypeAttrFind(subtype_ptr->globals.atts, key);
+  if (att_ptr == NULL) 
+    subtypeAttrInsert(&subtype_ptr->globals, key, val);
+  else
+    att_ptr->val = val;
+}
+
+
+/* Sets an attribute for a subtype (for example a set of TILES). If
+   the attribute has already been defined, then its value is
+   overwritten. */
+void subtypeDefGlobalData(int subtypeID, int key, int val)
+{
+  subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
+  subtypeDefGlobalDataP(subtype_ptr, key, val);
+}
+
+
+/* Retrieves an attribute for a subtype (for example a set of TILES).
+   If the attribute has not been defined, then return -1. */
+int subtypeGetGlobalDataP(subtype_t *subtype_ptr, int key)
+{
+  if (subtype_ptr == NULL)  Error("Internal error!");
+  /* find entry in linked list */
+  struct subtype_attr_t* att_ptr = subtypeAttrFind(subtype_ptr->globals.atts, key);
+  if (att_ptr == NULL) 
+    return -1;
+  else
+    return att_ptr->val;
+}
+
+
+/* Retrieves an attribute for a subtype (for example a set of TILES) .
+   If the attribute has not been defined, then return -1. */
+int subtypeGetGlobalData(int subtypeID, int key)
+{
+  subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
+  return subtypeGetGlobalDataP(subtype_ptr, key);
+}
+
+
+/* Sets an attribute for a single subtype entry (e.g. a single TILE).
+   If the attribute has already been defined, then its value is
+   overwritten. */
+void subtypeDefEntryDataP(struct subtype_entry_t *subtype_entry_ptr, int key, int val)
+{
+  if (subtype_entry_ptr == NULL)  Error("Internal error!");
+  /* find entry in linked list or append otherwise */
+  struct subtype_attr_t* att_ptr = subtypeAttrFind(subtype_entry_ptr->atts, key);
+  if (att_ptr == NULL) 
+    subtypeAttrInsert(subtype_entry_ptr, key, val);
+  else
+    att_ptr->val = val;
+}
+
+
+
+/* ------------------------------------------------------------------- */
+/* IMPLEMENTATIONS FOR KEY-VALUE-PAIR QUERIES			       */
+/* ------------------------------------------------------------------- */
+
+
+/* Generate a "query object" out of a key-value pair. */
+subtype_query_t keyValuePair(const char* key, int value)
+{
+  subtype_query_t result;
+  result.nAND = 1;
+  result.key_value_pairs[0][0] = attribute_to_index(key);
+  result.key_value_pairs[1][0] = value;
+  if (CDI_Debug) {
+    Message("key  %s matches %d", key, result.key_value_pairs[0][0]);
+    Message("%d --?-- %d", result.key_value_pairs[0][0], result.key_value_pairs[1][0]);
+  }
+  return result;
+}
+
+
+/* Generate an AND-combined "query object" out of two previous query
+   objects. */
+subtype_query_t matchAND(subtype_query_t q1, subtype_query_t q2)
+{
+  if ((q1.nAND + q2.nAND) > MAX_KV_PAIRS_MATCH)  Error("Internal error");
+  subtype_query_t result;
+  result.nAND = q1.nAND;
+  for (int i=0; i<q1.nAND; i++)
+    {
+      result.key_value_pairs[0][i] = q1.key_value_pairs[0][i];
+      result.key_value_pairs[1][i] = q1.key_value_pairs[1][i];
+    }
+  for (int i=0; i<q2.nAND; i++)
+    {
+      result.key_value_pairs[0][result.nAND] = q2.key_value_pairs[0][i];
+      result.key_value_pairs[1][result.nAND] = q2.key_value_pairs[1][i];
+      result.nAND++;
+    }
+
+  if (CDI_Debug) {
+    Message("combined criterion:");
+    for (int i=0; i<result.nAND; i++)
+      Message("%d --?-- %d", result.key_value_pairs[0][i], result.key_value_pairs[1][i]);
+  }
+  return result;
+}
+
+
+
+/* ------------------------------------------------------------------- */
+/* SPECIFIC IMPLEMENTATIONS FOR TILE SETS			       */
+/* ------------------------------------------------------------------- */
+
+
+/* Integrate tile set "s2" into the tile set "subtype1_ID":
+
+   Insert all entries set 2 to set 1 together with its attributes.
+*/
+void tilesetInsertP(subtype_t *s1, subtype_t *s2)
+{
+  if (s1 == NULL)  Error("Internal error!");
+  if (s2 == NULL)  Error("Internal error!");
+  struct subtype_entry_t 
+    *entry1 = s1->entries,
+    *entry2 = s2->entries;
+  struct subtype_attr_t *att_ptr2;
+
+  /* test all entries of set 2 against set 1, to check if entry
+     already exists: */
+  if (subtypeAttsCompare(s1->globals.atts, s2->globals.atts) != differ) 
+    {
+      while (entry1 != NULL) {
+	int found = 1;
+	entry2 = s2->entries;
+	while (entry2 != NULL) {
+	  found &= (subtypeAttsCompare(entry1->atts, entry2->atts) != differ);
+	  entry2 = entry2->next;
+	}
+	if (found) 
+	  {
+	    return;
+	  }
+	entry1 = entry1->next;
+      }
+    
+      entry2 = s2->entries;
+      while (entry2 != NULL) {
+	entry1 = subtypeEntryInsert(s1);
+	
+	att_ptr2 = entry2->atts;
+	while (att_ptr2 != NULL) {
+	  (void) subtypeAttrInsert(entry1, att_ptr2->key, att_ptr2->val);
+	  att_ptr2 = att_ptr2->next;
+	}
+	entry2 = entry2->next;
+      }
+    }
+  else
+    {
+      fprintf(stderr, "\n# SUBTYPE A:\n");
+      subtypePrintKernel(s1, stderr);
+      fprintf(stderr, "\n# SUBTYPE B:\n");
+      subtypePrintKernel(s2, stderr);
+      Error("Attempting to insert subtype entry into subtype with different global attributes!");
+    }
+}
+
+
+
+/* ------------------------------------------------------------------- */
+/* IMPLEMENTATIONS FOR ROUTINES VISIBLE THROUGH CDI.H		       */
+/* ------------------------------------------------------------------- */
+
+
+/*
+  @Function  subtypeCreate
+  @Title     Create a variable subtype
+  
+  @Prototype int subtypeCreate(int subtype)
+  @Parameter
+  @Item  subtype  The type of the variable subtype, one of the set of predefined CDI variable subtypes.
+  The valid CDI variable subtypes are @func{SUBTYPE_TILES}
+  
+  @Description
+  The function @func{subtypeCreate} creates a variable subtype.
+  
+  @Result
+  @func{subtypeCreate} returns an identifier to the variable subtype.
+  
+  @EndFunction
+*/
+int subtypeCreate(int subtype)
+{
+  if ( CDI_Debug )  Message("subtype: %d ", subtype);
+  Message("subtype: %d ", subtype);
+
+  /* allocate new subtype */
+  subtype_t *subtype_ptr;
+  subtypeAllocate(&subtype_ptr, subtype);
+  /* register object at resource handler */
+  return subtypePush(subtype_ptr);
+}
+
+
+/* Print-out subtype data structure together with its attributes. */
+void subtypePrint(int subtypeID)
+{
+  subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
+  subtypePrintKernel(subtype_ptr, stdout);
+}
+
+
+/* Compares two subtype data structures. */
+int subtypeCompare(int subtypeID1, int subtypeID2)
+{
+  subtype_t *subtype_ptr1 = (subtype_t *)reshGetVal(subtypeID1, &subtypeOps);
+  subtype_t *subtype_ptr2 = (subtype_t *)reshGetVal(subtypeID2, &subtypeOps);
+  return subtypeCompareP(subtype_ptr1,subtype_ptr2);
+}
+
+
+/*  Get the size of a subtype (e.g. no. of tiles). */
+int subtypeInqSize(int subtypeID)
+{
+  if ( subtypeID == CDI_UNDEFID )
+    {
+      return 0;
+    }
+  else
+    {
+      subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
+      return subtype_ptr->nentries;
+    }
+}
+
+
+/* Get the currently active index of a subtype (e.g. current tile index). */
+int subtypeInqActiveIndex(int subtypeID)
+{
+  if (subtypeID == CDI_UNDEFID)  return 0;
+  subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
+  return subtype_ptr->active_subtype_index;
+}
+
+
+/* Set the currently active index of a subtype (e.g. current tile index). */
+void subtypeDefActiveIndex(int subtypeID, int index)
+{
+  subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
+  subtype_ptr->active_subtype_index = index;
+}
+
+
+/* subtypeInqSubEntry: Returns subtype entry ID for a given
+   criterion. */
+int subtypeInqSubEntry(int subtypeID, subtype_query_t criterion)
+{
+  subtype_t *subtype_ptr = (subtype_t *)reshGetVal(subtypeID, &subtypeOps);
+  struct subtype_entry_t *entry = subtype_ptr->entries;
+  /* loop over all entries of this subtype */
+  while (entry != NULL) {
+    {
+      int match = 1;
+      /* test if this entry matches ALL criteria. */
+      for (int j=0; (j<criterion.nAND) && (match); j++)
+	{
+	  if (CDI_Debug)  Message("check criterion %d :  %d --?-- %d", j,
+				  criterion.key_value_pairs[0][j], criterion.key_value_pairs[1][j]);
+	  struct subtype_attr_t* att_ptr = 
+	    subtypeAttrFind(entry->atts, criterion.key_value_pairs[0][j]);
+	  if (att_ptr == NULL)
+	    {
+	      match = 0;
+	      if (CDI_Debug)  Message("did not find %d", criterion.key_value_pairs[0][j]);
+	    }
+	  else
+	    {
+	      if (CDI_Debug)  Message("found %d", criterion.key_value_pairs[0][j]);
+	      match &= (att_ptr->val == criterion.key_value_pairs[1][j]);
+	    }
+	}
+      if (match) return entry->self;
+    }
+    entry = entry->next;
+  }
+  return CDI_UNDEFID;
+}
+
+
+int subtypeInqTile(int subtypeID, int tileindex, int attribute)
+{
+  return subtypeInqSubEntry(subtypeID, 
+			    matchAND(keyValuePair(cdiSubtypeAttributeName[SUBTYPE_ATT_TILEINDEX], tileindex),
+				     keyValuePair(cdiSubtypeAttributeName[SUBTYPE_ATT_TILEATTRIBUTE], attribute)));
+}
+
+
+/* Construct a new subtype for a tile set. If a corresponding subtype
+ * already exists, then we return this subtype ID instead. 
+ *
+ * See comment on subtype.c::tilesetMatchingPtr for the specification
+ * of the term "corresponding" tile set.
+ */
+int vlistDefTileSubtype(int vlistID, subtype_t *tiles)
+{
+  int subtypeID = CDI_UNDEFID;
+
+  /* loop over subtypes and search for an identical tileset */
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+  int      tileset_defined = 0;
+  for (int isub=0; isub<vlistptr->nsubtypes; isub++)
+    {
+      /* get the ID of the "isub"th subtype */
+      subtypeID = vlistptr->subtypeIDs[isub];
+      if (subtypeComparePtr(subtypeID, tiles) == 0)
+        {
+          tileset_defined = 1;
+          break;
+        }
+    }
+
+  /* tile set seems to be new: register at resource handler. */
+  if (tileset_defined == 0)  {
+    subtype_t *tiles_duplicate = NULL;
+    subtypeDuplicate(tiles, &tiles_duplicate);
+    subtypeID = vlistptr->subtypeIDs[vlistptr->nsubtypes++] = subtypePush(tiles_duplicate);
+  }
+
+  return subtypeID;
+}
+
+
+
+int vlistInsertTrivialTileSubtype(int vlistID)
+{
+  /* first, generate a subtype */
+  subtype_t *subtype_ptr;
+  subtypeAllocate(&subtype_ptr, SUBTYPE_TILES);
+
+  /* create a tile set that contains only one tile/attribute pair. */
+  (void) subtypeEntryInsert(subtype_ptr);
+
+  /* register tile */
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+  int subtypeID = vlistptr->subtypeIDs[vlistptr->nsubtypes++] = subtypePush(subtype_ptr);
+  return subtypeID;
+}
+
+
+
+
+/* ------------------------------------------------------------------- */
+/* NOT YET IMPLEMENTED						       */
+/* ------------------------------------------------------------------- */
+
+static int subtypeGetPackSize( void * subtype_ptr, void *context)
+{
+  (void)subtype_ptr; (void)context;
+  Error("Not yet implemented for subtypes!");
+  return 0;
+}
+
+static void subtypePack( void * subtype_ptr, void * buffer, int size, int *pos, void *context)
+{
+  (void)subtype_ptr; (void)buffer; (void)size; (void)pos; (void)context;
+  Error("Not yet implemented for subtypes!");
+}
+
+static int subtypeTxCode( void )
+{  Error("Not yet implemented for subtypes!");  return 0; }
+
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/subtype.h b/libcdi/src/subtype.h
new file mode 100644
index 0000000..db938c3
--- /dev/null
+++ b/libcdi/src/subtype.h
@@ -0,0 +1,105 @@
+#ifndef _SUBTYPE_H
+#define _SUBTYPE_H
+
+
+enum {
+  /* subtype attributes wrt. TILES */
+  SUBTYPE_ATT_TILEINDEX                 = 0,
+  SUBTYPE_ATT_TOTALNO_OF_TILEATTR_PAIRS = 1,
+  SUBTYPE_ATT_TILE_CLASSIFICATION       = 2,
+  SUBTYPE_ATT_NUMBER_OF_TILES           = 3,
+  SUBTYPE_ATT_NUMBER_OF_ATTR            = 4,
+  SUBTYPE_ATT_TILEATTRIBUTE             = 5,
+/* No. of different constants in the enumeration
+   "subtype_attributes" */
+  nSubtypeAttributes
+};
+
+
+/* Literal constants corresponding to the different constants of the
+   enumeration "subtype_attributes". */
+extern const char * const cdiSubtypeAttributeName[];
+
+/* Data type specifying an attribute of a subtype (for example an
+   attribute of a set of TILES) or an attribute of a subtype entry
+   (for example an attribute of a single TILE). This data type is part
+   of a linked list. */
+struct subtype_attr_t {
+  int   key, val;                                /* key/value pair */
+  struct subtype_attr_t* next;                   /* next element in linked list */
+};
+
+
+/* Data type specifying a single entry of a subtype, for example a
+   single TILE in a set of TILES. */
+struct subtype_entry_t {
+  int                     self;                  /* list entry index (0,...,nentries-1) */
+  struct subtype_entry_t *next;                  /* next node in linked list */
+
+  /* linked list with attributes for this subtype entry, ordered by its key values*/
+  struct subtype_attr_t  *atts;
+};
+
+
+/* Data type specifying a variable subtype, for example a list of
+   TILES. This can be interpreted as an additional axis like the
+   vertical axis. */
+typedef struct  {
+  int                     self;                  /* resource handler ID */
+  int                     subtype;               /* subtype kind: TILES, ... */
+  int                     nentries;              /* counter: total no. of entries in list */
+
+  struct subtype_entry_t  globals;               /* global attributes */
+
+  /* list of subtype entries, e.g. the list of tiles, ordered by entry->self. */
+  struct subtype_entry_t *entries;
+  /* currently active subtype, e.g. GRIB2 tile index (for example for
+     stream/vlist accesses): */
+  int                     active_subtype_index;
+} subtype_t;
+
+
+
+
+/* prototypes: allocation and destruction */
+void  subtypeAllocate(subtype_t **subtype_ptr2, int subtype);
+int   subtypePush(subtype_t *subtype_ptr);
+void  subtypeDestroyPtr(void *ptr);
+void  subtypeDuplicate(subtype_t *subtype_ptr, subtype_t **dst);
+struct subtype_entry_t* subtypeEntryInsert(subtype_t* head);
+
+/* prototypes: accessing global attributes */
+void  subtypePrint(int subtypeID);
+void  subtypePrintPtr(subtype_t* subtype_ptr);
+void  subtypeDefGlobalDataP(subtype_t *subtype_ptr, int key, int val);
+void  subtypeDefGlobalData(int subtypeID, int key, int val);
+int   subtypeGetGlobalData(int subtypeID, int key);
+int   subtypeGetGlobalDataP(subtype_t *subtype_ptr, int key);
+int   subtypeComparePtr(int s1_ID, subtype_t *s2);
+
+/* prototypes: accessing subtype entries */
+void  subtypeDefEntryDataP(struct subtype_entry_t *subtype_entry_ptr, int key, int val);
+
+
+/* prototypes: tile implementations */
+void  tilesetInsertP(subtype_t *s1, subtype_t *s2);
+
+/* Construct a new subtype for a tile set. If a corresponding subtype
+ * already exists, then we return this subtype ID instead. */
+int vlistDefTileSubtype(int vlistID, subtype_t *tiles);
+
+/* Insert a trivial one-tile-subtype */
+int vlistInsertTrivialTileSubtype(int vlistID);
+
+
+#endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/swap.c b/libcdi/src/swap.c
index cb3259f..82c498a 100644
--- a/libcdi/src/swap.c
+++ b/libcdi/src/swap.c
@@ -5,33 +5,26 @@
 #include <inttypes.h>
 #include <stdio.h>
 
-#include "error.h"
-#include "binary.h"
+#include "swap.h"
 
 void swap4byte(void *ptr, size_t size)
 {
-  int32_t *ptrtmp = ptr;
+  int32_t *ptrtmp = (int32_t *)ptr;
 
-  if (sizeof (int32_t) == 4)
-    for (size_t i = 0; i < size; ++i)
-      ptrtmp[i] = (((ptrtmp[i] >> 24) & 0x00ff) | ((ptrtmp[i] & 0x00ff) << 24) |
-                   ((ptrtmp[i] >>  8) & 0xff00) | ((ptrtmp[i] & 0xff00) <<  8));
-  else
-    Error("not implemented for %d byte data", sizeof(int32_t));
+  for (size_t i = 0; i < size; ++i)
+    ptrtmp[i] = (((ptrtmp[i] >> 24) & 0x00ff) | ((ptrtmp[i] & 0x00ff) << 24) |
+                 ((ptrtmp[i] >>  8) & 0xff00) | ((ptrtmp[i] & 0xff00) <<  8));
 }
 
 void swap8byte(void *ptr, size_t size)
 {
-  int64_t *ptrtmp = ptr;
+  int64_t *ptrtmp = (int64_t *)ptr;
 
-  if (sizeof (int64_t) == 8)
-    for (size_t i = 0; i < size; ++i)
-      ptrtmp[i] = (((ptrtmp[i] >> 56) & 0x000000ff) | ((ptrtmp[i] & 0x000000ff) << 56) |
-                   ((ptrtmp[i] >> 40) & 0x0000ff00) | ((ptrtmp[i] & 0x0000ff00) << 40) |
-                   ((ptrtmp[i] >> 24) & 0x00ff0000) | ((ptrtmp[i] & 0x00ff0000) << 24) |
-                   ((ptrtmp[i] >>  8) & 0xff000000) | ((ptrtmp[i] & 0xff000000) <<  8));
-  else
-    Error("not implemented for %d byte data", sizeof(int64_t));
+  for (size_t i = 0; i < size; ++i)
+    ptrtmp[i] = (((ptrtmp[i] >> 56) & 0x000000ff) | ((ptrtmp[i] & 0x000000ff) << 56) |
+                 ((ptrtmp[i] >> 40) & 0x0000ff00) | ((ptrtmp[i] & 0x0000ff00) << 40) |
+                 ((ptrtmp[i] >> 24) & 0x00ff0000) | ((ptrtmp[i] & 0x00ff0000) << 24) |
+                 ((ptrtmp[i] >>  8) & 0xff000000) | ((ptrtmp[i] & 0xff000000) <<  8));
 }
 /*
  * Local Variables:
diff --git a/libcdi/src/table.c b/libcdi/src/table.c
index bd7ec02..2babc18 100644
--- a/libcdi/src/table.c
+++ b/libcdi/src/table.c
@@ -25,8 +25,8 @@
 typedef struct
 {
   int    used;
-  PAR   *pars;
   int    npars;
+  PAR   *pars;
   int    modelID;
   int    number;
   char  *name;
@@ -58,17 +58,17 @@ void tableDefEntry(int tableID, int id, const char *name,
   parTable[tableID].pars[item].longname = NULL;
   parTable[tableID].pars[item].units    = NULL;
 
-  if ( name && strlen(name) > 0 )
+  if ( name && name[0] )
     {
       parTable[tableID].pars[item].name     = strdupx(name);
       parTable[tableID].pars[item].dupflags |= TABLE_DUP_NAME;
     }
-  if ( longname && strlen(longname) > 0 )
+  if ( longname && longname[0] )
     {
       parTable[tableID].pars[item].longname = strdupx(longname);
       parTable[tableID].pars[item].dupflags |= TABLE_DUP_LONGNAME;
     }
-  if ( units && strlen(units) > 0 )
+  if ( units && units[0] )
     {
       parTable[tableID].pars[item].units    = strdupx(units);
       parTable[tableID].pars[item].dupflags |= TABLE_DUP_UNITS;
@@ -122,14 +122,14 @@ static void parTableFinalize(void)
         for (int item = 0; item < npars; ++item)
           {
             if (parTable[tableID].pars[item].dupflags & TABLE_DUP_NAME)
-              free((void *)parTable[tableID].pars[item].name);
+              Free((void *)parTable[tableID].pars[item].name);
             if (parTable[tableID].pars[item].dupflags & TABLE_DUP_LONGNAME)
-              free((void *)parTable[tableID].pars[item].longname);
+              Free((void *)parTable[tableID].pars[item].longname);
             if (parTable[tableID].pars[item].dupflags & TABLE_DUP_UNITS)
-              free((void *)parTable[tableID].pars[item].units);
+              Free((void *)parTable[tableID].pars[item].units);
           }
-        free(parTable[tableID].pars);
-        free(parTable[tableID].name);
+        Free(parTable[tableID].pars);
+        Free(parTable[tableID].name);
       }
 }
 
@@ -193,8 +193,7 @@ decodeForm1(char *pline, char *name, char *longname, char *units)
   else
     return (0);
 
-  len = strlen(pline);
-  if ( len == 0 ) return (0);
+  if ( pline[0] == 0 ) return (0);
 
   /* Format 1 : code name add mult longname [units] */
   /* FIXME: successful parse isn't verified */
@@ -251,7 +250,6 @@ decodeForm2(char *pline, char *name, char *longname, char *units)
 {
   /* Format 2 : code | name | longname | units */
   char *pend;
-  size_t len;
 
   pline = strchr(pline, '|');
   pline++;
@@ -264,7 +262,7 @@ decodeForm2(char *pline, char *name, char *longname, char *units)
         {
           pend = pline;
           while ( ! isspace((int) *pend) ) pend++;
-          len = (size_t)(pend - pline);
+          size_t len = (size_t)(pend - pline);
           if ( len > 0 )
             {
               memcpy(name, pline, len);
@@ -276,7 +274,7 @@ decodeForm2(char *pline, char *name, char *longname, char *units)
         {
           pend--;
           while ( isspace((int) *pend) ) pend--;
-          len = (size_t)(pend - pline + 1);
+          size_t len = (size_t)(pend - pline + 1);
           if ( len > 0 )
             {
               memcpy(name, pline, len);
@@ -294,12 +292,14 @@ decodeForm2(char *pline, char *name, char *longname, char *units)
   if ( !pend ) pend = strchr(pline, 0);
   pend--;
   while ( isspace((int) *pend) ) pend--;
-  len = (size_t)(pend - pline + 1);
-  if ( len > 0 )
-    {
-      memcpy(longname, pline, len);
-      longname[len] = 0;
-    }
+  {
+    size_t len = (size_t)(pend - pline + 1);
+    if ( len > 0 )
+      {
+        memcpy(longname, pline, len);
+        longname[len] = 0;
+      }
+  }
 
   pline = strchr(pline, '|');
   if ( pline )
@@ -333,7 +333,7 @@ int tableRead(const char *tablefile)
   tablefp = fopen(tablefile, "r");
   if ( tablefp == NULL ) return (tableID);
 
-  tablename = strrchr(tablefile, '/');
+  tablename = (char* )strrchr(tablefile, '/');
   if ( tablename == 0 ) tablename = (char *) tablefile;
   else                  tablename++;
 
@@ -369,7 +369,7 @@ int tableRead(const char *tablefile)
 
       if ( err ) continue;
 
-      if ( strlen(name) == 0 ) sprintf(name, "var%d", id);
+      if ( name[0] ) sprintf(name, "var%d", id);
 
       tableDefEntry(tableID, id, name, longname, units);
     }
@@ -422,7 +422,7 @@ static int tableFromEnv(int modelID, int tablenum)
       lenf = strlen(tablename);
       /* if (tablePath) printf("tablePath = %s\n", tablePath); */
       /* if (tablename) printf("tableName = %s\n", tablename); */
-      tablefile = (char *) malloc(lenp+lenf+3);
+      tablefile = (char *) Malloc(lenp+lenf+3);
       if ( tablePath )
 	{
 	  strcpy(tablefile, tablePath);
@@ -441,7 +441,7 @@ static int tableFromEnv(int modelID, int tablenum)
 	}
       /* printf("tableID = %d %s\n", tableID, tablefile); */
 
-      free(tablefile);
+      Free(tablefile);
     }
 
   return (tableID);
@@ -545,7 +545,7 @@ int tableDef(int modelID, int tablenum, const char *tablename)
       if ( tablename )
 	parTable[tableID].name = strdupx(tablename);
 
-      parTable[tableID].pars = (PAR *) malloc(MAX_PARS * sizeof(PAR));
+      parTable[tableID].pars = (PAR *) Malloc(MAX_PARS * sizeof(PAR));
     }
 
   return (tableID);
@@ -821,7 +821,7 @@ int tableInqParName(int tableID, int code, char *varname)
 {
   int err = 1;
 
-  if ( tableID != UNDEFID )
+  if ( tableID >= 0 && tableID < MAX_TABLE )
     {
       int npars = parTable[tableID].npars;
       for ( int item = 0; item < npars; item++ )
@@ -835,6 +835,10 @@ int tableInqParName(int tableID, int code, char *varname)
 	    }
 	}
     }
+  else if ( tableID == UNDEFID )
+    { }
+  else
+    Error("Invalid table ID %d", tableID);
 
   return (err);
 }
diff --git a/libcdi/src/table.h b/libcdi/src/table.h
index f7f5f14..faebeff 100644
--- a/libcdi/src/table.h
+++ b/libcdi/src/table.h
@@ -1224,8 +1224,7 @@ static const PAR cosmo250[] = {
 };
 
 
-static void
-tableDefault(void)
+static void tableDefault(void)
 {
   int tableID, instID, modelID;
 
@@ -1424,3 +1423,12 @@ tableDefault(void)
 }
 
 #endif  /* _TABLE_H */
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/taxis.c b/libcdi/src/taxis.c
index f1ac7ed..20167ae 100644
--- a/libcdi/src/taxis.c
+++ b/libcdi/src/taxis.c
@@ -5,26 +5,23 @@
 #include <stddef.h>
 #include <string.h>
 
-#include "dmemory.h"
-
 #include "cdi.h"
+#include "calendar.h"
+#include "dmemory.h"
 #include "error.h"
 #include "taxis.h"
 #include "cdi_cksum.h"
 #include "cdi_int.h"
-#include "calendar.h"
 #include "namespace.h"
 #include "serialize.h"
 #include "resource_handle.h"
 #include "resource_unpack.h"
 
-extern int cdiDefaultCalendar;
-
 static int DefaultTimeType = TAXIS_ABSOLUTE;
 static int DefaultTimeUnit = TUNIT_HOUR;
 
 
-const char *Timeunits[] = {
+static const char *Timeunits[] = {
   "undefined",
   "seconds",
   "minutes",
@@ -58,7 +55,7 @@ const resOps taxisOps = {
 };
 
 #define container_of(ptr, type, member) \
-  ((type *)((unsigned char *)ptr - offsetof(type,member)))
+  ((type *)(void*)((unsigned char *)ptr - offsetof(type,member)))
 
 struct refcount_string
 {
@@ -70,7 +67,7 @@ static char *
 new_refcount_string(size_t len)
 {
   struct refcount_string *container
-    = xmalloc(sizeof (*container) + len + 1);
+    = (struct refcount_string *) Malloc(sizeof (*container) + len + 1);
   container->ref_count = 1;
   return container->string;
 }
@@ -83,7 +80,7 @@ delete_refcount_string(void *p)
       struct refcount_string *container
         = container_of(p, struct refcount_string, string);
       if (!--(container->ref_count))
-        free(container);
+        Free(container);
     }
 }
 
@@ -179,7 +176,7 @@ void taxisDefaultValue(taxis_t* taxisptr)
 static taxis_t *
 taxisNewEntry(cdiResH resH)
 {
-  taxis_t *taxisptr = (taxis_t*) xmalloc(sizeof(taxis_t));
+  taxis_t *taxisptr = (taxis_t*) Malloc(sizeof(taxis_t));
 
   taxisDefaultValue(taxisptr);
   if (resH == CDI_UNDEFID)
@@ -269,11 +266,8 @@ int taxisCreate(int taxistype)
 
 void taxisDestroyKernel(taxis_t *taxisptr)
 {
-  int id = taxisptr->self;
   delete_refcount_string(taxisptr->name);
   delete_refcount_string(taxisptr->longname);
-  if (id != CDI_UNDEFID)
-    reshRemove(id, &taxisOps);
 }
 
 /*
@@ -289,15 +283,16 @@ void taxisDestroyKernel(taxis_t *taxisptr)
 void taxisDestroy(int taxisID)
 {
   taxis_t *taxisptr = (taxis_t *)reshGetVal(taxisID, &taxisOps);
+  reshRemove(taxisID, &taxisOps);
   taxisDestroyKernel(taxisptr);
-  free(taxisptr);
+  Free(taxisptr);
 }
 
 
 void taxisDestroyP( void * taxisptr )
 {
   taxisDestroyKernel((taxis_t *)taxisptr);
-  free(taxisptr);
+  Free(taxisptr);
 }
 
 
@@ -920,7 +915,8 @@ ptaxisDefLongname(taxis_t *taxisptr, const char *longname)
 }
 
 
-void cdiDecodeTimevalue(int timeunit, double timevalue, int *days, int *secs)
+static void
+cdiDecodeTimevalue(int timeunit, double timevalue, int *days, int *secs)
 {
   static int lwarn = TRUE;
 
@@ -942,7 +938,7 @@ void cdiDecodeTimevalue(int timeunit, double timevalue, int *days, int *secs)
     {
       *days = (int) (timevalue/86400);
       double seconds = timevalue - *days*86400.;
-      *secs = lround(seconds);
+      *secs = (int)lround(seconds);
       if ( *secs < 0 ) { *days -= 1; *secs += 86400; };
       /*
       {
@@ -956,7 +952,7 @@ void cdiDecodeTimevalue(int timeunit, double timevalue, int *days, int *secs)
     {
       *days = (int) timevalue;
       double seconds = (timevalue - *days)*86400;
-      *secs = lround(seconds);
+      *secs = (int)lround(seconds);
       if ( *secs < 0 ) { *days -= 1; *secs += 86400; };
       /*
       {
@@ -1012,8 +1008,6 @@ void cdiEncodeTimevalue(int days, int secs, int timeunit, double *timevalue)
     }
 }
 
-int days_per_month(int calendar, int year, int month);
-
 void timeval2vtime(double timevalue, taxis_t *taxis, int *vdate, int *vtime)
 {
   int year, month, day, hour, minute, second;
@@ -1154,7 +1148,7 @@ double vtime2timeval(int vdate, int vtime, taxis_t *taxis)
 }
 
 
-void conv_timeval(double timevalue, int *rvdate, int *rvtime)
+static void conv_timeval(double timevalue, int *rvdate, int *rvtime)
 {
   int vdate = 0, vtime = 0;
   int hour, minute, second;
@@ -1176,7 +1170,8 @@ void conv_timeval(double timevalue, int *rvdate, int *rvtime)
 }
 
 
-void splitTimevalue(double timevalue, int timeunit, int *date, int *time)
+static void
+splitTimevalue(double timevalue, int timeunit, int *date, int *time)
 {
   int vdate = 0, vtime = 0;
   int hour, minute, second;
@@ -1199,8 +1194,7 @@ void splitTimevalue(double timevalue, int timeunit, int *date, int *time)
     }
   else if ( timeunit == TUNIT_MONTH )
     {
-      vdate = (int) timevalue*100;
-      vdate += 1;
+      vdate = (int) timevalue*100 - ((vdate < 0) * 2 - 1);
       vtime = 0;
     }
   else if ( timeunit == TUNIT_YEAR )
@@ -1345,11 +1339,13 @@ double cdiEncodeTimeval(int date, int time, taxis_t *taxis)
 	{
 	  int year, month, day;
 	  cdiDecodeDate(date, &year, &month, &day);
-	  if ( day == 0 )
-	    timevalue = date/100;
-	  else
-	    timevalue = date/100 + 0.5;
-	}
+          timevalue = date/100;
+	  if ( day != 0 )
+            {
+              if ( date < 0 ) timevalue -= 0.5;
+              else            timevalue += 0.5;
+            }
+        }
       else
 	{
 	  int hour, minute, second;
@@ -1444,7 +1440,7 @@ taxisPrintKernel(taxis_t * taxisptr, FILE * fp)
   fprintf ( fp, "\n");
 }
 
-void taxisPrint ( int taxisID )
+static void taxisPrint ( int taxisID )
 {
   taxis_t * taxisptr;
 
@@ -1530,7 +1526,7 @@ taxisUnpack(char * unpackBuffer, int unpackBufferSize, int * unpackBufferPos,
 
   xassert(!force_id || targetID == taxisP->self);
 
-  taxisP->used        = intBuffer[idx++];
+  taxisP->used        = (short)intBuffer[idx++];
   taxisP->type        = intBuffer[idx++];
   taxisP->vdate       = intBuffer[idx++];
   taxisP->vtime       = intBuffer[idx++];
@@ -1543,7 +1539,7 @@ taxisUnpack(char * unpackBuffer, int unpackBufferSize, int * unpackBufferPos,
   taxisP->fc_unit     = intBuffer[idx++];
   taxisP->numavg      = intBuffer[idx++];
   taxisP->climatology = intBuffer[idx++];
-  taxisP->has_bounds  = intBuffer[idx++];
+  taxisP->has_bounds  = (short)intBuffer[idx++];
   taxisP->vdate_lb    = intBuffer[idx++];
   taxisP->vtime_lb    = intBuffer[idx++];
   taxisP->vdate_ub    = intBuffer[idx++];
@@ -1569,6 +1565,9 @@ taxisUnpack(char * unpackBuffer, int unpackBufferSize, int * unpackBufferPos,
       taxisP->longname = longname;
     }
 
+  reshSetStatus(taxisP->self, &taxisOps,
+                reshGetStatus(taxisP->self, &taxisOps) & ~RESH_SYNC_BIT);
+
   return taxisP->self;
 }
 
diff --git a/libcdi/src/taxis.h b/libcdi/src/taxis.h
index 00f0f31..78cf402 100644
--- a/libcdi/src/taxis.h
+++ b/libcdi/src/taxis.h
@@ -9,7 +9,8 @@ typedef struct {
   /* Date format  YYYYMMDD */
   /* Time format    hhmmss */
   int     self;
-  int     used;
+  short   used;
+  short   has_bounds;
   int     type;           // time type
   int     vdate;          // verification date
   int     vtime;          // verification time
@@ -21,7 +22,6 @@ typedef struct {
   int     unit;           // time unit
   int     numavg;
   int     climatology;
-  int     has_bounds;
   int     vdate_lb;       // lower bounds of vdate
   int     vtime_lb;       // lower bounds of vtime
   int     vdate_ub;       // upper bounds of vdate
diff --git a/libcdi/src/timebase.c b/libcdi/src/timebase.c
index 03d2162..0849fda 100644
--- a/libcdi/src/timebase.c
+++ b/libcdi/src/timebase.c
@@ -343,3 +343,12 @@ int main(void)
   return (0);
 }
 #endif
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/timebase.h b/libcdi/src/timebase.h
index 716bb60..00ebf34 100644
--- a/libcdi/src/timebase.h
+++ b/libcdi/src/timebase.h
@@ -23,3 +23,13 @@ void encode_juldaysec(int calendar, int year, int month, int day, int hour, int
 void decode_juldaysec(int calendar, int julday, int secofday, int *year, int *month, int *day, int *hour, int *minute, int *second);
 
 #endif  /* _TIMEBASE_H */
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/src/tsteps.c b/libcdi/src/tsteps.c
index a4c22b6..92273ec 100644
--- a/libcdi/src/tsteps.c
+++ b/libcdi/src/tsteps.c
@@ -2,6 +2,8 @@
 #  include "config.h"
 #endif
 
+#include <limits.h>
+
 #include "dmemory.h"
 
 #include "cdi.h"
@@ -9,7 +11,7 @@
 
 
 static
-void tstepsInitEntry(stream_t *streamptr, int tsID)
+void tstepsInitEntry(stream_t *streamptr, size_t tsID)
 {
   streamptr->tsteps[tsID].curRecID     = CDI_UNDEFID;
   streamptr->tsteps[tsID].position     = 0;
@@ -26,13 +28,9 @@ void tstepsInitEntry(stream_t *streamptr, int tsID)
 
 int tstepsNewEntry(stream_t *streamptr)
 {
-  int tsID = 0;
-  int tstepsTableSize;
-  tsteps_t *tstepsTable;
-
-  tsID            = streamptr->tstepsNextID++;
-  tstepsTableSize = streamptr->tstepsTableSize;
-  tstepsTable     = streamptr->tsteps;
+  size_t tsID            = (size_t)streamptr->tstepsNextID++;
+  size_t tstepsTableSize = (size_t)streamptr->tstepsTableSize;
+  tsteps_t *tstepsTable  = streamptr->tsteps;
 
   /*
     If the table overflows, double its size.
@@ -40,24 +38,24 @@ int tstepsNewEntry(stream_t *streamptr)
   if ( tsID == tstepsTableSize )
     {
       if ( tstepsTableSize == 0 ) tstepsTableSize = 1;
-      tstepsTableSize = 2*tstepsTableSize;
-      tstepsTable = (tsteps_t *)xrealloc(tstepsTable,
-                                         (size_t)tstepsTableSize * sizeof (tsteps_t));
-      if ( tstepsTable == NULL )
-	{
-          Message("tstepsTableSize = %d", tstepsTableSize);
-	  SysError("Reallocation of tsteps_t failed");
-	}
+      if ( tstepsTableSize <= INT_MAX / 2)
+        tstepsTableSize *= 2;
+      else if ( tstepsTableSize < INT_MAX)
+        tstepsTableSize = INT_MAX;
+      else
+        Error("Resizing of tstep table failed!");
+      tstepsTable = (tsteps_t *) Realloc(tstepsTable,
+                                         tstepsTableSize * sizeof (tsteps_t));
     }
 
-  streamptr->tstepsTableSize = tstepsTableSize;
+  streamptr->tstepsTableSize = (int)tstepsTableSize;
   streamptr->tsteps          = tstepsTable;
 
   tstepsInitEntry(streamptr, tsID);
 
   streamptr->tsteps[tsID].taxis.used = TRUE;
 
-  return (tsID);
+  return (int)tsID;
 }
 
 
@@ -72,14 +70,14 @@ void cdiCreateTimesteps(stream_t *streamptr)
   if ( streamptr->ntsteps == 0 ) ntsteps = 1;    /* <<<<<-------- */
   else ntsteps = streamptr->ntsteps;
 
-  streamptr->tsteps = (tsteps_t *)xmalloc((size_t)ntsteps*sizeof(tsteps_t));
+  streamptr->tsteps = (tsteps_t *) Malloc((size_t)ntsteps*sizeof(tsteps_t));
 
   streamptr->tstepsTableSize = (int)ntsteps;
   streamptr->tstepsNextID    = (int)ntsteps;
 
   for ( tsID = 0; tsID < ntsteps; tsID++ )
     {
-      tstepsInitEntry(streamptr, (int)tsID);
+      tstepsInitEntry(streamptr, (size_t)tsID);
       streamptr->tsteps[tsID].taxis.used = TRUE;
     }
 }
diff --git a/libcdi/src/util.c b/libcdi/src/util.c
index 8c33813..25f4845 100644
--- a/libcdi/src/util.c
+++ b/libcdi/src/util.c
@@ -5,59 +5,61 @@
 #define _XOPEN_SOURCE 600
 
 #include <errno.h>
+#include <float.h>
+#include <inttypes.h>
 #include <stdio.h>
 #include <string.h>
-#include <float.h>
 #include <sys/types.h>
 
 #include "cdi.h"
 #include "cdi_int.h"
+#include "create_uuid.h"
 #include "dmemory.h"
 #include "binary.h"
 
 
-#undef  IsBigendian
-#define IsBigendian()  ( u_byteorder.c[sizeof(long) - 1] )
-
 void cdiPrintDatatypes(void)
 {
-  /* IsBigendian returns 1 for big endian byte order */
-  static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
-
-  fprintf (stderr, "+-------------+-------+\n");
-  fprintf (stderr, "| types       | bytes |\n");
-  fprintf (stderr, "+-------------+-------+\n");
-  fprintf (stderr, "| void *      |   %3d |\n", (int) sizeof(void *));
-  fprintf (stderr, "+-------------+-------+\n");
-  fprintf (stderr, "| char        |   %3d |\n", (int) sizeof(char));
-  fprintf (stderr, "+-------------+-------+\n");
-  fprintf (stderr, "| short       |   %3d |\n", (int) sizeof(short));
-  fprintf (stderr, "| int         |   %3d |\n", (int) sizeof(int));
-  fprintf (stderr, "| long        |   %3d |\n", (int) sizeof(long));
-  fprintf (stderr, "| long long   |   %3d |\n", (int) sizeof(long long));
-  fprintf (stderr, "| size_t      |   %3d |\n", (int) sizeof(size_t));
-  fprintf (stderr, "| off_t       |   %3d |\n", (int) sizeof(off_t));
-  fprintf (stderr, "+-------------+-------+\n");
-  fprintf (stderr, "| float       |   %3d |\n", (int) sizeof(float));
-  fprintf (stderr, "| double      |   %3d |\n", (int) sizeof(double));
-  fprintf (stderr, "| long double |   %3d |\n", (int) sizeof(long double));
-  fprintf (stderr, "+-------------+-------+\n\n");
 #define XSTRING(x)	#x
 #define STRING(x)	XSTRING(x)
-  fprintf (stderr, "+-------------+-----------+\n");
-  fprintf (stderr, "| INT32       | %-9s |\n", STRING(INT32));
-  fprintf (stderr, "| INT64       | %-9s |\n", STRING(INT64));
-  fprintf (stderr, "| FLT32       | %-9s |\n", STRING(FLT32));
-  fprintf (stderr, "| FLT64       | %-9s |\n", STRING(FLT64));
-  fprintf (stderr, "+-------------+-----------+\n");
-
-  if ( IsBigendian() )
-    fprintf (stderr, "\n  byte ordering is BIGENDIAN\n\n");
-  else
-    fprintf (stderr, "\n  byte ordering is LITTLEENDIAN\n\n");
+  fprintf (stderr, "+-------------+-------+\n"
+           "| types       | bytes |\n"
+           "+-------------+-------+\n"
+           "| void *      |   %3d |\n"
+           "+-------------+-------+\n"
+           "| char        |   %3d |\n"
+           "+-------------+-------+\n"
+           "| short       |   %3d |\n"
+           "| int         |   %3d |\n"
+           "| long        |   %3d |\n"
+           "| long long   |   %3d |\n"
+           "| size_t      |   %3d |\n"
+           "| off_t       |   %3d |\n"
+           "+-------------+-------+\n"
+           "| float       |   %3d |\n"
+           "| double      |   %3d |\n"
+           "| long double |   %3d |\n"
+           "+-------------+-------+\n\n"
+           "+-------------+-----------+\n"
+           "| INT32       | %-9s |\n"
+           "| INT64       | %-9s |\n"
+           "| FLT32       | %-9s |\n"
+           "| FLT64       | %-9s |\n"
+           "+-------------+-----------+\n"
+           "\n  byte ordering is %s\n\n",
+           (int) sizeof(void *), (int) sizeof(char),
+           (int) sizeof(short), (int) sizeof(int), (int) sizeof(long), (int) sizeof(long long),
+           (int) sizeof(size_t), (int) sizeof(off_t),
+           (int) sizeof(float), (int) sizeof(double), (int) sizeof(long double),
+           STRING(INT32), STRING(INT64), STRING(FLT32), STRING(FLT64),
+           ((HOST_ENDIANNESS == CDI_BIGENDIAN) ? "BIGENDIAN"
+            : ((HOST_ENDIANNESS == CDI_LITTLEENDIAN) ? "LITTLEENDIAN"
+               : "Unhandled endianness!")));
+#undef STRING
+#undef XSTRING
 }
 
-static char uuidFmt[] = "%02hhx%02hhx%02hhx%02hhx-"
+static const char uuidFmt[] = "%02hhx%02hhx%02hhx%02hhx-"
   "%02hhx%02hhx-%02hhx%02hhx-%02hhx%02hhx-"
   "%02hhx%02hhx%02hhx%02hhx%02hhx%02hhx";
 
@@ -99,20 +101,17 @@ char* cdiEscapeSpaces(const char* string)
 {
   //How much memory do we need?
   size_t escapeCount = 0, length = 0;
-  for(const char* current = string; *current; current++)
-    {
-      if(strchr(" \\", *current)) escapeCount++;
-      length++;
-    }
+  for(; string[length]; ++length)
+    escapeCount += string[length] == ' ' || string[length] == '\\';
 
-  char* result = malloc(length + escapeCount + 1);
+  char* result = (char *) Malloc(length + escapeCount + 1);
   if(!result) return NULL;
 
   //Do the escaping.
-  for(size_t in = 0, out = 0; in < length;)
+  for(size_t in = 0, out = 0; in < length; ++out, ++in)
     {
-      if(strchr(" \\", string[in])) result[out++] = '\\';
-      result[out++] = string[in++];
+      if(string[in] == ' ' || string[in] == '\\') result[out++] = '\\';
+      result[out] = string[in];
     }
   result[length + escapeCount] = 0;     //termination!
   return result;
@@ -135,7 +134,7 @@ char* cdiUnescapeSpaces(const char* string, const char** outStringEnd)
       length++;
     }
 
-  char* result = malloc(length + 1);
+  char* result = (char *) Malloc(length + 1);
   if(!result) return NULL;
 
   //Do the unescaping.
@@ -185,9 +184,9 @@ typedef uint32_t u_int32_t;
 void
 create_uuid(unsigned char *uuid)
 {
-  unsigned32 status;
-  uuid_create((uuid_t *)uuid, &status);
-  if (status == -1)
+  uint32_t status;
+  uuid_create((uuid_t *)(void *)uuid, &status);
+  if (status != uuid_s_ok)
     {
       perror("uuid generation failed!");
       exit(1);
diff --git a/libcdi/src/varscan.c b/libcdi/src/varscan.c
index 559cdb6..e33e093 100644
--- a/libcdi/src/varscan.c
+++ b/libcdi/src/varscan.c
@@ -14,6 +14,7 @@
 #include "vlist.h"
 #include "grid.h"
 #include "zaxis.h"
+#include "subtype.h"
 
 
 #undef  UNDEFID
@@ -26,6 +27,7 @@ static int numberOfVerticalLevels = 0;
 static int numberOfVerticalGrid = 0;
 static unsigned char uuidVGrid[CDI_UUID_SIZE];
 
+
 typedef struct
 {
   int      level1;
@@ -35,48 +37,58 @@ typedef struct
 }
 leveltable_t;
 
+
 typedef struct
 {
-  int           param;
-  int           prec;
-  int           tsteptype;
-  int           timave;
-  int           timaccu;
-  int           gridID;
-  int           zaxistype;
-  int           ltype1;     /* GRIB first level type */
-  int           ltype2;     /* GRIB second level type */
-  int           lbounds;
-  int           level_sf;
-  int           level_unit;
-  int           zaxisID;
+  int           subtypeIndex; /* corresponding tile in subtype_t structure (subtype->self) */
+
   unsigned      nlevels;
   int           levelTableSize;
-  leveltable_t *levelTable;
-  int           instID;
-  int           modelID;
-  int           tableID;
-  int           comptype;       // compression type
-  int           complevel;      // compression level
-  int           lmissval;
-  double        missval;
-  char         *name;
-  char         *stdname;
-  char         *longname;
-  char         *units;
-  ensinfo_t    *ensdata;
-  int           typeOfGeneratingProcess;
-  int           productDefinitionTemplate;
-#if  defined  (HAVE_LIBGRIB_API)
-  /* (Optional) list of keyword/double value pairs */
-  int           opt_grib_dbl_nentries;
-  char         *opt_grib_dbl_keyword[MAX_OPT_GRIB_ENTRIES];
-  double        opt_grib_dbl_val[MAX_OPT_GRIB_ENTRIES];
-  /* (Optional) list of keyword/integer value pairs */
-  int           opt_grib_int_nentries;
-  char         *opt_grib_int_keyword[MAX_OPT_GRIB_ENTRIES];
-  int           opt_grib_int_val[MAX_OPT_GRIB_ENTRIES];
-#endif
+  leveltable_t* levelTable;
+} subtypetable_t;
+
+
+typedef struct
+{
+  int            param;
+  int            prec;
+  int            tsteptype;
+  int            timaccu;
+  int            gridID;
+  int            zaxistype;
+  int            ltype1;     /* GRIB first level type */
+  int            ltype2;     /* GRIB second level type */
+  int            lbounds;
+  int            level_sf;
+  int            level_unit;
+  int            zaxisID;
+
+  int            nsubtypes_alloc;
+  int            nsubtypes;
+  subtypetable_t *recordTable;    /* ~ two-dimensional record list [nsubtypes_alloc][levelTableSize] */
+
+  int            instID;
+  int            modelID;
+  int            tableID;
+  int            comptype;       // compression type
+  int            complevel;      // compression level
+  short          timave;
+  short          lmissval;
+  double         missval;
+  char          *name;
+  char          *stdname;
+  char          *longname;
+  char          *units;
+  ensinfo_t     *ensdata;
+  int            typeOfGeneratingProcess;
+  int            productDefinitionTemplate;
+
+  /* meta-data for specification of tiles (currently only GRIB-API: */
+  subtype_t     *tiles;
+
+  int                 opt_grib_nentries;                       /* current no. key-value pairs            */
+  int                 opt_grib_kvpair_size;                    /* current allocated size                 */
+  opt_key_val_pair_t *opt_grib_kvpair;                         /* (optional) list of keyword/value pairs */
 }
 vartable_t;
 
@@ -101,9 +113,9 @@ paramInitEntry(unsigned varID, int param)
   vartable[varID].lbounds        = 0;
   vartable[varID].level_sf       = 0;
   vartable[varID].level_unit     = 0;
-  vartable[varID].levelTable     = NULL;
-  vartable[varID].levelTableSize = 0;
-  vartable[varID].nlevels        = 0;
+  vartable[varID].recordTable    = NULL;
+  vartable[varID].nsubtypes_alloc= 0;
+  vartable[varID].nsubtypes      = 0;
   vartable[varID].instID         = UNDEFID;
   vartable[varID].modelID        = UNDEFID;
   vartable[varID].tableID        = UNDEFID;
@@ -118,25 +130,39 @@ paramInitEntry(unsigned varID, int param)
   vartable[varID].longname       = NULL;
   vartable[varID].units          = NULL;
   vartable[varID].ensdata        = NULL;
+  vartable[varID].tiles          = NULL;
 }
 
+/* Test if a variable specified by the given meta-data has already
+ * been registered in "vartable". */
 static unsigned
-varGetEntry(int param, int zaxistype, int ltype1, int tsteptype, const char *name)
+varGetEntry(int param, int zaxistype, int ltype1, int tsteptype, const char *name, const var_tile_t *tiles)
 {
   for ( unsigned varID = 0; varID < varTablesize; varID++ )
     {
-      if ( vartable[varID].param      == param       &&
-	   vartable[varID].zaxistype  == zaxistype   &&
-	   vartable[varID].ltype1     == ltype1      &&
-	   vartable[varID].tsteptype  == tsteptype )
+      /* testing for "param" implicitly checks if we are beyond the
+       * current vartable size: */
+      if (vartable[varID].param == param)
         {
-          if ( name && name[0] && vartable[varID].name && vartable[varID].name[0] )
+          int no_of_tiles = -1;
+          if ( tiles ) no_of_tiles = tiles->numberOfTiles;
+          int vt_no_of_tiles = -1;
+          if ( vartable[varID].tiles )
+            vt_no_of_tiles = subtypeGetGlobalDataP(vartable[varID].tiles,
+                                                   SUBTYPE_ATT_NUMBER_OF_TILES);
+          if ( (vartable[varID].zaxistype  == zaxistype)               &&
+               (vartable[varID].ltype1     == ltype1   )               &&
+               (vartable[varID].tsteptype  == tsteptype)               &&
+               (vt_no_of_tiles == no_of_tiles) )
             {
-              if ( strcmp(name, vartable[varID].name) == 0 ) return (varID);
-            }
-          else
-            {
-              return (varID);
+              if ( name && name[0] && vartable[varID].name && vartable[varID].name[0] )
+                {
+                  if ( strcmp(name, vartable[varID].name) == 0 ) return (varID);
+                }
+              else
+                {
+                  return (varID);
+                }
             }
         }
     }
@@ -147,41 +173,119 @@ varGetEntry(int param, int zaxistype, int ltype1, int tsteptype, const char *nam
 static
 void varFree(void)
 {
+  if ( CDI_Debug ) Message("call to varFree");
+
   for ( unsigned varID = 0; varID < nvars; varID++ )
     {
-      if ( vartable[varID].levelTable )
-	free(vartable[varID].levelTable);
-
-      if ( vartable[varID].name )     free(vartable[varID].name);
-      if ( vartable[varID].stdname )  free(vartable[varID].stdname);
-      if ( vartable[varID].longname ) free(vartable[varID].longname);
-      if ( vartable[varID].units )    free(vartable[varID].units);
-      if ( vartable[varID].ensdata )  free(vartable[varID].ensdata);
+      if ( vartable[varID].recordTable )
+        {
+          for (int isub=0; isub<vartable[varID].nsubtypes_alloc; isub++)
+            Free(vartable[varID].recordTable[isub].levelTable);
+          Free(vartable[varID].recordTable);
+        }
+
+      if ( vartable[varID].name )     Free(vartable[varID].name);
+      if ( vartable[varID].stdname )  Free(vartable[varID].stdname);
+      if ( vartable[varID].longname ) Free(vartable[varID].longname);
+      if ( vartable[varID].units )    Free(vartable[varID].units);
+      if ( vartable[varID].ensdata )  Free(vartable[varID].ensdata);
+      if ( vartable[varID].tiles )    subtypeDestroyPtr(vartable[varID].tiles);
+
+      if ( vartable[varID].opt_grib_kvpair )
+        {
+          for (int i=0; i<vartable[varID].opt_grib_nentries; i++) {
+            if ( vartable[varID].opt_grib_kvpair[i].keyword )
+              Free(vartable[varID].opt_grib_kvpair[i].keyword);
+          }
+          Free(vartable[varID].opt_grib_kvpair);
+        }
+      vartable[varID].opt_grib_nentries    = 0;
+      vartable[varID].opt_grib_kvpair_size = 0;
+      vartable[varID].opt_grib_kvpair      = NULL;
     }
 
   if ( vartable )
-    free(vartable);
+    Free(vartable);
 
   vartable = NULL;
   varTablesize = 0;
   nvars = 0;
 
   if ( Vct )
-    free(Vct);
+    Free(Vct);
 
   Vct = NULL;
   Vctsize = 0;
 }
 
-static int
-levelNewEntry(unsigned varID, int level1, int level2)
+/* Search for a tile subtype with subtypeIndex == tile_index. */
+static int tileGetEntry(unsigned varID, int tile_index)
 {
-  int levelID = 0;
-  int levelTableSize;
-  leveltable_t *levelTable;
+  for (int isub=0; isub<vartable[varID].nsubtypes; isub++)
+    if (vartable[varID].recordTable[isub].subtypeIndex == tile_index)
+      return isub;
+  return CDI_UNDEFID;
+}
 
-  levelTableSize = vartable[varID].levelTableSize;
-  levelTable     = vartable[varID].levelTable;
+
+/* Resizes vartable:recordTable data structure, if necessary. */
+static int tileNewEntry(int varID)
+{
+  int tileID = 0;
+  if (vartable[varID].nsubtypes_alloc == 0)
+    {
+      /* create table for the first time. */
+      vartable[varID].nsubtypes_alloc = 2;
+      vartable[varID].nsubtypes       = 0;
+      vartable[varID].recordTable     =
+        (subtypetable_t *) Malloc((size_t)vartable[varID].nsubtypes_alloc * sizeof (subtypetable_t));
+      if( vartable[varID].recordTable == NULL )
+        SysError("Allocation of leveltable failed!");
+
+      for (int isub = 0; isub<vartable[varID].nsubtypes_alloc; isub++) {
+	vartable[varID].recordTable[isub].levelTable     = NULL;
+        vartable[varID].recordTable[isub].levelTableSize = 0;
+        vartable[varID].recordTable[isub].nlevels        = 0;
+        vartable[varID].recordTable[isub].subtypeIndex   = CDI_UNDEFID;
+      }
+    }
+  else
+    {
+      /* data structure large enough; find a free entry. */
+      while(tileID <  vartable[varID].nsubtypes_alloc)
+	{
+	  if (vartable[varID].recordTable[tileID].levelTable == NULL) break;
+	  tileID++;
+	}
+    }
+
+  /* If the table overflows, double its size. */
+  if (tileID == vartable[varID].nsubtypes_alloc)
+    {
+      tileID = vartable[varID].nsubtypes_alloc;
+      vartable[varID].nsubtypes_alloc *= 2;
+      vartable[varID].recordTable   =
+        (subtypetable_t *) Realloc(vartable[varID].recordTable,
+                                   (size_t)vartable[varID].nsubtypes_alloc * sizeof (subtypetable_t));
+      if (vartable[varID].recordTable == NULL)
+        SysError("Reallocation of leveltable failed");
+      for(int isub=tileID; isub<vartable[varID].nsubtypes_alloc; isub++) {
+	vartable[varID].recordTable[isub].levelTable     = NULL;
+        vartable[varID].recordTable[isub].levelTableSize = 0;
+        vartable[varID].recordTable[isub].nlevels        = 0;
+        vartable[varID].recordTable[isub].subtypeIndex   = CDI_UNDEFID;
+      }
+    }
+
+  return tileID;
+}
+
+
+static int levelNewEntry(unsigned varID, int level1, int level2, int tileID)
+{
+  int levelID = 0;
+  int levelTableSize = vartable[varID].recordTable[tileID].levelTableSize;
+  leveltable_t *levelTable = vartable[varID].recordTable[tileID].levelTable;
 
   /*
     Look for a free slot in levelTable.
@@ -189,56 +293,37 @@ levelNewEntry(unsigned varID, int level1, int level2)
   */
   if ( ! levelTableSize )
     {
-      int i;
-
       levelTableSize = 2;
-      levelTable = (leveltable_t *)xmalloc((size_t)levelTableSize
+      levelTable = (leveltable_t *) Malloc((size_t)levelTableSize
                                            * sizeof (leveltable_t));
-      if( levelTable == NULL )
-	{
-          Message("levelTableSize = %d", levelTableSize);
-	  SysError("Allocation of leveltable failed!");
-	}
-
-      for( i = 0; i < levelTableSize; i++ )
-	levelTable[i].recID = UNDEFID;
+      for ( int i = 0; i < levelTableSize; i++ )
+        levelTable[i].recID = UNDEFID;
     }
   else
     {
-      while( levelID < levelTableSize )
-	{
-	  if ( levelTable[levelID].recID == UNDEFID ) break;
-	  levelID++;
-	}
+      while( levelID < levelTableSize
+             && levelTable[levelID].recID != UNDEFID )
+        ++levelID;
     }
   /*
     If the table overflows, double its size.
   */
   if( levelID == levelTableSize )
     {
-      int i;
-
-      levelTableSize = 2*levelTableSize;
-      levelTable = (leveltable_t *)xrealloc(levelTable, (size_t)levelTableSize
+      levelTable = (leveltable_t *) Realloc(levelTable,
+                                            (size_t)(levelTableSize *= 2)
                                             * sizeof (leveltable_t));
-      if( levelTable == NULL )
-	{
-          Message("levelTableSize = %d", levelTableSize);
-	  SysError("Reallocation of leveltable failed");
-	}
-      levelID = levelTableSize/2;
-
-      for( i = levelID; i < levelTableSize; i++ )
-	levelTable[i].recID = UNDEFID;
+      for( int i = levelID; i < levelTableSize; i++ )
+        levelTable[i].recID = UNDEFID;
     }
 
   levelTable[levelID].level1   = level1;
   levelTable[levelID].level2   = level2;
   levelTable[levelID].lindex   = levelID;
 
-  vartable[varID].nlevels = (unsigned)levelID+1;
-  vartable[varID].levelTableSize = levelTableSize;
-  vartable[varID].levelTable = levelTable;
+  vartable[varID].recordTable[tileID].nlevels        = (unsigned)levelID+1;
+  vartable[varID].recordTable[tileID].levelTableSize = levelTableSize;
+  vartable[varID].recordTable[tileID].levelTable     = levelTable;
 
   return (levelID);
 }
@@ -257,7 +342,7 @@ paramNewEntry(int param)
   if ( ! varTablesize )
     {
       varTablesize = 2;
-      vartable = (vartable_t *)xmalloc((size_t)varTablesize
+      vartable = (vartable_t *) Malloc((size_t)varTablesize
                                        * sizeof (vartable_t));
       if( vartable == NULL )
 	{
@@ -266,13 +351,12 @@ paramNewEntry(int param)
 	}
 
       for( unsigned i = 0; i < varTablesize; i++ )
-	{
-	  vartable[i].param = UNDEF_PARAM;
-#if  defined  (HAVE_LIBGRIB_API)
-	  vartable[i].opt_grib_int_nentries = 0;
-	  vartable[i].opt_grib_dbl_nentries = 0;
-#endif
-	}
+        {
+          vartable[i].param = UNDEF_PARAM;
+          vartable[i].opt_grib_kvpair      = NULL;
+          vartable[i].opt_grib_kvpair_size = 0;
+          vartable[i].opt_grib_nentries    = 0;
+        }
     }
   else
     {
@@ -287,25 +371,15 @@ paramNewEntry(int param)
   */
   if ( varID == varTablesize )
     {
-
-      varTablesize = 2 * varTablesize;
-      vartable = (vartable_t *)xrealloc(vartable, (size_t)varTablesize
+      vartable = (vartable_t *) Realloc(vartable, (size_t)(varTablesize *= 2)
                                         * sizeof (vartable_t));
-      if( vartable == NULL )
-	{
-          Message("varTablesize = %d", varTablesize);
-	  SysError("Reallocation of vartable failed!");
-	}
-      varID = varTablesize/2;
-
       for( unsigned i = varID; i < varTablesize; i++ )
-	{
-	  vartable[i].param = UNDEF_PARAM;
-#if  defined  (HAVE_LIBGRIB_API)
-	  vartable[i].opt_grib_int_nentries = 0;
-	  vartable[i].opt_grib_dbl_nentries = 0;
-#endif
-	}
+        {
+          vartable[i].param = UNDEF_PARAM;
+          vartable[i].opt_grib_kvpair      = NULL;
+          vartable[i].opt_grib_kvpair_size = 0;
+          vartable[i].opt_grib_nentries    = 0;
+        }
     }
 
   paramInitEntry(varID, param);
@@ -314,13 +388,68 @@ paramNewEntry(int param)
 }
 
 
+/* Append tile set to a subtype. Return index of the new tile (i.e.
+ * the "entry->self" value). */
+static
+int varInsertTileSubtype(vartable_t *vptr, const var_tile_t *tiles)
+{
+  if ( tiles == NULL ) return -1;
+
+  int totalno_of_tileattr_pairs = -1;
+  int tileClassification = -1;
+  int numberOfTiles = -1;
+  int numberOfAttributes = -1;
+  int tileindex = -1;
+  int attribute = -1;
+
+  if ( tiles )
+    {
+      totalno_of_tileattr_pairs = tiles->totalno_of_tileattr_pairs;
+      tileClassification =  tiles->tileClassification;
+      numberOfTiles = tiles->numberOfTiles;
+      numberOfAttributes = tiles->numberOfAttributes;
+      tileindex = tiles->tileindex;
+      attribute = tiles->attribute;
+    }
+
+  /* first, generate a subtype based on the info in "tiles". */
+
+  subtype_t *subtype_ptr;
+  subtypeAllocate(&subtype_ptr, SUBTYPE_TILES);
+  subtypeDefGlobalDataP(subtype_ptr, SUBTYPE_ATT_TOTALNO_OF_TILEATTR_PAIRS, totalno_of_tileattr_pairs);
+  subtypeDefGlobalDataP(subtype_ptr, SUBTYPE_ATT_TILE_CLASSIFICATION      , tileClassification);
+  subtypeDefGlobalDataP(subtype_ptr, SUBTYPE_ATT_NUMBER_OF_TILES          , numberOfTiles);
+
+  /*
+   * Here, we create a tile set for comparison that contains only one
+   * tile/attribute pair (based on "tiles").
+   */
+  struct subtype_entry_t *entry = subtypeEntryInsert(subtype_ptr);
+  subtypeDefEntryDataP(entry, SUBTYPE_ATT_NUMBER_OF_ATTR,            numberOfAttributes);
+  subtypeDefEntryDataP(entry, SUBTYPE_ATT_TILEINDEX,                 tileindex);
+  subtypeDefEntryDataP(entry, SUBTYPE_ATT_TILEATTRIBUTE,             attribute);
+
+  if (vptr->tiles == NULL) {
+    vptr->tiles = subtype_ptr;
+    return 0;
+  }
+  else {
+    tilesetInsertP(vptr->tiles, subtype_ptr);
+    subtypeDestroyPtr(subtype_ptr);
+    return vptr->tiles->nentries - 1;
+  }
+  return CDI_UNDEFID;
+}
+
+
 void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
 		  int level1, int level2, int level_sf, int level_unit, int prec,
 		  int *pvarID, int *plevelID, int tsteptype, int numavg, int ltype1, int ltype2,
-		  const char *name, const char *stdname, const char *longname, const char *units)
+		  const char *name, const char *stdname, const char *longname, const char *units,
+                  const var_tile_t *tiles, int *tile_index)
 {
   unsigned varID = (cdiSplitLtype105 != 1 || zaxistype != ZAXIS_HEIGHT) ?
-    varGetEntry(param, zaxistype, ltype1, tsteptype, name) : (unsigned)UNDEFID;
+    varGetEntry(param, zaxistype, ltype1, tsteptype, name, tiles) : (unsigned)UNDEFID;
 
   if ( varID == (unsigned)UNDEFID )
     {
@@ -334,6 +463,7 @@ void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
       vartable[varID].level_sf   = level_sf;
       vartable[varID].level_unit = level_unit;
       vartable[varID].tsteptype  = tsteptype;
+
       if ( numavg ) vartable[varID].timave = 1;
 
       if ( name )     if ( name[0] )     vartable[varID].name     = strdup(name);
@@ -360,12 +490,28 @@ void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
 
   if ( prec > vartable[varID].prec ) vartable[varID].prec = prec;
 
-  int levelID = levelNewEntry(varID, level1, level2);
-  vartable[varID].levelTable[levelID].recID = recID;
-
-  *pvarID   = (int)varID;
+  /* append current tile to tile subtype info. */
+  int this_tile = varInsertTileSubtype(&vartable[varID], tiles);
+  int tileID = tileGetEntry(varID, this_tile);
+  if ( tile_index ) (*tile_index) = this_tile;
+  if (tileID == CDI_UNDEFID) {
+    tileID = tileNewEntry((int)varID);
+    vartable[varID].recordTable[tileID].subtypeIndex = this_tile;
+    vartable[varID].nsubtypes++;
+  }
+
+  /* append current level to level table info */
+  int levelID = levelNewEntry(varID, level1, level2, tileID);
+  if (CDI_Debug)
+    Message("vartable[%d].recordTable[%d].levelTable[%d].recID = %d; level1,2=%d,%d",
+            varID, tileID, levelID, recID, level1, level2);
+  vartable[varID].recordTable[tileID].levelTable[levelID].recID = recID;
+
+  *pvarID   = (int) varID;
   *plevelID = levelID;
 }
+
+
 /*
 static
 int dblcmp(const void *s1, const void *s2)
@@ -434,6 +580,7 @@ int cmpparam(const void* s1, const void* s2)
 void cdi_generate_vars(stream_t *streamptr)
 {
   int gridID, zaxisID;
+
   int instID, modelID, tableID;
   int param, zaxistype, ltype1, ltype2;
   int prec;
@@ -448,12 +595,12 @@ void cdi_generate_vars(stream_t *streamptr)
   double level_sf = 1;
   int vlistID = streamptr->vlistID;
 
-  int *varids = (int *)xmalloc(nvars*sizeof(int));
+  int *varids = (int *) Malloc(nvars*sizeof(int));
   for ( unsigned varID = 0; varID < nvars; varID++ ) varids[varID] = (int)varID;
 
   if ( streamptr->sortname )
     {
-      param_t *varInfo = (param_t *)xmalloc((size_t)nvars * sizeof (param_t));
+      param_t *varInfo = (param_t *) Malloc((size_t)nvars * sizeof (param_t));
 
       for ( unsigned varID = 0; varID < nvars; varID++ )
 	{
@@ -466,7 +613,7 @@ void cdi_generate_vars(stream_t *streamptr)
 	{
 	  varids[varID] = varInfo[varID].varid;
 	}
-      free(varInfo);
+      Free(varInfo);
     }
 
   for ( unsigned index = 0; index < nvars; index++ )
@@ -475,7 +622,6 @@ void cdi_generate_vars(stream_t *streamptr)
 
       gridID     = vartable[varid].gridID;
       param      = vartable[varid].param;
-      unsigned nlevels = vartable[varid].nlevels;
       ltype1     = vartable[varid].ltype1;
       ltype2     = vartable[varid].ltype2;
       zaxistype = vartable[varid].zaxistype;
@@ -496,19 +642,50 @@ void cdi_generate_vars(stream_t *streamptr)
 
       zaxisID = UNDEFID;
 
+      /* consistency check: test if all subtypes have the same levels: */
+      unsigned nlevels = vartable[varid].recordTable[0].nlevels;
+      for (int isub=1; isub<vartable[varid].nsubtypes; isub++) {
+        if (vartable[varid].recordTable[isub].nlevels != nlevels)
+          {
+            fprintf(stderr, "var \"%s\": isub = %d / %d :: "
+                    "nlevels = %d, vartable[varid].recordTable[isub].nlevels = %d\n",
+                    vartable[varid].name, isub, vartable[varid].nsubtypes,
+                    nlevels, vartable[varid].recordTable[isub].nlevels);
+            Error("zaxis size must not change for same parameter!");
+          }
+
+        leveltable_t *t1 = vartable[varid].recordTable[isub-1].levelTable;
+        leveltable_t *t2 = vartable[varid].recordTable[isub  ].levelTable;
+        for (unsigned ilev=0; ilev<nlevels; ilev++)
+          if ((t1[ilev].level1 != t2[ilev].level1)  ||
+              (t1[ilev].level2 != t2[ilev].level2)  ||
+              (t1[ilev].lindex != t2[ilev].lindex))
+            {
+              fprintf(stderr, "var \"%s\", varID=%d: isub = %d / %d :: "
+                      "nlevels = %d, vartable[varid].recordTable[isub].nlevels = %d\n",
+                      vartable[varid].name, varid, isub, vartable[varid].nsubtypes,
+                      nlevels, vartable[varid].recordTable[isub].nlevels);
+              Message("t1[ilev].level1=%d / t2[ilev].level1=%d",t1[ilev].level1, t2[ilev].level1);
+              Message("t1[ilev].level2=%d / t2[ilev].level2=%d",t1[ilev].level2, t2[ilev].level2);
+              Message("t1[ilev].lindex=%d / t2[ilev].lindex=%d",t1[ilev].lindex, t2[ilev].lindex);
+              Error("zaxis type must not change for same parameter!");
+            }
+      }
+      leveltable_t *levelTable = vartable[varid].recordTable[0].levelTable;
+
       if ( ltype1 == 0 && zaxistype == ZAXIS_GENERIC && nlevels == 1 &&
-	   vartable[varid].levelTable[0].level1 == 0 )
+	   levelTable[0].level1 == 0 )
 	zaxistype = ZAXIS_SURFACE;
 
-      dlevels = (double *) malloc(nlevels*sizeof(double));
+      dlevels = (double *) Malloc(nlevels*sizeof(double));
 
       if ( lbounds && zaxistype != ZAXIS_HYBRID && zaxistype != ZAXIS_HYBRID_HALF )
 	for (unsigned levelID = 0; levelID < nlevels; levelID++ )
-	  dlevels[levelID] = (level_sf*vartable[varid].levelTable[levelID].level1 +
-	                      level_sf*vartable[varid].levelTable[levelID].level2)/2;
+	  dlevels[levelID] = (level_sf*levelTable[levelID].level1 +
+	                      level_sf*levelTable[levelID].level2)/2;
       else
 	for (unsigned levelID = 0; levelID < nlevels; levelID++ )
-	  dlevels[levelID] = level_sf*vartable[varid].levelTable[levelID].level1;
+	  dlevels[levelID] = level_sf*levelTable[levelID].level1;
 
       if ( nlevels > 1 )
 	{
@@ -522,24 +699,24 @@ void cdi_generate_vars(stream_t *streamptr)
             }
           /*
            * always sort pressure z-axis to ensure
-           * vartable[varid].levelTable[levelID1].level1 < vartable[varid].levelTable[levelID2].level1 <=> levelID1 > levelID2
+           * levelTable[levelID1].level1 < levelTable[levelID2].level1 <=> levelID1 > levelID2
            * unless already sorted in decreasing order
            */
           if ( !ldec && zaxistype == ZAXIS_PRESSURE )
             {
-              qsort(vartable[varid].levelTable, nlevels, sizeof(leveltable_t), cmpLevelTableInv);
+              qsort(levelTable, nlevels, sizeof(leveltable_t), cmpLevelTableInv);
               lsort = true;
             }
           /*
            * always sort hybrid and depth-below-land z-axis to ensure
-           * vartable[varid].levelTable[levelID1].level1 < vartable[varid].levelTable[levelID2].level1 <=> levelID1 < levelID2
+           * levelTable[levelID1].level1 < levelTable[levelID2].level1 <=> levelID1 < levelID2
            * unless already sorted in increasing order
            */
           else if ( (!linc && !ldec) ||
                     zaxistype == ZAXIS_HYBRID ||
                     zaxistype == ZAXIS_DEPTH_BELOW_LAND )
             {
-              qsort(vartable[varid].levelTable, nlevels, sizeof(leveltable_t), cmpLevelTable);
+              qsort(levelTable, nlevels, sizeof(leveltable_t), cmpLevelTable);
               lsort = true;
             }
 
@@ -547,25 +724,25 @@ void cdi_generate_vars(stream_t *streamptr)
             {
               if ( lbounds && zaxistype != ZAXIS_HYBRID && zaxistype != ZAXIS_HYBRID_HALF )
                 for (unsigned levelID = 0; levelID < nlevels; levelID++ )
-                  dlevels[levelID] = (level_sf*vartable[varid].levelTable[levelID].level1 +
-                                      level_sf*vartable[varid].levelTable[levelID].level2)/2.;
+                  dlevels[levelID] = (level_sf*levelTable[levelID].level1 +
+                                      level_sf*levelTable[levelID].level2)/2.;
               else
                 for (unsigned levelID = 0; levelID < nlevels; levelID++ )
-                  dlevels[levelID] = level_sf*vartable[varid].levelTable[levelID].level1;
+                  dlevels[levelID] = level_sf*levelTable[levelID].level1;
             }
 	}
 
       if ( lbounds )
 	{
-	  dlevels1 = (double *) malloc(nlevels*sizeof(double));
+	  dlevels1 = (double *) Malloc(nlevels*sizeof(double));
 	  for (unsigned levelID = 0; levelID < nlevels; levelID++)
-	    dlevels1[levelID] = level_sf*vartable[varid].levelTable[levelID].level1;
-	  dlevels2 = (double *) malloc(nlevels*sizeof(double));
+	    dlevels1[levelID] = level_sf*levelTable[levelID].level1;
+	  dlevels2 = (double *) Malloc(nlevels*sizeof(double));
 	  for (unsigned levelID = 0; levelID < nlevels; levelID++)
-	    dlevels2[levelID] = level_sf*vartable[varid].levelTable[levelID].level2;
+	    dlevels2[levelID] = level_sf*levelTable[levelID].level2;
         }
 
-      char *unitptr = cdiUnitNamePtr(vartable[varid].level_unit);
+      const char *unitptr = cdiUnitNamePtr(vartable[varid].level_unit);
       zaxisID = varDefZaxis(vlistID, zaxistype, (int)nlevels, dlevels, lbounds, dlevels1, dlevels2,
                             (int)Vctsize, Vct, NULL, NULL, unitptr, 0, 0, ltype1);
 
@@ -581,12 +758,17 @@ void cdi_generate_vars(stream_t *streamptr)
           if ( !cdiUUIDIsNull(uuidVGrid) ) zaxisDefUUID(zaxisID, uuidVGrid);
         }
 
-      if ( lbounds ) free(dlevels1);
-      if ( lbounds ) free(dlevels2);
-      free(dlevels);
+      if ( lbounds ) Free(dlevels1);
+      if ( lbounds ) Free(dlevels2);
+      Free(dlevels);
 
-      int varID = stream_new_var(streamptr, gridID, zaxisID);
-      varID = vlistDefVar(vlistID, gridID, zaxisID, tsteptype);
+      /* define new subtype for tile set */
+      int tilesetID = CDI_UNDEFID;
+      if ( vartable[varid].tiles ) tilesetID = vlistDefTileSubtype(vlistID, vartable[varid].tiles);
+
+      /* generate new variable */
+      int varID = stream_new_var(streamptr, gridID, zaxisID, tilesetID);
+      varID = vlistDefVarTiles(vlistID, gridID, zaxisID, tsteptype, tilesetID);
 
       vlistDefVarParam(vlistID, varID, param);
       vlistDefVarDatatype(vlistID, varID, prec);
@@ -601,7 +783,6 @@ void cdi_generate_vars(stream_t *streamptr)
         vlistDefVarProductDefinitionTemplate(vlistID, varID, vartable[varid].productDefinitionTemplate);
 
       if ( vartable[varid].lmissval ) vlistDefVarMissval(vlistID, varID, vartable[varid].missval);
-
       if ( vartable[varid].name )     vlistDefVarName(vlistID, varID, vartable[varid].name);
       if ( vartable[varid].stdname )  vlistDefVarStdname(vlistID, varID, vartable[varid].stdname);
       if ( vartable[varid].longname ) vlistDefVarLongname(vlistID, varID, vartable[varid].longname);
@@ -611,34 +792,23 @@ void cdi_generate_vars(stream_t *streamptr)
 	                                                  vartable[varid].ensdata->ens_count,
 							  vartable[varid].ensdata->forecast_init_type);
 
-#if  defined  (HAVE_LIBGRIB_API)
-      /* ---------------------------------- */
-      /* Local change: 2013-04-23, FP (DWD) */
-      /* ---------------------------------- */
-
       int    i;
       vlist_t *vlistptr;
       vlistptr = vlist_to_pointer(vlistID);
-      for (i=0; i<vartable[varid].opt_grib_int_nentries; i++)
-        {
-          int idx = vlistptr->vars[varID].opt_grib_int_nentries;
-          vlistptr->vars[varID].opt_grib_int_nentries++;
-          if ( idx >= MAX_OPT_GRIB_ENTRIES ) Error("Too many optional keyword/integer value pairs!");
-          vlistptr->vars[varID].opt_grib_int_update[idx] = TRUE;
-          vlistptr->vars[varID].opt_grib_int_val[idx] = vartable[varid].opt_grib_int_val[idx];
-          vlistptr->vars[varID].opt_grib_int_keyword[idx] = strdupx(vartable[varid].opt_grib_int_keyword[idx]);
-        }
-      for (i=0; i<vartable[varid].opt_grib_dbl_nentries; i++)
+      for (i=0; i<vartable[varid].opt_grib_nentries; i++)
         {
-          int idx = vlistptr->vars[varID].opt_grib_dbl_nentries;
-          vlistptr->vars[varID].opt_grib_dbl_nentries++;
-          if ( idx >= MAX_OPT_GRIB_ENTRIES ) Error("Too many optional keyword/double value pairs!");
-          vlistptr->vars[varID].opt_grib_dbl_update[idx] = TRUE;
-          vlistptr->vars[varID].opt_grib_dbl_val[idx] = vartable[varid].opt_grib_dbl_val[idx];
-          vlistptr->vars[varID].opt_grib_dbl_keyword[idx] = strdupx(vartable[varid].opt_grib_dbl_keyword[idx]);
+          resize_opt_grib_entries(&vlistptr->vars[varID], vlistptr->vars[varID].opt_grib_nentries+1);
+          vlistptr->vars[varID].opt_grib_nentries += 1;
+          int idx = vlistptr->vars[varID].opt_grib_nentries-1;
+
+          vlistptr->vars[varID].opt_grib_kvpair[idx] = vartable[varid].opt_grib_kvpair[i];
+          vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = NULL;
+	  if (vartable[varid].opt_grib_kvpair[i].keyword) 
+	    vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = 
+	      strdupx(vartable[varid].opt_grib_kvpair[i].keyword);
+          vlistptr->vars[varID].opt_grib_kvpair[i].update = TRUE;
         }
       /* note: if the key is not defined, we do not throw an error! */
-#endif
 
       if ( cdiDefaultTableID != UNDEFID )
 	{
@@ -675,34 +845,42 @@ void cdi_generate_vars(stream_t *streamptr)
 
   for ( unsigned index = 0; index < nvars; index++ )
     {
-      int varID = (int)index;
       int varid = varids[index];
+      unsigned nlevels = vartable[varid].recordTable[0].nlevels;
 
-      unsigned nlevels = vartable[varid].nlevels;
       /*
       for ( levelID = 0; levelID < nlevels; levelID++ )
 	{
-	  printf("%d %d %d %d %d\n", varID, levelID,
+	  printf("%d %d %d %d %d\n", varid, levelID,
 		 vartable[varid].levelTable[levelID].lindex,
 		 vartable[varid].levelTable[levelID].recID,
 		 vartable[varid].levelTable[levelID].level1);
 	}
       */
-      for (unsigned levelID = 0; levelID < nlevels; levelID++)
-	{
-	  streamptr->vars[varID].level[levelID] = vartable[varid].levelTable[levelID].recID;
-          unsigned lindex;
-	  for (lindex = 0; lindex < nlevels; lindex++ )
-	    if ( levelID == (unsigned)vartable[varid].levelTable[lindex].lindex ) break;
-
-	  if ( lindex == nlevels )
-	    Error("Internal problem! lindex not found.");
-
-	  streamptr->vars[varID].lindex[levelID] = (int)lindex;
-	}
+      unsigned nsub = vartable[varid].nsubtypes >= 0
+        ? (unsigned)vartable[varid].nsubtypes : 0U;
+      for (size_t isub=0; isub < nsub; isub++)
+        {
+          sleveltable_t *restrict streamRecordTable
+            = streamptr->vars[index].recordTable + isub;
+          leveltable_t *restrict vartableLevelTable
+            = vartable[varid].recordTable[isub].levelTable;
+          for (unsigned levelID = 0; levelID < nlevels; levelID++)
+            {
+              streamRecordTable->recordID[levelID]
+                = vartableLevelTable[levelID].recID;
+              unsigned lindex;
+              for (lindex = 0; lindex < nlevels; lindex++ )
+                if ( levelID == (unsigned)vartableLevelTable[lindex].lindex )
+                  break;
+              if ( lindex == nlevels )
+                Error("Internal problem! lindex not found.");
+              streamRecordTable->lindex[levelID] = (int)lindex;
+            }
+        }
     }
 
-  free(varids);
+  Free(varids);
 
   varFree();
 }
@@ -713,7 +891,7 @@ void varDefVCT(size_t vctsize, double *vctptr)
   if ( Vct == NULL && vctptr != NULL && vctsize > 0 )
     {
       Vctsize = vctsize;
-      Vct = (double *) malloc(vctsize*sizeof(double));
+      Vct = (double *) Malloc(vctsize*sizeof(double));
       memcpy(Vct, vctptr, vctsize*sizeof(double));
     }
 }
@@ -726,84 +904,8 @@ void varDefZAxisReference(int nhlev, int nvgrid, unsigned char uuid[CDI_UUID_SIZ
   memcpy(uuidVGrid, uuid, CDI_UUID_SIZE);
 }
 
-struct varDefGridSearchState
-{
-  int resIDValue;
-  const grid_t *queryKey;
-};
-
-static enum cdiApplyRet
-varDefGridSearch(int id, void *res, void *data)
-{
-  struct varDefGridSearchState *state = data;
-  (void)res;
-  if (gridCompare(id, state->queryKey) == 0)
-    {
-      state->resIDValue = id;
-      return CDI_APPLY_STOP;
-    }
-  else
-    return CDI_APPLY_GO_ON;
-}
-
-int varDefGrid(int vlistID, const grid_t *grid, int mode)
-{
-  /*
-    mode: 0 search in vlist and grid table
-          1 search in grid table
-   */
-  int gridglobdefined = FALSE;
-  int griddefined;
-  int gridID = CDI_UNDEFID;
-  vlist_t *vlistptr = vlist_to_pointer(vlistID);
-
-  griddefined = FALSE;
-  unsigned ngrids = (unsigned)vlistptr->ngrids;
-
-  if ( mode == 0 )
-    for (unsigned index = 0; index < ngrids; index++ )
-      {
-	gridID = vlistptr->gridIDs[index];
-	if ( gridID == UNDEFID )
-	  Error("Internal problem: undefined gridID %d!", gridID);
-
-	if ( gridCompare(gridID, grid) == 0 )
-	  {
-	    griddefined = TRUE;
-	    break;
-	  }
-      }
-
-  if ( ! griddefined )
-    {
-      struct varDefGridSearchState query = { .queryKey = grid };
-      if ((gridglobdefined
-           = (cdiResHFilterApply(&gridOps, varDefGridSearch, &query)
-              == CDI_APPLY_STOP)))
-        gridID = query.resIDValue;
-
-      if ( mode == 1 && gridglobdefined)
-	for (unsigned index = 0; index < ngrids; index++ )
-	  if ( vlistptr->gridIDs[index] == gridID )
-	    {
-	      gridglobdefined = FALSE;
-	      break;
-	    }
-    }
-
-  if ( ! griddefined )
-    {
-      if ( ! gridglobdefined ) gridID = gridGenerate(grid);
-      ngrids = (unsigned)vlistptr->ngrids;
-      vlistptr->gridIDs[ngrids] = gridID;
-      vlistptr->ngrids++;
-    }
-
-  return (gridID);
-}
-
 
-int zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, const double *levels, char *longname, char *units, int ltype1)
+int zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, const double *levels, const char *longname, const char *units, int ltype1)
 {
   int differ = 1;
   int levelID;
@@ -854,16 +956,17 @@ struct varDefZAxisSearchState
   int resIDValue;
   int zaxistype;
   int nlevels;
-  double *levels;
   int lbounds;
-  char *longname, *units;
+  double *levels;
+  const char *longname;
+  const char *units;
   int ltype;
 };
 
 static enum cdiApplyRet
 varDefZAxisSearch(int id, void *res, void *data)
 {
-  struct varDefZAxisSearchState *state = data;
+  struct varDefZAxisSearchState *state = (struct varDefZAxisSearchState *)data;
   (void)res;
   if (zaxisCompare(id, state->zaxistype, state->nlevels, state->lbounds,
                    state->levels, state->longname, state->units, state->ltype)
@@ -879,7 +982,7 @@ varDefZAxisSearch(int id, void *res, void *data)
 
 int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbounds,
 		double *levels1, double *levels2, int vctsize, double *vct, char *name,
-		char *longname, char *units, int prec, int mode, int ltype1)
+		char *longname, const char *units, int prec, int mode, int ltype1)
 {
   /*
     mode: 0 search in vlist and zaxis table
@@ -888,7 +991,6 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbo
   int zaxisdefined = 0;
   int nzaxis;
   int zaxisID = UNDEFID;
-  int index;
   int zaxisglobdefined = 0;
   vlist_t *vlistptr;
 
@@ -897,7 +999,7 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbo
   nzaxis = vlistptr->nzaxis;
 
   if ( mode == 0 )
-    for ( index = 0; index < nzaxis; index++ )
+    for ( int index = 0; index < nzaxis; index++ )
       {
 	zaxisID = vlistptr->zaxisIDs[index];
 
@@ -910,17 +1012,17 @@ int varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbo
 
   if ( ! zaxisdefined )
     {
-      struct varDefZAxisSearchState query = {
-        .zaxistype = zaxistype,
-        .nlevels = nlevels,
-        .levels = levels,
-        .lbounds = lbounds,
-        .longname = longname,
-        .units = units,
-        .ltype = ltype1,
-      };
+      struct varDefZAxisSearchState query;
+      query.zaxistype = zaxistype;
+      query.nlevels = nlevels;
+      query.levels = levels;
+      query.lbounds = lbounds;
+      query.longname = longname;
+      query.units = units;
+      query.ltype = ltype1;
+
       if ((zaxisglobdefined
-           = (cdiResHFilterApply(&zaxisOps, varDefZAxisSearch, &query)
+           = (cdiResHFilterApply(getZaxisOps(), varDefZAxisSearch, &query)
               == CDI_APPLY_STOP)))
         zaxisID = query.resIDValue;
 
@@ -1029,7 +1131,7 @@ void varDefTable(int varID, int tableID)
 void varDefEnsembleInfo(int varID, int ens_idx, int ens_count, int forecast_type)
 {
   if ( vartable[varID].ensdata == NULL )
-      vartable[varID].ensdata = (ensinfo_t *)xmalloc( sizeof( ensinfo_t ) );
+      vartable[varID].ensdata = (ensinfo_t *) Malloc( sizeof( ensinfo_t ) );
 
   vartable[varID].ensdata->ens_index = ens_idx;
   vartable[varID].ensdata->ens_count = ens_count;
@@ -1048,27 +1150,99 @@ void varDefProductDefinitionTemplate(int varID, int productDefinitionTemplate)
   vartable[varID].productDefinitionTemplate = productDefinitionTemplate;
 }
 
+#if  defined  (HAVE_LIBGRIB_API)
+/* Resizes and initializes opt_grib_kvpair data structure. */
+static 
+void resize_vartable_opt_grib_entries(vartable_t *var, int nentries)
+{
+  if (var->opt_grib_kvpair_size >= nentries) 
+    {
+      return;   /* nothing to do; array is still large enough */
+    }
+  else
+    {
+      if ( CDI_Debug )
+        Message("resize data structure, %d -> %d", var->opt_grib_kvpair_size, nentries);
+
+      int i, new_size;
+      new_size = (2*var->opt_grib_kvpair_size) > nentries ? (2*var->opt_grib_kvpair_size) : nentries;
+      if (CDI_Debug)
+        Message("resize vartable opt_grib_entries array to size %d", new_size);
+      opt_key_val_pair_t *tmp = (opt_key_val_pair_t *) Malloc((size_t)new_size * sizeof (opt_key_val_pair_t));
+      for (i=0; i<var->opt_grib_kvpair_size; i++) {
+        tmp[i] = var->opt_grib_kvpair[i];
+      }
+      for (i=var->opt_grib_kvpair_size; i<new_size; i++) {
+        tmp[i].int_val =     0;
+        tmp[i].dbl_val =     0;
+        tmp[i].update  = FALSE;
+        tmp[i].keyword =  NULL;
+      } // for
+      var->opt_grib_kvpair_size = new_size;
+      Free(var->opt_grib_kvpair);
+      var->opt_grib_kvpair = tmp;
+    }
+}
+#endif
 
 #if  defined  (HAVE_LIBGRIB_API)
-void varDefOptGribInt(int varID, long lval, const char *keyword)
+void varDefOptGribInt(int varID, int tile_index, long lval, const char *keyword)
 {
-  int idx = vartable[varID].opt_grib_int_nentries;
-  vartable[varID].opt_grib_int_nentries++;
-  if ( idx >= MAX_OPT_GRIB_ENTRIES ) Error("Too many optional keyword/integer value pairs!");
-  vartable[varID].opt_grib_int_val[idx] = (int) lval;
-  vartable[varID].opt_grib_int_keyword[idx] = strdupx(keyword);
+  int idx = -1;
+  for (int i=0; i<vartable[varID].opt_grib_nentries; i++)
+    {
+      if ( (strcmp(keyword, vartable[varID].opt_grib_kvpair[i].keyword) == 0 ) &&
+           (vartable[varID].opt_grib_kvpair[i].data_type == t_int)             &&
+           (vartable[varID].opt_grib_kvpair[i].subtype_index == tile_index) )
+        idx = i;
+    }
+
+  if (idx == -1)
+    {
+      resize_vartable_opt_grib_entries(&vartable[varID], vartable[varID].opt_grib_nentries+1);
+      vartable[varID].opt_grib_nentries += 1;
+      idx = vartable[varID].opt_grib_nentries -1;
+    }
+  else
+    {
+      if (vartable[varID].opt_grib_kvpair[idx].keyword)
+        Free(vartable[varID].opt_grib_kvpair[idx].keyword);
+    }
+  vartable[varID].opt_grib_kvpair[idx].data_type     = t_int;
+  vartable[varID].opt_grib_kvpair[idx].int_val       = (int) lval;
+  vartable[varID].opt_grib_kvpair[idx].keyword       = strdupx(keyword);
+  vartable[varID].opt_grib_kvpair[idx].subtype_index = tile_index;
 }
 #endif
 
 
 #if  defined  (HAVE_LIBGRIB_API)
-void varDefOptGribDbl(int varID, double dval, const char *keyword)
+void varDefOptGribDbl(int varID, int tile_index, double dval, const char *keyword)
 {
-  int idx = vartable[varID].opt_grib_dbl_nentries;
-  vartable[varID].opt_grib_dbl_nentries++;
-  if ( idx >= MAX_OPT_GRIB_ENTRIES ) Error("Too many optional keyword/double value pairs!");
-  vartable[varID].opt_grib_dbl_val[idx] = dval;
-  vartable[varID].opt_grib_dbl_keyword[idx] = strdupx(keyword);
+  int idx = -1;
+  for (int i=0; i<vartable[varID].opt_grib_nentries; i++)
+    {
+      if ( (strcmp(keyword, vartable[varID].opt_grib_kvpair[i].keyword) == 0 ) &&
+           (vartable[varID].opt_grib_kvpair[i].data_type == t_double)          &&
+           (vartable[varID].opt_grib_kvpair[i].subtype_index == tile_index) )
+        idx = i;
+    }
+
+  if (idx == -1) 
+    {
+      resize_vartable_opt_grib_entries(&vartable[varID], vartable[varID].opt_grib_nentries+1);
+      vartable[varID].opt_grib_nentries += 1;
+      idx = vartable[varID].opt_grib_nentries -1;
+    }
+  else
+    {
+      if (vartable[varID].opt_grib_kvpair[idx].keyword)
+        Free(vartable[varID].opt_grib_kvpair[idx].keyword);
+    }
+  vartable[varID].opt_grib_kvpair[idx].data_type     = t_double;
+  vartable[varID].opt_grib_kvpair[idx].dbl_val       = dval;
+  vartable[varID].opt_grib_kvpair[idx].keyword       = strdupx(keyword);
+  vartable[varID].opt_grib_kvpair[idx].subtype_index = tile_index;
 }
 #endif
 
@@ -1077,7 +1251,7 @@ void varDefOptGribDbl(int varID, double dval, const char *keyword)
 int varOptGribNentries(int varID)
 {
   int nentries = 0;
-  nentries = vartable[varID].opt_grib_int_nentries + vartable[varID].opt_grib_dbl_nentries;
+  nentries = vartable[varID].opt_grib_nentries;
   return (nentries);
 }
 #endif
diff --git a/libcdi/src/varscan.h b/libcdi/src/varscan.h
index 43c41a9..366ceba 100644
--- a/libcdi/src/varscan.h
+++ b/libcdi/src/varscan.h
@@ -5,23 +5,23 @@
 #  include "grid.h"
 #endif
 
-#include "cdi.h"
 
 void varAddRecord(int recID, int param, int gridID, int zaxistype, int lbounds,
 		  int level1, int level2, int level_sf, int level_unit, int prec,
 		  int *pvarID, int *plevelID, int tsteptype, int numavg, int ltype1, int ltype2,
-		  const char *name, const char *stdname, const char *longname, const char *units);
+		  const char *name, const char *stdname, const char *longname, const char *units,
+                  const var_tile_t *tiles, int *tile_index);
 
 void varDefVCT(size_t vctsize, double *vctptr);
 void varDefZAxisReference(int nlev, int nvgrid, unsigned char uuid[CDI_UUID_SIZE]);
 
-int  varDefGrid(int vlistID, const grid_t *grid, int mode);
 int  varDefZaxis(int vlistID, int zaxistype, int nlevels, double *levels, int lbounds,
 		 double *levels1, double *levels2, int vctsize, double *vct, char *name,
-		 char *longname, char *units, int prec, int mode, int ltype);
+		 char *longname, const char *units, int prec, int mode, int ltype);
 
 void varDefMissval(int varID, double missval);
 void varDefCompType(int varID, int comptype);
+void varDefCompLevel(int varID, int complevel);
 void varDefInst(int varID, int instID);
 int  varInqInst(int varID);
 void varDefModel(int varID, int modelID);
@@ -34,11 +34,11 @@ void varDefTypeOfGeneratingProcess(int varID, int typeOfGeneratingProcess);
 void varDefProductDefinitionTemplate(int varID, int productDefinitionTemplate);
 
 
-void varDefOptGribInt(int varID, long lval, const char *keyword);
-void varDefOptGribDbl(int varID, double dval, const char *keyword);
+void varDefOptGribInt(int varID, int tile_index, long lval, const char *keyword);
+void varDefOptGribDbl(int varID, int tile_index, double dval, const char *keyword);
 int varOptGribNentries(int varID);
 
-int  zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, const double *levels, char *longname, char *units, int ltype);
+int  zaxisCompare(int zaxisID, int zaxistype, int nlevels, int lbounds, const double *levels, const char *longname, const char *units, int ltype);
 
 #endif
 /*
diff --git a/libcdi/src/version.c b/libcdi/src/version.c
index 35a18bf..f61a4d5 100644
--- a/libcdi/src/version.c
+++ b/libcdi/src/version.c
@@ -2,12 +2,14 @@
 #  include "config.h"
 #endif
 
+#include "cdi.h"
+
 /*
  * A version string.
  */
 
 #if defined (VERSION)
-   static const char cdi_libvers[] = VERSION " of "__DATE__" "__TIME__;
+   static const char cdi_libvers[] = VERSION " of " __DATE__" " __TIME__;
 #else
 #  error "VERSION undefined"
 #endif
diff --git a/libcdi/src/vlist.c b/libcdi/src/vlist.c
index 16346e8..11e0822 100644
--- a/libcdi/src/vlist.c
+++ b/libcdi/src/vlist.c
@@ -107,12 +107,15 @@ void vlist_init_entry(vlist_t *vlistptr)
   vlistptr->ntsteps        = CDI_UNDEFID;
   vlistptr->atts.nalloc    = MAX_ATTRIBUTES;
   vlistptr->atts.nelems    = 0;
+  vlistptr->nsubtypes      = 0;
+  for (int i=0; i<MAX_SUBTYPES_PS; i++)
+    vlistptr->subtypeIDs[i] = CDI_UNDEFID;
 }
 
 static
 vlist_t *vlist_new_entry(cdiResH resH)
 {
-  vlist_t *vlistptr = (vlist_t*) xmalloc(sizeof(vlist_t));
+  vlist_t *vlistptr = (vlist_t*) Malloc(sizeof(vlist_t));
   vlist_init_entry(vlistptr);
   if (resH == CDI_UNDEFID)
     vlistptr->self = reshPut(vlistptr, &vlistOps);
@@ -133,7 +136,7 @@ void vlist_delete_entry(vlist_t *vlistptr)
 
   reshRemove(idx, &vlistOps );
 
-  free(vlistptr);
+  Free(vlistptr);
 
   if ( VLIST_Debug )
     Message("Removed idx %d from vlist list", idx);
@@ -166,7 +169,7 @@ void vlist_lock(int vlistID)
 
   if ( !vlistptr->locked )
     {
-      vlistptr->locked = 1;
+      vlistptr->locked += 1;
       reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
     }
 }
@@ -178,7 +181,7 @@ void vlist_unlock(int vlistID)
 
   if ( vlistptr->locked )
     {
-      vlistptr->locked = 0;
+      vlistptr->locked -= 1;
       reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
     }
 }
@@ -215,6 +218,7 @@ int vlistCreate(void)
   VLIST_INIT();
 
   vlist_t *vlistptr = vlist_new_entry(CDI_UNDEFID);
+  if ( CDI_Debug ) Message("create vlistID = %d", vlistptr->self);
   return (vlistptr->self);
 }
 
@@ -222,6 +226,7 @@ static void
 vlist_delete(vlist_t *vlistptr)
 {
   int vlistID = vlistptr->self;
+  if ( CDI_Debug ) Message("call to vlist_delete, vlistID = %d", vlistID);
 
   vlistDelAtts(vlistID, CDI_GLOBAL);
 
@@ -230,30 +235,29 @@ vlist_delete(vlist_t *vlistptr)
 
   for ( int varID = 0; varID < nvars; varID++ )
     {
-      if ( vars[varID].levinfo )  free(vars[varID].levinfo);
-      if ( vars[varID].name )     free(vars[varID].name);
-      if ( vars[varID].longname ) free(vars[varID].longname);
-      if ( vars[varID].stdname )  free(vars[varID].stdname);
-      if ( vars[varID].units )    free(vars[varID].units);
-      if ( vars[varID].ensdata )  free(vars[varID].ensdata);
-
-#if  defined  (HAVE_LIBGRIB_API)
-      for ( int i=0; i<vars[varID].opt_grib_int_nentries; i++ )
+      if ( vars[varID].levinfo )  Free(vars[varID].levinfo);
+      if ( vars[varID].name )     Free(vars[varID].name);
+      if ( vars[varID].longname ) Free(vars[varID].longname);
+      if ( vars[varID].stdname )  Free(vars[varID].stdname);
+      if ( vars[varID].units )    Free(vars[varID].units);
+      if ( vars[varID].ensdata )  Free(vars[varID].ensdata);
+
+      if ( vlistptr->vars[varID].opt_grib_kvpair )
         {
-          if ( vars[varID].opt_grib_int_keyword[i] )
-            free(vars[varID].opt_grib_int_keyword[i]);
-        }
-      for ( int i=0; i<vars[varID].opt_grib_dbl_nentries; i++ )
-        {
-          if ( vars[varID].opt_grib_dbl_keyword[i] )
-            free(vars[varID].opt_grib_dbl_keyword[i]);
+          for (int i=0; i<vlistptr->vars[varID].opt_grib_nentries; i++) {
+            if ( vlistptr->vars[varID].opt_grib_kvpair[i].keyword )
+              Free(vlistptr->vars[varID].opt_grib_kvpair[i].keyword);
+          }
+          Free(vlistptr->vars[varID].opt_grib_kvpair);
         }
-#endif
+      vlistptr->vars[varID].opt_grib_nentries    = 0;
+      vlistptr->vars[varID].opt_grib_kvpair_size = 0;
+      vlistptr->vars[varID].opt_grib_kvpair      = NULL;
 
       vlistDelAtts(vlistID, varID);
     }
 
-  if ( vars ) free(vars);
+  if ( vars ) Free(vars);
 
   vlist_delete_entry(vlistptr);
 }
@@ -273,7 +277,7 @@ void vlistDestroy(int vlistID)
 {
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
 
-  if ( vlistptr->locked )
+  if ( vlistptr->locked != 0 )
     Warning("Destroying of a locked object (vlistID=%d) failed!", vlistID);
   else
     vlist_delete(vlistptr);
@@ -288,34 +292,32 @@ void var_copy_entries(var_t *var2, var_t *var1)
   if ( var1->units )    var2->units    = strdupx(var1->units);
   if ( var1->ensdata )
     {
-      var2->ensdata = (ensinfo_t *)xmalloc(sizeof(ensinfo_t));
+      var2->ensdata = (ensinfo_t *) Malloc(sizeof(ensinfo_t));
       memcpy(var2->ensdata, var1->ensdata, sizeof(ensinfo_t));
     }
-#if  defined  (HAVE_LIBGRIB_API)
-  /* ---------------------------------- */
-  /* Local change: 2013-01-28, FP (DWD) */
-  /* ---------------------------------- */
-  var2->opt_grib_int_nentries = var1->opt_grib_int_nentries;
-  for ( int i = 0; i < var1->opt_grib_int_nentries; i++ )
-    {
-      if ( var1->opt_grib_int_keyword[i] )
-        {
-          var2->opt_grib_int_keyword[i] = strdupx(var1->opt_grib_int_keyword[i]);
-          var2->opt_grib_int_val[i]     = var1->opt_grib_int_val[i];
-          var2->opt_grib_int_update[i]  = TRUE;
-        }
+
+  var2->opt_grib_kvpair_size = 0;
+  var2->opt_grib_kvpair      = NULL;
+  var2->opt_grib_nentries    = 0;
+
+  resize_opt_grib_entries(var2, var1->opt_grib_nentries);
+  var2->opt_grib_nentries = var1->opt_grib_nentries;
+  if ((var2->opt_grib_nentries > 0) && CDI_Debug )
+    Message("copy %d optional GRIB keywords", var2->opt_grib_nentries);
+
+  for (int i=0; i<var1->opt_grib_nentries; i++) {
+    if ( CDI_Debug )  Message("copy entry \"%s\" ...", var1->opt_grib_kvpair[i].keyword);
+    var2->opt_grib_kvpair[i].keyword = NULL;
+    if ( var1->opt_grib_kvpair[i].keyword != NULL ) {
+      var2->opt_grib_kvpair[i]         = var1->opt_grib_kvpair[i];
+      var2->opt_grib_kvpair[i].keyword = strdupx(var1->opt_grib_kvpair[i].keyword);
+      var2->opt_grib_kvpair[i].update  = TRUE;
+      if ( CDI_Debug )  Message("done.");
     }
-  var2->opt_grib_dbl_nentries = var1->opt_grib_dbl_nentries;
-  for ( int i = 0; i < var1->opt_grib_dbl_nentries; i++ )
-    {
-      if ( var1->opt_grib_dbl_keyword[i] )
-        {
-          var2->opt_grib_dbl_keyword[i] = strdupx(var1->opt_grib_dbl_keyword[i]);
-          var2->opt_grib_dbl_val[i]     = var1->opt_grib_dbl_val[i];
-          var2->opt_grib_dbl_update[i]  = TRUE;
-        }
+    else {
+      if ( CDI_Debug )  Message("not done.");
     }
-#endif
+  }
 }
 
 /*
@@ -336,6 +338,7 @@ void vlistCopy(int vlistID2, int vlistID1)
 {
   vlist_t *vlistptr1 = vlist_to_pointer(vlistID1);
   vlist_t *vlistptr2 = vlist_to_pointer(vlistID2);
+  if ( CDI_Debug ) Message("call to vlistCopy, vlistIDs %d -> %d", vlistID1, vlistID2);
 
   var_t *vars1 = vlistptr1->vars;
   var_t *vars2 = vlistptr2->vars;
@@ -349,7 +352,7 @@ void vlistCopy(int vlistID2, int vlistID1)
       //vlistptr2->varsAllocated = nvars;
 
       size_t n = (size_t)vlistptr2->varsAllocated;
-      vars2 = xrealloc(vars2, n*sizeof(var_t));
+      vars2 = (var_t *) Realloc(vars2, n*sizeof(var_t));
       memcpy(vars2, vars1, n*sizeof(var_t));
       vlistptr2->vars = vars2;
 
@@ -357,13 +360,13 @@ void vlistCopy(int vlistID2, int vlistID1)
         {
           var_copy_entries(&vars2[varID], &vars1[varID]);
 
-	  vars2[varID].atts.nelems = 0;
+          vlistptr2->vars[varID].atts.nelems = 0;
 	  vlistCopyVarAtts(vlistID1, varID, vlistID2, varID);
 
           if ( vars1[varID].levinfo )
             {
               n = (size_t)zaxisInqSize(vars1[varID].zaxisID);
-              vars2[varID].levinfo = xmalloc(n*sizeof(levinfo_t));
+              vars2[varID].levinfo = (levinfo_t *) Malloc(n*sizeof(levinfo_t));
               memcpy(vars2[varID].levinfo, vars1[varID].levinfo, n*sizeof(levinfo_t));
             }
 	}
@@ -388,6 +391,8 @@ The function @func{vlistDuplicate} duplicates the variable list from vlistID1.
 */
 int vlistDuplicate(int vlistID)
 {
+  if ( CDI_Debug ) Message("call to vlistDuplicate");
+
   int vlistIDnew = vlistCreate();
   vlistCopy(vlistIDnew, vlistID);
   return (vlistIDnew);
@@ -411,6 +416,33 @@ void vlistClearFlag(int vlistID)
     }
 }
 
+
+struct vgzSearchState
+{
+  int resIDValue;
+  int zaxistype;
+  int nlevels;
+  int lbounds;
+  const double *levels;
+};
+
+static enum cdiApplyRet
+vgzZAxisSearch(int id, void *res, void *data)
+{
+  struct vgzSearchState *state = (struct vgzSearchState *)data;
+  (void)res;
+  if (zaxisCompare(id, state->zaxistype, state->nlevels, state->lbounds,
+                   state->levels, NULL, NULL, 0)
+      == 0)
+    {
+      state->resIDValue = id;
+      return CDI_APPLY_STOP;
+    }
+  else
+    return CDI_APPLY_GO_ON;
+}
+
+
 static
 int vlist_generate_zaxis(int vlistID, int zaxistype, int nlevels, const double *levels,
                          const double *lbounds, const double *ubounds, int vctsize, const double *vct)
@@ -437,24 +469,16 @@ int vlist_generate_zaxis(int vlistID, int zaxistype, int nlevels, const double *
 
   if ( ! zaxisdefined )
     {
-      unsigned nzaxis = cdiZaxisCount();
-      if ( nzaxis > 0 )
-        {
-          int *zaxisIndexList = (int *)xmalloc((size_t)nzaxis * sizeof (int));
-          reshLock();
-          cdiZaxisGetIndexList(nzaxis, zaxisIndexList);
-          for (unsigned index = 0; index < nzaxis; ++index)
-            {
-              zaxisID = zaxisIndexList[index];
-              if ( zaxisCompare(zaxisID, zaxistype, nlevels, has_bounds, levels, NULL, NULL, 0) == 0 )
-                {
-                  zaxisglobdefined = 1;
-                  break;
-                }
-            }
-          reshUnlock();
-          free(zaxisIndexList);
-        }
+      struct vgzSearchState query;
+      query.zaxistype = zaxistype;
+      query.nlevels = nlevels;
+      query.levels = levels;
+      query.lbounds = has_bounds;
+
+      if ((zaxisglobdefined
+           = (cdiResHFilterApply(getZaxisOps(), vgzZAxisSearch, &query)
+              == CDI_APPLY_STOP)))
+        zaxisID = query.resIDValue;
     }
 
   if ( ! zaxisdefined )
@@ -526,7 +550,7 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
       vlistptr2->nvars = nvars2;
       vlistptr2->varsAllocated = nvars2;
       if ( nvars2 > 0 )
-        vars2 = (var_t *)xmalloc((size_t)nvars2*sizeof(var_t));
+        vars2 = (var_t *) Malloc((size_t)nvars2*sizeof(var_t));
       else
         vars2 = NULL;
 
@@ -536,9 +560,10 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
       for ( int varID = 0; varID < nvars; varID++ )
 	if ( vars1[varID].flag )
 	  {
-	    vars2[varID2].flag = FALSE;
-	    int zaxisID = vars1[varID].zaxisID;
-	    int gridID  = vars1[varID].gridID;
+	    vlistptr2->vars[varID2].flag = FALSE;
+	    int zaxisID   = vlistptr1->vars[varID].zaxisID;
+	    int gridID    = vlistptr1->vars[varID].gridID;
+	    int subtypeID = vlistptr1->vars[varID].subtypeID;
 
 	    memcpy(&vars2[varID2], &vars1[varID], sizeof(var_t));
 
@@ -549,7 +574,7 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
 
             var_copy_entries(&vars2[varID2], &vars1[varID]);
 
-	    vars2[varID2].atts.nelems = 0;
+	    vlistptr2->vars[varID2].atts.nelems = 0;
 	    vlistCopyVarAtts(vlistID1, varID, vlistID2, varID2);
 
 	    int nlevs  = zaxisInqSize(vars1[varID].zaxisID);
@@ -558,7 +583,7 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
               for ( int levID = 0; levID < nlevs; levID++ )
                 nlevs2 += (vars1[varID].levinfo[levID].flag != 0);
 
-	    vars2[varID2].levinfo = (levinfo_t *)xmalloc((size_t)nlevs2 * sizeof(levinfo_t));
+	    vars2[varID2].levinfo = (levinfo_t *) Malloc((size_t)nlevs2 * sizeof(levinfo_t));
 
 	    if ( nlevs != nlevs2 )
 	      {
@@ -568,17 +593,21 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
                 char ctemp[CDI_MAX_NAME];
 
 		zaxisID = vars1[varID].zaxisID;
-		double *levels = (double *)xmalloc((size_t)nlevs2 * sizeof (double));
-                int levID2 = 0;
+		double *levels = (double *) Malloc((size_t)nlevs2 * sizeof (double));
                 if ( !vars1[varID].levinfo )
                   cdiVlistCreateVarLevInfo(vlistptr1, varID);
-                for ( int levID = 0; levID < nlevs; ++levID )
-                  if ( vars1[varID].levinfo[levID].flag )
-                    {
-                      vars1[varID].levinfo[levID].flevelID = levID2;
-                      vars1[varID].levinfo[levID].mlevelID = levID2;
-                      levels[levID2++] = zaxisInqLevel(zaxisID, levID);
-                    }
+
+                {
+                  int levID2 = 0;
+                  for ( int levID = 0; levID < nlevs; ++levID )
+                    if ( vars1[varID].levinfo[levID].flag )
+                      {
+                        vars1[varID].levinfo[levID].flevelID = levID2;
+                        vars1[varID].levinfo[levID].mlevelID = levID2;
+                        levels[levID2++] = zaxisInqLevel(zaxisID, levID);
+                      }
+                }
+
 		int zaxisType = zaxisInqType(zaxisID);
 
 		if ( zaxisType == ZAXIS_HYBRID )
@@ -589,10 +618,10 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
 
                 if ( zaxisInqLbounds(zaxisID, NULL) && zaxisInqUbounds(zaxisID, NULL) )
                   {
-                    lbounds = (double *)xmalloc(2 * (size_t)nlevs2 * sizeof (double));
+                    lbounds = (double *) Malloc(2 * (size_t)nlevs2 * sizeof (double));
                     ubounds = lbounds + nlevs2;
 
-                    double *lbounds1 = (double *)xmalloc(2 * (size_t)nlevs * sizeof (double)),
+                    double *lbounds1 = (double *) Malloc(2 * (size_t)nlevs * sizeof (double)),
                       *ubounds1 = lbounds1 + nlevs;
 
                     zaxisInqLbounds(zaxisID, lbounds1);
@@ -607,12 +636,12 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
                           levID2++;
                         }
 
-                    free(lbounds1);
+                    Free(lbounds1);
                   }
 
 		int zaxisID2 = vlist_generate_zaxis(vlistID2, zaxisType, nlevs2, levels, lbounds, ubounds, nvct, vct);
 		free(levels);
-                free(lbounds);
+                Free(lbounds);
 
                 zaxisInqName(zaxisID, ctemp);
                 zaxisDefName(zaxisID2, ctemp);
@@ -642,6 +671,7 @@ void vlistCopyFlag(int vlistID2, int vlistID1)
 
             vlistAdd2GridIDs(vlistptr2, gridID);
             vlistAdd2ZaxisIDs(vlistptr2, zaxisID);
+            vlistAdd2SubtypeIDs(vlistptr2, subtypeID);
 
 	    varID2++;
 	  }
@@ -676,7 +706,7 @@ void vlistCat(int vlistID2, int vlistID1)
   if ( nvars > vlistptr2->varsAllocated )
     {
       vlistptr2->varsAllocated = nvars;
-      vars2 = xrealloc(vars2, (size_t)nvars*sizeof(var_t));
+      vars2 = (var_t *) Realloc(vars2, (size_t)nvars*sizeof(var_t));
       vlistptr2->vars = vars2;
     }
   memcpy(vars2+nvars2, vars1, (size_t)nvars1 * sizeof(var_t));
@@ -703,7 +733,7 @@ void vlistCat(int vlistID2, int vlistID1)
       int nlevs = zaxisInqSize(vars1[varID].zaxisID);
       if ( vars1[varID].levinfo )
         {
-          vars2[varID2].levinfo = (levinfo_t *)xmalloc((size_t)nlevs * sizeof(levinfo_t));
+          vars2[varID2].levinfo = (levinfo_t *) Malloc((size_t)nlevs * sizeof(levinfo_t));
           memcpy(vars2[varID2].levinfo, vars1[varID].levinfo,
                  (size_t)nlevs * sizeof(levinfo_t));
         }
@@ -713,6 +743,7 @@ void vlistCat(int vlistID2, int vlistID1)
 
       vlistAdd2GridIDs(vlistptr2, vars1[varID].gridID);
       vlistAdd2ZaxisIDs(vlistptr2, vars1[varID].zaxisID);
+      vlistAdd2SubtypeIDs(vlistptr2, vars1[varID].subtypeID);
     }
 }
 
@@ -779,7 +810,7 @@ void vlistMerge(int vlistID2, int vlistID1)
           */
           if ( vars1[varID].levinfo )
             {
-              vars2[varID].levinfo = (levinfo_t*)xrealloc(vars2[varID].levinfo,
+              vars2[varID].levinfo = (levinfo_t*) Realloc(vars2[varID].levinfo,
                                      (size_t)nlevs * sizeof(levinfo_t));
 
               memcpy(vars2[varID].levinfo+nlevs2, vars1[varID].levinfo,
@@ -792,7 +823,7 @@ void vlistMerge(int vlistID2, int vlistID1)
             vars1[varID].levinfo[levID].mlevelID = nlevs2 + levID;
 	}
 
-      int *lvar = (int *)xcalloc((size_t)nvars2, sizeof(int));
+      int *lvar = (int *) Calloc((size_t)nvars2, sizeof(int));
 
       for ( varID = 0; varID < nvars2; varID++ )
         {
@@ -815,7 +846,7 @@ void vlistMerge(int vlistID2, int vlistID1)
 
           zaxisResize(zaxisID, nlevs);
 
-          double *levels = (double *)xmalloc((size_t)nlevs1 * sizeof(double));
+          double *levels = (double *) Malloc((size_t)nlevs1 * sizeof(double));
 
           zaxisInqLevels(zaxisID1, levels);
           /*
@@ -825,7 +856,7 @@ void vlistMerge(int vlistID2, int vlistID1)
           for ( int levID = 0; levID < nlevs1; levID++ )
             zaxisDefLevel(zaxisID, nlevs2+levID, levels[levID]);
 
-          free(levels);
+          Free(levels);
 
           for ( int index = 0; index < vlistptr2->nzaxis; index++ )
             if ( vlistptr2->zaxisIDs[index] == zaxisID2 )
@@ -839,7 +870,7 @@ void vlistMerge(int vlistID2, int vlistID1)
               }
         }
 
-      free(lvar);
+      Free(lvar);
     }
   else
     {
@@ -958,6 +989,14 @@ int vlistNzaxis(int vlistID)
 }
 
 
+int vlistNsubtypes(int vlistID)
+{
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+
+  return (vlistptr->nsubtypes);
+}
+
+
 void vlistDefNtsteps(int vlistID, int nts)
 {
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
@@ -977,8 +1016,8 @@ int vlistNtsteps(int vlistID)
   return (int)vlistptr->ntsteps;
 }
 
-static void
-vlistPrintKernel(vlist_t *vlistptr, FILE * fp )
+static
+void vlistPrintKernel(vlist_t *vlistptr, FILE *fp)
 {
   char paramstr[32];
 
@@ -986,25 +1025,27 @@ vlistPrintKernel(vlist_t *vlistptr, FILE * fp )
 
   int nvars = vlistptr->nvars;
 
-  fprintf(fp, "nvars   %d\n"
-          "ngrids  %d\n"
-          "nzaxis  %d\n"
-          "taxisID %d\n"
-          "instID  %d\n"
-          "modelID %d\n"
-          "tableID %d\n",
-          nvars, vlistptr->ngrids, vlistptr->nzaxis, vlistptr->taxisID,
+  fprintf(fp, "nvars    : %d\n"
+          "ngrids   : %d\n"
+          "nzaxis   : %d\n"
+          "nsubtypes: %d\n"
+          "taxisID  : %d\n"
+          "instID   : %d\n"
+          "modelID  : %d\n"
+          "tableID  : %d\n",
+          nvars, vlistptr->ngrids, vlistptr->nzaxis, vlistptr->nsubtypes, vlistptr->taxisID,
           vlistptr->instID, vlistptr->modelID, vlistptr->tableID);
 
   if ( nvars > 0 )
     {
-      fprintf(fp, " varID param    gridID zaxisID tsteptype flag "
-              " name     longname iorank\n");
+      fprintf(fp, " varID param    gridID zaxisID stypeID tsteptype flag iorank"
+              " name     longname         units\n");
       for ( int varID = 0; varID < nvars; varID++ )
         {
           int param = vlistptr->vars[varID].param;
           int gridID = vlistptr->vars[varID].gridID;
           int zaxisID = vlistptr->vars[varID].zaxisID;
+          int subtypeID = vlistptr->vars[varID].subtypeID;
 	  int tsteptype = vlistptr->vars[varID].tsteptype;
           const char *name = vlistptr->vars[varID].name;
           const char *longname = vlistptr->vars[varID].longname;
@@ -1013,14 +1054,9 @@ vlistPrintKernel(vlist_t *vlistptr, FILE * fp )
           int iorank = vlistptr->vars[varID].iorank;
 
           cdiParamToString(param, paramstr, sizeof(paramstr));
-          fprintf(fp, "%6d %-8s %6d %6d %6d %5d %-8s"
-                  " %s %6d",
-                  varID, paramstr, gridID, zaxisID, tsteptype, flag,
-                  name ? name : "", longname ? longname : "",
-                  iorank);
-
-          if ( units ) fprintf(fp, "   [%s]", units);
-          fputs("\n", fp);
+          fprintf(fp, "%6d %-8s %6d  %6d  %6d  %6d  %5d %6d %-8s %s [%s]\n",
+                  varID, paramstr, gridID, zaxisID, subtypeID, tsteptype, flag, iorank,
+                  name?name:"", longname?longname:"", units?units:"");
         }
 
       fputs("\n"
@@ -1305,6 +1341,7 @@ int vlistZaxis(int vlistID, int index)
   return (zaxisID);
 }
 
+
 int vlistZaxisIndex(int vlistID, int zaxisID)
 {
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
@@ -1337,7 +1374,7 @@ void vlistChangeZaxisIndex(int vlistID, int index, int zaxisID)
             vlistptr->vars[varID].zaxisID = zaxisID;
             if ( vlistptr->vars[varID].levinfo && nlevs != nlevsOld )
               {
-                vlistptr->vars[varID].levinfo = (levinfo_t *)xrealloc(vlistptr->vars[varID].levinfo, (size_t)nlevs * sizeof (levinfo_t));
+                vlistptr->vars[varID].levinfo = (levinfo_t *) Realloc(vlistptr->vars[varID].levinfo, (size_t)nlevs * sizeof (levinfo_t));
 
                 for ( int levID = 0; levID < nlevs; levID++ )
                   vlistptr->vars[varID].levinfo[levID] = DEFAULT_LEVINFO(levID);
@@ -1372,7 +1409,7 @@ void vlistChangeZaxis(int vlistID, int zaxisID1, int zaxisID2)
         if ( vlistptr->vars[varID].levinfo && nlevs2 != nlevs1 )
           {
             vlistptr->vars[varID].levinfo
-              = (levinfo_t *)xrealloc(vlistptr->vars[varID].levinfo,
+              = (levinfo_t *) Realloc(vlistptr->vars[varID].levinfo,
                                       (size_t)nlevs2 * sizeof(levinfo_t));
 
             for ( int levID = 0; levID < nlevs2; levID++ )
@@ -1383,6 +1420,32 @@ void vlistChangeZaxis(int vlistID, int zaxisID1, int zaxisID2)
 }
 
 
+int vlistSubtype(int vlistID, int index)
+{
+  int subtypeID = CDI_UNDEFID;
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+
+  if ( index < vlistptr->nsubtypes && index >= 0 )
+    subtypeID = vlistptr->subtypeIDs[index];
+
+  return subtypeID;
+}
+
+
+int vlistSubtypeIndex(int vlistID, int subtypeID)
+{
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+
+  int index;
+  for ( index = 0 ; index < vlistptr->nsubtypes ; index++ )
+    if ( subtypeID == vlistptr->subtypeIDs[index] ) break;
+
+  if ( index == vlistptr->nsubtypes ) index = -1;
+
+  return (index);
+}
+
+
 int vlistHasTime(int vlistID)
 {
   int hastime = FALSE;
@@ -1441,7 +1504,7 @@ void vlistPackP ( void * vlistptr, void * buf, int size, int *position,
   vlistAttsPack(p, CDI_GLOBAL, buf, size, position, context);
   for ( varID = 0; varID < p->nvars; varID++ )
     {
-      vlistVarPack(p, varID, buf, size, position, context);
+      vlistVarPack(p, varID, (char *)buf, size, position, context);
     }
 }
 
@@ -1464,6 +1527,8 @@ void vlistUnpack(char * buf, int size, int *position, int originNamespace,
   vlistAttsUnpack(targetID, CDI_GLOBAL, buf, size, position, context);
   for (int varID = 0; varID < nvars; varID++ )
     vlistVarUnpack(targetID, buf, size, position, originNamespace, context);
+  reshSetStatus(targetID, &vlistOps,
+                reshGetStatus(targetID, &vlistOps) & ~RESH_SYNC_BIT);
 }
 
 
@@ -1480,6 +1545,40 @@ void vlist_check_contents(int vlistID)
 	cdiCheckZaxis(zaxisID);
     }
 }
+
+
+/* Resizes and initializes opt_grib_kvpair data structure. */
+void resize_opt_grib_entries(var_t *var, int nentries)
+{
+  if (var->opt_grib_kvpair_size >= nentries) 
+    {
+      if ( CDI_Debug )
+        Message("data structure has size %d, no resize to %d needed.", var->opt_grib_kvpair_size, nentries);
+      return;   /* nothing to do; array is still large enough */
+    }
+  else
+    {
+      if ( CDI_Debug )
+        Message("resize data structure, %d -> %d", var->opt_grib_kvpair_size, nentries);
+
+      int i, new_size;
+      new_size = (2*var->opt_grib_kvpair_size) > nentries ? (2*var->opt_grib_kvpair_size) : nentries;
+      opt_key_val_pair_t *tmp = (opt_key_val_pair_t *) Malloc((size_t)new_size * sizeof (opt_key_val_pair_t));
+      for (i=0; i<var->opt_grib_kvpair_size; i++) {
+        tmp[i] = var->opt_grib_kvpair[i];
+      }
+      for (i=var->opt_grib_kvpair_size; i<new_size; i++) {
+        tmp[i].int_val =     0;
+        tmp[i].dbl_val =     0;
+        tmp[i].update  = FALSE;
+        tmp[i].keyword =  NULL;
+      } // for
+      var->opt_grib_kvpair_size = new_size;
+      Free(var->opt_grib_kvpair);
+      var->opt_grib_kvpair = tmp;
+    }
+}
+
 /*
  * Local Variables:
  * c-file-style: "Java"
diff --git a/libcdi/src/vlist.h b/libcdi/src/vlist.h
index 5a4ff73..6fdd5cd 100644
--- a/libcdi/src/vlist.h
+++ b/libcdi/src/vlist.h
@@ -65,12 +65,6 @@ typedef struct
 }
 ensinfo_t;
 
-/* ---------------------------------- */
-/* Local change: 2013-01-28, FP (DWD) */
-/* ---------------------------------- */
-
-/* Length of optional keyword/value pair list */
-#define MAX_OPT_GRIB_ENTRIES 50
 
 
 typedef struct
@@ -110,22 +104,12 @@ typedef struct
   ensinfo_t  *ensdata;      /* Ensemble information */
   cdi_atts_t  atts;
   int         iorank;
-#if  defined  (HAVE_LIBGRIB_API)
-  /* ---------------------------------- */
-  /* Local change: 2013-01-28, FP (DWD) */
-  /* ---------------------------------- */
-
-  /* (Optional) list of keyword/double value pairs */
-  int    opt_grib_dbl_nentries;
-  char*  opt_grib_dbl_keyword[MAX_OPT_GRIB_ENTRIES];
-  int    opt_grib_dbl_update[MAX_OPT_GRIB_ENTRIES];
-  double opt_grib_dbl_val[MAX_OPT_GRIB_ENTRIES];
-  /* (Optional) list of keyword/integer value pairs */
-  int    opt_grib_int_nentries;
-  char*  opt_grib_int_keyword[MAX_OPT_GRIB_ENTRIES];
-  int    opt_grib_int_update[MAX_OPT_GRIB_ENTRIES];
-  int    opt_grib_int_val[MAX_OPT_GRIB_ENTRIES];
-#endif
+
+  int         subtypeID;   /* subtype ID for tile-related meta-data, currently for GRIB-API only. */
+
+  int                 opt_grib_nentries;       /* current no. key-value pairs            */
+  int                 opt_grib_kvpair_size;    /* current allocated size                 */
+  opt_key_val_pair_t *opt_grib_kvpair;         /* (optional) list of keyword/value pairs */
 }
 var_t;
 
@@ -137,6 +121,7 @@ typedef struct
   int         nvars;        /* number of variables                */
   int         ngrids;
   int         nzaxis;
+  int         nsubtypes;    /* no. of variable subtypes (e.g. sets of tiles) */
   long        ntsteps;
   int         taxisID;
   int         tableID;
@@ -145,6 +130,7 @@ typedef struct
   int         varsAllocated;
   int         gridIDs[MAX_GRIDS_PS];
   int         zaxisIDs[MAX_ZAXES_PS];
+  int         subtypeIDs[MAX_SUBTYPES_PS];
   var_t      *vars;
   cdi_atts_t  atts;
 }
@@ -159,6 +145,7 @@ const char *vlistInqVarStdnamePtr(int vlistID, int varID);
 const char *vlistInqVarUnitsPtr(int vlistID, int varID);
 void     vlistDestroyVarName(int vlistID, int varID);
 void     vlistDestroyVarLongname(int vlistID, int varID);
+void     vlistDestroyVarStdname(int vlistID, int varID);
 void     vlistDestroyVarUnits(int vlistID, int varID);
 void     vlistDefVarTsteptype(int vlistID, int varID, int tsteptype);
 int      vlistInqVarMissvalUsed(int vlistID, int varID);
@@ -183,6 +170,10 @@ int vlist_att_compare(vlist_t *a, int varIDA, vlist_t *b, int varIDB, int attnum
 void vlist_lock(int vlistID);
 void vlist_unlock(int vlistID);
 
+void resize_opt_grib_entries(var_t *var, int nentries);
+
+
+
 static inline void
 vlistAdd2GridIDs(vlist_t *vlistptr, int gridID)
 {
@@ -214,6 +205,24 @@ vlistAdd2ZaxisIDs(vlist_t *vlistptr, int zaxisID)
     }
 }
 
+static inline void
+vlistAdd2SubtypeIDs(vlist_t *vlistptr, int subtypeID)
+{
+  if ( subtypeID == CDI_UNDEFID ) return;
+
+  int index, nsubs = vlistptr->nsubtypes;
+  for ( index = 0; index < nsubs; index++ )
+    if (vlistptr->subtypeIDs[index] == subtypeID ) break;
+  if ( index == nsubs )
+    {
+      if (nsubs >= MAX_SUBTYPES_PS)
+        Error("Internal limit exceeded: more than %d subs.", MAX_SUBTYPES_PS);
+      ++(vlistptr->nsubtypes);
+      vlistptr->subtypeIDs[nsubs] = subtypeID;
+    }
+}
+
+
 
 #if  defined  (HAVE_LIBGRIB_API)
 extern int   cdiNAdditionalGRIBKeys;
diff --git a/libcdi/src/vlist_att.c b/libcdi/src/vlist_att.c
index 8419631..aea6650 100644
--- a/libcdi/src/vlist_att.c
+++ b/libcdi/src/vlist_att.c
@@ -12,6 +12,7 @@
 #include "cdi.h"
 #include "cdi_int.h"
 #include "vlist.h"
+#include "vlist_att.h"
 #include "error.h"
 #include "serialize.h"
 
@@ -71,7 +72,7 @@ cdi_att_t *new_att(cdi_atts_t *attsp, const char *name)
   slen = strlen(name);
   if ( slen > CDI_MAX_NAME ) slen = CDI_MAX_NAME;
 
-  attp->name = (char *) malloc(slen+1);
+  attp->name = (char *) Malloc(slen+1);
   memcpy(attp->name, name, slen+1);
   attp->namesz = slen;
   attp->xvalue = NULL;
@@ -91,7 +92,7 @@ void fill_att(cdi_att_t *attp, int indtype, int exdtype, size_t nelems, size_t x
 
   if ( xsz > 0 )
     {
-      attp->xvalue = xrealloc(attp->xvalue, xsz);
+      attp->xvalue = Realloc(attp->xvalue, xsz);
       memcpy(attp->xvalue, xvalue, xsz);
     }
 }
@@ -196,8 +197,8 @@ int vlistDelAtts(int vlistID, int varID)
   for ( attid = 0; attid < (int)attsp->nelems; attid++ )
     {
       attp = &(attsp->value[attid]);
-      if ( attp->name   ) free(attp->name);
-      if ( attp->xvalue ) free(attp->xvalue);
+      if ( attp->name   ) Free(attp->name);
+      if ( attp->xvalue ) Free(attp->xvalue);
     }
 
   attsp->nelems = 0;
@@ -569,7 +570,7 @@ vlistAttUnpack(int vlistID, int varID,
 
   serializeUnpack(buf, size, position,
                   tempbuf, vlist_att_nints, DATATYPE_INT, context);
-  char *attName = (char *)xmalloc((size_t)tempbuf[0] + 1);
+  char *attName = (char *) Malloc((size_t)tempbuf[0] + 1);
   serializeUnpack(buf, size, position, attName, tempbuf[0], DATATYPE_TXT, context);
   attName[tempbuf[0]] = '\0';
   int attVDt;
@@ -592,12 +593,12 @@ vlistAttUnpack(int vlistID, int varID,
     xabort("Unknown datatype encountered in attribute %s: %d\n",
            attName, tempbuf[2]);
   }
-  void *attData = (void *)xmalloc(elemSize * (size_t)tempbuf[3]);
+  void *attData = (void *) Malloc(elemSize * (size_t)tempbuf[3]);
   serializeUnpack(buf, size, position, attData, tempbuf[3], attVDt, context);
   vlist_def_att(tempbuf[2], tempbuf[1], vlistID, varID, attName,
                 (size_t)tempbuf[3], (size_t)tempbuf[3] * elemSize, attData);
-  free(attName);
-  free(attData);
+  Free(attName);
+  Free(attData);
 }
 
 void
diff --git a/libcdi/src/vlist_var.c b/libcdi/src/vlist_var.c
index 1217bc1..0d0d309 100644
--- a/libcdi/src/vlist_var.c
+++ b/libcdi/src/vlist_var.c
@@ -14,7 +14,6 @@
 #include "namespace.h"
 #include "serialize.h"
 #include "error.h"
-#include "proprietarySystemWorkarounds.h"
 
 #if  defined  (HAVE_LIBGRIB_API)
 #  include "file.h"
@@ -42,6 +41,7 @@ void vlistvarInitEntry(int vlistID, int varID)
   vlistptr->vars[varID].xyz           = 321;
   vlistptr->vars[varID].gridID        = CDI_UNDEFID;
   vlistptr->vars[varID].zaxisID       = CDI_UNDEFID;
+  vlistptr->vars[varID].subtypeID     = CDI_UNDEFID;
   vlistptr->vars[varID].instID        = CDI_UNDEFID;
   vlistptr->vars[varID].modelID       = CDI_UNDEFID;
   vlistptr->vars[varID].tableID       = CDI_UNDEFID;
@@ -64,26 +64,13 @@ void vlistvarInitEntry(int vlistID, int varID)
   vlistptr->vars[varID].validrange[1] = VALIDMISS;
   vlistptr->vars[varID].ensdata       = NULL;
   vlistptr->vars[varID].iorank        = CDI_UNDEFID;
-
-#if  defined  (HAVE_LIBGRIB_API)
-  /* ---------------------------------- */
-  /* Local change: 2013-01-28, FP (DWD) */
-  /* ---------------------------------- */
-
-  vlistptr->vars[varID].opt_grib_dbl_nentries = 0;
-  vlistptr->vars[varID].opt_grib_int_nentries = 0;
-  int i;
-  for (i=0; i<MAX_OPT_GRIB_ENTRIES; i++) {
-    vlistptr->vars[varID].opt_grib_int_val[i] =   0;
-    vlistptr->vars[varID].opt_grib_dbl_val[i] = 0.0;
-    vlistptr->vars[varID].opt_grib_int_update[i] = FALSE;
-    vlistptr->vars[varID].opt_grib_dbl_update[i] = FALSE;
-    vlistptr->vars[varID].opt_grib_int_keyword[i] = NULL;
-    vlistptr->vars[varID].opt_grib_dbl_keyword[i] = NULL;
-  } // for
-#endif
+  vlistptr->vars[varID].opt_grib_kvpair_size = 0;
+  vlistptr->vars[varID].opt_grib_kvpair      = NULL;
+  vlistptr->vars[varID].opt_grib_nentries    = 0;
 }
 
+
+
 static
 int vlistvarNewEntry(int vlistID)
 {
@@ -101,7 +88,7 @@ int vlistvarNewEntry(int vlistID)
   if ( ! vlistvarSize )
     {
       vlistvarSize = 2;
-      vlistvar = (var_t *)xmalloc((size_t)vlistvarSize * sizeof (var_t));
+      vlistvar = (var_t *) Malloc((size_t)vlistvarSize * sizeof (var_t));
       for (int i = 0; i < vlistvarSize; i++ )
 	vlistvar[i].isUsed = FALSE;
     }
@@ -115,14 +102,9 @@ int vlistvarNewEntry(int vlistID)
   */
   if ( varID == vlistvarSize )
     {
-      int i;
-
-      vlistvarSize = 2*vlistvarSize;
-      vlistvar = (var_t *)xrealloc(vlistvar,
-                                   (size_t)vlistvarSize * sizeof(var_t));
-      varID = vlistvarSize/2;
-
-      for ( i = varID; i < vlistvarSize; i++ )
+      vlistvar = (var_t *) Realloc(vlistvar,
+                                   (size_t)(vlistvarSize *= 2) * sizeof(var_t));
+      for ( int i = varID; i < vlistvarSize; i++ )
 	vlistvar[i].isUsed = FALSE;
     }
 
@@ -150,6 +132,36 @@ void vlistCheckVarID(const char *caller, int vlistID, int varID)
     Errorc("varID %d undefined!", varID);
 }
 
+
+int vlistDefVarTiles(int vlistID, int gridID, int zaxisID, int tsteptype, int tilesetID)
+{
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+  if ( CDI_Debug )
+    Message("gridID = %d  zaxisID = %d  tsteptype = %d", gridID, zaxisID, tsteptype);
+
+  int varID = vlistvarNewEntry(vlistID);
+
+  vlistptr->nvars++;
+  vlistptr->vars[varID].gridID    = gridID;
+  vlistptr->vars[varID].zaxisID   = zaxisID;
+  vlistptr->vars[varID].tsteptype = tsteptype;
+  vlistptr->vars[varID].subtypeID = tilesetID;
+
+  if ( tsteptype < 0 )
+    {
+      Message("Unexpected tstep type %d, set to TSTEP_INSTANT!", tsteptype);
+      vlistptr->vars[varID].tsteptype = TSTEP_INSTANT;
+    }
+
+  vlistAdd2GridIDs(vlistptr, gridID);
+  vlistAdd2ZaxisIDs(vlistptr, zaxisID);
+  vlistAdd2SubtypeIDs(vlistptr, tilesetID);
+
+  vlistptr->vars[varID].param = cdiEncodeParam(-(varID + 1), 255, 255);
+  reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
+  return (varID);
+}
+
 /*
 @Function  vlistDefVar
 @Title     Define a Variable
@@ -189,30 +201,8 @@ vlistDestroy(vlistID);
 */
 int vlistDefVar(int vlistID, int gridID, int zaxisID, int tsteptype)
 {
-  vlist_t *vlistptr = vlist_to_pointer(vlistID);
-  if ( CDI_Debug )
-    Message("gridID = %d  zaxisID = %d  tsteptype = %d", gridID, zaxisID, tsteptype);
-
-  int varID = vlistvarNewEntry(vlistID);
-
-  vlistptr->nvars++;
-
-  vlistptr->vars[varID].gridID  = gridID;
-  vlistptr->vars[varID].zaxisID = zaxisID;
-  vlistptr->vars[varID].tsteptype = tsteptype;
-
-  if ( tsteptype < 0 )
-    {
-      Message("Unexpected tstep type %d, set to TSTEP_INSTANT!", tsteptype);
-      vlistptr->vars[varID].tsteptype = TSTEP_INSTANT;
-    }
-
-  vlistAdd2GridIDs(vlistptr, gridID);
-  vlistAdd2ZaxisIDs(vlistptr, zaxisID);
-
-  vlistptr->vars[varID].param = cdiEncodeParam(-(varID + 1), 255, 255);
-  reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
-  return (varID);
+  /* call "vlistDefVarTiles" with a trivial tile index: */
+  return vlistDefVarTiles(vlistID, gridID, zaxisID, tsteptype, CDI_UNDEFID);
 }
 
 void
@@ -224,7 +214,7 @@ cdiVlistCreateVarLevInfo(vlist_t *vlistptr, int varID)
   size_t nlevs = (size_t)zaxisInqSize(zaxisID);
 
   vlistptr->vars[varID].levinfo
-    = (levinfo_t*)xmalloc((size_t)nlevs * sizeof(levinfo_t));
+    = (levinfo_t*) Malloc((size_t)nlevs * sizeof(levinfo_t));
 
   for (size_t levID = 0; levID < nlevs; levID++ )
     vlistptr->vars[varID].levinfo[levID] = DEFAULT_LEVINFO((int)levID);
@@ -356,6 +346,28 @@ int vlistInqVarZaxis(int vlistID, int varID)
   return (vlistptr->vars[varID].zaxisID);
 }
 
+
+/*
+ at Function  vlistInqVarSubtype
+ at Title     Get the Subtype ID of a Variable
+
+ at Description
+The function @func{vlistInqVarSubtype} returns the subtype ID of a variable.
+
+ at Result
+ at func{vlistInqVarSubtype} returns the subtype ID of the variable.
+
+ at EndFunction
+*/
+int vlistInqVarSubtype(int vlistID, int varID)
+{
+  vlist_t *vlistptr = vlist_to_pointer(vlistID);
+
+  vlistCheckVarID(__func__, vlistID, varID);
+  return (vlistptr->vars[varID].subtypeID);
+}
+
+
 /*
 @Function  vlistInqVarParam
 @Title     Get the parameter number of a Variable
@@ -408,7 +420,8 @@ int vlistInqVarCode(int vlistID, int varID)
   int param = vlistptr->vars[varID].param;
   int pdis, pcat, pnum;
   cdiDecodeParam(param, &pnum, &pcat, &pdis);
-  int code = pdis == 255 ? pnum : -varID-1;
+  int code = pnum;
+  if ( pdis != 255 ) code = -varID-1; // GRIB2 Parameter
 
   if ( code < 0 && vlistptr->vars[varID].tableID != -1 && vlistptr->vars[varID].name != NULL )
     {
@@ -517,11 +530,11 @@ void vlistInqVarName(int vlistID, int varID, char *name)
     @Item  vlistID  Variable list ID, from a previous call to @fref{vlistCreate} or @fref{streamInqVlist}.
     @Item  varID    Variable identifier.
 
- at Return A pointer to a malloc'ed string. Must be cleaned up with free().
+ at Return A pointer to a malloc'ed string. Must be cleaned up with Free().
 
 @Description
 This is the buffer overflow immune version of vlistInqVarName().
-The memory for the returned string is allocated to fit the string via malloc().
+The memory for the returned string is allocated to fit the string via Malloc().
 
 @EndFunction
 */
@@ -532,23 +545,31 @@ char* vlistCopyVarName(int vlistId, int varId)
 
   //If a name is set in the variable description, use that.
   const char* name = vlistptr->vars[varId].name;
-  if(name) return myStrDup(name);
+  if(name) return strdup(name);
 
   //Otherwise we check if we should use the table of parameter descriptions.
   int param = vlistptr->vars[varId].param;
   int discipline, category, number;
   cdiDecodeParam(param, &number, &category, &discipline);
+  char *result = NULL;
   if(discipline == 255)
     {
       int tableId = vlistptr->vars[varId].tableID;
-      if(( name = tableInqParNamePtr(tableId, number) )) return myStrDup(name);
-
-      //No luck, fall back to outputting a name of the format "var<num>".
-      return myAsprintf("var%d", number);
+      if(( name = tableInqParNamePtr(tableId, number) ))
+        result = strdup(name);
+      {
+        //No luck, fall back to outputting a name of the format "var<num>".
+        result = (char *) Malloc(3 + 3 * sizeof (int) * CHAR_BIT / 8 + 2);
+        sprintf(result, "var%d", number);
+      }
+    }
+  else
+    {
+      result = (char *) Malloc(5 + 2 + 3 * (3 * sizeof (int) * CHAR_BIT + 1) + 1);
+      sprintf(result, "param%d.%d.%d", number, category, discipline);
     }
-
   //Finally, we fall back to outputting a name of the format "param<num>.<cat>.<dis>".
-  return myAsprintf("param%d.%d.%d", number, category, discipline);
+  return result;
 }
 
 /*
@@ -891,7 +912,7 @@ void vlistDefVarName(int vlistID, int varID, const char *name)
     {
       if ( vlistptr->vars[varID].name )
 	{
-	  free(vlistptr->vars[varID].name);
+	  Free(vlistptr->vars[varID].name);
 	  vlistptr->vars[varID].name = NULL;
 	}
 
@@ -925,7 +946,7 @@ void vlistDefVarLongname(int vlistID, int varID, const char *longname)
     {
       if ( vlistptr->vars[varID].longname )
 	{
-	  free(vlistptr->vars[varID].longname);
+	  Free(vlistptr->vars[varID].longname);
 	  vlistptr->vars[varID].longname = 0;
 	}
 
@@ -959,7 +980,7 @@ void vlistDefVarStdname(int vlistID, int varID, const char *stdname)
     {
       if ( vlistptr->vars[varID].stdname )
 	{
-	  free(vlistptr->vars[varID].stdname);
+	  Free(vlistptr->vars[varID].stdname);
 	  vlistptr->vars[varID].stdname = 0;
 	}
 
@@ -993,7 +1014,7 @@ void vlistDefVarUnits(int vlistID, int varID, const char *units)
     {
       if ( vlistptr->vars[varID].units )
 	{
-	  free(vlistptr->vars[varID].units);
+	  Free(vlistptr->vars[varID].units);
 	  vlistptr->vars[varID].units = 0;
 	}
 
@@ -1078,7 +1099,7 @@ void vlistDefVarExtra(int vlistID, int varID, const char *extra)
     {
       if ( vlistptr->vars[varID].extra )
 	{
-	  free(vlistptr->vars[varID].extra);
+	  Free(vlistptr->vars[varID].extra);
 	  vlistptr->vars[varID].extra = NULL;
 	}
 
@@ -1297,7 +1318,7 @@ void vlistDestroyVarName(int vlistID, int varID)
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
   if ( vlistptr->vars[varID].name )
     {
-      free(vlistptr->vars[varID].name);
+      Free(vlistptr->vars[varID].name);
       vlistptr->vars[varID].name = NULL;
       reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
     }
@@ -1310,7 +1331,7 @@ void vlistDestroyVarLongname(int vlistID, int varID)
 
   if ( vlistptr->vars[varID].longname )
     {
-      free(vlistptr->vars[varID].longname);
+      Free(vlistptr->vars[varID].longname);
       vlistptr->vars[varID].longname = NULL;
       reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
     }
@@ -1323,7 +1344,7 @@ void vlistDestroyVarStdname(int vlistID, int varID)
 
   if ( vlistptr->vars[varID].stdname )
     {
-      free(vlistptr->vars[varID].stdname);
+      Free(vlistptr->vars[varID].stdname);
       vlistptr->vars[varID].stdname = NULL;
       reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
     }
@@ -1336,7 +1357,7 @@ void vlistDestroyVarUnits(int vlistID, int varID)
 
   if ( vlistptr->vars[varID].units )
     {
-      free(vlistptr->vars[varID].units);
+      Free(vlistptr->vars[varID].units);
       vlistptr->vars[varID].units = NULL;
       reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
     }
@@ -1709,7 +1730,7 @@ void vlistDefVarEnsemble(int vlistID, int varID, int ensID, int ensCount, int fo
 
   if ( vlistptr->vars[varID].ensdata == NULL )
     vlistptr->vars[varID].ensdata
-      = (ensinfo_t *)xmalloc( sizeof( ensinfo_t ) );
+      = (ensinfo_t *) Malloc( sizeof( ensinfo_t ) );
 
   vlistptr->vars[varID].ensdata->ens_index          = ensID;
   vlistptr->vars[varID].ensdata->ens_count          = ensCount;
@@ -1737,42 +1758,61 @@ int vlistInqVarEnsemble( int vlistID, int varID, int *ensID, int *ensCount, int
   return (status);
 }
 
-/* ---------------------------------- */
-/* Local change: 2013-01-28, FP (DWD) */
-/* ---------------------------------- */
+
 
 /* vlistDefVarIntKey: Set an arbitrary keyword/integer value pair for GRIB API */
 void vlistDefVarIntKey(int vlistID, int varID, const char *name, int value)
 {
 #if  defined  (HAVE_LIBGRIB_API)
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
+  if (vlistptr == NULL)  Error("Internal error!");
   int idx;
 
-  if ( !vlistptr->locked )
+  if ( vlistptr->locked != 0 )
     Error("User defined vlist object (vlistID=%d) isn't allowed!\n"
           "Need a CDI internal vlist object from streamInqVlist(streamID).", vlistID);
 
-  for ( idx=0; idx<vlistptr->vars[varID].opt_grib_int_nentries; idx++)
-    if ( strcmp(name, vlistptr->vars[varID].opt_grib_int_keyword[idx]) == 0 ) break;
+  for ( idx=0; idx<vlistptr->vars[varID].opt_grib_nentries; idx++)
+    if ( (strcmp(name, vlistptr->vars[varID].opt_grib_kvpair[idx].keyword) == 0 ) &&
+         (vlistptr->vars[varID].opt_grib_kvpair[idx].data_type == t_int) )  break;
 
-  if ( idx < vlistptr->vars[varID].opt_grib_int_nentries )
+  if ( idx < vlistptr->vars[varID].opt_grib_nentries )
     {
-      vlistptr->vars[varID].opt_grib_int_val[idx] = value;
-      vlistptr->vars[varID].opt_grib_int_update[idx] = TRUE;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].int_val = value;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].update  = TRUE;
     }
   else
     {
-      idx = vlistptr->vars[varID].opt_grib_int_nentries;
-      vlistptr->vars[varID].opt_grib_int_nentries++;
-      if ( idx >= MAX_OPT_GRIB_ENTRIES ) Error("Too many optional keyword/integer value pairs!");
-      vlistptr->vars[varID].opt_grib_int_val[idx] = value;
-      vlistptr->vars[varID].opt_grib_int_update[idx] = TRUE;
+      resize_opt_grib_entries(&vlistptr->vars[varID], vlistptr->vars[varID].opt_grib_nentries+1);
+      vlistptr->vars[varID].opt_grib_nentries += 1;
+      idx = vlistptr->vars[varID].opt_grib_nentries -1;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].data_type   = t_int;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].int_val     = value;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].update      = TRUE;
       if ( name )
-        vlistptr->vars[varID].opt_grib_int_keyword[idx] = strdupx(name);
+        vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = strdupx(name);
       else
         Error("Internal error, name undefined!");
     }
 
+  if ( CDI_Debug )
+    {
+      Message("define additional GRIB2 key \"%s\" (integer): %d", name, value);
+      Message("total list of registered, additional GRIB2 keys (total: %d):",
+              vlistptr->vars[varID].opt_grib_nentries);
+      for ( idx=0; idx<vlistptr->vars[varID].opt_grib_nentries; idx++)
+        if (vlistptr->vars[varID].opt_grib_kvpair[idx].data_type == t_int)
+          Message("%s -> integer %d",
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].keyword,
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].int_val);
+        else if (vlistptr->vars[varID].opt_grib_kvpair[idx].data_type == t_double)
+          Message("%s -> double %d",
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].keyword,
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].dbl_val);
+        else
+          Message("%s -> unknown", vlistptr->vars[varID].opt_grib_kvpair[idx].keyword);
+    }
+
   reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
 #else
   (void)vlistID;
@@ -1787,33 +1827,54 @@ void vlistDefVarDblKey(int vlistID, int varID, const char *name, double value)
 {
 #if  defined  (HAVE_LIBGRIB_API)
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
+  if (vlistptr == NULL)  Error("Internal error!");
   int idx;
 
-  if ( !vlistptr->locked )
+  if ( vlistptr->locked != 0 )
     Error("User defined vlist object (vlistID=%d) isn't allowed!\n"
           "Need a CDI internal vlist object from streamInqVlist(streamID).", vlistID);
 
-  for ( idx=0; idx<vlistptr->vars[varID].opt_grib_dbl_nentries; idx++)
-    if ( strcmp(name, vlistptr->vars[varID].opt_grib_dbl_keyword[idx]) == 0 ) break;
+  for ( idx=0; idx<vlistptr->vars[varID].opt_grib_nentries; idx++)
+    if ( (strcmp(name, vlistptr->vars[varID].opt_grib_kvpair[idx].keyword) == 0 ) &&
+         (vlistptr->vars[varID].opt_grib_kvpair[idx].data_type == t_double) )  break;
 
-  if ( idx < vlistptr->vars[varID].opt_grib_dbl_nentries )
+  if ( idx < vlistptr->vars[varID].opt_grib_nentries )
     {
-      vlistptr->vars[varID].opt_grib_dbl_val[idx] = value;
-      vlistptr->vars[varID].opt_grib_dbl_update[idx] = TRUE;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].dbl_val = value;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].update  = TRUE;
     }
   else
     {
-      idx = vlistptr->vars[varID].opt_grib_dbl_nentries;
-      vlistptr->vars[varID].opt_grib_dbl_nentries++;
-      if ( idx >= MAX_OPT_GRIB_ENTRIES ) Error("Too many optional keyword/double value pairs!");
-      vlistptr->vars[varID].opt_grib_dbl_val[idx] = value;
-      vlistptr->vars[varID].opt_grib_dbl_update[idx] = TRUE;
+      resize_opt_grib_entries(&vlistptr->vars[varID], vlistptr->vars[varID].opt_grib_nentries+1);
+      vlistptr->vars[varID].opt_grib_nentries += 1;
+      idx = vlistptr->vars[varID].opt_grib_nentries - 1;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].data_type = t_double;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].dbl_val   = value;
+      vlistptr->vars[varID].opt_grib_kvpair[idx].update    = TRUE;
       if ( name )
-        vlistptr->vars[varID].opt_grib_dbl_keyword[idx] = strdupx(name);
+        vlistptr->vars[varID].opt_grib_kvpair[idx].keyword = strdupx(name);
       else
         Error("Internal error, name undefined!");
     }
 
+  if ( CDI_Debug )
+    {
+      Message("define additional GRIB2 key \"%s\" (double): %d", name, value);
+      Message("total list of registered, additional GRIB2 keys (total: %d):",
+              vlistptr->vars[varID].opt_grib_nentries);
+      for ( idx=0; idx<vlistptr->vars[varID].opt_grib_nentries; idx++)
+        if (vlistptr->vars[varID].opt_grib_kvpair[idx].data_type == t_int)
+          Message("%s -> integer %d",
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].keyword,
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].int_val);
+        else if (vlistptr->vars[varID].opt_grib_kvpair[idx].data_type == t_double)
+          Message("%s -> double %d",
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].keyword,
+                  vlistptr->vars[varID].opt_grib_kvpair[idx].dbl_val);
+        else
+          Message("%s -> unknown", vlistptr->vars[varID].opt_grib_kvpair[idx].keyword);
+    }
+
   reshSetStatus(vlistID, &vlistOps, RESH_DESYNC_IN_USE);
 #else
   (void)vlistID;
@@ -1828,7 +1889,7 @@ void vlistDefVarDblKey(int vlistID, int varID, const char *name, double value)
 void cdiClearAdditionalKeys()
 {
 #if  defined  (HAVE_LIBGRIB_API)
-  for (int i=0; i<cdiNAdditionalGRIBKeys; i++)  free(cdiAdditionalGRIBKeys[i]);
+  for (int i=0; i<cdiNAdditionalGRIBKeys; i++)  Free(cdiAdditionalGRIBKeys[i]);
   cdiNAdditionalGRIBKeys = 0;
 #endif
 }
@@ -1856,15 +1917,9 @@ int vlistHasVarKey(int vlistID, int varID, const char* name)
   /* check if the GRIB key was previously read and is stored */
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
 
-  for (int i=0; i<vlistptr->vars[varID].opt_grib_dbl_nentries; i++)
+  for (int i=0; i<vlistptr->vars[varID].opt_grib_nentries; i++)
     {
-      if ( strcmp(name, vlistptr->vars[varID].opt_grib_dbl_keyword[i]) == 0 )
-	return 1;
-    }
-
-  for (int i=0; i<vlistptr->vars[varID].opt_grib_int_nentries; i++)
-    {
-      if ( strcmp(name, vlistptr->vars[varID].opt_grib_int_keyword[i]) == 0 )
+      if ( strcmp(name, vlistptr->vars[varID].opt_grib_kvpair[i].keyword) == 0 )
 	return 1;
     }
 #else
@@ -1883,9 +1938,14 @@ double vlistInqVarDblKey(int vlistID, int varID, const char* name)
   /* check if the GRIB key was previously read and is stored in "opt_grib_dbl_val" */
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
 
-  for (int i=0; i<vlistptr->vars[varID].opt_grib_dbl_nentries; i++)
-    if ( strcmp(name, vlistptr->vars[varID].opt_grib_dbl_keyword[i]) == 0 )
-      return vlistptr->vars[varID].opt_grib_dbl_val[i];
+  for (int i=0; i<vlistptr->vars[varID].opt_grib_nentries; i++)
+    {
+      int isub = subtypeInqActiveIndex(vlistptr->vars[varID].subtypeID);
+      if ( (strcmp(name, vlistptr->vars[varID].opt_grib_kvpair[i].keyword) == 0 ) &&
+           (vlistptr->vars[varID].opt_grib_kvpair[i].data_type == t_double)       &&
+           (vlistptr->vars[varID].opt_grib_kvpair[i].subtype_index == isub) )
+        return vlistptr->vars[varID].opt_grib_kvpair[i].dbl_val;
+    }
 #else
   (void)vlistID;
   (void)varID;
@@ -1903,9 +1963,15 @@ int vlistInqVarIntKey(int vlistID, int varID, const char* name)
   /* check if the GRIB key was previously read and is stored in "opt_grib_int_val" */
   vlist_t *vlistptr = vlist_to_pointer(vlistID);
 
-  for (int i=0; i<vlistptr->vars[varID].opt_grib_int_nentries; i++)
-    if ( strcmp(name, vlistptr->vars[varID].opt_grib_int_keyword[i]) == 0 )
-      return vlistptr->vars[varID].opt_grib_int_val[i];
+  for (int i=0; i<vlistptr->vars[varID].opt_grib_nentries; i++)
+    {
+      int isub = subtypeInqActiveIndex(vlistptr->vars[varID].subtypeID);
+      if ( (strcmp(name, vlistptr->vars[varID].opt_grib_kvpair[i].keyword) == 0 ) &&
+           (vlistptr->vars[varID].opt_grib_kvpair[i].data_type == t_int)          &&
+           (vlistptr->vars[varID].opt_grib_kvpair[i].subtype_index == isub) )
+        return vlistptr->vars[varID].opt_grib_kvpair[i].int_val;
+    }
+
 #else
   (void)vlistID;
   (void)varID;
@@ -1987,7 +2053,7 @@ int vlistVarCompare(vlist_t *a, int varIDA, vlist_t *b, int varIDB)
 
 
 enum {
-  vlistvar_nints = 20,
+  vlistvar_nints = 21,
   vlistvar_ndbls = 3,
 };
 
@@ -2004,6 +2070,8 @@ int vlistVarGetPackSize(vlist_t *p, int varID, void *context)
     varsize += serializeGetSize((int)strlen(var->stdname), DATATYPE_TXT, context);
   if (var->units)
     varsize += serializeGetSize((int)strlen(var->units), DATATYPE_TXT, context);
+  if (var->extra)
+    varsize += serializeGetSize((int)strlen(var->extra), DATATYPE_TXT, context);
   varsize += serializeGetSize(4 * zaxisInqSize(var->zaxisID),
                               DATATYPE_INT, context);
   varsize += vlistAttsGetSize(p, varID, context);
@@ -2015,7 +2083,8 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position,
 {
   double dtempbuf[vlistvar_ndbls];
   var_t *var = p->vars + varID;
-  int tempbuf[vlistvar_nints], namesz, longnamesz, stdnamesz, unitssz;
+  int tempbuf[vlistvar_nints], namesz, longnamesz, stdnamesz, unitssz,
+    extralen;
 
   tempbuf[0] = var->flag;
   tempbuf[1] = var->gridID;
@@ -2038,6 +2107,7 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position,
   int nlevs = var->levinfo ? zaxisInqSize(var->zaxisID) : 0;
   tempbuf[18] = nlevs;
   tempbuf[19] = var->iorank;
+  tempbuf[20] = extralen = var->extra?(int)strlen(var->extra):0;
   dtempbuf[0] = var->missval;
   dtempbuf[1] = var->scalefactor;
   dtempbuf[2] = var->addoffset;
@@ -2056,6 +2126,9 @@ void vlistVarPack(vlist_t *p, int varID, char * buf, int size, int *position,
   if (unitssz)
     serializePack(var->units, unitssz, DATATYPE_TXT,
                   buf, size, position, context);
+  if (extralen)
+    serializePack(var->extra, extralen, DATATYPE_TXT,
+                  buf, size, position, context);
   if (nlevs)
     {
       int levbuf[nlevs][4];
@@ -2091,14 +2164,19 @@ void vlistVarUnpack(int vlistID, char * buf, int size, int *position,
   serializeUnpack(buf, size, position,
                   dtempbuf, vlistvar_ndbls, DATATYPE_FLT64, context);
 
+  /* ------------------------------------------- */
+  /* NOTE: Tile sets  currently not supported!!! */
+  /* ------------------------------------------- */
+
   int newvar = vlistDefVar ( vlistID,
 			 namespaceAdaptKey ( tempbuf[1], originNamespace ),
 			 namespaceAdaptKey ( tempbuf[2], originNamespace ),
 			 tempbuf[3]);
-  if (tempbuf[4] || tempbuf[5] || tempbuf[6] || tempbuf[7])
-    varname = (char *)xmalloc((size_t)imax(imax(imax(tempbuf[4],tempbuf[5]),
-                                                tempbuf[6]),
-                                           tempbuf[7]) + 1);
+  if (tempbuf[4] || tempbuf[5] || tempbuf[6] || tempbuf[7] || tempbuf[20])
+    varname = (char *)Malloc((size_t)imax(imax(imax(imax(tempbuf[4],
+                                                         tempbuf[5]),
+                                                    tempbuf[6]),
+                                               tempbuf[7]), tempbuf[20]) + 1);
   if (tempbuf[4])
   {
     serializeUnpack(buf, size, position,
@@ -2127,7 +2205,14 @@ void vlistVarUnpack(int vlistID, char * buf, int size, int *position,
     varname[tempbuf[7]] = '\0';
     vlistDefVarUnits(vlistID, newvar, varname);
   }
-  free(varname);
+  if (tempbuf[20])
+    {
+      serializeUnpack(buf, size, position,
+                      varname, tempbuf[20], DATATYPE_TXT, context);
+      varname[tempbuf[20]] = '\0';
+      vlistDefVarExtra(vlistID, newvar, varname);
+    }
+  Free(varname);
   vlistDefVarDatatype(vlistID, newvar, tempbuf[8]);
   vlistDefVarInstitut ( vlistID, newvar,
 			namespaceAdaptKey ( tempbuf[10], originNamespace ));
diff --git a/libcdi/src/zaxis.c b/libcdi/src/zaxis.c
index 641808b..d61a5b9 100644
--- a/libcdi/src/zaxis.c
+++ b/libcdi/src/zaxis.c
@@ -16,6 +16,7 @@
 #include "varscan.h"
 #include "namespace.h"
 #include "serialize.h"
+#include "zaxis.h"
 
 #define  LevelUp    1
 #define  LevelDown  2
@@ -23,10 +24,10 @@
 
 static const struct {
   unsigned char positive;   // 1: up;  2: down
-  char *name;
-  char *longname;
-  char *stdname;
-  char *units;
+  const char *name;
+  const char *longname;
+  const char *stdname;
+  const char *units;
 }
 ZaxistypeEntry[] = {
   { /*  0 */ 0, "sfc",               "surface",                "",               ""},
@@ -54,7 +55,7 @@ ZaxistypeEntry[] = {
   { /* 22 */ 0, "sedimentbottomta",  "sediment_bottom_ta",     "",               ""},
   { /* 23 */ 0, "sedimentbottomtw",  "sediment_bottom_tw",     "",               ""},
   { /* 24 */ 0, "mixlayer",          "mix_layer",              "",               ""},
-  { /* 25 */ 0, "height",            "generalized height",     "height",         ""},
+  { /* 25 */ 0, "height",            "generalized_height",     "height",         ""},
 };
 
 enum {
@@ -68,12 +69,14 @@ typedef struct {
   char     longname[CDI_MAX_NAME];
   char     stdname[CDI_MAX_NAME];
   char     units[CDI_MAX_NAME];
+  char     psname[CDI_MAX_NAME];
   double  *vals;
   double  *lbounds;
   double  *ubounds;
   double  *weights;
   int      self;
   int      prec;
+  int      scalar;
   int      type;
   int      ltype;    /* GRIB level type */
   int      ltype2;
@@ -87,14 +90,14 @@ typedef struct {
 }
 zaxis_t;
 
-static int zaxisCompareP(zaxis_t *z1, zaxis_t *z2);
+static int    zaxisCompareP    (zaxis_t *z1, zaxis_t *z2);
 static void   zaxisDestroyP    ( void * zaxisptr );
 static void   zaxisPrintP      ( void * zaxisptr, FILE * fp );
 static int    zaxisGetPackSize ( void * zaxisptr, void *context);
 static void   zaxisPack        ( void * zaxisptr, void * buffer, int size, int *pos, void *context);
 static int    zaxisTxCode      ( void );
 
-const resOps zaxisOps = {
+static const resOps zaxisOps = {
   (int (*)(void *, void *))zaxisCompareP,
   zaxisDestroyP,
   zaxisPrintP,
@@ -103,6 +106,11 @@ const resOps zaxisOps = {
   zaxisTxCode
 };
 
+const resOps *getZaxisOps(void)
+{
+  return &zaxisOps;
+}
+
 static int  ZAXIS_Debug = 0;   /* If set to 1, debugging */
 
 void zaxisGetTypeDescription(int zaxisType, int* outPositive, const char** outName, const char** outLongName, const char** outStdName, const char** outUnit)
@@ -133,6 +141,7 @@ void zaxisDefaultValue(zaxis_t *zaxisptr)
   zaxisptr->longname[0] = 0;
   zaxisptr->stdname[0]  = 0;
   zaxisptr->units[0]    = 0;
+  zaxisptr->psname[0]   = 0;
   zaxisptr->vals        = NULL;
   zaxisptr->ubounds     = NULL;
   zaxisptr->lbounds     = NULL;
@@ -141,6 +150,7 @@ void zaxisDefaultValue(zaxis_t *zaxisptr)
   zaxisptr->ltype       = 0;
   zaxisptr->ltype2      = -1;
   zaxisptr->positive    = 0;
+  zaxisptr->scalar      = 0;
   zaxisptr->direction   = 0;
   zaxisptr->prec        = 0;
   zaxisptr->size        = 0;
@@ -155,7 +165,7 @@ void zaxisDefaultValue(zaxis_t *zaxisptr)
 static
 zaxis_t *zaxisNewEntry(int id)
 {
-  zaxis_t *zaxisptr = (zaxis_t *)xmalloc(sizeof(zaxis_t));
+  zaxis_t *zaxisptr = (zaxis_t *) Malloc(sizeof(zaxis_t));
 
   zaxisDefaultValue ( zaxisptr );
 
@@ -170,6 +180,13 @@ zaxis_t *zaxisNewEntry(int id)
   return (zaxisptr);
 }
 
+static inline zaxis_t *
+zaxisID2Ptr(int id)
+{
+  return (zaxis_t *)reshGetVal(id, &zaxisOps);
+}
+
+
 static
 void zaxisInit(void)
 {
@@ -197,6 +214,7 @@ unsigned cdiZaxisCount(void)
   return reshCountType(&zaxisOps);
 }
 
+
 static int
 zaxisCreate_(int zaxistype, int size, int id)
 {
@@ -220,7 +238,7 @@ zaxisCreate_(int zaxistype, int size, int id)
   zaxisptr->positive = ZaxistypeEntry[zaxistype].positive;
 
   double *vals = zaxisptr->vals
-    = (double *)xmalloc((size_t)size * sizeof(double));
+    = (double *) Malloc((size_t)size * sizeof(double));
 
   for ( int ilev = 0; ilev < size; ilev++ )
     vals[ilev] = 0.0;
@@ -281,19 +299,17 @@ int zaxisCreate(int zaxistype, int size)
 
 static void zaxisDestroyKernel( zaxis_t * zaxisptr )
 {
-  int id;
-
   xassert ( zaxisptr );
 
-  id = zaxisptr->self;
+  int id = zaxisptr->self;
 
-  if ( zaxisptr->vals )    free ( zaxisptr->vals );
-  if ( zaxisptr->lbounds ) free ( zaxisptr->lbounds );
-  if ( zaxisptr->ubounds ) free ( zaxisptr->ubounds );
-  if ( zaxisptr->weights ) free ( zaxisptr->weights );
-  if ( zaxisptr->vct )     free ( zaxisptr->vct );
+  if ( zaxisptr->vals )    Free( zaxisptr->vals );
+  if ( zaxisptr->lbounds ) Free( zaxisptr->lbounds );
+  if ( zaxisptr->ubounds ) Free( zaxisptr->ubounds );
+  if ( zaxisptr->weights ) Free( zaxisptr->weights );
+  if ( zaxisptr->vct )     Free( zaxisptr->vct );
 
-  free ( zaxisptr );
+  Free( zaxisptr );
 
   reshRemove ( id, &zaxisOps );
 }
@@ -310,7 +326,7 @@ static void zaxisDestroyKernel( zaxis_t * zaxisptr )
 */
 void zaxisDestroy(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   zaxisDestroyKernel ( zaxisptr );
 }
@@ -323,15 +339,11 @@ void zaxisDestroyP ( void * zaxisptr )
 }
 
 
-char *zaxisNamePtr(int zaxistype)
+const char *zaxisNamePtr(int zaxistype)
 {
-  char *name;
-
-  if ( zaxistype >= 0 && zaxistype < CDI_NumZaxistype )
-    name = ZaxistypeEntry[zaxistype].longname;
-  else
-    name = ZaxistypeEntry[ZAXIS_GENERIC].longname;
-
+  const char *name = (zaxistype >= 0 && zaxistype < CDI_NumZaxistype)
+    ? ZaxistypeEntry[zaxistype].longname
+    : ZaxistypeEntry[ZAXIS_GENERIC].longname;
   return (name);
 }
 
@@ -357,7 +369,7 @@ The function @func{zaxisDefName} defines the name of a Z-axis.
 */
 void zaxisDefName(int zaxisID, const char *name)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( name )
     {
@@ -383,7 +395,7 @@ The function @func{zaxisDefLongname} defines the longname of a Z-axis.
 */
 void zaxisDefLongname(int zaxisID, const char *longname)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( longname )
     {
@@ -409,7 +421,7 @@ The function @func{zaxisDefUnits} defines the units of a Z-axis.
 */
 void zaxisDefUnits(int zaxisID, const char *units)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( units )
     {
@@ -419,6 +431,19 @@ void zaxisDefUnits(int zaxisID, const char *units)
     }
 }
 
+
+void zaxisDefPsName(int zaxisID, const char *psname)
+{
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+
+  if ( psname )
+    {
+      strncpy(zaxisptr->psname, psname, CDI_MAX_NAME - 1);
+      zaxisptr->name[CDI_MAX_NAME - 1] = '\0';
+      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
+    }
+}
+
 /*
 @Function  zaxisInqName
 @Title     Get the name of a Z-axis
@@ -440,7 +465,7 @@ The function @func{zaxisInqName} returns the name of a Z-axis.
 */
 void zaxisInqName(int zaxisID, char *name)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   strcpy(name, zaxisptr->name);
 }
 
@@ -465,7 +490,7 @@ The function @func{zaxisInqLongname} returns the longname of a Z-axis.
 */
 void zaxisInqLongname(int zaxisID, char *longname)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   strcpy(longname, zaxisptr->longname);
 }
 
@@ -490,21 +515,28 @@ The function @func{zaxisInqUnits} returns the units of a Z-axis.
 */
 void zaxisInqUnits(int zaxisID, char *units)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   strcpy(units, zaxisptr->units);
 }
 
 
 void zaxisInqStdname(int zaxisID, char *stdname)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   strcpy(stdname, zaxisptr->stdname);
 }
 
 
+void zaxisInqPsName(int zaxisID, char *psname)
+{
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  strcpy(psname, zaxisptr->psname);
+}
+
+
 void zaxisDefPrec(int zaxisID, int prec)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if (zaxisptr->prec != prec)
     {
@@ -516,15 +548,14 @@ void zaxisDefPrec(int zaxisID, int prec)
 
 int zaxisInqPrec(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   return (zaxisptr->prec);
 }
 
 
 void zaxisDefPositive(int zaxisID, int positive)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if (zaxisptr->positive != positive)
     {
@@ -536,15 +567,29 @@ void zaxisDefPositive(int zaxisID, int positive)
 
 int zaxisInqPositive(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  return zaxisptr->positive;
+}
+
+
+void zaxisDefScalar(int zaxisID)
+{
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
-  return (zaxisptr->positive);
+  zaxisptr->scalar = 1;
+  reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
+}
+
+int zaxisInqScalar(int zaxisID)
+{
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  return zaxisptr->scalar;
 }
 
 
 void zaxisDefLtype(int zaxisID, int ltype)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if (zaxisptr->ltype != ltype)
     {
@@ -556,15 +601,14 @@ void zaxisDefLtype(int zaxisID, int ltype)
 
 int zaxisInqLtype(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
-  return (zaxisptr->ltype);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  return zaxisptr->ltype;
 }
 
 
 void zaxisDefLtype2(int zaxisID, int ltype2)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if (zaxisptr->ltype2 != ltype2)
     {
@@ -576,9 +620,8 @@ void zaxisDefLtype2(int zaxisID, int ltype2)
 
 int zaxisInqLtype2(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
-  return (zaxisptr->ltype2);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  return zaxisptr->ltype2;
 }
 
 /*
@@ -597,7 +640,7 @@ The function @func{zaxisDefLevels} defines the levels of a Z-axis.
 */
 void zaxisDefLevels(int zaxisID, const double *levels)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   int size = zaxisptr->size;
 
@@ -625,8 +668,7 @@ The function @func{zaxisDefLevel} defines one level of a Z-axis.
 */
 void zaxisDefLevel(int zaxisID, int levelID, double level)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   if ( levelID >= 0 && levelID < zaxisptr->size )
     zaxisptr->vals[levelID] = level;
   reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
@@ -635,8 +677,7 @@ void zaxisDefLevel(int zaxisID, int levelID, double level)
 
 void zaxisDefNlevRef(int zaxisID, const int nhlev)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   if (zaxisptr->nhlev != nhlev)
     {
       zaxisptr->nhlev = nhlev;
@@ -647,9 +688,8 @@ void zaxisDefNlevRef(int zaxisID, const int nhlev)
 
 int zaxisInqNlevRef(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
-  return (zaxisptr->nhlev);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  return zaxisptr->nhlev;
 }
 
 /*
@@ -668,8 +708,7 @@ The function @func{zaxisDefNumber} defines the reference number for a generalize
 */
 void zaxisDefNumber(int zaxisID, const int number)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   if (zaxisptr->number != number)
     {
       zaxisptr->number = number;
@@ -694,9 +733,8 @@ The function @func{zaxisInqNumber} returns the reference number to a generalized
 */
 int zaxisInqNumber(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
-  return (zaxisptr->number);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  return zaxisptr->number;
 }
 
 /*
@@ -715,8 +753,7 @@ The function @func{zaxisDefUUID} defines the UUID for a generalized  Z-axis.
 */
 void zaxisDefUUID(int zaxisID, const unsigned char uuid[CDI_UUID_SIZE])
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   memcpy(zaxisptr->uuid, uuid, CDI_UUID_SIZE);
   reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
 }
@@ -739,7 +776,7 @@ The function @func{zaxisInqUUID} returns the UUID to a generalized Z-axis.
 */
 void zaxisInqUUID(int zaxisID, unsigned char uuid[CDI_UUID_SIZE])
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   memcpy(uuid, zaxisptr->uuid, CDI_UUID_SIZE);
 }
 
@@ -762,44 +799,41 @@ The function @func{zaxisInqLevel} returns one level of a Z-axis.
 double zaxisInqLevel(int zaxisID, int levelID)
 {
   double level = 0;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( levelID >= 0 && levelID < zaxisptr->size )
     level = zaxisptr->vals[levelID];
 
-  return (level);
+  return level;
 }
 
 double zaxisInqLbound(int zaxisID, int index)
 {
   double level = 0;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
-  if ( zaxisptr->lbounds )
-    if ( index >= 0 && index < zaxisptr->size )
+  if ( zaxisptr->lbounds && ( index >= 0 && index < zaxisptr->size ) )
       level = zaxisptr->lbounds[index];
 
-  return (level);
+  return level;
 }
 
 
 double zaxisInqUbound(int zaxisID, int index)
 {
   double level = 0;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-
-  if ( zaxisptr->ubounds )
-    if ( index >= 0 && index < zaxisptr->size )
-      level = zaxisptr->ubounds[index];
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
-  return (level);
+  if ( zaxisptr->ubounds && ( index >= 0 && index < zaxisptr->size ) )
+    level = zaxisptr->ubounds[index];
+  return level;
 }
 
 
 const double *zaxisInqLevelsPtr(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
-  return ( zaxisptr->vals );
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
+  return zaxisptr->vals;
 }
 
 /*
@@ -821,7 +855,7 @@ The function @func{zaxisInqLevels} returns all levels of a Z-axis.
 */
 void zaxisInqLevels(int zaxisID, double *levels)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   int size = zaxisptr->size;
   for (int i = 0; i < size; i++ )
     levels[i] =  zaxisptr->vals[i];
@@ -831,7 +865,7 @@ void zaxisInqLevels(int zaxisID, double *levels)
 int zaxisInqLbounds(int zaxisID, double *lbounds)
 {
   int size = 0;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( zaxisptr->lbounds )
     {
@@ -849,7 +883,7 @@ int zaxisInqLbounds(int zaxisID, double *lbounds)
 int zaxisInqUbounds(int zaxisID, double *ubounds)
 {
   int size = 0;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( zaxisptr->ubounds )
     {
@@ -867,7 +901,7 @@ int zaxisInqUbounds(int zaxisID, double *ubounds)
 int zaxisInqWeights(int zaxisID, double *weights)
 {
   int size = 0;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( zaxisptr->weights )
     {
@@ -885,7 +919,7 @@ int zaxisInqWeights(int zaxisID, double *weights)
 int zaxisInqLevelID(int zaxisID, double level)
 {
   int levelID = CDI_UNDEFID;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   int size = zaxisptr->size;
   for ( int i = 0; i < size; i++ )
@@ -895,7 +929,7 @@ int zaxisInqLevelID(int zaxisID, double level)
         break;
       }
 
-  return (levelID);
+  return levelID;
 }
 
 /*
@@ -925,7 +959,7 @@ The valid CDI Z-axis types are @func{ZAXIS_GENERIC}, @func{ZAXIS_SURFACE},
 */
 int zaxisInqType(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   return (zaxisptr->type);
 }
 
@@ -947,14 +981,14 @@ The function @func{zaxisInqSize} returns the size of a Z-axis.
 */
 int zaxisInqSize(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   return (zaxisptr->size);
 }
 
 
 void cdiCheckZaxis(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   if ( zaxisInqType(zaxisID) == ZAXIS_GENERIC )
     {
@@ -990,45 +1024,43 @@ void cdiCheckZaxis(int zaxisID)
 
 void zaxisDefVct(int zaxisID, int size, const double *vct)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
-  if ( zaxisptr->vct == 0 )
+  if ( zaxisptr->vct == 0 || zaxisptr->vctsize != size )
     {
       zaxisptr->vctsize = size;
-      zaxisptr->vct = (double *)xmalloc((size_t)size * sizeof (double));
-      memcpy(zaxisptr->vct, vct, (size_t)size * sizeof (double));
-      reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
+      zaxisptr->vct = (double *) Realloc(zaxisptr->vct, (size_t)size*sizeof(double));
     }
-  else
-    if ( zaxisptr->vctsize != size )
-      Warning("VCT was already defined");
+
+  memcpy(zaxisptr->vct, vct, (size_t)size*sizeof(double));
+  reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
 }
 
 
 void zaxisInqVct(int zaxisID, double *vct)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   memcpy(vct, zaxisptr->vct, (size_t)zaxisptr->vctsize * sizeof (double));
 }
 
 
 int zaxisInqVctSize(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   return (zaxisptr->vctsize);
 }
 
 
 const double *zaxisInqVctPtr(int zaxisID)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   return (zaxisptr->vct);
 }
 
 
 void zaxisDefLbounds(int zaxisID, const double *lbounds)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   size_t size = (size_t)zaxisptr->size;
 
@@ -1037,7 +1069,7 @@ void zaxisDefLbounds(int zaxisID, const double *lbounds)
       Warning("Lower bounds already defined for zaxisID = %d", zaxisID);
 
   if ( zaxisptr->lbounds == NULL )
-    zaxisptr->lbounds = (double *)xmalloc(size*sizeof(double));
+    zaxisptr->lbounds = (double *) Malloc(size*sizeof(double));
 
   memcpy(zaxisptr->lbounds, lbounds, size*sizeof(double));
   reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
@@ -1046,7 +1078,7 @@ void zaxisDefLbounds(int zaxisID, const double *lbounds)
 
 void zaxisDefUbounds(int zaxisID, const double *ubounds)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   size_t size = (size_t)zaxisptr->size;
 
@@ -1055,7 +1087,7 @@ void zaxisDefUbounds(int zaxisID, const double *ubounds)
       Warning("Upper bounds already defined for zaxisID = %d", zaxisID);
 
   if ( zaxisptr->ubounds == NULL )
-    zaxisptr->ubounds = (double *)xmalloc(size*sizeof(double));
+    zaxisptr->ubounds = (double *) Malloc(size*sizeof(double));
 
   memcpy(zaxisptr->ubounds, ubounds, size*sizeof(double));
   reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
@@ -1064,7 +1096,7 @@ void zaxisDefUbounds(int zaxisID, const double *ubounds)
 
 void zaxisDefWeights(int zaxisID, const double *weights)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   size_t size = (size_t)zaxisptr->size;
 
@@ -1073,7 +1105,7 @@ void zaxisDefWeights(int zaxisID, const double *weights)
       Warning("Weights already defined for zaxisID = %d", zaxisID);
 
   if ( zaxisptr->weights == NULL )
-    zaxisptr->weights = (double *)xmalloc(size*sizeof(double));
+    zaxisptr->weights = (double *) Malloc(size*sizeof(double));
 
   memcpy(zaxisptr->weights, weights, size*sizeof(double));
   reshSetStatus(zaxisID, &zaxisOps, RESH_DESYNC_IN_USE);
@@ -1082,34 +1114,34 @@ void zaxisDefWeights(int zaxisID, const double *weights)
 
 void zaxisChangeType(int zaxisID, int zaxistype)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
   zaxisptr->type = zaxistype;
 }
 
 
 void zaxisResize(int zaxisID, int size)
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   xassert(size >= 0);
 
   zaxisptr->size = size;
 
   if ( zaxisptr->vals )
-    zaxisptr->vals = (double *)xrealloc(zaxisptr->vals, (size_t)size * sizeof(double));
+    zaxisptr->vals = (double *) Realloc(zaxisptr->vals, (size_t)size * sizeof(double));
 }
 
 
 int zaxisDuplicate(int zaxisID)
 {
   int zaxisIDnew;
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   int zaxistype = zaxisInqType(zaxisID);
   int zaxissize = zaxisInqSize(zaxisID);
 
   zaxisIDnew = zaxisCreate(zaxistype, zaxissize);
-  zaxis_t *zaxisptrnew = reshGetVal(zaxisIDnew, &zaxisOps);
+  zaxis_t *zaxisptrnew = zaxisID2Ptr(zaxisIDnew);
 
   zaxis_copy(zaxisptrnew, zaxisptr);
 
@@ -1121,7 +1153,7 @@ int zaxisDuplicate(int zaxisID)
     {
       size_t size = (size_t)zaxissize;
 
-      zaxisptrnew->vals = (double *)xmalloc(size * sizeof (double));
+      zaxisptrnew->vals = (double *) Malloc(size * sizeof (double));
       memcpy(zaxisptrnew->vals, zaxisptr->vals, size * sizeof (double));
     }
 
@@ -1129,7 +1161,7 @@ int zaxisDuplicate(int zaxisID)
     {
       size_t size = (size_t)zaxissize;
 
-      zaxisptrnew->lbounds = (double *)xmalloc(size * sizeof (double));
+      zaxisptrnew->lbounds = (double *) Malloc(size * sizeof (double));
       memcpy(zaxisptrnew->lbounds, zaxisptr->lbounds, size * sizeof(double));
     }
 
@@ -1137,7 +1169,7 @@ int zaxisDuplicate(int zaxisID)
     {
       size_t size = (size_t)zaxissize;
 
-      zaxisptrnew->ubounds = (double *)xmalloc(size * sizeof (double));
+      zaxisptrnew->ubounds = (double *) Malloc(size * sizeof (double));
       memcpy(zaxisptrnew->ubounds, zaxisptr->ubounds, size * sizeof (double));
     }
 
@@ -1148,7 +1180,7 @@ int zaxisDuplicate(int zaxisID)
       if ( size )
         {
           zaxisptrnew->vctsize = (int)size;
-          zaxisptrnew->vct = (double *)xmalloc(size * sizeof (double));
+          zaxisptrnew->vct = (double *) Malloc(size * sizeof (double));
           memcpy(zaxisptrnew->vct, zaxisptr->vct, size * sizeof (double));
         }
     }
@@ -1157,7 +1189,7 @@ int zaxisDuplicate(int zaxisID)
 }
 
 
-void zaxisPrintKernel ( zaxis_t * zaxisptr, int index, FILE * fp )
+static void zaxisPrintKernel ( zaxis_t * zaxisptr, int index, FILE * fp )
 {
   unsigned char uuid[CDI_UUID_SIZE];
   int levelID;
@@ -1258,19 +1290,21 @@ void zaxisPrintKernel ( zaxis_t * zaxisptr, int index, FILE * fp )
 
   if ( type == ZAXIS_REFERENCE )
     {
-      const unsigned char *d;
       zaxisInqUUID(zaxisID, uuid);
-      d = uuid;
-      fprintf(fp, "uuid      = %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
-              d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
-              d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
+      if ( *uuid )
+        {
+          const unsigned char *d = uuid;
+          fprintf(fp, "uuid      = %02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
+                  d[0], d[1], d[2], d[3], d[4], d[5], d[6], d[7],
+                  d[8], d[9], d[10], d[11], d[12], d[13], d[14], d[15]);
+        }
     }
 }
 
 
 void zaxisPrint ( int zaxisID, int index )
 {
-  zaxis_t *zaxisptr = reshGetVal(zaxisID, &zaxisOps);
+  zaxis_t *zaxisptr = zaxisID2Ptr(zaxisID);
 
   zaxisPrintKernel ( zaxisptr, index, stdout );
 }
@@ -1486,7 +1520,7 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
       int size = zaxisP->size;
       xassert(size >= 0);
 
-      zaxisP->vals = (double *)xmalloc((size_t)size * sizeof (double));
+      zaxisP->vals = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       zaxisP->vals, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -1499,7 +1533,7 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
       int size = zaxisP->size;
       xassert(size >= 0);
 
-      zaxisP->lbounds = (double *)xmalloc((size_t)size * sizeof (double));
+      zaxisP->lbounds = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       zaxisP->lbounds, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -1512,7 +1546,7 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
       int size = zaxisP->size;
       xassert(size >= 0);
 
-      zaxisP->ubounds = (double *)xmalloc((size_t)size * sizeof (double));
+      zaxisP->ubounds = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       zaxisP->ubounds, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -1525,7 +1559,7 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
       int size = zaxisP->size;
       xassert(size >= 0);
 
-      zaxisP->weights = (double *)xmalloc((size_t)size * sizeof (double));
+      zaxisP->weights = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       zaxisP->weights, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -1538,7 +1572,7 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
       int size = zaxisP->vctsize;
       xassert(size >= 0);
 
-      zaxisP->vct = (double *)xmalloc((size_t)size * sizeof (double));
+      zaxisP->vct = (double *) Malloc((size_t)size * sizeof (double));
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                       zaxisP->vct, size, DATATYPE_FLT64, context);
       serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
@@ -1560,6 +1594,8 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
     serializeUnpack(unpackBuffer, unpackBufferSize, unpackBufferPos,
                     zaxisP->uuid, CDI_UUID_SIZE, DATATYPE_UCHAR, context);
 
+  reshSetStatus(zaxisP->self, &zaxisOps,
+                reshGetStatus(zaxisP->self, &zaxisOps) & ~RESH_SYNC_BIT);
 }
 
 static void
@@ -1657,7 +1693,7 @@ zaxisPack(void * voidP, void * packBuffer, int packBufferSize,
 }
 
 
-void cdiZaxisGetIndexList(unsigned nzaxis, int zaxisResHs[nzaxis])
+void cdiZaxisGetIndexList(unsigned nzaxis, int *zaxisResHs)
 {
   reshGetResHListOfType(nzaxis, zaxisResHs, &zaxisOps);
 }
diff --git a/libcdi/src/zaxis.h b/libcdi/src/zaxis.h
index 7d97553..95c35e3 100644
--- a/libcdi/src/zaxis.h
+++ b/libcdi/src/zaxis.h
@@ -3,11 +3,9 @@
 
 void zaxisGetTypeDescription(int zaxisType, int* outPositive, const char** outName, const char** outLongName, const char** outStdName, const char** outUnit);  //The returned const char* point to static storage. Don't free or modify them.
 
-int zaxisSize(void);
-
 unsigned cdiZaxisCount(void);
 
-void cdiZaxisGetIndexList(unsigned numIDs, int IDs[numIDs]);
+void cdiZaxisGetIndexList(unsigned numIDs, int *IDs);
 
 void
 zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
@@ -16,6 +14,16 @@ zaxisUnpack(char * unpackBuffer, int unpackBufferSize,
 
 void zaxisDefLtype2(int zaxisID, int ltype2);
 
-extern const resOps zaxisOps;
+const resOps *getZaxisOps(void);
 
 #endif
+
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/libcdi/tests/Makefile.am b/libcdi/tests/Makefile.am
index f258bfd..c5efabd 100644
--- a/libcdi/tests/Makefile.am
+++ b/libcdi/tests/Makefile.am
@@ -7,10 +7,16 @@ TESTS = cksum_verify \
 	test_chunk_cksum \
 	pio_write_run pio_cksum_mpinonb pio_cksum_fpguard \
 	pio_cksum_asynch pio_cksum_writer pio_cksum_cdf \
+	pio_cksum_mpi_fw_ordered \
+	pio_cksum_mpi_fw_at_all \
+	pio_cksum_mpi_fw_at_reblock \
 	test_resource_copy pio_write_deco2d_run \
-	test_f2003 test_cdf_transformation
+	test_f2003 test_cdf_transformation \
+	test_table test_byteswap
+
 check_PROGRAMS = cksum_verify test_grib cksum_write cksum_read pio_write \
-	test_resource_copy cksum_write_chunk pio_write_deco2d
+	test_resource_copy cksum_write_chunk pio_write_deco2d test_table \
+	test_byteswap
 
 if ENABLE_NETCDF
 check_PROGRAMS += test_cdf_write test_cdf_read
@@ -34,6 +40,8 @@ test_resource_copy_LDADD = $(UUID_C_LIB) ../src/libcdiresunpack.la $(LDADD)
 test_resource_copy_mpi_SOURCES = test_resource_copy.c
 test_cdf_write_SOURCES = test_cdf_write.c
 test_cdf_read_SOURCES = test_cdf_read.c
+test_table_SOURCES = test_table.c
+test_byteswap_SOURCES = test_byteswap.c
 #
 AM_CFLAGS = $(PPM_CORE_CFLAGS) $(YAXT_CFLAGS) $(MPI_C_INCLUDE)
 if USE_MPI
diff --git a/libcdi/tests/Makefile.in b/libcdi/tests/Makefile.in
index 2cd6def..7a86bff 100644
--- a/libcdi/tests/Makefile.in
+++ b/libcdi/tests/Makefile.in
@@ -81,13 +81,16 @@ TESTS = cksum_verify$(EXEEXT) test_cksum_grib test_cksum_nc \
 	test_cksum_extra test_cksum_service test_cksum_nc2 \
 	test_cksum_nc4 test_cksum_ieg test_chunk_cksum pio_write_run \
 	pio_cksum_mpinonb pio_cksum_fpguard pio_cksum_asynch \
-	pio_cksum_writer pio_cksum_cdf test_resource_copy$(EXEEXT) \
-	pio_write_deco2d_run test_f2003 test_cdf_transformation \
-	$(am__append_2)
+	pio_cksum_writer pio_cksum_cdf pio_cksum_mpi_fw_ordered \
+	pio_cksum_mpi_fw_at_all pio_cksum_mpi_fw_at_reblock \
+	test_resource_copy$(EXEEXT) pio_write_deco2d_run test_f2003 \
+	test_cdf_transformation test_table$(EXEEXT) \
+	test_byteswap$(EXEEXT) $(am__append_2)
 check_PROGRAMS = cksum_verify$(EXEEXT) test_grib$(EXEEXT) \
 	cksum_write$(EXEEXT) cksum_read$(EXEEXT) pio_write$(EXEEXT) \
 	test_resource_copy$(EXEEXT) cksum_write_chunk$(EXEEXT) \
-	pio_write_deco2d$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2)
+	pio_write_deco2d$(EXEEXT) test_table$(EXEEXT) \
+	test_byteswap$(EXEEXT) $(am__EXEEXT_1) $(am__EXEEXT_2)
 @ENABLE_NETCDF_TRUE at am__append_1 = test_cdf_write test_cdf_read
 @USE_MPI_TRUE at am__append_2 = test_resource_copy_mpi_run
 @USE_MPI_TRUE at am__append_3 = test_resource_copy_mpi
@@ -100,9 +103,12 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
 	$(srcdir)/test_cksum_ieg.in $(srcdir)/test_chunk_cksum.in \
 	$(srcdir)/test_f2003.in $(srcdir)/pio_write_run.in \
 	$(srcdir)/pio_write_deco2d_run.in \
-	$(srcdir)/pio_cksum_mpinonb.in $(srcdir)/pio_cksum_fpguard.in \
-	$(srcdir)/pio_cksum_asynch.in $(srcdir)/pio_cksum_writer.in \
-	$(srcdir)/pio_cksum_cdf.in \
+	$(srcdir)/pio_cksum_mpinonb.in \
+	$(srcdir)/pio_cksum_mpi_fw_ordered.in \
+	$(srcdir)/pio_cksum_mpi_fw_at_all.in \
+	$(srcdir)/pio_cksum_mpi_fw_at_reblock.in \
+	$(srcdir)/pio_cksum_fpguard.in $(srcdir)/pio_cksum_asynch.in \
+	$(srcdir)/pio_cksum_writer.in $(srcdir)/pio_cksum_cdf.in \
 	$(srcdir)/test_resource_copy_mpi_run.in \
 	$(srcdir)/test_cdf_transformation.in \
 	$(top_srcdir)/config/depcomp
@@ -110,18 +116,22 @@ ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps =  \
 	$(top_srcdir)/m4/acx_assert_lang_is_fortran_variant.m4 \
 	$(top_srcdir)/m4/acx_c_package.m4 \
+	$(top_srcdir)/m4/acx_cfortran_flags.m4 \
+	$(top_srcdir)/m4/acx_check_cfortran.m4 \
 	$(top_srcdir)/m4/acx_check_strptr_convert.m4 \
 	$(top_srcdir)/m4/acx_execinfo.m4 \
 	$(top_srcdir)/m4/acx_fortran_package.m4 \
 	$(top_srcdir)/m4/acx_lang_check_include.m4 \
 	$(top_srcdir)/m4/acx_lang_other_suffix_conftest.m4 \
 	$(top_srcdir)/m4/acx_lang_package.m4 \
+	$(top_srcdir)/m4/acx_lt_problems.m4 \
 	$(top_srcdir)/m4/acx_option_search_libs.m4 \
 	$(top_srcdir)/m4/acx_options.m4 \
 	$(top_srcdir)/m4/acx_sl_fc_mod_path_flag.m4 \
 	$(top_srcdir)/m4/acx_sl_mod_suffix.m4 \
 	$(top_srcdir)/m4/asx_tr_arg.m4 $(top_srcdir)/m4/asx_unset.m4 \
-	$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
+	$(top_srcdir)/m4/ax_pthread.m4 \
+	$(top_srcdir)/m4/kpse_libtool.m4 $(top_srcdir)/m4/libtool.m4 \
 	$(top_srcdir)/m4/ltoptions.m4 $(top_srcdir)/m4/ltsugar.m4 \
 	$(top_srcdir)/m4/ltversion.m4 $(top_srcdir)/m4/lt~obsolete.m4 \
 	$(top_srcdir)/m4/pkg.m4 $(top_srcdir)/m4/starlink_fpp.m4 \
@@ -137,9 +147,11 @@ CONFIG_HEADER = $(top_builddir)/src/config.h
 CONFIG_CLEAN_FILES = test_cksum_grib test_cksum_nc test_cksum_nc2 \
 	test_cksum_nc4 test_cksum_extra test_cksum_service \
 	test_cksum_ieg test_chunk_cksum test_f2003 pio_write_run \
-	pio_write_deco2d_run pio_cksum_mpinonb pio_cksum_fpguard \
-	pio_cksum_asynch pio_cksum_writer pio_cksum_cdf \
-	test_resource_copy_mpi_run test_cdf_transformation
+	pio_write_deco2d_run pio_cksum_mpinonb \
+	pio_cksum_mpi_fw_ordered pio_cksum_mpi_fw_at_all \
+	pio_cksum_mpi_fw_at_reblock pio_cksum_fpguard pio_cksum_asynch \
+	pio_cksum_writer pio_cksum_cdf test_resource_copy_mpi_run \
+	test_cdf_transformation
 CONFIG_CLEAN_VPATH_FILES =
 @ENABLE_NETCDF_TRUE at am__EXEEXT_1 = test_cdf_write$(EXEEXT) \
 @ENABLE_NETCDF_TRUE@	test_cdf_read$(EXEEXT)
@@ -183,6 +195,10 @@ pio_write_deco2d_OBJECTS = $(am_pio_write_deco2d_OBJECTS)
 @USE_MPI_FALSE@	$(am__DEPENDENCIES_2)
 @USE_MPI_TRUE at pio_write_deco2d_DEPENDENCIES = ../src/libcdipio.la \
 @USE_MPI_TRUE@	$(am__DEPENDENCIES_2) $(am__DEPENDENCIES_2)
+am_test_byteswap_OBJECTS = test_byteswap.$(OBJEXT)
+test_byteswap_OBJECTS = $(am_test_byteswap_OBJECTS)
+test_byteswap_LDADD = $(LDADD)
+test_byteswap_DEPENDENCIES = ../src/libcdi.la
 am_test_cdf_read_OBJECTS = test_cdf_read.$(OBJEXT)
 test_cdf_read_OBJECTS = $(am_test_cdf_read_OBJECTS)
 test_cdf_read_LDADD = $(LDADD)
@@ -210,6 +226,10 @@ test_resource_copy_mpi_LINK = $(LIBTOOL) $(AM_V_lt) --tag=CC \
 	$(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=link $(CCLD) \
 	$(test_resource_copy_mpi_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
 	$(LDFLAGS) -o $@
+am_test_table_OBJECTS = test_table.$(OBJEXT)
+test_table_OBJECTS = $(am_test_table_OBJECTS)
+test_table_LDADD = $(LDADD)
+test_table_DEPENDENCIES = ../src/libcdi.la
 AM_V_P = $(am__v_P_ at AM_V@)
 am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
 am__v_P_0 = false
@@ -247,15 +267,17 @@ am__v_CCLD_1 =
 SOURCES = $(cksum_read_SOURCES) $(cksum_verify_SOURCES) \
 	$(cksum_write_SOURCES) $(cksum_write_chunk_SOURCES) \
 	$(pio_write_SOURCES) $(pio_write_deco2d_SOURCES) \
-	$(test_cdf_read_SOURCES) $(test_cdf_write_SOURCES) \
-	$(test_grib_SOURCES) $(test_resource_copy_SOURCES) \
-	$(test_resource_copy_mpi_SOURCES)
+	$(test_byteswap_SOURCES) $(test_cdf_read_SOURCES) \
+	$(test_cdf_write_SOURCES) $(test_grib_SOURCES) \
+	$(test_resource_copy_SOURCES) \
+	$(test_resource_copy_mpi_SOURCES) $(test_table_SOURCES)
 DIST_SOURCES = $(cksum_read_SOURCES) $(cksum_verify_SOURCES) \
 	$(cksum_write_SOURCES) $(cksum_write_chunk_SOURCES) \
 	$(pio_write_SOURCES) $(pio_write_deco2d_SOURCES) \
-	$(test_cdf_read_SOURCES) $(test_cdf_write_SOURCES) \
-	$(test_grib_SOURCES) $(test_resource_copy_SOURCES) \
-	$(test_resource_copy_mpi_SOURCES)
+	$(test_byteswap_SOURCES) $(test_cdf_read_SOURCES) \
+	$(test_cdf_write_SOURCES) $(test_grib_SOURCES) \
+	$(test_resource_copy_SOURCES) \
+	$(test_resource_copy_mpi_SOURCES) $(test_table_SOURCES)
 am__can_run_installinfo = \
   case $$AM_UPDATE_INFO_DIR in \
     n|no|NO) false;; \
@@ -307,7 +329,6 @@ ACLOCAL = @ACLOCAL@
 AMTAR = @AMTAR@
 AM_DEFAULT_VERBOSITY = @AM_DEFAULT_VERBOSITY@
 AR = @AR@
-AS = @AS@
 AUTOCONF = @AUTOCONF@
 AUTOHEADER = @AUTOHEADER@
 AUTOMAKE = @AUTOMAKE@
@@ -518,6 +539,8 @@ test_resource_copy_LDADD = $(UUID_C_LIB) ../src/libcdiresunpack.la $(LDADD)
 test_resource_copy_mpi_SOURCES = test_resource_copy.c
 test_cdf_write_SOURCES = test_cdf_write.c
 test_cdf_read_SOURCES = test_cdf_read.c
+test_table_SOURCES = test_table.c
+test_byteswap_SOURCES = test_byteswap.c
 #
 AM_CFLAGS = $(PPM_CORE_CFLAGS) $(YAXT_CFLAGS) $(MPI_C_INCLUDE)
 @USE_MPI_FALSE at pio_write_LDADD = $(LDADD) $(UUID_C_LIB)
@@ -595,6 +618,12 @@ pio_write_deco2d_run: $(top_builddir)/config.status $(srcdir)/pio_write_deco2d_r
 	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 pio_cksum_mpinonb: $(top_builddir)/config.status $(srcdir)/pio_cksum_mpinonb.in
 	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+pio_cksum_mpi_fw_ordered: $(top_builddir)/config.status $(srcdir)/pio_cksum_mpi_fw_ordered.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+pio_cksum_mpi_fw_at_all: $(top_builddir)/config.status $(srcdir)/pio_cksum_mpi_fw_at_all.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+pio_cksum_mpi_fw_at_reblock: $(top_builddir)/config.status $(srcdir)/pio_cksum_mpi_fw_at_reblock.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 pio_cksum_fpguard: $(top_builddir)/config.status $(srcdir)/pio_cksum_fpguard.in
 	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 pio_cksum_asynch: $(top_builddir)/config.status $(srcdir)/pio_cksum_asynch.in
@@ -641,6 +670,10 @@ pio_write_deco2d$(EXEEXT): $(pio_write_deco2d_OBJECTS) $(pio_write_deco2d_DEPEND
 	@rm -f pio_write_deco2d$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(pio_write_deco2d_OBJECTS) $(pio_write_deco2d_LDADD) $(LIBS)
 
+test_byteswap$(EXEEXT): $(test_byteswap_OBJECTS) $(test_byteswap_DEPENDENCIES) $(EXTRA_test_byteswap_DEPENDENCIES) 
+	@rm -f test_byteswap$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_byteswap_OBJECTS) $(test_byteswap_LDADD) $(LIBS)
+
 test_cdf_read$(EXEEXT): $(test_cdf_read_OBJECTS) $(test_cdf_read_DEPENDENCIES) $(EXTRA_test_cdf_read_DEPENDENCIES) 
 	@rm -f test_cdf_read$(EXEEXT)
 	$(AM_V_CCLD)$(LINK) $(test_cdf_read_OBJECTS) $(test_cdf_read_LDADD) $(LIBS)
@@ -661,6 +694,10 @@ test_resource_copy_mpi$(EXEEXT): $(test_resource_copy_mpi_OBJECTS) $(test_resour
 	@rm -f test_resource_copy_mpi$(EXEEXT)
 	$(AM_V_CCLD)$(test_resource_copy_mpi_LINK) $(test_resource_copy_mpi_OBJECTS) $(test_resource_copy_mpi_LDADD) $(LIBS)
 
+test_table$(EXEEXT): $(test_table_OBJECTS) $(test_table_DEPENDENCIES) $(EXTRA_test_table_DEPENDENCIES) 
+	@rm -f test_table$(EXEEXT)
+	$(AM_V_CCLD)$(LINK) $(test_table_OBJECTS) $(test_table_LDADD) $(LIBS)
+
 mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
 
@@ -677,11 +714,13 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/simple_model.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/simple_model_helper.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/stream_cksum.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_byteswap.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_cdf_read.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_cdf_write.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_grib.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_resource_copy.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_resource_copy_mpi-test_resource_copy.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/test_table.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/var_cksum.Po at am__quote@
 
 .c.o:
diff --git a/libcdi/tests/cksum_read.c b/libcdi/tests/cksum_read.c
index df52cda..0b3493a 100644
--- a/libcdi/tests/cksum_read.c
+++ b/libcdi/tests/cksum_read.c
@@ -26,7 +26,7 @@ read_table(const char *table_fname, size_t *table_len)
       *table_len = (size_t)-1;
       return NULL;
     }
-  while (fscanf(tablefp, "%08"PRIx32" %d\n", &cksum_temp, &code) == 2)
+  while (fscanf(tablefp, "%08" PRIx32" %d\n", &cksum_temp, &code) == 2)
     {
       ENSURE_ARRAY_SIZE(table, table_size, table_used + 1);
       table[table_used].code = code;
@@ -41,7 +41,7 @@ read_table(const char *table_fname, size_t *table_len)
 
 int main(int argc, char *argv[])
 {
-  char *fname = "example.grb", *table_fname = "example.cksum";
+  const char *fname = "example.grb", *table_fname = "example.cksum";
 
   if (argc > 1)
     fname = argv[1];
@@ -60,10 +60,14 @@ int main(int argc, char *argv[])
     struct cksum_table *ref_var_table
       = read_table(table_fname, &num_ref_entries);
     if (num_ref_entries == (size_t)-1)
-      exit(EXIT_FAILURE);
+      {
+        free(file_vars);
+        exit(EXIT_FAILURE);
+      }
     retcode
       = compare_checksums(file_vars, nvars, "file",
                           ref_var_table, num_ref_entries, "reference table");
+    free(file_vars);
     free(ref_var_table);
   }
 
diff --git a/libcdi/tests/cksum_verify.c b/libcdi/tests/cksum_verify.c
index 6983993..b2c865a 100644
--- a/libcdi/tests/cksum_verify.c
+++ b/libcdi/tests/cksum_verify.c
@@ -2,7 +2,7 @@
 #include "config.h"
 #endif
 
-#ifndef __STDC_FORMAT_MACROS
+#if defined __cplusplus && !defined __STDC_FORMAT_MACROS
 #define __STDC_FORMAT_MACROS
 #endif
 
@@ -22,8 +22,8 @@ main()
 {
   unsigned char *test_data, *init_block;
   size_t num_blocks = 1000;
-  if (!(init_block = calloc(block_size * block_size, 1U))
-      || !(test_data = calloc((size_t)block_size * num_blocks, 1U)))
+  if (!(init_block = (unsigned char *)calloc(block_size * block_size, 1U))
+      || !(test_data = (unsigned char *)calloc((size_t)block_size * num_blocks, 1U)))
     return EXIT_FAILURE;
   /* this is supposed to be non-random */
   srand48(5L);
@@ -45,7 +45,7 @@ main()
   uint32_t cksum_result = memcrc(test_data, num_blocks * block_size);
   if (cksum_result != UINT32_C(0xc47779cd))
     {
-      printf("unexpected crc result: 0x%8"PRIx32"\n", cksum_result);
+      printf("unexpected crc result: 0x%8" PRIx32"\n", cksum_result);
       return EXIT_FAILURE;
     }
   return EXIT_SUCCESS;
diff --git a/libcdi/tests/cksum_write.c b/libcdi/tests/cksum_write.c
index f0eff94..0e87873 100644
--- a/libcdi/tests/cksum_write.c
+++ b/libcdi/tests/cksum_write.c
@@ -34,6 +34,13 @@ parse_intarg(const char msg[])
   return (int)temp;
 }
 
+/* If we're not using GNU C, elide __attribute__ */
+#if ! defined __GNUC__ && ! defined __attribute__
+#  define  __attribute__(x)  /*NOTHING*/
+#endif
+static void
+allocError(const char *msg) __attribute__((noreturn));
+
 static void
 allocError(const char *msg)
 {
@@ -46,7 +53,7 @@ fname_create(const char *prefix, const char *suffix)
 {
   size_t prefix_len, suffix_len;
   char *fname;
-  if (!(fname = malloc((prefix_len = strlen(prefix)) + 1
+  if (!(fname = (char *)malloc((prefix_len = strlen(prefix)) + 1
                        + (suffix_len = strlen(suffix)) + 1)))
     allocError("cannot create string");
   strcpy(fname, prefix);
@@ -110,15 +117,15 @@ int
 main(int argc, char *argv[])
 {
   int gridID, zaxisID[nvars], taxisID;
-  int vlistID, varID[nvars], streamID, tsID;
+  int vlistID, varID[nvars], streamID;
   int nlon = 12, //!< Number of longitudes
     nlat = 6, //!< Number of latitudes
     nlev = 5, //!< Number of levels
     nts = 3; //!< Number of time steps
-  int i, j, k, nmiss = 0;
-  double *lons, *lats, *var[nvars], *levs, mscale, mrscale;
+  enum { nmiss = 0 };
+  double *lons, *lats, *restrict var[nvars], *levs, mscale, mrscale;
   size_t varSize[nvars];
-  char *varName[nvars] = { "varname1", "varname2" };
+  const char *varName[nvars] = { "varname1", "varname2" };
 #ifndef TEST_CHUNK_WRITE
   const char *suffix = "grb", *prefix = "example";
   int grid = GRID_LONLAT;
@@ -189,14 +196,14 @@ main(int argc, char *argv[])
       }
   }
 
-  lons = malloc((size_t)nlon * sizeof (lons[0]));
-  for (i = 0; i < nlon; ++i)
+  lons = (double *)malloc((size_t)nlon * sizeof (lons[0]));
+  for (size_t i = 0; i < (size_t)nlon; ++i)
     lons[i] = ((double)(i * 360))/nlon;
-  lats = malloc((size_t)nlat * sizeof (lats[0]));
-  for (i = 0; i < nlat; ++i)
+  lats = (double *)malloc((size_t)nlat * sizeof (lats[0]));
+  for (size_t i = 0; i < (size_t)nlat; ++i)
     lats[i] = ((double)(i * 180))/nlat - 90.0;
-  levs = malloc((size_t)nlev * sizeof (levs[0]));
-  for (i = 0; i < nlev; ++i)
+  levs = (double *)malloc((size_t)nlev * sizeof (levs[0]));
+  for (size_t i = 0; i < (size_t)nlev; ++i)
     levs[i] = 101300 - floor(3940.3 * (exp(2.3579 * (double)(i)/(nlev - 1)) - 1.0));
 
   varSize[0] = (size_t)nlon * (size_t)nlat;
@@ -244,7 +251,7 @@ main(int argc, char *argv[])
   // Create a variable list
   vlistID = vlistCreate();
 
-  for (i = 0; i < nvars; ++i)
+  for (size_t i = 0; i < nvars; ++i)
     {
       // Define the variables
       varID[i] = vlistDefVar(vlistID, gridID, zaxisID[i], TIME_VARIABLE);
@@ -255,7 +262,7 @@ main(int argc, char *argv[])
       // and set the data type
       vlistDefVarDatatype(vlistID, varID[i], datatype);
       // create memory for variables
-      var[i] = malloc(varSize[i] * sizeof (var[i][0]));
+      var[i] = (double *)malloc(varSize[i] * sizeof (var[i][0]));
     }
 
   var_scale(datatype, &mscale, &mrscale);
@@ -281,32 +288,32 @@ main(int argc, char *argv[])
   {
     uint32_t checksum_state[nvars] = { 0, 0 };
     // Loop over the number of time steps
-    for ( tsID = 0; tsID < nts; tsID++ )
+    for ( size_t tsID = 0; tsID < (size_t)nts; tsID++ )
       {
-        int vdatetime[2] = { 120000, 19850101+tsID };
+        int vdatetime[2] = { 120000, 19850101+(int)tsID };
         // Set the verification date to 1985-01-01 + tsID
         taxisDefVdate(taxisID, vdatetime[1]);
         // Set the verification time to 12:00:00
         taxisDefVtime(taxisID, vdatetime[0]);
         // Define the time step
-        streamDefTimestep(streamID, tsID);
+        streamDefTimestep(streamID, (int)tsID);
 
         // Init var1 and var2
-        for (j = 0; j < nlat; j++)
-          for (i = 0; i < nlon; i++)
-            var[0][i+j*nlon]
+        for (size_t j = 0; j < (size_t)nlat; j++)
+          for (size_t i = 0; i < (size_t)nlon; i++)
+            var[0][i+j*(size_t)nlon]
               = sign_flat(round(
-                   (sin(2.0 * M_PI * (lons[(i + tsID)%nlon] - lons[0])
+                   (sin(2.0 * M_PI * (lons[(i + tsID)%(size_t)nlon] - lons[0])
                         / (lons[nlon-1] - lons[0]))
                     * cos(2.0 * M_PI * (lats[j] - lats[0])
                           / (lons[nlat-1] - lats[0]))
                     ) * mscale)) * mrscale;
-        for (k = 0; k < nlev; ++k)
-          for (j = 0; j < nlat; j++)
-            for (i = 0; i < nlon; i++)
-              var[1][i+j*nlon+k*nlon*nlat]
+        for (size_t k = 0; k < (size_t)nlev; ++k)
+          for (size_t j = 0; j < (size_t)nlat; j++)
+            for (size_t i = 0; i < (size_t)nlon; i++)
+              var[1][i+j*(size_t)nlon+k*(size_t)nlon*(size_t)nlat]
                 = sign_flat(round(
-                     (cos(2.0 * M_PI * (lons[(i + tsID)%nlon] - lons[0])
+                     (cos(2.0 * M_PI * (lons[(i + tsID)%(size_t)nlon] - lons[0])
                           / (lons[nlon-1] - lons[0]))
                       * sin(2.0 * M_PI * (lats[j] - lats[0])
                             / (lons[nlat-1] - lats[0]))
@@ -330,7 +337,7 @@ main(int argc, char *argv[])
         {
           size_t maxChunkSize
             = ((size_t)nlon + 1)/2 * (size_t)nlat * (size_t)nlev;
-          double *chunkBuf = malloc(maxChunkSize * sizeof (double));
+          double *chunkBuf = (double *)malloc(maxChunkSize * sizeof (double));
           int varShape[2][3] = { { nlon, nlat, 1 }, { nlon, nlat, nlev } },
             chunk[3][2] = { { 0, nlon/2 - 1 }, { 0, nlat - 1 }, { 0, 0 } };
           if (!chunkBuf)
@@ -372,7 +379,7 @@ main(int argc, char *argv[])
           }
         free(fname);
       }
-      for (i = 0; i < nvars; ++i)
+      for (size_t i = 0; i < (size_t)nvars; ++i)
         {
           uint32_t cksum;
           int code;
@@ -395,7 +402,7 @@ main(int argc, char *argv[])
   streamClose(streamID);
 
   // Destroy the objects
-  for (i = 0; i < nvars; ++i)
+  for (size_t i = 0; i < nvars; ++i)
     free(var[i]);
   vlistDestroy(vlistID);
   taxisDestroy(taxisID);
diff --git a/libcdi/tests/deco2d_model.c b/libcdi/tests/deco2d_model.c
index c75902e..f86cb0a 100644
--- a/libcdi/tests/deco2d_model.c
+++ b/libcdi/tests/deco2d_model.c
@@ -75,7 +75,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
 {
   static const char * const fname_prefix        = "example";
 
-  struct
+  struct varDesc_t
   {
     size_t size;
     int nlev, zaxisID, id, code;
@@ -87,8 +87,8 @@ modelRun(struct model_config setup, MPI_Comm comm)
 #endif
   } *varDesc;
   int gridID, taxisID, vlistID, streamID, tsID, tfID = 0;
-  int i, nmiss = 0;
-  double *lons, *lats, *levs;
+  enum { nmiss = 0 };
+  double *restrict lons, *restrict lats, *restrict levs;
   double *var = NULL, *varslice = NULL;
   double mscale, mrscale;
   time_t current_time;
@@ -96,7 +96,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
   int rank = 0;
   char filename[1024];
   int nlon = setup.nlon, nlat = setup.nlat;
-  int nVars = setup.nvars;
+  size_t nVars = setup.nvars > 0 ? (size_t)setup.nvars : 0;
   size_t varslice_size = 0;
 #if USE_MPI
   int comm_size = 1;
@@ -107,11 +107,13 @@ modelRun(struct model_config setup, MPI_Comm comm)
 #if USE_MPI
   xmpi ( MPI_Comm_rank ( comm, &rank ));
   xmpi ( MPI_Comm_size ( comm, &comm_size ));
+#else
+  (void)comm;
 #endif
 
   if (rank == 0 && setup.compute_checksum)
     {
-      var = xmalloc((size_t)nlon * (size_t)nlat
+      var = (double *)Malloc((size_t)nlon * (size_t)nlat
                     * (size_t)setup.max_nlev * sizeof(var[0]));
     }
 
@@ -129,7 +131,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
       rank_coord[0] = rank % npart[0],
         rank_coord[1] = rank / npart[0];
     }
-  blk_displ = xmalloc((size_t)setup.max_nlev * sizeof (blk_displ[0]) * 2);
+  blk_displ = Malloc((size_t)setup.max_nlev * sizeof (blk_displ[0]) * 2);
   blk_lens = blk_displ + setup.max_nlev;
 #endif
 
@@ -138,11 +140,11 @@ modelRun(struct model_config setup, MPI_Comm comm)
   gridID = gridCreate ( GRID_LONLAT, nlon*nlat );
   gridDefXsize ( gridID, nlon );
   gridDefYsize ( gridID, nlat );
-  lons = xmalloc((size_t)nlon * sizeof (lons[0]));
-  for (i = 0; i < nlon; ++i)
+  lons = (double *)Malloc((size_t)nlon * sizeof (lons[0]));
+  for (size_t i = 0; i < (size_t)nlon; ++i)
     lons[i] = ((double)(i * 360))/nlon;
-  lats = xmalloc((size_t)nlat * sizeof (lats[0]));
-  for (i = 0; i < nlat; ++i)
+  lats = (double *)Malloc((size_t)nlat * sizeof (lats[0]));
+  for (size_t i = 0; i < (size_t)nlat; ++i)
     lats[i] = ((double)(i * 180))/nlat - 90.0;
   gridDefXvals ( gridID, lons );
   gridDefYvals ( gridID, lats );
@@ -155,16 +157,16 @@ modelRun(struct model_config setup, MPI_Comm comm)
 #endif
     gridDefUUID(gridID, uuid);
   }
-  levs = xmalloc((size_t)setup.max_nlev * sizeof (levs[0]));
+  levs = (double *)Malloc((size_t)setup.max_nlev * sizeof (levs[0]));
   {
     double lscale = 1.0/(double)(setup.max_nlev - 1);
-    for (i = 0; i < setup.max_nlev; ++i)
+    for (size_t i = 0; i < (size_t)setup.max_nlev; ++i)
       levs[i] = 101300.0 - 13000.0 * expm1(2.173 * (double)i * lscale);
   }
   vlistID = vlistCreate ();
 
-  varDesc = xmalloc((size_t)nVars * sizeof (varDesc[0]));
-  for (int varIdx = 0; varIdx < nVars; varIdx++ )
+  varDesc = (struct varDesc_t *)Malloc(nVars * sizeof (varDesc[0]));
+  for (size_t varIdx = 0; varIdx < nVars; varIdx++ )
     {
       int varLevs = (int)random()%4;
       switch (varLevs)
@@ -227,7 +229,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
         Xt_int varSizeXt[3] = { (Xt_int)nlon, (Xt_int)nlat, (Xt_int)varLevs };
         chunkSize[2] = varLevs;
         Xt_int varStartXt[3] = { start[0], start[1], 0 };
-        for (int i = 0; i < varIdx; ++i)
+        for (size_t i = 0; i < varIdx; ++i)
           if (varDesc[i].nlev == varLevs)
             {
               varDesc[varIdx].redist4gather = varDesc[i].redist4gather;
@@ -252,7 +254,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
             Xt_xmap xmap4gather
               = xt_xmap_all2all_new(part_idxlist, gather_idxlist, comm);
             xt_idxlist_delete(gather_idxlist);
-            struct Xt_offset_ext *src_blocks = xmalloc((size_t)varLevs
+            struct Xt_offset_ext *src_blocks = Malloc((size_t)varLevs
                                                        * sizeof (*src_blocks));
             struct Xt_offset_ext dst_block = { .start = 0,
                                                .size = nlon * nlat * varLevs,
@@ -269,13 +271,13 @@ modelRun(struct model_config setup, MPI_Comm comm)
               = xt_redist_p2p_ext_new(xmap4gather,
                                       varLevs, src_blocks, 1, &dst_block,
                                       MPI_DOUBLE);
-            free(src_blocks);
+            Free(src_blocks);
             xt_xmap_delete(xmap4gather);
           }
         gatherRedistSet: ;
       }
 #endif
-      varDesc[varIdx].code = 129 + varIdx;
+      varDesc[varIdx].code = GRIB_USERDEF + (int)varIdx;
       vlistDefVarCode(vlistID, varDesc[varIdx].id, varDesc[varIdx].code);
       vlistDefVarDatatype(vlistID, varDesc[varIdx].id, setup.datatype);
     }
@@ -294,7 +296,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
 
   for ( tfID = 0; tfID < ntfiles; tfID++ )
     {
-      for (int varIdx = 0; varIdx < nVars; ++varIdx)
+      for (size_t varIdx = 0; varIdx < nVars; ++varIdx)
         varDesc[varIdx].checksum_state = 0;
       if ( tfID > 0 )
 	{
@@ -314,15 +316,15 @@ modelRun(struct model_config setup, MPI_Comm comm)
 	  taxisDefVdate(taxisID, vdatetime[1]);
 	  taxisDefVtime(taxisID, vdatetime[0]);
 	  streamDefTimestep ( streamID, tsID );
-	  for (int varID = 0; varID < nVars; ++varID)
+	  for (size_t varIdx = 0; varIdx < nVars; ++varIdx)
 	    {
-              size_t varLevs = (size_t)varDesc[varID].nlev;
+              size_t varLevs = (size_t)varDesc[varIdx].nlev;
 #ifdef USE_MPI
-              int start[3] = { varDesc[varID].start[0],
-                               varDesc[varID].start[1],
+              int start[3] = { varDesc[varIdx].start[0],
+                               varDesc[varIdx].start[1],
                                0 };
-              int chunk[3] = { varDesc[varID].chunkSize[0],
-                               varDesc[varID].chunkSize[1],
+              int chunk[3] = { varDesc[varIdx].chunkSize[0],
+                               varDesc[varIdx].chunkSize[1],
                                (int)varLevs };
 #else
               int chunk[3] = { nlon, nlat, (int)varLevs };
@@ -333,7 +335,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
                    / (size_t)nproma) * (size_t)nproma * varLevs;
               if (varslice_size < chunkSize)
                 {
-                  varslice = xrealloc(varslice, chunkSize * sizeof (var[0]));
+                  varslice = (double *)Realloc(varslice, chunkSize * sizeof (var[0]));
                   varslice_size = chunkSize;
                 }
               modelRegionCompute(varslice, (int)varLevs, nlat, nlon,
@@ -342,7 +344,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
               if (setup.compute_checksum)
                 {
 #if USE_MPI
-                  xt_redist_s_exchange1(varDesc[varID].redist4gather,
+                  xt_redist_s_exchange1(varDesc[varIdx].redist4gather,
                                         varslice, var);
                   size_t layerSize = (size_t)(chunk[0] * chunk[1]);
                   size_t nblk = (layerSize + nproma - 1)/nproma - 1;
@@ -369,26 +371,26 @@ modelRun(struct model_config setup, MPI_Comm comm)
                 }
               if (rank == 0 && setup.compute_checksum)
                 {
-                  memcrc_r(&varDesc[varID].checksum_state,
+                  memcrc_r(&varDesc[varIdx].checksum_state,
                            (const unsigned char *)vdatetime,
                            sizeof (vdatetime));
-                  memcrc_r(&varDesc[varID].checksum_state,
+                  memcrc_r(&varDesc[varIdx].checksum_state,
                            (const unsigned char *)var,
-                           varDesc[varID].size * sizeof (var[0]));
+                           varDesc[varIdx].size * sizeof (var[0]));
                 }
 
 #ifdef USE_MPI
-	      streamWriteScatteredVarPart(streamID, varDesc[varID].id,
+	      streamWriteScatteredVarPart(streamID, varDesc[varIdx].id,
                                           varslice,
                                           (int)varLevs, blk_lens, blk_displ,
-                                          nmiss, varDesc[varID].partDesc);
+                                          nmiss, varDesc[varIdx].partDesc);
 #else
-	      streamWriteVar(streamID, varDesc[varID].id, var, nmiss);
+	      streamWriteVar(streamID, varDesc[varIdx].id, var, nmiss);
 #endif
 	    }
           current_time += 86400;
 #ifdef USE_MPI
-	  pioWriteTimestep ( tsID, vdate, vtime );
+	  pioWriteTimestep();
 #endif
 	}
       if (rank == 0 && setup.compute_checksum)
@@ -401,7 +403,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
                 perror("failed to open table file");
                 exit(EXIT_FAILURE);
               }
-            for (i = 0; i < nVars; ++i)
+            for (size_t i = 0; i < nVars; ++i)
               {
                 uint32_t cksum;
                 int code;
@@ -422,37 +424,37 @@ modelRun(struct model_config setup, MPI_Comm comm)
           }
         }
     }
-  free(varslice);
+  Free(varslice);
 #ifdef USE_MPI
   pioEndTimestepping ();
 #endif
   streamClose ( streamID );
   vlistDestroy ( vlistID );
   taxisDestroy ( taxisID );
-  for (int varID = 0; varID < nVars; varID++ )
+  for (size_t varIdx = 0; varIdx < nVars; varIdx++ )
     {
-      int zID = varDesc[varID].zaxisID;
+      int zID = varDesc[varIdx].zaxisID;
       if (zID != CDI_UNDEFID)
         {
           zaxisDestroy(zID);
 #if USE_MPI
-          xt_idxlist_delete(varDesc[varID].partDesc);
-          xt_redist_delete(varDesc[varID].redist4gather);
+          xt_idxlist_delete(varDesc[varIdx].partDesc);
+          xt_redist_delete(varDesc[varIdx].redist4gather);
 #endif
-          for (int j = varID + 1; j < nVars; ++j)
+          for (size_t j = varIdx + 1; j < nVars; ++j)
             if (zID == varDesc[j].zaxisID)
               varDesc[j].zaxisID = CDI_UNDEFID;
         }
     }
   gridDestroy ( gridID );
-  free(var);
+  Free(var);
 #if USE_MPI
-  free(blk_displ);
+  Free(blk_displ);
 #endif
-  free(varDesc);
-  free(levs);
-  free(lats);
-  free(lons);
+  Free(varDesc);
+  Free(levs);
+  Free(lats);
+  Free(lons);
 }
 
 #ifdef USE_MPI
@@ -510,7 +512,7 @@ findPartition2D(int npart[2], int num_parts)
         }
       } while (pattern <= lastPattern);
     }
-  free(factors);
+  Free(factors);
 }
 #endif
 
diff --git a/libcdi/tests/pio_cksum_mpi_fw_at_all.in b/libcdi/tests/pio_cksum_mpi_fw_at_all.in
new file mode 100644
index 0000000..3320d5f
--- /dev/null
+++ b/libcdi/tests/pio_cksum_mpi_fw_at_all.in
@@ -0,0 +1,9 @@
+#! @SHELL@
+pio_write_args="-p PIO_MPI_FW_AT_ALL -w 2"
+mpi_task_num=5
+LOG=pio_cksum_mpi_fw_at_all.log
+if [ "@USE_MPI@" = yes ]; then
+  . ./pio_write_run
+else
+  exit 77
+fi
diff --git a/libcdi/tests/pio_cksum_mpi_fw_at_reblock.in b/libcdi/tests/pio_cksum_mpi_fw_at_reblock.in
new file mode 100644
index 0000000..2aeb44d
--- /dev/null
+++ b/libcdi/tests/pio_cksum_mpi_fw_at_reblock.in
@@ -0,0 +1,9 @@
+#! @SHELL@
+pio_write_args="-p PIO_MPI_FW_AT_REBLOCK -w 2"
+mpi_task_num=5
+LOG=pio_cksum_mpi_fw_at_reblock.log
+if [ "@USE_MPI@" = yes ]; then
+  . ./pio_write_run
+else
+  exit 77
+fi
diff --git a/libcdi/tests/pio_cksum_mpi_fw_ordered.in b/libcdi/tests/pio_cksum_mpi_fw_ordered.in
new file mode 100644
index 0000000..a5862f1
--- /dev/null
+++ b/libcdi/tests/pio_cksum_mpi_fw_ordered.in
@@ -0,0 +1,9 @@
+#! @SHELL@
+pio_write_args="-p PIO_MPI_FW_ORDERED -w 2"
+mpi_task_num=5
+LOG=pio_cksum_mpi_fw_ordered.log
+if [ "@USE_MPI@" = yes ]; then
+  . ./pio_write_run
+else
+  exit 77
+fi
diff --git a/libcdi/tests/pio_write.c b/libcdi/tests/pio_write.c
index 3e064e3..b78463c 100644
--- a/libcdi/tests/pio_write.c
+++ b/libcdi/tests/pio_write.c
@@ -5,10 +5,12 @@
 #include <errno.h>
 #include <inttypes.h>
 #include <limits.h>
+#include <stdarg.h>
 #include <stdbool.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <sys/time.h>
 #include <unistd.h>
 
 #ifdef USE_MPI
@@ -26,42 +28,16 @@ typedef int MPI_Comm;
 #include "pio_util.h"
 #endif
 
-void
-modelRun(struct model_config setup, MPI_Comm comm);
-
 static const struct model_config default_setup
+#ifdef __cplusplus
+= { 12, 6, 3, 5, 5, FILETYPE_GRB, DATATYPE_PACK24,1,"grb"};
+#else
   = { .nlon = 12, .nts = 3, .nlat = 6, .nvars = 5,
       .filetype = FILETYPE_GRB, .datatype = DATATYPE_PACK24,
       .compute_checksum = 1,
       .suffix = "grb",
       .max_nlev = 5,
 };
-
-#ifdef USE_MPI
-static const struct {
-  char *text;
-  int mode;
-} mode_map[] = {
-  { "PIO_MPI", PIO_MPI },
-  { "PIO_FPGUARD", PIO_FPGUARD },
-  { "PIO_ASYNCH", PIO_ASYNCH },
-  { "PIO_WRITER", PIO_WRITER }
-};
-
-static inline int
-search_iomode_str(const char *modestr)
-{
-  int retval = -1;
-  for (size_t i = 0;
-       i < sizeof (mode_map) / sizeof (mode_map[0]);
-       ++i)
-    if (!strcmp(modestr, mode_map[i].text))
-      {
-        retval = (int)i;
-        break;
-      }
-  return retval;
-}
 #endif
 
 static const struct {
@@ -77,6 +53,15 @@ static const struct {
   { "ieg", FILETYPE_IEG, DATATYPE_FLT64, GRID_LONLAT },
 };
 
+static void
+invalidOptionDie(const char *format, ...)
+{
+  va_list ap;
+  va_start(ap, format);
+  vfprintf(stderr, format, ap);
+  exit(EXIT_FAILURE);
+}
+
 static int
 parse_intarg(const char msg[])
 {
@@ -88,18 +73,89 @@ parse_intarg(const char msg[])
     exit(EXIT_FAILURE);
   }
   if (temp > INT_MAX || temp < INT_MIN)
-  {
-    fprintf(stderr, "range error: %ld\n", temp);
-    exit(EXIT_FAILURE);
-  }
+    invalidOptionDie("range error: %ld\n", temp);
   return (int)temp;
 }
 
+static unsigned
+parse_unsignedarg(const char msg[])
+{
+  char *end;
+  unsigned long temp = strtoul(optarg, &end, 0);
+  if ((errno == ERANGE && (temp == ULONG_MAX))
+      || (errno != 0 && temp == 0))
+    {
+      perror(msg);
+      exit(EXIT_FAILURE);
+    }
+  if (temp > UINT_MAX)
+    invalidOptionDie("range error: %ld\n", temp);
+  return (unsigned)temp;
+}
+
+typedef int (*pioRoleFunc)(MPI_Comm commSuper, int IOMode, int nProcsIO);
+
+static void
+parse_long_option(int pioConfHandle, pioRoleFunc *pioRoleAssign,
+                  const char *str)
+{
+  static const char cacheRedistStr[] = "cache-redists",
+    pioRoleSchemeOptionStr[] = "pio-role-scheme";
+  if (!strncmp(str, cacheRedistStr, sizeof (cacheRedistStr) - 1))
+    {
+#ifdef USE_MPI
+      if (str[sizeof (cacheRedistStr) - 1] == '\0'
+          || !strcmp(str + sizeof (cacheRedistStr) - 1, "=true"))
+        cdiPioConfSetRedistCache(pioConfHandle, 1);
+      else if (!strcmp(str + sizeof (cacheRedistStr) - 1, "=false"))
+        cdiPioConfSetRedistCache(pioConfHandle, 0);
+      else
+        invalidOptionDie("invalid option argument to -qcache-redists: %s\n",
+                         optarg + sizeof (cacheRedistStr) - 1);
+#else
+      invalidOptionDie("CDI-PIO option -q%s ignored in non-MPI mode\n",
+                       cacheRedistStr);
+#endif
+    }
+  else if (!strncmp(str, pioRoleSchemeOptionStr,
+                    sizeof (pioRoleSchemeOptionStr) - 1))
+    {
+#ifdef USE_MPI
+      static const char pioRoleSchemeLastN[]="last",
+        pioRoleSchemeFirstN[]="first", pioRoleSchemeBalanced[]="balanced";
+      if (str[sizeof (pioRoleSchemeOptionStr) - 1] == '=')
+        {
+          const char *optargarg = str + sizeof (pioRoleSchemeOptionStr);
+          if (!strcmp(optargarg, pioRoleSchemeLastN))
+            *pioRoleAssign = cdiPioCSRLastN;
+          else if (!strcmp(optargarg, pioRoleSchemeFirstN))
+            *pioRoleAssign = cdiPioCSRFirstN;
+          else if (!strcmp(optargarg, pioRoleSchemeBalanced))
+            *pioRoleAssign = cdiPioCSRBalanced;
+          else
+            invalidOptionDie("unknown scheme argument \"%s\" to -q%s",
+                             optargarg, pioRoleSchemeOptionStr);
+        }
+      else
+        invalidOptionDie("long option %s needs argument\n",
+                         pioRoleSchemeOptionStr);
+#else
+      invalidOptionDie("CDI-PIO option -q%s ignored in non-MPI mode\n",
+                       pioRoleSchemeOptionStr);
+#endif
+    }
+  else
+    invalidOptionDie("unknown long option: %s\n", str);
+}
+
+
 int main(int argc, char *argv[])
 {
   struct model_config setup = default_setup;
 
   MPI_Comm commModel;
+  int pioConfHandle = 0;
+  pioRoleFunc pioRoleAssign = 0;
 #ifdef USE_MPI
   MPI_Comm commGlob;
   int sizeGlob;
@@ -113,11 +169,32 @@ int main(int argc, char *argv[])
   xmpi ( MPI_Comm_set_errhandler ( commGlob, MPI_ERRORS_RETURN ));
   xmpi ( MPI_Comm_size ( commGlob, &sizeGlob ));
   xmpi ( MPI_Comm_rank ( commGlob, &rankGlob ));
+
+  pioConfHandle = cdiPioConfCreate();
+  pioRoleAssign = cdiPioCSRLastN;
 #endif
 
+  /* seed random generator */
+  unsigned randSeed;
+  {
+#ifdef USE_MPI
+    if (rankGlob == 0)
+#endif
+      {
+        struct timeval tv;
+        int status = gettimeofday(&tv, NULL);
+        if (status != 0)
+          {
+            perror("failed seed generation!");
+            exit(1);
+          }
+        randSeed = (unsigned)(tv.tv_sec ^ tv.tv_usec);
+      }
+  }
+
   {
     int opt;
-    while ((opt = getopt(argc, argv, "f:m:n:z:t:y:c"
+    while ((opt = getopt(argc, argv, "f:m:n:z:t:y:cs:q:"
 #ifdef USE_MPI
                          "p:w:"
 #endif
@@ -125,15 +202,12 @@ int main(int argc, char *argv[])
       switch (opt) {
 #ifdef USE_MPI
       case 'p':
-        {
-          int entry = search_iomode_str(optarg);
-          if (entry < 0)
-            {
-              fprintf(stderr, "Unsupported PIO mode requested: %s\n", optarg);
-              exit(EXIT_FAILURE);
-            }
-          IOMode = mode_map[entry].mode;
-        }
+        IOMode = cdiPioStr2IOMode(optarg);
+        if (IOMode < 0)
+          {
+            fprintf(stderr, "Unsupported PIO mode requested: %s\n", optarg);
+            exit(EXIT_FAILURE);
+          }
         break;
       case 'w':
         {
@@ -147,6 +221,9 @@ int main(int argc, char *argv[])
         }
         break;
 #endif
+      case 'q':
+        parse_long_option(pioConfHandle, &pioRoleAssign, optarg);
+        break;
       case 'f':
         {
           int found = 0;
@@ -204,6 +281,9 @@ int main(int argc, char *argv[])
       case 'c':
         setup.compute_checksum = 0;
         break;
+      case 's':
+        randSeed = parse_unsignedarg("error parsing random seed");
+        break;
       default: /* '?' */
         fprintf(stderr, "Usage: %s "
                 "[-m nlon] [-n nlat] [-z nlev] [-t nts] [-y num_vars]"
@@ -217,9 +297,22 @@ int main(int argc, char *argv[])
   }
 
 #ifdef USE_MPI
+  MPI_Bcast(&randSeed, 1, MPI_UNSIGNED, 0, MPI_COMM_WORLD);
+#endif
+  srandom(randSeed);
+#ifdef USE_MPI
+  if (rankGlob == 0)
+#endif
+    fprintf(stderr, "random seed=%u\n", randSeed);
+
+#ifdef USE_MPI
   int pioNamespace;
-  commModel = pioInit(commGlob, nProcsIO, IOMode, &pioNamespace, 1.0,
-                      cdiPioNoPostCommSetup);
+  cdiPioConfSetIOMode(pioConfHandle, IOMode);
+  cdiPioConfSetCSRole(pioConfHandle, pioRoleAssign(commGlob, IOMode,
+                                                   nProcsIO));
+  cdiPioConfSetPartInflate(pioConfHandle, 1.0f);
+  int initNamespace = namespaceGetActive();
+  commModel = cdiPioInit(commGlob, pioConfHandle, &pioNamespace);
   if (commModel != MPI_COMM_NULL)
     {
       namespaceSetActive(pioNamespace);
@@ -231,6 +324,8 @@ int main(int argc, char *argv[])
 
 #ifdef USE_MPI
     }
+  namespaceSetActive(initNamespace);
+  cdiPioConfDestroy(pioConfHandle);
   pioFinalize ();
   xt_finalize();
   MPI_Finalize ();
diff --git a/libcdi/tests/pio_write.h b/libcdi/tests/pio_write.h
index 66b3762..9a9ed6a 100644
--- a/libcdi/tests/pio_write.h
+++ b/libcdi/tests/pio_write.h
@@ -15,4 +15,7 @@ struct model_config
   const char *suffix;
 };
 
+void
+modelRun(struct model_config setup, MPI_Comm comm);
+
 #endif
diff --git a/libcdi/tests/pio_write_run.in b/libcdi/tests/pio_write_run.in
index e3a691f..fba1426 100644
--- a/libcdi/tests/pio_write_run.in
+++ b/libcdi/tests/pio_write_run.in
@@ -1,23 +1,29 @@
 #! @SHELL@
 set -e
 LOG="${LOG-pio_write.log}"
-if [ @ENABLE_GRIB@ = yes ]; then
-  mpi_task_num="${mpi_task_num-4}"
-  suffix="${suffix-grb}"
+if [ @ENABLE_GRIB@ != yes ]; then
+  # skip tests for unsupported formats
+  exit 77
+fi
+mpi_task_num="${mpi_task_num-4}"
+suffix="${suffix-grb}"
+if [ "@USE_MPI@" = yes ]; then
+  variations="-qcache-redists"
+else
+  unset variations
+fi
+for variation in "" $variations ; do
   exec 5>&1 6>&2 >"$LOG" 2>&1
   ../libtool --mode=execute \
     @MPI_LAUNCH@ \
-    -n ${mpi_task_num} ${tool_wrap} ./pio_write ${pio_write_args}
+    -n ${mpi_task_num} ${tool_wrap} ./pio_write ${pio_write_args} ${variation}
   exec 2>&6 1>&5 5>&- 6>&-
   ../libtool --mode=execute \
     ${tool_wrap} ./cksum_read example_0.${suffix} example_0.cksum
   ../libtool --mode=execute \
     ${tool_wrap} ./cksum_read example_1.${suffix} example_1.cksum
   \rm "$LOG"
-else
-  # skip tests for unsupported formats
-  exit 77
-fi
+done
 #
 # Local Variables:
 # mode: sh
diff --git a/libcdi/tests/simple_model.c b/libcdi/tests/simple_model.c
index 079433b..f46c620 100644
--- a/libcdi/tests/simple_model.c
+++ b/libcdi/tests/simple_model.c
@@ -63,7 +63,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
 {
   static const char * const fname_prefix        = "example";
 
-  struct
+  struct varDesc_t
   {
     size_t size;
     int nlev, zaxisID, id, code;
@@ -74,7 +74,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
 #endif
   } *varDesc;
   int gridID, taxisID, vlistID, streamID, tsID, tfID = 0;
-  int i, nmiss = 0;
+  enum { nmiss = 0 };
   double *lons, *lats, *levs;
   double *var = NULL, *varslice = NULL;
   double mscale, mrscale;
@@ -83,7 +83,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
   int rank = 0;
   char filename[1024];
   int nlon = setup.nlon, nlat = setup.nlat;
-  int nVars = setup.nvars;
+  size_t nVars = (size_t)setup.nvars;
   size_t varslice_size = 0;
 #if USE_MPI
   int *chunks = NULL, *displs = NULL, comm_size = 1;
@@ -94,11 +94,13 @@ modelRun(struct model_config setup, MPI_Comm comm)
   xmpi ( MPI_Comm_size ( comm, &comm_size ));
   if (rank == 0 && setup.compute_checksum)
     {
-      chunks = xmalloc((size_t)comm_size * sizeof (chunks[0]));
-      displs = xmalloc((size_t)comm_size * sizeof (displs[0]));
-      var = xmalloc((size_t)nlon * (size_t)nlat
+      chunks = malloc((size_t)comm_size * sizeof (chunks[0]));
+      displs = malloc((size_t)comm_size * sizeof (displs[0]));
+      var = malloc((size_t)nlon * (size_t)nlat
                     * (size_t)setup.max_nlev * sizeof(var[0]));
     }
+#else
+  (void)comm;
 #endif
 
   var_scale(setup.datatype, &mscale, &mrscale);
@@ -106,11 +108,11 @@ modelRun(struct model_config setup, MPI_Comm comm)
   gridID = gridCreate ( GRID_LONLAT, nlon*nlat );
   gridDefXsize ( gridID, nlon );
   gridDefYsize ( gridID, nlat );
-  lons = xmalloc((size_t)nlon * sizeof (lons[0]));
-  for (i = 0; i < nlon; ++i)
+  lons = (double *)malloc((size_t)nlon * sizeof (lons[0]));
+  for (size_t i = 0; i < (size_t)nlon; ++i)
     lons[i] = ((double)(i * 360))/nlon;
-  lats = xmalloc((size_t)nlat * sizeof (lats[0]));
-  for (i = 0; i < nlat; ++i)
+  lats = (double *)malloc((size_t)nlat * sizeof (lats[0]));
+  for (size_t i = 0; i < (size_t)nlat; ++i)
     lats[i] = ((double)(i * 180))/nlat - 90.0;
   gridDefXvals ( gridID, lons );
   gridDefYvals ( gridID, lats );
@@ -123,16 +125,16 @@ modelRun(struct model_config setup, MPI_Comm comm)
 #endif
     gridDefUUID(gridID, uuid);
   }
-  levs = xmalloc((size_t)setup.max_nlev * sizeof (levs[0]));
+  levs = (double *)malloc((size_t)setup.max_nlev * sizeof (levs[0]));
   {
     double lscale = 1.0/(double)(setup.max_nlev - 1);
-    for (i = 0; i < setup.max_nlev; ++i)
+    for (size_t i = 0; i < (size_t)setup.max_nlev; ++i)
       levs[i] = 101300.0 - 13000.0 * expm1(2.173 * (double)i * lscale);
   }
   vlistID = vlistCreate ();
 
-  varDesc = xmalloc((size_t)nVars * sizeof (varDesc[0]));
-  for (int varIdx = 0; varIdx < nVars; varIdx++ )
+  varDesc = (struct varDesc_t *)malloc(nVars * sizeof (varDesc[0]));
+  for (size_t varIdx = 0; varIdx < nVars; varIdx++ )
     {
       int varLevs = (int)random()%4;
       switch (varLevs)
@@ -192,7 +194,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
         varDesc[varIdx].partDesc = idxlist;
       }
 #endif
-      varDesc[varIdx].code = 129 + varIdx;
+      varDesc[varIdx].code = GRIB_USERDEF + (int)varIdx;
       vlistDefVarCode(vlistID, varDesc[varIdx].id, varDesc[varIdx].code);
       vlistDefVarDatatype(vlistID, varDesc[varIdx].id, setup.datatype);
     }
@@ -211,7 +213,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
 
   for ( tfID = 0; tfID < ntfiles; tfID++ )
     {
-      for (int varIdx = 0; varIdx < nVars; ++varIdx)
+      for (size_t varIdx = 0; varIdx < nVars; ++varIdx)
         varDesc[varIdx].checksum_state = 0;
       if ( tfID > 0 )
 	{
@@ -239,22 +241,22 @@ modelRun(struct model_config setup, MPI_Comm comm)
                * return */
               vdatetime[0] = 0;
             }
-	  for (int varID = 0; varID < nVars; ++varID)
+	  for (size_t varIdx = 0; varIdx < nVars; ++varIdx)
 	    {
 #ifdef USE_MPI
-              int start = varDesc[varID].start;
-              int chunk = varDesc[varID].chunkSize;
+              int start = varDesc[varIdx].start;
+              int chunk = varDesc[varIdx].chunkSize;
 #else
-              int chunk = (int)varDesc[varID].size;
+              int chunk = (int)varDesc[varIdx].size;
               int start = 0;
 #endif
               if (varslice_size < (size_t)chunk)
                 {
-                  varslice = xrealloc(varslice, (size_t)chunk * sizeof (var[0]));
+                  varslice = (double *)realloc(varslice, (size_t)chunk * sizeof (var[0]));
                   varslice_size = (size_t)chunk;
                 }
               modelRegionCompute(varslice, (size_t)start, (size_t)chunk,
-                                 varDesc[varID].nlev, nlat, nlon,
+                                 varDesc[varIdx].nlev, nlat, nlon,
                                  tsID, lons, lats,
                                  mscale, mrscale);
               if (setup.compute_checksum)
@@ -265,7 +267,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
                   if (rank == 0)
                     {
                       displs[0] = 0;
-                      for (i = 1; i < comm_size; ++i)
+                      for (size_t i = 1; i < (size_t)comm_size; ++i)
                         displs[i] = displs[i - 1] + chunks[i - 1];
                     }
                   xmpi(MPI_Gatherv(varslice, chunk, MPI_DOUBLE,
@@ -276,24 +278,24 @@ modelRun(struct model_config setup, MPI_Comm comm)
                 }
               if (rank == 0 && setup.compute_checksum)
                 {
-                  memcrc_r(&varDesc[varID].checksum_state,
+                  memcrc_r(&varDesc[varIdx].checksum_state,
                            (const unsigned char *)vdatetime,
                            sizeof (vdatetime));
-                  memcrc_r(&varDesc[varID].checksum_state,
+                  memcrc_r(&varDesc[varIdx].checksum_state,
                            (const unsigned char *)var,
-                           varDesc[varID].size * sizeof (var[0]));
+                           varDesc[varIdx].size * sizeof (var[0]));
                 }
 
 #ifdef USE_MPI
-	      streamWriteVarPart(streamID, varDesc[varID].id, varslice, nmiss,
-                                 varDesc[varID].partDesc);
+	      streamWriteVarPart(streamID, varDesc[varIdx].id, varslice, nmiss,
+                                 varDesc[varIdx].partDesc);
 #else
-	      streamWriteVar(streamID, varDesc[varID].id, varslice, nmiss);
+	      streamWriteVar(streamID, varDesc[varIdx].id, varslice, nmiss);
 #endif
 	    }
           current_time += 86400;
 #ifdef USE_MPI
-	  pioWriteTimestep ( tsID, vdate, vtime );
+	  pioWriteTimestep();
 #endif
 	}
       if (rank == 0 && setup.compute_checksum)
@@ -306,7 +308,7 @@ modelRun(struct model_config setup, MPI_Comm comm)
                 perror("failed to open table file");
                 exit(EXIT_FAILURE);
               }
-            for (i = 0; i < nVars; ++i)
+            for (size_t i = 0; i < (size_t)nVars; ++i)
               {
                 uint32_t cksum;
                 int code;
@@ -327,36 +329,34 @@ modelRun(struct model_config setup, MPI_Comm comm)
           }
         }
     }
-  free(varslice);
+  Free(varslice);
 #ifdef USE_MPI
   pioEndTimestepping ();
 #endif
   streamClose ( streamID );
   vlistDestroy ( vlistID );
   taxisDestroy ( taxisID );
-  for (int varID = 0; varID < nVars; varID++ )
+  for (size_t varIdx = 0; varIdx < nVars; varIdx++ )
     {
-      int zID = varDesc[varID].zaxisID;
+      int zID = varDesc[varIdx].zaxisID;
       if (zID != CDI_UNDEFID)
         {
           zaxisDestroy(zID);
-          for (int j = varID + 1; j < nVars; ++j)
+          for (size_t j = varIdx + 1; j < nVars; ++j)
             if (zID == varDesc[j].zaxisID)
               varDesc[j].zaxisID = CDI_UNDEFID;
         }
     }
   gridDestroy ( gridID );
 #if USE_MPI
-  for (int varID = 0; varID < nVars; ++varID)
-    xt_idxlist_delete(varDesc[varID].partDesc);
-  free(displs);
-  free(chunks);
-  free(var);
+  Free(displs);
+  Free(chunks);
+  Free(var);
 #endif
-  free(varDesc);
-  free(levs);
-  free(lats);
-  free(lons);
+  Free(varDesc);
+  Free(levs);
+  Free(lats);
+  Free(lons);
 }
 
 /*
diff --git a/libcdi/tests/simple_model_helper.c b/libcdi/tests/simple_model_helper.c
index 9947774..6744380 100644
--- a/libcdi/tests/simple_model_helper.c
+++ b/libcdi/tests/simple_model_helper.c
@@ -107,7 +107,7 @@ int
 PPM_prime_factorization_32(uint32_t n, uint32_t **factors)
 {
   if (n <= 1) return 0;
-  uint32_t * restrict pfactors = xrealloc(*factors, 32 * sizeof (pfactors[0]));
+  uint32_t * restrict pfactors = realloc(*factors, 32 * sizeof (pfactors[0]));
   size_t numFactors = 0;
   uint32_t unfactored = n;
   while (!(unfactored & 1))
diff --git a/libcdi/tests/simple_model_helper.h b/libcdi/tests/simple_model_helper.h
index b7509e8..abe2b5c 100644
--- a/libcdi/tests/simple_model_helper.h
+++ b/libcdi/tests/simple_model_helper.h
@@ -9,14 +9,20 @@
 #include <math.h>
 #include <time.h>
 
+
+enum {
+  /* 129 is the first user-defined code of the GRIB format */
+  GRIB_USERDEF = 129,
+};
+
 void
 var_scale(int datatype, double *mscale, double *mrscale);
 
 static inline double
 sign_flat(double v)
 {
-  if (v == 0.0)
-    return 0.0;
+  if (!(v < 0.0 || v > 0.0)) return 0.0;
+  //    if (v == 0.0) return 0.0;
   return v;
 }
 
diff --git a/libcdi/tests/stream_cksum.c b/libcdi/tests/stream_cksum.c
index 3704a7d..93baaa4 100644
--- a/libcdi/tests/stream_cksum.c
+++ b/libcdi/tests/stream_cksum.c
@@ -16,7 +16,7 @@ cksum_stream(const char *fname, size_t *table_len)
   int nvars, ngrids, nzaxis;
   int i;
   uint32_t *checksum_state = NULL;
-  struct
+  struct var_size_t
   {
     int x, y, z;
     size_t chars;
@@ -49,8 +49,8 @@ cksum_stream(const char *fname, size_t *table_len)
         nvars = -1;
         break;
       }
-    checksum_state = xcalloc((size_t)nvars, sizeof (checksum_state[0]));
-    varSize = xmalloc((size_t)nvars * sizeof (varSize[0]));
+    checksum_state = (uint32_t *) Calloc((size_t)nvars, sizeof (checksum_state[0]));
+    varSize = (struct var_size_t *)malloc((size_t)nvars * sizeof (varSize[0]));
 
     for (i = 0; i < nvars; ++i)
       {
@@ -95,7 +95,7 @@ cksum_stream(const char *fname, size_t *table_len)
       if (var_size_max_chars < varSize[i].chars)
         var_size_max_chars = varSize[i].chars;
     }
-    buf = xmalloc(var_size_max_chars);
+    buf = (double*)malloc(var_size_max_chars);
 
     if (nvars == -1)
       break;
@@ -121,7 +121,7 @@ cksum_stream(const char *fname, size_t *table_len)
         ++tsID;
       }
 
-    file_vars = xmalloc((size_t)nvars * sizeof (file_vars[0]));
+    file_vars = (struct cksum_table *)malloc((size_t)nvars * sizeof (file_vars[0]));
     for (i = 0; i < nvars; ++i)
       {
         file_vars[i].code = vlistInqVarCode(vlistID, i);
diff --git a/libcdi/tests/test_byteswap.c b/libcdi/tests/test_byteswap.c
new file mode 100644
index 0000000..af87667
--- /dev/null
+++ b/libcdi/tests/test_byteswap.c
@@ -0,0 +1,13 @@
+#include <assert.h>
+#include <stdlib.h>
+
+#include "cdi.h"
+
+/* function called by CDO */
+extern int getByteswap(int);
+
+int main()
+{
+  assert(getByteswap(-1) == -1);
+  return EXIT_SUCCESS;
+}
diff --git a/libcdi/tests/test_cdf_read.c b/libcdi/tests/test_cdf_read.c
index 167158c..a870617 100644
--- a/libcdi/tests/test_cdf_read.c
+++ b/libcdi/tests/test_cdf_read.c
@@ -44,7 +44,7 @@ int main(int argc, const char **argv)
           int nmiss;
           if (memSize > bufSize)
             {
-              double *temp = realloc(buf, memSize);
+              double *temp = (double *)realloc(buf, memSize);
               if (!temp)
                 {
                   perror("read buffer reallocation failed");
@@ -55,7 +55,6 @@ int main(int argc, const char **argv)
           streamReadVar(streamID, (int)varID, buf, &nmiss);
           allNmissSum += (size_t)nmiss;
         }
-      ++tsID;
     }
   if (countMissingValues)
     printf("missing values count = %zu\n", allNmissSum);
@@ -89,14 +88,17 @@ printAtts(int vlistID)
                                attName, &attType, &attLen);
           {
             const char *varDesc = varIdx > 0
-              ? (sprintf(buf, "%s%d", varDescPrefix,
-                         vlistInqVarCode(vlistID, varID)), buf)
+              ? (sprintf((char *)buf, "%s%d", varDescPrefix,
+                         vlistInqVarCode(vlistID, varID)), (char *)buf)
               : globDesc;
             printf("%s attribute \"%s\", value: ",
                    varDesc, attName);
           }
           if (attLen < 0)
-            goto attGetFail;
+            {
+            puts("error retrieving value");
+            continue;
+            }
           size_t elemSize = 0;
           switch (attType)
             {
@@ -125,16 +127,16 @@ printAtts(int vlistID)
             {
             case DATATYPE_TXT:
               rc = vlistInqAttTxt(vlistID, (int)varID, attName,
-                                  attLen, buf);
+                                  attLen, (char *)buf);
               if (rc == CDI_NOERR)
                 printf("\"%.*s\"", attLen, (char *)buf);
               break;
             case DATATYPE_FLT:
               rc = vlistInqAttFlt(vlistID, (int)varID, attName,
-                                  attLen + 1, buf);
+                                  attLen + 1, (double *)buf);
               if (rc == CDI_NOERR && attLen)
                 {
-                  const double *restrict dp = buf;
+                  const double *restrict dp = (const double*)buf;
                   printf("%10g", dp[0]);
                   for (size_t i = 1; i < (size_t)attLen; ++i)
                     printf(", %10g", dp[i]);
@@ -142,10 +144,10 @@ printAtts(int vlistID)
               break;
             case DATATYPE_INT:
               rc = vlistInqAttInt(vlistID, (int)varID, attName,
-                                  attLen + 1, buf);
+                                  attLen + 1, (int *)buf);
               if (rc == CDI_NOERR && attLen)
                 {
-                  const int *restrict ip = buf;
+                  const int *restrict ip = (const int *)buf;
                   printf("%d", ip[0]);
                   for (size_t i = 1; i < (size_t)attLen; ++i)
                     printf(", %d", ip[i]);
@@ -159,7 +161,6 @@ printAtts(int vlistID)
             }
           else
             {
-              attGetFail:
               puts("error retrieving value");
             }
         }
diff --git a/libcdi/tests/test_cdf_write.c b/libcdi/tests/test_cdf_write.c
index b3f4fff..43e01b3 100644
--- a/libcdi/tests/test_cdf_write.c
+++ b/libcdi/tests/test_cdf_write.c
@@ -50,10 +50,17 @@ int main(int argc, const char **argv)
   {
     /* anti-clockwise coordinates around Amazonia */
     static struct cart_coord region[4]
-      = { { .lon = DEG2RAD(-85.0), .lat = DEG2RAD(-25.0) },
+#ifdef __cplusplus
+      = { { DEG2RAD(-25.0), DEG2RAD(-85.0) },
+          { DEG2RAD(-18.0), DEG2RAD(-44.0) },
+          { DEG2RAD(-7.0),  DEG2RAD(-50.0) },
+          { DEG2RAD(10.0),  DEG2RAD(-80.0) } };
+#else
+    = { { .lon = DEG2RAD(-85.0), .lat = DEG2RAD(-25.0) },
           { .lon = DEG2RAD(-44.0), .lat = DEG2RAD(-18.0) },
           { .lon = DEG2RAD(-50.0), .lat = DEG2RAD(7.0) },
           { .lon = DEG2RAD(-80.0), .lat = DEG2RAD(10.0) } };
+#endif
     double (*gridCoords)[sizey][sizex]
       = (double (*)[sizey][sizex])
       malloc(sizeof (*gridCoords) * sizey * sizex * 2);
@@ -87,7 +94,7 @@ int main(int argc, const char **argv)
   (void)streamDefTimestep(streamID, 0);
 
   {
-    double (*data)[sizex] = malloc(sizeof (**data) * sizex * sizey);
+    double (*data)[sizex] = (double(*)[sizex])malloc(sizeof (**data) * sizex * sizey);
     if (!data)
       {
         perror("data values memory allocation failed");
@@ -137,7 +144,11 @@ static void
 compute_curvilinear(double *coords_,
                     const struct cart_coord a[4], size_t sizex, size_t sizey)
 {
+#ifdef __cplusplus
+  auto coords = (double (*)[sizey][sizex])coords_;
+#else
   double (*coords)[sizey][sizex] = (double (*)[sizey][sizex])coords_;
+#endif
   for (size_t j = 0; j < sizey; ++j)
     {
       double g = (double)j / (double)(sizey - 1);
diff --git a/libcdi/tests/test_grib.c b/libcdi/tests/test_grib.c
index cc4c789..7f9fe33 100644
--- a/libcdi/tests/test_grib.c
+++ b/libcdi/tests/test_grib.c
@@ -30,7 +30,7 @@ int main()
 
 
   size_t datasize = (size_t)nlon * (size_t)nlat;
-  data = (double *)xmalloc(datasize * sizeof (double));
+  data = (double *)malloc(datasize * sizeof (double));
   memset(data, 0, datasize * sizeof (double));
 
   gridID = gridCreate(GRID_GAUSSIAN, (int)datasize);
@@ -79,14 +79,14 @@ int main()
 
   for ( varID = 0; varID < nvars; varID++ )
     {
-      int gridID      = vlistInqVarGrid(vlistID, varID);
-      int zaxisID     = vlistInqVarZaxis(vlistID, varID);
-      size_t gridsize = (size_t)gridInqSize(gridID);
-      size_t nlevel   = (size_t)zaxisInqSize(zaxisID);
-      if ( gridsize*nlevel > datasize ) datasize = gridsize*nlevel;
+      int varGridID      = vlistInqVarGrid(vlistID, varID);
+      int varZaxisID     = vlistInqVarZaxis(vlistID, varID);
+      size_t gridsize = (size_t)gridInqSize(varGridID);
+      size_t varNlevel   = (size_t)zaxisInqSize(varZaxisID);
+      if ( gridsize*varNlevel > datasize ) datasize = gridsize*varNlevel;
     }
 
-  data = (double *)xrealloc(data, datasize*sizeof(double));
+  data = (double *)realloc(data, datasize*sizeof(double));
   memset(data, 0, datasize*sizeof(double));
 
   taxisID = vlistInqTaxis(vlistID);
diff --git a/libcdi/tests/test_resource_copy.c b/libcdi/tests/test_resource_copy.c
index c0a4f89..c662fac 100644
--- a/libcdi/tests/test_resource_copy.c
+++ b/libcdi/tests/test_resource_copy.c
@@ -28,11 +28,11 @@ enum {
   nlev             = 5,
   ntsteps          = 3 };
 
-double lons[nlon] = {0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330};
-double lats[nlat] = {-75, -45, -15, 15, 45, 75};
-double levs[nlev] = {101300, 92500, 85000, 50000, 20000};
+static double lons[nlon] = {0, 30, 60, 90, 120, 150, 180, 210, 240, 270, 300, 330};
+static double lats[nlat] = {-75, -45, -15, 15, 45, 75};
+static double levs[nlev] = {101300, 92500, 85000, 50000, 20000};
 
-int defineGrid ()
+static int defineGrid (void)
 {
   int gridID = CDI_UNDEFID;
   int mask_vec[nlon*nlat];
@@ -94,7 +94,7 @@ int defineGrid ()
   return gridID;
 }
 
-int defineZaxis ()
+static int defineZaxis (void)
 {
   int zaxisID = CDI_UNDEFID;
   double vct[3] = { 3.0, 3.3, 3.6 };
@@ -120,7 +120,7 @@ int defineZaxis ()
   return zaxisID;
 }
 
-int defineTaxis ()
+static int defineTaxis (void)
 {
   int taxisID = CDI_UNDEFID;
 
@@ -140,7 +140,7 @@ int defineTaxis ()
   return taxisID;
 }
 
-void defineStream ( int streamID, int vlistID )
+static void defineStream ( int streamID, int vlistID )
 {
   streamDefByteorder ( streamID, 1 );
   streamDefCompType  ( streamID, 2 );
@@ -152,7 +152,7 @@ struct idPair {
   int id1, id2;
 };
 
-struct idPair defineVlist ( int gridID, int zaxisID, int taxisID )
+static struct idPair defineVlist ( int gridID, int zaxisID, int taxisID )
 {
   int vlistID = CDI_UNDEFID;
   int zaxisID2 = zaxisCreate(ZAXIS_SURFACE, 1);
@@ -176,7 +176,7 @@ struct idPair defineVlist ( int gridID, int zaxisID, int taxisID )
   return (struct idPair){ vlistID, vlistID2 };
 }
 
-int defineInstitute ()
+static int defineInstitute ()
 {
   int instID = CDI_UNDEFID;
 
@@ -185,7 +185,7 @@ int defineInstitute ()
   return instID;
 }
 
-int defineModel ( int instID )
+static int defineModel ( int instID )
 {
   int modelID = CDI_UNDEFID;
 
@@ -196,7 +196,7 @@ int defineModel ( int instID )
 
 static int destNamespace;
 
-int modelRun(MPI_Comm comm)
+static int modelRun(MPI_Comm comm)
 {
   int gridID, zaxisID, taxisID, instID, vlistID, streamID;
 
@@ -222,7 +222,7 @@ int modelRun(MPI_Comm comm)
   }
 
   reshPackBufferCreate ( &sendBuffer, &bufferSize, &comm );
-  recvBuffer = xmalloc((size_t)bufferSize);
+  recvBuffer = (char *)malloc((size_t)bufferSize);
 #ifdef MPI_MARSHALLING
   xmpi(MPI_Sendrecv(sendBuffer, bufferSize, MPI_PACKED, 0, 0,
                     recvBuffer, bufferSize, MPI_PACKED, 0, 0,
diff --git a/libcdi/tests/test_table.c b/libcdi/tests/test_table.c
new file mode 100644
index 0000000..1bbd120
--- /dev/null
+++ b/libcdi/tests/test_table.c
@@ -0,0 +1,10 @@
+#include <assert.h>
+#include <stdlib.h>
+
+#include "cdi.h"
+
+int main()
+{
+  assert(tableInqParName(-1, -1, NULL) != 0);
+  return EXIT_SUCCESS;
+}
diff --git a/m4/._ax_pthread.m4 b/m4/._ax_pthread.m4
deleted file mode 100644
index cddd2a5..0000000
Binary files a/m4/._ax_pthread.m4 and /dev/null differ
diff --git a/m4/acx_options.m4 b/m4/acx_options.m4
index a3c77df..7367fdd 100644
--- a/m4/acx_options.m4
+++ b/m4/acx_options.m4
@@ -143,23 +143,23 @@ ENABLE_NC2=no
 ENABLE_NC4=no
 ENABLE_NC4HDF5=no
 AC_ARG_WITH([netcdf],
-            [AS_HELP_STRING([--with-netcdf=<yes|no|directory> (default=no)],[location of netcdf library (lib and include subdirs)])],
+            [AS_HELP_STRING([--with-netcdf=<yes|no|directory> (default=no)],[location of netCDF library (lib and include subdirs)])],
             [AS_CASE(["$with_netcdf"],
-                     [no],[AC_MSG_CHECKING([for netcdf library])
+                     [no],[AC_MSG_CHECKING([for netCDF library])
                            AC_MSG_RESULT([suppressed])],
                      [yes],[AC_CHECK_HEADERS([netcdf.h])
                             AC_SEARCH_LIBS([nc_open],
                                            [netcdf],
-                                           [AC_DEFINE([HAVE_LIBNETCDF],[1],[Define to 1 for NETCDF support])
+                                           [AC_DEFINE([HAVE_LIBNETCDF],[1],[Define to 1 for netCDF support])
                                             ENABLE_NETCDF=yes],
-                                           [AC_MSG_ERROR([Could not link to netcdf library])])
+                                           [AC_MSG_ERROR([Could not link to netCDF library])])
                             NETCDF_LIBS=" -lnetcdf"
 			    
                             AC_CHECK_PROG(NC_CONFIG,nc-config,nc-config)
                             AS_IF([test "x$NC_CONFIG" != "x"],
                                   [AC_MSG_CHECKING([netcdf's nc2 support])
                                    AS_IF([test "x$($NC_CONFIG --has-nc2)" = "xyes"],
-                                         [AC_DEFINE([HAVE_NETCDF2],[1],[Define to 1 for NETCDF2 support])
+                                         [AC_DEFINE([HAVE_NETCDF2],[1],[Define to 1 for netCDF2 support])
                                           ENABLE_NC2=yes
                                           AC_MSG_RESULT([yes])],[AC_MSG_RESULT([no])])
                                    AC_MSG_CHECKING([netcdf's nc4 support])
@@ -226,39 +226,38 @@ AC_SUBST([NETCDF_ROOT])
 AC_SUBST([NETCDF_INCLUDE])
 AC_SUBST([NETCDF_LIBS])
 #  ----------------------------------------------------------------------
-#  Link application with JASPER library (needed for GRIB2 compression)
-JASPER_LIBS=''
-AC_ARG_WITH([jasper],
-            [AS_HELP_STRING([--with-jasper=<directory>],
-                            [Specify location of JASPER library. You must specify its location if GRIB_API was built with JASPER.])],
-            [AS_CASE(["$with_jasper"],
-                     [no],[AC_MSG_CHECKING([for jasper library])
+#  Link application with CMOR library
+CMOR_LIBS=''
+AC_ARG_WITH([cmor],
+            [AS_HELP_STRING([--with-cmor=<directory>],
+                            [Specify location of CMOR library.])],
+            [AS_CASE(["$with_cmor"],
+                     [no],[AC_MSG_CHECKING([for cmor library])
                            AC_MSG_RESULT([suppressed])],
-                     [yes],[AC_CHECK_HEADERS([jasper.h])
-                            AC_SEARCH_LIBS([jas_init],[jasper],[AC_DEFINE([HAVE_LIBJASPER],[1],[Define to 1 for JPEG compression for GRIB2])],
-                                           [AC_MSG_ERROR([Could not link to jasper library! Required for GRIB_API])])
-                            AC_SUBST([JASPER_LIBS],[" -ljasper"])],
-                     [*],[JASPER_ROOT=$with_jasper
-                          AS_IF([test -d "$JASPER_ROOT"],
-                                [LDFLAGS="$LDFLAGS -L$JASPER_ROOT/lib"
-                                 CPPFLAGS="$CPPFLAGS -I$JASPER_ROOT/include"
-                                 AC_SEARCH_LIBS([jas_stream_memopen],
-                                                [jasper],
-                                                [AC_DEFINE([HAVE_LIBJASPER],[1],[Define to 1 for JPEG compression for GRIB2])],
-                                                [AC_MSG_ERROR([Could not link to jasper library! Required for GRIB_API])])
-                                 JASPER_LIBS=" -L$JASPER_ROOT/lib -ljasper"],
-                                [AC_MSG_ERROR([$JASPER_ROOT is not a directory! JASPER suppressed])])])],
-            [AC_MSG_CHECKING([for the JASPER library])
+                     [yes],[AC_CHECK_HEADERS([cmor.h])
+                            AC_SEARCH_LIBS([cmor_load_table],[cmor],[AC_DEFINE([HAVE_LIBCMOR],[1],[Define to 1 for CMOR support])],
+                                           [AC_MSG_ERROR([Could not link to cmor library!])])
+                            AC_SUBST([CMOR_LIBS],[" -lcmor"])],
+                     [*],[CMOR_ROOT=$with_cmor
+                          AS_IF([test -d "$CMOR_ROOT"],
+                                [LDFLAGS="$LDFLAGS -L$CMOR_ROOT/lib"
+                                 CPPFLAGS="$CPPFLAGS -I$CMOR_ROOT/include"
+                                 AC_SEARCH_LIBS([cmor_load_table],
+                                                [cmor],
+                                                [AC_DEFINE([HAVE_LIBCMOR],[1],[Define to 1 for CMOR support])],
+                                                [AC_MSG_ERROR([Could not link to cmor library!])])
+                                 CMOR_LIBS=" -L$CMOR_ROOT/lib -lcmor"],
+                                [AC_MSG_ERROR([$CMOR_ROOT is not a directory! CMOR suppressed])])])],
+            [AC_MSG_CHECKING([for the CMOR library])
              AC_MSG_RESULT([suppressed])])
-AC_SUBST([JASPER_LIBS])
+AC_SUBST([CMOR_LIBS])
 #  ----------------------------------------------------------------------
 #  Compile application with GRIB_API library (for GRIB2 support)
 GRIB_API_INCLUDE=''
 GRIB_API_LIBS=''
 ENABLE_GRIBAPI=no
 AC_ARG_WITH([grib_api],
-            [AS_HELP_STRING([--with-grib_api=<yes|no|directory>],
-                            [library for grib2 compression; if a directory is given, it will be used as a value for --with-jasper-root])],
+            [AS_HELP_STRING([--with-grib_api=<yes|no|directory> (default=no)],[location of GRIB_API library (lib and include subdirs)])],
             [AS_CASE(["$with_grib_api"],
                      [no],[AC_MSG_CHECKING([for GRIB_API library])
                            AC_MSG_RESULT([suppressed])],
diff --git a/src/Adisit.c b/src/Adisit.c
index 2d75ce1..f085c25 100644
--- a/src/Adisit.c
+++ b/src/Adisit.c
@@ -208,8 +208,6 @@ void *Adisit(void *argument)
 
   for ( varID = 0; varID < nvars; varID++ )
     {
-      gridID  = vlistInqVarGrid(vlistID1, varID);
-
       code = vlistInqVarCode(vlistID1, varID);
 
       if ( code <= 0 )
@@ -249,7 +247,7 @@ void *Adisit(void *argument)
   if ( nlevel1 != nlevel2 ) cdoAbort("temperature and salinity have different number of levels!");
   nlevel = nlevel1;
 
-  pressure = (double*) malloc(nlevel*sizeof(double));
+  pressure = (double*) Malloc(nlevel*sizeof(double));
   zaxisInqLevels(zaxisID, pressure);
 
   if ( pin >= 0 ) 
@@ -267,9 +265,9 @@ void *Adisit(void *argument)
   field_init(&tho);
   field_init(&sao);
   field_init(&tis);
-  tho.ptr = (double*) malloc(gridsize*nlevel*sizeof(double));
-  sao.ptr = (double*) malloc(gridsize*nlevel*sizeof(double));
-  tis.ptr = (double*) malloc(gridsize*nlevel*sizeof(double));
+  tho.ptr = (double*) Malloc(gridsize*nlevel*sizeof(double));
+  sao.ptr = (double*) Malloc(gridsize*nlevel*sizeof(double));
+  tis.ptr = (double*) Malloc(gridsize*nlevel*sizeof(double));
 
   tho.nmiss = 0;
   sao.nmiss = 0;
@@ -375,12 +373,12 @@ void *Adisit(void *argument)
 
   vlistDestroy(vlistID2);
 
-  free(pressure);
-  free(tis.ptr);
-  free(tho.ptr);
-  free(sao.ptr);
+  Free(pressure);
+  Free(tis.ptr);
+  Free(tho.ptr);
+  Free(sao.ptr);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Afterburner.c b/src/Afterburner.c
index 4f0f882..034b836 100644
--- a/src/Afterburner.c
+++ b/src/Afterburner.c
@@ -42,11 +42,11 @@ static double starttime = 0.0;
 void afterInqHistory(int fileID);
 void afterDefHistory(int fileID, char *histstring);
 
-int   scan_par_obsolate(char *namelist, char *name, int def);
+int   scan_par_obsolate(char *namelist, const char *name, int def);
 void  scan_code(char *namelist, struct Variable *vars, int maxCodes, int *numCodes);
-int   scan_par(int verbose, char *namelist, char *name, int def);
+int   scan_par(int verbose, char *namelist, const char *name, int def);
 int   scan_time(int verbose, char *namelist, int *hours, int max_hours);
-void  scan_darray(char *namelist, char *name, double *values, int maxValues, int *numValues);
+void  scan_darray(char *namelist, const char *name, double *values, int maxValues, int *numValues);
 
 long  get_nfft(void);
 
@@ -147,7 +147,7 @@ void FreeMean(struct Variable *vars)
   for ( int code = 0; code < MaxCodes; code++ )
     if ( vars[code].mean )
       {
-	free(vars[code].mean);
+        Free(vars[code].mean);
 	vars[code].mean = NULL;
       }
 }
@@ -528,7 +528,7 @@ void after_setEndOfInterval(struct Control *globs, int nrecs)
       else if ( globs->OutputInterval == UNLIM_INTERVAL )
 	globs->EndOfInterval = FALSE;
       else
-	Error( "output interval %d not implemented!\n", globs->OutputInterval);
+	Error("output interval %d not implemented!", globs->OutputInterval);
     }
 }
 
@@ -655,11 +655,11 @@ void after_control(struct Control *globs, struct Variable *vars)
 	    {
 	      statusp = after_readTimestep(&rarg);
 	    }
-#if  defined  (HAVE_LIBPTHREAD)
+#if defined(HAVE_LIBPTHREAD)
 	  else
 	    {
 	      rval = pthread_create(&thrID, &attr, after_readTimestep, &rarg);
-	      if ( rval != 0 ) Error( "pthread_create failed!");
+	      if ( rval != 0 ) Error("pthread_create failed!");
 	    }
 #endif
 
@@ -668,22 +668,22 @@ void after_control(struct Control *globs, struct Variable *vars)
 	      if ( globs->Type >  0 ) after_legini_setup(globs, vars);
 	    }
 
-#if  defined  (HAVE_LIBPTHREAD)
+#if defined(HAVE_LIBPTHREAD)
 	  if ( ParallelRead )
 	    {
 	      pthread_join(thrID, &statusp);
 	      if ( *(int *)statusp < 0 )
-		Error( "after_readTimestep error! (status = %d)", *(int *)statusp);
+		Error("after_readTimestep error! (status = %d)", *(int *)statusp);
 	    }
 #endif
 	  tsFirst = FALSE;
 	}
-#if  defined  (HAVE_LIBPTHREAD)
+#if defined(HAVE_LIBPTHREAD)
       else
 	{
 	  pthread_join(thrID, &statusp);
 	  if ( *(int *)statusp < 0 )
-	    Error( "after_readTimestep error! (status = %d)", *(int *)statusp);
+	    Error("after_readTimestep error! (status = %d)", *(int *)statusp);
 	}
 #endif
       nrecs = *(int *)statusp;
@@ -697,7 +697,7 @@ void after_control(struct Control *globs, struct Variable *vars)
       if ( nrecs && ParallelRead )
 	{
 	  rval = pthread_create(&thrID, &attr, after_readTimestep, &rarg);
-	  if ( rval != 0 ) Error( "pthread_create failed!");
+	  if ( rval != 0 ) Error("pthread_create failed!");
 	}
 #endif
 
@@ -743,9 +743,8 @@ void after_setLevel(struct Control *globs)
   double level;
   int checkLevel = TRUE;
   int numplevelDefault;  /* default pressure level */
-  long plevelDefault[] = { 100000, 92500, 85000, 70000, 60000, 50000,  \
-			    40000, 30000, 25000, 20000, 15000, 10000,  \
-			     7000,  5000,  3000,  2000, 1000 };
+  long plevelDefault[] = { 100000, 92500, 85000, 70000, 60000, 50000, 40000, 30000, 25000, 20000, 15000,
+                            10000,  7000,  5000,  3000,  2000, 1000 };
   int numhlevelDefault;  /* default height level */
   long hlevelDefault[] = {  0, 1000, 2000, 5000, 10000, 15000, 20000, 25000, 30000 };
 
@@ -1429,7 +1428,7 @@ void after_precntl(struct Control *globs, struct Variable *vars)
     }
 
   if ( globs->Truncation == 0 && globs->Latitudes == 0 )
-    Error("Unsupported file structure!\n");
+    Error("Unsupported file structure!");
 
   if ( globs->Truncation == 0 )
     {
@@ -1487,7 +1486,7 @@ void after_precntl(struct Control *globs, struct Variable *vars)
 
 	      iVertID = zaxisID;
 	      globs->NumLevelFound = numlevel;
-	      LevelFound = (double *) malloc(globs->NumLevelFound*sizeof(double));
+	      LevelFound = (double *) Malloc(globs->NumLevelFound*sizeof(double));
 	      for ( l = 0; l < globs->NumLevelFound; l++ )
 		LevelFound[l] = (int) zaxisInqLevel(zaxisID, l);
 
@@ -1501,7 +1500,7 @@ void after_precntl(struct Control *globs, struct Variable *vars)
 
 			  if ( globs->vct == NULL )
 			    {
-			      globs->vct = (double *) malloc(globs->nvct*sizeof(double));
+			      globs->vct = (double *) Malloc(globs->nvct*sizeof(double));
 			      memcpy(globs->vct, zaxisInqVctPtr(zaxisID), globs->nvct*sizeof(double));
 			    }
 			}
@@ -1511,19 +1510,19 @@ void after_precntl(struct Control *globs, struct Variable *vars)
 			    {
 			      fprintf(stderr," Using internal VCT for L191\n");
 			      globs->nvct = (191+1)*2;
-			      globs->vct = (double *) malloc(globs->nvct*sizeof(double));
+			      globs->vct = (double *) Malloc(globs->nvct*sizeof(double));
 			      memcpy(globs->vct, VCT_L191, globs->nvct*sizeof(double));
 			      zaxisDefVct(zaxisID, globs->nvct, globs->vct);
 			    }
 			  else
 			    {
-			      Error( "VCT not defined in inputfile!");
+			      Error("VCT not defined in inputfile!");
 			    }
 			}
 		    }
 
 		  if ( numlevel != (globs->nvct/2 - 1) )
-		    Error( "Number of hybrid levels %d does not match vct levels %d",
+		    Error("Number of hybrid levels %d does not match vct levels %d",
 			  numlevel, globs->nvct/2-1);
 
 		  if ( globs->Debug )
@@ -1608,9 +1607,9 @@ void after_precntl(struct Control *globs, struct Variable *vars)
     }
 
   if ( globs->Debug )
-    Message( "FieldDim = %d\n", FieldDim);
+    Message( "FieldDim = %d", FieldDim);
 
-  globs->Field = (double *) malloc(FieldDim*sizeof(double));
+  globs->Field = (double *) Malloc(FieldDim*sizeof(double));
 
   if ( globs->Debug )
     for ( code = 0; code < MaxCodes; code++ )
@@ -1777,7 +1776,7 @@ void after_readVct(struct Control *globs, const char *vctfile)
   while ( fgets(line, 1023, fp) ) globs->nvct++;
 
   globs->nvct *= 2;
-  globs->vct = (double *) malloc(globs->nvct*sizeof(double));
+  globs->vct = (double *) Malloc(globs->nvct*sizeof(double));
 
   rewind(fp);
   for ( i = 0; i < globs->nvct/2; i++ )
@@ -2058,9 +2057,9 @@ void after_processing(struct Control *globs, struct Variable *vars)
 
   after_dimcalc(globs);
 
-  globs->rcoslat          = (double *) malloc(globs->Latitudes*sizeof(double));
-  globs->coslat           = (double *) malloc(globs->Latitudes*sizeof(double));
-  globs->DerivationFactor = (double *) malloc(globs->Latitudes*sizeof(double));
+  globs->rcoslat          = (double *) Malloc(globs->Latitudes*sizeof(double));
+  globs->coslat           = (double *) Malloc(globs->Latitudes*sizeof(double));
+  globs->DerivationFactor = (double *) Malloc(globs->Latitudes*sizeof(double));
 
   if ( globs->Type < 50 && globs->AnalysisData )
     {
@@ -2124,8 +2123,8 @@ void after_processing(struct Control *globs, struct Variable *vars)
   /*  if ( vars[U_WIND].needed || vars[V_WIND].needed ) */
   if ( vars[U_WIND].comp || vars[V_WIND].comp )
     {
-      globs->dv2uv_f1 = (double *) malloc(globs->DimSP_half*sizeof(double));
-      globs->dv2uv_f2 = (double *) malloc(globs->DimSP_half*sizeof(double));
+      globs->dv2uv_f1 = (double *) Malloc(globs->DimSP_half*sizeof(double));
+      globs->dv2uv_f2 = (double *) Malloc(globs->DimSP_half*sizeof(double));
       geninx(globs->Truncation, globs->dv2uv_f1, globs->dv2uv_f2);
     }
 
@@ -2153,16 +2152,16 @@ void after_processing(struct Control *globs, struct Variable *vars)
 #endif
   streamClose(globs->istreamID);
 
-  if ( globs->rcoslat )          free(globs->rcoslat);
-  if ( globs->coslat )           free(globs->coslat);
-  if ( globs->DerivationFactor ) free(globs->DerivationFactor);
+  if ( globs->rcoslat )          Free(globs->rcoslat);
+  if ( globs->coslat )           Free(globs->coslat);
+  if ( globs->DerivationFactor ) Free(globs->DerivationFactor);
 
-  if ( globs->Field ) free(globs->Field);
+  if ( globs->Field ) Free(globs->Field);
 
-  if ( globs->poli ) free(globs->poli);
-  if ( globs->pold ) free(globs->pold);
-  if ( globs->pdev ) free(globs->pdev);
-  if ( globs->pol2 ) free(globs->pol2);  if ( globs->pol3 ) free(globs->pol3);
+  if ( globs->poli ) Free(globs->poli);
+  if ( globs->pold ) Free(globs->pold);
+  if ( globs->pdev ) Free(globs->pdev);
+  if ( globs->pol2 ) Free(globs->pol2);  if ( globs->pol3 ) Free(globs->pol3);
 }
 
 extern char *optarg;
@@ -2224,7 +2223,7 @@ int afterburner(int argc, char *argv[])
       fclose(fp);
     }
 
-  struct Control *globs = (struct Control *) malloc(sizeof(struct Control));
+  struct Control *globs = (struct Control *) Malloc(sizeof(struct Control));
   after_control_init(globs);
 
   globs->Verbose = 1;
@@ -2238,7 +2237,7 @@ int afterburner(int argc, char *argv[])
     switch (c)
       {
       case 'a': globs->AnalysisData = 1; break;
-      case 'b': Message( "option -b not longer needed!\n"); break;
+      case 'b': Message( "option -b not longer needed!"); break;
       case 'c': after_printCodes(); break;
       case 'd': globs->Debug = 1; break;
       case 'p': ParallelRead = TRUE; break;
@@ -2320,7 +2319,7 @@ int afterburner(int argc, char *argv[])
       if ( globs->Multi > 0 )
 	Error( "Namelist parameter MULTI works only with one inputfile");
 
-      ifiles = (char **) malloc(globs->Nfiles*sizeof(char*));
+      ifiles = (char **) Malloc(globs->Nfiles*sizeof(char*));
       for ( i = 0; i < globs->Nfiles; i++ )
 	ifiles[i] = argv[--fargcn];
     }
@@ -2351,7 +2350,7 @@ int afterburner(int argc, char *argv[])
 
   FreeMean(vars);
 
-  free(globs);
+  Free(globs);
 
   return(0);
 }
@@ -2364,7 +2363,7 @@ void *Afterburner(void *argument)
 
   lstdout = !cdoSilentMode;
 
-  struct Control *globs = (struct Control *) malloc(sizeof(struct Control));
+  struct Control *globs = (struct Control *) Malloc(sizeof(struct Control));
   after_control_init(globs);
 
   globs->Verbose = cdoVerbose;
@@ -2390,7 +2389,7 @@ void *Afterburner(void *argument)
       if ( globs->Multi > 0 )
 	Error( "Namelist parameter MULTI works only with one inputfile");
 
-      ifiles = (char **) malloc(globs->Nfiles*sizeof(char*));
+      ifiles = (char **) Malloc(globs->Nfiles*sizeof(char*));
       for ( int i = 0; i < globs->Nfiles; ++i )
 	ifiles[i] = cdoStreamName(--nfiles)->args;
       for ( int i = 0; i < globs->Nfiles; ++i ) printf("files %d %s\n", i+1, ifiles[i]);
@@ -2400,11 +2399,11 @@ void *Afterburner(void *argument)
 
   FreeMean(vars);
 
-  free(globs);
+  Free(globs);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
 #else
 int main(int argc, char *argv[])
diff --git a/src/Arith.c b/src/Arith.c
index 61c8ef1..c6caf27 100644
--- a/src/Arith.c
+++ b/src/Arith.c
@@ -35,11 +35,8 @@
 
 void *Arith(void *argument)
 {
-  int operatorID;
-  int operfunc;
   enum {FILL_NONE, FILL_TS, FILL_VAR, FILL_VARTS, FILL_FILE};
   int filltype = FILL_NONE;
-  int streamIDx1, streamIDx2, streamID1, streamID2, streamID3;
   int gridsize;
   int nrecs, nrecs2, nvars = 0, nlev, recID;
   int nlevels2 = 1;
@@ -48,10 +45,7 @@ void *Arith(void *argument)
   int varID2, levelID2;
   int offset;
   int lfill1, lfill2;
-  int ntsteps1, ntsteps2;
-  int vlistIDx1, vlistIDx2, vlistID1, vlistID2, vlistID3;
-  int taxisIDx1, taxisID1, taxisID2, taxisID3;
-  field_t *fieldx1, *fieldx2, field1, field2;
+  int streamID3, vlistID3, taxisID3;
   int *varnmiss2 = NULL;
   int **varnmiss = NULL;
   double *vardata2 = NULL;
@@ -67,31 +61,34 @@ void *Arith(void *argument)
   cdoOperatorAdd("max",   func_max,   0, NULL);
   cdoOperatorAdd("atan2", func_atan2, 0, NULL);
 
-  operatorID = cdoOperatorID();
-  operfunc = cdoOperatorF1(operatorID);
+  int operatorID = cdoOperatorID();
+  int operfunc = cdoOperatorF1(operatorID);
+  operatorCheckArgc(0);
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
-  streamID2 = streamOpenRead(cdoStreamName(1));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID2 = streamOpenRead(cdoStreamName(1));
 
-  streamIDx1 = streamID1;
-  streamIDx2 = streamID2;
-  fieldx1 = &field1;
-  fieldx2 = &field2;
+  int streamIDx1 = streamID1;
+  int streamIDx2 = streamID2;
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = streamInqVlist(streamID2);
-  vlistIDx1 = vlistID1;
-  vlistIDx2 = vlistID2;
+  field_t field1, field2;
+  field_t *fieldx1 = &field1;
+  field_t *fieldx2 = &field2;
+
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = streamInqVlist(streamID2);
+  int vlistIDx1 = vlistID1;
+  int vlistIDx2 = vlistID2;
 
   if ( cdoVerbose ) vlistPrint(vlistID1);
   if ( cdoVerbose ) vlistPrint(vlistID2);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = vlistInqTaxis(vlistID2);
-  taxisIDx1 = taxisID1;
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = vlistInqTaxis(vlistID2);
+  int taxisIDx1 = taxisID1;
 
-  ntsteps1 = vlistNtsteps(vlistID1);
-  ntsteps2 = vlistNtsteps(vlistID2);
+  int ntsteps1 = vlistNtsteps(vlistID1);
+  int ntsteps2 = vlistNtsteps(vlistID2);
   if ( ntsteps1 == 0 ) ntsteps1 = 1;
   if ( ntsteps2 == 0 ) ntsteps2 = 1;
 
@@ -150,12 +147,12 @@ void *Arith(void *argument)
 
   field_init(&field1);
   field_init(&field2);
-  field1.ptr = (double*) malloc(gridsize*sizeof(double));
-  field2.ptr = (double*) malloc(gridsize*sizeof(double));
+  field1.ptr = (double*) Malloc(gridsize*sizeof(double));
+  field2.ptr = (double*) Malloc(gridsize*sizeof(double));
   if ( filltype == FILL_VAR || filltype == FILL_VARTS )
     {
-      vardata2 = (double*) malloc(gridsize*nlevels2*sizeof(double));
-      varnmiss2 = (int*) malloc(nlevels2*sizeof(int));
+      vardata2 = (double*) Malloc(gridsize*nlevels2*sizeof(double));
+      varnmiss2 = (int*) Malloc(nlevels2*sizeof(int));
     }
 
   if ( cdoVerbose ) cdoPrint("Number of timesteps: file1 %d, file2 %d", ntsteps1, ntsteps2);
@@ -183,14 +180,14 @@ void *Arith(void *argument)
       if ( filltype == FILL_TS )
 	{
 	  nvars  = vlistNvars(vlistIDx2);
-	  vardata  = (double **) malloc(nvars*sizeof(double *));
-	  varnmiss = (int **) malloc(nvars*sizeof(int *));
+	  vardata  = (double **) Malloc(nvars*sizeof(double *));
+	  varnmiss = (int **) Malloc(nvars*sizeof(int *));
 	  for ( varID = 0; varID < nvars; varID++ )
 	    {
 	      gridsize = gridInqSize(vlistInqVarGrid(vlistIDx2, varID));
 	      nlev     = zaxisInqSize(vlistInqVarZaxis(vlistIDx2, varID));
-	      vardata[varID]  = (double*) malloc(nlev*gridsize*sizeof(double));
-	      varnmiss[varID] = (int*) malloc(nlev*sizeof(int));
+	      vardata[varID]  = (double*) Malloc(nlev*gridsize*sizeof(double));
+	      varnmiss[varID] = (int*) Malloc(nlev*sizeof(int));
 	    }
 	}
     }
@@ -328,20 +325,20 @@ void *Arith(void *argument)
     {
       for ( varID = 0; varID < nvars; varID++ )
 	{
-	  free(vardata[varID]);
-	  free(varnmiss[varID]);
+	  Free(vardata[varID]);
+	  Free(varnmiss[varID]);
 	}
 
-      free(vardata);
-      free(varnmiss);
+      Free(vardata);
+      Free(varnmiss);
     }
 
-  if ( field1.ptr ) free(field1.ptr);
-  if ( field2.ptr ) free(field2.ptr);
-  if ( vardata2   ) free(vardata2);
-  if ( varnmiss2  ) free(varnmiss2);
+  if ( field1.ptr ) Free(field1.ptr);
+  if ( field2.ptr ) Free(field2.ptr);
+  if ( vardata2   ) Free(vardata2);
+  if ( varnmiss2  ) Free(varnmiss2);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Arithc.c b/src/Arithc.c
index a6fddf2..b3aa92b 100644
--- a/src/Arithc.c
+++ b/src/Arithc.c
@@ -36,7 +36,7 @@ int *fill_vars(int vlistID)
 {
   int varID;
   int nvars = vlistNvars(vlistID);
-  int *vars = (int*) malloc(nvars*sizeof(int));
+  int *vars = (int*) Malloc(nvars*sizeof(int));
 
   if ( cdoNumVarnames )
     {
@@ -72,18 +72,8 @@ int *fill_vars(int vlistID)
 
 void *Arithc(void *argument)
 {
-  int operatorID;
-  int operfunc;
-  int streamID1, streamID2;
-  int gridsize, i;
   int nrecs, recID;
-  int tsID;
   int varID, levelID;
-  int vlistID1, vlistID2;
-  double rconst;
-  field_t field;
-  int taxisID1, taxisID2;
-  int *vars = NULL;
 
   cdoInitialize(argument);
 
@@ -93,34 +83,36 @@ void *Arithc(void *argument)
   cdoOperatorAdd("divc", func_div, 0, "constant value");
   cdoOperatorAdd("mod",  func_mod, 0, "divisor");
 
-  operatorID = cdoOperatorID();
-  operfunc = cdoOperatorF1(operatorID);
+  int operatorID = cdoOperatorID();
+  int operfunc = cdoOperatorF1(operatorID);
 
   operatorInputArg(cdoOperatorEnter(operatorID));
-  rconst = parameter2double(operatorArgv()[0]);
+  operatorCheckArgc(1);
+  double rconst = parameter2double(operatorArgv()[0]);
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = vlistDuplicate(vlistID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
 
-  vars = fill_vars(vlistID1);
+  int *vars = fill_vars(vlistID1);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
-  gridsize = vlistGridsizeMax(vlistID1);
+  int gridsize = vlistGridsizeMax(vlistID1);
 
+  field_t field;
   field_init(&field);
-  field.ptr    = (double*) malloc(gridsize*sizeof(double));
+  field.ptr    = (double*) Malloc(gridsize*sizeof(double));
   field.weight = NULL;
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       taxisCopyTimestep(taxisID2, taxisID1);
@@ -142,7 +134,7 @@ void *Arithc(void *argument)
 	      /* recalculate number of missing values */
 	      gridsize = gridInqSize(field.grid);
 	      field.nmiss = 0;
-	      for ( i = 0; i < gridsize; ++i )
+	      for ( int i = 0; i < gridsize; ++i )
 		if ( DBL_IS_EQUAL(field.ptr[i], field.missval) ) field.nmiss++;
 	    }
 
@@ -155,12 +147,12 @@ void *Arithc(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( field.ptr ) free(field.ptr);
-  if ( vars ) free(vars);
+  if ( field.ptr ) Free(field.ptr);
+  if ( vars ) Free(vars);
 
   vlistDestroy(vlistID2);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Arithdays.c b/src/Arithdays.c
index 6288216..0db2bab 100644
--- a/src/Arithdays.c
+++ b/src/Arithdays.c
@@ -116,7 +116,7 @@ void *Arithdays(void *argument)
   gridsize = vlistGridsizeMax(vlistID1);
 
   field_init(&field);
-  field.ptr    = (double*) malloc(gridsize*sizeof(double));
+  field.ptr    = (double*) Malloc(gridsize*sizeof(double));
   field.weight = NULL;
 
   tsID = 0;
@@ -165,9 +165,9 @@ void *Arithdays(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Arithlat.c b/src/Arithlat.c
index ccb2fc9..ba58276 100644
--- a/src/Arithlat.c
+++ b/src/Arithlat.c
@@ -71,7 +71,7 @@ void *Arithlat(void *argument)
 
   gridsize = vlistGridsizeMax(vlistID1);
 
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -118,7 +118,7 @@ void *Arithlat(void *argument)
 
 	      gridsize = gridInqSize(gridID);
 
-	      scale = (double*) realloc(scale, gridsize*sizeof(double));
+	      scale = (double*) Realloc(scale, gridsize*sizeof(double));
 	      gridInqYvals(gridID, scale);
 
 	      /* Convert lat/lon units if required */
@@ -147,10 +147,10 @@ void *Arithlat(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array ) free(array);
-  if ( scale ) free(scale);
+  if ( array ) Free(array);
+  if ( scale ) Free(scale);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/CDIread.c b/src/CDIread.c
index 8b19644..e7aadc8 100644
--- a/src/CDIread.c
+++ b/src/CDIread.c
@@ -89,7 +89,6 @@ void *CDIread(void *argument)
   int filetype = -1, datatype = -1;
   int irun, nruns = 1;
   char sinfo[64];
-  char *envstr;
   off_t nvalues = 0;
   double file_size = 0, data_size = 0;
   double tw, tw0, t0, twsum = 0;
@@ -100,7 +99,7 @@ void *CDIread(void *argument)
 
   cdoInitialize(argument);
 
-  envstr = getenv("MEMTYPE");
+  char *envstr = getenv("MEMTYPE");
   if ( envstr )
     {
       if      ( strcmp(envstr, "float")  == 0 ) memtype = MEMTYPE_FLOAT;
@@ -116,11 +115,7 @@ void *CDIread(void *argument)
   if ( nruns <  0 ) nruns = 0;
   if ( nruns > 99 ) nruns = 99;
 
-  if ( cdoVerbose )
-    {
-      cdoPrint("nruns      : %d", nruns);
-    } 
-
+  if ( cdoVerbose ) cdoPrint("nruns      : %d", nruns);
 
   // vlistDefNtsteps(vlistID, 1);
 
@@ -139,8 +134,8 @@ void *CDIread(void *argument)
 	  
       gridsize = vlistGridsizeMax(vlistID);
       
-      if ( darray == NULL ) darray = (double*) malloc(gridsize*sizeof(double));
-      if ( farray == NULL && memtype == MEMTYPE_FLOAT ) farray = (float*) malloc(gridsize*sizeof(float));
+      if ( darray == NULL ) darray = (double*) Malloc(gridsize*sizeof(double));
+      if ( farray == NULL && memtype == MEMTYPE_FLOAT ) farray = (float*) Malloc(gridsize*sizeof(float));
 
       t0 = timer_val(timer_read);
 
@@ -184,7 +179,7 @@ void *CDIread(void *argument)
       tw = timer_val(timer_read) - tw0;
       twsum += tw;
 
-      file_size = (double) filesize(cdoStreamName(0)->args);
+      file_size = (double) fileSize(cdoStreamName(0)->args);
 
       if ( nruns > 1 ) sprintf(sinfo, "(run %d)", irun+1);
 
@@ -194,10 +189,10 @@ void *CDIread(void *argument)
   if ( nruns > 1 )
     print_stat("(mean)", memtype, datatype, filetype, nvalues, data_size, file_size, twsum/nruns);
 
-  if ( darray ) free(darray);
-  if ( farray ) free(farray);
+  if ( darray ) Free(darray);
+  if ( farray ) Free(farray);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/CDItest.c b/src/CDItest.c
index e869f61..7942956 100644
--- a/src/CDItest.c
+++ b/src/CDItest.c
@@ -79,7 +79,7 @@ void *CDItest(void *argument)
       streamDefVlist(streamID2, vlistID2);
 
       gridsize = vlistGridsizeMax(vlistID1);
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
 
       tsID1 = 0;
       tsID2 = 0;
@@ -114,7 +114,7 @@ void *CDItest(void *argument)
       vlistDestroy(vlistID2);
       taxisDestroy(taxisID2);
 
-      if ( array ) free(array);
+      if ( array ) Free(array);
 
       n++;
 
@@ -134,5 +134,5 @@ void *CDItest(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/CDIwrite.c b/src/CDIwrite.c
index ed26527..b71f3f2 100644
--- a/src/CDIwrite.c
+++ b/src/CDIwrite.c
@@ -93,7 +93,7 @@ void *CDIwrite(void *argument)
 {
   int memtype = MEMTYPE_DOUBLE;
   int nvars = 10, nlevs = 0, ntimesteps = 30;
-  char *defaultgrid = "global_.2";
+  const char *defaultgrid = "global_.2";
   int streamID;
   int tsID, varID, levelID;
   int gridsize, i;
@@ -105,7 +105,6 @@ void *CDIwrite(void *argument)
   unsigned int seed = 1;
   const char *gridfile;
   char sinfo[64];
-  char *envstr;
   off_t nvalues = 0;
   double file_size = 0, data_size = 0;
   double tw, tw0, t0, twsum = 0;
@@ -117,7 +116,7 @@ void *CDIwrite(void *argument)
 
   cdoInitialize(argument);
 
-  envstr = getenv("MEMTYPE");
+  char *envstr = getenv("MEMTYPE");
   if ( envstr )
     {
       if      ( strcmp(envstr, "float")  == 0 ) memtype = MEMTYPE_FLOAT;
@@ -166,9 +165,9 @@ void *CDIwrite(void *argument)
       cdoPrint("nvars      : %d", nvars);
     }
 
-  double *array = (double*) malloc(gridsize*sizeof(double));
-  double *xvals = (double*) malloc(gridsize*sizeof(double));
-  double *yvals = (double*) malloc(gridsize*sizeof(double));
+  double *array = (double*) Malloc(gridsize*sizeof(double));
+  double *xvals = (double*) Malloc(gridsize*sizeof(double));
+  double *yvals = (double*) Malloc(gridsize*sizeof(double));
 
   int gridID2 = gridID;
   if ( gridInqType(gridID) == GRID_GME ) gridID2 = gridToUnstructured(gridID, 0);
@@ -189,30 +188,30 @@ void *CDIwrite(void *argument)
   for ( i = 0; i < gridsize; i++ )
     array[i] = 2 - cos(acos(cos(xvals[i]) * cos(yvals[i]))/1.2);
 
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
 
-  vars = (double ***) malloc(nvars*sizeof(double **));
+  vars = (double ***) Malloc(nvars*sizeof(double **));
   for ( varID = 0; varID < nvars; varID++ )
     {
-      vars[varID] = (double **) malloc(nlevs*sizeof(double *));
+      vars[varID] = (double **) Malloc(nlevs*sizeof(double *));
       for ( levelID = 0; levelID < nlevs; levelID++ )
 	{
-	  vars[varID][levelID] = (double*) malloc(gridsize*sizeof(double));
+	  vars[varID][levelID] = (double*) Malloc(gridsize*sizeof(double));
 	  for ( i = 0; i < gridsize; ++i )
 	    vars[varID][levelID][i] = varID + array[i]*(levelID+1);
 	  //    vars[varID][levelID][i] = varID + rand()/(RAND_MAX+1.0);
 	}
     }
 
-  if ( memtype == MEMTYPE_FLOAT ) farray = (float*) malloc(gridsize*sizeof(float));
+  if ( memtype == MEMTYPE_FLOAT ) farray = (float*) Malloc(gridsize*sizeof(float));
 
   vlistID = vlistCreate();
 
   for ( i = 0; i < nvars; ++i )
     {
       varID = vlistDefVar(vlistID, gridID, zaxisID, TSTEP_INSTANT);
-      vlistDefVarCode(vlistID, varID, varID+1);
+      vlistDefVarParam(vlistID, varID, cdiEncodeParam(varID+1, 255, 255));
       //    vlistDefVarName(vlistID, varID, );
     }
 
@@ -280,7 +279,7 @@ void *CDIwrite(void *argument)
       tw = timer_val(timer_write) - tw0;
       twsum += tw;
 
-      file_size = (double ) filesize(cdoStreamName(0)->args);
+      file_size = (double) fileSize(cdoStreamName(0)->args);
 
       if ( nruns > 1 ) sprintf(sinfo, "(run %d)", irun+1);
 
@@ -294,16 +293,16 @@ void *CDIwrite(void *argument)
 
   for ( varID = 0; varID < nvars; varID++ )
     {
-      for ( levelID = 0; levelID < nlevs; levelID++ ) free(vars[varID][levelID]);
-      free(vars[varID]);
+      for ( levelID = 0; levelID < nlevs; levelID++ ) Free(vars[varID][levelID]);
+      Free(vars[varID]);
     }
-  free(vars);
+  Free(vars);
 
-  free(array);
+  Free(array);
 
-  if ( farray ) free(farray);
+  if ( farray ) Free(farray);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/CMOR.c b/src/CMOR.c
new file mode 100644
index 0000000..6b010e6
--- /dev/null
+++ b/src/CMOR.c
@@ -0,0 +1,51 @@
+#include <cdi.h>
+#include "cdo.h"
+#include "cdo_int.h"
+#include "par_io.h"
+#include "pstream.h"
+
+#if defined(HAVE_LIBCMOR)
+//#include "cmor.h"
+#endif
+
+void *CMOR(void *argument)
+{
+  cdoInitialize(argument);
+
+#if defined(HAVE_LIBCMOR)
+  /*
+  if ( cdoVerbose )
+    cdoPrint("Using CMOR version %d.%d.%d.", CMOR_VERSION_MAJOR, CMOR_VERSION_MINOR, CMOR_VERSION_PATCH);
+  */
+  int streamID = streamOpenRead(cdoStreamName(0));
+
+  int vlistID = streamInqVlist(streamID);
+  int taxisID = vlistInqTaxis(vlistID);
+
+  int gridsize = vlistGridsizeMax(vlistID);
+  double *array = (double*) Malloc(gridsize*sizeof(double));
+
+  int recID, varID, levelID, nrecs, nmiss;
+  int tsID = 0;
+  while ( (nrecs = streamInqTimestep(streamID, tsID)) )
+    {
+      for ( recID = 0; recID < nrecs; recID++ )
+        { 
+          streamInqRecord(streamID, &varID, &levelID);
+          streamReadRecord(streamID, array, &nmiss);
+        }
+
+      tsID++;
+    }
+
+  streamClose(streamID);
+
+  if ( array ) Free(array);
+#else
+  cdoWarning("CMOR support not compiled in!");
+#endif
+
+  cdoFinish();
+
+  return 0;
+}
diff --git a/src/Cat.c b/src/Cat.c
index 7b6372c..476ac87 100644
--- a/src/Cat.c
+++ b/src/Cat.c
@@ -114,7 +114,7 @@ void *Cat(void *argument)
 	  if ( ! lcopy )
 	    {
 	      gridsize = vlistGridsizeMax(vlistID1);
-	      array = (double*) malloc(gridsize*sizeof(double));
+	      array = (double*) Malloc(gridsize*sizeof(double));
 	    }
 	}
       else
@@ -166,9 +166,9 @@ void *Cat(void *argument)
  
   if ( cdoTimer ) timer_stop(timer_cat);
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Change.c b/src/Change.c
index 077f0c5..efea385 100644
--- a/src/Change.c
+++ b/src/Change.c
@@ -204,8 +204,8 @@ void *Change(void *argument)
 	{
 	  zaxisID1 = vlistZaxis(vlistID2, index);
 	  nlevs = zaxisInqSize(zaxisID1);
-	  levels = (double*) malloc(nlevs*sizeof(double));
-	  newlevels = (double*) malloc(nlevs*sizeof(double));
+	  levels = (double*) Malloc(nlevs*sizeof(double));
+	  newlevels = (double*) Malloc(nlevs*sizeof(double));
 	  zaxisInqLevels(zaxisID1, levels);
 
 	  for ( k = 0; k < nlevs; k++ ) newlevels[k] = levels[k];
@@ -227,8 +227,8 @@ void *Change(void *argument)
 	      vlistChangeZaxis(vlistID2, zaxisID1, zaxisID2);
 	    }
 
-	  free(levels);
-	  free(newlevels);
+	  Free(levels);
+	  Free(newlevels);
 	}
     }
   else if ( operatorID == CHLEVELC || operatorID == CHLEVELV )
@@ -255,7 +255,7 @@ void *Change(void *argument)
 
       zaxisID1 = vlistInqVarZaxis(vlistID2, varID);
       nlevs = zaxisInqSize(zaxisID1);
-      levels = (double*) malloc(nlevs*sizeof(double));
+      levels = (double*) Malloc(nlevs*sizeof(double));
       zaxisInqLevels(zaxisID1, levels);
       nfound = 0;
       for ( k = 0; k < nlevs; k++ )
@@ -274,7 +274,7 @@ void *Change(void *argument)
       else
 	cdoAbort("Level %g not found!", chlevels[0]);
 
-      free(levels);
+      Free(levels);
     }
   else if ( operatorID == CHLTYPE )                
     {
@@ -308,7 +308,7 @@ void *Change(void *argument)
   streamDefVlist(streamID2, vlistID2);
 
   gridsize = vlistGridsizeMax(vlistID2);
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
   tsID1 = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID1)) )
@@ -331,9 +331,9 @@ void *Change(void *argument)
   streamClose(streamID1);
   streamClose(streamID2);
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Change_e5slm.c b/src/Change_e5slm.c
index 8500267..cef1c6f 100644
--- a/src/Change_e5slm.c
+++ b/src/Change_e5slm.c
@@ -75,9 +75,9 @@ void *Change_e5slm(void *argument)
 
   gridsize = gridInqSize(vlistInqVarGrid(vlistIDslm, 0));
 
-  array = (double*) malloc(gridsize*sizeof(double));
-  cland = (double*) malloc(gridsize*sizeof(double));
-  lsea  = (short*) malloc(gridsize*sizeof(short));
+  array = (double*) Malloc(gridsize*sizeof(double));
+  cland = (double*) Malloc(gridsize*sizeof(double));
+  lsea  = (short*) Malloc(gridsize*sizeof(short));
 
   streamInqTimestep(streamIDslm, 0);
 
@@ -102,7 +102,7 @@ void *Change_e5slm(void *argument)
 
 
   nvars = vlistNvars(vlistID1);
-  codes = (short*) malloc(nvars*sizeof(short));
+  codes = (short*) Malloc(nvars*sizeof(short));
 
   for ( varID = 0; varID < nvars; ++varID )
     {
@@ -183,12 +183,12 @@ void *Change_e5slm(void *argument)
   streamClose(streamID1);
   streamClose(streamID2);
 
-  free(array);
-  free(cland);
-  free(lsea);
-  free(codes);
+  Free(array);
+  Free(cland);
+  Free(lsea);
+  Free(codes);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Cloudlayer.c b/src/Cloudlayer.c
index ff582d5..2626853 100644
--- a/src/Cloudlayer.c
+++ b/src/Cloudlayer.c
@@ -122,19 +122,13 @@ void pl_index(int *kmax, int *kmin, double pmax, double pmin, long nlevs, double
 
 void *Cloudlayer(void *argument)
 {
-  int streamID1, streamID2;
-  int vlistID1, vlistID2;
-  int taxisID1, taxisID2;
-  int gridID, zaxisID, tsID;
-  int surfaceID;
-  int nlevel, nhlev, nlevs, nrecs, recID, code;
+  int gridID, zaxisID;
+  int nlevel, nlevs, nrecs, recID, code;
   int varID, levelID;
   int zrev = FALSE;
-  int nvars;
   int i;
   int offset;
   int nmiss;
-  int aclcac_code;
   int aclcacID = -1;
   int nvars2 = 0;
   int aclcac_code_found = 0;
@@ -142,9 +136,7 @@ void *Cloudlayer(void *argument)
   char varname[CDI_MAX_NAME];
   double sfclevel = 0;
   double *plevs = NULL;
-  double *aclcac = NULL;
   double *cloud[NVARS];
-  double missval;
   double pmin = 0, pmax = 0;
 
   cdoInitialize(argument);
@@ -161,21 +153,18 @@ void *Cloudlayer(void *argument)
       nvars2 = NVARS;
     }
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
+  int vlistID1 = streamInqVlist(streamID1);
 
   int gridsize = vlist_check_gridsize(vlistID1);
 
-  aclcac_code = 223;
+  int aclcac_code = 223;
 
-  nvars = vlistNvars(vlistID1);
+  int nvars = vlistNvars(vlistID1);
   for ( varID = 0; varID < nvars; ++varID )
     {
-      gridID   = vlistInqVarGrid(vlistID1, varID);
       zaxisID  = vlistInqVarZaxis(vlistID1, varID);
-      nlevel   = zaxisInqSize(zaxisID);
-
       code = vlistInqVarCode(vlistID1, varID);
 
       if ( code <= 0 )
@@ -204,20 +193,20 @@ void *Cloudlayer(void *argument)
 	cdoAbort("Cloud cover (parameter 223) not found!");
     }
 
-  missval = vlistInqVarMissval(vlistID1, aclcacID);
+  double missval = vlistInqVarMissval(vlistID1, aclcacID);
   gridID  = vlistInqVarGrid(vlistID1, aclcacID);
   zaxisID = vlistInqVarZaxis(vlistID1, aclcacID);
 
   nlevel = zaxisInqSize(zaxisID);
-  nhlev  = nlevel+1;
+  int nhlev  = nlevel+1;
 
-  aclcac = (double*) malloc(gridsize*nlevel*sizeof(double));
+  double *aclcac = (double*) Malloc(gridsize*nlevel*sizeof(double));
   for ( varID = 0; varID < nvars2; ++varID )
-    cloud[varID] = (double*) malloc(gridsize*sizeof(double));
+    cloud[varID] = (double*) Malloc(gridsize*sizeof(double));
 
   if ( zaxisInqType(zaxisID) == ZAXIS_PRESSURE )
     {
-      plevs = (double*) malloc(nlevel*sizeof(double));
+      plevs = (double*) Malloc(nlevel*sizeof(double));
       zaxisInqLevels(zaxisID, plevs);
       if ( plevs[0] > plevs[nlevel-1] )
 	{
@@ -247,7 +236,7 @@ void *Cloudlayer(void *argument)
 	  pl_index(&kmax[0], &kmin[0], 75000.,101300., nlevel, plevs);
 	}
 
-      free(plevs);
+      Free(plevs);
     }
   else if ( zaxisInqType(zaxisID) == ZAXIS_HYBRID )
     {
@@ -258,13 +247,13 @@ void *Cloudlayer(void *argument)
 	{
 	  double *vct;
 
-	  vct = (double*) malloc(nvct*sizeof(double));
+	  vct = (double*) Malloc(nvct*sizeof(double));
 	  zaxisInqVct(zaxisID, vct);
 
 	  nlevs = nlevel + 1;
-	  plevs = (double*) malloc(nlevs*sizeof(double));
+	  plevs = (double*) Malloc(nlevs*sizeof(double));
 	  vct2plev(vct, plevs, nlevs);
-	  free(vct);
+	  Free(vct);
 
 	  if ( nvars2 == 1 )
 	    {
@@ -277,7 +266,7 @@ void *Cloudlayer(void *argument)
 	      hl_index(&kmax[0], &kmin[0], 75000.,101300., nhlev, plevs);
 	    }
 
-	  free(plevs);
+	  Free(plevs);
  	}
       else
 	cdoAbort("Unsupported vertical coordinate table format!");
@@ -286,15 +275,15 @@ void *Cloudlayer(void *argument)
     cdoAbort("Unsupported Z-Axis type!");
 
 
-  surfaceID = zaxisCreate(ZAXIS_SURFACE, 1);
+  int surfaceID = zaxisCreate(ZAXIS_SURFACE, 1);
   zaxisDefLevels(surfaceID, &sfclevel);
 
-  vlistID2 = vlistCreate();
+  int vlistID2 = vlistCreate();
 
   if ( nvars2 == 1 )
     {
       varID = vlistDefVar(vlistID2, gridID, surfaceID, TSTEP_INSTANT);
-      vlistDefVarCode(vlistID2, varID, 33);
+      vlistDefVarParam(vlistID2, varID, cdiEncodeParam(33, 128, 255));
       vlistDefVarName(vlistID2, varID, "cld_lay");
       vlistDefVarLongname(vlistID2, varID, "cloud layer");
       vlistDefVarMissval(vlistID2, varID, missval);
@@ -302,33 +291,33 @@ void *Cloudlayer(void *argument)
   else
     {
       varID = vlistDefVar(vlistID2, gridID, surfaceID, TSTEP_INSTANT);
-      vlistDefVarCode(vlistID2, varID, 34);
+      vlistDefVarParam(vlistID2, varID, cdiEncodeParam(34, 128, 255));
       vlistDefVarName(vlistID2, varID, "low_cld");
       vlistDefVarLongname(vlistID2, varID, "low cloud");
       vlistDefVarMissval(vlistID2, varID, missval);
 
       varID = vlistDefVar(vlistID2, gridID, surfaceID, TSTEP_INSTANT);
-      vlistDefVarCode(vlistID2, varID, 35);
+      vlistDefVarParam(vlistID2, varID, cdiEncodeParam(35, 128, 255));
       vlistDefVarName(vlistID2, varID, "mid_cld");
       vlistDefVarLongname(vlistID2, varID, "mid cloud");
       vlistDefVarMissval(vlistID2, varID, missval);
 
       varID = vlistDefVar(vlistID2, gridID, surfaceID, TSTEP_INSTANT);
-      vlistDefVarCode(vlistID2, varID, 36);
+      vlistDefVarParam(vlistID2, varID, cdiEncodeParam(36, 128, 255));
       vlistDefVarName(vlistID2, varID, "hih_cld");
       vlistDefVarLongname(vlistID2, varID, "high cloud");
       vlistDefVarMissval(vlistID2, varID, missval);
     }
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       taxisCopyTimestep(taxisID2, taxisID1);
@@ -380,11 +369,11 @@ void *Cloudlayer(void *argument)
  
   vlistDestroy(vlistID2);
 
-  free(aclcac);
+  Free(aclcac);
   for ( varID = 0; varID < nvars2; ++varID )
-    free(cloud[varID]);
+    Free(cloud[varID]);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Collgrid.c b/src/Collgrid.c
index 1546e23..bf7a9a5 100644
--- a/src/Collgrid.c
+++ b/src/Collgrid.c
@@ -15,6 +15,8 @@
   GNU General Public License for more details.
 */
 
+#include <ctype.h>
+
 #include <cdi.h>
 #include "cdo.h"
 #include "cdo_int.h"
@@ -48,7 +50,7 @@ int cmpx(const void *s1, const void *s2)
   if      ( xy1->x < xy2->x ) cmp = -1;
   else if ( xy1->x > xy2->x ) cmp =  1;
 
-  return (cmp);
+  return cmp;
 }
 
 static
@@ -61,7 +63,7 @@ int cmpxy_lt(const void *s1, const void *s2)
   if      ( xy1->y < xy2->y || (!(fabs(xy1->y - xy2->y) > 0) && xy1->x < xy2->x) ) cmp = -1;
   else if ( xy1->y > xy2->y || (!(fabs(xy1->y - xy2->y) > 0) && xy1->x > xy2->x) ) cmp =  1;
 
-  return (cmp);
+  return cmp;
 }
 
 static
@@ -74,116 +76,145 @@ int cmpxy_gt(const void *s1, const void *s2)
   if      ( xy1->y > xy2->y || (!(fabs(xy1->y - xy2->y) > 0) && xy1->x < xy2->x) ) cmp = -1;
   else if ( xy1->y < xy2->y || (!(fabs(xy1->y - xy2->y) > 0) && xy1->x > xy2->x) ) cmp =  1;
 
-  return (cmp);
+  return cmp;
 }
 
 static
-int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid)
+int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid, int nxblocks)
 {
   int lsouthnorth = TRUE;
-  int fileID;
-  int gridID;
   int gridID2 = -1;
-  int gridtype = -1;
-  int *xsize, *ysize;
-  int *xoff, *yoff;
-  int xsize2, ysize2;
   int idx;
   int nx, ny, ix, iy, i, j, ij, offset;
-  double **xvals, **yvals;
-  double *xvals2, *yvals2;
-  xyinfo_t *xyinfo;
+  int lregular = FALSE;
+  int lcurvilinear = FALSE;
+  double *xvals2 = NULL, *yvals2 = NULL;
 
-  gridID   = vlistGrid(ef[0].vlistID, igrid);
-  gridtype = gridInqType(gridID);
+  int gridID   = vlistGrid(ef[0].vlistID, igrid);
+  int gridtype = gridInqType(gridID);
   if ( gridtype == GRID_GENERIC && gridInqXsize(gridID) == 0 && gridInqYsize(gridID) == 0 )
-    return (gridID2);
+    return gridID2;
 
-  xsize = (int*) malloc(nfiles*sizeof(int));
-  ysize = (int*) malloc(nfiles*sizeof(int));
-  xyinfo = (xyinfo_t*) malloc(nfiles*sizeof(xyinfo_t));
-  xvals = (double**) malloc(nfiles*sizeof(double*));
-  yvals = (double**) malloc(nfiles*sizeof(double*));
+  int *xsize = (int*) Malloc(nfiles*sizeof(int));
+  int *ysize = (int*) Malloc(nfiles*sizeof(int));
+  xyinfo_t *xyinfo = (xyinfo_t*) Malloc(nfiles*sizeof(xyinfo_t));
+  double **xvals = (double**) Malloc(nfiles*sizeof(double*));
+  double **yvals = (double**) Malloc(nfiles*sizeof(double*));
 
-  for ( fileID = 0; fileID < nfiles; fileID++ )
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
     {
       gridID   = vlistGrid(ef[fileID].vlistID, igrid);
       gridtype = gridInqType(gridID);
-      if ( !(gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN ||
-	    (gridtype == GRID_GENERIC && gridInqXsize(gridID) > 0 && gridInqYsize(gridID) > 0)) )
+      if ( gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN )
+        lregular = TRUE;
+      else if ( gridtype == GRID_CURVILINEAR )
+        lcurvilinear = TRUE;
+      else if ( gridtype == GRID_GENERIC && gridInqXsize(gridID) > 0 && gridInqYsize(gridID) > 0 )
+        ;
+      else
 	cdoAbort("Unsupported grid type: %s!", gridNamePtr(gridtype));
 
       xsize[fileID] = gridInqXsize(gridID);
       ysize[fileID] = gridInqYsize(gridID);
-      /*
-      if ( xsize == 0 ) xsize = gridInqXsize(gridID);
-      if ( ysize == 0 ) ysize = gridInqYsize(gridID);
-      if ( xsize != gridInqXsize(gridID) ) cdoAbort("xsize differ!");
-      if ( ysize != gridInqYsize(gridID) ) cdoAbort("ysize differ!");
-      */
-      xvals[fileID] = (double*) malloc(xsize[fileID]*sizeof(double));
-      yvals[fileID] = (double*) malloc(ysize[fileID]*sizeof(double));
-      gridInqXvals(gridID, xvals[fileID]);
-      gridInqYvals(gridID, yvals[fileID]);
 
+      if ( lregular )
+        {
+          xvals[fileID] = (double*) Malloc(xsize[fileID]*sizeof(double));
+          yvals[fileID] = (double*) Malloc(ysize[fileID]*sizeof(double));
+        }
+      else if ( lcurvilinear )
+        {
+          xvals[fileID] = (double*) Malloc(xsize[fileID]*ysize[fileID]*sizeof(double));
+          yvals[fileID] = (double*) Malloc(xsize[fileID]*ysize[fileID]*sizeof(double));
+        }
+      else
+        {
+          xvals[fileID] = NULL;
+          yvals[fileID] = NULL;
+        }
+        
+      if ( lregular || lcurvilinear )
+        {
+          gridInqXvals(gridID, xvals[fileID]);
+          gridInqYvals(gridID, yvals[fileID]);
+        }
       // printf("fileID %d, gridID %d\n", fileID, gridID);
 
-      xyinfo[fileID].x  = xvals[fileID][0];
-      xyinfo[fileID].y  = yvals[fileID][0];
-      xyinfo[fileID].id = fileID;
-
-      if ( ysize[fileID] > 1 )
-	{
-	  if ( yvals[fileID][0] > yvals[fileID][ysize[fileID]-1] ) lsouthnorth = FALSE;
-	}
+      if ( lregular )
+        {
+          xyinfo[fileID].x  = xvals[fileID][0];
+          xyinfo[fileID].y  = yvals[fileID][0];
+          xyinfo[fileID].id = fileID;
+
+          if ( ysize[fileID] > 1 )
+            {
+              if ( yvals[fileID][0] > yvals[fileID][ysize[fileID]-1] ) lsouthnorth = FALSE;
+            }
+        }
     }
-  /*
+
   if ( cdoVerbose )
-    for ( fileID = 0; fileID < nfiles; fileID++ )
+    for ( int fileID = 0; fileID < nfiles; fileID++ )
       printf("1 %d %g %g \n",  xyinfo[fileID].id, xyinfo[fileID].x, xyinfo[fileID].y);
-  */
-  qsort(xyinfo, nfiles, sizeof(xyinfo_t), cmpx);  	      
-  /*
-  if ( cdoVerbose )
-    for ( fileID = 0; fileID < nfiles; fileID++ )
-      printf("2 %d %g %g \n",  xyinfo[fileID].id, xyinfo[fileID].x, xyinfo[fileID].y);
-  */
-  if ( lsouthnorth )
-    qsort(xyinfo, nfiles, sizeof(xyinfo_t), cmpxy_lt);  
-  else
-    qsort(xyinfo, nfiles, sizeof(xyinfo_t), cmpxy_gt);  	      
 
-  if ( cdoVerbose )
-    for ( fileID = 0; fileID < nfiles; fileID++ )
-      printf("3 %d %g %g \n",  xyinfo[fileID].id, xyinfo[fileID].x, xyinfo[fileID].y);
+  if ( lregular )
+    {
+      qsort(xyinfo, nfiles, sizeof(xyinfo_t), cmpx);  	      
+
+      if ( cdoVerbose )
+        for ( int fileID = 0; fileID < nfiles; fileID++ )
+          printf("2 %d %g %g \n",  xyinfo[fileID].id, xyinfo[fileID].x, xyinfo[fileID].y);
 
-  nx = 1;
-  for ( fileID = 1; fileID < nfiles; fileID++ )
+      if ( lsouthnorth )
+        qsort(xyinfo, nfiles, sizeof(xyinfo_t), cmpxy_lt);  
+      else
+        qsort(xyinfo, nfiles, sizeof(xyinfo_t), cmpxy_gt);  	      
+
+      if ( cdoVerbose )
+        for ( int fileID = 0; fileID < nfiles; fileID++ )
+          printf("3 %d %g %g \n",  xyinfo[fileID].id, xyinfo[fileID].x, xyinfo[fileID].y);
+
+      nx = 1;
+      for ( int fileID = 1; fileID < nfiles; fileID++ )
+        {
+          if ( DBL_IS_EQUAL(xyinfo[0].y, xyinfo[fileID].y) ) nx++;
+          else break;
+        }
+    }
+  else
     {
-      if ( DBL_IS_EQUAL(xyinfo[0].y, xyinfo[fileID].y) ) nx++;
-      else break;
+      nx = nxblocks;
+      if ( nx <= 0 ) cdoAbort("Parameter nx missing!");
     }
+
   ny = nfiles/nx;
-  if ( cdoVerbose ) cdoPrint("nx %d  ny %d", nx, ny);
-  if ( nx*ny != nfiles ) cdoAbort("Number of input files (%d) seems to be incomplete!", nfiles);
+  if ( nx*ny != nfiles ) cdoAbort("Number of input files (%d) and number of blocks (%dx%d) differ!", nfiles, nx, ny);
  
-  xsize2 = 0;
+  int xsize2 = 0;
   for ( i = 0; i < nx; ++i ) xsize2 += xsize[xyinfo[i].id];
-  ysize2 = 0;
+  int ysize2 = 0;
   for ( j = 0; j < ny; ++j ) ysize2 += ysize[xyinfo[j*nx].id];
   if ( cdoVerbose ) cdoPrint("xsize2 %d  ysize2 %d", xsize2, ysize2);
 
-  xvals2 = (double*) malloc(xsize2*sizeof(double));
-  yvals2 = (double*) malloc(ysize2*sizeof(double));
-
-  xoff = (int*) malloc((nx+1)*sizeof(int));
-  yoff = (int*) malloc((ny+1)*sizeof(int));
+  if ( lregular )
+    {
+      xvals2 = (double*) Malloc(xsize2*sizeof(double));
+      yvals2 = (double*) Malloc(ysize2*sizeof(double));
+    }
+  else if ( lcurvilinear )
+    {
+      xvals2 = (double*) Malloc(xsize2*ysize2*sizeof(double));
+      yvals2 = (double*) Malloc(xsize2*ysize2*sizeof(double));
+    }
+    
+  int *xoff = (int*) Malloc((nx+1)*sizeof(int));
+  int *yoff = (int*) Malloc((ny+1)*sizeof(int));
 
   xoff[0] = 0;
   for ( i = 0; i < nx; ++i )
     {
       idx = xyinfo[i].id;
-      memcpy(xvals2+xoff[i], xvals[idx], xsize[idx]*sizeof(double));
+      if ( lregular ) memcpy(xvals2+xoff[i], xvals[idx], xsize[idx]*sizeof(double));
       xoff[i+1] = xoff[i] + xsize[idx];
     }
 
@@ -191,13 +222,13 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid)
   for ( j = 0; j < ny; ++j )
     {
       idx = xyinfo[j*nx].id;
-      memcpy(yvals2+yoff[j], yvals[idx], ysize[idx]*sizeof(double));
+      if ( lregular ) memcpy(yvals2+yoff[j], yvals[idx], ysize[idx]*sizeof(double));
       yoff[j+1] = yoff[j] + ysize[idx];
     }
 
   if ( gridindex != NULL )
     {
-      for ( fileID = 0; fileID < nfiles; fileID++ )
+      for ( int fileID = 0; fileID < nfiles; fileID++ )
 	{
 	  idx = xyinfo[fileID].id;
 	  iy = fileID/nx;
@@ -212,6 +243,11 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid)
 	  for ( j = 0; j < ysize[idx]; ++j )
 	    for ( i = 0; i < xsize[idx]; ++i )
 	      {
+                if ( lcurvilinear )
+                  {
+                    xvals2[offset+j*xsize2+i] = xvals[idx][ij];
+                    yvals2[offset+j*xsize2+i] = yvals[idx][ij];
+                  }
 		gridindex[idx][ij++] = offset+j*xsize2+i;
 	      }
 	}
@@ -220,15 +256,18 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid)
   gridID2 = gridCreate(gridtype, xsize2*ysize2);
   gridDefXsize(gridID2, xsize2);
   gridDefYsize(gridID2, ysize2);
-  gridDefXvals(gridID2, xvals2);
-  gridDefYvals(gridID2, yvals2);
+  if ( lregular || lcurvilinear )
+    {
+      gridDefXvals(gridID2, xvals2);
+      gridDefYvals(gridID2, yvals2);
+    }
 
-  free(xoff);
-  free(yoff);
-  free(xsize);
-  free(ysize);
-  free(xvals2);
-  free(yvals2);
+  Free(xoff);
+  Free(yoff);
+  Free(xsize);
+  Free(ysize);
+  if ( xvals2 ) Free(xvals2);
+  if ( yvals2 ) Free(yvals2);
 
   char string[1024];
   string[0] = 0;
@@ -246,28 +285,27 @@ int genGrid(int nfiles, ens_file_t *ef, int **gridindex, int igrid)
   gridInqYunits(gridID, string);
   gridDefYunits(gridID2, string);
 
-  for ( fileID = 0; fileID < nfiles; fileID++ )
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
     {
-      free(xvals[fileID]);
-      free(yvals[fileID]);
+      if ( xvals[fileID] ) Free(xvals[fileID]);
+      if ( yvals[fileID] ) Free(yvals[fileID]);
     }
-  free(xvals);
-  free(yvals);
-  free(xyinfo);
+  Free(xvals);
+  Free(yvals);
+  Free(xyinfo);
 
-  return (gridID2);
+  return gridID2;
 }
 
 
 void *Collgrid(void *argument)
 {
+  int nxblocks = 1;
   int varID, recID;
   int nrecs, nrecs0;
   int levelID;
   int nmiss;
-  int taxisID1, taxisID2;
   double missval;
-  int fileID;
 
   cdoInitialize(argument);
     
@@ -279,9 +317,9 @@ void *Collgrid(void *argument)
       if ( !userFileOverwrite(ofilename) )
 	cdoAbort("Outputfile %s already exists!", ofilename);
 
-  ens_file_t *ef = (ens_file_t*) malloc(nfiles*sizeof(ens_file_t));
+  ens_file_t *ef = (ens_file_t*) Malloc(nfiles*sizeof(ens_file_t));
 
-  for ( fileID = 0; fileID < nfiles; fileID++ )
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
     {
       ef[fileID].streamID = streamOpenRead(cdoStreamName(fileID));
       ef[fileID].vlistID  = streamInqVlist(ef[fileID].streamID);
@@ -291,16 +329,29 @@ void *Collgrid(void *argument)
   vlistClearFlag(vlistID1);
 
   /* check that the contents is always the same */
-  for ( fileID = 1; fileID < nfiles; fileID++ )
+  for ( int fileID = 1; fileID < nfiles; fileID++ )
     vlistCompare(vlistID1, ef[fileID].vlistID, CMP_NAME | CMP_NLEVEL);
 
   int nvars = vlistNvars(vlistID1);
-  int *vars  = (int*) malloc(nvars*sizeof(int));
+  int *vars  = (int*) Malloc(nvars*sizeof(int));
   for ( varID = 0; varID < nvars; varID++ ) vars[varID] = FALSE;
-  int *vars1  = (int*) malloc(nvars*sizeof(int));
+  int *vars1  = (int*) Malloc(nvars*sizeof(int));
   for ( varID = 0; varID < nvars; varID++ ) vars1[varID] = FALSE;
 
   int nsel = operatorArgc();
+
+  if ( nsel > 0 )
+    {
+      int len = (int) strlen(operatorArgv()[0]);
+      while ( --len >= 0 && isdigit(operatorArgv()[0][len]) ) ;
+
+      if ( len == -1 )
+        {
+          nsel--;
+          nxblocks = parameter2int(operatorArgv()[0]);
+        }
+    }
+
   if ( nsel == 0 )
     {
       for ( varID = 0; varID < nvars; varID++ ) vars1[varID] = TRUE;
@@ -313,7 +364,7 @@ void *Collgrid(void *argument)
 	for ( int i = 0; i < nsel; i++ )
 	  fprintf(stderr, "name %d = %s\n", i+1, argnames[i]);
 
-      int *selfound = (int*) malloc(nsel*sizeof(int));
+      int *selfound = (int*) Malloc(nsel*sizeof(int));
       for ( int i = 0; i < nsel; i++ ) selfound[i] = FALSE;
 
       char varname[CDI_MAX_NAME];
@@ -335,7 +386,7 @@ void *Collgrid(void *argument)
 	if ( selfound[isel] == FALSE )
 	  cdoAbort("Variable name %s not found!", argnames[isel]);
 
-      free(selfound);
+      Free(selfound);
     }
 
   for ( varID = 0; varID < nvars; varID++ )
@@ -351,15 +402,14 @@ void *Collgrid(void *argument)
 
   int gridsize;
   int gridsizemax = 0;
-  for ( fileID = 0; fileID < nfiles; fileID++ )
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
     {
       gridsize = vlistGridsizeMax(ef[fileID].vlistID);
       if ( gridsize > gridsizemax ) gridsizemax = gridsize;
     }
-  gridsize = gridsizemax;
 
-  for ( fileID = 0; fileID < nfiles; fileID++ )
-    ef[fileID].array = (double*) malloc(gridsizemax*sizeof(double));
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
+    ef[fileID].array = (double*) Malloc(gridsizemax*sizeof(double));
 
 
   int vlistID2 = vlistCreate();
@@ -373,16 +423,16 @@ void *Collgrid(void *argument)
   */
   //int vlistID2 = vlistDuplicate(vlistID1);
   int nvars2 = vlistNvars(vlistID2);
-  // int *vars  = (int*) malloc(nvars*sizeof(int));
+  // int *vars  = (int*) Malloc(nvars*sizeof(int));
   //for ( varID = 0; varID < nvars; varID++ ) vars[varID] = FALSE;
 
   int ngrids1 = vlistNgrids(vlistID1);
   int ngrids2 = vlistNgrids(vlistID2);
 
-  int *gridIDs = (int*) malloc(ngrids2*sizeof(int));
-  int **gridindex = (int **) malloc(nfiles*sizeof(int *));
-  for ( fileID = 0; fileID < nfiles; fileID++ )
-    gridindex[fileID] = (int*) malloc(gridsizemax*sizeof(int));
+  int *gridIDs = (int*) Malloc(ngrids2*sizeof(int));
+  int **gridindex = (int **) Malloc(nfiles*sizeof(int *));
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
+    gridindex[fileID] = (int*) Malloc(gridsizemax*sizeof(int));
 
   int ginit = FALSE;
   for ( int i2 = 0; i2 < ngrids2; ++i2 )
@@ -395,16 +445,16 @@ void *Collgrid(void *argument)
 
       if ( ginit == FALSE )
 	{
-	  gridIDs[i2] = genGrid(nfiles, ef, gridindex, i1);
+	  gridIDs[i2] = genGrid(nfiles, ef, gridindex, i1, nxblocks);
 	  if ( gridIDs[i2] != -1 ) ginit = TRUE;
 	}
       else
-	gridIDs[i2] = genGrid(nfiles, ef, NULL, i1);
+	gridIDs[i2] = genGrid(nfiles, ef, NULL, i1, nxblocks);
     }
 
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID2, taxisID2);
 
   int gridsize2 = 0;
@@ -437,13 +487,13 @@ void *Collgrid(void *argument)
       
   streamDefVlist(streamID2, vlistID2);
 	  
-  double *array2 = (double*) malloc(gridsize2*sizeof(double));
+  double *array2 = (double*) Malloc(gridsize2*sizeof(double));
 
   int tsID = 0;
   do
     {
       nrecs0 = streamInqTimestep(ef[0].streamID, tsID);
-      for ( fileID = 1; fileID < nfiles; fileID++ )
+      for ( int fileID = 1; fileID < nfiles; fileID++ )
 	{
 	  nrecs = streamInqTimestep(ef[fileID].streamID, tsID);
 	  if ( nrecs != nrecs0 )
@@ -459,7 +509,7 @@ void *Collgrid(void *argument)
 	  streamInqRecord(ef[0].streamID, &varID, &levelID);
 	  if ( cdoVerbose && tsID == 0 ) printf(" tsID, recID, varID, levelID %d %d %d %d\n", tsID, recID, varID, levelID);
 
-	  for ( fileID = 0; fileID < nfiles; fileID++ )
+	  for ( int fileID = 0; fileID < nfiles; fileID++ )
 	    {
 	      int varIDx, levelIDx;
 	      if ( fileID > 0 ) streamInqRecord(ef[fileID].streamID, &varIDx, &levelIDx);
@@ -475,9 +525,9 @@ void *Collgrid(void *argument)
 	      for ( int i = 0; i < gridsize2; i++ ) array2[i] = missval;
 
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(fileID, nmiss)
+#pragma omp parallel for default(shared) private(nmiss)
 #endif
-	      for ( fileID = 0; fileID < nfiles; fileID++ )
+	      for ( int fileID = 0; fileID < nfiles; fileID++ )
 		{
 		  streamReadRecord(ef[fileID].streamID, ef[fileID].array, &nmiss);
 
@@ -508,22 +558,22 @@ void *Collgrid(void *argument)
     }
   while ( nrecs0 > 0 );
 
-  for ( fileID = 0; fileID < nfiles; fileID++ )
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
     streamClose(ef[fileID].streamID);
 
   streamClose(streamID2);
 
-  for ( fileID = 0; fileID < nfiles; fileID++ )
-    if ( ef[fileID].array ) free(ef[fileID].array);
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
+    if ( ef[fileID].array ) Free(ef[fileID].array);
 
-  if ( ef ) free(ef);
-  if ( array2 ) free(array2);
+  if ( ef ) Free(ef);
+  if ( array2 ) Free(array2);
 
-  free(gridIDs);
-  if ( vars   ) free(vars);
-  if ( vars1  ) free(vars1);
+  Free(gridIDs);
+  if ( vars   ) Free(vars);
+  if ( vars1  ) Free(vars1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Command.c b/src/Command.c
index 097f49d..d6c6a75 100644
--- a/src/Command.c
+++ b/src/Command.c
@@ -50,19 +50,19 @@ double *gl_data = NULL;
 
 int Done = 0;
 
-int com_help(char *);
-int com_list(char *);
-int com_quit(char *);
-int com_stat(char *);
-int com_set(char *);
-int com_vars(char *);
+int com_help(const char *);
+int com_list(const char *);
+int com_quit(const char *);
+int com_stat(const char *);
+int com_set(const char *);
+int com_vars(const char *);
 //int com_stat(char *);
 
 
 typedef struct {
-  char  *name; /* User printable name of the function. */
-  int  (*func)(char *); /* Function to call to do the job. */
-  char  *doc; /* Documentation for this function. */
+  const char  *name; /* User printable name of the function. */
+  int  (*func)(const char *); /* Function to call to do the job. */
+  const char  *doc; /* Documentation for this function. */
 }
 command_t;
 
@@ -86,13 +86,13 @@ int valid_argument (char *caller, char *arg)
   if (!arg || !*arg)
     {
       fprintf (stderr, "%s: Argument required.\n", caller);
-      return (0);
+      return 0;
     }
   return (1);
 }
 
 /* Print out help for ARG, or for all of the commands if ARG is not present. */
-int com_help(char *arg)
+int com_help(const char *arg)
 {
   int i;
   int printed = 0;
@@ -124,31 +124,31 @@ int com_help(char *arg)
       if (printed) printf ("\n");
     }
 
-  return (0);
+  return 0;
 }
 
 
 /* List the file(s) named in arg. */
-int com_list(char *arg)
+int com_list(const char *arg)
 {
   if (!arg)
     arg = "";
 
-  return (0);
+  return 0;
 }
 
 /* The user wishes to quit using this program. Just set DONE non-zero. */
-int com_quit(char *arg)
+int com_quit(const char *arg)
 {
   UNUSED(arg);
 
   Done = 1;
 
-  return (0);
+  return 0;
 }
 
 
-int com_stat(char *arg)
+int com_stat(const char *arg)
 {
   int nrecs;
   int tsID;
@@ -191,19 +191,19 @@ int com_stat(char *arg)
 	}
     }
 
-  return (0);
+  return 0;
 }
 
 
-int com_set(char *arg)
+int com_set(const char *arg)
 {
   printf("com_set: %s\n", arg);
 
-  return (0);
+  return 0;
 }
 
 
-int com_vars(char *arg)
+int com_vars(const char *arg)
 {
   int varID;
   char paramstr[32];
@@ -219,7 +219,7 @@ int com_vars(char *arg)
 	      varID+1, paramstr, all_vars[varID].name, all_vars[varID].longname, all_vars[varID].units);
     }
 
-  return (0);
+  return 0;
 }
 
 /* Look up NAME as the name of a command, and return a pointer to that
@@ -254,7 +254,7 @@ int execute_line(char *line)
   if ( !command )
     {
       fprintf (stderr, "%s: No such command!\n", word);
-      return (-1);
+      return -1;
     }
   /* Get argument to command, if any. */
   while ( isspace(line[i]) ) i++;
@@ -308,10 +308,10 @@ void command_init()
   UNUSED(taxisID);
 
   gridsize = vlistGridsizeMax(gl_vlistID);
-  gl_data = (double*) malloc(gridsize*sizeof(double));
+  gl_data = (double*) Malloc(gridsize*sizeof(double));
 
   gl_nvars = vlistNvars(gl_vlistID);
-  all_vars = (vars_t*) malloc(gl_nvars*sizeof(vars_t));
+  all_vars = (vars_t*) Malloc(gl_nvars*sizeof(vars_t));
 
   for ( varID = 0; varID < gl_nvars; ++varID )
     {
@@ -374,8 +374,8 @@ void *Command(void *argument)
   
   streamClose(gl_streamID);
 
-  if ( gl_data ) free(gl_data);
-  if ( all_vars ) free(all_vars);
+  if ( gl_data ) Free(gl_data);
+  if ( all_vars ) Free(all_vars);
   
   cdoProcessTime(&e_utime, &e_stime);
 
@@ -390,5 +390,5 @@ void *Command(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Comp.c b/src/Comp.c
index 859bc71..1a2f887 100644
--- a/src/Comp.c
+++ b/src/Comp.c
@@ -112,9 +112,9 @@ void *Comp(void *argument)
 
   gridsize = vlistGridsizeMax(vlistIDx1);
 
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize*sizeof(double));
-  array3 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
+  array2 = (double*) Malloc(gridsize*sizeof(double));
+  array3 = (double*) Malloc(gridsize*sizeof(double));
 
   arrayx1 = array1;
   arrayx2 = array2;
@@ -143,12 +143,12 @@ void *Comp(void *argument)
       if ( filltype == FILL_TS )
 	{
 	  nvars  = vlistNvars(vlistIDx2);
-	  vardata  = (double **) malloc(nvars*sizeof(double *));
+	  vardata  = (double **) Malloc(nvars*sizeof(double *));
 	  for ( varID = 0; varID < nvars; varID++ )
 	    {
 	      gridsize = gridInqSize(vlistInqVarGrid(vlistIDx2, varID));
 	      nlev     = zaxisInqSize(vlistInqVarZaxis(vlistIDx2, varID));
-	      vardata[varID]  = (double*) malloc(nlev*gridsize*sizeof(double));
+	      vardata[varID]  = (double*) Malloc(nlev*gridsize*sizeof(double));
 	    }
 	}
     }
@@ -288,15 +288,15 @@ void *Comp(void *argument)
 
   if ( vardata )
     {
-      for ( varID = 0; varID < nvars; varID++ ) free(vardata[varID]);
-      free(vardata);
+      for ( varID = 0; varID < nvars; varID++ ) Free(vardata[varID]);
+      Free(vardata);
     }
 
-  if ( array3 ) free(array3);
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
+  if ( array3 ) Free(array3);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Compc.c b/src/Compc.c
index 6439cef..da9abe7 100644
--- a/src/Compc.c
+++ b/src/Compc.c
@@ -78,8 +78,8 @@ void *Compc(void *argument)
 
   gridsize = vlistGridsizeMax(vlistID1);
 
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
+  array2 = (double*) Malloc(gridsize*sizeof(double));
 
   streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
@@ -150,10 +150,10 @@ void *Compc(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Complextorect.c b/src/Complextorect.c
index 2452a04..c0c1940 100644
--- a/src/Complextorect.c
+++ b/src/Complextorect.c
@@ -74,9 +74,9 @@ void *Complextorect(void *argument)
   streamDefVlist(streamID3, vlistID3);
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array1 = (double*) malloc(2*gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize*sizeof(double));
-  array3 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(2*gridsize*sizeof(double));
+  array2 = (double*) Malloc(gridsize*sizeof(double));
+  array3 = (double*) Malloc(gridsize*sizeof(double));
       
   tsID  = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -114,9 +114,9 @@ void *Complextorect(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array1 ) free(array1);
-  if ( array2 ) free(array2);
-  if ( array3 ) free(array3);
+  if ( array1 ) Free(array1);
+  if ( array2 ) Free(array2);
+  if ( array3 ) Free(array3);
 
   vlistDestroy(vlistID2);
   vlistDestroy(vlistID3);
diff --git a/src/Cond.c b/src/Cond.c
index 7ce989d..7f34566 100644
--- a/src/Cond.c
+++ b/src/Cond.c
@@ -95,9 +95,9 @@ void *Cond(void *argument)
   if ( filltype == FILL_REC && gridsize != gridInqSize(vlistGrid(vlistID1, 0)) )
     cdoAbort("Stream1 >%s< has wrong gridsize!", cdoStreamName(0)->args);
 
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize*sizeof(double));
-  array3 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
+  array2 = (double*) Malloc(gridsize*sizeof(double));
+  array3 = (double*) Malloc(gridsize*sizeof(double));
 
   if ( cdoVerbose )
     cdoPrint("Number of timesteps: file1 %d, file2 %d", ntsteps1, ntsteps2);
@@ -110,14 +110,14 @@ void *Cond(void *argument)
 	  cdoPrint("Filling up stream1 >%s< by copying the first timestep.", cdoStreamName(0)->args);
 
 	  nvars  = vlistNvars(vlistID1);
-	  vardata1  = (double **) malloc(nvars*sizeof(double *));
-	  varnmiss1 = (int **) malloc(nvars*sizeof(int *));
+	  vardata1  = (double **) Malloc(nvars*sizeof(double *));
+	  varnmiss1 = (int **) Malloc(nvars*sizeof(int *));
 	  for ( varID = 0; varID < nvars; varID++ )
 	    {
 	      gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
 	      nlev     = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
-	      vardata1[varID]  = (double*) malloc(nlev*gridsize*sizeof(double));
-	      varnmiss1[varID] = (int*) malloc(nlev*sizeof(int));
+	      vardata1[varID]  = (double*) Malloc(nlev*gridsize*sizeof(double));
+	      varnmiss1[varID] = (int*) Malloc(nlev*sizeof(int));
 	    }
 	}
     }
@@ -206,19 +206,19 @@ void *Cond(void *argument)
     {
       for ( varID = 0; varID < nvars; varID++ )
 	{
-	  free(vardata1[varID]);
-	  free(varnmiss1[varID]);
+	  Free(vardata1[varID]);
+	  Free(varnmiss1[varID]);
 	}
 
-      free(vardata1);
-      free(varnmiss1);
+      Free(vardata1);
+      Free(varnmiss1);
     }
 
-  if ( array3 ) free(array3);
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
+  if ( array3 ) Free(array3);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Cond2.c b/src/Cond2.c
index ed30a85..1e7af49 100644
--- a/src/Cond2.c
+++ b/src/Cond2.c
@@ -98,10 +98,10 @@ void *Cond2(void *argument)
   if ( filltype == FILL_REC && gridsize != gridInqSize(vlistGrid(vlistID1, 0)) )
     cdoAbort("Stream1 >%s< has wrong gridsize!", cdoStreamName(0)->args);
 
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize*sizeof(double));
-  array3 = (double*) malloc(gridsize*sizeof(double));
-  array4 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
+  array2 = (double*) Malloc(gridsize*sizeof(double));
+  array3 = (double*) Malloc(gridsize*sizeof(double));
+  array4 = (double*) Malloc(gridsize*sizeof(double));
 
   if ( cdoVerbose )
     cdoPrint("Number of timesteps: file1 %d, file2 %d, file3 %d",
@@ -115,14 +115,14 @@ void *Cond2(void *argument)
 	  cdoPrint("Filling up stream1 >%s< by copying the first timestep.", cdoStreamName(0)->args);
 
 	  nvars  = vlistNvars(vlistID1);
-	  vardata1  = (double **) malloc(nvars*sizeof(double *));
-	  varnmiss1 = (int **) malloc(nvars*sizeof(int *));
+	  vardata1  = (double **) Malloc(nvars*sizeof(double *));
+	  varnmiss1 = (int **) Malloc(nvars*sizeof(int *));
 	  for ( varID = 0; varID < nvars; varID++ )
 	    {
 	      gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
 	      nlev     = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
-	      vardata1[varID]  = (double*) malloc(nlev*gridsize*sizeof(double));
-	      varnmiss1[varID] = (int*) malloc(nlev*sizeof(int));
+	      vardata1[varID]  = (double*) Malloc(nlev*gridsize*sizeof(double));
+	      varnmiss1[varID] = (int*) Malloc(nlev*sizeof(int));
 	    }
 	}
     }
@@ -215,20 +215,20 @@ void *Cond2(void *argument)
     {
       for ( varID = 0; varID < nvars; varID++ )
 	{
-	  free(vardata1[varID]);
-	  free(varnmiss1[varID]);
+	  Free(vardata1[varID]);
+	  Free(varnmiss1[varID]);
 	}
 
-      free(vardata1);
-      free(varnmiss1);
+      Free(vardata1);
+      Free(varnmiss1);
     }
 
-  if ( array4 ) free(array4);
-  if ( array3 ) free(array3);
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
+  if ( array4 ) Free(array4);
+  if ( array3 ) Free(array3);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Condc.c b/src/Condc.c
index 340bdd1..41720a1 100644
--- a/src/Condc.c
+++ b/src/Condc.c
@@ -69,8 +69,8 @@ void *Condc(void *argument)
 
   gridsize = vlistGridsizeMax(vlistID1);
 
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
+  array2 = (double*) Malloc(gridsize*sizeof(double));
 
   streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
@@ -119,10 +119,10 @@ void *Condc(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Consecstat.c b/src/Consecstat.c
index d02b68f..7ee6152 100644
--- a/src/Consecstat.c
+++ b/src/Consecstat.c
@@ -151,7 +151,7 @@ void *Consecstat(void *argument)
   vlistDefTaxis(ovlistID, otaxisID);
 
   field_init(&field);
-  field.ptr = (double*) malloc(vlistGridsizeMax(ovlistID)*sizeof(double));
+  field.ptr = (double*) Malloc(vlistGridsizeMax(ovlistID)*sizeof(double));
 
   nvars     = vlistNvars(ivlistID);
   vars      = field_calloc(ivlistID, FIELD_PTR);
@@ -265,5 +265,5 @@ void *Consecstat(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Copy.c b/src/Copy.c
index fd71c84..508c899 100644
--- a/src/Copy.c
+++ b/src/Copy.c
@@ -102,11 +102,11 @@ void *Copy(void *argument)
 	  streamDefVlist(streamID2, vlistID2);
 
 	  gridsize = vlistGridsizeMax(vlistID1);
-	  array = (double*) malloc(gridsize*sizeof(double));
+	  array = (double*) Malloc(gridsize*sizeof(double));
 	  if ( cdoParIO )
 	    {
 	      fprintf(stderr, "Parallel reading enabled!\n");
-	      parIO.array = (double*) malloc(gridsize*sizeof(double));
+	      parIO.array = (double*) Malloc(gridsize*sizeof(double));
 	      parIO.array_size = gridsize;
 	    }
 	}
@@ -165,10 +165,10 @@ void *Copy(void *argument)
 
   streamClose(streamID2);
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
   if ( vlistID2 != CDI_UNDEFID ) vlistDestroy(vlistID2);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Deltime.c b/src/Deltime.c
index 156f768..dbc08ff 100644
--- a/src/Deltime.c
+++ b/src/Deltime.c
@@ -103,7 +103,7 @@ void *Deltime(void *argument)
   if ( ! lcopy )
     {
       gridsize = vlistGridsizeMax(vlistID1);
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
     }
       
   nfound = 0;
@@ -158,7 +158,7 @@ void *Deltime(void *argument)
     cdoWarning("Day %d%s not found!", dday, cmons[dmon]);
 
   if ( ! lcopy )
-    if ( array ) free(array);
+    if ( array ) Free(array);
 
   vlistDestroy(vlistID2);
 
diff --git a/src/Derivepar.c b/src/Derivepar.c
index 74ca483..28cb0b1 100644
--- a/src/Derivepar.c
+++ b/src/Derivepar.c
@@ -152,7 +152,7 @@ void *Derivepar(void *argument)
                       if ( cdoVerbose )
                         cdoPrint("lhavevct=TRUE  zaxisIDh = %d, nhlevf   = %d", zaxisIDh, nlevel);
  
-		      vct = (double*) malloc(nvct*sizeof(double));
+		      vct = (double*) Malloc(nvct*sizeof(double));
 		      zaxisInqVct(zaxisID, vct);
 
 		      if ( cdoVerbose )
@@ -283,32 +283,32 @@ void *Derivepar(void *argument)
 
   if ( tempID == -1 ) cdoAbort("%s not found!", var_stdname(air_temperature));
 
-  array   = (double*) malloc(gridsize*sizeof(double));
-  sgeopot = (double*) malloc(gridsize*sizeof(double));
-  ps      = (double*) malloc(gridsize*sizeof(double));
-  temp    = (double*) malloc(gridsize*nhlevf*sizeof(double));
+  array   = (double*) Malloc(gridsize*sizeof(double));
+  sgeopot = (double*) Malloc(gridsize*sizeof(double));
+  ps      = (double*) Malloc(gridsize*sizeof(double));
+  temp    = (double*) Malloc(gridsize*nhlevf*sizeof(double));
 
-  // lwater = (double*) malloc(gridsize*nhlevf*sizeof(double));
-  // iwater = (double*) malloc(gridsize*nhlevf*sizeof(double));
+  // lwater = (double*) Malloc(gridsize*nhlevf*sizeof(double));
+  // iwater = (double*) Malloc(gridsize*nhlevf*sizeof(double));
 
-  half_press = (double*) malloc(gridsize*(nhlevf+1)*sizeof(double));
+  half_press = (double*) Malloc(gridsize*(nhlevf+1)*sizeof(double));
 
   if ( operatorID == GHEIGHT )
     {
       if ( humID == -1 )
 	cdoWarning("%s not found - using algorithm without %s!", var_stdname(specific_humidity), var_stdname(specific_humidity));
       else
-	hum    = (double*) malloc(gridsize*nhlevf*sizeof(double));
+	hum    = (double*) Malloc(gridsize*nhlevf*sizeof(double));
 
-      gheight = (double*) malloc(gridsize*(nhlevf+1)*sizeof(double));
+      gheight = (double*) Malloc(gridsize*(nhlevf+1)*sizeof(double));
     }
   
   if ( operatorID == SEALEVELPRESSURE )
     {
-      full_press   = (double*) malloc(gridsize*nhlevf*sizeof(double));
+      full_press   = (double*) Malloc(gridsize*nhlevf*sizeof(double));
 
       surfaceID = zaxisFromName("surface");
-      sealevelpressure = (double*) malloc(gridsize*sizeof(double));
+      sealevelpressure = (double*) Malloc(gridsize*sizeof(double));
     }
 
   if ( zaxisIDh != -1 && sgeopotID == -1 )
@@ -493,20 +493,20 @@ void *Derivepar(void *argument)
 
   vlistDestroy(vlistID2);
 
-  free(ps);
-  free(sgeopot);
-  free(temp);
-  if ( gheight ) free(gheight);
-  if ( sealevelpressure ) free(sealevelpressure);
-  if ( hum ) free(hum);
+  Free(ps);
+  Free(sgeopot);
+  Free(temp);
+  if ( gheight ) Free(gheight);
+  if ( sealevelpressure ) Free(sealevelpressure);
+  if ( hum ) Free(hum);
 
-  if ( full_press ) free(full_press);
-  if ( half_press ) free(half_press);
+  if ( full_press ) Free(full_press);
+  if ( half_press ) Free(half_press);
 
-  free(array);
-  if ( vct ) free(vct);
+  Free(array);
+  if ( vct ) Free(vct);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Detrend.c b/src/Detrend.c
index 1a55b57..315d306 100644
--- a/src/Detrend.c
+++ b/src/Detrend.c
@@ -70,14 +70,10 @@ void *Detrend(void *argument)
   int gridsize;
   int nrecs;
   int gridID, varID, levelID, recID;
-  int tsID;
   int i;
-  int nts;
   int nalloc = 0;
-  int streamID1, streamID2;
-  int vlistID1, vlistID2, taxisID1, taxisID2;
   int nmiss;
-  int nvars, nlevel;
+  int nlevel;
   double missval;
   field_t ***vars = NULL;
   dtlist_type *dtlist = dtlist_new();
@@ -86,32 +82,31 @@ void *Detrend(void *argument)
     double *array1;
     double *array2;
   } memory_t;
-  memory_t *ompmem = NULL;
 
   cdoInitialize(argument);
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = vlistDuplicate(vlistID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
-  nvars = vlistNvars(vlistID1);
+  int nvars = vlistNvars(vlistID1);
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       if ( tsID >= nalloc )
 	{
 	  nalloc += NALLOC_INC;
-	  vars   = (field_t ***) realloc(vars, nalloc*sizeof(field_t **));
+	  vars   = (field_t ***) Realloc(vars, nalloc*sizeof(field_t **));
 	}
 
       dtlist_taxisInqTimestep(dtlist, taxisID1, tsID);
@@ -123,7 +118,7 @@ void *Detrend(void *argument)
 	  streamInqRecord(streamID1, &varID, &levelID);
 	  gridID   = vlistInqVarGrid(vlistID1, varID);
 	  gridsize = gridInqSize(gridID);
-	  vars[tsID][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+	  vars[tsID][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 	  streamReadRecord(streamID1, vars[tsID][varID][levelID].ptr, &nmiss);
 	  vars[tsID][varID][levelID].nmiss = nmiss;
 	}
@@ -131,13 +126,13 @@ void *Detrend(void *argument)
       tsID++;
     }
 
-  nts = tsID;
+  int nts = tsID;
 
-  ompmem = (memory_t*) malloc(ompNumThreads*sizeof(memory_t));
+  memory_t *ompmem = (memory_t*) Malloc(ompNumThreads*sizeof(memory_t));
   for ( i = 0; i < ompNumThreads; i++ )
     {
-      ompmem[i].array1 = (double*) malloc(nts*sizeof(double));
-      ompmem[i].array2 = (double*) malloc(nts*sizeof(double));
+      ompmem[i].array1 = (double*) Malloc(nts*sizeof(double));
+      ompmem[i].array2 = (double*) Malloc(nts*sizeof(double));
     }
 
   for ( varID = 0; varID < nvars; varID++ )
@@ -149,18 +144,18 @@ void *Detrend(void *argument)
       for ( levelID = 0; levelID < nlevel; levelID++ )
 	{
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(i, tsID)
+#pragma omp parallel for default(none) shared(ompmem, vars, varID, levelID, gridsize, nts, missval)
 #endif
 	  for ( i = 0; i < gridsize; i++ )
 	    {
               int ompthID = cdo_omp_get_thread_num();
 
-	      for ( tsID = 0; tsID < nts; tsID++ )
+	      for ( int tsID = 0; tsID < nts; tsID++ )
 		ompmem[ompthID].array1[tsID] = vars[tsID][varID][levelID].ptr[i];
 
 	      detrend(nts, missval, ompmem[ompthID].array1, ompmem[ompthID].array2);
 
-	      for ( tsID = 0; tsID < nts; tsID++ )
+	      for ( int tsID = 0; tsID < nts; tsID++ )
 		vars[tsID][varID][levelID].ptr[i] = ompmem[ompthID].array2[tsID];
 	    }
 	}
@@ -168,12 +163,12 @@ void *Detrend(void *argument)
 
   for ( i = 0; i < ompNumThreads; i++ )
     {
-      free(ompmem[i].array1);
-      free(ompmem[i].array2);
+      Free(ompmem[i].array1);
+      Free(ompmem[i].array2);
     }
-  free(ompmem);
+  Free(ompmem);
 
-  for ( tsID = 0; tsID < nts; tsID++ )
+  for ( int tsID = 0; tsID < nts; tsID++ )
     {
       dtlist_taxisDefTimestep(dtlist, taxisID2, tsID);
       streamDefTimestep(streamID2, tsID);
@@ -188,7 +183,7 @@ void *Detrend(void *argument)
 		  nmiss = vars[tsID][varID][levelID].nmiss;
 		  streamDefRecord(streamID2, varID, levelID);
 		  streamWriteRecord(streamID2, vars[tsID][varID][levelID].ptr, nmiss);
-		  free(vars[tsID][varID][levelID].ptr);
+		  Free(vars[tsID][varID][levelID].ptr);
 		  vars[tsID][varID][levelID].ptr = NULL;
 		}
 	    }
@@ -197,7 +192,7 @@ void *Detrend(void *argument)
       field_free(vars[tsID], vlistID1);
     }
 
-  if ( vars  ) free(vars);
+  if ( vars  ) Free(vars);
 
   dtlist_delete(dtlist);
 
@@ -206,5 +201,5 @@ void *Detrend(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Diff.c b/src/Diff.c
index 03b2573..23dd7bb 100644
--- a/src/Diff.c
+++ b/src/Diff.c
@@ -30,73 +30,63 @@
 
 void *Diff(void *argument)
 {
-  int DIFF, DIFFP, DIFFN, DIFFC;
-  int operatorID;
   int lhead = TRUE;
   int i;
-  int indg;
   int varID1, varID2, recID;
-  int gridsize;
   int ndiff;
   int code, param;
-  int gridID, zaxisID, vdate, vtime;
+  int gridID, zaxisID;
   int checkrel;
   int nrecs, nrecs2;
   int levelID;
-  int tsID;
   int dsgn, zero;
-  int streamID1, streamID2;
-  int vlistID1, vlistID2;
-  int taxisID;
   int nmiss1, nmiss2;
   int ndrec = 0, nd2rec = 0, ngrec = 0;
   char varname[CDI_MAX_NAME];
   char paramstr[32];
   char vdatestr[32], vtimestr[32];
   double absdiff;
-  double abslim = 0., abslim2 = 1.e-3, rellim = 0.5;
+  double abslim = 0., abslim2 = 1.e-3, rellim = 1.0;
   double absm, relm;
   double missval1, missval2;
-  double *array1, *array2;
 
   cdoInitialize(argument);
 
-  DIFF  = cdoOperatorAdd("diff",  0, 0, NULL);
-  DIFFP = cdoOperatorAdd("diffp", 0, 0, NULL);
-  DIFFN = cdoOperatorAdd("diffn", 0, 0, NULL);
-  DIFFC = cdoOperatorAdd("diffc", 0, 0, NULL);
+  int DIFF  = cdoOperatorAdd("diff",  0, 0, NULL);
+  int DIFFP = cdoOperatorAdd("diffp", 0, 0, NULL);
+  int DIFFN = cdoOperatorAdd("diffn", 0, 0, NULL);
+  int DIFFC = cdoOperatorAdd("diffc", 0, 0, NULL);
 
-  operatorID = cdoOperatorID();
+  int operatorID = cdoOperatorID();
 
-  if ( operatorArgc() == 1 ) abslim = parameter2double(operatorArgv()[0]);
+  if ( operatorArgc() >= 1 ) abslim = parameter2double(operatorArgv()[0]);
   if ( abslim < -1.e33 || abslim > 1.e+33 ) cdoAbort("Abs. limit out of range\n");
+  if ( operatorArgc() == 2 ) rellim = parameter2double(operatorArgv()[1]);
+  if ( rellim < -1.e33 || rellim > 1.e+33 ) cdoAbort("Rel. limit out of range\n");
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
-  streamID2 = streamOpenRead(cdoStreamName(1));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID2 = streamOpenRead(cdoStreamName(1));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = streamInqVlist(streamID2);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = streamInqVlist(streamID2);
 
   vlistCompare(vlistID1, vlistID2, CMP_ALL);
 
-  gridsize = vlistGridsizeMax(vlistID1);
+  int gridsize = vlistGridsizeMax(vlistID1);
 
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize*sizeof(double));
+  double *array1 = (double*) Malloc(gridsize*sizeof(double));
+  double *array2 = (double*) Malloc(gridsize*sizeof(double));
 
-  indg = 0;
-  tsID = 0;
-  taxisID = vlistInqTaxis(vlistID1);
+  int indg = 0;
+  int tsID = 0;
+  int taxisID = vlistInqTaxis(vlistID1);
   while ( TRUE )
     {
       nrecs = streamInqTimestep(streamID1, tsID);
       if ( nrecs > 0 )
 	{
-	  vdate = taxisInqVdate(taxisID);
-	  vtime = taxisInqVtime(taxisID);
-	  
-	  date2str(vdate, vdatestr, sizeof(vdatestr));
-	  time2str(vtime, vtimestr, sizeof(vtimestr));
+	  date2str(taxisInqVdate(taxisID), vdatestr, sizeof(vdatestr));
+	  time2str(taxisInqVtime(taxisID), vtimestr, sizeof(vtimestr));
 	}
 
       nrecs2 = streamInqTimestep(streamID2, tsID);
@@ -118,7 +108,8 @@ void *Diff(void *argument)
 	  missval1 = vlistInqVarMissval(vlistID1, varID1);
 	  missval2 = vlistInqVarMissval(vlistID2, varID2);
 
-	  checkrel = gridInqType(gridID) != GRID_SPECTRAL;
+	  //checkrel = gridInqType(gridID) != GRID_SPECTRAL;
+          checkrel = TRUE;
 
 	  cdiParamToString(param, paramstr, sizeof(paramstr));
 
@@ -163,7 +154,7 @@ void *Diff(void *argument)
 
 	  if ( ! cdoSilentMode || cdoVerbose )
 	    {
-	      if ( absm > abslim || (checkrel && relm > rellim) || cdoVerbose )
+	      if ( absm > abslim || (checkrel && relm >= rellim) || cdoVerbose )
 		{
 		  if ( lhead )
 		    {
@@ -224,8 +215,8 @@ void *Diff(void *argument)
 	    }
 
 	  ngrec++;
-	  if ( absm > abslim  || (checkrel && relm > rellim) ) ndrec++;
-	  if ( absm > abslim2 || (checkrel && relm > rellim) ) nd2rec++;
+	  if ( absm > abslim  || (checkrel && relm >= rellim) ) ndrec++;
+	  if ( absm > abslim2 || (checkrel && relm >= rellim) ) nd2rec++;
 	}
       tsID++;
     }
@@ -250,10 +241,10 @@ void *Diff(void *argument)
   streamClose(streamID1);
   streamClose(streamID2);
 
-  if ( array1 ) free(array1);
-  if ( array2 ) free(array2);
+  if ( array1 ) Free(array1);
+  if ( array2 ) Free(array2);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Distgrid.c b/src/Distgrid.c
index fae6d70..27c13ae 100644
--- a/src/Distgrid.c
+++ b/src/Distgrid.c
@@ -20,32 +20,45 @@
 #include "cdo_int.h"
 #include "pstream.h"
 
-#define  MAX_BLOCKS  16384
+#define  MAX_BLOCKS  65536
 
 static
 void genGrids(int gridID1, int *gridIDs, int nxvals, int nyvals, int nxblocks, int nyblocks,
 	      int **gridindex, int *ogridsize, int nsplit)
 {
   int gridID2;
-  int gridtype;
-  int nx, ny;
   int gridsize2;
-  int index, i, j, ix, iy, offset;
-  int *xlsize = NULL, *ylsize = NULL;
-  double *xvals = NULL, *yvals = NULL;
-
-  gridtype = gridInqType(gridID1);
-  if ( !(gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN || gridtype == GRID_GENERIC) )
+  int i, j, ix, iy, offset;
+
+  int gridtype = gridInqType(gridID1);
+  int lregular = TRUE;
+  if ( gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN || gridtype == GRID_GENERIC )
+    lregular = TRUE;
+  else if ( gridtype == GRID_CURVILINEAR )
+    lregular = FALSE;
+  else
     cdoAbort("Unsupported grid type: %s!", gridNamePtr(gridtype));
 
-  nx = gridInqXsize(gridID1);
-  ny = gridInqYsize(gridID1);
-
-  xvals = (double*) malloc(nx*sizeof(double));
-  yvals = (double*) malloc(ny*sizeof(double));
+  int nx = gridInqXsize(gridID1);
+  int ny = gridInqYsize(gridID1);
 
-  xlsize = (int*) malloc(nxblocks*sizeof(int));
-  ylsize = (int*) malloc(nyblocks*sizeof(int));
+  double *xvals = NULL, *yvals = NULL;
+  double *xvals2 = NULL, *yvals2 = NULL;
+  if ( lregular )
+    {
+      xvals = (double*) Malloc(nx*sizeof(double));
+      yvals = (double*) Malloc(ny*sizeof(double));
+    }
+  else
+    {
+      xvals = (double*) Malloc(nx*ny*sizeof(double));
+      yvals = (double*) Malloc(nx*ny*sizeof(double));
+      xvals2 = (double*) Malloc(nxvals*nyvals*sizeof(double));
+      yvals2 = (double*) Malloc(nxvals*nyvals*sizeof(double));      
+    }
+  
+  int *xlsize = (int*) Malloc(nxblocks*sizeof(int));
+  int *ylsize = (int*) Malloc(nyblocks*sizeof(int));
 
   gridInqXvals(gridID1, xvals);
   gridInqYvals(gridID1, yvals);
@@ -58,14 +71,14 @@ void genGrids(int gridID1, int *gridIDs, int nxvals, int nyvals, int nxblocks, i
   if ( ny%nyblocks != 0 ) ylsize[nyblocks-1] = ny - (nyblocks-1)*nyvals;
   if ( cdoVerbose ) for ( iy = 0; iy < nyblocks; ++iy ) cdoPrint("yblock %d: %d", iy, ylsize[iy]);
 
-  index = 0;
+  int index = 0;
   for ( iy = 0; iy < nyblocks; ++iy )
     for ( ix = 0; ix < nxblocks; ++ix )
       {
 	offset = iy*nyvals*nx + ix*nxvals;
 
 	gridsize2 = xlsize[ix]*ylsize[iy];
-	gridindex[index] = (int*) malloc(gridsize2*sizeof(int));
+	gridindex[index] = (int*) Malloc(gridsize2*sizeof(int));
 
 	gridsize2 = 0;
         // printf("iy %d, ix %d offset %d\n", iy, ix,  offset);
@@ -74,6 +87,11 @@ void genGrids(int gridID1, int *gridIDs, int nxvals, int nyvals, int nxblocks, i
 	    for ( i = 0; i < xlsize[ix]; ++i )
 	      {
 	       	// printf(">> %d %d %d\n", j, i, offset + j*nx + i);
+                if ( !lregular )
+                  {
+                    xvals2[gridsize2] = xvals[offset + j*nx + i];
+                    yvals2[gridsize2] = yvals[offset + j*nx + i];
+                  }
 		gridindex[index][gridsize2++] = offset + j*nx + i;
 	      }
 	  }
@@ -82,9 +100,18 @@ void genGrids(int gridID1, int *gridIDs, int nxvals, int nyvals, int nxblocks, i
 	gridID2 = gridCreate(gridtype, gridsize2);
 	gridDefXsize(gridID2, xlsize[ix]);
 	gridDefYsize(gridID2, ylsize[iy]);
-	gridDefXvals(gridID2, xvals+ix*nxvals);
-	gridDefYvals(gridID2, yvals+iy*nyvals);
 
+        if ( lregular )
+          {
+            gridDefXvals(gridID2, xvals+ix*nxvals);
+            gridDefYvals(gridID2, yvals+iy*nyvals);
+          }
+        else
+          {
+            gridDefXvals(gridID2, xvals2);
+            gridDefYvals(gridID2, yvals2);
+          }
+        
 	gridIDs[index] = gridID2;
 	ogridsize[index] = gridsize2;
 
@@ -93,18 +120,18 @@ void genGrids(int gridID1, int *gridIDs, int nxvals, int nyvals, int nxblocks, i
 	  cdoAbort("Internal problem, index exceeded bounds!");
       }
 
-  free(xvals);
-  free(yvals);
-  free(xlsize);
-  free(ylsize);
+  if ( xvals2 ) Free(xvals2);
+  if ( yvals2 ) Free(yvals2);
+  Free(xvals);
+  Free(yvals);
+  Free(xlsize);
+  Free(ylsize);
 }
 
 static
 void window_cell(double *array1, double *array2, long gridsize2, int *cellidx)
 {
-  long i;
-
-  for ( i = 0; i < gridsize2; ++i )
+  for ( long i = 0; i < gridsize2; ++i )
     array2[i] = array1[cellidx[i]];
 }
 
@@ -119,61 +146,53 @@ typedef struct
 
 void *Distgrid(void *argument)
 {
-  int nchars;
-  int streamID1;
-  int *vlistIDs = NULL, *streamIDs = NULL;
-  int gridID1 = -1, varID;
-  int nrecs, ngrids;
-  int tsID, recID, levelID;
-  int vlistID1;
+  int gridID1;
+  int varID;
+  int nrecs;
+  int recID, levelID;
   char filesuffix[32];
   char filename[8192];
   const char *refname;
   int index;
-  int nsplit;
-  int xinc = 1, yinc = 1;
-  int gridsize, gridsize2max;
   int gridtype = -1;
   int nmiss;
-  int nxblocks = 1, nyblocks = 1;
-  int nx, ny, i;
+  int i;
   double missval;
-  double *array1 = NULL, *array2 = NULL;
-  sgrid_t *grids;
 
   cdoInitialize(argument);
 
   operatorInputArg("nxblocks, [nyblocks]");
   if ( operatorArgc() < 1 ) cdoAbort("Too few arguments!");
   if ( operatorArgc() > 2 ) cdoAbort("Too many arguments!");
-  nxblocks = parameter2int(operatorArgv()[0]);
+  int nxblocks = parameter2int(operatorArgv()[0]);
+  int nyblocks = 1;
   if ( operatorArgc() == 2 ) nyblocks = parameter2int(operatorArgv()[1]);
 
   if ( nxblocks <= 0 ) cdoAbort("nxblocks has to be greater than 0!");
   if ( nyblocks <= 0 ) cdoAbort("nyblocks has to be greater than 0!");
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
+  int vlistID1 = streamInqVlist(streamID1);
 
-  ngrids = vlistNgrids(vlistID1);
+  int ngrids = vlistNgrids(vlistID1);
 
   for ( index = 0; index < ngrids; index++ )
     {
       gridID1 = vlistGrid(vlistID1, index);
       gridtype = gridInqType(gridID1);
-      if ( gridtype == GRID_LONLAT   || gridtype == GRID_GAUSSIAN ||
+      if ( gridtype == GRID_LONLAT   || gridtype == GRID_GAUSSIAN || gridtype == GRID_CURVILINEAR ||
 	  (gridtype == GRID_GENERIC && gridInqXsize(gridID1) > 0 && gridInqYsize(gridID1) > 0) )
 	   break;
     }
 
   if ( index == ngrids )
-    cdoAbort("No Lon/Lat, Gaussian or Generic grid found (%s data unsupported)!", gridNamePtr(gridtype));
+    cdoAbort("No Lon/Lat, Gaussian, curvilinear or generic grid found (%s data unsupported)!", gridNamePtr(gridtype));
 
   gridID1 = vlistGrid(vlistID1, 0);
-  gridsize = gridInqSize(gridID1);
-  nx = gridInqXsize(gridID1);
-  ny = gridInqYsize(gridID1);
+  int gridsize = gridInqSize(gridID1);
+  int nx = gridInqXsize(gridID1);
+  int ny = gridInqYsize(gridID1);
   for ( i = 1; i < ngrids; i++ )
     {
       gridID1 = vlistGrid(vlistID1, i);
@@ -192,28 +211,27 @@ void *Distgrid(void *argument)
       nyblocks = ny;
     }
 
-  xinc = nx/nxblocks;
-  yinc = ny/nyblocks;
+  int xinc = nx/nxblocks;
+  int yinc = ny/nyblocks;
 
   if ( nx%xinc != 0 ) xinc++;
   if ( ny%yinc != 0 ) yinc++;
 
-  nsplit = nxblocks*nyblocks;
+  int nsplit = nxblocks*nyblocks;
   if ( nsplit > MAX_BLOCKS ) cdoAbort("Too many blocks (max = %d)!", MAX_BLOCKS);
 
-  array1 = (double*) malloc(gridsize*sizeof(double));
+  double *array1 = (double*) Malloc(gridsize*sizeof(double));
 
-  vlistIDs  = (int*) malloc(nsplit*sizeof(int));
-  streamIDs = (int*) malloc(nsplit*sizeof(int));
+  int *vlistIDs  = (int*) Malloc(nsplit*sizeof(int));
+  int *streamIDs = (int*) Malloc(nsplit*sizeof(int));
 
-  grids = (sgrid_t*) malloc(ngrids*sizeof(sgrid_t));
+  sgrid_t *grids = (sgrid_t*) Malloc(ngrids*sizeof(sgrid_t));
   for ( i = 0; i < ngrids; i++ )
     {  
-      gridID1 = vlistGrid(vlistID1, i);
       grids[i].gridID    = vlistGrid(vlistID1, i);
-      grids[i].gridIDs   = (int*) malloc(nsplit*sizeof(int));
-      grids[i].gridsize  = (int*) malloc(nsplit*sizeof(int));
-      grids[i].gridindex = (int**) malloc(nsplit*sizeof(int*));
+      grids[i].gridIDs   = (int*) Malloc(nsplit*sizeof(int));
+      grids[i].gridsize  = (int*) Malloc(nsplit*sizeof(int));
+      grids[i].gridindex = (int**) Malloc(nsplit*sizeof(int*));
 
       for ( index = 0; index < nsplit; index++ ) grids[i].gridindex[index] = NULL;
     }
@@ -236,14 +254,14 @@ void *Distgrid(void *argument)
 	vlistChangeGridIndex(vlistIDs[index], i, grids[i].gridIDs[index]);
     }
 
-  gridsize2max = 0;
+  int gridsize2max = 0;
   for ( index = 0; index < nsplit; index++ )
     if ( grids[0].gridsize[index] > gridsize2max ) gridsize2max = grids[0].gridsize[index];
 
-  array2 = (double*) malloc(gridsize2max*sizeof(double));
+  double *array2 = (double*) Malloc(gridsize2max*sizeof(double));
 
   strcpy(filename, cdoStreamName(1)->args);
-  nchars = strlen(filename);
+  int nchars = strlen(filename);
 
   refname = cdoStreamName(0)->argv[cdoStreamName(0)->argc-1];
   filesuffix[0] = 0;
@@ -263,7 +281,7 @@ void *Distgrid(void *argument)
     }
 
   if ( ngrids > 1 ) cdoPrint("Bausstelle: number of different grids > 1!");
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       for ( index = 0; index < nsplit; index++ )
@@ -302,26 +320,26 @@ void *Distgrid(void *argument)
       vlistDestroy(vlistIDs[index]);
     }
 
-  if ( array1 ) free(array1);
-  if ( array2 ) free(array2);
+  if ( array1 ) Free(array1);
+  if ( array2 ) Free(array2);
 
-  if ( vlistIDs  ) free(vlistIDs);
-  if ( streamIDs ) free(streamIDs);
+  if ( vlistIDs  ) Free(vlistIDs);
+  if ( streamIDs ) Free(streamIDs);
 
   for ( i = 0; i < ngrids; i++ )
     {
       for ( index = 0; index < nsplit; index++ )
 	gridDestroy(grids[i].gridIDs[index]);
-      free(grids[i].gridIDs);
-      free(grids[i].gridsize);
+      Free(grids[i].gridIDs);
+      Free(grids[i].gridsize);
 
       for ( index = 0; index < nsplit; index++ )
-	free(grids[i].gridindex[index]);
-      free(grids[i].gridindex);
+        Free(grids[i].gridindex[index]);
+      Free(grids[i].gridindex);
     }
-  free(grids);
+  Free(grids);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Duplicate.c b/src/Duplicate.c
index aef844b..18dcf87 100644
--- a/src/Duplicate.c
+++ b/src/Duplicate.c
@@ -86,9 +86,9 @@ void *Duplicate(void *argument)
       if ( tsID >= nalloc )
 	{
 	  nalloc += NALLOC_INC;
-	  vdate = (int*) realloc(vdate, nalloc*sizeof(int));
-	  vtime = (int*) realloc(vtime, nalloc*sizeof(int));
-	  vars  = (field_t ***) realloc(vars, nalloc*sizeof(field_t **));
+	  vdate = (int*) Realloc(vdate, nalloc*sizeof(int));
+	  vtime = (int*) Realloc(vtime, nalloc*sizeof(int));
+	  vars  = (field_t ***) Realloc(vars, nalloc*sizeof(field_t **));
 	}
 
       vdate[tsID] = taxisInqVdate(taxisID1);
@@ -101,7 +101,7 @@ void *Duplicate(void *argument)
 	  streamInqRecord(streamID1, &varID, &levelID);
 	  gridID   = vlistInqVarGrid(vlistID1, varID);
 	  gridsize = gridInqSize(gridID);
-	  vars[tsID][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+	  vars[tsID][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 	  streamReadRecord(streamID1, vars[tsID][varID][levelID].ptr, &nmiss);
 	  vars[tsID][varID][levelID].nmiss = nmiss;
 	}
@@ -137,14 +137,14 @@ void *Duplicate(void *argument)
 
   for ( tsID = 0; tsID < nts; tsID++ ) field_free(vars[tsID], vlistID1);
 
-  if ( vars  ) free(vars);
-  if ( vdate ) free(vdate);
-  if ( vtime ) free(vtime);
+  if ( vars  ) Free(vars);
+  if ( vdate ) Free(vdate);
+  if ( vtime ) Free(vtime);
 
   streamClose(streamID2);
   streamClose(streamID1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/EOFs.c b/src/EOFs.c
index 4293cf8..d670010 100644
--- a/src/EOFs.c
+++ b/src/EOFs.c
@@ -54,7 +54,7 @@ void scale_eigvec_time(double *restrict out, int tsID, int nts, int npack, const
 		       double **covar, double **data, double missval, double sum_w)
 {
 #if defined(_OPENMP)
-#pragma omp parallel for shared(tsID, data, out)
+#pragma omp parallel for default(none) shared(npack, nts, tsID, pack, data, covar, out)
 #endif
   for ( int i = 0; i < npack; ++i )
     {
@@ -81,7 +81,7 @@ void scale_eigvec_time(double *restrict out, int tsID, int nts, int npack, const
 #endif
   for ( int i = 0; i < npack; ++i )
     {
-      // do not need to account for weights as eigenvectors are non-weighted                                   
+      // do not need to account for weights as eigenvectors are non-weighted                               
       sum += weight[pack[i]] * out[pack[i]] * out[pack[i]];
     }
 
@@ -221,7 +221,7 @@ void *EOFs(void * argument)
   int gridID1   = vlistInqVarGrid(vlistID1, 0);
   int gridsize  = vlistGridsizeMax(vlistID1);
   int nvars     = vlistNvars(vlistID1);
-  int nrecs     = vlistNrecs(vlistID1);
+  int nrecs;
 
   int ngrids = vlistNgrids(vlistID1);
   for ( int index = 1; index < ngrids; index++ )
@@ -230,7 +230,7 @@ void *EOFs(void * argument)
 	cdoAbort("Too many different grids!");
       }
 
-  double *weight = (double *) malloc(gridsize*sizeof(double));
+  double *weight = (double *) Malloc(gridsize*sizeof(double));
   for ( i = 0; i < gridsize; ++i ) weight[i] = 1.;
 
   if ( weight_mode == WEIGHT_ON )
@@ -323,18 +323,17 @@ void *EOFs(void * argument)
 
   /* allocation of temporary fields and output structures */
   int npack = -1;
-  int *pack            = (int *) malloc(gridsize*sizeof(int));
-  double *in           = (double *) malloc(gridsize*sizeof(double));
-  eofdata_t **eofdata  = (eofdata_t **) malloc(nvars*sizeof(eofdata_t*));
+  int *pack            = (int *) Malloc(gridsize*sizeof(int));
+  double *in           = (double *) Malloc(gridsize*sizeof(double));
+  eofdata_t **eofdata  = (eofdata_t **) Malloc(nvars*sizeof(eofdata_t*));
 
   for ( varID = 0; varID < nvars; ++varID )
     {
-      gridID1  = vlistInqVarGrid(vlistID1, varID);
       gridsize = vlistGridsizeMax(vlistID1);
       nlevs    = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
       missval  = vlistInqVarMissval(vlistID1, varID);
 
-      eofdata[varID] = (eofdata_t *) malloc(nlevs*sizeof(eofdata_t));
+      eofdata[varID] = (eofdata_t *) Malloc(nlevs*sizeof(eofdata_t));
 
       for ( levelID = 0; levelID < nlevs; ++levelID )
         {
@@ -346,7 +345,7 @@ void *EOFs(void * argument)
 	  eofdata[varID][levelID].data = NULL;
 
 	  if ( time_space )
-	    eofdata[varID][levelID].data = (double **) malloc(nts*sizeof(double *));
+	    eofdata[varID][levelID].data = (double **) Malloc(nts*sizeof(double *));
         }
     }
 
@@ -409,8 +408,8 @@ void *EOFs(void * argument)
 	      if ( !eofdata[varID][levelID].init )
 		{
 		  n = npack;
-		  double *covar_array = (double *) malloc(npack*npack*sizeof(double));
-		  covar = (double **) malloc(npack*sizeof(double *));
+		  double *covar_array = (double *) Malloc(npack*npack*sizeof(double));
+		  covar = (double **) Malloc(npack*sizeof(double *));
 		  for ( i = 0; i < npack; ++i ) covar[i] = covar_array + npack*i;
 		  for ( i = 0; i < npack; ++i )
 		    {
@@ -435,7 +434,7 @@ void *EOFs(void * argument)
 	    }
           else if ( time_space )
 	    {
-	      double *data = (double *) malloc(npack*sizeof(double));
+	      double *data = (double *) Malloc(npack*sizeof(double));
 	      eofdata[varID][levelID].data[tsID] = data;
 
 	      for ( ipack = 0; ipack < npack; ipack++ )
@@ -536,7 +535,7 @@ void *EOFs(void * argument)
 		    {
 		      if ( npack )
 			{
-			  eig_val = (double *) malloc(npack*sizeof(double));
+			  eig_val = (double *) Malloc(npack*sizeof(double));
 			  eofdata[varID][levelID].eig_val = eig_val;
 			}
 
@@ -567,11 +566,11 @@ void *EOFs(void * argument)
 		      if ( cdoVerbose )
 			cdoPrint("allocating covar with %i x %i elements | npack=%i", nts, nts, npack);
 
-		      covar_array = (double *) malloc(nts*nts*sizeof(double));
-		      covar = (double **) malloc(nts*sizeof(double *));
+		      covar_array = (double *) Malloc(nts*nts*sizeof(double));
+		      covar = (double **) Malloc(nts*sizeof(double *));
 		      for ( i = 0; i < nts; ++i ) covar[i] = covar_array + nts*i;
 
-		      eig_val = (double *) malloc(nts*sizeof(double));
+		      eig_val = (double *) Malloc(nts*sizeof(double));
 		      eofdata[varID][levelID].eig_val     = eig_val;
 		      eofdata[varID][levelID].covar_array = covar_array;
 		      eofdata[varID][levelID].covar       = covar;
@@ -647,24 +646,24 @@ void *EOFs(void * argument)
       
       for( levelID = 0; levelID < nlevs; levelID++ )
         { 	  
-	  if ( eofdata[varID][levelID].eig_val ) free(eofdata[varID][levelID].eig_val);
-	  if ( eofdata[varID][levelID].covar_array ) free(eofdata[varID][levelID].covar_array);
-	  if ( eofdata[varID][levelID].covar ) free(eofdata[varID][levelID].covar);
+	  if ( eofdata[varID][levelID].eig_val ) Free(eofdata[varID][levelID].eig_val);
+	  if ( eofdata[varID][levelID].covar_array ) Free(eofdata[varID][levelID].covar_array);
+	  if ( eofdata[varID][levelID].covar ) Free(eofdata[varID][levelID].covar);
 	  if ( time_space && eofdata[varID][levelID].data )
 	    {
 	      for ( tsID = 0; tsID < nts; tsID++ )
-		if ( eofdata[varID][levelID].data[tsID] ) free(eofdata[varID][levelID].data[tsID]);
-	      free(eofdata[varID][levelID].data);
+		if ( eofdata[varID][levelID].data[tsID] ) Free(eofdata[varID][levelID].data[tsID]);
+	      Free(eofdata[varID][levelID].data);
 	    }
 	}
       
-      free(eofdata[varID]);
+      Free(eofdata[varID]);
     }
 
-  free(eofdata);
-  free(in);
-  free(pack);
-  free(weight);
+  Free(eofdata);
+  Free(in);
+  Free(pack);
+  Free(weight);
 
   streamClose(streamID3);
   streamClose(streamID2);
@@ -680,5 +679,5 @@ void *EOFs(void * argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/EcaIndices.c b/src/EcaIndices.c
index 4318705..7ad3975 100755
--- a/src/EcaIndices.c
+++ b/src/EcaIndices.c
@@ -303,7 +303,7 @@ void *EcaCfd(void *argument)
   eca1(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -338,7 +338,7 @@ void *EcaCsu(void *argument)
   eca1(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -355,7 +355,7 @@ void *EcaCwdi(void *argument)
   if ( operatorArgc() > 0 ) argN = parameter2int(operatorArgv()[0]);
   if ( operatorArgc() > 1 ) argT = parameter2double(operatorArgv()[1]);
   
-  longname = (char*) malloc(strlen(CWDI_LONGNAME) + 80);
+  longname = (char*) Malloc(strlen(CWDI_LONGNAME) + 80);
   sprintf(longname, CWDI_LONGNAME, argN, argT);
 
   request.var1.name     = CWDI_NAME;
@@ -378,10 +378,10 @@ void *EcaCwdi(void *argument)
    
   eca2(&request);
   
-  free(longname);
+  Free(longname);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -396,7 +396,7 @@ void *EcaCwfi(void *argument)
 
   if ( operatorArgc() > 0 ) argN = parameter2int(operatorArgv()[0]);
 
-  longname = (char*) malloc(strlen(CWFI_LONGNAME) + 40);
+  longname = (char*) Malloc(strlen(CWFI_LONGNAME) + 40);
   sprintf(longname, CWFI_LONGNAME, argN);
 
   request.var1.name     = CWFI_NAME;
@@ -418,10 +418,10 @@ void *EcaCwfi(void *argument)
    
   eca2(&request);
   
-  free(longname);
+  Free(longname);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -442,7 +442,7 @@ void *EcaEtr(void *argument)
   eca3(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -469,7 +469,7 @@ void *EcaFd(void *argument)
   eca1(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -498,7 +498,7 @@ void *EcaGsl(void *argument)
   if ( operatorArgc() > 1 ) argT = parameter2double(operatorArgv()[1]);
   if ( operatorArgc() > 2 ) minLandFraction = parameter2double(operatorArgv()[2]);
 
-  longname = (char*) malloc(strlen(GSL_LONGNAME) + 160);
+  longname = (char*) Malloc(strlen(GSL_LONGNAME) + 160);
   sprintf(longname, GSL_LONGNAME, argN, argT, argN, argT);
   
   request.name      = GSL_NAME;
@@ -517,11 +517,11 @@ void *EcaGsl(void *argument)
    
   eca4(&request);
   
-  free(longname);
+  Free(longname);
 
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -559,7 +559,7 @@ void *EcaHd(void *argument)
 
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -576,7 +576,7 @@ void *EcaHwdi(void *argument)
   if ( operatorArgc() > 0 ) argN = parameter2int(operatorArgv()[0]);
   if ( operatorArgc() > 1 ) argT = parameter2double(operatorArgv()[1]);
   
-  longname = (char*) malloc(strlen(HWDI_LONGNAME) + 80);
+  longname = (char*) Malloc(strlen(HWDI_LONGNAME) + 80);
   sprintf(longname, HWDI_LONGNAME, argN, argT);
   
   request.var1.name     = HWDI_NAME;
@@ -599,10 +599,10 @@ void *EcaHwdi(void *argument)
    
   eca2(&request);
   
-  free(longname);
+  Free(longname);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -617,7 +617,7 @@ void *EcaHwfi(void *argument)
 
   if ( operatorArgc() > 0 ) argN = parameter2int(operatorArgv()[0]);
 
-  longname = (char*) malloc(strlen(HWFI_LONGNAME) + 40);
+  longname = (char*) Malloc(strlen(HWFI_LONGNAME) + 40);
   sprintf(longname, HWFI_LONGNAME, argN);
 
   request.var1.name     = HWFI_NAME;
@@ -639,10 +639,10 @@ void *EcaHwfi(void *argument)
    
   eca2(&request);
   
-  free(longname);
+  Free(longname);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -669,7 +669,7 @@ void *EcaId(void *argument)
   eca1(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -683,7 +683,7 @@ void *EcaSu(void *argument)
   cdoOperatorAdd("eca_su", 0, 31, NULL);
 
   if ( operatorArgc() > 0 ) argT = parameter2double(operatorArgv()[0]);
-  longname = (char*) malloc(strlen(SU_LONGNAME) + 40);
+  longname = (char*) Malloc(strlen(SU_LONGNAME) + 40);
   sprintf(longname, SU_LONGNAME, argT);
 
   request.var1.name     = SU_NAME;
@@ -701,10 +701,10 @@ void *EcaSu(void *argument)
  
   eca1(&request);
   
-  free(longname);
+  Free(longname);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -729,7 +729,7 @@ void *EcaTg10p(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -754,7 +754,7 @@ void *EcaTg90p(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -779,7 +779,7 @@ void *EcaTn10p(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -804,7 +804,7 @@ void *EcaTn90p(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -818,7 +818,7 @@ void *EcaTr(void *argument)
   cdoOperatorAdd("eca_tr", 0, 31, NULL);
 
   if ( operatorArgc() > 0 ) argT = parameter2double(operatorArgv()[0]);
-  longname = (char*) malloc(strlen(TR_LONGNAME) + 40);
+  longname = (char*) Malloc(strlen(TR_LONGNAME) + 40);
   sprintf(longname, TR_LONGNAME, argT);
  
   request.var1.name     = TR_NAME;
@@ -836,10 +836,10 @@ void *EcaTr(void *argument)
    
   eca1(&request);
   
-  free(longname);
+  Free(longname);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -864,7 +864,7 @@ void *EcaTx10p(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -889,7 +889,7 @@ void *EcaTx90p(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -931,7 +931,7 @@ void *EcaCdd(void *argument)
   eca1(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -970,7 +970,7 @@ void *EcaCwd(void *argument)
   eca1(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1038,7 +1038,7 @@ void *EcaPd(void *argument)
   eca1(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1064,7 +1064,7 @@ void *EcaR75p(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1090,7 +1090,7 @@ void *EcaR75ptot(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1116,7 +1116,7 @@ void *EcaR90p(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1142,7 +1142,7 @@ void *EcaR90ptot(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1168,7 +1168,7 @@ void *EcaR95p(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1194,7 +1194,7 @@ void *EcaR95ptot(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1220,7 +1220,7 @@ void *EcaR99p(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1246,7 +1246,7 @@ void *EcaR99ptot(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1280,7 +1280,7 @@ void *EcaRr1(void *argument)
   eca1(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1314,7 +1314,7 @@ void *EcaRx1day(void *argument)
   eca1(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1327,7 +1327,7 @@ void *EcaRx5day(void *argument)
   cdoInitialize(argument);
   if ( operatorArgc() > 0 ) argX = parameter2double(operatorArgv()[0]);
   
-  longname = (char*) malloc(strlen(RX5DAY_LONGNAME2) + 40);
+  longname = (char*) Malloc(strlen(RX5DAY_LONGNAME2) + 40);
   sprintf(longname, RX5DAY_LONGNAME2, argX);
   
   cdoOperatorAdd("eca_rx5day", 0, 31, NULL);
@@ -1351,10 +1351,10 @@ void *EcaRx5day(void *argument)
    
   eca1(&request);
   
-  free(longname);
+  Free(longname);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1388,7 +1388,7 @@ void *EcaSdii(void *argument)
   eca1(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1415,7 +1415,7 @@ void *Fdns(void *argument)
   eca2(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1431,7 +1431,7 @@ void *Strwin(void *argument)
   if ( operatorArgc() > 0 )
     maxWind = parameter2double(operatorArgv()[0]);
 
-  longname = (char*) malloc(strlen(STRWIN_LONGNAME) + 40);
+  longname = (char*) Malloc(strlen(STRWIN_LONGNAME) + 40);
   sprintf(longname, STRWIN_LONGNAME, maxWind);
          
   request.var1.name     = STRWIN_NAME;
@@ -1454,10 +1454,10 @@ void *Strwin(void *argument)
    
   eca1(&request);
   
-  free(longname);
+  Free(longname);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1490,7 +1490,7 @@ void *Strbre(void *argument)
   eca1(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1523,7 +1523,7 @@ void *Strgal(void *argument)
   eca1(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
@@ -1556,5 +1556,5 @@ void *Hurr(void *argument)
   eca1(&request);
   cdoFinish();
   
-  return (0);
+  return 0;
 }
diff --git a/src/Echam5ini.c b/src/Echam5ini.c
index c6c61e4..43612d1 100644
--- a/src/Echam5ini.c
+++ b/src/Echam5ini.c
@@ -89,7 +89,7 @@ void inivar(VAR *var, int gridtype, int zaxistype, int code, const char *name,
 static
 void inivars_ml(VAR **vars)
 {
-  *vars = (VAR*) malloc((nvars_ml+1)*sizeof(VAR));
+  *vars = (VAR*) Malloc((nvars_ml+1)*sizeof(VAR));
 
   inivar(&(*vars)[0], GRID_GAUSSIAN, ZAXIS_HYBRID,  133, "Q",   "specific humidity", "kg/kg");
   inivar(&(*vars)[1], GRID_SPECTRAL, ZAXIS_HYBRID,  138, "SVO", "vorticity", "1/s");
@@ -136,7 +136,7 @@ int import_e5ml(const char *filename, VAR **vars)
   nce(nc_inq_attlen(nc_file_id, NC_GLOBAL, "file_type", &attlen));
   filetype[attlen] = 0;
 
-  if ( strcmp(filetype, strfiletype_ml) != 0 ) return (0);
+  if ( strcmp(filetype, strfiletype_ml) != 0 ) return 0;
 
   inivars_ml(vars);
 
@@ -170,15 +170,15 @@ int import_e5ml(const char *filename, VAR **vars)
   zaxisIDsfc = zaxisCreate(ZAXIS_SURFACE, 1);
   zaxisIDml  = zaxisCreate(ZAXIS_HYBRID, nlev);
 
-  levs = (double*) malloc(nlev*sizeof(double));
+  levs = (double*) Malloc(nlev*sizeof(double));
   for ( i = 0; i < nlev; i++ ) levs[i] = i+1;
   zaxisDefLevels(zaxisIDml, levs);
-  free(levs);
+  Free(levs);
 
   /* read variables */
 
-  xvals = (double*) malloc(nlon*sizeof(double));
-  yvals = (double*) malloc(nlat*sizeof(double));
+  xvals = (double*) Malloc(nlon*sizeof(double));
+  yvals = (double*) Malloc(nlat*sizeof(double));
 
   nce(nc_inq_varid(nc_file_id, "lon", &nc_var_id));
   nce(nc_get_var_double(nc_file_id, nc_var_id, xvals));
@@ -189,10 +189,10 @@ int import_e5ml(const char *filename, VAR **vars)
   gridDefXvals(gridIDgp, xvals);
   gridDefYvals(gridIDgp, yvals);
 
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
 
-  vct   = (double*) malloc(nvct*sizeof(double));
+  vct   = (double*) Malloc(nvct*sizeof(double));
 
   nce(nc_inq_varid(nc_file_id, "vct_a", &nc_var_id));
   nce(nc_get_var_double(nc_file_id, nc_var_id, vct));
@@ -201,7 +201,7 @@ int import_e5ml(const char *filename, VAR **vars)
   nce(nc_get_var_double(nc_file_id, nc_var_id, vct+nlevp1));
 
   zaxisDefVct(zaxisIDml, 2*nlevp1, vct);
-  free(vct);
+  Free(vct);
 
   for ( iv = 0; iv < nvars_ml; iv++ )
     {
@@ -227,7 +227,7 @@ int import_e5ml(const char *filename, VAR **vars)
       (*vars)[iv].gridsize  = nvals;
       (*vars)[iv].nlev      = nlev;
 
-      (*vars)[iv].ptr = (double*) malloc(nlev*nvals*sizeof(double));
+      (*vars)[iv].ptr = (double*) Malloc(nlev*nvals*sizeof(double));
       
       for ( i = 0; i < nlev; i++ )
 	{
@@ -257,7 +257,7 @@ int import_e5ml(const char *filename, VAR **vars)
   start[0] = 0;    start[1] = 0;  start[2] = nlev;
   count[0] = nsp;  count[1] = 2;  count[2] = 1;
 
-  (*vars)[nvars_ml].ptr = (double*) malloc(nsp*2*sizeof(double));
+  (*vars)[nvars_ml].ptr = (double*) Malloc(nsp*2*sizeof(double));
 
   nce(nc_inq_varid(nc_file_id, "STP", &nc_var_id));
   nce(nc_get_vara_double(nc_file_id, nc_var_id, start, count, (*vars)[nvars_ml].ptr));
@@ -296,7 +296,7 @@ void export_e5ml(const char *filename, VAR *vars, int nvars, int vdate, int vtim
   char atttext[1024];
   size_t attlen;
   //int attint;
-  char *username;
+  const char *username;
   char timestr[30];
   time_t date_and_time_in_sec;
   struct tm *date_and_time;
@@ -452,8 +452,8 @@ void export_e5ml(const char *filename, VAR *vars, int nvars, int vdate, int vtim
 
   /* define gaussian grid */
 
-  xvals = (double*) malloc(nlon*sizeof(double));
-  yvals = (double*) malloc(nlat*sizeof(double));
+  xvals = (double*) Malloc(nlon*sizeof(double));
+  yvals = (double*) Malloc(nlat*sizeof(double));
 
   gridInqXvals(gridIDgp, xvals);
   gridInqYvals(gridIDgp, yvals);
@@ -480,14 +480,14 @@ void export_e5ml(const char *filename, VAR *vars, int nvars, int vdate, int vtim
   nce(nc_enddef(nc_file_id));
   nce(nc_put_var_double(nc_file_id, nc_var_id, xvals));
 
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
 
   /* define model level */
 
   // nvct = nvclev*2;
 
-  /* vct   = (double*) malloc(nvct*sizeof(double)); */
+  /* vct   = (double*) Malloc(nvct*sizeof(double)); */
 
   vct = zaxisInqVctPtr(zaxisIDml);
 
@@ -513,7 +513,7 @@ void export_e5ml(const char *filename, VAR *vars, int nvars, int vdate, int vtim
   nce(nc_enddef(nc_file_id));
   nce(nc_put_var_double(nc_file_id, nc_var_id, vct+nlevp1));
 
-  /* free(vct); */
+  /* Free(vct); */
 
   lspid = -1;
   nc_stpid = -1;
@@ -634,7 +634,7 @@ void read_gg3d(int nc_file_id, const char *name, VAR *var, int gridID, int zaxis
   var->gridsize  = gridsize;
   var->nlev      = nlev;
 
-  var->ptr = (double*) malloc(nlev*gridsize*sizeof(double));
+  var->ptr = (double*) Malloc(nlev*gridsize*sizeof(double));
   
   for ( i = 0; i < nlev; i++ )
     {
@@ -671,7 +671,7 @@ void read_fc4d(int nc_file_id, const char *name, VAR *var, int gridID, int zaxis
   var->gridsize  = nfc;
   var->nlev      = nlev;
 
-  var->ptr = (double*) malloc(nlev*nfc*sizeof(double));
+  var->ptr = (double*) Malloc(nlev*nfc*sizeof(double));
   
   for ( i = 0; i < nlev; i++ )
     {
@@ -726,7 +726,7 @@ int import_e5res(const char *filename, VAR **vars, ATTS *atts)
   nce(nc_inq_attlen(nc_file_id, NC_GLOBAL, "file_type", &attlen));
   filetype[attlen] = 0;
 
-  if ( memcmp(filetype, strfiletype_res, strlen(strfiletype_res)) != 0 ) return (0);
+  if ( memcmp(filetype, strfiletype_res, strlen(strfiletype_res)) != 0 ) return 0;
 
   /* printf("%s\n", filetype); */
 
@@ -800,8 +800,8 @@ int import_e5res(const char *filename, VAR **vars, ATTS *atts)
   gridDefXsize(gridIDgp, nlon);
   gridDefYsize(gridIDgp, nlat);
 
-  xvals = (double*) malloc(nlon*sizeof(double));
-  yvals = (double*) malloc(nlat*sizeof(double));
+  xvals = (double*) Malloc(nlon*sizeof(double));
+  yvals = (double*) Malloc(nlat*sizeof(double));
 
   nce(nc_inq_varid(nc_file_id, "lon", &nc_var_id));
   nce(nc_get_var_double(nc_file_id, nc_var_id, xvals));
@@ -812,8 +812,8 @@ int import_e5res(const char *filename, VAR **vars, ATTS *atts)
   gridDefXvals(gridIDgp, xvals);
   gridDefYvals(gridIDgp, yvals);
 
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
 
   /* define fourier grid */
 
@@ -835,10 +835,10 @@ int import_e5res(const char *filename, VAR **vars, ATTS *atts)
   nlev = belowsurface;
   zaxisIDbsfc = zaxisCreate(ZAXIS_DEPTH_BELOW_LAND, nlev);
 
-  levs = (double*) malloc(nlev*sizeof(double));
+  levs = (double*) Malloc(nlev*sizeof(double));
   for ( i = 0; i < nlev; i++ ) levs[i] = 0;
   zaxisDefLevels(zaxisIDbsfc, levs);
-  free(levs);
+  Free(levs);
 
 
   /* define n2 level */
@@ -846,17 +846,17 @@ int import_e5res(const char *filename, VAR **vars, ATTS *atts)
   nlev = n2;
   zaxisIDn2 = zaxisCreate(ZAXIS_GENERIC, nlev);
 
-  levs = (double*) malloc(nlev*sizeof(double));
+  levs = (double*) Malloc(nlev*sizeof(double));
   for ( i = 0; i < nlev; i++ ) levs[i] = 0;
   zaxisDefLevels(zaxisIDn2, levs);
-  free(levs);
+  Free(levs);
 
   /* define model level */
 
   nlev = lev;
   nvct = nvclev*2;
 
-  vct   = (double*) malloc(nvct*sizeof(double));
+  vct   = (double*) Malloc(nvct*sizeof(double));
 
   nce(nc_inq_varid(nc_file_id, "vct_a", &nc_var_id));
   nce(nc_get_var_double(nc_file_id, nc_var_id, vct));
@@ -868,10 +868,10 @@ int import_e5res(const char *filename, VAR **vars, ATTS *atts)
 
   zaxisIDml  = zaxisCreate(ZAXIS_HYBRID, nlev);
 
-  levs = (double*) malloc(nlev*sizeof(double));
+  levs = (double*) Malloc(nlev*sizeof(double));
   for ( i = 0; i < nlev; i++ ) levs[i] = i+1;
   zaxisDefLevels(zaxisIDml, levs);
-  free(levs);
+  Free(levs);
 
   zaxisDefVct(zaxisIDml, 2*nlevp1, vct);
 
@@ -879,14 +879,14 @@ int import_e5res(const char *filename, VAR **vars, ATTS *atts)
 
   zaxisIDmlh  = zaxisCreate(ZAXIS_HYBRID_HALF, nlevp1);
 
-  levs = (double*) malloc(nlevp1*sizeof(double));
+  levs = (double*) Malloc(nlevp1*sizeof(double));
   for ( i = 0; i < nlevp1; i++ ) levs[i] = i;
   zaxisDefLevels(zaxisIDmlh, levs);
-  free(levs);
+  Free(levs);
 
   zaxisDefVct(zaxisIDmlh, 2*nlevp1, vct);
 
-  free(vct);
+  Free(vct);
 
 
   nce(nc_inq(nc_file_id, &ndims, &nvars, &ngatts, &unlimdimid));
@@ -936,7 +936,7 @@ int import_e5res(const char *filename, VAR **vars, ATTS *atts)
 	}
     }
 
-  *vars = (VAR*) malloc(max_vars*sizeof(VAR));
+  *vars = (VAR*) Malloc(max_vars*sizeof(VAR));
 
   varid = 0;
   for ( ncvarid = 0; ncvarid < nvars; ncvarid++ )
@@ -1008,7 +1008,7 @@ int import_e5res(const char *filename, VAR **vars, ATTS *atts)
 	      (*vars)[varid].gridsize  = nvals;
 	      (*vars)[varid].nlev      = 1;
 
-	      (*vars)[varid].ptr = (double*) malloc(nvals*sizeof(double));
+	      (*vars)[varid].ptr = (double*) Malloc(nvals*sizeof(double));
 
 	      nce(nc_inq_varid(nc_file_id, name, &nc_var_id));
 	      nce(nc_get_var_double(nc_file_id, nc_var_id, (*vars)[varid].ptr));
@@ -1026,7 +1026,7 @@ int import_e5res(const char *filename, VAR **vars, ATTS *atts)
 	      (*vars)[varid].gridsize  = nvals;
 	      (*vars)[varid].nlev      = nlev;
 
-	      (*vars)[varid].ptr = (double*) malloc(nvals*nlev*sizeof(double));
+	      (*vars)[varid].ptr = (double*) Malloc(nvals*nlev*sizeof(double));
 
 	      for ( i = 0; i < nlev; i++ )
 		{
@@ -1375,8 +1375,8 @@ void export_e5res(const char *filename, VAR *vars, int nvars)
   nlon = lon;
   nlat = lat;
 
-  xvals = (double*) malloc(nlon*sizeof(double));
-  yvals = (double*) malloc(nlat*sizeof(double));
+  xvals = (double*) Malloc(nlon*sizeof(double));
+  yvals = (double*) Malloc(nlat*sizeof(double));
 
   gridInqXvals(gridIDgp, xvals);
   gridInqYvals(gridIDgp, yvals);
@@ -1392,15 +1392,15 @@ void export_e5res(const char *filename, VAR *vars, int nvars)
   nce(nc_enddef(nc_file_id));
   nce(nc_put_var_double(nc_file_id, nc_var_id, xvals));
 
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
 
   /* define model level */
 
   nlev = lev;
   //nvct = nvclev*2;
 
-  /* vct   = (double*) malloc(nvct*sizeof(double)); */
+  /* vct   = (double*) Malloc(nvct*sizeof(double)); */
 
   vct = zaxisInqVctPtr(zaxisIDml);
 
@@ -1414,7 +1414,7 @@ void export_e5res(const char *filename, VAR *vars, int nvars)
   nce(nc_enddef(nc_file_id));
   nce(nc_put_var_double(nc_file_id, nc_var_id, vct+nlevp1));
 
-  /* free(vct); */
+  /* Free(vct); */
 
   /*close input file */
   nce(nc_close(nc_file_id));
@@ -1536,7 +1536,7 @@ void *Echam5ini(void *argument)
 
       nvars = vlistNvars(vlistID1);
 
-      vars = (VAR*) malloc(nvars*sizeof(VAR));
+      vars = (VAR*) Malloc(nvars*sizeof(VAR));
 
       for ( varID = 0; varID < nvars; ++varID )
 	{
@@ -1587,7 +1587,7 @@ void *Echam5ini(void *argument)
 	  vars[varID].gridsize  = gridsize;
 	  vars[varID].nlev      = nlev;
 
-	  vars[varID].ptr = (double*) malloc(nlev*gridsize*sizeof(double));
+	  vars[varID].ptr = (double*) Malloc(nlev*gridsize*sizeof(double));
 	}
 
       nrecs = streamInqTimestep(streamID1, 0);
@@ -1630,5 +1630,5 @@ void *Echam5ini(void *argument)
   */
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Enlarge.c b/src/Enlarge.c
index 9be8095..3d9268a 100644
--- a/src/Enlarge.c
+++ b/src/Enlarge.c
@@ -77,8 +77,8 @@ void *Enlarge(void *argument)
 
   streamDefVlist(streamID2, vlistID2);
 
-  array1 = (double*) malloc(gridsize2*sizeof(double));
-  array2 = (double*) malloc(gridsize2*sizeof(double));
+  array1 = (double*) Malloc(gridsize2*sizeof(double));
+  array2 = (double*) Malloc(gridsize2*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -151,10 +151,10 @@ void *Enlarge(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array1 ) free(array1);
-  if ( array2 ) free(array2);
+  if ( array1 ) Free(array1);
+  if ( array2 ) Free(array2);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Enlargegrid.c b/src/Enlargegrid.c
index 674fa6d..0fca3c3 100644
--- a/src/Enlargegrid.c
+++ b/src/Enlargegrid.c
@@ -69,13 +69,13 @@ void gen_index(int gridID1, int gridID2, int *index)
       if ( ! (gridInqXvals(gridID2, NULL) && gridInqYvals(gridID2, NULL)) )
 	cdoAbort("Grid 2 has no values!");
 
-      xvals1 = (double*) malloc(nlon1*sizeof(double));
-      yvals1 = (double*) malloc(nlat1*sizeof(double));
-      xvals2 = (double*) malloc(nlon2*sizeof(double));
-      yvals2 = (double*) malloc(nlat2*sizeof(double));
+      xvals1 = (double*) Malloc(nlon1*sizeof(double));
+      yvals1 = (double*) Malloc(nlat1*sizeof(double));
+      xvals2 = (double*) Malloc(nlon2*sizeof(double));
+      yvals2 = (double*) Malloc(nlat2*sizeof(double));
 
-      xindex = (int*) malloc(nlon2*sizeof(int));
-      yindex = (int*) malloc(nlat2*sizeof(int));
+      xindex = (int*) Malloc(nlon2*sizeof(int));
+      yindex = (int*) Malloc(nlat2*sizeof(int));
 
       gridInqXvals(gridID1, xvals1);
       gridInqYvals(gridID1, yvals1);
@@ -154,12 +154,12 @@ void gen_index(int gridID1, int gridID2, int *index)
 	  }
 
 
-      free(xindex);
-      free(yindex);
-      free(xvals1);
-      free(yvals1);
-      free(xvals2);
-      free(yvals2);
+      Free(xindex);
+      Free(yindex);
+      Free(xvals1);
+      Free(yvals1);
+      Free(xvals2);
+      Free(yvals2);
     }
   else
     cdoAbort("Unsupported grid type: %s", gridNamePtr(gridtype1));
@@ -209,9 +209,9 @@ void *Enlargegrid(void *argument)
   gridsize1 = gridInqSize(gridID1);
   gridsize2 = gridInqSize(gridID2);
 
-  array1 = (double*) malloc(gridsize1*sizeof(double));
-  array2 = (double*) malloc(gridsize2*sizeof(double));
-  gindex = (int*) malloc(gridsize1*sizeof(int));
+  array1 = (double*) Malloc(gridsize1*sizeof(double));
+  array2 = (double*) Malloc(gridsize2*sizeof(double));
+  gindex = (int*) Malloc(gridsize1*sizeof(int));
 
   gen_index(gridID2, gridID1, gindex);
 
@@ -261,11 +261,11 @@ void *Enlargegrid(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
  
-  if ( gindex ) free(gindex);
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
+  if ( gindex ) Free(gindex);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Ensstat.c b/src/Ensstat.c
index 8f5d570..a7da8b6 100644
--- a/src/Ensstat.c
+++ b/src/Ensstat.c
@@ -41,13 +41,12 @@
 void *Ensstat(void *argument)
 {
   int i;
-  int varID, recID;
+  int varID = 0, recID;
   int gridID;
   int nrecs, nrecs0;
-  int levelID;
+  int levelID = 0;
   int streamID = 0;
   int nmiss;
-  int fileID;
   double missval;
   typedef struct
   {
@@ -56,7 +55,6 @@ void *Ensstat(void *argument)
     double missval;
     double *array;
   } ens_file_t;
-  int pn = 0;
 
   cdoInitialize(argument);
 
@@ -76,13 +74,13 @@ void *Ensstat(void *argument)
 
   int argc = operatorArgc();
   int nargc = argc;
+
+  double pn = 0;
   if ( operfunc == func_pctl )
     {
       operatorInputArg("percentile number");
       pn = parameter2int(operatorArgv()[0]);
-      
-      if ( pn < 1 || pn > 99 )
-        cdoAbort("Illegal argument: percentile number %d is not in the range 1..99!", pn);
+      percentile_check_number(pn);
       argc--;
     }
 
@@ -104,26 +102,26 @@ void *Ensstat(void *argument)
       if ( !userFileOverwrite(ofilename) )
 	cdoAbort("Outputfile %s already exists!", ofilename);
 
-  ens_file_t *ef = (ens_file_t *) malloc(nfiles*sizeof(ens_file_t));
+  ens_file_t *ef = (ens_file_t *) Malloc(nfiles*sizeof(ens_file_t));
 
-  field_t *field = (field_t *) malloc(ompNumThreads*sizeof(field_t));
+  field_t *field = (field_t *) Malloc(ompNumThreads*sizeof(field_t));
   for ( i = 0; i < ompNumThreads; i++ )
     {
       field_init(&field[i]);
       field[i].size   = nfiles;
-      field[i].ptr    = (double*) malloc(nfiles*sizeof(double));
-      field[i].weight = (double*) malloc(nfiles*sizeof(double));
-      for ( fileID = 0; fileID < nfiles; fileID++ ) field[i].weight[fileID] = 1;
+      field[i].ptr    = (double*) Malloc(nfiles*sizeof(double));
+      field[i].weight = (double*) Malloc(nfiles*sizeof(double));
+      for ( int fileID = 0; fileID < nfiles; fileID++ ) field[i].weight[fileID] = 1;
     }
 
-  for ( fileID = 0; fileID < nfiles; fileID++ )
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
     {
       ef[fileID].streamID = streamOpenRead(cdoStreamName(fileID));
       ef[fileID].vlistID  = streamInqVlist(ef[fileID].streamID);
     }
 
   /* check that the contents is always the same */
-  for ( fileID = 1; fileID < nfiles; fileID++ )
+  for ( int fileID = 1; fileID < nfiles; fileID++ )
     vlistCompare(ef[0].vlistID, ef[fileID].vlistID, CMP_ALL);
 
   int vlistID1 = ef[0].vlistID;
@@ -134,16 +132,16 @@ void *Ensstat(void *argument)
 
   int gridsize = vlistGridsizeMax(vlistID1);
 
-  for ( fileID = 0; fileID < nfiles; fileID++ )
-    ef[fileID].array = (double*) malloc(gridsize*sizeof(double));
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
+    ef[fileID].array = (double*) Malloc(gridsize*sizeof(double));
 
-  double *array2 = (double *) malloc(gridsize*sizeof(double));
+  double *array2 = (double *) Malloc(gridsize*sizeof(double));
 
   int nvars = vlistNvars(vlistID2);
   double *count2 = NULL;
   if ( count_data )
     {
-      count2 = (double *) malloc(gridsize*sizeof(double));
+      count2 = (double *) Malloc(gridsize*sizeof(double));
       for ( varID = 0; varID < nvars; ++varID )
 	{
 	  char name[CDI_MAX_NAME];
@@ -167,7 +165,7 @@ void *Ensstat(void *argument)
   do
     {
       nrecs0 = streamInqTimestep(ef[0].streamID, tsID);
-      for ( fileID = 1; fileID < nfiles; fileID++ )
+      for ( int fileID = 1; fileID < nfiles; fileID++ )
 	{
 	  streamID = ef[fileID].streamID;
 	  nrecs = streamInqTimestep(streamID, tsID);
@@ -190,10 +188,11 @@ void *Ensstat(void *argument)
       for ( recID = 0; recID < nrecs0; recID++ )
 	{
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(fileID, streamID, nmiss) \
+#pragma omp parallel for default(none) shared(ef, nfiles)         \
+                                         private(streamID, nmiss) \
                                      lastprivate(varID, levelID)
 #endif
-	  for ( fileID = 0; fileID < nfiles; fileID++ )
+	  for ( int fileID = 0; fileID < nfiles; fileID++ )
 	    {
 	      streamID = ef[fileID].streamID;
 	      streamInqRecord(streamID, &varID, &levelID);
@@ -207,7 +206,7 @@ void *Ensstat(void *argument)
 
 	  nmiss = 0;
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(i, fileID)
+#pragma omp parallel for default(shared)
 #endif
 	  for ( i = 0; i < gridsize; ++i )
 	    {
@@ -215,7 +214,7 @@ void *Ensstat(void *argument)
 
 	      field[ompthID].missval = missval;
 	      field[ompthID].nmiss = 0;
-	      for ( fileID = 0; fileID < nfiles; fileID++ )
+	      for ( int fileID = 0; fileID < nfiles; fileID++ )
 		{
 		  field[ompthID].ptr[fileID] = ef[fileID].array[i];
 		  if ( DBL_IS_EQUAL(field[ompthID].ptr[fileID], ef[fileID].missval) )
@@ -255,27 +254,27 @@ void *Ensstat(void *argument)
     }
   while ( nrecs0 > 0 );
 
-  for ( fileID = 0; fileID < nfiles; fileID++ )
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
     streamClose(ef[fileID].streamID);
 
   streamClose(streamID2);
 
-  for ( fileID = 0; fileID < nfiles; fileID++ )
-    if ( ef[fileID].array ) free(ef[fileID].array);
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
+    if ( ef[fileID].array ) Free(ef[fileID].array);
 
-  if ( ef ) free(ef);
-  if ( array2 ) free(array2);
-  if ( count2 ) free(count2);
+  if ( ef ) Free(ef);
+  if ( array2 ) Free(array2);
+  if ( count2 ) Free(count2);
 
   for ( i = 0; i < ompNumThreads; i++ )
     {
-      if ( field[i].ptr    ) free(field[i].ptr);
-      if ( field[i].weight ) free(field[i].weight);
+      if ( field[i].ptr    ) Free(field[i].ptr);
+      if ( field[i].weight ) Free(field[i].weight);
     }
 
-  if ( field ) free(field);
+  if ( field ) Free(field);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Ensstat3.c b/src/Ensstat3.c
index fa4db7c..45f6a66 100644
--- a/src/Ensstat3.c
+++ b/src/Ensstat3.c
@@ -77,7 +77,6 @@ void *Ensstat3(void *argument)
   double val;
   int ival;
   field_t *field;
-  int fileID;
   const char *ofilename;
 
   typedef struct
@@ -117,25 +116,25 @@ void *Ensstat3(void *argument)
       if ( !userFileOverwrite(ofilename) )
 	cdoAbort("Outputfile %s already exists!", ofilename);
 
-  ef = (ens_file_t*) malloc(nfiles*sizeof(ens_file_t));
+  ef = (ens_file_t*) Malloc(nfiles*sizeof(ens_file_t));
 
   /* *************************************************** */
   /* should each thread be allocating memory locally???? */
   /* ("first touch strategy")                            */
   /* --> #pragma omp parallel for ...                    */
   /* *************************************************** */
-  field = (field_t*) malloc(ompNumThreads*sizeof(field_t));
+  field = (field_t*) Malloc(ompNumThreads*sizeof(field_t));
   for ( i = 0; i < ompNumThreads; i++ )
     {
       field_init(&field[i]);
       field[i].size   = nfiles;
-      field[i].ptr    = (double*) malloc(nfiles*sizeof(double));
-      field[i].weight = (double*) malloc(nfiles*sizeof(double));
-      for ( fileID = 0; fileID < nfiles; fileID++ )
+      field[i].ptr    = (double*) Malloc(nfiles*sizeof(double));
+      field[i].weight = (double*) Malloc(nfiles*sizeof(double));
+      for ( int fileID = 0; fileID < nfiles; fileID++ )
 	field[i].weight[fileID] = 1;
     }
 
-  for ( fileID = 0; fileID < nfiles; fileID++ )
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
     {
       streamID = streamOpenRead(cdoStreamName(fileID));
 
@@ -146,15 +145,15 @@ void *Ensstat3(void *argument)
     }
 
   /* check for identical contents of all ensemble members */
-  for ( fileID = 1; fileID < nfiles; fileID++ )
+  for ( int fileID = 1; fileID < nfiles; fileID++ )
     vlistCompare(ef[0].vlistID, ef[fileID].vlistID, CMP_ALL);
 
   vlistID1 = ef[0].vlistID;
   vlistID2 = vlistCreate();
   nvars = vlistNvars(vlistID1);
-  varID2 = (int*) malloc(nvars*sizeof(int));
+  varID2 = (int*) Malloc(nvars*sizeof(int));
 
-  levs = (double*) calloc(nfiles, sizeof(double));
+  levs = (double*) Calloc(nfiles, sizeof(double));
   zaxisID2 = zaxisCreate(ZAXIS_GENERIC, nfiles);
   for ( i=0; i<nfiles; i++ )
     levs[i] = i;
@@ -207,38 +206,38 @@ void *Ensstat3(void *argument)
 
   gridsize = vlistGridsizeMax(vlistID1);
 
-  for ( fileID = 0; fileID < nfiles; fileID++ )
-    ef[fileID].array = (double*) malloc(gridsize*sizeof(double));
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
+    ef[fileID].array = (double*) Malloc(gridsize*sizeof(double));
 
   if ( operfunc == func_rank && datafunc == SPACE ) 
     { /*need to memorize data for entire grid before writing          */
-      array2 = (int**) malloc((nfiles+1)*sizeof(int*));
+      array2 = (int**) Malloc((nfiles+1)*sizeof(int*));
       for ( binID=0; binID<nfiles; binID++ ) 
-	array2[binID] = (int*) calloc( gridsize, sizeof(int));
+	array2[binID] = (int*) Calloc( gridsize, sizeof(int));
     }
   else if ( operfunc == func_rank )
     {  /* can process data separately for each timestep and only need */
        /* to cumulate values over the grid                            */
-      array2    = (int **) malloc( (nfiles+1)*sizeof(int *));
+      array2    = (int **) Malloc( (nfiles+1)*sizeof(int *));
       for ( binID=0; binID<nfiles; binID++ )
-	array2[binID] = (int*) calloc( 1, sizeof(int));
+	array2[binID] = (int*) Calloc( 1, sizeof(int));
     }
 
   if ( operfunc == func_roc ) {
-    ctg_tab = (int**) malloc((nbins+1)*sizeof(int*));
+    ctg_tab = (int**) Malloc((nbins+1)*sizeof(int*));
     hist =    (int*) malloc ( nbins*sizeof(int));
-    uThresh = (double*) malloc( nbins*sizeof(double));
-    lThresh = (double*) malloc( nbins*sizeof(double));
-    roc     = (double**) malloc((nbins+1)*sizeof(double*));
+    uThresh = (double*) Malloc( nbins*sizeof(double));
+    lThresh = (double*) Malloc( nbins*sizeof(double));
+    roc     = (double**) Malloc((nbins+1)*sizeof(double*));
     
     for  ( i=0; i<nbins; i++ ) {
-      ctg_tab[i] = (int*) calloc( 4,sizeof(int));
-      roc[i]     = (double*) calloc( 2,sizeof(double));
+      ctg_tab[i] = (int*) Calloc( 4,sizeof(int));
+      roc[i]     = (double*) Calloc( 2,sizeof(double));
       uThresh[i] = ((double)i+1)/nbins;
       lThresh[i] = (double)i/nbins;
     }
-    ctg_tab[nbins] = (int*) calloc(4,sizeof(int));
-    roc[nbins]     = (double*) calloc(2,sizeof(double));
+    ctg_tab[nbins] = (int*) Calloc(4,sizeof(int));
+    roc[nbins]     = (double*) Calloc(2,sizeof(double));
   }
   
   
@@ -246,7 +245,7 @@ void *Ensstat3(void *argument)
   do
     {
       nrecs0 = streamInqTimestep(ef[0].streamID, tsID);
-      for ( fileID = 1; fileID < nfiles; fileID++ )
+      for ( int fileID = 1; fileID < nfiles; fileID++ )
 	{
 	  streamID = ef[fileID].streamID;
 	  nrecs = streamInqTimestep(streamID, tsID);
@@ -271,10 +270,11 @@ void *Ensstat3(void *argument)
       for ( recID = 0; recID < nrecs0; recID++ )
 	{
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(fileID, streamID, nmiss) \
-                                     lastprivate(varID, levelID)
+#pragma omp parallel for default(none) shared(ef, nfiles)      \
+                                      private(streamID, nmiss) \
+                                  lastprivate(varID, levelID)
 #endif
-	  for ( fileID = 0; fileID < nfiles; fileID++ )
+	  for ( int fileID = 0; fileID < nfiles; fileID++ )
 	    {
 	      streamID = ef[fileID].streamID;
 	      streamInqRecord(streamID, &varID, &levelID);
@@ -291,7 +291,7 @@ void *Ensstat3(void *argument)
 	      array2[binID][0] = 0;
 
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(i, binID, fileID)
+#pragma omp parallel for default(shared) private(binID)
 #endif
 	  for ( i = 0; i < gridsize; i++ )
 	    {
@@ -300,7 +300,7 @@ void *Ensstat3(void *argument)
 	      field[ompthID].missval = missval;
 	      field[ompthID].nmiss = 0;
 	      have_miss = 0;
-	      for ( fileID = 0; fileID < nfiles; fileID++ )
+	      for ( int fileID = 0; fileID < nfiles; fileID++ )
 		{
 		  field[ompthID].ptr[fileID] = ef[fileID].array[i];
 		  if ( DBL_IS_EQUAL(field[ompthID].ptr[fileID], missval) ) 
@@ -439,7 +439,7 @@ void *Ensstat3(void *argument)
       int osize = gridsize;
 
       if ( datafunc == TIME ) osize = 1;
-      tmpdoub = (double*) malloc(osize*sizeof(double));
+      tmpdoub = (double*) Malloc(osize*sizeof(double));
 
       for ( binID = 0; binID < nfiles; binID++ )
 	{
@@ -450,7 +450,7 @@ void *Ensstat3(void *argument)
 	  streamWriteRecord(streamID2, tmpdoub, nmiss);
 	}
 
-      free(tmpdoub);
+      Free(tmpdoub);
     }
   else if ( operfunc == func_roc ) {
     fprintf(stdout, "#             :     TP     FP     FN     TN         TPR        FPR\n");
@@ -478,7 +478,7 @@ void *Ensstat3(void *argument)
 	    roc_curve_integrate((const double **)roc,nbins));
   }
 
-  for ( fileID = 0; fileID < nfiles; fileID++ )
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
     {
       streamID = ef[fileID].streamID;
       streamClose(streamID);
@@ -487,27 +487,27 @@ void *Ensstat3(void *argument)
   if ( operfunc != func_roc ) 
     streamClose(streamID2);
 
-  for ( fileID = 0; fileID < nfiles; fileID++ )
-    if ( ef[fileID].array ) free(ef[fileID].array);
+  for ( int fileID = 0; fileID < nfiles; fileID++ )
+    if ( ef[fileID].array ) Free(ef[fileID].array);
 
-  if ( ef ) free(ef);
+  if ( ef ) Free(ef);
   if ( array2 ) {
     for (binID=0; binID<nfiles; binID++ )
-      free(array2[binID]);
-    free(array2);
+      Free(array2[binID]);
+    Free(array2);
   }
 
   for ( i = 0; i < ompNumThreads; i++ )
     {
-      if ( field[i].ptr    ) free(field[i].ptr);
-      if ( field[i].weight ) free(field[i].weight);
+      if ( field[i].ptr    ) Free(field[i].ptr);
+      if ( field[i].weight ) Free(field[i].weight);
     }
   
-  if ( field ) free(field);
+  if ( field ) Free(field);
   
   cdoFinish();
   
-  return (0);
+  return 0;
 }
 
 
diff --git a/src/Ensval.c b/src/Ensval.c
index 1e0439f..1338930 100644
--- a/src/Ensval.c
+++ b/src/Ensval.c
@@ -118,31 +118,31 @@ void *Ensval(void *argument)
   }
 
   // allocate array to hold results 
-  r = (double*) malloc( nostreams*sizeof(double));
+  r = (double*) Malloc( nostreams*sizeof(double));
   
 
   // one stream for each value of the decomposition
-  streamID2 = (int*) malloc( nostreams*sizeof(int));
-  vlistID2 = (int*) malloc( nostreams*sizeof(int));
-  taxisID2 = (int*) malloc( nostreams*sizeof(int));
-  zaxisID2 = (int*) malloc( nostreams*sizeof(int));
+  streamID2 = (int*) Malloc( nostreams*sizeof(int));
+  vlistID2 = (int*) Malloc( nostreams*sizeof(int));
+  taxisID2 = (int*) Malloc( nostreams*sizeof(int));
+  zaxisID2 = (int*) Malloc( nostreams*sizeof(int));
 
-  val = (double*) calloc( nfiles,sizeof(double));
+  val = (double*) Calloc( nfiles,sizeof(double));
   
   if ( operfunc == CRPS ) {
-    alpha= (double*) calloc( nens+1,sizeof(double));
-    beta = (double*) calloc( nens+1,sizeof(double));
-    alpha_weights= (double*) calloc( nens+1,sizeof(double));
-    beta_weights = (double*) calloc( nens+1,sizeof(double));
+    alpha= (double*) Calloc( nens+1,sizeof(double));
+    beta = (double*) Calloc( nens+1,sizeof(double));
+    alpha_weights= (double*) Calloc( nens+1,sizeof(double));
+    beta_weights = (double*) Calloc( nens+1,sizeof(double));
   }
   else if ( operfunc == BRS ) {
-    brs_g = (double*) calloc( nens+1,sizeof(double));
-    brs_o = (double*) calloc( nens+1,sizeof(double));
+    brs_g = (double*) Calloc( nens+1,sizeof(double));
+    brs_o = (double*) Calloc( nens+1,sizeof(double));
   }
   if ( cdoVerbose )
     cdoPrint("Ensemble over %d files (Ensstat5).", nfiles-1);
 
-  ef = (ens_file_t*) malloc(nfiles*sizeof(ens_file_t));
+  ef = (ens_file_t*) Malloc(nfiles*sizeof(ens_file_t));
   
   for ( fileID = 0; fileID < nfiles; fileID++ )
     {
@@ -203,7 +203,7 @@ void *Ensval(void *argument)
       break;
     }
 
-    ofilename = (char*) calloc(namelen, sizeof(char));
+    ofilename = (char*) Calloc(namelen, sizeof(char));
 
     sprintf(ofilename, "%s.%s%s", ofilebase, type_suffix, file_suffix);
     // fprintf(stderr, "StreamID %i: %s\n", stream, ofilename);
@@ -217,7 +217,7 @@ void *Ensval(void *argument)
     streamID2[stream] = streamOpenWrite(fileargument, cdoFiletype());    
     file_argument_free(fileargument);
 
-    free(ofilename);
+    Free(ofilename);
 
     zaxisID2[stream] = zaxisDuplicate(zaxisID1);
     taxisID2[stream] = taxisDuplicate(taxisID1);
@@ -269,12 +269,12 @@ void *Ensval(void *argument)
 		  gridsize = gridInqSize(gridID);
 		  missval  = vlistInqVarMissval(vlistID1, varID);
 		  gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));//vlistGridsizeMax(vlistID1);
-		  if ( weights ) free(weights); 
-		  weights= (double*) malloc(gridsize*sizeof(double));
+		  if ( weights ) Free(weights); 
+		  weights= (double*) Malloc(gridsize*sizeof(double));
 		}
 
-	      if (ef[fileID].array ) free(ef[fileID].array);
-	      ef[fileID].array = (double*) malloc(gridsize*sizeof(double));
+	      if (ef[fileID].array ) Free(ef[fileID].array);
+	      ef[fileID].array = (double*) Malloc(gridsize*sizeof(double));
 
 	      streamID = ef[fileID].streamID;
 	      streamReadRecord(streamID, ef[fileID].array, &nmiss);
@@ -509,7 +509,7 @@ void *Ensval(void *argument)
     streamClose(streamID2[stream]);
   
   for ( fileID = 0; fileID < nfiles; fileID++ )
-    if ( ef[fileID].array ) free(ef[fileID].array);
+    if ( ef[fileID].array ) Free(ef[fileID].array);
 
   for ( stream = 0; stream < nostreams; stream++ ) {
     vlistDestroy(vlistID2[stream]);
@@ -524,23 +524,23 @@ void *Ensval(void *argument)
   gridDestroy(gridID);
   gridDestroy(gridID2);
 
-  if ( ef ) free(ef);
-  if ( weights ) free(weights);
-  if ( r ) free(r);
-  if ( alpha ) free(alpha);
-  if ( beta ) free(beta);
-  if ( alpha_weights ) free(alpha_weights);
-  if ( beta_weights ) free(beta_weights);
-  if ( brs_g ) free(brs_g);
-  if ( brs_o) free(brs_o);
-  if ( brs_g_weights ) free(brs_g_weights);
-  if ( brs_o_weights) free(brs_o_weights);
-  if ( val ) free(val);
-  if ( vlistID2 ) free(vlistID2);
-  if ( streamID2 ) free(streamID2);
-  if ( zaxisID2 ) free(zaxisID2);
-  if ( taxisID2 ) free(taxisID2);  
+  if ( ef ) Free(ef);
+  if ( weights ) Free(weights);
+  if ( r ) Free(r);
+  if ( alpha ) Free(alpha);
+  if ( beta ) Free(beta);
+  if ( alpha_weights ) Free(alpha_weights);
+  if ( beta_weights ) Free(beta_weights);
+  if ( brs_g ) Free(brs_g);
+  if ( brs_o) Free(brs_o);
+  if ( brs_g_weights ) Free(brs_g_weights);
+  if ( brs_o_weights) Free(brs_o_weights);
+  if ( val ) Free(val);
+  if ( vlistID2 ) Free(vlistID2);
+  if ( streamID2 ) Free(streamID2);
+  if ( zaxisID2 ) Free(zaxisID2);
+  if ( taxisID2 ) Free(taxisID2);  
   cdoFinish();
   
-  return (0);
+  return 0;
 }
diff --git a/src/Eof3d.c b/src/Eof3d.c
index 21f3ce4..5883300 100644
--- a/src/Eof3d.c
+++ b/src/Eof3d.c
@@ -91,13 +91,12 @@ void *EOF3d(void * argument)
 
   int streamID1  = streamOpenRead(cdoStreamName(0));
   int vlistID1   = streamInqVlist(streamID1);
-  int taxisID1   = vlistInqTaxis(vlistID1);
   int gridID1    = vlistInqVarGrid(vlistID1, 0);
   long gridsize  = vlistGridsizeMax(vlistID1);
   int nvars      = vlistNvars(vlistID1);
-  int nrecs      = vlistNrecs(vlistID1);
+  int nrecs;
 
-  double *weight = (double *) malloc(gridsize*sizeof(double));
+  double *weight = (double *) Malloc(gridsize*sizeof(double));
   for ( i = 0; i < gridsize; ++i ) weight[i] = 1.;
 
   if ( weight_mode == WEIGHT_ON )
@@ -136,7 +135,7 @@ void *EOF3d(void * argument)
 
   streamID1 = streamOpenRead(cdoStreamName(0));
   vlistID1  = streamInqVlist(streamID1);
-  taxisID1  = vlistInqTaxis(vlistID1);
+  int taxisID1  = vlistInqTaxis(vlistID1);
 
   /* reset the requested number of eigen-function to the maximum if neccessary */
   if ( n_eig > nts )
@@ -152,44 +151,43 @@ void *EOF3d(void * argument)
   if ( cdoVerbose )  cdoPrint("counted %i timesteps",n);
 
   /* allocation of temporary fields and output structures */
-  double *in       = (double *) malloc(gridsize*sizeof(double));
-  int **datacounts = (int **) malloc(nvars*sizeof(int*));
-  double ***datafields   = (double ***) malloc(nvars*sizeof(double **));
-  double ***eigenvectors = (double ***) malloc(nvars*sizeof(double **));
-  double ***eigenvalues  = (double ***) malloc(nvars*sizeof(double **));
+  double *in       = (double *) Malloc(gridsize*sizeof(double));
+  int **datacounts = (int **) Malloc(nvars*sizeof(int*));
+  double ***datafields   = (double ***) Malloc(nvars*sizeof(double **));
+  double ***eigenvectors = (double ***) Malloc(nvars*sizeof(double **));
+  double ***eigenvalues  = (double ***) Malloc(nvars*sizeof(double **));
 
   for ( varID = 0; varID < nvars; ++varID )
     {
-      gridID1             = vlistInqVarGrid(vlistID1, varID);
       gridsize            = vlistGridsizeMax(vlistID1);
       nlevs               = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
       temp_size           = gridsize * nlevs;
       missval             = vlistInqVarMissval(vlistID1, varID);
 
-      datacounts[varID]   = (int*) malloc(nlevs*sizeof(int));
-      datafields[varID]   = (double **) malloc(nts*sizeof(double *));
+      datacounts[varID]   = (int*) Malloc(nlevs*sizeof(int));
+      datafields[varID]   = (double **) Malloc(nts*sizeof(double *));
 
       for ( tsID = 0; tsID < nts; tsID++ )
 	{
-	  datafields[varID][tsID] = (double *) malloc(temp_size*sizeof(double));
+	  datafields[varID][tsID] = (double *) Malloc(temp_size*sizeof(double));
 	  for ( i = 0; i < temp_size; ++i ) datafields[varID][tsID][i] = 0;
 	}
-      datacounts[varID] = (int *) malloc(temp_size*sizeof(int));	      
+      datacounts[varID] = (int *) Malloc(temp_size*sizeof(int));	      
       for( i = 0; i < temp_size; i++) datacounts[varID][i] = 0;
       
-      eigenvectors[varID] = (double **) malloc(n_eig*sizeof(double *));
-      eigenvalues[varID]  = (double **) malloc(nts*sizeof(double *));
+      eigenvectors[varID] = (double **) Malloc(n_eig*sizeof(double *));
+      eigenvalues[varID]  = (double **) Malloc(nts*sizeof(double *));
 
       for ( i = 0; i < n; i++ )
 	{
 	  if ( i < n_eig )
 	    {
-	      eigenvectors[varID][i] = (double *) malloc(temp_size*sizeof(double));
+	      eigenvectors[varID][i] = (double *) Malloc(temp_size*sizeof(double));
 	      for ( i2 = 0; i2 < temp_size; ++i2 )
 		eigenvectors[varID][i][i2] = missval;
 	    }
 	  
-	  eigenvalues[varID][i]    = (double *) malloc(1*sizeof(double));
+	  eigenvalues[varID][i]    = (double *) Malloc(1*sizeof(double));
 	  eigenvalues[varID][i][0] = missval;
 	}
     }
@@ -241,7 +239,7 @@ void *EOF3d(void * argument)
   if ( cdoVerbose ) 
     cdoPrint("Read data for %i variables",nvars);
   
-  int *pack = (int*) malloc(temp_size*sizeof(int)); //TODO
+  int *pack = (int*) Malloc(temp_size*sizeof(int)); //TODO
 
   for ( varID = 0; varID < nvars; varID++ )
     {
@@ -284,10 +282,10 @@ void *EOF3d(void * argument)
       }
 
 	  
-      cov = (double **) malloc(nts*sizeof(double*));
+      cov = (double **) Malloc(nts*sizeof(double*));
       for ( j1 = 0; j1 < nts; j1++)
-	cov[j1] = (double *) malloc(nts*sizeof(double));
-      eigv = (double *) malloc(n*sizeof(double));
+	cov[j1] = (double *) Malloc(nts*sizeof(double));
+      eigv = (double *) Malloc(n*sizeof(double));
 
       if ( cdoVerbose )  {
 	cdoPrint("varID %i allocated eigv and cov with nts=%i and n=%i",varID,nts,n);
@@ -339,7 +337,7 @@ void *EOF3d(void * argument)
 	  double *eigenvec = eigenvectors[varID][eofID];
 
 #if defined(_OPENMP)
-#pragma omp parallel for private(i,j,sum) shared(datafields, eigenvec)
+#pragma omp parallel for default(none) private(j,sum) shared(varID,nts,eofID,npack,pack,cov,datafields,eigenvec)
 #endif 
 	  for ( i = 0; i < npack; i++ )
 	    {
@@ -353,8 +351,7 @@ void *EOF3d(void * argument)
 	  sum = 0;
 
 #if defined(_OPENMP)
-#pragma omp parallel for private(i) default(none) reduction(+:sum) \
-  shared(eigenvec,weight,pack,npack,gridsize)
+#pragma omp parallel for default(none)  shared(eigenvec,weight,pack,npack,gridsize) reduction(+:sum)
 #endif 
 	  for ( i = 0; i < npack; i++ )
 	    sum +=  weight[pack[i]%gridsize] *
@@ -364,8 +361,7 @@ void *EOF3d(void * argument)
 	    {
 	      sum = sqrt(sum);
 #if defined(_OPENMP)
-#pragma omp parallel for private(i) default(none) \
-  shared(sum,npack,eigenvec,pack)
+#pragma omp parallel for default(none) shared(sum,npack,eigenvec,pack)
 #endif
 	      for( i = 0; i < npack; i++ )
 		eigenvec[pack[i]] /= sum;
@@ -373,18 +369,17 @@ void *EOF3d(void * argument)
 	  else
 	    {
 #if defined(_OPENMP)
-#pragma omp parallel for private(i) default(none) \
-  shared(eigenvec,pack,missval,npack)
+#pragma omp parallel for default(none) shared(eigenvec,pack,missval,npack)
 #endif
 	      for( i = 0; i < npack; i++ )
 		eigenvec[pack[i]] = missval;
 	    }
 	}     /* for ( eofID = 0; eofID < n_eig; eofID++ )     */
 
-      if ( eigv ) free(eigv);
+      if ( eigv ) Free(eigv);
       for ( i=0; i<n; i++ )
 	if ( cov[i] ) 
-	  free(cov[i]);
+	  Free(cov[i]);
     }         /* for ( varID = 0; varID < nvars; varID++ )    */
 
   /* write files with eigenvalues (ID3) and eigenvectors (ID2) */
@@ -397,9 +392,9 @@ void *EOF3d(void * argument)
   int gridID2     = gridCreate(GRID_LONLAT, 1);
   gridDefXsize(gridID2, 1);
   gridDefYsize(gridID2, 1);
-  xvals       = (double*) malloc(1*sizeof(double));
-  yvals       = (double*) malloc(1*sizeof(double));
-  zvals       = (double*) malloc(1*sizeof(double));
+  xvals       = (double*) Malloc(1*sizeof(double));
+  yvals       = (double*) Malloc(1*sizeof(double));
+  zvals       = (double*) Malloc(1*sizeof(double));
   xvals[0]    = 0;
   yvals[0]    = 0;
   zvals[0]    = 0;
@@ -416,7 +411,7 @@ void *EOF3d(void * argument)
   taxisDefRtime(taxisID2, 0);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  varID2 = (int*) malloc(nvars*sizeof(int));
+  varID2 = (int*) Malloc(nvars*sizeof(int));
   for ( varID=0; varID<nvars; varID++ )
     varID2[varID] = vlistDefVar(vlistID2, gridID2, zaxisID2, TSTEP_INSTANT);
   ngrids      = vlistNgrids(vlistID2);
@@ -480,26 +475,26 @@ void *EOF3d(void * argument)
     {
       for( i = 0; i < nts; i++)
 	{
-	  free(datafields[varID][tsID]);
+	  Free(datafields[varID][tsID]);
 	  if ( i < n_eig )
-	    free(eigenvectors[varID][i]);
-	  free(eigenvalues[varID][i]);
+	    Free(eigenvectors[varID][i]);
+	  Free(eigenvalues[varID][i]);
 	}
 
-      free(datafields[varID]);
-      free(datacounts[varID]);
-      free(eigenvectors[varID]);
-      free(eigenvalues[varID]);
+      Free(datafields[varID]);
+      Free(datacounts[varID]);
+      Free(eigenvectors[varID]);
+      Free(eigenvalues[varID]);
     }
 
-  free(datafields);
-  free(datacounts);
-  free(eigenvectors);
-  free(eigenvalues);
-  free(in);
+  Free(datafields);
+  Free(datacounts);
+  Free(eigenvectors);
+  Free(eigenvalues);
+  Free(in);
 
-  free(pack);
-  free(weight);
+  Free(pack);
+  Free(weight);
 
   streamClose(streamID3);
   streamClose(streamID2);
@@ -507,5 +502,5 @@ void *EOF3d(void * argument)
   
   cdoFinish();
  
-  return (0);
+  return 0;
 }
diff --git a/src/Eofcoeff.c b/src/Eofcoeff.c
index 7b9160b..0a62b97 100644
--- a/src/Eofcoeff.c
+++ b/src/Eofcoeff.c
@@ -81,9 +81,8 @@ void *Eofcoeff(void * argument)
     cdoAbort("Too many grids in input");
   
   nvars = vlistNvars(vlistID1)==vlistNvars(vlistID2) ? vlistNvars(vlistID1) : -1;
-  nrecs = vlistNrecs(vlistID1);
   nlevs = zaxisInqSize(vlistInqVarZaxis(vlistID1, 0));
-  //w = (double*) malloc(gridsize*sizeof(double));
+  //w = (double*) Malloc(gridsize*sizeof(double));
   //gridWeights(gridID2, w);
   
   
@@ -100,9 +99,9 @@ void *Eofcoeff(void * argument)
   filesuffix[0] = 0;
   cdoGenFileSuffix(filesuffix, sizeof(filesuffix), streamInqFiletype(streamID1), vlistID1, refname);
   
-  eof = (field_t***) malloc(nvars * sizeof(field_t**));
+  eof = (field_t***) Malloc(nvars * sizeof(field_t**));
   for ( varID=0; varID<nvars; varID++)
-    eof[varID] = (field_t**) malloc(nlevs*sizeof(field_t*));
+    eof[varID] = (field_t**) Malloc(nlevs*sizeof(field_t*));
 
   eofID = 0;
   while ( 1 )       
@@ -115,13 +114,13 @@ void *Eofcoeff(void * argument)
          streamInqRecord(streamID1, &varID, &levelID);
          missval1 = vlistInqVarMissval(vlistID1, varID);
          if ( eofID == 0 )
-           eof[varID][levelID] = (field_t*) malloc(1*sizeof(field_t));
+           eof[varID][levelID] = (field_t*) Malloc(1*sizeof(field_t));
          else
-           eof[varID][levelID] = (field_t*) realloc(eof[varID][levelID], (eofID+1)*sizeof(field_t));
+           eof[varID][levelID] = (field_t*) Realloc(eof[varID][levelID], (eofID+1)*sizeof(field_t));
          eof[varID][levelID][eofID].grid   = gridID1;
          eof[varID][levelID][eofID].nmiss  = 0;
          eof[varID][levelID][eofID].missval= missval1;
-         eof[varID][levelID][eofID].ptr    = (double*) malloc(gridsize*sizeof(double));
+         eof[varID][levelID][eofID].ptr    = (double*) Malloc(gridsize*sizeof(double));
          memset(&eof[varID][levelID][eofID].ptr[0], missval1, gridsize*sizeof(double));
          if ( varID >= nvars )
            cdoAbort("Internal error - too high varID");
@@ -140,8 +139,8 @@ void *Eofcoeff(void * argument)
   gridID3 = gridCreate(GRID_LONLAT, 1);
   gridDefXsize(gridID3, 1);
   gridDefYsize(gridID3, 1);
-  xvals= (double*) malloc(1*sizeof(double));
-  yvals= (double*) malloc(1*sizeof(double));
+  xvals= (double*) Malloc(1*sizeof(double));
+  yvals= (double*) Malloc(1*sizeof(double));
   xvals[0]=0;
   yvals[0]=0;
   gridDefXvals(gridID3, xvals);
@@ -159,8 +158,7 @@ void *Eofcoeff(void * argument)
     vlistDefVarTsteptype(vlistID3, varID, TSTEP_INSTANT);
   
   // open streams for eofcoeff output
-  streamIDs = (int*) malloc(neof*sizeof(int)); 
-  eofID = 0;
+  streamIDs = (int*) Malloc(neof*sizeof(int)); 
   for ( eofID = 0; eofID < neof; eofID++)
     {
       oname[nchars] = '\0';                       
@@ -182,11 +180,11 @@ void *Eofcoeff(void * argument)
     }
   
   // ALLOCATE temporary fields for data read and write
-  in.ptr = (double*) malloc(gridsize*sizeof(double));
+  in.ptr = (double*) Malloc(gridsize*sizeof(double));
   in.grid = gridID1;  
   out.missval = missval1;
   out.nmiss = 0;
-  out.ptr = (double*) malloc(1*sizeof(double));
+  out.ptr = (double*) Malloc(1*sizeof(double));
  
   tsID=0;
   while ( 1 )
@@ -246,6 +244,6 @@ void *Eofcoeff(void * argument)
   
   cdoFinish();
 
-  return (0);
+  return 0;
 }
 
diff --git a/src/Eofcoeff3d.c b/src/Eofcoeff3d.c
index ca8ba72..e647975 100644
--- a/src/Eofcoeff3d.c
+++ b/src/Eofcoeff3d.c
@@ -82,9 +82,8 @@ void *Eofcoeff3d(void * argument)
     cdoAbort("Too many grids in input");
   
   nvars = vlistNvars(vlistID1)==vlistNvars(vlistID2) ? vlistNvars(vlistID1) : -1;
-  nrecs = vlistNrecs(vlistID1); 
   nlevs = zaxisInqSize(vlistInqVarZaxis(vlistID1, 0));
-  //w = (double*) malloc(gridsize*sizeof(double));
+  //w = (double*) Malloc(gridsize*sizeof(double));
   //gridWeights(gridID2, w);
   
   
@@ -99,9 +98,9 @@ void *Eofcoeff3d(void * argument)
   filesuffix[0] = 0;
   cdoGenFileSuffix(filesuffix, sizeof(filesuffix), streamInqFiletype(streamID1), vlistID1, refname);
  
-  eof = (field_t***) malloc(nvars * sizeof(field_t**));
+  eof = (field_t***) Malloc(nvars * sizeof(field_t**));
   for ( varID=0; varID<nvars; varID++)
-    eof[varID] = (field_t**) malloc(nlevs*sizeof(field_t*));
+    eof[varID] = (field_t**) Malloc(nlevs*sizeof(field_t*));
 
   eofID = 0;
   while ( 1 )       
@@ -114,13 +113,13 @@ void *Eofcoeff3d(void * argument)
          streamInqRecord(streamID1, &varID, &levelID);
          missval1 = vlistInqVarMissval(vlistID1, varID);
          if ( eofID == 0 )
-           eof[varID][levelID] = (field_t*) malloc(1*sizeof(field_t));
+           eof[varID][levelID] = (field_t*) Malloc(1*sizeof(field_t));
          else
-           eof[varID][levelID] = (field_t*) realloc(eof[varID][levelID], (eofID+1)*sizeof(field_t));
+           eof[varID][levelID] = (field_t*) Realloc(eof[varID][levelID], (eofID+1)*sizeof(field_t));
          eof[varID][levelID][eofID].grid   = gridID1;
          eof[varID][levelID][eofID].nmiss  = 0;
          eof[varID][levelID][eofID].missval= missval1;
-         eof[varID][levelID][eofID].ptr    = (double*) malloc(gridsize*sizeof(double));
+         eof[varID][levelID][eofID].ptr    = (double*) Malloc(gridsize*sizeof(double));
          memset(&eof[varID][levelID][eofID].ptr[0], missval1, gridsize*sizeof(double));
 
          if ( varID >= nvars )
@@ -140,14 +139,14 @@ void *Eofcoeff3d(void * argument)
   gridID3 = gridCreate(GRID_LONLAT, 1);
   gridDefXsize(gridID3, 1);
   gridDefYsize(gridID3, 1);
-  xvals= (double*) malloc(1*sizeof(double));
-  yvals= (double*) malloc(1*sizeof(double));
+  xvals= (double*) Malloc(1*sizeof(double));
+  yvals= (double*) Malloc(1*sizeof(double));
   xvals[0]=0;
   yvals[0]=0;
   gridDefXvals(gridID3, xvals);
   gridDefYvals(gridID3, yvals);
   
-  zvals = (double *) malloc( 1* sizeof(double ));
+  zvals = (double *) Malloc( 1* sizeof(double ));
   zvals[0] = 0.;
   zaxisID3 = zaxisCreate(ZAXIS_GENERIC,1);
   zaxisDefLevels(zaxisID3,zvals);
@@ -156,13 +155,12 @@ void *Eofcoeff3d(void * argument)
   
   vlistID3 = vlistCreate();
   vlistDefTaxis(vlistID3,taxisID3);
-  varID3 = (int*) malloc( nvars * sizeof(int));
+  varID3 = (int*) Malloc( nvars * sizeof(int));
   for ( varID=0; varID<nvars; varID++ )
     varID3[varID] = vlistDefVar(vlistID3, gridID3, zaxisID3, TSTEP_INSTANT);
   
   // open streams for eofcoeff output
-  streamIDs = (int*) malloc(neof*sizeof(int)); 
-  eofID = 0;
+  streamIDs = (int*) Malloc(neof*sizeof(int)); 
   for ( eofID = 0; eofID < neof; eofID++)
     {
       oname[nchars] = '\0';                       
@@ -183,15 +181,15 @@ void *Eofcoeff3d(void * argument)
     }
   
   // ALLOCATE temporary fields for data read and write
-  in.ptr = (double*) malloc(gridsize*sizeof(double));
+  in.ptr = (double*) Malloc(gridsize*sizeof(double));
   in.grid = gridID1;  
-  out = (field_t**) malloc(nvars*sizeof(field_t*));
+  out = (field_t**) Malloc(nvars*sizeof(field_t*));
   for ( varID = 0; varID < nvars; varID++ ) {
-    out[varID] = (field_t*) malloc( neof * sizeof(field_t));
+    out[varID] = (field_t*) Malloc( neof * sizeof(field_t));
     for ( eofID=0; eofID<neof; eofID++ ) {
       out[varID][eofID].missval = missval1;
       out[varID][eofID].nmiss = 0;
-      out[varID][eofID].ptr = (double*) malloc(1*sizeof(double));
+      out[varID][eofID].ptr = (double*) Malloc(1*sizeof(double));
     }
   }
 
@@ -264,6 +262,6 @@ void *Eofcoeff3d(void * argument)
   
   cdoFinish();
 
-  return (0);
+  return 0;
 }
 
diff --git a/src/Exprf.c b/src/Exprf.c
index 6e81869..54b232f 100644
--- a/src/Exprf.c
+++ b/src/Exprf.c
@@ -86,7 +86,7 @@ void *Expr(void *argument)
       size_t slen;
 
       slen = strlen(operatorArgv()[0]);
-      exprs = (char*) malloc(slen+2);
+      exprs = (char*) Malloc(slen+2);
       strcpy(exprs, operatorArgv()[0]);
       if ( exprs[slen-1] != ';' )
 	{
@@ -109,7 +109,7 @@ void *Expr(void *argument)
       if ( stat(exprf, &filestat) != 0 ) cdoAbort("Stat failed on %s", exprf);
 
       fsize = (size_t) filestat.st_size;
-      exprs = (char*) malloc(fsize+1);
+      exprs = (char*) Malloc(fsize+1);
 
       while ( (ichar = fgetc(fp)) != EOF ) exprs[ipos++] = ichar;
 
@@ -177,8 +177,8 @@ void *Expr(void *argument)
 
   streamDefVlist(streamID2, vlistID2);
 
-  parse_arg.vardata1 = (double**) malloc(nvars1*sizeof(double*));
-  parse_arg.vardata2 = (double**) malloc(nvars2*sizeof(double*));
+  parse_arg.vardata1 = (double**) Malloc(nvars1*sizeof(double*));
+  parse_arg.vardata2 = (double**) Malloc(nvars2*sizeof(double*));
 
   for ( varID = 0; varID < nvars1; varID++ )
     {
@@ -189,7 +189,7 @@ void *Expr(void *argument)
       gridsize = gridInqSize(gridID);
       nlevel   = zaxisInqSize(zaxisID);
       if ( parse_arg.var_needed[varID] )
-	parse_arg.vardata1[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
+	parse_arg.vardata1[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
       else
 	parse_arg.vardata1[varID] = NULL;
     }
@@ -206,11 +206,11 @@ void *Expr(void *argument)
 
       gridsize = gridInqSize(gridID);
       nlevel   = zaxisInqSize(zaxisID);
-      parse_arg.vardata2[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
+      parse_arg.vardata2[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
     }
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -227,7 +227,6 @@ void *Expr(void *argument)
 	  if ( parse_arg.var_needed[varID] )
 	    {
 	      gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
-	      nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	      offset   = gridsize*levelID;
 	      single1  = parse_arg.vardata1[varID] + offset;
 	      streamReadRecord(streamID1, single1, &nmiss);
@@ -288,10 +287,10 @@ void *Expr(void *argument)
 
   yylex_destroy(scanner);
 
-  if ( array ) free(array);
-  if ( exprs ) free(exprs);
+  if ( array ) Free(array);
+  if ( exprs ) Free(exprs);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/FC.c b/src/FC.c
index 2082b14..f764a4a 100644
--- a/src/FC.c
+++ b/src/FC.c
@@ -189,8 +189,6 @@ void *FC(void *argument)
 	    }
 
 	  gridID2 = gridIDfc;
-	  nfc  = gridInqSize(gridID2);
-
 	  sptrans = sptrans_new(nlon, nlat, ntr, 0);
  	}
     }
@@ -230,7 +228,7 @@ void *FC(void *argument)
   // printf("nfc %d, ntr %d, nlat %d, nlon %d\n", nfc, ntr, nlat, nlon);
 
   nvars = vlistNvars(vlistID2);
-  vars  = (int*) malloc(nvars*sizeof(int));
+  vars  = (int*) Malloc(nvars*sizeof(int));
   for ( varID = 0; varID < nvars; varID++ )
     {
       if ( gridID1 == vlistInqVarGrid(vlistID1, varID) )
@@ -246,12 +244,12 @@ void *FC(void *argument)
   streamDefVlist(streamID2, vlistID2);
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array1 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
 
   if ( gridID2 != -1 )
     {
       gridsize = gridInqSize(gridID2);
-      array2 = (double*) malloc(gridsize*sizeof(double));
+      array2 = (double*) Malloc(gridsize*sizeof(double));
     }
 
   tsID = 0;
@@ -303,13 +301,13 @@ void *FC(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
-  if ( vars )   free(vars);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
+  if ( vars )   Free(vars);
 
   sptrans_delete(sptrans);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Filedes.c b/src/Filedes.c
index d9c12c4..d081aaa 100644
--- a/src/Filedes.c
+++ b/src/Filedes.c
@@ -425,5 +425,5 @@ void *Filedes(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Fillmiss.c b/src/Fillmiss.c
index c90806d..d6ff705 100644
--- a/src/Fillmiss.c
+++ b/src/Fillmiss.c
@@ -19,6 +19,7 @@
    This module contains the following operators:
 
 */
+#include <time.h> // clock()
 
 #include <cdi.h>
 #include <cdi.h>
@@ -27,26 +28,27 @@
 #include "pstream.h"
 #include "grid.h"
 
+#include "grid_search.h"
+#include "clipping/geometry.h"
+
 
 void fillmiss(field_t *field1, field_t *field2, int nfill)
 {
-  int gridID, nx, ny, i, j;
-  int nmiss1, nmiss2 = 0;
+  int nx, ny, i, j;
+  int nmiss2 = 0;
   int kr, ku, kl, ko;
   int ir, iu, il, io;
   int kh, kv, k1, k2, kk;
   int globgrid = FALSE,gridtype;
   double s1, s2;
   double xr, xu, xl, xo;
-  double missval;
-  double *array1, *array2;
   double **matrix1, **matrix2;
 
-  gridID   = field1->grid;
-  nmiss1   = field1->nmiss;
-  missval  = field1->missval;
-  array1   = field1->ptr;
-  array2   = field2->ptr;
+  int gridID = field1->grid;
+  int nmiss1 = field1->nmiss;
+  double missval  = field1->missval;
+  double *array1  = field1->ptr;
+  double *array2  = field2->ptr;
 
   nx       = gridInqXsize(gridID);
   ny       = gridInqYsize(gridID);
@@ -56,8 +58,8 @@ void fillmiss(field_t *field1, field_t *field2, int nfill)
   if ( !(gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN ) )
     cdoAbort("Unsupported grid type: %s!", gridNamePtr(gridtype));
 
-  matrix1 = (double **) malloc(ny * sizeof(double *));
-  matrix2 = (double **) malloc(ny * sizeof(double *));
+  matrix1 = (double **) Malloc(ny * sizeof(double *));
+  matrix2 = (double **) Malloc(ny * sizeof(double *));
 
   for ( j = 0; j < ny; j++ )
     {
@@ -140,10 +142,11 @@ void fillmiss(field_t *field1, field_t *field2, int nfill)
 
   if ( nmiss1 != nmiss2 ) cdoAbort("found only %d of %d missing values!", nmiss2, nmiss1);
 
-  free(matrix2);
-  free(matrix1);
+  Free(matrix2);
+  Free(matrix1);
 }
 
+
 void fillmiss_one_step(field_t *field1, field_t *field2, int maxfill)
 {
   int gridID, nx, ny, i, j;
@@ -165,8 +168,8 @@ void fillmiss_one_step(field_t *field1, field_t *field2, int maxfill)
   nx  = gridInqXsize(gridID);
   ny  = gridInqYsize(gridID);
 
-  matrix1 = (double **) malloc(ny * sizeof(double *));
-  matrix2 = (double **) malloc(ny * sizeof(double *));
+  matrix1 = (double **) Malloc(ny * sizeof(double *));
+  matrix2 = (double **) Malloc(ny * sizeof(double *));
 
   for ( j = 0; j < ny; j++ ) { matrix1[j] = array1 + j*nx; matrix2[j] = array2 + j*nx; }
 
@@ -263,40 +266,179 @@ void fillmiss_one_step(field_t *field1, field_t *field2, int maxfill)
   for ( j = 0; j < ny; j++ ) for ( i = 0; i < nx; i++ ) matrix1[j][i] = matrix2[j][i];
   }
 
-  free(matrix2);
-  free(matrix1);
+  Free(matrix2);
+  Free(matrix1);
+}
+
+
+void grid_search_nbr(struct gridsearch *gs, int num_neighbors, int *restrict nbr_add, double *restrict nbr_dist, double plon, double plat);
+double nbr_compute_weights(unsigned num_neighbors, const int *restrict src_grid_mask, int *restrict nbr_mask, const int *restrict nbr_add, double *restrict nbr_dist);
+unsigned nbr_normalize_weights(unsigned num_neighbors, double dist_tot, const int *restrict nbr_mask, int *restrict nbr_add, double *restrict nbr_dist);
+
+static
+void setmisstodis(field_t *field1, field_t *field2, int num_neighbors)
+{
+  int gridID = field1->grid;
+  double missval = field1->missval;
+  double *array1 = field1->ptr;
+  double *array2 = field2->ptr;
+
+  unsigned gridsize = gridInqSize(gridID);
+
+  unsigned nmiss = field1->nmiss;
+  unsigned nvals = gridsize - nmiss;
+
+  double *xvals = (double*) Malloc(gridsize*sizeof(double));
+  double *yvals = (double*) Malloc(gridsize*sizeof(double));
+
+  if ( gridInqType(gridID) == GRID_GME ) gridID = gridToUnstructured(gridID, 0);
+
+  if ( gridInqType(gridID) != GRID_UNSTRUCTURED && gridInqType(gridID) != GRID_CURVILINEAR )
+    gridID = gridToCurvilinear(gridID, 0);
+
+  gridInqXvals(gridID, xvals);
+  gridInqYvals(gridID, yvals);
+
+  /* Convert lat/lon units if required */
+  char units[CDI_MAX_NAME];
+  gridInqXunits(gridID, units);
+  grid_to_radian(units, gridsize, xvals, "grid center lon");
+  gridInqYunits(gridID, units);
+  grid_to_radian(units, gridsize, yvals, "grid center lat");
+
+  unsigned *mindex = NULL;
+  unsigned *vindex = NULL;
+  double *lons = NULL;
+  double *lats = NULL;
+
+  if ( nmiss ) mindex = (unsigned *) Calloc(1, nmiss*sizeof(unsigned));
+  if ( nvals )
+    {
+      vindex = (unsigned *) Calloc(1, nvals*sizeof(unsigned));
+      lons   = (double *) Malloc(nvals*sizeof(double));
+      lats   = (double *) Malloc(nvals*sizeof(double));
+    }
+  
+  unsigned nv = 0, nm = 0;
+  for ( unsigned i = 0; i < gridsize; ++i ) 
+    {
+      array2[i] = array1[i];
+      if ( DBL_IS_EQUAL(array1[i], missval) )
+        {
+          mindex[nm] = i;
+          nm++;
+        }
+      else
+        {
+          lons[nv] = xvals[i];
+          lats[nv] = yvals[i];
+          vindex[nv] = i;
+          nv++;
+        }
+    }
+
+  if ( nv != nvals ) cdoAbort("Internal problem, number of valid values differ!");
+  
+  int nbr_mask[num_neighbors];    /* mask at nearest neighbors                   */
+  int nbr_add[num_neighbors];     /* source address at nearest neighbors         */
+  double nbr_dist[num_neighbors]; /* angular distance four nearest neighbors     */
+
+  clock_t start, finish;
+  start = clock();
+
+  struct gridsearch *gs = NULL;
+
+  if ( nmiss )
+    {
+      if ( num_neighbors == 1 )
+        gs = gridsearch_create_nn(nvals, lons, lats);
+      else
+        gs = gridsearch_create(nvals, lons, lats);
+    }
+  
+  finish = clock();
+
+  if ( cdoVerbose ) printf("gridsearch created: %.2f seconds\n", ((double)(finish-start))/CLOCKS_PER_SEC);
+
+  progressInit();
+
+  start = clock();
+
+  double findex = 0;
+
+#pragma omp parallel for default(none) shared(findex, mindex, vindex, array1, array2, xvals, yvals, gs, nmiss, num_neighbors) \
+                                      private(nbr_mask, nbr_add, nbr_dist)
+  for ( unsigned i = 0; i < nmiss; ++i )
+    {
+#if defined(_OPENMP)
+#include "pragma_omp_atomic_update.h"
+#endif
+      findex++;
+      if ( cdo_omp_get_thread_num() == 0 ) progressStatus(0, 1, findex/nmiss);
+
+      grid_search_nbr(gs, num_neighbors, nbr_add, nbr_dist, xvals[mindex[i]], yvals[mindex[i]]);
+
+      /* Compute weights based on inverse distance if mask is false, eliminate those points */
+      double dist_tot = nbr_compute_weights(num_neighbors, NULL, nbr_mask, nbr_add, nbr_dist);
+
+      /* Normalize weights and store the link */
+      unsigned nadds = nbr_normalize_weights(num_neighbors, dist_tot, nbr_mask, nbr_add, nbr_dist);
+      if ( nadds )
+        {
+          double result = 0;
+          for ( unsigned n = 0; n < nadds; ++n ) result += array1[vindex[nbr_add[n]]]*nbr_dist[n];
+          array2[mindex[i]] = result;
+        }
+    }
+
+  if ( mindex ) Free(mindex);
+  if ( vindex ) Free(vindex);
+
+  finish = clock();
+
+  if ( cdoVerbose ) printf("gridsearch nearest: %.2f seconds\n", ((double)(finish-start))/CLOCKS_PER_SEC);
+
+  if ( gs ) gridsearch_delete(gs);
+
+  if ( lons ) Free(lons);
+  if ( lats ) Free(lats);
+  Free(xvals);
+  Free(yvals);
 }
 
 
 void *Fillmiss(void *argument)
 {
-  int FILLMISS,FILLMISSONESTEP;
-  int operatorID;
-  int streamID1, streamID2;
-  int nrecs, ngrids;
-  int index;
-  int tsID, recID, varID, levelID;
-  int gridsize;
-  int vlistID1, vlistID2;
-  int gridID1 = -1;
-  field_t field1, field2;
-  int taxisID1, taxisID2;
-  int nmiss, i, nfill = 1;
-  void (*fill_method) (field_t *fin , field_t *fout , int);
+  int nrecs, recID, varID, levelID;
+  void (*fill_method) (field_t *fin , field_t *fout , int) = NULL;
 
   cdoInitialize(argument);
 
-  FILLMISS        = cdoOperatorAdd("fillmiss"  ,  0, 0, "nfill");
-  FILLMISSONESTEP = cdoOperatorAdd("fillmiss2" ,  0, 0, "nfill");
-  operatorID      = cdoOperatorID();
+  int FILLMISS        = cdoOperatorAdd("fillmiss"   ,   0, 0, "nfill");
+  int FILLMISSONESTEP = cdoOperatorAdd("fillmiss2"  ,   0, 0, "nfill");
+  int SETMISSTONN     = cdoOperatorAdd("setmisstonn" ,  0, 0, "");
+  int SETMISSTODIS    = cdoOperatorAdd("setmisstodis" , 0, 0, "number of neighbors");
+
+  int operatorID      = cdoOperatorID();
+
+  int nfill = 1;
   if ( operatorID == FILLMISS )
      {
        fill_method = &fillmiss;
      }
-  else
+  else if ( operatorID == FILLMISSONESTEP )
      {
        fill_method = &fillmiss_one_step;
      }
+  else if ( operatorID == SETMISSTONN )
+     {
+       fill_method = &setmisstodis;
+     }
+  else if ( operatorID == SETMISSTODIS )
+     {
+       nfill = 4;
+       fill_method = &setmisstodis;
+     }
 
   /* Argument handling */
   {
@@ -305,8 +447,8 @@ void *Fillmiss(void *argument)
 
     if ( oargc == 1 )
       {
-        nfill = atoi(oargv[0]);
-        if ( operatorID != FILLMISSONESTEP ) 
+        nfill = parameter2int(oargv[0]);
+        if ( operatorID == FILLMISS ) 
           {
             if ( nfill < 1 || nfill > 4 ) cdoAbort("nfill out of range!");
           }
@@ -315,37 +457,28 @@ void *Fillmiss(void *argument)
       cdoAbort("Too many arguments!");
   }
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = vlistDuplicate(vlistID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  ngrids = vlistNgrids(vlistID1);
-  for ( index = 0; index < ngrids; index++ )
-    {
-      gridID1 = vlistGrid(vlistID1, index);
-
-      if ( gridInqType(gridID1) == GRID_GME ||
-	   gridInqType(gridID1) == GRID_UNSTRUCTURED )
-	cdoAbort("Interpolation of %s data unsupported!", gridNamePtr(gridInqType(gridID1)) );
-    }
-
-  streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
-  gridsize = vlistGridsizeMax(vlistID1);
+  int gridsize = vlistGridsizeMax(vlistID1);
 
+  field_t field1, field2;
   field_init(&field1);
   field_init(&field2);
-  field1.ptr   = (double*) malloc(gridsize*sizeof(double));
-  field2.ptr   = (double*) malloc(gridsize*sizeof(double));
+  field1.ptr = (double*) Malloc(gridsize*sizeof(double));
+  field2.ptr = (double*) Malloc(gridsize*sizeof(double));
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       taxisCopyTimestep(taxisID2, taxisID1);
@@ -357,33 +490,47 @@ void *Fillmiss(void *argument)
 	  streamInqRecord(streamID1, &varID, &levelID);
 	  streamReadRecord(streamID1, field1.ptr, &field1.nmiss);
 
-	  field1.grid    = vlistInqVarGrid(vlistID1, varID);
-	  field1.missval = vlistInqVarMissval(vlistID1, varID);
-
-	  field2.grid    = field1.grid;
-	  field2.nmiss   = 0;
-	  field2.missval = field1.missval;
-
-	  fill_method(&field1, &field2, nfill);
-
-	  gridsize = gridInqSize(field2.grid);
-	  nmiss = 0;
-	  for ( i = 0; i < gridsize; ++i )
-	    if ( DBL_IS_EQUAL(field2.ptr[i], field2.missval) ) nmiss++;
-
 	  streamDefRecord(streamID2, varID, levelID);
-	  streamWriteRecord(streamID2, field2.ptr, nmiss);
-	}
+
+          if ( field1.nmiss == 0 )
+            {
+              streamWriteRecord(streamID2, field1.ptr, 0);
+            }
+          else
+            {
+              int gridID = vlistInqVarGrid(vlistID1, varID);
+
+              if ( (operatorID == FILLMISS || operatorID == FILLMISSONESTEP) && 
+                   (gridInqType(gridID) == GRID_GME || gridInqType(gridID) == GRID_UNSTRUCTURED) )
+                cdoAbort("%s data unsupported!", gridNamePtr(gridInqType(gridID)) );
+                
+              field1.grid    = gridID;
+              field1.missval = vlistInqVarMissval(vlistID1, varID);
+
+              field2.grid    = field1.grid;
+              field2.nmiss   = 0;
+              field2.missval = field1.missval;
+
+              fill_method(&field1, &field2, nfill);
+
+              int gridsize = gridInqSize(field2.grid);
+              int nmiss = 0;
+              for ( int i = 0; i < gridsize; ++i )
+                if ( DBL_IS_EQUAL(field2.ptr[i], field2.missval) ) nmiss++;
+              
+              streamWriteRecord(streamID2, field2.ptr, nmiss);
+            }
+        }
       tsID++;
     }
 
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( field2.ptr ) free(field2.ptr);
-  if ( field1.ptr ) free(field1.ptr);
+  if ( field2.ptr ) Free(field2.ptr);
+  if ( field1.ptr ) Free(field1.ptr);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Filter.c b/src/Filter.c
index 08b0bf2..c65ca9f 100644
--- a/src/Filter.c
+++ b/src/Filter.c
@@ -65,12 +65,10 @@ void create_fmasc(int nts, double fdata, double fmin, double fmax, int *fmasc)
 #if defined(HAVE_LIBFFTW3) 
 static
 void filter_fftw(int nts, const int *fmasc, fftw_complex *fft_out, fftw_plan *p_T2S, fftw_plan *p_S2T)
-{  
-  int i;
-
+{
   fftw_execute(*p_T2S);
 
-  for ( i = 0; i < nts; i++ )
+  for ( int i = 0; i < nts; i++ )
     if ( ! fmasc[i] )
       {
         fft_out[i][0] = 0;
@@ -86,7 +84,6 @@ void filter_fftw(int nts, const int *fmasc, fftw_complex *fft_out, fftw_plan *p_
 static
 void filter_intrinsic(int nts, const int *fmasc, double *array1, double *array2)
 {  
-  int i;
   int lpower2 = FALSE;
   double *work_r = NULL;
   double *work_i = NULL;
@@ -95,8 +92,8 @@ void filter_intrinsic(int nts, const int *fmasc, double *array1, double *array2)
 
   if ( !lpower2 )
     {
-      work_r = (double*) malloc(nts*sizeof(double));
-      work_i = (double*) malloc(nts*sizeof(double));
+      work_r = (double*) Malloc(nts*sizeof(double));
+      work_i = (double*) Malloc(nts*sizeof(double));
     }
 
   if ( lpower2 )
@@ -104,7 +101,7 @@ void filter_intrinsic(int nts, const int *fmasc, double *array1, double *array2)
   else
     ft_r(array1, array2, nts, 1, work_r, work_i);
 
-  for ( i = 0; i < nts; i++ )
+  for ( int i = 0; i < nts; i++ )
     if ( ! fmasc[i] )
       array1[i] = array2[i] = 0;
 
@@ -113,8 +110,8 @@ void filter_intrinsic(int nts, const int *fmasc, double *array1, double *array2)
   else
     ft_r(array1, array2, nts, -1, work_r, work_i);
 
-  if ( work_r ) free(work_r);
-  if ( work_i ) free(work_i);
+  if ( work_r ) Free(work_r);
+  if ( work_i ) Free(work_i);
   
   return;
 }
@@ -123,13 +120,12 @@ void filter_intrinsic(int nts, const int *fmasc, double *array1, double *array2)
 void *Filter(void *argument)
 {
   enum {BANDPASS, HIGHPASS, LOWPASS};
-  char *tunits[] = {"second", "minute", "hour", "day", "month", "year"};
+  const char *tunits[] = {"second", "minute", "hour", "day", "month", "year"};
   int iunits[] = {31536000, 525600, 8760, 365, 12, 1};
   int gridsize;
   int nrecs;
   int gridID, varID, levelID, recID;
   int tsID;
-  int i;
   int nts;
   int nalloc = 0;
   int nmiss;
@@ -194,7 +190,7 @@ void *Filter(void *argument)
       if ( tsID >= nalloc )
         {
           nalloc += NALLOC_INC;
-          vars   = (field_t ***) realloc(vars, nalloc*sizeof(field_t **));
+          vars   = (field_t ***) Realloc(vars, nalloc*sizeof(field_t **));
         }
                        
       dtlist_taxisInqTimestep(dtlist, taxisID1, tsID);
@@ -206,7 +202,7 @@ void *Filter(void *argument)
           streamInqRecord(streamID1, &varID, &levelID);
           gridID   = vlistInqVarGrid(vlistID1, varID);
           gridsize = gridInqSize(gridID);
-          vars[tsID][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+          vars[tsID][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
           streamReadRecord(streamID1, vars[tsID][varID][levelID].ptr, &nmiss);
           vars[tsID][varID][levelID].nmiss = nmiss;
           if ( nmiss ) cdoAbort("Missing value support for operators in module Filter not added yet!");
@@ -262,11 +258,11 @@ void *Filter(void *argument)
   if ( use_fftw )
     {
 #if defined(HAVE_LIBFFTW3) 
-      ompmem = (memory_t*) malloc(ompNumThreads*sizeof(memory_t));
-      for ( i = 0; i < ompNumThreads; i++ )
+      ompmem = (memory_t*) Malloc(ompNumThreads*sizeof(memory_t));
+      for ( int i = 0; i < ompNumThreads; i++ )
 	{
-	  ompmem[i].in_fft  = (fftw_complex*) malloc(nts*sizeof(fftw_complex));
-	  ompmem[i].out_fft = (fftw_complex*) malloc(nts*sizeof(fftw_complex));
+	  ompmem[i].in_fft  = (fftw_complex*) Malloc(nts*sizeof(fftw_complex));
+	  ompmem[i].out_fft = (fftw_complex*) Malloc(nts*sizeof(fftw_complex));
 	  ompmem[i].p_T2S = fftw_plan_dft_1d(nts, ompmem[i].in_fft, ompmem[i].out_fft,  1, FFTW_ESTIMATE);
 	  ompmem[i].p_S2T = fftw_plan_dft_1d(nts, ompmem[i].out_fft, ompmem[i].in_fft, -1, FFTW_ESTIMATE);
 	}
@@ -274,15 +270,15 @@ void *Filter(void *argument)
     }
   else
     {
-      ompmem = (memory_t*) malloc(ompNumThreads*sizeof(memory_t));
-      for ( i = 0; i < ompNumThreads; i++ )
+      ompmem = (memory_t*) Malloc(ompNumThreads*sizeof(memory_t));
+      for ( int i = 0; i < ompNumThreads; i++ )
 	{
-	  ompmem[i].array1 = (double*) malloc(nts*sizeof(double));
-	  ompmem[i].array2 = (double*) malloc(nts*sizeof(double));
+	  ompmem[i].array1 = (double*) Malloc(nts*sizeof(double));
+	  ompmem[i].array2 = (double*) Malloc(nts*sizeof(double));
 	}
     }
 
-  int *fmasc = (int*) calloc(nts, sizeof(int));
+  int *fmasc = (int*) Calloc(nts, sizeof(int));
 
   switch(operfunc)
     {
@@ -328,9 +324,9 @@ void *Filter(void *argument)
             {
 #if defined(HAVE_LIBFFTW3) 
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(i, tsID)
+#pragma omp parallel for default(shared) private(tsID)
 #endif
-              for ( i = 0; i < gridsize; i++ )
+              for ( int i = 0; i < gridsize; i++ )
                 {
             	  int ompthID = cdo_omp_get_thread_num();
 
@@ -352,9 +348,9 @@ void *Filter(void *argument)
           else
             {
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(i, tsID)
+#pragma omp parallel for default(shared) private(tsID)
 #endif
-              for ( i = 0; i < gridsize; i++ )  
+              for ( int i = 0; i < gridsize; i++ )  
                 {
             	  int ompthID = cdo_omp_get_thread_num();
 
@@ -375,22 +371,22 @@ void *Filter(void *argument)
   if ( use_fftw )
     {
 #if defined(HAVE_LIBFFTW3) 
-      for ( i = 0; i < ompNumThreads; i++ )
+      for ( int i = 0; i < ompNumThreads; i++ )
 	{
-	  free(ompmem[i].in_fft);
-	  free(ompmem[i].out_fft);
+	  Free(ompmem[i].in_fft);
+	  Free(ompmem[i].out_fft);
 	}
-      free(ompmem);
+      Free(ompmem);
 #endif
     }
   else
     {
-      for ( i = 0; i < ompNumThreads; i++ )
+      for ( int i = 0; i < ompNumThreads; i++ )
 	{
-	  free(ompmem[i].array1);
-	  free(ompmem[i].array2);
+	  Free(ompmem[i].array1);
+	  Free(ompmem[i].array2);
 	}
-      free(ompmem);
+      Free(ompmem);
     }
 
   int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
@@ -413,7 +409,7 @@ void *Filter(void *argument)
                   streamDefRecord(streamID2, varID, levelID);
                   streamWriteRecord(streamID2, vars[tsID][varID][levelID].ptr, nmiss);
 
-                  free(vars[tsID][varID][levelID].ptr);
+                  Free(vars[tsID][varID][levelID].ptr);
                   vars[tsID][varID][levelID].ptr = NULL;
                 }
             }
@@ -422,7 +418,7 @@ void *Filter(void *argument)
       field_free(vars[tsID], vlistID1);
     }
 
-  if ( vars   ) free(vars);
+  if ( vars   ) Free(vars);
 
   dtlist_delete(dtlist);
 
@@ -431,5 +427,5 @@ void *Filter(void *argument)
 
   cdoFinish();
   
-  return (0);
+  return 0;
 }
diff --git a/src/Fldrms.c b/src/Fldrms.c
index bce8302..6a258c5 100644
--- a/src/Fldrms.c
+++ b/src/Fldrms.c
@@ -33,8 +33,6 @@ void *Fldrms(void *argument)
   int streamID1, streamID2, streamID3;
   int vlistID1, vlistID2, vlistID3;
   int gridID1, gridID2, gridID3, lastgrid = -1;
-  int wstatus = FALSE;
-  int code = 0, oldcode = 0;
   int index, ngrids;
   int recID, nrecs;
   int tsID, varID, levelID;
@@ -101,12 +99,12 @@ void *Fldrms(void *argument)
   field_init(&field3);
 
   lim = vlistGridsizeMax(vlistID1);
-  field1.ptr    = (double*) malloc(lim*sizeof(double));
+  field1.ptr    = (double*) Malloc(lim*sizeof(double));
   field1.weight = NULL;
   if ( needWeights )
-    field1.weight = (double*) malloc(lim*sizeof(double));
+    field1.weight = (double*) Malloc(lim*sizeof(double));
 
-  field2.ptr    = (double*) malloc(lim*sizeof(double));
+  field2.ptr    = (double*) Malloc(lim*sizeof(double));
   field2.weight = NULL;
 
   field3.ptr  = &sglval;
@@ -130,14 +128,22 @@ void *Fldrms(void *argument)
 
 	  field1.grid    = vlistInqVarGrid(vlistID1, varID);
 	  field2.grid    = vlistInqVarGrid(vlistID2, varID);
-	  if ( needWeights && field1.grid != lastgrid )
+
+          if ( needWeights && field1.grid != lastgrid )
 	    {
 	      lastgrid = field1.grid;
-	      wstatus = gridWeights(field1.grid, field1.weight);
+	      field1.weight[0] = 1;
+	      if ( field1.size > 1 )
+		{
+		  int wstatus = gridWeights(field1.grid, field1.weight);
+		  if ( wstatus != 0 && tsID == 0 && levelID == 0 )
+		    {
+		      char varname[CDI_MAX_NAME];
+		      vlistInqVarName(vlistID1, varID, varname);
+		      cdoWarning("Grid cell bounds not available, using constant grid cell area weights for variable %s!", varname);
+		    }
+		}
 	    }
-	  code = vlistInqVarCode(vlistID1, varID);
-	  if ( wstatus != 0 && tsID == 0 && code != oldcode )
-	    cdoWarning("Using constant area weights for code %d!", oldcode=code);
 
 	  field1.missval = vlistInqVarMissval(vlistID1, varID);
 	  field2.missval = vlistInqVarMissval(vlistID1, varID);
@@ -155,11 +161,11 @@ void *Fldrms(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( field1.ptr )    free(field1.ptr);
-  if ( field1.weight ) free(field1.weight);
-  if ( field2.ptr )    free(field2.ptr);
+  if ( field1.ptr )    Free(field1.ptr);
+  if ( field1.weight ) Free(field1.weight);
+  if ( field2.ptr )    Free(field2.ptr);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Fldstat.c b/src/Fldstat.c
index f8aa2e7..73f0659 100644
--- a/src/Fldstat.c
+++ b/src/Fldstat.c
@@ -24,9 +24,9 @@
       Fldstat    fldmean         Field mean
       Fldstat    fldavg          Field average
       Fldstat    fldstd          Field standard deviation
-      Fldstat    fldstd1         Field standard deviation
+      Fldstat    fldstd1         Field standard deviation [Divisor is (n-1)]
       Fldstat    fldvar          Field variance
-      Fldstat    fldvar1         Field variance
+      Fldstat    fldvar1         Field variance [Divisor is (n-1)]
       Fldstat    fldpctl         Field percentiles
 */
 
@@ -93,44 +93,39 @@ void *Fldstat(void *argument)
   int index;
   int recID, nrecs;
   int varID, levelID;
-  int needWeights = FALSE;
   int nmiss;
   double sglval;
   field_t field;
-  int pn = 0;
 
   cdoInitialize(argument);
 
   cdoOperatorAdd("fldmin",  func_min,  0, NULL);
   cdoOperatorAdd("fldmax",  func_max,  0, NULL);
   cdoOperatorAdd("fldsum",  func_sum,  0, NULL);
-  cdoOperatorAdd("fldmean", func_mean, 0, NULL);
-  cdoOperatorAdd("fldavg",  func_avg,  0, NULL);
-  cdoOperatorAdd("fldstd",  func_std,  0, NULL);
-  cdoOperatorAdd("fldstd1", func_std1, 0, NULL);
-  cdoOperatorAdd("fldvar",  func_var,  0, NULL);
-  cdoOperatorAdd("fldvar1", func_var1, 0, NULL);
+  cdoOperatorAdd("fldmean", func_mean, 1, NULL);
+  cdoOperatorAdd("fldavg",  func_avg,  1, NULL);
+  cdoOperatorAdd("fldstd",  func_std,  1, NULL);
+  cdoOperatorAdd("fldstd1", func_std1, 1, NULL);
+  cdoOperatorAdd("fldvar",  func_var,  1, NULL);
+  cdoOperatorAdd("fldvar1", func_var1, 1, NULL);
   cdoOperatorAdd("fldpctl", func_pctl, 0, NULL);
 
-  int operatorID = cdoOperatorID();
-  int operfunc = cdoOperatorF1(operatorID);
+  int operatorID  = cdoOperatorID();
+  int operfunc    = cdoOperatorF1(operatorID);
+  int needWeights = cdoOperatorF2(operatorID);
 
+  double pn = 0;
   if ( operfunc == func_pctl )
     {
       operatorInputArg("percentile number");
-      pn = parameter2int(operatorArgv()[0]);
-      
-      if ( pn < 1 || pn > 99 )
-        cdoAbort("Illegal argument: percentile number %d is not in the range 1..99!", pn);
+      pn = parameter2double(operatorArgv()[0]);
+      percentile_check_number(pn);
     }
 
   int useweights = TRUE;
 
-  if ( operfunc == func_mean || operfunc == func_avg ||
-       operfunc == func_var  || operfunc == func_std ||
-       operfunc == func_var1 || operfunc == func_std1 )
+  if ( needWeights )
     {
-      needWeights = TRUE;
       unsigned npar = operatorArgc();
       if ( npar > 0 )
 	{
@@ -183,11 +178,11 @@ void *Fldstat(void *argument)
   field_init(&field);
 
   int lim = vlistGridsizeMax(vlistID1);
-  field.ptr    = (double*) malloc(lim*sizeof(double));
+  field.ptr    = (double*) Malloc(lim*sizeof(double));
   field.weight = NULL;
   if ( needWeights )
     {
-      field.weight = (double*) malloc(lim*sizeof(double));
+      field.weight = (double*) Malloc(lim*sizeof(double));
       if ( !useweights )
 	{
 	  cdoPrint("Using constant grid cell area weights!");
@@ -226,7 +221,7 @@ void *Fldstat(void *argument)
 	      field.weight[0] = 1;
 	      if ( useweights && field.size > 1 )
 		{
-		  int wstatus = wstatus = gridWeights(field.grid, field.weight);
+		  int wstatus = gridWeights(field.grid, field.weight);
 		  if ( wstatus != 0 && tsID == 0 && levelID == 0 )
 		    {
 		      char varname[CDI_MAX_NAME];
@@ -263,10 +258,10 @@ void *Fldstat(void *argument)
 
   vlistDestroy(vlistID2);
 
-  if ( field.ptr )    free(field.ptr);
-  if ( field.weight ) free(field.weight);
+  if ( field.ptr )    Free(field.ptr);
+  if ( field.weight ) Free(field.weight);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Fldstat2.c b/src/Fldstat2.c
index 78f2afd..049015e 100644
--- a/src/Fldstat2.c
+++ b/src/Fldstat2.c
@@ -96,24 +96,16 @@ double covariance_s(const double * restrict in0, const double * restrict in1,
 
 void *Fldstat2(void *argument)
 {
-  int operatorID;
-  int operfunc;
-  int streamID1, streamID2, streamID3;
-  int vlistID1, vlistID2, vlistID3;
   int gridID, lastgridID = -1;
   int gridID3;
   int wstatus = FALSE;
-  int index, ngrids;
+  int index;
   int recID, nrecs, nrecs2;
-  int tsID, varID, levelID;
-  long gridsize;
+  int varID, levelID;
   int needWeights = TRUE;
   int nmiss1, nmiss2, nmiss3;
-  int taxisID1, taxisID3;
   double missval1, missval2;
-  double slon, slat;
-  double sglval;
-  double *array1, *array2, *weight;
+  double sglval = 0;
   char varname[CDI_MAX_NAME];
 
   cdoInitialize(argument);
@@ -121,48 +113,57 @@ void *Fldstat2(void *argument)
   cdoOperatorAdd("fldcor",   func_cor,   0, NULL);
   cdoOperatorAdd("fldcovar", func_covar, 0, NULL);
 
-  operatorID = cdoOperatorID();
-  operfunc = cdoOperatorF1(operatorID);
+  int operatorID = cdoOperatorID();
+  int operfunc = cdoOperatorF1(operatorID);
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
-  streamID2 = streamOpenRead(cdoStreamName(1));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID2 = streamOpenRead(cdoStreamName(1));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = streamInqVlist(streamID2);
-  vlistID3 = vlistDuplicate(vlistID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = streamInqVlist(streamID2);
+  int vlistID3 = vlistDuplicate(vlistID1);
 
   vlistCompare(vlistID1, vlistID2, CMP_ALL);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID3 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID3 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID3, taxisID3);
 
-  slon = 0;
-  slat = 0;
-  gridID3 = gridCreate(GRID_LONLAT, 1);
-  gridDefXsize(gridID3, 1);
-  gridDefYsize(gridID3, 1);
-  gridDefXvals(gridID3, &slon);
-  gridDefYvals(gridID3, &slat);
+  if ( CDO_Reduce_Dim )
+    {
+      gridID3 = gridCreate(GRID_GENERIC, 1);
+      gridDefXsize(gridID3, 0);
+      gridDefYsize(gridID3, 0);
+    }
+  else
+    {
+      double slon = 0;
+      double slat = 0;
+      gridID3 = gridCreate(GRID_LONLAT, 1);
+      gridDefXsize(gridID3, 1);
+      gridDefYsize(gridID3, 1);
+      gridDefXvals(gridID3, &slon);
+      gridDefYvals(gridID3, &slat);
+    }
 
-  ngrids = vlistNgrids(vlistID1);
+  int ngrids = vlistNgrids(vlistID1);
 
   for ( index = 0; index < ngrids; index++ )
     vlistChangeGridIndex(vlistID3, index, gridID3);
 
-  streamID3 = streamOpenWrite(cdoStreamName(2), cdoFiletype());
+  int streamID3 = streamOpenWrite(cdoStreamName(2), cdoFiletype());
 
   streamDefVlist(streamID3, vlistID3);
 
-  gridsize = vlistGridsizeMax(vlistID1);
+  int gridsize = vlistGridsizeMax(vlistID1);
 
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize*sizeof(double));
-  weight = NULL;
+  double *array1 = (double*) Malloc(gridsize*sizeof(double));
+  double *array2 = (double*) Malloc(gridsize*sizeof(double));
+  double *weight = NULL;
   if ( needWeights )
-    weight = (double*) malloc(gridsize*sizeof(double));
+    weight = (double*) Malloc(gridsize*sizeof(double));
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       nrecs2 = streamInqTimestep(streamID2, tsID);
@@ -224,11 +225,11 @@ void *Fldstat2(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array1 ) free(array1);
-  if ( array2 ) free(array2);
-  if ( weight ) free(weight);
+  if ( array1 ) Free(array1);
+  if ( array2 ) Free(array2);
+  if ( weight ) Free(weight);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Fourier.c b/src/Fourier.c
index c223529..cea048c 100644
--- a/src/Fourier.c
+++ b/src/Fourier.c
@@ -33,7 +33,6 @@ void *Fourier(void *argument)
   int nrecs;
   int gridID, varID, levelID, recID;
   int tsID;
-  int i;
   int nts;
   int nalloc = 0;
   int streamID1, streamID2;
@@ -79,9 +78,9 @@ void *Fourier(void *argument)
       if ( tsID >= nalloc )
 	{
 	  nalloc += NALLOC_INC;
-	  vdate = (int*) realloc(vdate, nalloc*sizeof(int));
-	  vtime = (int*) realloc(vtime, nalloc*sizeof(int));
-	  vars  = (field_t ***) realloc(vars, nalloc*sizeof(field_t **));
+	  vdate = (int*) Realloc(vdate, nalloc*sizeof(int));
+	  vtime = (int*) Realloc(vtime, nalloc*sizeof(int));
+	  vars  = (field_t ***) Realloc(vars, nalloc*sizeof(field_t **));
 	}
 
       vdate[tsID] = taxisInqVdate(taxisID1);
@@ -94,7 +93,7 @@ void *Fourier(void *argument)
 	  streamInqRecord(streamID1, &varID, &levelID);
 	  gridID   = vlistInqVarGrid(vlistID1, varID);
 	  gridsize = gridInqSize(gridID);
-	  vars[tsID][varID][levelID].ptr = (double*) malloc(2*gridsize*sizeof(double));
+	  vars[tsID][varID][levelID].ptr = (double*) Malloc(2*gridsize*sizeof(double));
 	  streamReadRecord(streamID1, vars[tsID][varID][levelID].ptr, &nmiss);
 	  vars[tsID][varID][levelID].nmiss = nmiss;
 	}
@@ -106,15 +105,15 @@ void *Fourier(void *argument)
 
   for ( bit = nts; !(bit & 1); bit >>= 1 );
 
-  ompmem = (memory_t*) malloc(ompNumThreads*sizeof(memory_t));
-  for ( i = 0; i < ompNumThreads; i++ )
+  ompmem = (memory_t*) Malloc(ompNumThreads*sizeof(memory_t));
+  for ( int i = 0; i < ompNumThreads; i++ )
     {
-      ompmem[i].real = (double*) malloc(nts*sizeof(double));
-      ompmem[i].imag = (double*) malloc(nts*sizeof(double));
+      ompmem[i].real = (double*) Malloc(nts*sizeof(double));
+      ompmem[i].imag = (double*) Malloc(nts*sizeof(double));
       if ( bit != 1 )
 	{
-	  ompmem[i].work_r = (double*) malloc(nts*sizeof(double));
-	  ompmem[i].work_i = (double*) malloc(nts*sizeof(double));
+	  ompmem[i].work_r = (double*) Malloc(nts*sizeof(double));
+	  ompmem[i].work_i = (double*) Malloc(nts*sizeof(double));
 	}
     }
 
@@ -127,9 +126,9 @@ void *Fourier(void *argument)
       for ( levelID = 0; levelID < nlevel; levelID++ )
 	{
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(i, tsID)
+#pragma omp parallel for default(shared) private(tsID)
 #endif
-	  for ( i = 0; i < gridsize; i++ )
+	  for ( int i = 0; i < gridsize; i++ )
 	    {
 	      int lmiss = 0;
               int ompthID = cdo_omp_get_thread_num();
@@ -167,17 +166,17 @@ void *Fourier(void *argument)
 	}
     }
 
-  for ( i = 0; i < ompNumThreads; i++ )
+  for ( int i = 0; i < ompNumThreads; i++ )
     {
-      free(ompmem[i].real);
-      free(ompmem[i].imag);
+      Free(ompmem[i].real);
+      Free(ompmem[i].imag);
       if ( bit != 1 )
 	{
-	  free(ompmem[i].work_r);
-	  free(ompmem[i].work_i);
+	  Free(ompmem[i].work_r);
+	  Free(ompmem[i].work_i);
 	}
     }
-  free(ompmem);
+  Free(ompmem);
 
   for ( tsID = 0; tsID < nts; tsID++ )
     {
@@ -195,7 +194,7 @@ void *Fourier(void *argument)
 		  nmiss = vars[tsID][varID][levelID].nmiss;
 		  streamDefRecord(streamID2, varID, levelID);
 		  streamWriteRecord(streamID2, vars[tsID][varID][levelID].ptr, nmiss);
-		  free(vars[tsID][varID][levelID].ptr);
+		  Free(vars[tsID][varID][levelID].ptr);
 		  vars[tsID][varID][levelID].ptr = NULL;
 		}
 	    }
@@ -204,9 +203,9 @@ void *Fourier(void *argument)
       field_free(vars[tsID], vlistID1);
     }
 
-  if ( vars  ) free(vars);
-  if ( vdate ) free(vdate);
-  if ( vtime ) free(vtime);
+  if ( vars  ) Free(vars);
+  if ( vdate ) Free(vdate);
+  if ( vtime ) Free(vtime);
 
   streamClose(streamID2);
   streamClose(streamID1);
diff --git a/src/Gengrid.c b/src/Gengrid.c
index ecd020a..e91478e 100644
--- a/src/Gengrid.c
+++ b/src/Gengrid.c
@@ -34,7 +34,6 @@ void *Gengrid(void *argument)
   int gridID1, gridID2, gridID3;
   int zaxisID3;
   int datatype;
-  int nrecs;
   int tsID, varID, levelID;
   int gridsize, i;
   int xsize, ysize;
@@ -62,13 +61,9 @@ void *Gengrid(void *argument)
   xsize = gridInqXsize(gridID1);
   ysize = gridInqYsize(gridID1);
 
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize*sizeof(double));
-  array3 = (double*) malloc(gridsize*sizeof(double));
-
-  tsID = 0;
-  nrecs = streamInqTimestep(streamID1, tsID);
-  nrecs = streamInqTimestep(streamID2, tsID);
+  array1 = (double*) Malloc(gridsize*sizeof(double));
+  array2 = (double*) Malloc(gridsize*sizeof(double));
+  array3 = (double*) Malloc(gridsize*sizeof(double));
 
   streamInqRecord(streamID1, &varID, &levelID);
   streamReadRecord(streamID1, array1, &nmiss1);
@@ -155,11 +150,11 @@ void *Gengrid(void *argument)
 
   streamClose(streamID3);
 
-  if ( array1 ) free(array1);
-  if ( array2 ) free(array2);
-  if ( array3 ) free(array3);
+  if ( array1 ) Free(array1);
+  if ( array2 ) Free(array2);
+  if ( array3 ) Free(array3);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Gradsdes.c b/src/Gradsdes.c
index 47ebaa2..2c2b06a 100644
--- a/src/Gradsdes.c
+++ b/src/Gradsdes.c
@@ -274,7 +274,7 @@ void dumpmap()
 
       if ( indx.hinum > 0 )
         {
-          indx.hipnt = (int*) malloc(sizeof(int)*indx.hinum);
+          indx.hipnt = (int*) Malloc(sizeof(int)*indx.hinum);
           for ( i = 0; i < indx.hinum; i++ )
             {
               nbytes = fread(mrec, sizeof(unsigned char), 4, mapfp);
@@ -283,12 +283,12 @@ void dumpmap()
         }
       if ( indx.hfnum > 0 )
         {
-          indx.hfpnt = (float*) malloc(sizeof(float)*indx.hfnum);
+          indx.hfpnt = (float*) Malloc(sizeof(float)*indx.hfnum);
           nbytes = fread (indx.hfpnt,sizeof(float),indx.hfnum,mapfp);
         }
       if ( indx.intnum > 0 )
         {
-          indx.intpnt = (int*) malloc(sizeof(int)*indx.intnum);
+          indx.intpnt = (int*) Malloc(sizeof(int)*indx.intnum);
           for ( i = 0; i < indx.intnum; i++ )
             {
               nbytes = fread(mrec, sizeof(unsigned char), 4, mapfp);
@@ -298,7 +298,7 @@ void dumpmap()
         }
       if ( indx.fltnum > 0 )
         {
-          indx.fltpnt = (float*) malloc(sizeof(float)*indx.fltnum);
+          indx.fltpnt = (float*) Malloc(sizeof(float)*indx.fltnum);
           for ( i = 0; i < indx.fltnum; i++ )
             {
               nbytes = fread(urec, sizeof(unsigned char), 4, mapfp);
@@ -317,26 +317,26 @@ void dumpmap()
 
       if ( indx.hinum > 0 )
         {
-          indx.hipnt = (int*) malloc(sizeof(int)*indx.hinum);
+          indx.hipnt = (int*) Malloc(sizeof(int)*indx.hinum);
           nbytes = fread (indx.hipnt, sizeof(int), indx.hinum, mapfp);
           if ( swpflg ) gabswp((float *)(indx.hipnt),indx.hinum);
         }
       if ( indx.hfnum > 0 )
         {
-          indx.hfpnt = (float*) malloc(sizeof(float)*indx.hfnum);
+          indx.hfpnt = (float*) Malloc(sizeof(float)*indx.hfnum);
           nbytes = fread (indx.hfpnt,sizeof(float),indx.hfnum,mapfp);
           if ( swpflg ) gabswp(indx.hfpnt,indx.hfnum);
         }
 
       if ( indx.intnum > 0 )
         {
-          indx.intpnt = (int*) malloc(sizeof(int)*indx.intnum);
+          indx.intpnt = (int*) Malloc(sizeof(int)*indx.intnum);
           nbytes = fread (indx.intpnt,sizeof(int),indx.intnum,mapfp);
           if ( swpflg ) gabswp((float *)(indx.intpnt),indx.intnum);
         }
       if ( indx.fltnum > 0 )
         {
-          indx.fltpnt = (float*) malloc(sizeof(float)*indx.fltnum);
+          indx.fltpnt = (float*) Malloc(sizeof(float)*indx.fltnum);
           nbytes = fread (indx.fltpnt,sizeof(float),indx.fltnum,mapfp);
           if ( swpflg ) gabswp(indx.fltpnt,indx.fltnum);
         }
@@ -346,7 +346,7 @@ void dumpmap()
           indxb.bignum = indx.hipnt[4];
           if ( indxb.bignum > 0 )
             {
-              indxb.bigpnt = (off_t*) malloc(sizeof(off_t)*indxb.bignum);
+              indxb.bigpnt = (off_t*) Malloc(sizeof(off_t)*indxb.bignum);
               nbytes = fread (indxb.bigpnt,sizeof(off_t),indxb.bignum,mapfp);
               if ( swpflg ) gabswp(indxb.bigpnt,indxb.bignum);
             }
@@ -437,8 +437,8 @@ void ctl_xydef(FILE *gdp, int gridID, int *yrev)
               xsize, ysize, originLat, originLon, lat1, lat2, lonParY, xincm, yincm);
 
       gridID = gridToCurvilinear(gridID, 0);
-      xvals = (double*) malloc(xsize*ysize*sizeof(double));
-      yvals = (double*) malloc(xsize*ysize*sizeof(double));
+      xvals = (double*) Malloc(xsize*ysize*sizeof(double));
+      yvals = (double*) Malloc(xsize*ysize*sizeof(double));
       gridInqXvals(gridID, xvals);
       gridInqYvals(gridID, yvals);
       for ( i = 0; i < xsize*ysize; ++i )
@@ -449,8 +449,8 @@ void ctl_xydef(FILE *gdp, int gridID, int *yrev)
           if ( yvals[i] < ymin ) ymin = yvals[i];
           if ( yvals[i] > ymax ) ymax = yvals[i];
         }
-      free(xvals);
-      free(yvals);
+      Free(xvals);
+      Free(yvals);
 
       xfirst = ((int)(xmin-0.0));
       yfirst = ((int)(ymin-0.0));
@@ -479,7 +479,7 @@ void ctl_xydef(FILE *gdp, int gridID, int *yrev)
       xinc   = gridInqXinc(gridID);
       if ( IS_EQUAL(xinc, 0) && gridInqXvals(gridID, NULL) )
         {
-          xvals = (double*) malloc(xsize*sizeof(double));
+          xvals = (double*) Malloc(xsize*sizeof(double));
           gridInqXvals(gridID, xvals);
           fprintf(gdp ,"XDEF %d LEVELS ", xsize);
           j = 0;
@@ -496,7 +496,7 @@ void ctl_xydef(FILE *gdp, int gridID, int *yrev)
             }
           if ( j ) fprintf(gdp, "\n");
 
-          free(xvals);
+          Free(xvals);
         }
       else
         {
@@ -515,7 +515,7 @@ void ctl_xydef(FILE *gdp, int gridID, int *yrev)
 
       if ( IS_EQUAL(yinc, 0) && gridInqYvals(gridID, NULL) )
         {
-          yvals = (double*) malloc(ysize*sizeof(double));
+          yvals = (double*) Malloc(ysize*sizeof(double));
           gridInqYvals(gridID, yvals);
           fprintf(gdp ,"YDEF %d LEVELS ", ysize);
           j = 0;
@@ -551,7 +551,7 @@ void ctl_xydef(FILE *gdp, int gridID, int *yrev)
 
           if ( j ) fprintf(gdp, "\n");
 
-          free(yvals);
+          Free(yvals);
         }
       else
         {
@@ -591,7 +591,7 @@ void ctl_zdef(FILE *gdp, int vlistID, int *zrev)
         }
     }
 
-  levels = (double*) malloc(nlevmax*sizeof(double));
+  levels = (double*) Malloc(nlevmax*sizeof(double));
   zaxisInqLevels(zaxisIDmax, levels);
   if ( zaxisInqType(zaxisIDmax) == ZAXIS_PRESSURE ) lplev = TRUE;
   level0 = levels[0];
@@ -655,7 +655,7 @@ void ctl_zdef(FILE *gdp, int vlistID, int *zrev)
       if ( j ) fprintf(gdp, "\n");
     }
 
-  free(levels);
+  Free(levels);
 }
 
 static
@@ -851,7 +851,7 @@ void write_map_grib1(const char *ctlfile, int map_version, int nrecords, int *in
       nb += 7;      /* base time (+ sec)  for compatibility with earlier version 2 maps */
       nb += 8*4;    /* grvals for time <-> grid conversion */
 
-      map = (unsigned char*) malloc(nb);
+      map = (unsigned char*) Malloc(nb);
 
       bcnt = 0;
       Put1Byte(map, bcnt, 0);
@@ -904,7 +904,7 @@ void write_map_grib1(const char *ctlfile, int map_version, int nrecords, int *in
 
       fwrite(map, 1, bcnt, mapfp);
 
-      free(map);
+      Free(map);
     }
   else
     {
@@ -913,7 +913,7 @@ void write_map_grib1(const char *ctlfile, int map_version, int nrecords, int *in
       if ( map_version == 1 )
         {
           int *intnumbuf;
-          intnumbuf = (int*) malloc(indx.intnum*sizeof(int));
+          intnumbuf = (int*) Malloc(indx.intnum*sizeof(int));
           for ( i = 0; i < nrecords; i++ )
             {
               intnumbuf[i*3+0] = (int) bignum[i*2];
@@ -921,7 +921,7 @@ void write_map_grib1(const char *ctlfile, int map_version, int nrecords, int *in
               intnumbuf[i*3+2] = intnum[i];
             }
           if ( indx.intnum > 0 ) fwrite(intnumbuf, sizeof(int), indx.intnum, mapfp);
-          free(intnumbuf);
+          Free(intnumbuf);
           if ( indx.fltnum > 0 ) fwrite(fltnum, sizeof(float), indx.fltnum, mapfp);
         }
       else
@@ -961,7 +961,8 @@ void *Gradsdes(void *argument)
   int flt64 = 0;
   int cal365day = 0;
   int sequential = FALSE;
-  char Time[30], Incr[10] = {"1mn"}, *IncrKey[] = {"mn","hr","dy","mo","yr"};
+  char Time[30], Incr[10] = {"1mn"};
+  const char *IncrKey[] = {"mn","hr","dy","mo","yr"};
   int isd, imn, ihh, iyy, imm, idd;
   int isds = 0, imns = 0, ihhs = 0, iyys = 0, imms = 0, idds = 0;
   int imn0 = 0, ihh0 = 0, iyy0 = 0, imm0 = 0, idd0 = 0;
@@ -991,7 +992,7 @@ void *Gradsdes(void *argument)
 
   const char *datfile = cdoStreamName(0)->args;
   size_t len = strlen(datfile);
-  char *ctlfile = (char *) malloc(len+10);
+  char *ctlfile = (char *) Malloc(len+10);
   strcpy(ctlfile, datfile);
 
   if ( cdoStreamName(0)->args[0] == '-' )
@@ -1000,7 +1001,8 @@ void *Gradsdes(void *argument)
   if ( operatorID == DUMPMAP )
     {
       dumpmap();
-      goto END_LABEL;
+      cdoFinish();
+      return 0;
     }
 
   if ( operatorArgc() > 1 ) cdoAbort("Too many arguments!");
@@ -1013,7 +1015,7 @@ void *Gradsdes(void *argument)
     }
   else
     {
-      if ( filesize(cdoStreamName(0)->args) > 2147483647L ) map_version = 4;
+      if ( fileSize(cdoStreamName(0)->args) > 2147483647L ) map_version = 4;
     }
 
   if ( cdoVerbose ) cdoPrint("GrADS GRIB map version: %d", map_version);
@@ -1064,8 +1066,8 @@ void *Gradsdes(void *argument)
     cdoAbort("No Lon/Lat, Gaussian or Lambert grid found (%s data unsupported)!", gridNamePtr(gridtype));
 
   /* select all variables with used gridID */
-  int *vars = (int*) malloc(nvars*sizeof(int));
-  int *recoffset = (int*) malloc(nvars*sizeof(int));
+  int *vars = (int*) Malloc(nvars*sizeof(int));
+  int *recoffset = (int*) Malloc(nvars*sizeof(int));
   int nvarsout = 0;
   int nrecsout = 0;
   for ( varID = 0; varID < nvars; varID++ )
@@ -1187,7 +1189,7 @@ void *Gradsdes(void *argument)
         }
 
       gridsize = vlistGridsizeMax(vlistID);
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
     }
   else if ( filetype == FILETYPE_NC )
     {
@@ -1303,9 +1305,9 @@ void *Gradsdes(void *argument)
           if ( nrecords >= maxrecs )
             {
               maxrecs = nrecords;
-              intnum = (int*) realloc(intnum, 1*maxrecs*sizeof(int));
-              fltnum = (float*) realloc(fltnum, 3*maxrecs*sizeof(float));
-              bignum = (off_t*) realloc(bignum, 2*maxrecs*sizeof(off_t));
+              intnum = (int*) Realloc(intnum, 1*maxrecs*sizeof(int));
+              fltnum = (float*) Realloc(fltnum, 3*maxrecs*sizeof(float));
+              bignum = (off_t*) Realloc(bignum, 2*maxrecs*sizeof(off_t));
             }
 
           for ( recID = 0; recID < nrecs; recID++ )
@@ -1400,18 +1402,18 @@ void *Gradsdes(void *argument)
 
   streamClose(streamID);
 
-  if ( ctlfile ) free(ctlfile);
-  if ( idxfile ) free(idxfile);
+  if ( ctlfile ) Free(ctlfile);
+  if ( idxfile ) Free(idxfile);
 
-  if ( vars ) free(vars);
-  if ( recoffset ) free(recoffset);
-  if ( array ) free(array);
-  if ( intnum ) free(intnum);
-  if ( fltnum ) free(fltnum);
+  if ( vars ) Free(vars);
+  if ( recoffset ) Free(recoffset);
+  if ( array ) Free(array);
+  if ( intnum ) Free(intnum);
+  if ( fltnum ) Free(fltnum);
 
  END_LABEL:
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Gridboxstat.c b/src/Gridboxstat.c
index ccc4e97..248d2bf 100644
--- a/src/Gridboxstat.c
+++ b/src/Gridboxstat.c
@@ -24,7 +24,9 @@
       Gridboxstat    gridboxmean         Gridbox mean
       Gridboxstat    gridboxavg          Gridbox average
       Gridboxstat    gridboxstd          Gridbox standard deviation
+      Gridboxstat    gridboxstd1         Gridbox standard deviation [Divisor is (n-1)]
       Gridboxstat    gridboxvar          Gridbox variance
+      Gridboxstat    gridboxvar1         Gridbox variance [Divisor is (n-1)]
 */
 
 
@@ -91,19 +93,19 @@ int genBoxGrid(int gridID1, int xinc, int yinc)
       if ( gridInqXbounds(gridID1, NULL) && gridInqYbounds(gridID1, NULL) )
         gridHasBounds = TRUE;
 
-      xvals1 = (double*) malloc(nlon1*sizeof(double));
-      yvals1 = (double*) malloc(nlat1*sizeof(double));
-      xvals2 = (double*) malloc(nlon2*sizeof(double));
-      yvals2 = (double*) malloc(nlat2*sizeof(double));
+      xvals1 = (double*) Malloc(nlon1*sizeof(double));
+      yvals1 = (double*) Malloc(nlat1*sizeof(double));
+      xvals2 = (double*) Malloc(nlon2*sizeof(double));
+      yvals2 = (double*) Malloc(nlat2*sizeof(double));
       gridInqXvals(gridID1, xvals1);
       gridInqYvals(gridID1, yvals1);
 
       if ( gridHasBounds )
         {
-          grid1_corner_lon = (double*) malloc(2*nlon1*sizeof(double));
-          grid1_corner_lat = (double*) malloc(2*nlat1*sizeof(double));
-          grid2_corner_lon = (double*) malloc(2*nlon2*sizeof(double));
-          grid2_corner_lat = (double*) malloc(2*nlat2*sizeof(double));
+          grid1_corner_lon = (double*) Malloc(2*nlon1*sizeof(double));
+          grid1_corner_lat = (double*) Malloc(2*nlat1*sizeof(double));
+          grid2_corner_lon = (double*) Malloc(2*nlon2*sizeof(double));
+          grid2_corner_lat = (double*) Malloc(2*nlat2*sizeof(double));
           gridInqXbounds(gridID1, grid1_corner_lon);
           gridInqYbounds(gridID1, grid1_corner_lat);
         }
@@ -138,22 +140,22 @@ int genBoxGrid(int gridID1, int xinc, int yinc)
       gridDefXvals(gridID2, xvals2);
       gridDefYvals(gridID2, yvals2);
 
-      free(xvals2);
-      free(yvals2);
+      Free(xvals2);
+      Free(yvals2);
 
-      free(xvals1);
-      free(yvals1);
+      Free(xvals1);
+      Free(yvals1);
       
       if ( gridHasBounds )
         {
           gridDefNvertex(gridID2, 2);
           gridDefXbounds(gridID2, grid2_corner_lon);
           gridDefYbounds(gridID2, grid2_corner_lat);
-          free(grid2_corner_lon);
-          free(grid2_corner_lat);
+          Free(grid2_corner_lon);
+          Free(grid2_corner_lat);
 
-          free(grid1_corner_lon);
-          free(grid1_corner_lat);
+          Free(grid1_corner_lon);
+          Free(grid1_corner_lat);
         }
     } /* if ( gridtype == GRID_GAUSSIAN || gridtype == GRID_LONLAT ) */
   else if ( gridtype == GRID_GENERIC )
@@ -165,10 +167,10 @@ int genBoxGrid(int gridID1, int xinc, int yinc)
       if ( gridInqXbounds(gridID1, NULL) && gridInqYbounds(gridID1, NULL) )
         gridHasBounds = TRUE;
       
-      xvals1 = (double*) malloc(nlon1*nlat1*sizeof(double));
-      yvals1 = (double*) malloc(nlon1*nlat1*sizeof(double));
-      xvals2 = (double*) malloc(nlon2*nlat2*sizeof(double));
-      yvals2 = (double*) malloc(nlon2*nlat2*sizeof(double));
+      xvals1 = (double*) Malloc(nlon1*nlat1*sizeof(double));
+      yvals1 = (double*) Malloc(nlon1*nlat1*sizeof(double));
+      xvals2 = (double*) Malloc(nlon2*nlat2*sizeof(double));
+      yvals2 = (double*) Malloc(nlon2*nlat2*sizeof(double));
       gridInqXvals(gridID1, xvals1);
       gridInqYvals(gridID1, yvals1);
 
@@ -183,10 +185,10 @@ int genBoxGrid(int gridID1, int xinc, int yinc)
       
       if ( gridHasBounds )
         {
-          grid1_corner_lon = (double*) malloc(4*nlon1*nlat1*sizeof(double));
-          grid1_corner_lat = (double*) malloc(4*nlon1*nlat1*sizeof(double));
-          grid2_corner_lon = (double*) malloc(4*nlon2*nlat2*sizeof(double));
-          grid2_corner_lat = (double*) malloc(4*nlon2*nlat2*sizeof(double));
+          grid1_corner_lon = (double*) Malloc(4*nlon1*nlat1*sizeof(double));
+          grid1_corner_lat = (double*) Malloc(4*nlon1*nlat1*sizeof(double));
+          grid2_corner_lon = (double*) Malloc(4*nlon2*nlat2*sizeof(double));
+          grid2_corner_lat = (double*) Malloc(4*nlon2*nlat2*sizeof(double));
           gridInqXbounds(gridID1, grid1_corner_lon);
           gridInqYbounds(gridID1, grid1_corner_lat);
 
@@ -420,11 +422,11 @@ int genBoxGrid(int gridID1, int xinc, int yinc)
       gridDefXvals(gridID2, xvals2);
       gridDefYvals(gridID2, yvals2);
 
-      free(xvals2);
-      free(yvals2);
+      Free(xvals2);
+      Free(yvals2);
 
-      free(xvals1);
-      free(yvals1);
+      Free(xvals1);
+      Free(yvals1);
 
       if ( gridHasBounds )
         {
@@ -432,11 +434,11 @@ int genBoxGrid(int gridID1, int xinc, int yinc)
           gridDefXbounds(gridID2, grid2_corner_lon);
           gridDefYbounds(gridID2, grid2_corner_lat);
           
-          free(grid2_corner_lon);
-          free(grid2_corner_lat);
+          Free(grid2_corner_lon);
+          Free(grid2_corner_lat);
           
-          free(grid1_corner_lon);
-          free(grid1_corner_lat);
+          Free(grid1_corner_lon);
+          Free(grid1_corner_lat);
         }
     } /* else if ( gridtype == GRID_CURVILINEAR ) */
   else
@@ -457,7 +459,7 @@ void gridboxstat(field_t *field1, field_t *field2, int xinc, int yinc, int statf
   int nmiss;
   double *array1, *array2;
   double missval;
-  long ig, i, j, ii, jj, index;
+  long i, j, ii, jj, index;
   long gridsize;
   field_t *field;
   int isize;
@@ -469,15 +471,15 @@ void gridboxstat(field_t *field1, field_t *field2, int xinc, int yinc, int statf
   */
   if ( field1->weight ) useWeight = TRUE;
 
-  gridsize      = xinc*yinc;
-  field = (field_t*) malloc(ompNumThreads*sizeof(field_t));
+  gridsize = xinc*yinc;
+  field = (field_t*) Malloc(ompNumThreads*sizeof(field_t));
   for ( i = 0; i < ompNumThreads; i++ )
     {
       field[i].size    = gridsize;
-      field[i].ptr     = (double*) malloc(gridsize*sizeof(double));
+      field[i].ptr     = (double*) Malloc(gridsize*sizeof(double));
       field[i].weight  = NULL;
       if ( useWeight )
-	field[i].weight  = (double*) malloc(gridsize*sizeof(double));
+	field[i].weight  = (double*) Malloc(gridsize*sizeof(double));
       field[i].missval = field1->missval;
       field[i].nmiss   = 0;
     }
@@ -495,9 +497,9 @@ void gridboxstat(field_t *field1, field_t *field2, int xinc, int yinc, int statf
   nlat2 = gridInqYsize(gridID2);
 
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(ig, ilat, ilon, j, jj, i, ii, index, isize)
+#pragma omp parallel for default(shared) private(ilat, ilon, j, jj, i, ii, index, isize)
 #endif
-  for ( ig = 0; ig < nlat2*nlon2; ++ig )
+  for ( long ig = 0; ig < nlat2*nlon2; ++ig )
     {
       int ompthID = cdo_omp_get_thread_num();
 
@@ -545,39 +547,30 @@ void gridboxstat(field_t *field1, field_t *field2, int xinc, int yinc, int statf
   
   for ( i = 0; i < ompNumThreads; i++ )
     {
-      if ( field[i].ptr    ) free(field[i].ptr);
-      if ( field[i].weight ) free(field[i].weight);
+      if ( field[i].ptr    ) Free(field[i].ptr);
+      if ( field[i].weight ) Free(field[i].weight);
     }
 
-  if ( field ) free(field);
+  if ( field ) Free(field);
 }
 
 
 void *Gridboxstat(void *argument)
 {
-  int operatorID;
-  int operfunc;
-  int streamID1, streamID2;
-  int vlistID1, vlistID2;
   int lastgrid = -1;
   int wstatus = FALSE;
-  int index, ngrids;
+  int index;
   int recID, nrecs;
-  int tsID, varID, levelID;
+  int varID, levelID;
   int needWeights = FALSE;
-  int gridID1, gridID2;
-  int gridsize1, gridsize2;
-  int taxisID1, taxisID2;
-  int xinc, yinc;
-  field_t field1, field2;
   char varname[CDI_MAX_NAME];
 
   cdoInitialize(argument);
 
   operatorInputArg("xinc, yinc");
   operatorCheckArgc(2);
-  xinc = parameter2int(operatorArgv()[0]);
-  yinc = parameter2int(operatorArgv()[1]);
+  int xinc = parameter2int(operatorArgv()[0]);
+  int yinc = parameter2int(operatorArgv()[1]);
 
   cdoOperatorAdd("gridboxmin",  func_min,  0, NULL);
   cdoOperatorAdd("gridboxmax",  func_max,  0, NULL);
@@ -585,53 +578,57 @@ void *Gridboxstat(void *argument)
   cdoOperatorAdd("gridboxmean", func_mean, 0, NULL);
   cdoOperatorAdd("gridboxavg",  func_avg,  0, NULL);
   cdoOperatorAdd("gridboxvar",  func_var,  0, NULL);
+  cdoOperatorAdd("gridboxvar1", func_var1, 0, NULL);
   cdoOperatorAdd("gridboxstd",  func_std,  0, NULL);
+  cdoOperatorAdd("gridboxstd1", func_std1, 0, NULL);
 
-  operatorID = cdoOperatorID();
-  operfunc = cdoOperatorF1(operatorID);
+  int operatorID = cdoOperatorID();
+  int operfunc = cdoOperatorF1(operatorID);
 
   if ( operfunc == func_mean || operfunc == func_avg ||
-       operfunc == func_var  || operfunc == func_std )
+       operfunc == func_var  || operfunc == func_std ||
+       operfunc == func_var1 || operfunc == func_std1 )
     needWeights = TRUE;
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = vlistDuplicate(vlistID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  ngrids = vlistNgrids(vlistID1);
+  int ngrids = vlistNgrids(vlistID1);
   if ( ngrids > 1 )  cdoAbort("Too many different grids!");
 
-  gridID1 = vlistGrid(vlistID1, 0);
+  int gridID1 = vlistGrid(vlistID1, 0);
   if ( gridInqType(gridID1) == GRID_GAUSSIAN_REDUCED )
     cdoAbort("Gaussian reduced grid found. Use option -R to convert it to a regular grid!");
 
-  gridID2 = genBoxGrid(gridID1, xinc, yinc);
+  int gridID2 = genBoxGrid(gridID1, xinc, yinc);
   for ( index = 0; index < ngrids; index++ )
     vlistChangeGridIndex(vlistID2, index, gridID2);
 
-  streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
+  field_t field1, field2;
   field_init(&field1);
   field_init(&field2);
 
-  gridsize1 = gridInqSize(gridID1);
-  field1.ptr    = (double*) malloc(gridsize1*sizeof(double));
+  int gridsize1 = gridInqSize(gridID1);
+  field1.ptr    = (double*) Malloc(gridsize1*sizeof(double));
   field1.weight = NULL;
   if ( needWeights )
-    field1.weight = (double*) malloc(gridsize1*sizeof(double));
+    field1.weight = (double*) Malloc(gridsize1*sizeof(double));
 
-  gridsize2 = gridInqSize(gridID2);
-  field2.ptr    = (double*) malloc(gridsize2*sizeof(double));
+  int gridsize2 = gridInqSize(gridID2);
+  field2.ptr    = (double*) Malloc(gridsize2*sizeof(double));
   field2.weight = NULL;
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       taxisCopyTimestep(taxisID2, taxisID1);
@@ -673,13 +670,13 @@ void *Gridboxstat(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
   
-  if ( field1.ptr )    free(field1.ptr);
-  if ( field1.weight ) free(field1.weight);
+  if ( field1.ptr )    Free(field1.ptr);
+  if ( field1.weight ) Free(field1.weight);
   
-  if ( field2.ptr )    free(field2.ptr);
-  if ( field2.weight ) free(field2.weight);
+  if ( field2.ptr )    Free(field2.ptr);
+  if ( field2.weight ) Free(field2.weight);
   
   cdoFinish();
   
-  return (0);
+  return 0;
 }
diff --git a/src/Gridcell.c b/src/Gridcell.c
index 8a6acfb..c0d4ec7 100644
--- a/src/Gridcell.c
+++ b/src/Gridcell.c
@@ -130,7 +130,7 @@ void *Gridcell(void *argument)
 
 
   gridsize = gridInqSize(gridID);
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
 
   if ( operatorID == GRIDAREA )
@@ -178,7 +178,7 @@ void *Gridcell(void *argument)
   else if ( operatorID == GRIDMASK )
     {
       int *mask;
-      mask = (int*) malloc(gridsize*sizeof(int));
+      mask = (int*) Malloc(gridsize*sizeof(int));
       if ( gridInqMask(gridID, NULL) )
 	{
 	  gridInqMask(gridID, mask);
@@ -189,7 +189,7 @@ void *Gridcell(void *argument)
 	}
 
       for ( i = 0; i < gridsize; ++i ) array[i] = mask[i];
-      free(mask);
+      Free(mask);
     }
   else if ( operatorID == GRIDDX || operatorID == GRIDDY )
     {
@@ -211,8 +211,8 @@ void *Gridcell(void *argument)
 	  xsize = gridInqXsize(gridID);
 	  ysize = gridInqYsize(gridID);
 
-	  xv = (double*) malloc(gridsize*sizeof(double));
-	  yv = (double*) malloc(gridsize*sizeof(double));
+	  xv = (double*) Malloc(gridsize*sizeof(double));
+	  yv = (double*) Malloc(gridsize*sizeof(double));
 
 	  gridInqXvals(gridID, xv);
 	  gridInqYvals(gridID, yv);
@@ -273,8 +273,8 @@ void *Gridcell(void *argument)
 		  }
 	    }
 
-	  free(xv);
-	  free(yv);
+	  Free(xv);
+	  Free(yv);
 	}
       else
 	{
@@ -302,9 +302,9 @@ void *Gridcell(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Gridsearch.c b/src/Gridsearch.c
index d7adfd0..9be79af 100644
--- a/src/Gridsearch.c
+++ b/src/Gridsearch.c
@@ -38,5 +38,5 @@ void *Gridsearch(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Harmonic.c b/src/Harmonic.c
index 4c2936a..af39598 100644
--- a/src/Harmonic.c
+++ b/src/Harmonic.c
@@ -80,7 +80,7 @@ void *Harmonic(void *argument)
   filesuffix[0] = 0;
   cdoGenFileSuffix(filesuffix, sizeof(filesuffix), streamInqFiletype(streamID1), vlistID1, refname);
 
-  streamIDs = (int*) malloc(n_out*sizeof(int));
+  streamIDs = (int*) Malloc(n_out*sizeof(int));
 
   strcpy(filename, cdoStreamName(1)->args);
   nchars = strlen(filename);
@@ -102,35 +102,35 @@ void *Harmonic(void *argument)
 
   nvars = vlistNvars(vlistID1);
 
-  out  = (double ***) malloc(n_out*sizeof(double **));
-  work = (double ***) malloc(2*n_out*sizeof(double **));
+  out  = (double ***) Malloc(n_out*sizeof(double **));
+  work = (double ***) Malloc(2*n_out*sizeof(double **));
 
   for ( j = 0; j < n_out; ++j )
     {
-      out[j] = (double **) malloc(nvars*sizeof(double *));
+      out[j] = (double **) Malloc(nvars*sizeof(double *));
       for ( varID = 0; varID < nvars; ++varID )
 	{
 	  gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
 	  nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
-	  out[j][varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
+	  out[j][varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
 	}
     }
 
   for ( j = 0; j < n_out*2; ++j )
     {
-      work[j] = (double **) malloc(nvars*sizeof(double *));
+      work[j] = (double **) Malloc(nvars*sizeof(double *));
       for ( varID = 0; varID < nvars; ++varID )
 	{
 	  gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
 	  nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
-	  work[j][varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
+	  work[j][varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
 	  memset(work[j][varID], 0, gridsize*nlevel*sizeof(double));
 	}
     }
 
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -145,7 +145,6 @@ void *Harmonic(void *argument)
 	{
 	  streamInqRecord(streamID1, &varID, &levelID);
 	  gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
-	  nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	  offset   = gridsize*levelID;
 
 	  streamReadRecord(streamID1, array, &nmiss);
@@ -169,7 +168,7 @@ void *Harmonic(void *argument)
 
   nts = tsID;
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   streamClose(streamID1);
 
@@ -289,29 +288,29 @@ void *Harmonic(void *argument)
       streamClose(streamID2);
     }
 
-  free(streamIDs);
+  Free(streamIDs);
 
   for ( j = 0; j < n_out; ++j )
     {
       for ( varID = 0; varID < nvars; ++varID )
-	free(out[j][varID]);
+        Free(out[j][varID]);
 
-      free(out[j]);
+      Free(out[j]);
     }
 
-  free(out);
+  Free(out);
 
   for ( j = 0; j < n_out*2; ++j )
     {
       for ( varID = 0; varID < nvars; ++varID )
-	free(work[j][varID]);
+        Free(work[j][varID]);
 
-      free(work[j]);
+      Free(work[j]);
     }
 
-  free(work);
+  Free(work);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Hi.c b/src/Hi.c
index 3446b92..f2d515a 100755
--- a/src/Hi.c
+++ b/src/Hi.c
@@ -97,7 +97,7 @@ void *Hi(void *argument)
   int varID1, varID2, varID3, varID4;
   int levelID1, levelID2, levelID3;
   int vlistID1, vlistID2, vlistID3, vlistID4;
-  int taxisID1, taxisID2, taxisID3, taxisID4;
+  int taxisID1, /*taxisID2, taxisID3,*/ taxisID4;
   field_t field1, field2, field3;
 
   cdoInitialize(argument);
@@ -112,8 +112,8 @@ void *Hi(void *argument)
   vlistID3 = streamInqVlist(streamID3);
 
   taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = vlistInqTaxis(vlistID2);
-  taxisID3 = vlistInqTaxis(vlistID3);
+  //taxisID2 = vlistInqTaxis(vlistID2);
+  //taxisID3 = vlistInqTaxis(vlistID3);
 
   vlistCompare(vlistID1, vlistID2, CMP_DIM);
   vlistCompare(vlistID1, vlistID3, CMP_DIM);
@@ -123,9 +123,9 @@ void *Hi(void *argument)
   field_init(&field1);
   field_init(&field2);
   field_init(&field3);
-  field1.ptr = (double*) malloc(gridsize*sizeof(double));
-  field2.ptr = (double*) malloc(gridsize*sizeof(double));
-  field3.ptr = (double*) malloc(gridsize*sizeof(double));
+  field1.ptr = (double*) Malloc(gridsize*sizeof(double));
+  field2.ptr = (double*) Malloc(gridsize*sizeof(double));
+  field3.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   if ( cdoVerbose )
     cdoPrint("Number of timesteps: file1 %d, file2 %d, file3 %d",
@@ -201,11 +201,11 @@ void *Hi(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( field1.ptr ) free(field1.ptr);
-  if ( field2.ptr ) free(field2.ptr);
-  if ( field3.ptr ) free(field3.ptr);
+  if ( field1.ptr ) Free(field1.ptr);
+  if ( field2.ptr ) Free(field2.ptr);
+  if ( field3.ptr ) Free(field3.ptr);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Histogram.c b/src/Histogram.c
index a32ff74..5f1eb95 100644
--- a/src/Histogram.c
+++ b/src/Histogram.c
@@ -84,11 +84,11 @@ void *Histogram(void *argument)
 
   /* create zaxis for output bins */
   zaxisID2 = zaxisCreate(ZAXIS_GENERIC, nbins);
-  bins = (double*) malloc(nbins*sizeof(double));
+  bins = (double*) Malloc(nbins*sizeof(double));
   /* for ( i = 0; i < nbins; i++ ) bins[i] = (fltarr[i]+fltarr[i+1])/2; */
   for ( i = 0; i < nbins; i++ ) bins[i] = fltarr[i];
   zaxisDefLevels(zaxisID2, bins);
-  free(bins);
+  Free(bins);
   zaxisDefLbounds(zaxisID2, fltarr);
   zaxisDefUbounds(zaxisID2, fltarr+1);
   zaxisDefName(zaxisID2, "bin");
@@ -114,22 +114,22 @@ void *Histogram(void *argument)
   streamDefVlist(streamID2, vlistID2);
 
   nvars = vlistNvars(vlistID2);
-  vardata   = (double **) malloc(nvars*sizeof(double *));
-  varcount  = (double **) malloc(nvars*sizeof(double *));
-  vartcount = (double **) malloc(nvars*sizeof(double *));
+  vardata   = (double **) Malloc(nvars*sizeof(double *));
+  varcount  = (double **) Malloc(nvars*sizeof(double *));
+  vartcount = (double **) Malloc(nvars*sizeof(double *));
   for ( varID = 0; varID < nvars; varID++ )
     {
       gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
-      vardata[varID]  = (double*) malloc(nbins*gridsize*sizeof(double));
-      varcount[varID] = (double*) malloc(nbins*gridsize*sizeof(double));
-      vartcount[varID] = (double*) malloc(gridsize*sizeof(double));
+      vardata[varID]  = (double*) Malloc(nbins*gridsize*sizeof(double));
+      varcount[varID] = (double*) Malloc(nbins*gridsize*sizeof(double));
+      vartcount[varID] = (double*) Malloc(gridsize*sizeof(double));
       memset(vardata[varID], 0, nbins*gridsize*sizeof(double));
       memset(varcount[varID], 0, nbins*gridsize*sizeof(double));
       memset(vartcount[varID], 0, gridsize*sizeof(double));
     }
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
   tsID1 = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID1)) )
@@ -226,21 +226,21 @@ void *Histogram(void *argument)
     {
       for ( varID = 0; varID < nvars; varID++ )
 	{
-	  free(vardata[varID]);
-	  free(varcount[varID]);
-	  free(vartcount[varID]);
+	  Free(vardata[varID]);
+	  Free(varcount[varID]);
+	  Free(vartcount[varID]);
 	}
 
-      free(vardata);
-      free(varcount);
-      free(vartcount);
+      Free(vardata);
+      Free(varcount);
+      Free(vartcount);
     }
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   listDelete(flist);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Importamsr.c b/src/Importamsr.c
index ef0f26b..95bf82c 100644
--- a/src/Importamsr.c
+++ b/src/Importamsr.c
@@ -45,8 +45,8 @@ void init_amsr_day(int vlistID, int gridID, int zaxisID, int nvars)
     5:cloud	cloud liquid water in millimeters
     6:rain   	rain rate in millimeters/hour
   */
-  char *name[]  = {"hours", "sst", "wind", "vapor", "cloud", "rain"};
-  char *units[] = {"h", "deg Celcius", "m/s", "mm", "mm", "mm/h"};
+  const char *name[]  = {"hours", "sst", "wind", "vapor", "cloud", "rain"};
+  const char *units[] = {"h", "deg Celcius", "m/s", "mm", "mm", "mm/h"};
   double xscale[]  = {0.1, 0.15, 0.2, 0.3, 0.01, 0.1};
   double xminval[] = {0., -3., 0., 0., 0., 0.};
   int i, varID;
@@ -91,8 +91,8 @@ void init_amsr_averaged(int vlistID, int gridID, int zaxisID, int nvars)
     4:cloud     cloud liquid water in millimeters
     5:rain	rain rate in millimeters/hour
   */
-  char *name[]  = {"sst", "wind", "vapor", "cloud", "rain"};
-  char *units[] = {"deg Celcius", "m/s", "mm", "mm", "mm/h"};
+  const char *name[]  = {"sst", "wind", "vapor", "cloud", "rain"};
+  const char *units[] = {"deg Celcius", "m/s", "mm", "mm", "mm/h"};
   double xscale[]  = {0.15, 0.2, 0.3, 0.01, 0.1};
   double xminval[] = {-3., 0., 0., 0., 0.};
   int i, varID;
@@ -121,7 +121,7 @@ void read_amsr(FILE *fp, int vlistID, int nvars, double *data[], int *nmiss)
   for ( varID = 0; varID < nvars; ++varID )
     {
       gridsize = gridInqSize(vlistInqVarGrid(vlistID, varID));
-      amsr_data = (unsigned char *) realloc(amsr_data, gridsize);
+      amsr_data = (unsigned char *) Realloc(amsr_data, gridsize);
       size = fread(amsr_data, 1, gridsize, fp);
       if ( (int)size != gridsize ) cdoAbort("Read error!");
 
@@ -144,7 +144,7 @@ void read_amsr(FILE *fp, int vlistID, int nvars, double *data[], int *nmiss)
 	}
     } 
 
-  free(amsr_data);
+  Free(amsr_data);
 }
 
 static
@@ -165,7 +165,7 @@ int getDate(const char *name)
   int date = 0;
   char *pname;
 
-  pname = strchr(name, '_');
+  pname = (char *)strchr(name, '_');
 
   if ( pname ) date = atoi(pname+1);
 
@@ -225,7 +225,7 @@ void *Importamsr(void *argument)
   if ( fsize == 12441600 )
     {
       nvars = 6;
-      for ( i = 0; i < nvars; ++i ) data[i] = (double*) malloc(gridsize*sizeof(double));
+      for ( i = 0; i < nvars; ++i ) data[i] = (double*) Malloc(gridsize*sizeof(double));
 
       init_amsr_day(vlistID, gridID, zaxisID, nvars);
 
@@ -245,12 +245,12 @@ void *Importamsr(void *argument)
 	  write_data(streamID, nvars, data, nmiss);
 	}
 
-      for ( i = 0; i < nvars; ++i ) free(data[i]);
+      for ( i = 0; i < nvars; ++i ) Free(data[i]);
     }
   else if ( fsize == 5184000 )
     {
       nvars = 5;
-      for ( i = 0; i < nvars; ++i ) data[i] = (double*) malloc(gridsize*sizeof(double));
+      for ( i = 0; i < nvars; ++i ) data[i] = (double*) Malloc(gridsize*sizeof(double));
 
       init_amsr_averaged(vlistID, gridID, zaxisID, nvars);
 
@@ -267,7 +267,7 @@ void *Importamsr(void *argument)
 
       write_data(streamID, nvars, data, nmiss);
 
-      for ( i = 0; i < nvars; ++i ) free(data[i]);
+      for ( i = 0; i < nvars; ++i ) Free(data[i]);
     }
   else
     cdoAbort("Unexpected file size for AMSR data!");
@@ -285,5 +285,5 @@ void *Importamsr(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Importbinary.c b/src/Importbinary.c
index 5d09fe8..49e292b 100644
--- a/src/Importbinary.c
+++ b/src/Importbinary.c
@@ -90,10 +90,10 @@ int y_is_gauss(double *gridyvals, int ysize)
   if ( ysize > 2 )
     {
       double *yvals, *yw;
-      yvals = (double*) malloc(ysize*sizeof(double));
-      yw    = (double*) malloc(ysize*sizeof(double));
-      gaussaw(yvals, yw, ysize);
-      free(yw);
+      yvals = (double*) Malloc(ysize*sizeof(double));
+      yw    = (double*) Malloc(ysize*sizeof(double));
+      gaussaw(yvals, yw, (size_t)ysize);
+      Free(yw);
       for ( i = 0; i < (int) ysize; i++ )
 	yvals[i] = asin(yvals[i])/M_PI*180.0;
 
@@ -113,7 +113,7 @@ int y_is_gauss(double *gridyvals, int ysize)
 	  if ( i == (int) ysize ) lgauss = TRUE;
 	}
 
-      free(yvals);
+      Free(yvals);
     }
 
   return (lgauss);
@@ -130,15 +130,15 @@ int define_grid(dsets_t *pfi)
   nx = pfi->dnum[0];
   ny = pfi->dnum[1];
 
-  xvals = (double*) malloc(nx*sizeof(double));
-  yvals = (double*) malloc(ny*sizeof(double));
+  xvals = (double*) Malloc(nx*sizeof(double));
+  yvals = (double*) Malloc(ny*sizeof(double));
 
   get_dim_vals(pfi, xvals, nx, 0);
   get_dim_vals(pfi, yvals, ny, 1);
 
   if ( pfi->yrflg ) rev_vals(yvals, ny);
 
-  if ( pfi->linear[1] == 0 ) lgauss = y_is_gauss(yvals, ny);
+  if ( pfi->linear[1] == 0 ) lgauss = y_is_gauss(yvals, (size_t)ny);
 
   if ( lgauss ) gridtype = GRID_GAUSSIAN;
   else          gridtype = GRID_LONLAT;
@@ -150,8 +150,8 @@ int define_grid(dsets_t *pfi)
   gridDefXvals(gridID, xvals);
   gridDefYvals(gridID, yvals);
 
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
   
   return (gridID);
 }
@@ -168,7 +168,7 @@ int define_level(dsets_t *pfi, int nlev)
     {
       double *zvals = NULL;
 
-      zvals = (double*) malloc(nz*sizeof(double));
+      zvals = (double*) Malloc(nz*sizeof(double));
 
       get_dim_vals(pfi, zvals, nz, 2);
 
@@ -182,7 +182,7 @@ int define_level(dsets_t *pfi, int nlev)
 	}
       zaxisDefLevels(zaxisID, zvals);
 
-      free(zvals);
+      Free(zvals);
     }
   else
     {
@@ -256,10 +256,10 @@ void *Importbinary(void *argument)
 
   vlistID = vlistCreate();
 
-  var_zaxisID = (int*) malloc(nvars*sizeof(int));
-  recVarID    = (int*) malloc(nrecs*sizeof(int));
-  recLevelID  = (int*) malloc(nrecs*sizeof(int));
-  var_dfrm    = (int*) malloc(nrecs*sizeof(int));
+  var_zaxisID = (int*) Malloc(nvars*sizeof(int));
+  recVarID    = (int*) Malloc(nrecs*sizeof(int));
+  recLevelID  = (int*) Malloc(nrecs*sizeof(int));
+  var_dfrm    = (int*) Malloc(nrecs*sizeof(int));
 
   recID = 0;
   for ( ivar = 0; ivar < nvars; ++ivar )
@@ -372,9 +372,9 @@ void *Importbinary(void *argument)
 
   //recsize = pfi.gsiz*4;
   recsize = pfi.gsiz*8;
-  rec = (char*) malloc(recsize);
+  rec = (char*) Malloc(recsize);
 
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
   /*
   if (pfi.tmplat)
@@ -501,21 +501,21 @@ void *Importbinary(void *argument)
 
 	      /* convert */
 	      if (var_dfrm[recID] == 1) {
-		unsigned char *carray = (void*)(rec + recoffset);
+		unsigned char *carray = (unsigned char *)(rec + recoffset);
 		for (i = 0; i < gridsize; ++i) array[i] = (double) carray[i];
 	      }
 	      else if (var_dfrm[recID] == 2) {
-		unsigned short *sarray = (void*)(rec + recoffset);
+		unsigned short *sarray = (unsigned short *)(rec + recoffset);
 	        if (pfi.bswap) gabswp2(sarray, gridsize);
 		for (i = 0; i < gridsize; ++i) array[i] = (double) sarray[i];
 	      }
 	      else if (var_dfrm[recID] == -2) {
-		short *sarray = (void*)(rec + recoffset);
+		short *sarray = (short *)(rec + recoffset);
 	        if (pfi.bswap) gabswp2(sarray, gridsize);
 		for (i = 0; i < gridsize; ++i) array[i] = (double) sarray[i];
 	      }
 	      else if (var_dfrm[recID] == 4) {
-		int *iarray = (void*)(rec + recoffset);
+		int *iarray = (int *)(rec + recoffset);
 	        if (pfi.bswap) gabswp(iarray, gridsize);
 		for (i = 0; i < gridsize; ++i) array[i] = (double) iarray[i];
 	      }
@@ -583,15 +583,15 @@ void *Importbinary(void *argument)
   zaxisDestroy(zaxisID);
   taxisDestroy(taxisID);
 
-  free(array);
-  free(rec);
+  Free(array);
+  Free(rec);
 
-  if ( var_zaxisID ) free(var_zaxisID);
-  if ( recVarID    ) free(recVarID);
-  if ( recLevelID  ) free(recLevelID);
-  if ( var_dfrm    ) free(var_dfrm);
+  if ( var_zaxisID ) Free(var_zaxisID);
+  if ( recVarID    ) Free(recVarID);
+  if ( recLevelID  ) Free(recLevelID);
+  if ( var_dfrm    ) Free(var_dfrm);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Importcmsaf.c b/src/Importcmsaf.c
index 331d167..e577cf2 100644
--- a/src/Importcmsaf.c
+++ b/src/Importcmsaf.c
@@ -74,7 +74,6 @@ static
 void print_filter(hid_t dset_id, char *varname)
 {
   hid_t plist;
-  H5Z_filter_t filter;
   unsigned int flags;
   int idx;
   unsigned int cd_values;
@@ -89,8 +88,7 @@ void print_filter(hid_t dset_id, char *varname)
 
   for ( idx = 0; idx < nfilter; idx++ )
     {
-      filter = H5Pget_filter(plist, idx, &flags, &cd_nelmts, &cd_values, 
-			     pnamelen, pname);
+      H5Pget_filter(plist, idx, &flags, &cd_nelmts, &cd_values, pnamelen, pname);
       cdoPrint("Dataset %s: filter %d =  %s", varname, idx+1, pname);
     }
 
@@ -175,10 +173,10 @@ int defLonLatGrid(int nx, int ny, double c0, double lts, double re)
       return(-1);
     }
 
-  xvals = (double*) malloc(nx*sizeof(double));
-  yvals = (double*) malloc(ny*sizeof(double));
-  xbounds = (double*) malloc(nx*2*sizeof(double));
-  ybounds = (double*) malloc(nx*2*sizeof(double));
+  xvals = (double*) Malloc(nx*sizeof(double));
+  yvals = (double*) Malloc(ny*sizeof(double));
+  xbounds = (double*) Malloc(nx*2*sizeof(double));
+  ybounds = (double*) Malloc(nx*2*sizeof(double));
 
   for ( i = 0; i < nx; ++i )
     {
@@ -213,73 +211,73 @@ int defLonLatGrid(int nx, int ny, double c0, double lts, double re)
   gridDefXbounds(gridID, xbounds);
   gridDefYbounds(gridID, ybounds);
   */
-  free(xvals);
-  free(yvals);
-  free(xbounds);
-  free(ybounds);
+  Free(xvals);
+  Free(yvals);
+  Free(xbounds);
+  Free(ybounds);
 
   return (gridID);
 }
 
 static
-int defSinusoidalGrid(int nx, int ny, double xmin, double xmax, double ymin, double ymax, 
+int defSinusoidalGrid(int nx, int ny, double xmin, double xmax, double ymin, double ymax,
 		      double dx, double dy, double p1, double p2, double p3, double p4)
 {
-  int gridID;
-  int i;
-  double *xvals, *yvals;
-
-  xvals = (double*) malloc(nx*sizeof(double));
-  yvals = (double*) malloc(ny*sizeof(double));
-
-  for ( i = 0; i < nx; ++i )
+  UNUSED(p1);
+  UNUSED(p2);
+  UNUSED(p3);
+  UNUSED(p4);
+  UNUSED(xmax);
+  UNUSED(ymin);
+  double *xvals = (double*) Malloc(nx*sizeof(double));
+  double *yvals = (double*) Malloc(ny*sizeof(double));
+
+  for ( int i = 0; i < nx; ++i )
     {
       xvals[i] = xmin + i*dx + dx/2;
       /* printf("x[%d]=%g\n", i, xvals[i]); */
     }
 
-  for ( i = 0; i < ny; ++i )
+  for ( int i = 0; i < ny; ++i )
     {
-      yvals[i] = ymax - i*dx - dx/2;
+      yvals[i] = ymax - i*dy - dy/2;
       /* printf("y[%d]=%g\n", i, yvals[i]); */
     }
 
-  gridID = gridCreate(GRID_SINUSOIDAL, nx*ny);
+  int gridID = gridCreate(GRID_SINUSOIDAL, nx*ny);
   gridDefXsize(gridID, nx);
   gridDefYsize(gridID, ny);
   gridDefXvals(gridID, xvals);
   gridDefYvals(gridID, yvals);
 
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
 
   return (gridID);
 }
 
 static
-int defLaeaGrid(int nx, int ny, double xmin, double xmax, double ymin, double ymax, 
+int defLaeaGrid(int nx, int ny, double xmin, double xmax, double ymin, double ymax,
 		double dx, double dy, double a, double lon0, double lat0)
 {
-  int gridID;
-  int i;
-  double *xvals, *yvals;
+  UNUSED(xmax);
+  UNUSED(ymin);
+  double *xvals = (double*) Malloc(nx*sizeof(double));
+  double *yvals = (double*) Malloc(ny*sizeof(double));
 
-  xvals = (double*) malloc(nx*sizeof(double));
-  yvals = (double*) malloc(ny*sizeof(double));
-
-  for ( i = 0; i < nx; ++i )
+  for ( int i = 0; i < nx; ++i )
     {
       xvals[i] = xmin + i*dx + dx/2;
       /* printf("x[%d]=%g\n", i, xvals[i]); */
     }
 
-  for ( i = 0; i < ny; ++i )
+  for ( int i = 0; i < ny; ++i )
     {
-      yvals[i] = ymax - i*dx - dx/2;
+      yvals[i] = ymax - i*dy - dy/2;
       /* printf("y[%d]=%g\n", i, yvals[i]); */
     }
 
-  gridID = gridCreate(GRID_LAEA, nx*ny);
+  int gridID = gridCreate(GRID_LAEA, nx*ny);
   gridDefXsize(gridID, nx);
   gridDefYsize(gridID, ny);
   gridDefXvals(gridID, xvals);
@@ -287,8 +285,8 @@ int defLaeaGrid(int nx, int ny, double xmin, double xmax, double ymin, double ym
 
   gridDefLaea(gridID, a, lon0, lat0);
 
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
 
   return (gridID);
 }
@@ -356,7 +354,6 @@ int read_geolocation(hid_t loc_id, int nx, int ny, int lprojtype)
   hid_t proj_tid, region_tid;
   hid_t str_tid, fltarr_tid;
   hid_t ptype_id;
-  herr_t     status;
   hsize_t dims;
   int xsize, ysize;
   typedef struct proj_t {
@@ -402,7 +399,7 @@ int read_geolocation(hid_t loc_id, int nx, int ny, int lprojtype)
   H5Tinsert(proj_tid, "Reference ellipsoid", HOFFSET(proj_t, ellipsoid), str_tid);
   H5Tinsert(proj_tid, "Projection parameter", HOFFSET(proj_t, parameter), fltarr_tid);
 
-  if ( projection_name ) free(projection_name);
+  if ( projection_name ) Free(projection_name);
 
   grp_id = H5Gopen(loc_id, "Geolocation");
 
@@ -426,7 +423,7 @@ int read_geolocation(hid_t loc_id, int nx, int ny, int lprojtype)
   if ( proj_id < 0 )
     memset(&proj, 0, sizeof(proj_t));
   else
-    status = H5Dread(proj_id, proj_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &proj);
+    H5Dread(proj_id, proj_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &proj);
 
   H5Dclose(proj_id);
   H5Tclose(proj_tid);
@@ -434,9 +431,9 @@ int read_geolocation(hid_t loc_id, int nx, int ny, int lprojtype)
   H5Tclose(fltarr_tid);
 
   if ( cdoVerbose )
-    cdoPrint("  Projection: name=%s\n\t\t\tellipsoid=%s\n\t\t\tparameter=%g %g %g %g %g %g",  
-	     proj.name, proj.ellipsoid, 
-	     proj.parameter[0], proj.parameter[1], proj.parameter[2], 
+    cdoPrint("  Projection: name=%s\n\t\t\tellipsoid=%s\n\t\t\tparameter=%g %g %g %g %g %g",
+	     proj.name, proj.ellipsoid,
+	     proj.parameter[0], proj.parameter[1], proj.parameter[2],
 	     proj.parameter[3], proj.parameter[4], proj.parameter[5]);
 
   region_tid = H5Tcreate(H5T_COMPOUND, sizeof(region_t));
@@ -450,11 +447,11 @@ int read_geolocation(hid_t loc_id, int nx, int ny, int lprojtype)
   region_id = H5Dopen(grp_id, "Region");
   if ( region_id < 0 )
     region_id = H5Dopen(grp_id, "region");
-  
+
   if ( region_id < 0 )
     memset(&region, 0, sizeof(region_t));
   else
-    status = H5Dread(region_id, region_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &region);
+    H5Dread(region_id, region_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &region);
 
   H5Dclose(region_id);
   H5Tclose(region_tid);
@@ -467,7 +464,7 @@ int read_geolocation(hid_t loc_id, int nx, int ny, int lprojtype)
       if ( cdoVerbose ) cdoPrint("  Swap xmin/xmax");
     }
 
-  if ( cdoVerbose ) 
+  if ( cdoVerbose )
     cdoPrint("  Region: xmin=%g xmax=%g ymin=%g ymax=%g dx=%g dy=%g",
 	     region.xmin, region.xmax, region.ymin, region.ymax, region.dx, region.dy);
 
@@ -488,7 +485,7 @@ int read_geolocation(hid_t loc_id, int nx, int ny, int lprojtype)
        (int)region.ymin == 8887500 && (int)region.ymax == 8887500 &&
        (int)region.dx == 15000 && (int)region.dy  == 15000 )
     {
-       region.xmax = 8887500.0;
+       region.xmax =  8887500.0;
        region.ymin = -8887500.0;
        if ( cdoVerbose )
          cdoPrint("  Corrected region: xmin=%g xmax=%g ymin=%g ymax=%g dx=%g dy=%g",
@@ -500,14 +497,14 @@ int read_geolocation(hid_t loc_id, int nx, int ny, int lprojtype)
     }
 
   if (nx == 298 && ny == 371 &&
-      (int)region.xmin == -6709222 &&  (int)region.xmax == 6709222 &&
+      (int)region.xmin == -6709222 && (int)region.xmax == 6709222 &&
       (int)region.ymin == -6664078 && (int)region.ymax == 9984898 &&
       (int)region.dx == 45000 && (int)region.dy  == 45000 )
     {
         region.xmin = -6705000;
-        region.xmax = 6705000;
+        region.xmax =  6705000;
         region.ymin = -6705000;
-        region.ymax = 9990000;      
+        region.ymax =  9990000;
         cdoPrint("  Corrected region: xmin=%g xmax=%g ymin=%g ymax=%g dx=%g dy=%g",
                region.xmin, region.xmax, region.ymin, region.ymax, region.dx, region.dy);
 
@@ -516,15 +513,15 @@ int read_geolocation(hid_t loc_id, int nx, int ny, int lprojtype)
         if ( cdoVerbose ) cdoPrint("  Corrected size: xsize=%d  ysize=%d", xsize, ysize);
     }
 
-  if ( strcmp(proj.name, "sinusoidal") != 0  && 
+  if ( strcmp(proj.name, "sinusoidal") != 0  &&
        ( (nx == xsize && ny == ysize &&
-	  (int)region.xmin == -8887500 && (int)region.xmax == 8887500 && 
-	  (int)region.ymin == -8887500 && (int)region.ymax == 8887500 && 
+	  (int)region.xmin == -8887500 && (int)region.xmax == 8887500 &&
+	  (int)region.ymin == -8887500 && (int)region.ymax == 8887500 &&
 	  (int)region.dx == 15000 && (int)region.dy  == 15000 )
 	 ||
 	 (nx == xsize && ny == ysize &&
-	  (int)region.xmin == -5827500 && (int)region.xmax == 5827500 && 
-	  (int)region.ymin ==  3307500 && (int)region.ymax == 8887500 && 
+	  (int)region.xmin == -5827500 && (int)region.xmax == 5827500 &&
+	  (int)region.ymin ==  3307500 && (int)region.ymax == 8887500 &&
 	  (int)region.dx == 15000 && (int)region.dy  == 15000 )
 	 ||
 	 (nx == xsize && ny == ysize &&
@@ -540,7 +537,7 @@ int read_geolocation(hid_t loc_id, int nx, int ny, int lprojtype)
 	 (nx == 298 && ny == 371 &&
 	  (int)region.xmin == -6709222 && (int)region.xmax == 6709222 &&
 	  (int)region.ymin == -6664078 && (int)region.ymax == 9984898 &&
-	  (int)region.dx == 45000 && (int)region.dy  == 45000 ) 
+	  (int)region.dx == 45000 && (int)region.dy  == 45000 )
 	 ||
 	 (nx == xsize && ny == ysize &&
 	  (int)region.xmin == -6705000 && (int)region.xmax == 6705000 &&
@@ -550,25 +547,25 @@ int read_geolocation(hid_t loc_id, int nx, int ny, int lprojtype)
       if ( cdoVerbose ) cdoPrint("Replacing incorrect projection parameters for sinusoidal products:");
       strcpy(proj.ellipsoid, "WGS-84");
       strcpy(proj.name, "sinusoidal");
-      proj.parameter[0] = 0.0; 
+      proj.parameter[0] = 0.0;
       proj.parameter[1] = 0.0;
-      proj.parameter[2] = 0.0; 
-      proj.parameter[3] = 0.0;  
-      proj.parameter[4] = -99.99;      
-      proj.parameter[5] = -99.99;          
-      if ( cdoVerbose ) 
-	  cdoPrint("proj1 = %g, proj2 = %g, proj3 = %g, proj4 = %g,",  
-		   proj.parameter[0], proj.parameter[1],  
+      proj.parameter[2] = 0.0;
+      proj.parameter[3] = 0.0;
+      proj.parameter[4] = -99.99;
+      proj.parameter[5] = -99.99;
+      if ( cdoVerbose )
+	  cdoPrint("proj1 = %g, proj2 = %g, proj3 = %g, proj4 = %g,",
+		   proj.parameter[0], proj.parameter[1],
 		   proj.parameter[2], proj.parameter[3]);
     }
 
-  if ( nx == xsize && ny == ysize && 
-       strcmp(proj.name, "sinusoidal") == 0 && 
+  if ( nx == xsize && ny == ysize &&
+       strcmp(proj.name, "sinusoidal") == 0 &&
        strcmp(proj.ellipsoid, "WGS-84") == 0  )
     {
-      gridID = defSinusoidalGrid(nx, ny, region.xmin, region.xmax, region.ymin, region.ymax, 
+      gridID = defSinusoidalGrid(nx, ny, region.xmin, region.xmax, region.ymin, region.ymax,
 				 region.dx, region.dy,
-				 proj.parameter[0], proj.parameter[1], 
+				 proj.parameter[0], proj.parameter[1],
 				 proj.parameter[2], proj.parameter[3]);
     }
   /* modification by Frank Kaspar */
@@ -595,17 +592,17 @@ int read_geolocation(hid_t loc_id, int nx, int ny, int lprojtype)
             memcmp(proj.ellipsoid, "Sphere", 6) == 0 )
     {
       double c0  = 0.001*sqrt(proj.parameter[5]);       /* nominal spatial resolution */
-      double lts = proj.parameter[3];      
+      double lts = proj.parameter[3];
       double re  = proj.parameter[4]/1000;  /* Earth radius [km]*/
-      if ( cdoVerbose ) cdoPrint("  c0 = %g, lts = %g, re = %g", c0, lts, re); 
+      if ( cdoVerbose ) cdoPrint("  c0 = %g, lts = %g, re = %g", c0, lts, re);
       gridID = defLonLatGrid(nx, ny, c0, lts, re);
     }
   else if ( nx == 386 && ny == 162 )
     {
       double c0  = 90;       /* nominal spatial resolution */
-      double lts = 30;      
+      double lts = 30;
       double re  = 6371.228;  /* Earth radius [km]*/
-      if ( cdoVerbose ) cdoPrint("  c0 = %g, lts = %g, re = %g", c0, lts, re); 
+      if ( cdoVerbose ) cdoPrint("  c0 = %g, lts = %g, re = %g", c0, lts, re);
       gridID = defLonLatGrid(nx, ny, c0, lts, re);
     }
 
@@ -620,7 +617,7 @@ int read_region(hid_t loc_id, int nx, int ny)
   hid_t region_id;
   hid_t region_tid;
   hid_t str64_tid, str128_tid, fltarr_tid;
-  herr_t     status;
+  herr_t status;
   hsize_t dims;
   typedef struct region_t {
     double area_extent[4];
@@ -687,6 +684,7 @@ int read_region(hid_t loc_id, int nx, int ny)
   }
   */
   status = H5Dread(region_id, region_tid, H5S_ALL, H5S_ALL, H5P_DEFAULT, &region);
+  UNUSED(status);
 
   if ( cdoVerbose )
     {
@@ -742,10 +740,10 @@ int read_region(hid_t loc_id, int nx, int ny)
   */
 
   if ( nfound == 4 &&
-       nx == region.xsize && ny == region.ysize && 
+       nx == region.xsize && ny == region.ysize &&
        strcmp(proj, "laea") == 0 )
     {
-      gridID = defLaeaGrid(nx, ny, xmin, xmax, ymin, ymax, 
+      gridID = defLaeaGrid(nx, ny, xmin, xmax, ymin, ymax,
 			   dx, dy, a, lon0, lat0);
     }
 
@@ -756,7 +754,7 @@ static
 void read_dataset(hid_t loc_id, const char *name, void *opdata)
 {
   hid_t dset_id, type_id;
-  hid_t   dataspace;   
+  hid_t   dataspace;
   hsize_t dims_out[9];  /* dataset dimensions           */
   herr_t  status;	/* Generic return value		*/
   hid_t   attr, atype, atype_mem;
@@ -790,7 +788,7 @@ void read_dataset(hid_t loc_id, const char *name, void *opdata)
   strcpy(varname, name);
 
   dset_id = H5Dopen(loc_id, varname);
-  
+
   type_id = H5Dget_type(dset_id);  /* get datatype*/
 
   type_class = H5Tget_class(type_id);
@@ -860,7 +858,7 @@ void read_dataset(hid_t loc_id, const char *name, void *opdata)
     if ( isdigit(varname[len-1]) && memcmp(varname, "Data", 4) != 0 )
       {
 	if ( nt > 1 ) cdoAbort("Combination of nlevel > 1 and ntime > 1 not implemented!");
-       
+
 	nz = atoi(&varname[len-1]);
 	varname[len-1] = 0;
       }
@@ -1029,21 +1027,21 @@ void read_dataset(hid_t loc_id, const char *name, void *opdata)
 	    {
 	      H5Aread(attr, atype_mem, attstring);
 	      if ( ((datasets_t *) opdata)->obj[nset].description )
-		free(((datasets_t *) opdata)->obj[nset].description);
+                Free(((datasets_t *) opdata)->obj[nset].description);
 	      ((datasets_t *) opdata)->obj[nset].description = strdup(attstring);
 	    }
 	  else if ( strcmp(attname, "title") == 0 )
 	    {
 	      H5Aread(attr, atype_mem, attstring);
 	      if ( ((datasets_t *) opdata)->obj[nset].title )
-		free(((datasets_t *) opdata)->obj[nset].title);
+                Free(((datasets_t *) opdata)->obj[nset].title);
 	      ((datasets_t *) opdata)->obj[nset].title = strdup(attstring);
 	    }
 	  else if ( strcmp(attname, "time") == 0 )
 	    {
 	      H5Aread(attr, atype_mem, attstring);
 	      if ( ((datasets_t *) opdata)->obj[nset].time )
-		free(((datasets_t *) opdata)->obj[nset].time);
+                Free(((datasets_t *) opdata)->obj[nset].time);
 	      ((datasets_t *) opdata)->obj[nset].time = strdup(attstring);
 	    }
 	  else if ( strcmp(attname, "unit") == 0 )
@@ -1056,10 +1054,10 @@ void read_dataset(hid_t loc_id, const char *name, void *opdata)
 	  H5Aclose(attr);
 	  H5Tclose(atype);
 	}
-      
+
       offset = gridsize*(nz-1);
       array  = ((datasets_t *) opdata)->obj[nset].array;
-      array  = (double*) realloc(array, gridsize*nz*nt*sizeof(double));
+      array  = (double*) Realloc(array, gridsize*nz*nt*sizeof(double));
       ((datasets_t *) opdata)->obj[nset].array    = array;
       array  = array+offset;
 
@@ -1069,12 +1067,12 @@ void read_dataset(hid_t loc_id, const char *name, void *opdata)
 	    {
 	      float *farray;
 	      int i;
-	      farray = (float*) malloc(gridsize*nt*sizeof(float));
+	      farray = (float*) Malloc(gridsize*nt*sizeof(float));
 	      status = H5Dread(dset_id, H5T_NATIVE_FLOAT, H5S_ALL, H5S_ALL, H5P_DEFAULT, farray);
 	      if ( status < 0 )
 		cdoAbort("Reading of NATIVE_FLOAT variable %s failed!", varname);
 	      for ( i = 0; i < gridsize*nt; ++i ) array[i] = farray[i];
-	      free(farray);
+	      Free(farray);
 	    }
 	  else
 	    {
@@ -1086,12 +1084,12 @@ void read_dataset(hid_t loc_id, const char *name, void *opdata)
       else
 	{
 	  int *iarray, i;
-	  iarray = (int*) malloc(gridsize*nt*sizeof(int));
+	  iarray = (int*) Malloc(gridsize*nt*sizeof(int));
 	  status = H5Dread(dset_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, iarray);
 	  if ( status < 0 )
 	    cdoAbort("Reading of NATIVE_INT variable %s failed!", varname);
 	  for ( i = 0; i < gridsize*nt; ++i ) array[i] = iarray[i];
-	  free(iarray);
+	  Free(iarray);
 	}
 
       ((datasets_t *) opdata)->obj[nset].name     = strdup(varname);
@@ -1113,16 +1111,16 @@ void read_dataset(hid_t loc_id, const char *name, void *opdata)
 	    cdoWarning("Scalefactor changes over levels!");
 
 	  if ( lmissval && !DBL_IS_EQUAL(((datasets_t *) opdata)->obj[nset].missval, missval) )
-	    cdoWarning("Missing value changes over levels!");	       
+	    cdoWarning("Missing value changes over levels!");
 	}
 
       if ( nz == 1 ) ((datasets_t *) opdata)->nsets++;
 
-      mask = (short*) malloc(gridsize*nt*sizeof(short));
+      mask = (short*) Malloc(gridsize*nt*sizeof(short));
       memset(mask, 0, gridsize*nt*sizeof(short));
 
       nmiss  = 0;
- 
+
       minval =  1e35;
       maxval = -1e35;
       for ( i = 0; i < gridsize*nt; i++ )
@@ -1152,7 +1150,7 @@ void read_dataset(hid_t loc_id, const char *name, void *opdata)
       lscalefactor = IS_NOT_EQUAL(scalefactor, 1);
 
       if ( laddoffset || lscalefactor )
-	{	  
+	{
 	  for ( i = 0; i < gridsize*nt; i++ )
 	    if ( !DBL_IS_EQUAL(array[i], missval) )
 	      {
@@ -1167,7 +1165,7 @@ void read_dataset(hid_t loc_id, const char *name, void *opdata)
 		mask[i] = 1;
 	      }
 	}
-	    
+
       minval =  1e35;
       maxval = -1e35;
       for ( i = 0; i < gridsize*nt; i++ )
@@ -1210,7 +1208,7 @@ void read_dataset(hid_t loc_id, const char *name, void *opdata)
       ((datasets_t *) opdata)->obj[nset].scale    = scalefactor;
       ((datasets_t *) opdata)->obj[nset].missval  = missval;
 
-      free(mask); 
+      Free(mask);
       mask = NULL;
     }
   else
@@ -1242,7 +1240,7 @@ obj_info(hid_t loc_id, const char *name, void *opdata)
     if ( cdoVerbose ) cdoPrint(" Object with name %s is a group", name);
     if ( strcmp(name, "Data") == 0 )
       {
-	((datasets_t *) opdata)->mergelevel = TRUE;	
+	((datasets_t *) opdata)->mergelevel = TRUE;
 	H5Giterate(loc_id, name, NULL, obj_info, opdata);
       }
     else if ( strcmp(name, "Geolocation") == 0 )
@@ -1254,7 +1252,7 @@ obj_info(hid_t loc_id, const char *name, void *opdata)
 	((datasets_t *) opdata)->lmetadata = TRUE;
       }
     break;
-  case H5G_DATASET: 
+  case H5G_DATASET:
     if ( cdoVerbose ) cdoPrint(" Object with name %s is a dataset", name);
     if ( strstr(name, "PALETTE") )
       {
@@ -1271,7 +1269,7 @@ obj_info(hid_t loc_id, const char *name, void *opdata)
 	read_dataset(loc_id, name, opdata);
       }
     break;
-  case H5G_TYPE: 
+  case H5G_TYPE:
     if ( cdoVerbose ) cdoPrint(" Object with name %s is a named datatype", name);
     if ( strcmp(name, "ProjType") == 0 )
       {
@@ -1320,23 +1318,23 @@ void get_global_att(hid_t file_id, const char *obj_path, int vlistID)
 	{
 	  H5Aread(attr, atype_mem, attstring);
 	  vlistDefAttTxt(vlistID, CDI_GLOBAL, attname, (int)strlen(attstring), attstring);
-	} 
+	}
       else if ( type_class == H5T_INTEGER )
 	{
 	  H5Aread(attr, H5T_NATIVE_INT, &attint);
 	  vlistDefAttInt(vlistID, CDI_GLOBAL, attname, DATATYPE_INT32, 1, &attint);
-	} 
+	}
       else if ( type_class == H5T_FLOAT )
 	{
 	  H5Aread(attr, H5T_NATIVE_DOUBLE, &attflt);
 	  vlistDefAttFlt(vlistID, CDI_GLOBAL, attname, DATATYPE_FLT64, 1, &attflt);
-	} 
+	}
       H5Tclose(atype_mem);
       H5Aclose(attr);
       H5Tclose(atype);
     }
 
-  if ( grp_id >= 0 ) H5Gclose(grp_id);	
+  if ( grp_id >= 0 ) H5Gclose(grp_id);
 
 }
 
@@ -1398,7 +1396,7 @@ void dsets_init(datasets_t *dsets)
       dsets->obj[i].loffset     = 0;
       dsets->obj[i].lmissval    = 0;
       dsets->obj[i].missval     = cdiInqMissval();
-      dsets->obj[i].array       = NULL;   
+      dsets->obj[i].array       = NULL;
     }
 }
 #endif
@@ -1455,8 +1453,8 @@ void *Importcmsaf(void *argument)
 
   if ( nt > 1 )
     {
-      vtimes = (int*) malloc(nt*sizeof(int));
-      
+      vtimes = (int*) Malloc(nt*sizeof(int));
+
       for ( i = 0; i < nt; ++i ) vtimes[i] = i*10000 + 45*100;
 
       if ( dsets.obj[ivar].time )
@@ -1479,7 +1477,7 @@ void *Importcmsaf(void *argument)
 
   if ( cdoVerbose )
     for ( ivar = 0; ivar < dsets.nsets; ++ivar )
-      cdoPrint(" Var %d %-20s %dx%d nlev = %d nts = %d", 
+      cdoPrint(" Var %d %-20s %dx%d nlev = %d nts = %d",
 	       ivar, dsets.obj[ivar].name, nx, ny, nz, dsets.obj[ivar].nt);
 
   for ( ivar = 1; ivar < dsets.nsets; ++ivar )
@@ -1498,7 +1496,7 @@ void *Importcmsaf(void *argument)
     {
       gridID = read_region(file_id, nx, ny);
     }
-  
+
   if ( gridID == -1 )
     {
       gridID = gridCreate(GRID_GENERIC, gridsize);
@@ -1511,11 +1509,11 @@ void *Importcmsaf(void *argument)
   else
     {
       double *levels;
-      levels = (double*) malloc(nz*sizeof(double));
+      levels = (double*) Malloc(nz*sizeof(double));
       for ( i = 0; i < nz; ++i ) levels[i] = i+1;
       zaxisID = zaxisCreate(ZAXIS_GENERIC, nz);
       zaxisDefLevels(zaxisID, levels);
-      free(levels);
+      Free(levels);
     }
 
   vlistID = vlistCreate();
@@ -1542,9 +1540,9 @@ void *Importcmsaf(void *argument)
       if ( dsets.obj[ivar].units )
 	vlistDefVarUnits(vlistID, varID,  dsets.obj[ivar].units);
       if ( dsets.obj[ivar].title )
-	vlistDefAttTxt(vlistID, varID, "title", (int)strlen(dsets.obj[ivar].title), 
+	vlistDefAttTxt(vlistID, varID, "title", (int)strlen(dsets.obj[ivar].title),
 		       dsets.obj[ivar].title);
-	
+
       /*
       vlistDefVarUnits(vlistID, varID, units[i]);
       */
@@ -1580,7 +1578,7 @@ void *Importcmsaf(void *argument)
 	  varID   = ivar;
 
 	  if ( tsID > 0 && dsets.obj[ivar].nt == 1 ) continue;
-	  
+
 	  gridsize = dsets.obj[ivar].gridsize;
 	  missval  = dsets.obj[ivar].missval;
 
@@ -1589,7 +1587,7 @@ void *Importcmsaf(void *argument)
 	      offset = gridsize*levelID;
 	      if ( nz == 1 ) offset = gridsize*tsID;
 	      array  = dsets.obj[ivar].array+offset;
-	      
+
 	      nmiss  = 0;
 	      minval =  1e35;
 	      maxval = -1e35;
@@ -1622,6 +1620,7 @@ void *Importcmsaf(void *argument)
 
   /* Close file */
   status = H5Fclose(file_id);
+  UNUSED(status);
 
   processDefVarNum(vlistNvars(vlistID), streamID);
 
@@ -1633,14 +1632,14 @@ void *Importcmsaf(void *argument)
   taxisDestroy(taxisID);
 
   for ( ivar = 0; ivar < dsets.nsets; ++ivar )
-    free(dsets.obj[ivar].array);
+    Free(dsets.obj[ivar].array);
 
-  if ( vtimes ) free(vtimes);
+  if ( vtimes ) Free(vtimes);
 
   cdoFinish();
 #else
   cdoAbort("HDF5 support not compiled in!");
 #endif
 
-  return (0);
+  return 0;
 }
diff --git a/src/Importobs.c b/src/Importobs.c
index bb1ef68..61fdf3c 100644
--- a/src/Importobs.c
+++ b/src/Importobs.c
@@ -31,14 +31,14 @@ static
 void init_vars(int vlistID, int gridID, int zaxisID, int nvars)
 {
   int  code[]  = {11, 17, 33, 34, 1, 2/*, 3*/};
-  char *name[]  = {"temp", "depoint", "u", "v", "height", "pressure" /*, "station"*/};
-  char *units[] = {"Celsius", "", "m/s", "m/s", "m", "hPa" /*, ""*/};
-  int i, varID;
+  const char *name[]  = {"temp", "depoint", "u", "v", "height", "pressure" /*, "station"*/};
+  const char *units[] = {"Celsius", "", "m/s", "m/s", "m", "hPa" /*, ""*/};
+  int varID;
 
-  for ( i = 0; i < nvars; ++i )
+  for ( int i = 0; i < nvars; ++i )
     {
       varID = vlistDefVar(vlistID, gridID, zaxisID, TSTEP_INSTANT);
-      vlistDefVarCode(vlistID, varID, code[i]);
+      vlistDefVarParam(vlistID, varID, cdiEncodeParam(code[i], 255, 255));
       vlistDefVarName(vlistID, varID, name[i]);
       vlistDefVarUnits(vlistID, varID, units[i]);
       vlistDefVarDatatype(vlistID, varID, DATATYPE_FLT32);
@@ -48,31 +48,26 @@ void init_vars(int vlistID, int gridID, int zaxisID, int nvars)
 static
 void init_data(int vlistID, int nvars, double *data[])
 {
-  int varID, i, gridsize;
+  int gridsize;
   double missval;
 
-  for ( varID = 0; varID < nvars; ++varID )
+  for ( int varID = 0; varID < nvars; ++varID )
     {
       gridsize = gridInqSize(vlistInqVarGrid(vlistID, varID));
       missval  = vlistInqVarMissval(vlistID, varID);
       
-      for ( i = 0; i < gridsize; ++i )
-	{
-	  data[varID][i] = missval;
-	}
+      for ( int i = 0; i < gridsize; ++i ) data[varID][i] = missval;
     } 
 }
 
 static
 void write_data(int streamID, int vlistID, int nvars, double *data[])
 {
-  int i;
-  int varID;
   int nmiss;
   int gridsize;
   double missval;
 
-  for ( varID = 0; varID < nvars; ++varID )
+  for ( int varID = 0; varID < nvars; ++varID )
     {
       gridsize = gridInqSize(vlistInqVarGrid(vlistID, varID));
       missval  = vlistInqVarMissval(vlistID, varID);
@@ -80,7 +75,7 @@ void write_data(int streamID, int vlistID, int nvars, double *data[])
       streamDefRecord(streamID, varID, 0);
 
       nmiss = 0;
-      for ( i = 0; i < gridsize; ++i )
+      for ( int i = 0; i < gridsize; ++i )
 	if ( DBL_IS_EQUAL(data[varID][i], missval) ) nmiss++;
       
       streamWriteRecord(streamID, data[varID], nmiss);
@@ -90,11 +85,9 @@ void write_data(int streamID, int vlistID, int nvars, double *data[])
 static
 int getDate(const char *name)
 {
-  int date = 0;
-  char *pname;
-
-  pname = strchr(name, '_');
+  char *pname = (char *)strchr(name, '_');
 
+  int date = 0;
   if ( pname ) date = atoi(pname+1);
 
   return(date);
@@ -104,19 +97,11 @@ int getDate(const char *name)
 
 void *Importobs(void *argument)
 {
-  int operatorID;
   char line[MAX_LINE_LEN];
-  int streamID;
-  int tsID;
-  int gridID, zaxisID, taxisID, vlistID;
   int i, j;
   int nvars = MAX_VARS;
-  int vdate = 0, vtime = 0;
-  int vdate0 = 0, vtime0 = 0;
-  int gridsize, xsize, ysize;
-  double *xvals = NULL, *yvals = NULL;
+  int vtime = 0;
   double *data[MAX_VARS];
-  FILE *fp;
   char dummy[32], station[32], datetime[32];
   float lat, lon, height1, pressure, height2, value;
   double latmin = 90, latmax = -90, lonmin = 360, lonmax = -360;
@@ -129,23 +114,23 @@ void *Importobs(void *argument)
 
   cdoOperatorAdd("import_obs",     0, 0, "grid description file or name");
 
-  operatorID = cdoOperatorID();
+  int operatorID = cdoOperatorID();
 
   operatorInputArg(cdoOperatorEnter(operatorID));  
 
-  gridID = cdoDefineGrid(operatorArgv()[0]);
+  int gridID = cdoDefineGrid(operatorArgv()[0]);
 
   if ( gridInqType(gridID) != GRID_LONLAT ) 
     cdoAbort("Unsupported grid type: %s", gridNamePtr(gridInqType(gridID)));
 
-  gridsize = gridInqSize(gridID);
-  xsize = gridInqXsize(gridID);
-  ysize = gridInqYsize(gridID);
+  int gridsize = gridInqSize(gridID);
+  int xsize = gridInqXsize(gridID);
+  int ysize = gridInqYsize(gridID);
 
   // printf("gridsize=%d, xsize=%d, ysize=%d\n", gridsize, xsize, ysize);
 
-  xvals = (double*) malloc(gridsize*sizeof(double));
-  yvals = (double*) malloc(gridsize*sizeof(double));
+  double *xvals = (double*) Malloc(gridsize*sizeof(double));
+  double *yvals = (double*) Malloc(gridsize*sizeof(double));
 
   gridInqXvals(gridID, xvals);
   gridInqYvals(gridID, yvals);
@@ -159,100 +144,100 @@ void *Importobs(void *argument)
     grid_to_degree(units, gridsize, yvals, "grid center lat");
   }
 
-  fp = fopen(cdoStreamName(0)->args, "r");
+  FILE *fp = fopen(cdoStreamName(0)->args, "r");
   if ( fp == NULL ) { perror(cdoStreamName(0)->args); exit(EXIT_FAILURE); }
 
-  vdate = getDate(cdoStreamName(0)->args);
+  int vdate = getDate(cdoStreamName(0)->args);
   if ( vdate <= 999999 ) vdate = vdate*100 + 1;
 
-  streamID = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
-  zaxisID = zaxisCreate(ZAXIS_SURFACE, 1);
+  int zaxisID = zaxisCreate(ZAXIS_SURFACE, 1);
 
-  taxisID = taxisCreate(TAXIS_ABSOLUTE);
+  int taxisID = taxisCreate(TAXIS_ABSOLUTE);
 
-  vlistID = vlistCreate();
+  int vlistID = vlistCreate();
   vlistDefTaxis(vlistID, taxisID);
 
+  for ( i = 0; i < nvars; ++i ) data[i] = (double*) Malloc(gridsize*sizeof(double));
+
+  init_vars(vlistID, gridID, zaxisID, nvars);
+
+  streamDefVlist(streamID, vlistID);
+
+  int vdate0 = 0;
+  int vtime0 = 0;
+  //ntime = 0;
+  int tsID = 0;
+  while ( readline(fp, line, MAX_LINE_LEN) )
     {
-      for ( i = 0; i < nvars; ++i ) data[i] = (double*) malloc(gridsize*sizeof(double));
-
-      init_vars(vlistID, gridID, zaxisID, nvars);
-
-      streamDefVlist(streamID, vlistID);
-
-      vdate0 = 0;
-      vtime0 = 0;
-      //ntime = 0;
-      tsID = 0;
-      while ( readline(fp, line, MAX_LINE_LEN) )
-	{
-	  sscanf(line, "%s %s %s %g %g %g %d %g %g %g", 
-		 dummy, station, datetime, &lat, &lon, &height1, &code, &pressure, &height2, &value);
-	  sscanf(datetime, "%d_%d", &vdate, &vtime);
-
-	  if ( vdate != vdate0 || vtime != vtime0 )
-	    {
-	      if ( tsID > 0 ) write_data(streamID, vlistID, nvars, data);
-
-	      vdate0 = vdate;
-	      vtime0 = vtime;
-	      /*
-	      printf("%s %d %d %g %g %g %d %g %g %g\n", 
-		     station, vdate, vtime, lat, lon, height1, code, pressure, height2, value);	    
-	      */
-	      taxisDefVdate(taxisID, vdate);
-	      taxisDefVtime(taxisID, vtime);
-	      streamDefTimestep(streamID, tsID);
+      sscanf(line, "%s %s %s %g %g %g %d %g %g %g", 
+             dummy, station, datetime, &lat, &lon, &height1, &code, &pressure, &height2, &value);
+      sscanf(datetime, "%d_%d", &vdate, &vtime);
+
+      if ( vdate != vdate0 || vtime != vtime0 )
+        {
+          if ( tsID > 0 ) write_data(streamID, vlistID, nvars, data);
+
+          vdate0 = vdate;
+          vtime0 = vtime;
+          /*
+            printf("%s %d %d %g %g %g %d %g %g %g\n", 
+            station, vdate, vtime, lat, lon, height1, code, pressure, height2, value);	    
+          */
+          taxisDefVdate(taxisID, vdate);
+          taxisDefVtime(taxisID, vtime);
+          streamDefTimestep(streamID, tsID);
       
-	      init_data(vlistID, nvars, data);
+          init_data(vlistID, nvars, data);
 
-	      tsID++;
-	    }
+          tsID++;
+        }
 
-	  if ( lon < lonmin ) lonmin = lon;
-	  if ( lon > lonmax ) lonmax = lon;
-	  if ( lat < latmin ) latmin = lat;
-	  if ( lat > latmax ) latmax = lat;
+      if ( lon < lonmin ) lonmin = lon;
+      if ( lon > lonmax ) lonmax = lon;
+      if ( lat < latmin ) latmin = lat;
+      if ( lat > latmax ) latmax = lat;
 
-	  dy =  yvals[1] - yvals[0];
-	  for ( j = 0; j < ysize; ++j )
-	    if ( lat >= (yvals[j]-dy/2) && lat < (yvals[j]+dy/2) )  break;
+      dy =  yvals[1] - yvals[0];
+      for ( j = 0; j < ysize; ++j )
+        if ( lat >= (yvals[j]-dy/2) && lat < (yvals[j]+dy/2) )  break;
 
-	  dx =  xvals[1] - xvals[0];
-	  if ( lon < (xvals[0] - dx/2) && lon < 0 ) lon+=360;
-	  for ( i = 0; i < xsize; ++i )
-	    if ( lon >= (xvals[i]-dx/2) && lon < (xvals[i]+dx/2) )  break;
+      dx =  xvals[1] - xvals[0];
+      if ( lon < (xvals[0] - dx/2) && lon < 0 ) lon+=360;
+      for ( i = 0; i < xsize; ++i )
+        if ( lon >= (xvals[i]-dx/2) && lon < (xvals[i]+dx/2) )  break;
 	  
-	  index = -1;
-	  if ( code == 11 ) index = 0;
-	  if ( code == 17 ) index = 1;
-	  if ( code == 33 ) index = 2;
-	  if ( code == 34 ) index = 3;
-
-	  //printf("%d %d %d %g %g %g %g\n", i, j, index, dx, dy, lon, lat);
-	  if ( i < xsize && j < ysize && index >= 0 )
-	    {
-	      pstation = station;
-	      while (isalpha(*pstation)) pstation++;
-	      // printf("station %s %d\n", pstation, atoi(pstation));
-	      data[index][j*xsize+i] = value;
-	      data[    4][j*xsize+i] = height1;
-	      data[    5][j*xsize+i] = pressure;
-	      // data[    6][j*xsize+i] = atoi(pstation);
-	    }
-
-	  /*
-	  printf("%s %d %d %g %g %g %d %g %g %g\n", 
-		 station, vdate, vtime, lat, lon, height1, code, pressure, height2, value);
-	  */
-	}
-
-      write_data(streamID, vlistID, nvars, data);
-
-      for ( i = 0; i < nvars; ++i ) free(data[i]);
+      index = -1;
+      if ( code == 11 ) index = 0;
+      if ( code == 17 ) index = 1;
+      if ( code == 33 ) index = 2;
+      if ( code == 34 ) index = 3;
+
+      //printf("%d %d %d %g %g %g %g\n", i, j, index, dx, dy, lon, lat);
+      if ( i < xsize && j < ysize && index >= 0 )
+        {
+          pstation = station;
+          while (isalpha(*pstation)) pstation++;
+          // printf("station %s %d\n", pstation, atoi(pstation));
+          data[index][j*xsize+i] = value;
+          data[    4][j*xsize+i] = height1;
+          data[    5][j*xsize+i] = pressure;
+          // data[    6][j*xsize+i] = atoi(pstation);
+        }
+
+      /*
+        printf("%s %d %d %g %g %g %d %g %g %g\n", 
+        station, vdate, vtime, lat, lon, height1, code, pressure, height2, value);
+      */
     }
-  printf("lonmin=%g, lonmax=%g, latmin=%g, latmax=%g\n", lonmin, lonmax, latmin, latmax);
+
+  write_data(streamID, vlistID, nvars, data);
+
+  for ( i = 0; i < nvars; ++i ) Free(data[i]);
+
+  if ( cdoVerbose )
+    printf("lonmin=%g, lonmax=%g, latmin=%g, latmax=%g\n", lonmin, lonmax, latmin, latmax);
 
   processDefVarNum(vlistNvars(vlistID), streamID);
 
@@ -265,10 +250,10 @@ void *Importobs(void *argument)
   zaxisDestroy(zaxisID);
   taxisDestroy(taxisID);
 
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Info.c b/src/Info.c
index 4d2b585..f9ffdb8 100644
--- a/src/Info.c
+++ b/src/Info.c
@@ -259,7 +259,8 @@ void *Info(void *argument)
   char vdatestr[32], vtimestr[32];
   double missval;
   double level;
-  double arrmin = 0, arrmax = 0, arrmean = 0, arrvar = 0;
+  double arrmin = 0, arrmax = 0, arrmean = 0;
+  // double arrvar = 0;
 
   cdoInitialize(argument);
 
@@ -286,7 +287,7 @@ void *Info(void *argument)
       gridsize = vlistGridsizeMax(vlistID);
       if ( vlistNumber(vlistID) != CDI_REAL ) gridsize *= 2;
 
-      double *array = (double*) malloc(gridsize*sizeof(double));
+      double *array = (double*) Malloc(gridsize*sizeof(double));
 
       int indg = 0;
       int tsID = 0;
@@ -362,7 +363,7 @@ void *Info(void *argument)
 			{
 			  ivals   = 0;
 			  arrmean = 0;
-			  arrvar  = 0;
+			  //arrvar  = 0;
 			  arrmin  =  1.e300;
 			  arrmax  = -1.e300;
 			  for ( i = 0; i < gridsize; ++i )
@@ -372,7 +373,7 @@ void *Info(void *argument)
 				  if ( array[i] < arrmin ) arrmin = array[i];
 				  if ( array[i] > arrmax ) arrmax = array[i];
 				  arrmean += array[i];
-				  arrvar  += array[i]*array[i];
+				  //arrvar  += array[i]*array[i];
 				  ivals++;
 				}
 			    }
@@ -382,18 +383,14 @@ void *Info(void *argument)
 		      else
 			{
 			  arrmean = array[0];
-			  arrvar  = array[0];
+			  //arrvar  = array[0];
 			  arrmin  = array[0];
 			  arrmax  = array[0];
-			  /*
-#pragma omp parallel for default(none) shared(arrmin, arrmax, array, gridsize)	\
-                                       reduction(+:arrmean, arrvar)
-			  */
+                          // #pragma omp parallel for default(none) shared(arrmin, arrmax, array, gridsize) reduction(+:arrmean, arrvar)
+                          // #pragma omp simd reduction(+:arrmean) reduction(min:arrmin) reduction(max:arrmax) aligned(array:16)
 			  for ( i = 1; i < gridsize; i++ )
 			    {
-			      /* #pragma omp critical */
 			      if ( array[i] < arrmin ) arrmin = array[i];
-			      /* #pragma omp critical */
 			      if ( array[i] > arrmax ) arrmax = array[i];
 			      arrmean += array[i];
 			      // arrvar  += array[i]*array[i];
@@ -486,10 +483,10 @@ void *Info(void *argument)
 
       streamClose(streamID);
 
-      if ( array ) free(array);
+      if ( array ) Free(array);
     }
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Input.c b/src/Input.c
index 0ca9d38..64a6a04 100644
--- a/src/Input.c
+++ b/src/Input.c
@@ -68,15 +68,12 @@ static int input_darray(int nval, double *array)
 
 void *Input(void *argument)
 {
-  int INPUT, INPUTSRV, INPUTEXT;
-  int operatorID;
   int varID = 0;
   int nlevs = 1;
   int gridsize0 = 0, gridsize = 0;
   int gridID = -1, zaxisID, vdate = 0, vtime = 0;
-  int nrecs;
   int levelID;
-  int tsID, taxisID = 0;
+  int taxisID = 0;
   int streamID = -1;
   int vlistID = -1;
   int nmiss = 0;
@@ -91,11 +88,11 @@ void *Input(void *argument)
 
   cdoInitialize(argument);
 
-  INPUT    = cdoOperatorAdd("input",    0, 0, NULL);
-  INPUTSRV = cdoOperatorAdd("inputsrv", 0, 0, NULL);
-  INPUTEXT = cdoOperatorAdd("inputext", 0, 0, NULL);
+  int INPUT    = cdoOperatorAdd("input",    0, 0, NULL);
+  int INPUTSRV = cdoOperatorAdd("inputsrv", 0, 0, NULL);
+  int INPUTEXT = cdoOperatorAdd("inputext", 0, 0, NULL);
 
-  operatorID = cdoOperatorID();
+  int operatorID = cdoOperatorID();
 
   if ( operatorID == INPUT )
     {
@@ -105,9 +102,9 @@ void *Input(void *argument)
     }
 
   levels[0] = 0;
-  nrecs = 0;
+  int nrecs = 0;
 
-  tsID = 0;
+  int tsID = 0;
   while ( TRUE )
     {
       if ( operatorID == INPUT )
@@ -121,7 +118,7 @@ void *Input(void *argument)
 	  time     = 0;
 	  
 	  if ( nrecs == 0 )
-	    array = (double*) malloc(gridsize*sizeof(double));
+	    array = (double*) Malloc(gridsize*sizeof(double));
 	  
 	  cdoPrint("Enter all %d elements of record %d!", gridsize, nrecs+1);
 	  
@@ -163,7 +160,7 @@ void *Input(void *argument)
 	      if ( gridsize < 0 )
 		cdoAbort("Gridsize must not be negative!", gridsize);
 
-	      array = (double*) malloc(gridsize*sizeof(double));
+	      array = (double*) Malloc(gridsize*sizeof(double));
 
 	      gridID = gridCreate(GRID_GENERIC, gridsize);
 	    }
@@ -209,7 +206,7 @@ void *Input(void *argument)
 	      if ( gridsize < 0 )
 		cdoAbort("Gridsize must not be negative!", gridsize);
 
-	      array = (double*) malloc(gridsize*sizeof(double));
+	      array = (double*) Malloc(gridsize*sizeof(double));
 
 	      gridID = gridCreate(GRID_GENERIC, gridsize);
 	      gridDefXsize(gridID, nlon);
@@ -234,7 +231,7 @@ void *Input(void *argument)
 
 	  vlistID = vlistCreate();
 	  varID = vlistDefVar(vlistID, gridID, zaxisID, TSTEP_INSTANT);
-	  vlistDefVarCode(vlistID, varID, code);
+	  vlistDefVarParam(vlistID, varID, cdiEncodeParam(code, 255, 255));
 
 	  missval = vlistInqVarMissval(vlistID, varID);
 
@@ -273,9 +270,9 @@ void *Input(void *argument)
       vlistDestroy(vlistID);
     }
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Intgrid.c b/src/Intgrid.c
index d72abe8..7dc4493 100644
--- a/src/Intgrid.c
+++ b/src/Intgrid.c
@@ -53,10 +53,10 @@ int genThinoutGrid(int gridID1, int xinc, int yinc)
 
   if ( gridtype == GRID_GAUSSIAN || gridtype == GRID_LONLAT )
     {
-      xvals1 = (double*) malloc(nlon1*sizeof(double));
-      yvals1 = (double*) malloc(nlat1*sizeof(double));
-      xvals2 = (double*) malloc(nlon2*sizeof(double));
-      yvals2 = (double*) malloc(nlat2*sizeof(double));
+      xvals1 = (double*) Malloc(nlon1*sizeof(double));
+      yvals1 = (double*) Malloc(nlat1*sizeof(double));
+      xvals2 = (double*) Malloc(nlon2*sizeof(double));
+      yvals2 = (double*) Malloc(nlat2*sizeof(double));
       gridInqXvals(gridID1, xvals1);
       gridInqYvals(gridID1, yvals1);
 
@@ -112,19 +112,19 @@ int genBoxavgGrid(int gridID1, int xinc, int yinc)
 
   if ( gridtype == GRID_GAUSSIAN || gridtype == GRID_LONLAT )
     {
-      xvals1 = (double*) malloc(nlon1*sizeof(double));
-      yvals1 = (double*) malloc(nlat1*sizeof(double));
-      xvals2 = (double*) malloc(nlon2*sizeof(double));
-      yvals2 = (double*) malloc(nlat2*sizeof(double));
+      xvals1 = (double*) Malloc(nlon1*sizeof(double));
+      yvals1 = (double*) Malloc(nlat1*sizeof(double));
+      xvals2 = (double*) Malloc(nlon2*sizeof(double));
+      yvals2 = (double*) Malloc(nlat2*sizeof(double));
       gridInqXvals(gridID1, xvals1);
       gridInqYvals(gridID1, yvals1);
 
       if ( gridInqYbounds(gridID1, NULL) && gridInqXbounds(gridID1, NULL) )
 	{
-	  grid1_corner_lon = (double*) malloc(2*nlon1*sizeof(double));
-	  grid1_corner_lat = (double*) malloc(2*nlat1*sizeof(double));
-	  grid2_corner_lon = (double*) malloc(2*nlon2*sizeof(double));
-	  grid2_corner_lat = (double*) malloc(2*nlat2*sizeof(double));
+	  grid1_corner_lon = (double*) Malloc(2*nlon1*sizeof(double));
+	  grid1_corner_lat = (double*) Malloc(2*nlat1*sizeof(double));
+	  grid2_corner_lon = (double*) Malloc(2*nlon2*sizeof(double));
+	  grid2_corner_lat = (double*) Malloc(2*nlat2*sizeof(double));
 	  gridInqXbounds(gridID1, grid1_corner_lon);
 	  gridInqYbounds(gridID1, grid1_corner_lat);
 	}
@@ -165,8 +165,8 @@ int genBoxavgGrid(int gridID1, int xinc, int yinc)
 	  gridDefXbounds(gridID2, grid2_corner_lon);
 	  gridDefYbounds(gridID2, grid2_corner_lat);
 
-	  free(grid2_corner_lon);
-	  free(grid2_corner_lat);
+	  Free(grid2_corner_lon);
+	  Free(grid2_corner_lat);
 	}
     }
   else
@@ -204,13 +204,13 @@ void boxavg(field_t *field1, field_t *field2, int xinc, int yinc)
   nlon2 = gridInqXsize(gridID2);
   nlat2 = gridInqYsize(gridID2);
 
-  xfield1 = (double **) malloc(nlat1*sizeof(double *));
+  xfield1 = (double **) Malloc(nlat1*sizeof(double *));
 
   for ( ilat = 0; ilat < nlat1; ilat++ )
     xfield1[ilat] = array1 + ilat*nlon1;
 
 
-  xfield2 = (double **) malloc(nlat2 * sizeof(double *));
+  xfield2 = (double **) Malloc(nlat2 * sizeof(double *));
 
   for ( ilat = 0; ilat < nlat2; ilat++ )
     xfield2[ilat] = array2 + ilat*nlon2;
@@ -242,8 +242,8 @@ void boxavg(field_t *field1, field_t *field2, int xinc, int yinc)
 
   field2->nmiss = nmiss;
 
-  free(xfield2);
-  free(xfield1);
+  Free(xfield2);
+  Free(xfield1);
 }
 
 
@@ -272,12 +272,12 @@ void thinout(field_t *field1, field_t *field2, int xinc, int yinc)
   nlon2 = gridInqXsize(gridID2);
   nlat2 = gridInqYsize(gridID2);
 
-  xfield1 = (double **) malloc(nlat1*sizeof(double *));
+  xfield1 = (double **) Malloc(nlat1*sizeof(double *));
 
   for ( ilat = 0; ilat < nlat1; ilat++ )
     xfield1[ilat] = array1 + ilat*nlon1;
 
-  xfield2 = (double **) malloc(nlat2*sizeof(double *));
+  xfield2 = (double **) Malloc(nlat2*sizeof(double *));
 
   for ( ilat = 0; ilat < nlat2; ilat++ )
     xfield2[ilat] = array2 + ilat*nlon2;
@@ -300,8 +300,8 @@ void thinout(field_t *field1, field_t *field2, int xinc, int yinc)
   
   field2->nmiss = nmiss;
 
-  free(xfield2);
-  free(xfield1);
+  Free(xfield2);
+  Free(xfield1);
 }
 
 
@@ -408,10 +408,10 @@ void *Intgrid(void *argument)
   streamDefVlist(streamID2, vlistID2);
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array1   = (double*) malloc(gridsize*sizeof(double));
+  array1   = (double*) Malloc(gridsize*sizeof(double));
 
   gridsize = gridInqSize(gridID2);
-  array2   = (double*) malloc(gridsize*sizeof(double));
+  array2   = (double*) Malloc(gridsize*sizeof(double));
 
   field_init(&field1);
   field_init(&field2);
@@ -461,10 +461,10 @@ void *Intgrid(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Intgridtraj.c b/src/Intgridtraj.c
index 2c3a196..0765c6c 100644
--- a/src/Intgridtraj.c
+++ b/src/Intgridtraj.c
@@ -100,21 +100,21 @@ void *Intgridtraj(void *argument)
   nvars    = vlistNvars(vlistID1);
   nrecords = vlistNrecs(vlistID1);
 
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
-  vardata1 = (double**) malloc(nvars*sizeof(double*));
-  vardata2 = (double**) malloc(nvars*sizeof(double*));
+  vardata1 = (double**) Malloc(nvars*sizeof(double*));
+  vardata2 = (double**) Malloc(nvars*sizeof(double*));
 
   for ( varID = 0; varID < nvars; varID++ )
     {
       gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
       nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
-      vardata1[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
-      vardata2[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
+      vardata1[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
+      vardata2[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
     }
 
   gridID2 = gridCreate(GRID_TRAJECTORY, 1);
@@ -246,14 +246,14 @@ void *Intgridtraj(void *argument)
 
   for ( varID = 0; varID < nvars; varID++ )
     {
-      free(vardata1[varID]);
-      free(vardata2[varID]);
+      Free(vardata1[varID]);
+      Free(vardata2[varID]);
     }
-  free(vardata1);
-  free(vardata2);
-  if ( array )  free(array);
+  Free(vardata1);
+  Free(vardata2);
+  if ( array )  Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Intlevel.c b/src/Intlevel.c
index 200052a..ef3a61c 100644
--- a/src/Intlevel.c
+++ b/src/Intlevel.c
@@ -35,13 +35,13 @@ static
 void vert_interp_lev(int gridsize, double missval, double *vardata1, double *vardata2,
 		     int nlev2, int *lev_idx1, int *lev_idx2, double *lev_wgt1, double *lev_wgt2)
 {
-  int i, ilev;
+  int i;
   int idx1, idx2;
   double wgt1, wgt2;
   double w1, w2;
   double *var1L1, *var1L2, *var2;
 
-  for ( ilev = 0; ilev < nlev2; ++ilev )
+  for ( int ilev = 0; ilev < nlev2; ++ilev )
     {
       idx1 = lev_idx1[ilev];
       idx2 = lev_idx2[ilev];
@@ -55,7 +55,7 @@ void vert_interp_lev(int gridsize, double missval, double *vardata1, double *var
       var1L2 = vardata1+gridsize*idx2;
 
 #if defined(_OPENMP)
-#pragma omp parallel for shared(gridsize, var2, var1L1, var1L2, wgt1, wgt2, missval) private(i, w1, w2)
+#pragma omp parallel for default(none) shared(gridsize, var2, var1L1, var1L2, wgt1, wgt2, missval) private(w1, w2)
 #endif
       for ( i = 0; i < gridsize; ++i )
 	{
@@ -227,7 +227,7 @@ void *Intlevel(void *argument)
   if ( i == nzaxis ) cdoAbort("No processable variable found!");
 
   nlev1 = nlevel;
-  lev1  = (double*) malloc((nlev1+2)*sizeof(double));
+  lev1  = (double*) Malloc((nlev1+2)*sizeof(double));
   zaxisInqLevels(zaxisID1, lev1+1);
 
   lup = FALSE;
@@ -269,10 +269,10 @@ void *Intlevel(void *argument)
 
   if ( cdoVerbose ) for ( i = 0; i < nlev1+2; ++i ) printf("lev1 %d: %g\n", i, lev1[i]);
 
-  lev_idx1 = (int*) malloc(nlev2*sizeof(int));
-  lev_idx2 = (int*) malloc(nlev2*sizeof(int));
-  lev_wgt1 = (double*) malloc(nlev2*sizeof(double));
-  lev_wgt2 = (double*) malloc(nlev2*sizeof(double));
+  lev_idx1 = (int*) Malloc(nlev2*sizeof(int));
+  lev_idx2 = (int*) Malloc(nlev2*sizeof(int));
+  lev_wgt1 = (double*) Malloc(nlev2*sizeof(double));
+  lev_wgt2 = (double*) Malloc(nlev2*sizeof(double));
 
   vert_gen_weights(expol, nlev1+2, lev1, nlev2, lev2, lev_idx1, lev_idx2, lev_wgt1, lev_wgt2);
 
@@ -303,11 +303,11 @@ void *Intlevel(void *argument)
 
   nvars = vlistNvars(vlistID1);
 
-  vars      = (int*) malloc(nvars*sizeof(int));
-  vardata1  = (double**) malloc(nvars*sizeof(double*));
-  vardata2  = (double**) malloc(nvars*sizeof(double*));
-  varnmiss  = (int**) malloc(nvars*sizeof(int*));
-  varinterp = (int*) malloc(nvars*sizeof(int));
+  vars      = (int*) Malloc(nvars*sizeof(int));
+  vardata1  = (double**) Malloc(nvars*sizeof(double*));
+  vardata2  = (double**) Malloc(nvars*sizeof(double*));
+  varnmiss  = (int**) Malloc(nvars*sizeof(int*));
+  varinterp = (int*) Malloc(nvars*sizeof(int));
 
   maxlev   = nlev1 > nlev2 ? nlev1 : nlev2;
 
@@ -318,20 +318,20 @@ void *Intlevel(void *argument)
       gridsize = gridInqSize(gridID);
       nlevel   = zaxisInqSize(zaxisID);
 
-      vardata1[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
+      vardata1[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
 
       if ( zaxisID == zaxisID1 )
 	{
 	  varinterp[varID] = TRUE;
-	  vardata2[varID]  = (double*) malloc(gridsize*nlev2*sizeof(double));
-	  varnmiss[varID]  = (int*) malloc(maxlev*sizeof(int));
+	  vardata2[varID]  = (double*) Malloc(gridsize*nlev2*sizeof(double));
+	  varnmiss[varID]  = (int*) Malloc(maxlev*sizeof(int));
 	  memset(varnmiss[varID], 0, maxlev*sizeof(int));
 	}
       else
 	{
 	  varinterp[varID] = FALSE;
 	  vardata2[varID]  = vardata1[varID];
-	  varnmiss[varID]  = (int*) malloc(nlevel*sizeof(int));
+	  varnmiss[varID]  = (int*) Malloc(nlevel*sizeof(int));
 	}
     }
 
@@ -349,7 +349,6 @@ void *Intlevel(void *argument)
 	{
 	  streamInqRecord(streamID1, &varID, &levelID);
 	  gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
-	  nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	  offset   = gridsize*levelID;
 	  single1  = vardata1[varID] + offset;
 	  
@@ -405,27 +404,27 @@ void *Intlevel(void *argument)
 
   for ( varID = 0; varID < nvars; varID++ )
     {
-      free(varnmiss[varID]);
-      free(vardata1[varID]);
-      if ( varinterp[varID] ) free(vardata2[varID]);
+      Free(varnmiss[varID]);
+      Free(vardata1[varID]);
+      if ( varinterp[varID] ) Free(vardata2[varID]);
     }
 
-  free(varinterp);
-  free(varnmiss);
-  free(vardata2);
-  free(vardata1);
-  free(vars);
+  Free(varinterp);
+  Free(varnmiss);
+  Free(vardata2);
+  Free(vardata1);
+  Free(vars);
 
-  free(lev_idx1);
-  free(lev_idx2);
-  free(lev_wgt1);
-  free(lev_wgt2);
+  Free(lev_idx1);
+  Free(lev_idx2);
+  Free(lev_wgt1);
+  Free(lev_wgt2);
 
-  if (lev1) free(lev1);
+  if (lev1) Free(lev1);
 
   listDelete(flist);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Intlevel3d.c b/src/Intlevel3d.c
index c0c95ae..9d1dc1b 100644
--- a/src/Intlevel3d.c
+++ b/src/Intlevel3d.c
@@ -68,7 +68,7 @@ void *Intlevel3d(void *argument)
   cdoInitialize(argument);
 
   int INTLEVEL3D  = cdoOperatorAdd("intlevel3d",  0, 0, NULL);
-  int INTLEVELX3D = cdoOperatorAdd("intlevelx3d",  0, 0, NULL);
+  int INTLEVELX3D = cdoOperatorAdd("intlevelx3d", 0, 0, NULL);
 
   int operatorID = cdoOperatorID();
 
@@ -109,12 +109,12 @@ void *Intlevel3d(void *argument)
     nlonIn  = gridInqXsize(gridID);
     nlatIn  = gridInqYsize(gridID);
     /*
-    lonIn   = (double*) malloc(nlonIn*sizeof(double));
-    latIn   = (double*) malloc(nlatIn*sizeof(double));
+    lonIn   = (double*) Malloc(nlonIn*sizeof(double));
+    latIn   = (double*) Malloc(nlatIn*sizeof(double));
     gridInqXvals(gridID, lonIn);
     gridInqYvals(gridID, latIn);
     */
-    zlevels_in = (double*) malloc(gridsize*(nlevel+2)*sizeof(double));
+    zlevels_in = (double*) Malloc(gridsize*(nlevel+2)*sizeof(double));
     nlevi      = nlevel;   /* number of input levels for later use */
     gridsizei  = gridsize; /* horizontal gridsize of input z coordinate */
     nrecs      = streamInqTimestep(streamID0, 0);
@@ -145,12 +145,12 @@ void *Intlevel3d(void *argument)
     nlonOut = gridInqXsize(gridID);
     nlatOut = gridInqYsize(gridID);
     /*
-    lonOut  = (double*) malloc(nlonOut*sizeof(double));
-    latOut  = (double*) malloc(nlatOut*sizeof(double));
+    lonOut  = (double*) Malloc(nlonOut*sizeof(double));
+    latOut  = (double*) Malloc(nlatOut*sizeof(double));
     gridInqXvals(gridID, lonOut);
     gridInqYvals(gridID, latOut);
     */
-    zlevels_out = (double*) malloc(gridsize*nlevel*sizeof(double));
+    zlevels_out = (double*) Malloc(gridsize*nlevel*sizeof(double));
     nlevo       = nlevel;  /* number of output levels for later use */
     gridsizeo   = gridsize;/* horizontal gridsize of output z coordinate */
     nrecs       = streamInqTimestep(streamID2, 0);
@@ -270,10 +270,10 @@ void *Intlevel3d(void *argument)
   /*
    * Create weights for later interpolation - assumption: input vertical correct is constant in time
    */
-  lev_idx1 = (int*) malloc(nlevo*gridSize*sizeof(int));
-  lev_idx2 = (int*) malloc(nlevo*gridSize*sizeof(int));
-  lev_wgt1 = (double*) malloc(nlevo*gridSize*sizeof(double));
-  lev_wgt2 = (double*) malloc(nlevo*gridSize*sizeof(double));
+  lev_idx1 = (int*) Malloc(nlevo*gridSize*sizeof(int));
+  lev_idx2 = (int*) Malloc(nlevo*gridSize*sizeof(int));
+  lev_wgt1 = (double*) Malloc(nlevo*gridSize*sizeof(double));
+  lev_wgt2 = (double*) Malloc(nlevo*gridSize*sizeof(double));
 
   vert_gen_weights3d(expol, nlevi+2, gridSize, zlevels_in, nlevo, zlevels_out, lev_idx1, lev_idx2, lev_wgt1, lev_wgt2);
 
@@ -281,7 +281,7 @@ void *Intlevel3d(void *argument)
    * Copy z-axis information to output z-axis
    */
   zaxisID3 = zaxisCreate(zaxisInqType(zaxisID1), nlevo);
-  lev2 = (double*) malloc(nlevo*sizeof(double));
+  lev2 = (double*) Malloc(nlevo*sizeof(double));
   /* fill values with its indices */
   for (i=0;i<nlevo;i++)
     lev2[i] = (double) i;
@@ -311,13 +311,13 @@ void *Intlevel3d(void *argument)
 
   streamDefVlist(streamID3, vlistID3);
 
-  maxlev   = nlevi > nlevo ? nlevi : nlevo;
+  maxlev    = nlevi > nlevo ? nlevi : nlevo;
   nvars     = vlistNvars(vlistID1);
-  vars      = (int*) malloc(nvars*sizeof(int));
-  vardata1  = (double**) malloc(nvars*sizeof(double*)); /* input                                         */
-  vardata2  = (double**) malloc(nvars*sizeof(double*)); /* output                                        */
-  varnmiss  = (int**) malloc(nvars*sizeof(int*));    /* can for missing values of arbitrary variables */
-  varinterp = (int*) malloc(nvars*sizeof(int));     /* marker for variables to be interpolated       */
+  vars      = (int*) Malloc(nvars*sizeof(int));
+  vardata1  = (double**) Malloc(nvars*sizeof(double*)); /* input                                         */
+  vardata2  = (double**) Malloc(nvars*sizeof(double*)); /* output                                        */
+  varnmiss  = (int**) Malloc(nvars*sizeof(int*));    /* can for missing values of arbitrary variables */
+  varinterp = (int*) Malloc(nvars*sizeof(int));     /* marker for variables to be interpolated       */
 
   /* by default no variable should be interpolated */
   for ( i = 0; i < nvars; i++ )
@@ -332,7 +332,7 @@ void *Intlevel3d(void *argument)
 
       vlistInqVarName(vlistID1, varID, varname);
 
-      vardata1[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
+      vardata1[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
 
       /*  variabls for interpolation:
        *  * have the required vertical axis, i.e. the correct number of levels (nlevi)
@@ -344,8 +344,8 @@ void *Intlevel3d(void *argument)
           nlonIn  = gridInqXsize(gridID);
           nlatIn  = gridInqYsize(gridID);
 	  /*
-          lonIn   = (double*) malloc(nlonIn*sizeof(double));
-          latIn   = (double*) malloc(nlatIn*sizeof(double));
+          lonIn   = (double*) Malloc(nlonIn*sizeof(double));
+          latIn   = (double*) Malloc(nlatIn*sizeof(double));
           gridInqXvals(gridID, lonIn);
           gridInqYvals(gridID, latIn);
 	  */
@@ -356,14 +356,14 @@ void *Intlevel3d(void *argument)
             {
               varinterp[varID] = FALSE;
               vardata2[varID]  = vardata1[varID];
-              varnmiss[varID]  = (int*) malloc(nlevel*sizeof(int));
+              varnmiss[varID]  = (int*) Malloc(nlevel*sizeof(int));
               if ( cdoVerbose ) cdoPrint("Ignore variable %s with %d levels\n",varname,nlevel);
             }
           else
             {
               varinterp[varID] = TRUE;
-              vardata2[varID]  = (double*) malloc(gridsize*nlevo*sizeof(double));
-              varnmiss[varID]  = (int*) malloc(maxlev*sizeof(int));
+              vardata2[varID]  = (double*) Malloc(gridsize*nlevo*sizeof(double));
+              varnmiss[varID]  = (int*) Malloc(maxlev*sizeof(int));
               memset(varnmiss[varID], 0, maxlev*sizeof(int));
             }
         }
@@ -371,7 +371,7 @@ void *Intlevel3d(void *argument)
         {
           varinterp[varID] = FALSE;
           vardata2[varID]  = vardata1[varID];
-          varnmiss[varID]  = (int*) malloc(nlevel*sizeof(int));
+          varnmiss[varID]  = (int*) Malloc(nlevel*sizeof(int));
           if ( cdoVerbose ) cdoPrint("Ignore variable %s with %d levels\n",varname,nlevel);
         }
       }
@@ -466,22 +466,22 @@ void *Intlevel3d(void *argument)
   nvars     = vlistNvars(vlistID1);
   for ( varID = 0; varID < nvars; varID++ )
     {
-      free(varnmiss[varID]);
-      free(vardata1[varID]);
-      if ( varinterp[varID] ) free(vardata2[varID]);
+      Free(varnmiss[varID]);
+      Free(vardata1[varID]);
+      if ( varinterp[varID] ) Free(vardata2[varID]);
     } 
 
 
-  free(varinterp);
-  free(varnmiss);
-  free(vardata2);
-  free(vardata1);
-  free(vars);
+  Free(varinterp);
+  Free(varnmiss);
+  Free(vardata2);
+  Free(vardata1);
+  Free(vars);
 
-  free(lev_idx1);
-  free(lev_idx2);
-  free(lev_wgt1);
-  free(lev_wgt2);
+  Free(lev_idx1);
+  Free(lev_idx2);
+  Free(lev_wgt1);
+  Free(lev_wgt2);
 
   streamClose(streamID0);
   streamClose(streamID1);
@@ -492,5 +492,5 @@ void *Intlevel3d(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Intntime.c b/src/Intntime.c
index ee5efab..e36383a 100644
--- a/src/Intntime.c
+++ b/src/Intntime.c
@@ -68,25 +68,25 @@ void *Intntime(void *argument)
   nvars    = vlistNvars(vlistID1);
   nrecords = vlistNrecs(vlistID1);
 
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
-  nmiss1   = (int **) malloc(nvars*sizeof(int *));
-  nmiss2   = (int **) malloc(nvars*sizeof(int *));
-  vardata1 = (double **) malloc(nvars*sizeof(double *));
-  vardata2 = (double **) malloc(nvars*sizeof(double *));
+  nmiss1   = (int **) Malloc(nvars*sizeof(int *));
+  nmiss2   = (int **) Malloc(nvars*sizeof(int *));
+  vardata1 = (double **) Malloc(nvars*sizeof(double *));
+  vardata2 = (double **) Malloc(nvars*sizeof(double *));
 
   for ( varID = 0; varID < nvars; varID++ )
     {
       gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
       nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
-      nmiss1[varID]   = (int*) malloc(nlevel*sizeof(int));
-      nmiss2[varID]   = (int*) malloc(nlevel*sizeof(int));
-      vardata1[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
-      vardata2[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
+      nmiss1[varID]   = (int*) Malloc(nlevel*sizeof(int));
+      nmiss2[varID]   = (int*) Malloc(nlevel*sizeof(int));
+      vardata1[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
+      vardata2[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
     }
 
   taxisID1 = vlistInqTaxis(vlistID1);
@@ -237,30 +237,30 @@ void *Intntime(void *argument)
 	  vardata2[varID] = vardatap;
 	}
 
-      vdate1 = vdate2;
-      vtime1 = vtime2;
+      //vdate1 = vdate2;
+      //vtime1 = vtime2;
       juldate1 = juldate2;
     }
 
   for ( varID = 0; varID < nvars; varID++ )
     {
-      free(nmiss1[varID]);
-      free(nmiss2[varID]);
-      free(vardata1[varID]);
-      free(vardata2[varID]);
+      Free(nmiss1[varID]);
+      Free(nmiss2[varID]);
+      Free(vardata1[varID]);
+      Free(vardata2[varID]);
     }
 
-  free(nmiss1);
-  free(nmiss2);
-  free(vardata1);
-  free(vardata2);
+  Free(nmiss1);
+  Free(nmiss2);
+  Free(vardata1);
+  Free(vardata2);
 
-  if ( array )  free(array);
+  if ( array )  Free(array);
 
   streamClose(streamID2);
   streamClose(streamID1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Inttime.c b/src/Inttime.c
index a341d25..d61dfb9 100644
--- a/src/Inttime.c
+++ b/src/Inttime.c
@@ -111,25 +111,25 @@ void *Inttime(void *argument)
   nvars    = vlistNvars(vlistID1);
   nrecords = vlistNrecs(vlistID1);
 
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
-  nmiss1   = (int **) malloc(nvars*sizeof(int *));
-  nmiss2   = (int **) malloc(nvars*sizeof(int *));
-  vardata1 = (double **) malloc(nvars*sizeof(double *));
-  vardata2 = (double **) malloc(nvars*sizeof(double *));
+  nmiss1   = (int **) Malloc(nvars*sizeof(int *));
+  nmiss2   = (int **) Malloc(nvars*sizeof(int *));
+  vardata1 = (double **) Malloc(nvars*sizeof(double *));
+  vardata2 = (double **) Malloc(nvars*sizeof(double *));
 
   for ( varID = 0; varID < nvars; varID++ )
     {
       gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
       nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
-      nmiss1[varID]   = (int*) malloc(nlevel*sizeof(int));
-      nmiss2[varID]   = (int*) malloc(nlevel*sizeof(int));
-      vardata1[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
-      vardata2[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
+      nmiss1[varID]   = (int*) Malloc(nlevel*sizeof(int));
+      nmiss2[varID]   = (int*) Malloc(nlevel*sizeof(int));
+      vardata1[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
+      vardata2[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
     }
 
   taxisID1 = vlistInqTaxis(vlistID1);
@@ -309,18 +309,18 @@ void *Inttime(void *argument)
 
   for ( varID = 0; varID < nvars; varID++ )
     {
-      free(nmiss1[varID]);
-      free(nmiss2[varID]);
-      free(vardata1[varID]);
-      free(vardata2[varID]);
+      Free(nmiss1[varID]);
+      Free(nmiss2[varID]);
+      Free(vardata1[varID]);
+      Free(vardata2[varID]);
     }
 
-  free(nmiss1);
-  free(nmiss2);
-  free(vardata1);
-  free(vardata2);
+  Free(nmiss1);
+  Free(nmiss2);
+  Free(vardata1);
+  Free(vardata2);
 
-  if ( array )  free(array);
+  if ( array )  Free(array);
 
   if ( streamID2 != -1 ) streamClose(streamID2);
   streamClose(streamID1);
@@ -329,5 +329,5 @@ void *Inttime(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Intyear.c b/src/Intyear.c
index f2c2601..2e4c4d1 100644
--- a/src/Intyear.c
+++ b/src/Intyear.c
@@ -60,7 +60,7 @@ void *Intyear(void *argument)
 
   iyears = (int *) listArrayPtr(ilist);
 
-  streamIDs = (int*) malloc(nyears*sizeof(int));
+  streamIDs = (int*) Malloc(nyears*sizeof(int));
 
   streamID1 = streamOpenRead(cdoStreamName(0));
   streamID2 = streamOpenRead(cdoStreamName(1));
@@ -72,9 +72,9 @@ void *Intyear(void *argument)
   vlistCompare(vlistID1, vlistID2, CMP_ALL);
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize*sizeof(double));
-  array3 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
+  array2 = (double*) Malloc(gridsize*sizeof(double));
+  array3 = (double*) Malloc(gridsize*sizeof(double));
 
   taxisID1 = vlistInqTaxis(vlistID1);
   taxisID2 = vlistInqTaxis(vlistID2);
@@ -189,15 +189,15 @@ void *Intyear(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array3 )  free(array3);
-  if ( array2 )  free(array2);
-  if ( array1 )  free(array1);
+  if ( array3 )  Free(array3);
+  if ( array2 )  Free(array2);
+  if ( array1 )  Free(array1);
 
-  free(streamIDs);
+  Free(streamIDs);
 
   listDelete(ilist);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Invert.c b/src/Invert.c
index 9744af2..2d519ad 100644
--- a/src/Invert.c
+++ b/src/Invert.c
@@ -66,8 +66,8 @@ void invertLonDes(int vlistID)
 	  else
             size = nlon;
 
-	  xv1 = (double*) malloc(size*sizeof(double));
-	  xv2 = (double*) malloc(size*sizeof(double));
+	  xv1 = (double*) Malloc(size*sizeof(double));
+	  xv2 = (double*) Malloc(size*sizeof(double));
 
 	  gridInqXvals(gridID1, xv1);
 
@@ -85,8 +85,8 @@ void invertLonDes(int vlistID)
 
 	  gridDefXvals(gridID2, xv2);
 
-	  if ( xv2 ) free(xv2);
-	  if ( xv1 ) free(xv1);
+	  if ( xv2 ) Free(xv2);
+	  if ( xv1 ) Free(xv1);
 	}
 
       if ( gridInqXbounds(gridID1, NULL) )
@@ -101,8 +101,8 @@ void invertLonDes(int vlistID)
 	  else
             size = nv*nlon;
 
-	  xb1 = (double*) malloc(size*sizeof(double));
-	  xb2 = (double*) malloc(size*sizeof(double));
+	  xb1 = (double*) Malloc(size*sizeof(double));
+	  xb2 = (double*) Malloc(size*sizeof(double));
 
 	  gridInqXbounds(gridID1, xb1);
 
@@ -124,8 +124,8 @@ void invertLonDes(int vlistID)
 
 	  gridDefXbounds(gridID2, xb2);
 
-	  if ( xb2 ) free(xb2);
-	  if ( xb1 ) free(xb1);
+	  if ( xb2 ) Free(xb2);
+	  if ( xb1 ) Free(xb1);
 	}
 
       vlistChangeGrid(vlistID, gridID1, gridID2);
@@ -165,8 +165,8 @@ void invertLatDes(int vlistID)
 	  else
             size = nlat;
 
-	  yv1 = (double*) malloc(size*sizeof(double));
-	  yv2 = (double*) malloc(size*sizeof(double));
+	  yv1 = (double*) Malloc(size*sizeof(double));
+	  yv2 = (double*) Malloc(size*sizeof(double));
 
 
 	  if ( gridtype == GRID_CURVILINEAR )
@@ -197,8 +197,8 @@ void invertLatDes(int vlistID)
 	      gridDefYvals(gridID2, yv2);
 	    }
 
-	  if ( yv2 ) free(yv2);
-	  if ( yv1 ) free(yv1);
+	  if ( yv2 ) Free(yv2);
+	  if ( yv1 ) Free(yv1);
 	}
 
       if ( gridInqYbounds(gridID1, NULL) )
@@ -213,8 +213,8 @@ void invertLatDes(int vlistID)
 	  else
             size = nv*nlat;
 
-	  yb1 = (double*) malloc(size*sizeof(double));
-	  yb2 = (double*) malloc(size*sizeof(double));
+	  yb1 = (double*) Malloc(size*sizeof(double));
+	  yb2 = (double*) Malloc(size*sizeof(double));
 
 	  gridInqYbounds(gridID1, yb1);
 
@@ -236,8 +236,8 @@ void invertLatDes(int vlistID)
 
 	  gridDefYbounds(gridID2, yb2);
 
-	  if ( yb2 ) free(yb2);
-	  if ( yb1 ) free(yb1);
+	  if ( yb2 ) Free(yb2);
+	  if ( yb1 ) Free(yb1);
 	}
 
       vlistChangeGrid(vlistID, gridID1, gridID2);
@@ -256,8 +256,8 @@ void invertLonData(double *array1, double *array2, int gridID1)
 
   if ( nlat > 0 )
     {
-      field1 = (double **) malloc(nlat*sizeof(double *));
-      field2 = (double **) malloc(nlat*sizeof(double *));
+      field1 = (double **) Malloc(nlat*sizeof(double *));
+      field2 = (double **) Malloc(nlat*sizeof(double *));
   
       for ( ilat = 0; ilat < nlat; ilat++ )
 	{
@@ -269,8 +269,8 @@ void invertLonData(double *array1, double *array2, int gridID1)
 	for ( ilon = 0; ilon < nlon; ilon++ )
 	  field2[ilat][nlon-ilon-1] = field1[ilat][ilon];
   
-      if ( field1 ) free(field1);
-      if ( field2 ) free(field2);
+      if ( field1 ) Free(field1);
+      if ( field2 ) Free(field2);
     }
   else
     {
@@ -290,8 +290,8 @@ void invertLatData(double *array1, double *array2, int gridID1)
 
   if ( nlat > 0 )
     {
-      field1 = (double **) malloc(nlat*sizeof(double *));
-      field2 = (double **) malloc(nlat*sizeof(double *));
+      field1 = (double **) Malloc(nlat*sizeof(double *));
+      field2 = (double **) Malloc(nlat*sizeof(double *));
   
       for ( ilat = 0; ilat < nlat; ilat++ )
 	{
@@ -302,8 +302,8 @@ void invertLatData(double *array1, double *array2, int gridID1)
       for ( ilat = 0; ilat < nlat; ilat++ )
 	memcpy(field2[nlat-ilat-1], field1[ilat], nlon*sizeof(double));
       
-      if ( field1 ) free(field1);
-      if ( field2 ) free(field2);
+      if ( field1 ) Free(field1);
+      if ( field2 ) Free(field2);
     }
   else
     {
@@ -355,8 +355,8 @@ void *Invert(void *argument)
 
   int gridsize = vlistGridsizeMax(vlistID1);
 
-  double *array1 = (double*) malloc(gridsize*sizeof(double));
-  double *array2 = (double*) malloc(gridsize*sizeof(double));
+  double *array1 = (double*) Malloc(gridsize*sizeof(double));
+  double *array2 = (double*) Malloc(gridsize*sizeof(double));
 
   int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -394,10 +394,10 @@ void *Invert(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array1 ) free(array1);
-  if ( array2 ) free(array2);
+  if ( array1 ) Free(array1);
+  if ( array2 ) Free(array2);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Invertlev.c b/src/Invertlev.c
index 03ba316..a1fcb18 100644
--- a/src/Invertlev.c
+++ b/src/Invertlev.c
@@ -28,61 +28,56 @@
 #include "error.h"
 
 
-
 static
 void invertLevDes(int vlistID)
 {
-  int index, nzaxis;
-  int zaxisID1, zaxisID2;
-  int nlev;
-  int ilev;
-  int zaxistype;
-  double *yv1, *yv2;
-  double *yb1, *yb2;
-
-  nzaxis = vlistNzaxis(vlistID);
-  for ( index = 0; index < nzaxis; index++ )
+  int nzaxis = vlistNzaxis(vlistID);
+  for ( int index = 0; index < nzaxis; index++ )
     {
-      zaxisID1 = vlistZaxis(vlistID, index);
-      zaxisID2 = zaxisDuplicate(zaxisID1);
-
-      zaxistype = zaxisInqType(zaxisID1);
-
-      nlev = zaxisInqSize(zaxisID1);
+      int zaxisID1 = vlistZaxis(vlistID, index);
+      int zaxisID2 = zaxisDuplicate(zaxisID1);
+      int zaxistype = zaxisInqType(zaxisID1);
 
-      if ( nlev < 2 || zaxistype == ZAXIS_HYBRID || zaxistype == ZAXIS_HYBRID_HALF ) continue;
+      int nlev = zaxisInqSize(zaxisID1);
+      if ( nlev <= 1 ) continue;
 
       /* if ( zaxisInqLevels(zaxisID1, NULL) ) */
 	{
-
-	  yv1 = (double*) malloc(nlev*sizeof(double));
-	  yv2 = (double*) malloc(nlev*sizeof(double));
-
+	  double yv1[nlev], yv2[nlev];
 	  zaxisInqLevels(zaxisID1, yv1);
-	  for ( ilev = 0; ilev < nlev; ++ilev ) yv2[nlev-ilev-1] = yv1[ilev];
+	  for ( int ilev = 0; ilev < nlev; ++ilev ) yv2[nlev-ilev-1] = yv1[ilev];
 	  zaxisDefLevels(zaxisID2, yv2);
-
-	  if ( yv2 ) free(yv2);
-	  if ( yv1 ) free(yv1);
 	}
 
       if ( zaxisInqLbounds(zaxisID1, NULL) && zaxisInqUbounds(zaxisID1, NULL) )
 	{
-	  yb1 = (double*) malloc(nlev*sizeof(double));
-	  yb2 = (double*) malloc(nlev*sizeof(double));
-
+	  double yb1[nlev], yb2[nlev];
 	  zaxisInqLbounds(zaxisID1, yb1);
-	  for ( ilev = 0; ilev < nlev; ++ilev ) yb2[nlev-ilev-1] = yb1[ilev];
+	  for ( int ilev = 0; ilev < nlev; ++ilev ) yb2[nlev-ilev-1] = yb1[ilev];
 	  zaxisDefLbounds(zaxisID2, yb2);
 
 	  zaxisInqUbounds(zaxisID1, yb1);
-	  for ( ilev = 0; ilev < nlev; ++ilev ) yb2[nlev-ilev-1] = yb1[ilev];
+	  for ( int ilev = 0; ilev < nlev; ++ilev ) yb2[nlev-ilev-1] = yb1[ilev];
 	  zaxisDefUbounds(zaxisID2, yb2);
-
-	  if ( yb2 ) free(yb2);
-	  if ( yb1 ) free(yb1);
 	}
 
+      if ( zaxistype == ZAXIS_HYBRID || zaxistype == ZAXIS_HYBRID_HALF )
+        {
+          int vctsize = zaxisInqVctSize(zaxisID1);		
+          if ( vctsize && vctsize%2 == 0 )
+            {
+              double vct1[vctsize];
+              double vct2[vctsize];
+              zaxisInqVct(zaxisID1, vct1);
+              for ( int i = 0; i < vctsize/2; ++i )
+                {
+                  vct2[vctsize/2-1-i] = vct1[i];
+                  vct2[vctsize-1-i]   = vct1[vctsize/2+i];
+                }
+              zaxisDefVct(zaxisID2, vctsize, vct2);
+            }
+        }
+
       vlistChangeZaxis(vlistID, zaxisID1, zaxisID2);
     }
 }
@@ -94,7 +89,7 @@ void *Invertlev(void *argument)
   int recID, varID, levelID;
   int nmiss;
   int nlev, nlevel;
-  int gridID, zaxisID, zaxistype, offset;
+  int gridID, zaxisID, offset;
   int lcopy = FALSE;
   int linvert = FALSE;
 
@@ -102,7 +97,7 @@ void *Invertlev(void *argument)
 
   if ( UNCHANGED_RECORD ) lcopy = TRUE;
 
-  cdoOperatorAdd("invertlev",     func_all, 0, NULL);
+  cdoOperatorAdd("invertlev", func_all, 0, NULL);
 
   int operatorID = cdoOperatorID();
   int operfunc   = cdoOperatorF1(operatorID);
@@ -124,22 +119,21 @@ void *Invertlev(void *argument)
 
   int gridsize = vlistGridsizeMax(vlistID1);
 
-  double *array = (double*) malloc(gridsize*sizeof(double));
+  double *array = (double*) Malloc(gridsize*sizeof(double));
 
   int nvars = vlistNvars(vlistID1);
 
-  double **vardata  = (double**) malloc(nvars*sizeof(double*));
-  int **varnmiss = (int**) malloc(nvars*sizeof(int*));
+  double **vardata  = (double**) Malloc(nvars*sizeof(double*));
+  int **varnmiss = (int**) Malloc(nvars*sizeof(int*));
 
   for ( varID = 0; varID < nvars; varID++ )
     {
       gridID    = vlistInqVarGrid(vlistID1, varID);
       zaxisID   = vlistInqVarZaxis(vlistID1, varID);
       gridsize  = gridInqSize(gridID);
-      zaxistype = zaxisInqType(zaxisID);
       nlev      = zaxisInqSize(zaxisID);
 
-      if ( nlev < 2 || zaxistype == ZAXIS_HYBRID || zaxistype == ZAXIS_HYBRID_HALF )
+      if ( nlev <= 1 )
 	{
 	  vardata[varID]  = NULL;
 	  varnmiss[varID] = NULL;
@@ -147,8 +141,8 @@ void *Invertlev(void *argument)
       else
 	{
 	  linvert = TRUE;
-	  vardata[varID]  = (double*) malloc(gridsize*nlev*sizeof(double));
-	  varnmiss[varID] = (int*) malloc(nlev*sizeof(int));
+	  vardata[varID]  = (double*) Malloc(gridsize*nlev*sizeof(double));
+	  varnmiss[varID] = (int*) Malloc(nlev*sizeof(int));
 	}
     }
 
@@ -168,9 +162,7 @@ void *Invertlev(void *argument)
 	  if ( vardata[varID] )
 	    {    
 	      gridID   = vlistInqVarGrid(vlistID1, varID);
-	      zaxisID  = vlistInqVarZaxis(vlistID1, varID);
 	      gridsize = gridInqSize(gridID);
-	      nlevel   = zaxisInqSize(zaxisID);
 	      offset   = gridsize*levelID;
 
 	      streamReadRecord(streamID1, vardata[varID]+offset, &nmiss);
@@ -203,8 +195,7 @@ void *Invertlev(void *argument)
 		{
 		  streamDefRecord(streamID2, varID, levelID);
 
-		  offset   = gridsize*(nlevel-levelID-1);
-
+		  offset = gridsize*(nlevel-levelID-1);
 		  nmiss = varnmiss[varID][nlevel-levelID-1];
 
 		  streamWriteRecord(streamID2, vardata[varID]+offset, nmiss);
@@ -218,21 +209,21 @@ void *Invertlev(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   for ( varID = 0; varID < nvars; varID++ )
     {
       if ( vardata[varID] )
 	{
-	  free(varnmiss[varID]);
-	  free(vardata[varID]);
+	  Free(varnmiss[varID]);
+	  Free(vardata[varID]);
 	}
     }
 
-  free(varnmiss);
-  free(vardata);
+  Free(varnmiss);
+  Free(vardata);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Isosurface.c b/src/Isosurface.c
index 18ea01a..777a7e9 100644
--- a/src/Isosurface.c
+++ b/src/Isosurface.c
@@ -135,7 +135,7 @@ void *Isosurface(void *argument)
   if ( i == nzaxis ) cdoAbort("No processable variable found!");
 
   nlev1 = nlevel;
-  lev1  = (double*) malloc((nlev1)*sizeof(double));
+  lev1  = (double*) Malloc((nlev1)*sizeof(double));
   zaxisInqLevels(zaxisID1, lev1);
 
   zaxisIDsfc = zaxisCreate(ZAXIS_SURFACE, 1);
@@ -150,13 +150,13 @@ void *Isosurface(void *argument)
   gridsize = vlistGridsizeMax(vlistID1);
 
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   nvars = vlistNvars(vlistID1);
 
-  liso  = (int*)     malloc(nvars*sizeof(int));
-  vars  = (int*)     malloc(nvars*sizeof(int));
-  vars1 = (field_t*) malloc(nvars*sizeof(field_t));
+  liso  = (int*)     Malloc(nvars*sizeof(int));
+  vars  = (int*)     Malloc(nvars*sizeof(int));
+  vars1 = (field_t*) Malloc(nvars*sizeof(field_t));
 
   for ( varID = 0; varID < nvars; varID++ )
     {
@@ -176,7 +176,7 @@ void *Isosurface(void *argument)
       vars1[varID].zaxis   = zaxisID;
       vars1[varID].nmiss   = 0;
       vars1[varID].missval = missval;
-      vars1[varID].ptr     = (double*) malloc(gridsize*nlevel*sizeof(double));
+      vars1[varID].ptr     = (double*) Malloc(gridsize*nlevel*sizeof(double));
     }
 
   tsID = 0;
@@ -196,7 +196,6 @@ void *Isosurface(void *argument)
 	{
 	  streamInqRecord(streamID1, &varID, &levelID);
 	  gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
-	  nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	  offset   = gridsize*levelID;
 	  single   = vars1[varID].ptr + offset;
 	  
@@ -241,14 +240,14 @@ void *Isosurface(void *argument)
       tsID++;
     }
 
-  for ( varID = 0; varID < nvars; varID++ ) free(vars1[varID].ptr);
-  free(vars1);
+  for ( varID = 0; varID < nvars; varID++ ) Free(vars1[varID].ptr);
+  Free(vars1);
 
-  free(vars);
-  free(liso);
-  if (lev1) free(lev1);
+  Free(vars);
+  Free(liso);
+  if (lev1) Free(lev1);
 
-  free(field.ptr);
+  Free(field.ptr);
 
   streamClose(streamID2);
   streamClose(streamID1);
@@ -257,5 +256,5 @@ void *Isosurface(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Kvl.c b/src/Kvl.c
index f8c3845..0e05ff0 100644
--- a/src/Kvl.c
+++ b/src/Kvl.c
@@ -55,7 +55,7 @@ int read_cmor_table(const char *filename)
 
   kvlDelete(kvlist);
 
-  return (0);
+  return 0;
 }
 
 static
@@ -139,7 +139,7 @@ int conv_cmor_table(const char *filename)
 		   strncmp("comment", ename, len)         == 0 )
 		printf("  %-15s = \"%.*s\"\n", ename, vlen, ovalue);
 
-	      free(ovalue);
+	      Free(ovalue);
 	    }
 	  if ( hasmissval ) printf("  %-15s = %g\n", "missing_value", missval);
 	  printf("/\n");
@@ -148,7 +148,7 @@ int conv_cmor_table(const char *filename)
 
   kvlDelete(kvlist);
 
-  return (0);
+  return 0;
 }
 
 
@@ -196,5 +196,5 @@ void *Kvl(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Log.c b/src/Log.c
index e2e7a81..83933ca 100644
--- a/src/Log.c
+++ b/src/Log.c
@@ -68,5 +68,5 @@ void *Log(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Maggraph.c b/src/Maggraph.c
index cb732a5..e801d44 100644
--- a/src/Maggraph.c
+++ b/src/Maggraph.c
@@ -170,7 +170,7 @@ void maggraph(const char *plotfile, const char *varname,const char *varunits, lo
 	  mag_setc ("output_format", DEVICE );
 	}
 	
-      free( split_str );
+      Free( split_str );
     }
 
   if ( DBG )
@@ -256,20 +256,20 @@ void maggraph(const char *plotfile, const char *varname,const char *varunits, lo
   if ( stat == TRUE )
     {
 	/* if all files are of same number of steps, only one date_time_str array is being used */
-        date_time_str[0] = (char **) malloc( ntime_steps*sizeof(char *)); 
+        date_time_str[0] = (char **) Malloc( ntime_steps*sizeof(char *)); 
 	
-	date_time   = (double*) malloc( ntime_steps*sizeof(double));
-	mean_val    = (double*) malloc( ntime_steps*sizeof(double));
-	std_dev_val = (double*) malloc( ntime_steps*sizeof(double));
-	spread_min  = (double*) malloc( ntime_steps*sizeof(double));
-	spread_max  = (double*) malloc( ntime_steps*sizeof(double));
+	date_time   = (double*) Malloc( ntime_steps*sizeof(double));
+	mean_val    = (double*) Malloc( ntime_steps*sizeof(double));
+	std_dev_val = (double*) Malloc( ntime_steps*sizeof(double));
+	spread_min  = (double*) Malloc( ntime_steps*sizeof(double));
+	spread_max  = (double*) Malloc( ntime_steps*sizeof(double));
 	
 	for ( tsID = 0; tsID < ntime_steps; ++tsID )
 	  {
 	    date_time[tsID] = tsID+1;
 	    date2str(vdate[0][tsID], vdatestr, sizeof(vdatestr));
 	    time2str(vtime[0][tsID], vtimestr, sizeof(vtimestr));
-	    date_time_str[0][tsID] = (char*) malloc(256);
+	    date_time_str[0][tsID] = (char*) Malloc(256);
 	    sprintf(date_time_str[0][tsID], "%s %s", vdatestr, vtimestr);
 	    mean_val[tsID] = 0.;
 	    std_dev_val[tsID] = 0.;
@@ -358,8 +358,8 @@ void maggraph(const char *plotfile, const char *varname,const char *varunits, lo
 	{
 	  if ( DBG )
 	    fprintf(stderr,"FILE  %ld\n", fileID );
-	  date_time             = (double*) malloc( nts[fileID]*sizeof(double));
-	  date_time_str[fileID] = (char **) malloc( nts[fileID]*sizeof(char *));
+	  date_time             = (double*) Malloc( nts[fileID]*sizeof(double));
+	  date_time_str[fileID] = (char **) Malloc( nts[fileID]*sizeof(char *));
 	  
 	  for ( tsID = 0; tsID <  nts[fileID]; ++tsID )
 	    {
@@ -367,7 +367,7 @@ void maggraph(const char *plotfile, const char *varname,const char *varunits, lo
 	      date2str(vdate[fileID][tsID], vdatestr, sizeof(vdatestr));
 	      time2str(vtime[fileID][tsID], vtimestr, sizeof(vtimestr));
 	      
-	      date_time_str[fileID][tsID] = (char*) malloc(256);
+	      date_time_str[fileID][tsID] = (char*) Malloc(256);
 	      sprintf(date_time_str[fileID][tsID], "%s %s", vdatestr, vtimestr);
 	      if ( DBG )
 		fprintf( stderr,"%s %s %s\n", vdatestr, vtimestr, date_time_str[fileID][tsID] );
@@ -377,7 +377,7 @@ void maggraph(const char *plotfile, const char *varname,const char *varunits, lo
 	      if( datatab[fileID][tsID] > max_val )
 	        max_val = datatab[ fileID ][ tsID ];	
 	    }
-	  free( date_time );
+	  Free( date_time );
 	  
 	  if( fileID == 0 )
 	    {
@@ -461,7 +461,7 @@ void maggraph(const char *plotfile, const char *varname,const char *varunits, lo
     num_years  = atoi( split_str[0] );
     num_months = atoi( split_str[1] );
     num_days   = atoi( split_str[2] );
-    free( split_str  );
+    Free( split_str  );
     
     split_str_count = StringSplitWithSeperator( min_date_time_str, sep_char, &split_str );
     num_years -= atoi( split_str[0] );
@@ -478,7 +478,7 @@ void maggraph(const char *plotfile, const char *varname,const char *varunits, lo
 	else if( num_months == 1 )
 	  num_days += ( 31- atoi( split_str[2] ) );
       }
-    free( split_str );
+    Free( split_str );
     
     if( DBG )
       fprintf(stderr," %d %d\n", num_years, num_months );
@@ -668,7 +668,7 @@ void maggraph(const char *plotfile, const char *varname,const char *varunits, lo
     }
   
   
-  lines[0] = (char*) malloc(1024);
+  lines[0] = (char*) Malloc(1024);
   /* To be obtained from Meta Data */
   /*sprintf( lines[0],"%s","ExpID : " );*/ 
   /*sprintf( lines[0],"%sxxxx  Variable : %s[%s]",lines[0], varname, varunits );*/
@@ -691,11 +691,11 @@ void maggraph(const char *plotfile, const char *varname,const char *varunits, lo
 
   if ( stat == TRUE )
     {
-      free( date_time );
-      free( mean_val );
-      free( std_dev_val );
-      free( spread_min );
-      free( spread_max );
+      Free( date_time );
+      Free( mean_val );
+      Free( std_dev_val );
+      Free( spread_min );
+      Free( spread_max );
     }
   
   
@@ -722,7 +722,7 @@ int compareDateOrTimeStr( char *datetimestr1, char *datetimestr2, char *sep_char
     split_str_count2 = StringSplitWithSeperator( datetimestr2, sep_char, &split_str2 );
   else
     {
-      free( split_str1 );
+      Free( split_str1 );
       return -999;
     }
   
@@ -734,13 +734,13 @@ int compareDateOrTimeStr( char *datetimestr1, char *datetimestr2, char *sep_char
     }
   else
     {
-      free( split_str1 );
-      free( split_str2 );
+      Free( split_str1 );
+      Free( split_str2 );
       return -999;
     }
   
-  free( split_str1 );
-  free( split_str2 );
+  Free( split_str1 );
+  Free( split_str2 );
   
   for ( i = 0;i < 3 ; i++ )
     {
@@ -824,10 +824,10 @@ void *Maggraph(void *argument)
        fprintf( stderr," files %s\n",ofilename );
     }
 	
-  datatab = (double **) malloc(nfiles*sizeof(double *));
-  vdate   = (int **) malloc(nfiles*sizeof(int *));
-  vtime   = (int **) malloc(nfiles*sizeof(int *));
-  nts     = (long*) malloc(nfiles*sizeof(long));
+  datatab = (double **) Malloc(nfiles*sizeof(double *));
+  vdate   = (int **) Malloc(nfiles*sizeof(int *));
+  vtime   = (int **) Malloc(nfiles*sizeof(int *));
+  nts     = (long*) Malloc(nfiles*sizeof(long));
   
   for ( fileID = 0; fileID < nfiles; fileID++ )
     {
@@ -876,9 +876,9 @@ void *Maggraph(void *argument)
 	  if ( tsID == 0 )
 	    {
 	      nts_alloc += NINC_ALLOC;
-	      datatab[ fileID ] = (double*) malloc( nts_alloc*sizeof(double));
-	      vdate[ fileID ]   = (int*) malloc(  nts_alloc*sizeof(int));
-	      vtime[ fileID ]   = (int*) malloc(  nts_alloc*sizeof(int));
+	      datatab[ fileID ] = (double*) Malloc( nts_alloc*sizeof(double));
+	      vdate[ fileID ]   = (int*) Malloc(  nts_alloc*sizeof(int));
+	      vtime[ fileID ]   = (int*) Malloc(  nts_alloc*sizeof(int));
 	    }
 		
 	  nts[ fileID ]++;
@@ -886,9 +886,9 @@ void *Maggraph(void *argument)
 	  if ( nts[ fileID ] > nts_alloc )
 	    {
 	      nts_alloc += NINC_ALLOC;
-	      datatab[ fileID ] = (double*) realloc(datatab[fileID], nts_alloc*sizeof(double));
-	      vdate[ fileID ]   = (int*) realloc(vdate[fileID], nts_alloc*sizeof(int));
-	      vtime[ fileID ]   = (int*) realloc(vtime[fileID], nts_alloc*sizeof(int));
+	      datatab[ fileID ] = (double*) Realloc(datatab[fileID], nts_alloc*sizeof(double));
+	      vdate[ fileID ]   = (int*) Realloc(vdate[fileID], nts_alloc*sizeof(int));
+	      vtime[ fileID ]   = (int*) Realloc(vtime[fileID], nts_alloc*sizeof(int));
 	    }
 	  
 	  streamInqRecord( streamID, &varID, &levelID );
@@ -939,18 +939,18 @@ void *Maggraph(void *argument)
 
   for ( fileID = 0; fileID < nfiles; fileID++ )
     {
-      if ( datatab[fileID] ) free(datatab[fileID]);
+      if ( datatab[fileID] ) Free(datatab[fileID]);
     }
 
-  free(datatab);
+  Free(datatab);
 
 
-  if ( vdate ) free(vdate);
-  if ( vtime ) free(vtime);
+  if ( vdate ) Free(vdate);
+  if ( vtime ) Free(vtime);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
 
 
@@ -1065,7 +1065,7 @@ void VerifyGraphParameters( int num_param, char **param_names )
 	  halt_flag = TRUE;
 	  fprintf( stderr,"Invalid parameter specification  '%s'!\n", param_names[i] );
 	}
-      free( split_str );
+      Free( split_str );
     }
       
     if( halt_flag == TRUE )
diff --git a/src/Magplot.c b/src/Magplot.c
index b6562ef..20d50b4 100644
--- a/src/Magplot.c
+++ b/src/Magplot.c
@@ -158,7 +158,7 @@ void magplot( const char *plotfile, int operatorID, const char *varname, const c
            if( !strcmp( split_str[0],"step_freq" ) )
 	     fprintf( stderr,"STEP_FREQ %d\n",STEP_FREQ );
 
-           free( split_str );
+           Free(split_str);
         }
     }
 
@@ -449,7 +449,7 @@ void magplot( const char *plotfile, int operatorID, const char *varname, const c
   mag_text();
 
   if( LEV_LIST ) 
-    free( LEV_LIST );
+    Free(LEV_LIST);
 
 
 }
@@ -549,9 +549,9 @@ void *Magplot(void *argument)
   nlat     = gridInqYsize(gridID);
   nlev     = zaxisInqSize(zaxisID);
 
-  array           = (double*) malloc(gridsize*sizeof(double));
-  grid_center_lat = (double*) malloc(gridsize*sizeof(double));
-  grid_center_lon = (double*) malloc(gridsize*sizeof(double));
+  array           = (double*) Malloc(gridsize*sizeof(double));
+  grid_center_lat = (double*) Malloc(gridsize*sizeof(double));
+  grid_center_lon = (double*) Malloc(gridsize*sizeof(double));
 
   gridInqYvals(gridID, grid_center_lat);
   gridInqXvals(gridID, grid_center_lon);
@@ -678,15 +678,15 @@ void *Magplot(void *argument)
 
   streamClose(streamID);
 
-  if ( array  ) free(array);
-  if ( grid_center_lon ) free(grid_center_lon);
-  if ( grid_center_lat ) free(grid_center_lat);
+  if ( array  ) Free(array);
+  if ( grid_center_lon ) Free(grid_center_lon);
+  if ( grid_center_lat ) Free(grid_center_lat);
 
 /*   quit_XMLtemplate_parser( ); */
 
   cdoFinish();
 
-  return (0);
+  return 0;
 
 }
 
@@ -931,12 +931,12 @@ void VerifyPlotParameters( int num_param, char **param_names, int opID )
 			  if( syntax == TRUE )
 			    {
 	                       NUM_LEVELS = split_str_count;
-	                       LEV_LIST = (double*) malloc( sizeof( double ) * split_str_count );
+	                       LEV_LIST = (double*) Malloc( sizeof( double ) * split_str_count );
 			       for( k = 0; k < split_str_count; k++ )
 		                 {
 		                    LEV_LIST[k] = atof( split_str1[k] );
 		                 }
-	                       free( split_str1 );
+	                       Free(split_str1);
 	                    }
 			  }
 		      }
@@ -960,8 +960,8 @@ void VerifyPlotParameters( int num_param, char **param_names, int opID )
 	  fprintf( stderr,"Invalid parameter specification  '%s'\n", param_names[i] );
 	}
 	
-      if( split_str ) 	  
-	free( split_str );
+      if ( split_str ) 	  
+        Free(split_str);
     } /*** Loop over params ****/
       
     if( halt_flag == TRUE )
@@ -991,7 +991,7 @@ int checkcolour( char *colour_in )
 	if( strchr( colour_in,';') == NULL || strstr( colour_in,"RGB(") == NULL )
 	  {
 	    cdoWarning( "Found 'RGB=true',Specify Colour in 'RGB(r;g;b)' ( where r,g,b in [0.0,1.0] ) format!" );
-	    free( split_str );
+	    Free(split_str);
 	    return 1;
 	  }
 	  
@@ -1020,7 +1020,7 @@ int checkcolour( char *colour_in )
 	if(  split_str_count != 3 ) 
 	  {
 	    cdoWarning( " Colour specified in Improper format!" );
-	    free( split_str );
+	    Free(split_str);
 	    return 1;
 	  }
     
@@ -1032,18 +1032,18 @@ int checkcolour( char *colour_in )
 	    rgb_values[0] + rgb_values[1] + rgb_values[2] < 0.0f 	   )
 	  {
 	    cdoWarning( " RGB Colour specified with Improper values!" );
-	    free( split_str );
+	    Free(split_str);
 	    return 1;
 	  }
 	  
-	free( split_str );  
+        Free(split_str);  
       }
     else
       {
 	if( strchr( colour_in,';') != NULL || strstr( colour_in,"RGB(") != NULL )
 	  {
 	    cdoWarning( "Found Colour with 'RGB(r;g;b)' format, set parameter RGB='true' !" );
-	    free( split_str );
+	    Free(split_str);
 	    return 1;
 	  }
 	  
@@ -1096,12 +1096,12 @@ int ReadColourTable ( char *filepath )
       }
     
     USR_COLOUR_COUNT = 0;
-    USR_COLOUR_TABLE = ( char **) malloc( num_colors * sizeof( char* ));
-    temp_table  = ( char **) malloc( num_colors * sizeof( char* ));
+    USR_COLOUR_TABLE = ( char **) Malloc( num_colors * sizeof( char* ));
+    temp_table  = ( char **) Malloc( num_colors * sizeof( char* ));
     
     for( i =0; i < num_colors; i++ )
       {
-         temp_table[i] = ( char *) malloc(  256 * sizeof( char ));
+         temp_table[i] = ( char *) Malloc(  256 * sizeof( char ));
 	 fscanf( fp, "%s", temp_table[i] );
 	 if( DBG )
 	   fprintf( stdout, "%s\n", temp_table[i] );
diff --git a/src/Magvector.c b/src/Magvector.c
index a61d832..f32b2f7 100644
--- a/src/Magvector.c
+++ b/src/Magvector.c
@@ -113,7 +113,7 @@ void magvector( const char *plotfile, int operatorID, const char *varname, long
 		  fprintf(stderr,"STEP FREQ %d\n",STEP_FREQ );
 	      }
 	      
-	    free( split_str );  
+	    Free( split_str );  
 	  }
 	  
         if( nlon > 1 )
@@ -291,10 +291,10 @@ void *Magvector(void *argument)
   nlat     = gridInqYsize(gridID);
   nlev     = zaxisInqSize(zaxisID);
 
-  uarray          = (double*) malloc(gridsize*sizeof(double));
-  varray          = (double*) malloc(gridsize*sizeof(double));
-  grid_center_lat = (double*) malloc(gridsize*sizeof(double));
-  grid_center_lon = (double*) malloc(gridsize*sizeof(double));
+  uarray          = (double*) Malloc(gridsize*sizeof(double));
+  varray          = (double*) Malloc(gridsize*sizeof(double));
+  grid_center_lat = (double*) Malloc(gridsize*sizeof(double));
+  grid_center_lon = (double*) Malloc(gridsize*sizeof(double));
 
   gridInqYvals(gridID, grid_center_lat);
   gridInqXvals(gridID, grid_center_lon);
@@ -410,10 +410,10 @@ void *Magvector(void *argument)
 
   streamClose(streamID);
 
-  if ( uarray  ) free(uarray);
-  if ( varray  ) free(varray);
-  if ( grid_center_lon ) free(grid_center_lon);
-  if ( grid_center_lat ) free(grid_center_lat);
+  if ( uarray  ) Free(uarray);
+  if ( varray  ) Free(varray);
+  if ( grid_center_lon ) Free(grid_center_lon);
+  if ( grid_center_lat ) Free(grid_center_lat);
 
   /*   quit_XMLtemplate_parser( ); */
 
@@ -421,7 +421,7 @@ void *Magvector(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 
 }
 
@@ -516,7 +516,7 @@ void VerifyVectorParameters( int num_param, char **param_names, int opID )
 	}
 	
       if( split_str ) 	  
-	free( split_str );
+        Free( split_str );
     }
       
     if( halt_flag == TRUE )
diff --git a/src/Makefile.am b/src/Makefile.am
index 14d521e..14dfe12 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -7,6 +7,8 @@ libcdo_la_SOURCES =            \
                cdo_vlist.c     \
                cdo_getopt.c    \
                cdo_getopt.h    \
+               cdo_task.c      \
+               cdo_task.h      \
                cdo_history.c   \
                after_sptrans.c \
                after_fctrans.c \
@@ -27,7 +29,6 @@ libcdo_la_SOURCES =            \
                datetime.c      \
                datetime.h      \
                dmemory.h       \
-               dtypes.h        \
                ecacore.c       \
                ecacore.h       \
                ecautil.c       \
@@ -71,6 +72,8 @@ libcdo_la_SOURCES =            \
                interpol.h      \
                job.c           \
                juldate.c       \
+               grid_search.c   \
+               grid_search.h   \
                kvlist.c        \
                kvlist.h        \
                list.c          \
@@ -87,6 +90,8 @@ libcdo_la_SOURCES =            \
                operator_help.h \
                par_io.c        \
                par_io.h        \
+               percentiles_hist.c   \
+               percentiles_hist.h   \
                percentiles.c   \
                percentiles.h   \
                pipe.c          \
@@ -115,7 +120,7 @@ libcdo_la_SOURCES =            \
                remap_store_link_cnsrv.h \
                remap_conserv.c \
                remap_conserv_scrip.c \
-               remap_distwgt_scrip.c \
+               remap_distwgt.c \
                remap_bicubic_scrip.c \
                remap_bilinear_scrip.c \
                stdnametable.c  \
@@ -134,6 +139,14 @@ libcdo_la_SOURCES =            \
                util.h          \
                zaxis.c
 libcdo_la_SOURCES +=           \
+               kdtreelib/kdtree.h            \
+               kdtreelib/kdtree_cartesian.c  \
+               kdtreelib/kdtree_common.c     \
+               kdtreelib/kdtree_spherical.c  \
+               kdtreelib/pmergesort.c        \
+               kdtreelib/pqueue.c            \
+               kdtreelib/pqueue.h
+libcdo_la_SOURCES +=           \
                clipping/clipping.c           \
                clipping/clipping.h           \
                clipping/area.c               \
@@ -166,6 +179,7 @@ cdo_SOURCES += Adisit.c        \
                Change.c        \
                Change_e5slm.c  \
                Cloudlayer.c    \
+               CMOR.c          \
                Collgrid.c      \
                Command.c       \
                Comp.c          \
@@ -312,11 +326,13 @@ cdo_SOURCES += Adisit.c        \
                Vertintml.c     \
                Vertintap.c     \
                Vertstat.c      \
+               Vertcum.c       \
                Vertwind.c      \
                Wct.c           \
                Wind.c          \
                Writegrid.c     \
                Writerandom.c   \
+               XTimstat.c      \
                YAR.c           \
                Yearmonstat.c   \
                Ydayarith.c     \
@@ -334,6 +350,14 @@ cdo_SOURCES += Adisit.c        \
                Zonstat.c       \
                cdo.h
 
+cdo_SOURCES += nearpt3c.h
+#if ENABLE_NEARPT3
+#cdo_SOURCES +=           \
+#               nearpt3x.h      \
+#               nearpt3c.h      \
+#               nearpt3c.cc     \
+#               cellsearchorder.h
+#endif
 
 if ENABLE_MAGICS
 cdo_SOURCES += Magplot.c       \
diff --git a/src/Makefile.in b/src/Makefile.in
index 49af461..53768be 100644
--- a/src/Makefile.in
+++ b/src/Makefile.in
@@ -80,6 +80,13 @@ POST_UNINSTALL = :
 build_triplet = @build@
 host_triplet = @host@
 bin_PROGRAMS = cdo$(EXEEXT)
+#if ENABLE_NEARPT3
+#cdo_SOURCES +=           \
+#               nearpt3x.h      \
+#               nearpt3c.h      \
+#               nearpt3c.cc     \
+#               cellsearchorder.h
+#endif
 @ENABLE_MAGICS_TRUE at am__append_1 = Magplot.c       \
 @ENABLE_MAGICS_TRUE@               Magvector.c     \
 @ENABLE_MAGICS_TRUE@               Maggraph.c      \
@@ -117,29 +124,31 @@ LTLIBRARIES = $(noinst_LTLIBRARIES)
 libcdo_la_LIBADD =
 am__dirstamp = $(am__leading_dot)dirstamp
 am_libcdo_la_OBJECTS = libcdo_la-cdo_pthread.lo libcdo_la-cdo_vlist.lo \
-	libcdo_la-cdo_getopt.lo libcdo_la-cdo_history.lo \
-	libcdo_la-after_sptrans.lo libcdo_la-after_fctrans.lo \
-	libcdo_la-after_dvtrans.lo libcdo_la-after_vertint.lo \
-	libcdo_la-after_namelist.lo libcdo_la-afterburnerlib.lo \
-	libcdo_la-constants.lo libcdo_la-color.lo \
-	libcdo_la-commandline.lo libcdo_la-datetime.lo \
-	libcdo_la-ecacore.lo libcdo_la-ecautil.lo \
-	libcdo_la-exception.lo libcdo_la-expr.lo libcdo_la-expr_lex.lo \
-	libcdo_la-expr_yacc.lo libcdo_la-features.lo \
-	libcdo_la-field.lo libcdo_la-field2.lo libcdo_la-fieldc.lo \
-	libcdo_la-fieldmem.lo libcdo_la-fieldmer.lo \
-	libcdo_la-fieldzon.lo libcdo_la-gradsdeslib.lo \
-	libcdo_la-grid.lo libcdo_la-grid_area.lo libcdo_la-grid_gme.lo \
+	libcdo_la-cdo_getopt.lo libcdo_la-cdo_task.lo \
+	libcdo_la-cdo_history.lo libcdo_la-after_sptrans.lo \
+	libcdo_la-after_fctrans.lo libcdo_la-after_dvtrans.lo \
+	libcdo_la-after_vertint.lo libcdo_la-after_namelist.lo \
+	libcdo_la-afterburnerlib.lo libcdo_la-constants.lo \
+	libcdo_la-color.lo libcdo_la-commandline.lo \
+	libcdo_la-datetime.lo libcdo_la-ecacore.lo \
+	libcdo_la-ecautil.lo libcdo_la-exception.lo libcdo_la-expr.lo \
+	libcdo_la-expr_lex.lo libcdo_la-expr_yacc.lo \
+	libcdo_la-features.lo libcdo_la-field.lo libcdo_la-field2.lo \
+	libcdo_la-fieldc.lo libcdo_la-fieldmem.lo \
+	libcdo_la-fieldmer.lo libcdo_la-fieldzon.lo \
+	libcdo_la-gradsdeslib.lo libcdo_la-grid.lo \
+	libcdo_la-grid_area.lo libcdo_la-grid_gme.lo \
 	libcdo_la-grid_lcc.lo libcdo_la-grid_rot.lo \
 	libcdo_la-gridreference.lo libcdo_la-griddes.lo \
 	libcdo_la-griddes_h5.lo libcdo_la-griddes_nc.lo \
 	libcdo_la-hetaeta.lo libcdo_la-institution.lo \
 	libcdo_la-interpol.lo libcdo_la-job.lo libcdo_la-juldate.lo \
-	libcdo_la-kvlist.lo libcdo_la-list.lo libcdo_la-merge_sort2.lo \
-	libcdo_la-modules.lo libcdo_la-namelist.lo libcdo_la-normal.lo \
+	libcdo_la-grid_search.lo libcdo_la-kvlist.lo libcdo_la-list.lo \
+	libcdo_la-merge_sort2.lo libcdo_la-modules.lo \
+	libcdo_la-namelist.lo libcdo_la-normal.lo \
 	libcdo_la-nth_element.lo libcdo_la-par_io.lo \
-	libcdo_la-percentiles.lo libcdo_la-pipe.lo \
-	libcdo_la-process.lo libcdo_la-pstream.lo \
+	libcdo_la-percentiles_hist.lo libcdo_la-percentiles.lo \
+	libcdo_la-pipe.lo libcdo_la-process.lo libcdo_la-pstream.lo \
 	libcdo_la-pthread_debug.lo libcdo_la-readline.lo \
 	libcdo_la-realtime.lo libcdo_la-remaplib.lo \
 	libcdo_la-remapsort.lo libcdo_la-remap_scrip_io.lo \
@@ -147,14 +156,18 @@ am_libcdo_la_OBJECTS = libcdo_la-cdo_pthread.lo libcdo_la-cdo_vlist.lo \
 	libcdo_la-remap_search_latbins.lo \
 	libcdo_la-remap_store_link.lo \
 	libcdo_la-remap_store_link_cnsrv.lo libcdo_la-remap_conserv.lo \
-	libcdo_la-remap_conserv_scrip.lo \
-	libcdo_la-remap_distwgt_scrip.lo \
+	libcdo_la-remap_conserv_scrip.lo libcdo_la-remap_distwgt.lo \
 	libcdo_la-remap_bicubic_scrip.lo \
 	libcdo_la-remap_bilinear_scrip.lo libcdo_la-stdnametable.lo \
 	libcdo_la-specspace.lo libcdo_la-statistic.lo \
 	libcdo_la-table.lo libcdo_la-text.lo libcdo_la-timer.lo \
 	libcdo_la-userlog.lo libcdo_la-util.lo libcdo_la-zaxis.lo \
-	clipping/libcdo_la-clipping.lo clipping/libcdo_la-area.lo \
+	kdtreelib/libcdo_la-kdtree_cartesian.lo \
+	kdtreelib/libcdo_la-kdtree_common.lo \
+	kdtreelib/libcdo_la-kdtree_spherical.lo \
+	kdtreelib/libcdo_la-pmergesort.lo \
+	kdtreelib/libcdo_la-pqueue.lo clipping/libcdo_la-clipping.lo \
+	clipping/libcdo_la-area.lo \
 	clipping/libcdo_la-ensure_array_size.lo \
 	clipping/libcdo_la-grid_cell.lo \
 	clipping/libcdo_la-intersection.lo clipping/libcdo_la-utils.lo
@@ -167,25 +180,25 @@ am__installdirs = "$(DESTDIR)$(bindir)"
 PROGRAMS = $(bin_PROGRAMS) $(noinst_PROGRAMS)
 am__cdo_SOURCES_DIST = cdo.c Adisit.c Afterburner.c Arith.c Arithc.c \
 	Arithdays.c Arithlat.c CDItest.c CDIread.c CDIwrite.c Cat.c \
-	Change.c Change_e5slm.c Cloudlayer.c Collgrid.c Command.c \
-	Comp.c Compc.c Complextorect.c Cond.c Cond2.c Condc.c \
-	Consecstat.c Copy.c Deltime.c Derivepar.c Detrend.c Diff.c \
-	Distgrid.c Duplicate.c EOFs.c Eof3d.c EcaIndices.c Echam5ini.c \
-	Enlarge.c Enlargegrid.c Ensstat.c Ensstat3.c Ensval.c \
-	Eofcoeff.c Eofcoeff3d.c Exprf.c FC.c Filedes.c Fillmiss.c \
-	Filter.c Fldrms.c Fldstat.c Fldstat2.c Fourier.c Gengrid.c \
-	Gradsdes.c Gridboxstat.c Gridcell.c Gridsearch.c Harmonic.c \
-	Hi.c Histogram.c Importamsr.c Importbinary.c Importcmsaf.c \
-	Importobs.c Info.c Input.c Intgrid.c Intgridtraj.c Intlevel.c \
-	Intlevel3d.c Intntime.c Inttime.c Intyear.c Invert.c \
-	Invertlev.c Isosurface.c Kvl.c Log.c Maskbox.c Mastrfu.c \
-	Math.c Merge.c Mergegrid.c Mergetime.c Merstat.c Monarith.c \
-	Mrotuv.c Mrotuvb.c Ninfo.c Nmltest.c Output.c Outputgmt.c \
-	Pack.c Pinfo.c Pressure.c Regres.c Remap.c Remapeta.c \
-	Replace.c Replacevalues.c Rhopot.c Rotuv.c Runpctl.c Runstat.c \
-	Seascount.c Seaspctl.c Seasstat.c Selbox.c Select.c \
-	Seloperator.c Selrec.c Seltime.c Selvar.c Set.c Setbox.c \
-	Setgatt.c Setgrid.c Sethalo.c Setmiss.c Setpartab.c \
+	Change.c Change_e5slm.c Cloudlayer.c CMOR.c Collgrid.c \
+	Command.c Comp.c Compc.c Complextorect.c Cond.c Cond2.c \
+	Condc.c Consecstat.c Copy.c Deltime.c Derivepar.c Detrend.c \
+	Diff.c Distgrid.c Duplicate.c EOFs.c Eof3d.c EcaIndices.c \
+	Echam5ini.c Enlarge.c Enlargegrid.c Ensstat.c Ensstat3.c \
+	Ensval.c Eofcoeff.c Eofcoeff3d.c Exprf.c FC.c Filedes.c \
+	Fillmiss.c Filter.c Fldrms.c Fldstat.c Fldstat2.c Fourier.c \
+	Gengrid.c Gradsdes.c Gridboxstat.c Gridcell.c Gridsearch.c \
+	Harmonic.c Hi.c Histogram.c Importamsr.c Importbinary.c \
+	Importcmsaf.c Importobs.c Info.c Input.c Intgrid.c \
+	Intgridtraj.c Intlevel.c Intlevel3d.c Intntime.c Inttime.c \
+	Intyear.c Invert.c Invertlev.c Isosurface.c Kvl.c Log.c \
+	Maskbox.c Mastrfu.c Math.c Merge.c Mergegrid.c Mergetime.c \
+	Merstat.c Monarith.c Mrotuv.c Mrotuvb.c Ninfo.c Nmltest.c \
+	Output.c Outputgmt.c Pack.c Pinfo.c Pressure.c Regres.c \
+	Remap.c Remapeta.c Replace.c Replacevalues.c Rhopot.c Rotuv.c \
+	Runpctl.c Runstat.c Seascount.c Seaspctl.c Seasstat.c Selbox.c \
+	Select.c Seloperator.c Selrec.c Seltime.c Selvar.c Set.c \
+	Setbox.c Setgatt.c Setgrid.c Sethalo.c Setmiss.c Setpartab.c \
 	Setrcaname.c Settime.c Setzaxis.c Showinfo.c Sinfo.c Smooth9.c \
 	Sort.c Sorttimestamp.c Specinfo.c Spectral.c Spectrum.c \
 	Split.c Splitrec.c Splitsel.c Splittime.c Splityear.c SSOpar.c \
@@ -193,15 +206,16 @@ am__cdo_SOURCES_DIST = cdo.c Adisit.c Afterburner.c Arith.c Arithc.c \
 	Timpctl.c Timselpctl.c Timselstat.c Timsort.c Timstat.c \
 	Timstat2.c Timstat3.c Tinfo.c Tocomplex.c Transpose.c Trend.c \
 	Trms.c Tstepcount.c Vardup.c Vargen.c Varrms.c Vertintml.c \
-	Vertintap.c Vertstat.c Vertwind.c Wct.c Wind.c Writegrid.c \
-	Writerandom.c YAR.c Yearmonstat.c Ydayarith.c Ydaypctl.c \
-	Ydaystat.c Ydrunpctl.c Ydrunstat.c Yhourarith.c Yhourstat.c \
-	Ymonarith.c Ymonpctl.c Ymonstat.c Yseaspctl.c Yseasstat.c \
-	Zonstat.c cdo.h Magplot.c Magvector.c Maggraph.c \
-	template_parser.h template_parser.c results_template_parser.h \
-	results_template_parser.c magics_template_parser.h \
-	magics_template_parser.c StringUtilities.h StringUtilities.c \
-	CdoMagicsMapper.h CdoMagicsMapper.c
+	Vertintap.c Vertstat.c Vertcum.c Vertwind.c Wct.c Wind.c \
+	Writegrid.c Writerandom.c XTimstat.c YAR.c Yearmonstat.c \
+	Ydayarith.c Ydaypctl.c Ydaystat.c Ydrunpctl.c Ydrunstat.c \
+	Yhourarith.c Yhourstat.c Ymonarith.c Ymonpctl.c Ymonstat.c \
+	Yseaspctl.c Yseasstat.c Zonstat.c cdo.h nearpt3c.h Magplot.c \
+	Magvector.c Maggraph.c template_parser.h template_parser.c \
+	results_template_parser.h results_template_parser.c \
+	magics_template_parser.h magics_template_parser.c \
+	StringUtilities.h StringUtilities.c CdoMagicsMapper.h \
+	CdoMagicsMapper.c
 @ENABLE_MAGICS_TRUE at am__objects_1 = cdo-Magplot.$(OBJEXT) \
 @ENABLE_MAGICS_TRUE@	cdo-Magvector.$(OBJEXT) \
 @ENABLE_MAGICS_TRUE@	cdo-Maggraph.$(OBJEXT) \
@@ -216,8 +230,9 @@ am_cdo_OBJECTS = cdo-cdo.$(OBJEXT) cdo-Adisit.$(OBJEXT) \
 	cdo-Arithlat.$(OBJEXT) cdo-CDItest.$(OBJEXT) \
 	cdo-CDIread.$(OBJEXT) cdo-CDIwrite.$(OBJEXT) cdo-Cat.$(OBJEXT) \
 	cdo-Change.$(OBJEXT) cdo-Change_e5slm.$(OBJEXT) \
-	cdo-Cloudlayer.$(OBJEXT) cdo-Collgrid.$(OBJEXT) \
-	cdo-Command.$(OBJEXT) cdo-Comp.$(OBJEXT) cdo-Compc.$(OBJEXT) \
+	cdo-Cloudlayer.$(OBJEXT) cdo-CMOR.$(OBJEXT) \
+	cdo-Collgrid.$(OBJEXT) cdo-Command.$(OBJEXT) \
+	cdo-Comp.$(OBJEXT) cdo-Compc.$(OBJEXT) \
 	cdo-Complextorect.$(OBJEXT) cdo-Cond.$(OBJEXT) \
 	cdo-Cond2.$(OBJEXT) cdo-Condc.$(OBJEXT) \
 	cdo-Consecstat.$(OBJEXT) cdo-Copy.$(OBJEXT) \
@@ -283,9 +298,10 @@ am_cdo_OBJECTS = cdo-cdo.$(OBJEXT) cdo-Adisit.$(OBJEXT) \
 	cdo-Tstepcount.$(OBJEXT) cdo-Vardup.$(OBJEXT) \
 	cdo-Vargen.$(OBJEXT) cdo-Varrms.$(OBJEXT) \
 	cdo-Vertintml.$(OBJEXT) cdo-Vertintap.$(OBJEXT) \
-	cdo-Vertstat.$(OBJEXT) cdo-Vertwind.$(OBJEXT) \
-	cdo-Wct.$(OBJEXT) cdo-Wind.$(OBJEXT) cdo-Writegrid.$(OBJEXT) \
-	cdo-Writerandom.$(OBJEXT) cdo-YAR.$(OBJEXT) \
+	cdo-Vertstat.$(OBJEXT) cdo-Vertcum.$(OBJEXT) \
+	cdo-Vertwind.$(OBJEXT) cdo-Wct.$(OBJEXT) cdo-Wind.$(OBJEXT) \
+	cdo-Writegrid.$(OBJEXT) cdo-Writerandom.$(OBJEXT) \
+	cdo-XTimstat.$(OBJEXT) cdo-YAR.$(OBJEXT) \
 	cdo-Yearmonstat.$(OBJEXT) cdo-Ydayarith.$(OBJEXT) \
 	cdo-Ydaypctl.$(OBJEXT) cdo-Ydaystat.$(OBJEXT) \
 	cdo-Ydrunpctl.$(OBJEXT) cdo-Ydrunstat.$(OBJEXT) \
@@ -382,6 +398,7 @@ CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
 CLDFLAGS = @CLDFLAGS@
 CLIBS = @CLIBS@
+CMOR_LIBS = @CMOR_LIBS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CURL_INCLUDE = @CURL_INCLUDE@
@@ -427,7 +444,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-JASPER_LIBS = @JASPER_LIBS@
 LD = @LD@
 LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
@@ -541,33 +557,37 @@ top_builddir = @top_builddir@
 top_srcdir = @top_srcdir@
 noinst_LTLIBRARIES = libcdo.la
 libcdo_la_SOURCES = cdo_int.h compare.h cdo_pthread.c cdo_vlist.c \
-	cdo_getopt.c cdo_getopt.h cdo_history.c after_sptrans.c \
-	after_fctrans.c after_dvtrans.c after_vertint.c \
-	after_vertint.h after_namelist.c afterburnerlib.c \
-	afterburner.h vct_l191.h constants.h constants.c color.c \
-	color.h commandline.c const.h counter.h datetime.c datetime.h \
-	dmemory.h dtypes.h ecacore.c ecacore.h ecautil.c ecautil.h \
-	error.h etopo.h temp.h mask.h exception.c expr.c expr.h \
-	expr_lex.c expr_yacc.c expr_yacc.h features.c field.c field.h \
-	field2.c fieldc.c fieldmem.c fieldmer.c fieldzon.c functs.h \
-	gradsdeslib.c gradsdeslib.h grid.c grid.h grid_area.c \
+	cdo_getopt.c cdo_getopt.h cdo_task.c cdo_task.h cdo_history.c \
+	after_sptrans.c after_fctrans.c after_dvtrans.c \
+	after_vertint.c after_vertint.h after_namelist.c \
+	afterburnerlib.c afterburner.h vct_l191.h constants.h \
+	constants.c color.c color.h commandline.c const.h counter.h \
+	datetime.c datetime.h dmemory.h ecacore.c ecacore.h ecautil.c \
+	ecautil.h error.h etopo.h temp.h mask.h exception.c expr.c \
+	expr.h expr_lex.c expr_yacc.c expr_yacc.h features.c field.c \
+	field.h field2.c fieldc.c fieldmem.c fieldmer.c fieldzon.c \
+	functs.h gradsdeslib.c gradsdeslib.h grid.c grid.h grid_area.c \
 	grid_gme.c grid_lcc.c grid_rot.c gridreference.c griddes.c \
 	griddes.h griddes_h5.c griddes_nc.c hetaeta.c hetaeta.h \
-	institution.c interpol.c interpol.h job.c juldate.c kvlist.c \
-	kvlist.h list.c list.h merge_sort2.c merge_sort2.h modules.c \
-	modules.h namelist.c namelist.h normal.c nth_element.c \
-	nth_element.h operator_help.h par_io.c par_io.h percentiles.c \
-	percentiles.h pipe.c pipe.h pragma_omp_atomic_update.h \
-	printinfo.h process.c process.h pstream.c pstream.h \
-	pstream_write.h pstream_int.h pthread_debug.c pthread_debug.h \
-	readline.c realtime.c remap.h remaplib.c remapsort.c \
-	remap_scrip_io.c remap_search_reg2d.c remap_search_latbins.c \
-	remap_store_link.c remap_store_link.h remap_store_link_cnsrv.c \
-	remap_store_link_cnsrv.h remap_conserv.c remap_conserv_scrip.c \
-	remap_distwgt_scrip.c remap_bicubic_scrip.c \
-	remap_bilinear_scrip.c stdnametable.c stdnametable.h \
-	specspace.c specspace.h statistic.c statistic.h table.c text.c \
-	text.h timebase.h timer.c userlog.c util.c util.h zaxis.c \
+	institution.c interpol.c interpol.h job.c juldate.c \
+	grid_search.c grid_search.h kvlist.c kvlist.h list.c list.h \
+	merge_sort2.c merge_sort2.h modules.c modules.h namelist.c \
+	namelist.h normal.c nth_element.c nth_element.h \
+	operator_help.h par_io.c par_io.h percentiles_hist.c \
+	percentiles_hist.h percentiles.c percentiles.h pipe.c pipe.h \
+	pragma_omp_atomic_update.h printinfo.h process.c process.h \
+	pstream.c pstream.h pstream_write.h pstream_int.h \
+	pthread_debug.c pthread_debug.h readline.c realtime.c remap.h \
+	remaplib.c remapsort.c remap_scrip_io.c remap_search_reg2d.c \
+	remap_search_latbins.c remap_store_link.c remap_store_link.h \
+	remap_store_link_cnsrv.c remap_store_link_cnsrv.h \
+	remap_conserv.c remap_conserv_scrip.c remap_distwgt.c \
+	remap_bicubic_scrip.c remap_bilinear_scrip.c stdnametable.c \
+	stdnametable.h specspace.c specspace.h statistic.c statistic.h \
+	table.c text.c text.h timebase.h timer.c userlog.c util.c \
+	util.h zaxis.c kdtreelib/kdtree.h kdtreelib/kdtree_cartesian.c \
+	kdtreelib/kdtree_common.c kdtreelib/kdtree_spherical.c \
+	kdtreelib/pmergesort.c kdtreelib/pqueue.c kdtreelib/pqueue.h \
 	clipping/clipping.c clipping/clipping.h clipping/area.c \
 	clipping/area.h clipping/ensure_array_size.c \
 	clipping/ensure_array_size.h clipping/geometry.h \
@@ -577,25 +597,25 @@ libcdo_la_SOURCES = cdo_int.h compare.h cdo_pthread.c cdo_vlist.c \
 #
 cdo_SOURCES = cdo.c Adisit.c Afterburner.c Arith.c Arithc.c \
 	Arithdays.c Arithlat.c CDItest.c CDIread.c CDIwrite.c Cat.c \
-	Change.c Change_e5slm.c Cloudlayer.c Collgrid.c Command.c \
-	Comp.c Compc.c Complextorect.c Cond.c Cond2.c Condc.c \
-	Consecstat.c Copy.c Deltime.c Derivepar.c Detrend.c Diff.c \
-	Distgrid.c Duplicate.c EOFs.c Eof3d.c EcaIndices.c Echam5ini.c \
-	Enlarge.c Enlargegrid.c Ensstat.c Ensstat3.c Ensval.c \
-	Eofcoeff.c Eofcoeff3d.c Exprf.c FC.c Filedes.c Fillmiss.c \
-	Filter.c Fldrms.c Fldstat.c Fldstat2.c Fourier.c Gengrid.c \
-	Gradsdes.c Gridboxstat.c Gridcell.c Gridsearch.c Harmonic.c \
-	Hi.c Histogram.c Importamsr.c Importbinary.c Importcmsaf.c \
-	Importobs.c Info.c Input.c Intgrid.c Intgridtraj.c Intlevel.c \
-	Intlevel3d.c Intntime.c Inttime.c Intyear.c Invert.c \
-	Invertlev.c Isosurface.c Kvl.c Log.c Maskbox.c Mastrfu.c \
-	Math.c Merge.c Mergegrid.c Mergetime.c Merstat.c Monarith.c \
-	Mrotuv.c Mrotuvb.c Ninfo.c Nmltest.c Output.c Outputgmt.c \
-	Pack.c Pinfo.c Pressure.c Regres.c Remap.c Remapeta.c \
-	Replace.c Replacevalues.c Rhopot.c Rotuv.c Runpctl.c Runstat.c \
-	Seascount.c Seaspctl.c Seasstat.c Selbox.c Select.c \
-	Seloperator.c Selrec.c Seltime.c Selvar.c Set.c Setbox.c \
-	Setgatt.c Setgrid.c Sethalo.c Setmiss.c Setpartab.c \
+	Change.c Change_e5slm.c Cloudlayer.c CMOR.c Collgrid.c \
+	Command.c Comp.c Compc.c Complextorect.c Cond.c Cond2.c \
+	Condc.c Consecstat.c Copy.c Deltime.c Derivepar.c Detrend.c \
+	Diff.c Distgrid.c Duplicate.c EOFs.c Eof3d.c EcaIndices.c \
+	Echam5ini.c Enlarge.c Enlargegrid.c Ensstat.c Ensstat3.c \
+	Ensval.c Eofcoeff.c Eofcoeff3d.c Exprf.c FC.c Filedes.c \
+	Fillmiss.c Filter.c Fldrms.c Fldstat.c Fldstat2.c Fourier.c \
+	Gengrid.c Gradsdes.c Gridboxstat.c Gridcell.c Gridsearch.c \
+	Harmonic.c Hi.c Histogram.c Importamsr.c Importbinary.c \
+	Importcmsaf.c Importobs.c Info.c Input.c Intgrid.c \
+	Intgridtraj.c Intlevel.c Intlevel3d.c Intntime.c Inttime.c \
+	Intyear.c Invert.c Invertlev.c Isosurface.c Kvl.c Log.c \
+	Maskbox.c Mastrfu.c Math.c Merge.c Mergegrid.c Mergetime.c \
+	Merstat.c Monarith.c Mrotuv.c Mrotuvb.c Ninfo.c Nmltest.c \
+	Output.c Outputgmt.c Pack.c Pinfo.c Pressure.c Regres.c \
+	Remap.c Remapeta.c Replace.c Replacevalues.c Rhopot.c Rotuv.c \
+	Runpctl.c Runstat.c Seascount.c Seaspctl.c Seasstat.c Selbox.c \
+	Select.c Seloperator.c Selrec.c Seltime.c Selvar.c Set.c \
+	Setbox.c Setgatt.c Setgrid.c Sethalo.c Setmiss.c Setpartab.c \
 	Setrcaname.c Settime.c Setzaxis.c Showinfo.c Sinfo.c Smooth9.c \
 	Sort.c Sorttimestamp.c Specinfo.c Spectral.c Spectrum.c \
 	Split.c Splitrec.c Splitsel.c Splittime.c Splityear.c SSOpar.c \
@@ -603,11 +623,12 @@ cdo_SOURCES = cdo.c Adisit.c Afterburner.c Arith.c Arithc.c \
 	Timpctl.c Timselpctl.c Timselstat.c Timsort.c Timstat.c \
 	Timstat2.c Timstat3.c Tinfo.c Tocomplex.c Transpose.c Trend.c \
 	Trms.c Tstepcount.c Vardup.c Vargen.c Varrms.c Vertintml.c \
-	Vertintap.c Vertstat.c Vertwind.c Wct.c Wind.c Writegrid.c \
-	Writerandom.c YAR.c Yearmonstat.c Ydayarith.c Ydaypctl.c \
-	Ydaystat.c Ydrunpctl.c Ydrunstat.c Yhourarith.c Yhourstat.c \
-	Ymonarith.c Ymonpctl.c Ymonstat.c Yseaspctl.c Yseasstat.c \
-	Zonstat.c cdo.h $(am__append_1)
+	Vertintap.c Vertstat.c Vertcum.c Vertwind.c Wct.c Wind.c \
+	Writegrid.c Writerandom.c XTimstat.c YAR.c Yearmonstat.c \
+	Ydayarith.c Ydaypctl.c Ydaystat.c Ydrunpctl.c Ydrunstat.c \
+	Yhourarith.c Yhourstat.c Ymonarith.c Ymonpctl.c Ymonstat.c \
+	Yseaspctl.c Yseasstat.c Zonstat.c cdo.h nearpt3c.h \
+	$(am__append_1)
 cdo_CPPFLAGS = -I$(top_srcdir)/libcdi/src
 cdo_LDADD = libcdo.la $(top_builddir)/libcdi/src/libcdi.la
 cdo_LDFLAGS = $(am__append_2)
@@ -686,6 +707,22 @@ clean-noinstLTLIBRARIES:
 	  echo rm -f $${locs}; \
 	  rm -f $${locs}; \
 	}
+kdtreelib/$(am__dirstamp):
+	@$(MKDIR_P) kdtreelib
+	@: > kdtreelib/$(am__dirstamp)
+kdtreelib/$(DEPDIR)/$(am__dirstamp):
+	@$(MKDIR_P) kdtreelib/$(DEPDIR)
+	@: > kdtreelib/$(DEPDIR)/$(am__dirstamp)
+kdtreelib/libcdo_la-kdtree_cartesian.lo: kdtreelib/$(am__dirstamp) \
+	kdtreelib/$(DEPDIR)/$(am__dirstamp)
+kdtreelib/libcdo_la-kdtree_common.lo: kdtreelib/$(am__dirstamp) \
+	kdtreelib/$(DEPDIR)/$(am__dirstamp)
+kdtreelib/libcdo_la-kdtree_spherical.lo: kdtreelib/$(am__dirstamp) \
+	kdtreelib/$(DEPDIR)/$(am__dirstamp)
+kdtreelib/libcdo_la-pmergesort.lo: kdtreelib/$(am__dirstamp) \
+	kdtreelib/$(DEPDIR)/$(am__dirstamp)
+kdtreelib/libcdo_la-pqueue.lo: kdtreelib/$(am__dirstamp) \
+	kdtreelib/$(DEPDIR)/$(am__dirstamp)
 clipping/$(am__dirstamp):
 	@$(MKDIR_P) clipping
 	@: > clipping/$(am__dirstamp)
@@ -778,6 +815,8 @@ mostlyclean-compile:
 	-rm -f *.$(OBJEXT)
 	-rm -f clipping/*.$(OBJEXT)
 	-rm -f clipping/*.lo
+	-rm -f kdtreelib/*.$(OBJEXT)
+	-rm -f kdtreelib/*.lo
 
 distclean-compile:
 	-rm -f *.tab.c
@@ -791,6 +830,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-CDIread.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-CDItest.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-CDIwrite.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-CMOR.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-Cat.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-CdoMagicsMapper.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-Change.Po at am__quote@
@@ -943,6 +983,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-Vardup.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-Vargen.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-Varrms.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-Vertcum.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-Vertintap.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-Vertintml.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-Vertstat.Po at am__quote@
@@ -951,6 +992,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-Wind.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-Writegrid.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-Writerandom.Po at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-XTimstat.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-YAR.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-Ydayarith.Po at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/cdo-Ydaypctl.Po at am__quote@
@@ -980,6 +1022,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-cdo_getopt.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-cdo_history.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-cdo_pthread.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-cdo_task.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-cdo_vlist.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-color.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-commandline.Plo at am__quote@
@@ -1004,6 +1047,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-grid_gme.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-grid_lcc.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-grid_rot.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-grid_search.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-griddes.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-griddes_h5.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-griddes_nc.Plo at am__quote@
@@ -1022,6 +1066,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-nth_element.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-par_io.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-percentiles.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-percentiles_hist.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-pipe.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-process.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-pstream.Plo at am__quote@
@@ -1032,7 +1077,7 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-remap_bilinear_scrip.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-remap_conserv.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-remap_conserv_scrip.Plo at am__quote@
- at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-remap_distwgt_scrip.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-remap_distwgt.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-remap_scrip_io.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-remap_search_latbins.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at ./$(DEPDIR)/libcdo_la-remap_search_reg2d.Plo at am__quote@
@@ -1055,6 +1100,11 @@ distclean-compile:
 @AMDEP_TRUE@@am__include@ @am__quote at clipping/$(DEPDIR)/libcdo_la-grid_cell.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at clipping/$(DEPDIR)/libcdo_la-intersection.Plo at am__quote@
 @AMDEP_TRUE@@am__include@ @am__quote at clipping/$(DEPDIR)/libcdo_la-utils.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at kdtreelib/$(DEPDIR)/libcdo_la-kdtree_cartesian.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at kdtreelib/$(DEPDIR)/libcdo_la-kdtree_common.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at kdtreelib/$(DEPDIR)/libcdo_la-kdtree_spherical.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at kdtreelib/$(DEPDIR)/libcdo_la-pmergesort.Plo at am__quote@
+ at AMDEP_TRUE@@am__include@ @am__quote at kdtreelib/$(DEPDIR)/libcdo_la-pqueue.Plo at am__quote@
 
 .c.o:
 @am__fastdepCC_TRUE@	$(AM_V_CC)depbase=`echo $@ | sed 's|[^/]*$$|$(DEPDIR)/&|;s|\.o$$||'`;\
@@ -1101,6 +1151,13 @@ libcdo_la-cdo_getopt.lo: cdo_getopt.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-cdo_getopt.lo `test -f 'cdo_getopt.c' || echo '$(srcdir)/'`cdo_getopt.c
 
+libcdo_la-cdo_task.lo: cdo_task.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-cdo_task.lo -MD -MP -MF $(DEPDIR)/libcdo_la-cdo_task.Tpo -c -o libcdo_la-cdo_task.lo `test -f 'cdo_task.c' || echo '$(srcdir)/'`cdo_task.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdo_la-cdo_task.Tpo $(DEPDIR)/libcdo_la-cdo_task.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='cdo_task.c' object='libcdo_la-cdo_task.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-cdo_task.lo `test -f 'cdo_task.c' || echo '$(srcdir)/'`cdo_task.c
+
 libcdo_la-cdo_history.lo: cdo_history.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-cdo_history.lo -MD -MP -MF $(DEPDIR)/libcdo_la-cdo_history.Tpo -c -o libcdo_la-cdo_history.lo `test -f 'cdo_history.c' || echo '$(srcdir)/'`cdo_history.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdo_la-cdo_history.Tpo $(DEPDIR)/libcdo_la-cdo_history.Plo
@@ -1374,6 +1431,13 @@ libcdo_la-juldate.lo: juldate.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-juldate.lo `test -f 'juldate.c' || echo '$(srcdir)/'`juldate.c
 
+libcdo_la-grid_search.lo: grid_search.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-grid_search.lo -MD -MP -MF $(DEPDIR)/libcdo_la-grid_search.Tpo -c -o libcdo_la-grid_search.lo `test -f 'grid_search.c' || echo '$(srcdir)/'`grid_search.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdo_la-grid_search.Tpo $(DEPDIR)/libcdo_la-grid_search.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='grid_search.c' object='libcdo_la-grid_search.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-grid_search.lo `test -f 'grid_search.c' || echo '$(srcdir)/'`grid_search.c
+
 libcdo_la-kvlist.lo: kvlist.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-kvlist.lo -MD -MP -MF $(DEPDIR)/libcdo_la-kvlist.Tpo -c -o libcdo_la-kvlist.lo `test -f 'kvlist.c' || echo '$(srcdir)/'`kvlist.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdo_la-kvlist.Tpo $(DEPDIR)/libcdo_la-kvlist.Plo
@@ -1430,6 +1494,13 @@ libcdo_la-par_io.lo: par_io.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-par_io.lo `test -f 'par_io.c' || echo '$(srcdir)/'`par_io.c
 
+libcdo_la-percentiles_hist.lo: percentiles_hist.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-percentiles_hist.lo -MD -MP -MF $(DEPDIR)/libcdo_la-percentiles_hist.Tpo -c -o libcdo_la-percentiles_hist.lo `test -f 'percentiles_hist.c' || echo '$(srcdir)/'`percentiles_hist.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdo_la-percentiles_hist.Tpo $(DEPDIR)/libcdo_la-percentiles_hist.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='percentiles_hist.c' object='libcdo_la-percentiles_hist.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-percentiles_hist.lo `test -f 'percentiles_hist.c' || echo '$(srcdir)/'`percentiles_hist.c
+
 libcdo_la-percentiles.lo: percentiles.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-percentiles.lo -MD -MP -MF $(DEPDIR)/libcdo_la-percentiles.Tpo -c -o libcdo_la-percentiles.lo `test -f 'percentiles.c' || echo '$(srcdir)/'`percentiles.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdo_la-percentiles.Tpo $(DEPDIR)/libcdo_la-percentiles.Plo
@@ -1542,12 +1613,12 @@ libcdo_la-remap_conserv_scrip.lo: remap_conserv_scrip.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-remap_conserv_scrip.lo `test -f 'remap_conserv_scrip.c' || echo '$(srcdir)/'`remap_conserv_scrip.c
 
-libcdo_la-remap_distwgt_scrip.lo: remap_distwgt_scrip.c
- at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-remap_distwgt_scrip.lo -MD -MP -MF $(DEPDIR)/libcdo_la-remap_distwgt_scrip.Tpo -c -o libcdo_la-remap_distwgt_scrip.lo `test -f 'remap_distwgt_scrip.c' || echo '$(srcdir)/'`remap_distwgt_scrip.c
- at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdo_la-remap_distwgt_scrip.Tpo $(DEPDIR)/libcdo_la-remap_distwgt_scrip.Plo
- at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='remap_distwgt_scrip.c' object='libcdo_la-remap_distwgt_scrip.lo' libtool=yes @AMDEPBACKSLASH@
+libcdo_la-remap_distwgt.lo: remap_distwgt.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-remap_distwgt.lo -MD -MP -MF $(DEPDIR)/libcdo_la-remap_distwgt.Tpo -c -o libcdo_la-remap_distwgt.lo `test -f 'remap_distwgt.c' || echo '$(srcdir)/'`remap_distwgt.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/libcdo_la-remap_distwgt.Tpo $(DEPDIR)/libcdo_la-remap_distwgt.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='remap_distwgt.c' object='libcdo_la-remap_distwgt.lo' libtool=yes @AMDEPBACKSLASH@
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
- at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-remap_distwgt_scrip.lo `test -f 'remap_distwgt_scrip.c' || echo '$(srcdir)/'`remap_distwgt_scrip.c
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-remap_distwgt.lo `test -f 'remap_distwgt.c' || echo '$(srcdir)/'`remap_distwgt.c
 
 libcdo_la-remap_bicubic_scrip.lo: remap_bicubic_scrip.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libcdo_la-remap_bicubic_scrip.lo -MD -MP -MF $(DEPDIR)/libcdo_la-remap_bicubic_scrip.Tpo -c -o libcdo_la-remap_bicubic_scrip.lo `test -f 'remap_bicubic_scrip.c' || echo '$(srcdir)/'`remap_bicubic_scrip.c
@@ -1626,6 +1697,41 @@ libcdo_la-zaxis.lo: zaxis.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libcdo_la-zaxis.lo `test -f 'zaxis.c' || echo '$(srcdir)/'`zaxis.c
 
+kdtreelib/libcdo_la-kdtree_cartesian.lo: kdtreelib/kdtree_cartesian.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kdtreelib/libcdo_la-kdtree_cartesian.lo -MD -MP -MF kdtreelib/$(DEPDIR)/libcdo_la-kdtree_cartesian.Tpo -c -o kdtreelib/libcdo_la-kdtree_cartesian.lo `test -f 'kdtreelib/kdtree_cartesian.c' || echo '$(srcdir)/'`kdtreelib/kdtree_cartesian.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) kdtreelib/$(DEPDIR)/libcdo_la-kdtree_cartesian.Tpo kdtreelib/$(DEPDIR)/libcdo_la-kdtree_cartesian.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='kdtreelib/kdtree_cartesian.c' object='kdtreelib/libcdo_la-kdtree_cartesian.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kdtreelib/libcdo_la-kdtree_cartesian.lo `test -f 'kdtreelib/kdtree_cartesian.c' || echo '$(srcdir)/'`kdtreelib/kdtree_cartesian.c
+
+kdtreelib/libcdo_la-kdtree_common.lo: kdtreelib/kdtree_common.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kdtreelib/libcdo_la-kdtree_common.lo -MD -MP -MF kdtreelib/$(DEPDIR)/libcdo_la-kdtree_common.Tpo -c -o kdtreelib/libcdo_la-kdtree_common.lo `test -f 'kdtreelib/kdtree_common.c' || echo '$(srcdir)/'`kdtreelib/kdtree_common.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) kdtreelib/$(DEPDIR)/libcdo_la-kdtree_common.Tpo kdtreelib/$(DEPDIR)/libcdo_la-kdtree_common.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='kdtreelib/kdtree_common.c' object='kdtreelib/libcdo_la-kdtree_common.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kdtreelib/libcdo_la-kdtree_common.lo `test -f 'kdtreelib/kdtree_common.c' || echo '$(srcdir)/'`kdtreelib/kdtree_common.c
+
+kdtreelib/libcdo_la-kdtree_spherical.lo: kdtreelib/kdtree_spherical.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kdtreelib/libcdo_la-kdtree_spherical.lo -MD -MP -MF kdtreelib/$(DEPDIR)/libcdo_la-kdtree_spherical.Tpo -c -o kdtreelib/libcdo_la-kdtree_spherical.lo `test -f 'kdtreelib/kdtree_spherical.c' || echo '$(srcdir)/'`kdtreelib/kdtree_spherical.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) kdtreelib/$(DEPDIR)/libcdo_la-kdtree_spherical.Tpo kdtreelib/$(DEPDIR)/libcdo_la-kdtree_spherical.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='kdtreelib/kdtree_spherical.c' object='kdtreelib/libcdo_la-kdtree_spherical.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kdtreelib/libcdo_la-kdtree_spherical.lo `test -f 'kdtreelib/kdtree_spherical.c' || echo '$(srcdir)/'`kdtreelib/kdtree_spherical.c
+
+kdtreelib/libcdo_la-pmergesort.lo: kdtreelib/pmergesort.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kdtreelib/libcdo_la-pmergesort.lo -MD -MP -MF kdtreelib/$(DEPDIR)/libcdo_la-pmergesort.Tpo -c -o kdtreelib/libcdo_la-pmergesort.lo `test -f 'kdtreelib/pmergesort.c' || echo '$(srcdir)/'`kdtreelib/pmergesort.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) kdtreelib/$(DEPDIR)/libcdo_la-pmergesort.Tpo kdtreelib/$(DEPDIR)/libcdo_la-pmergesort.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='kdtreelib/pmergesort.c' object='kdtreelib/libcdo_la-pmergesort.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kdtreelib/libcdo_la-pmergesort.lo `test -f 'kdtreelib/pmergesort.c' || echo '$(srcdir)/'`kdtreelib/pmergesort.c
+
+kdtreelib/libcdo_la-pqueue.lo: kdtreelib/pqueue.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT kdtreelib/libcdo_la-pqueue.lo -MD -MP -MF kdtreelib/$(DEPDIR)/libcdo_la-pqueue.Tpo -c -o kdtreelib/libcdo_la-pqueue.lo `test -f 'kdtreelib/pqueue.c' || echo '$(srcdir)/'`kdtreelib/pqueue.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) kdtreelib/$(DEPDIR)/libcdo_la-pqueue.Tpo kdtreelib/$(DEPDIR)/libcdo_la-pqueue.Plo
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='kdtreelib/pqueue.c' object='kdtreelib/libcdo_la-pqueue.lo' libtool=yes @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o kdtreelib/libcdo_la-pqueue.lo `test -f 'kdtreelib/pqueue.c' || echo '$(srcdir)/'`kdtreelib/pqueue.c
+
 clipping/libcdo_la-clipping.lo: clipping/clipping.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(LIBTOOL) $(AM_V_lt) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libcdo_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT clipping/libcdo_la-clipping.lo -MD -MP -MF clipping/$(DEPDIR)/libcdo_la-clipping.Tpo -c -o clipping/libcdo_la-clipping.lo `test -f 'clipping/clipping.c' || echo '$(srcdir)/'`clipping/clipping.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) clipping/$(DEPDIR)/libcdo_la-clipping.Tpo clipping/$(DEPDIR)/libcdo_la-clipping.Plo
@@ -1864,6 +1970,20 @@ cdo-Cloudlayer.obj: Cloudlayer.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Cloudlayer.obj `if test -f 'Cloudlayer.c'; then $(CYGPATH_W) 'Cloudlayer.c'; else $(CYGPATH_W) '$(srcdir)/Cloudlayer.c'; fi`
 
+cdo-CMOR.o: CMOR.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-CMOR.o -MD -MP -MF $(DEPDIR)/cdo-CMOR.Tpo -c -o cdo-CMOR.o `test -f 'CMOR.c' || echo '$(srcdir)/'`CMOR.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/cdo-CMOR.Tpo $(DEPDIR)/cdo-CMOR.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='CMOR.c' object='cdo-CMOR.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-CMOR.o `test -f 'CMOR.c' || echo '$(srcdir)/'`CMOR.c
+
+cdo-CMOR.obj: CMOR.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-CMOR.obj -MD -MP -MF $(DEPDIR)/cdo-CMOR.Tpo -c -o cdo-CMOR.obj `if test -f 'CMOR.c'; then $(CYGPATH_W) 'CMOR.c'; else $(CYGPATH_W) '$(srcdir)/CMOR.c'; fi`
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/cdo-CMOR.Tpo $(DEPDIR)/cdo-CMOR.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='CMOR.c' object='cdo-CMOR.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-CMOR.obj `if test -f 'CMOR.c'; then $(CYGPATH_W) 'CMOR.c'; else $(CYGPATH_W) '$(srcdir)/CMOR.c'; fi`
+
 cdo-Collgrid.o: Collgrid.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Collgrid.o -MD -MP -MF $(DEPDIR)/cdo-Collgrid.Tpo -c -o cdo-Collgrid.o `test -f 'Collgrid.c' || echo '$(srcdir)/'`Collgrid.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/cdo-Collgrid.Tpo $(DEPDIR)/cdo-Collgrid.Po
@@ -3908,6 +4028,20 @@ cdo-Vertstat.obj: Vertstat.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Vertstat.obj `if test -f 'Vertstat.c'; then $(CYGPATH_W) 'Vertstat.c'; else $(CYGPATH_W) '$(srcdir)/Vertstat.c'; fi`
 
+cdo-Vertcum.o: Vertcum.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Vertcum.o -MD -MP -MF $(DEPDIR)/cdo-Vertcum.Tpo -c -o cdo-Vertcum.o `test -f 'Vertcum.c' || echo '$(srcdir)/'`Vertcum.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/cdo-Vertcum.Tpo $(DEPDIR)/cdo-Vertcum.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='Vertcum.c' object='cdo-Vertcum.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Vertcum.o `test -f 'Vertcum.c' || echo '$(srcdir)/'`Vertcum.c
+
+cdo-Vertcum.obj: Vertcum.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Vertcum.obj -MD -MP -MF $(DEPDIR)/cdo-Vertcum.Tpo -c -o cdo-Vertcum.obj `if test -f 'Vertcum.c'; then $(CYGPATH_W) 'Vertcum.c'; else $(CYGPATH_W) '$(srcdir)/Vertcum.c'; fi`
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/cdo-Vertcum.Tpo $(DEPDIR)/cdo-Vertcum.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='Vertcum.c' object='cdo-Vertcum.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Vertcum.obj `if test -f 'Vertcum.c'; then $(CYGPATH_W) 'Vertcum.c'; else $(CYGPATH_W) '$(srcdir)/Vertcum.c'; fi`
+
 cdo-Vertwind.o: Vertwind.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-Vertwind.o -MD -MP -MF $(DEPDIR)/cdo-Vertwind.Tpo -c -o cdo-Vertwind.o `test -f 'Vertwind.c' || echo '$(srcdir)/'`Vertwind.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/cdo-Vertwind.Tpo $(DEPDIR)/cdo-Vertwind.Po
@@ -3978,6 +4112,20 @@ cdo-Writerandom.obj: Writerandom.c
 @AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
 @am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-Writerandom.obj `if test -f 'Writerandom.c'; then $(CYGPATH_W) 'Writerandom.c'; else $(CYGPATH_W) '$(srcdir)/Writerandom.c'; fi`
 
+cdo-XTimstat.o: XTimstat.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-XTimstat.o -MD -MP -MF $(DEPDIR)/cdo-XTimstat.Tpo -c -o cdo-XTimstat.o `test -f 'XTimstat.c' || echo '$(srcdir)/'`XTimstat.c
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/cdo-XTimstat.Tpo $(DEPDIR)/cdo-XTimstat.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='XTimstat.c' object='cdo-XTimstat.o' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-XTimstat.o `test -f 'XTimstat.c' || echo '$(srcdir)/'`XTimstat.c
+
+cdo-XTimstat.obj: XTimstat.c
+ at am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-XTimstat.obj -MD -MP -MF $(DEPDIR)/cdo-XTimstat.Tpo -c -o cdo-XTimstat.obj `if test -f 'XTimstat.c'; then $(CYGPATH_W) 'XTimstat.c'; else $(CYGPATH_W) '$(srcdir)/XTimstat.c'; fi`
+ at am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/cdo-XTimstat.Tpo $(DEPDIR)/cdo-XTimstat.Po
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	$(AM_V_CC)source='XTimstat.c' object='cdo-XTimstat.obj' libtool=no @AMDEPBACKSLASH@
+ at AMDEP_TRUE@@am__fastdepCC_FALSE@	DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+ at am__fastdepCC_FALSE@	$(AM_V_CC at am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o cdo-XTimstat.obj `if test -f 'XTimstat.c'; then $(CYGPATH_W) 'XTimstat.c'; else $(CYGPATH_W) '$(srcdir)/XTimstat.c'; fi`
+
 cdo-YAR.o: YAR.c
 @am__fastdepCC_TRUE@	$(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(cdo_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT cdo-YAR.o -MD -MP -MF $(DEPDIR)/cdo-YAR.Tpo -c -o cdo-YAR.o `test -f 'YAR.c' || echo '$(srcdir)/'`YAR.c
 @am__fastdepCC_TRUE@	$(AM_V_at)$(am__mv) $(DEPDIR)/cdo-YAR.Tpo $(DEPDIR)/cdo-YAR.Po
@@ -4320,6 +4468,7 @@ mostlyclean-libtool:
 clean-libtool:
 	-rm -rf .libs _libs
 	-rm -rf clipping/.libs clipping/_libs
+	-rm -rf kdtreelib/.libs kdtreelib/_libs
 
 ID: $(am__tagged_files)
 	$(am__define_uniq_tagged_files); mkid -fID $$unique
@@ -4439,6 +4588,8 @@ distclean-generic:
 	-test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
 	-rm -f clipping/$(DEPDIR)/$(am__dirstamp)
 	-rm -f clipping/$(am__dirstamp)
+	-rm -f kdtreelib/$(DEPDIR)/$(am__dirstamp)
+	-rm -f kdtreelib/$(am__dirstamp)
 
 maintainer-clean-generic:
 	@echo "This command is intended for maintainers to use"
@@ -4449,7 +4600,7 @@ clean-am: clean-binPROGRAMS clean-generic clean-libtool \
 	clean-noinstLTLIBRARIES clean-noinstPROGRAMS mostlyclean-am
 
 distclean: distclean-am
-	-rm -rf ./$(DEPDIR) clipping/$(DEPDIR)
+	-rm -rf ./$(DEPDIR) clipping/$(DEPDIR) kdtreelib/$(DEPDIR)
 	-rm -f Makefile
 distclean-am: clean-am distclean-compile distclean-generic \
 	distclean-hdr distclean-tags
@@ -4495,7 +4646,7 @@ install-ps-am:
 installcheck-am:
 
 maintainer-clean: maintainer-clean-am
-	-rm -rf ./$(DEPDIR) clipping/$(DEPDIR)
+	-rm -rf ./$(DEPDIR) clipping/$(DEPDIR) kdtreelib/$(DEPDIR)
 	-rm -f Makefile
 maintainer-clean-am: distclean-am maintainer-clean-generic
 
diff --git a/src/Maskbox.c b/src/Maskbox.c
index a65d5a2..ffd17eb 100644
--- a/src/Maskbox.c
+++ b/src/Maskbox.c
@@ -46,7 +46,6 @@ int ReadCoords(double *xvals, double *yvals, const char *polyfile, FILE *fp)
   while ( readline(fp, line, MAX_LINE) )
     {
       i = 0;
-      xcoord = 0;
       if ( line[0] == '#' ) 
          { 
            jumpedlines++;
@@ -118,19 +117,122 @@ static
 void maskbox(int *mask, int gridID,
 	     int lat1, int lat2, int lon11, int lon12, int lon21, int lon22)
 {
-  int nlon, nlat;
-  int ilat, ilon;
-
-  nlon = gridInqXsize(gridID);
-  nlat = gridInqYsize(gridID);
+  int nlon = gridInqXsize(gridID);
+  int nlat = gridInqYsize(gridID);
 
-  for ( ilat = 0; ilat < nlat; ilat++ )
-    for ( ilon = 0; ilon < nlon; ilon++ )
+  for ( int ilat = 0; ilat < nlat; ilat++ )
+    for ( int ilon = 0; ilon < nlon; ilon++ )
       if (  (lat1 <= ilat && ilat <= lat2 && 
 	      ((lon11 <= ilon && ilon <= lon12) || (lon21 <= ilon && ilon <= lon22))) )
 	mask[nlon*ilat + ilon] = 0;
 }
 
+void getlonlatparams(int argc_offset, double *xlon1, double *xlon2, double *xlat1, double *xlat2);
+void genlonlatbox_curv(int gridID, double xlon1, double xlon2, double xlat1, double xlat2,
+                       int *lat1, int *lat2, int *lon11, int *lon12, int *lon21, int *lon22);
+
+static
+void maskbox_curv(int *mask, int gridID)
+{
+  double xlon1 = 0, xlon2 = 0, xlat1 = 0, xlat2 = 0;
+  getlonlatparams(0, &xlon1, &xlon2, &xlat1, &xlat2);
+
+  int nlon = gridInqXsize(gridID);
+  int nlat = gridInqYsize(gridID);
+
+  int gridsize = nlon*nlat;
+
+  int grid_is_circular = gridIsCircular(gridID);
+
+  double *xvals = (double *) Malloc(gridsize*sizeof(double));
+  double *yvals = (double *) Malloc(gridsize*sizeof(double));
+
+  gridInqXvals(gridID, xvals);
+  gridInqYvals(gridID, yvals);
+
+  char xunits[CDI_MAX_NAME];
+  char yunits[CDI_MAX_NAME];
+  gridInqXunits(gridID, xunits);
+  gridInqYunits(gridID, yunits);
+
+  double xfact = 1, yfact = 1;
+  if ( strncmp(xunits, "radian", 6) == 0 ) xfact = RAD2DEG;
+  if ( strncmp(yunits, "radian", 6) == 0 ) yfact = RAD2DEG;
+
+  double xval, yval, xfirst, xlast, ylast;
+  int lp2 = FALSE;
+
+  if ( xlon1 > xlon2 ) 
+    cdoAbort("The second longitude have to be greater than the first one!");
+
+  if ( xlat1 > xlat2 )
+    {
+      double xtemp = xlat1;
+      xlat1 = xlat2;
+      xlat2 = xtemp;
+    }
+
+  int ilat, ilon;
+  
+  for ( ilat = 0; ilat < nlat; ilat++ )
+    {
+      xlast = xfact * xvals[ilat*nlon + nlon-1];
+      ylast = yfact * yvals[ilat*nlon + nlon-1];
+      if ( ylast >= xlat1 && ylast <= xlat2 )
+        if ( grid_is_circular && xlon1 <= xlast && xlon2 > xlast && (xlon2-xlon1) < 360 )
+          {
+            lp2 = TRUE;
+          }
+    }
+
+  for ( ilat = 0; ilat < nlat; ilat++ )
+    {
+      for ( ilon = 0; ilon < nlon; ilon++ )
+        {
+          mask[nlon*ilat + ilon] = 1;
+
+          xval = xvals[ilat*nlon + ilon];
+          yval = yvals[ilat*nlon + ilon];
+
+          xval *= xfact;
+          yval *= yfact;
+
+          if ( yval >= xlat1 && yval <= xlat2 )
+            {
+              if ( lp2 )
+                {
+                  xfirst = xfact * xvals[ilat*nlon];
+                  if ( xfirst < xlon1 ) xfirst = xlon1;
+                  
+                  xlast = xfact * xvals[ilat*nlon + nlon-1];
+                  if ( xlast > xlon2 ) xlast = xlon2;
+
+                  if ( xval >= xlon1 && xval <= xlast )
+                    {
+                      mask[nlon*ilat + ilon] = 0;
+                    }
+                  else if ( xval >= xfirst && xval <= xlon2 )
+                    {
+                      mask[nlon*ilat + ilon] = 0;
+                    }
+                }
+              else
+                {
+                  if ( ((xval     >= xlon1 && xval     <= xlon2) ||
+                        (xval-360 >= xlon1 && xval-360 <= xlon2) ||
+                        (xval+360 >= xlon1 && xval+360 <= xlon2)) )
+                    {
+                      mask[nlon*ilat + ilon] = 0;
+                    }
+                }
+            }
+        }
+    }
+
+  Free(xvals);
+  Free(yvals);
+}
+
 static
 void maskregion(int *mask, int gridID, double *xcoords, double *ycoords, int nofcoords)
 {
@@ -145,8 +247,8 @@ void maskregion(int *mask, int gridID, double *xcoords, double *ycoords, int nof
   nlon = gridInqXsize(gridID);
   nlat = gridInqYsize(gridID);
 
-  xvals = (double*) malloc(nlon*sizeof(double));
-  yvals = (double*) malloc(nlat*sizeof(double));
+  xvals = (double*) Malloc(nlon*sizeof(double));
+  yvals = (double*) Malloc(nlat*sizeof(double));
 
   gridInqXvals(gridID, xvals);
   gridInqYvals(gridID, yvals);  
@@ -228,52 +330,42 @@ void maskregion(int *mask, int gridID, double *xcoords, double *ycoords, int nof
 	}
     }
       
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
 }
 
 
 void *Maskbox(void *argument)
 {
-  int MASKLONLATBOX, MASKINDEXBOX, MASKREGION;
-  int operatorID;
-  int streamID1, streamID2;
-  int nrecs, nvars;
-  int tsID, recID, varID, levelID;
-  int gridsize;
-  int vlistID1, vlistID2;
+  int nrecs;
+  int recID, varID, levelID;
   int gridID = -1;
-  int index, ngrids, gridtype;
+  int index, gridtype = -1;
   int nmiss;
-  int *vars;
   int i, i2;
-  int ndiffgrids;
   int lat1, lat2, lon11, lon12, lon21, lon22;
   int number = 0, nfiles;
   double missval;
-  int *mask;
-  double *array;
-  int taxisID1, taxisID2;
   double *xcoords, *ycoords;
   FILE *fp;
   const char *polyfile;
 
   cdoInitialize(argument);
 
-  MASKLONLATBOX = cdoOperatorAdd("masklonlatbox", 0, 0, "western and eastern longitude and southern and northern latitude");
-  MASKINDEXBOX  = cdoOperatorAdd("maskindexbox",  0, 0, "index of first and last longitude and index of first and last latitude");
-  MASKREGION    = cdoOperatorAdd("maskregion",    0, 0, "limiting coordinates of the region");
+  int MASKLONLATBOX = cdoOperatorAdd("masklonlatbox", 0, 0, "western and eastern longitude and southern and northern latitude");
+  int MASKINDEXBOX  = cdoOperatorAdd("maskindexbox",  0, 0, "index of first and last longitude and index of first and last latitude");
+  int MASKREGION    = cdoOperatorAdd("maskregion",    0, 0, "limiting coordinates of the region");
 
-  operatorID = cdoOperatorID();
+  int operatorID = cdoOperatorID();
 
   operatorInputArg(cdoOperatorEnter(operatorID));
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
+  int vlistID1 = streamInqVlist(streamID1);
 
-  ngrids = vlistNgrids(vlistID1);
-  ndiffgrids = 0;
+  int ngrids = vlistNgrids(vlistID1);
+  int ndiffgrids = 0;
   for ( index = 1; index < ngrids; index++ )
     if ( vlistGrid(vlistID1, 0) != vlistGrid(vlistID1, index))
       ndiffgrids++;
@@ -297,14 +389,14 @@ void *Maskbox(void *argument)
 
   operatorInputArg(cdoOperatorEnter(operatorID));
 
-  vlistID2 = vlistDuplicate(vlistID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  nvars = vlistNvars(vlistID1);
-  vars  = (int*) malloc(nvars*sizeof(int));
+  int nvars = vlistNvars(vlistID1);
+  int *vars = (int *) Malloc(nvars*sizeof(int));
   for ( varID = 0; varID < nvars; varID++ )
     {
       if ( gridID == vlistInqVarGrid(vlistID1, varID) )
@@ -313,19 +405,26 @@ void *Maskbox(void *argument)
 	vars[varID] = FALSE;
     }
 
-  streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
-  gridsize = gridInqSize(gridID);
-  array = (double*) malloc( gridsize*sizeof(double));
-  mask  = (int*) malloc( gridsize*sizeof(int));
-  for( i=0;  i < gridsize; i++) mask[i] = 1;
+  int gridsize = gridInqSize(gridID);
+  double *array = (double *) Malloc(gridsize*sizeof(double));
+  int *mask  = (int *) Malloc(gridsize*sizeof(int));
+  for ( i = 0;  i < gridsize; ++i ) mask[i] = 1;
  
   if ( operatorID == MASKLONLATBOX )
     {
-      genlonlatbox(0, gridID, &lat1, &lat2, &lon11, &lon12, &lon21, &lon22);
-      maskbox(mask, gridID, lat1, lat2, lon11, lon12, lon21, lon22);
+      if ( gridtype == GRID_CURVILINEAR )
+        {
+          maskbox_curv(mask, gridID);
+        }
+      else
+        {
+          genlonlatbox(0, gridID, &lat1, &lat2, &lon11, &lon12, &lon21, &lon22);
+          maskbox(mask, gridID, lat1, lat2, lon11, lon12, lon21, lon22);
+        }
     }
   if ( operatorID == MASKINDEXBOX )
     {
@@ -334,8 +433,8 @@ void *Maskbox(void *argument)
     }
   if ( operatorID == MASKREGION )
     {
-      xcoords = (double*) malloc( MAX_VALS*sizeof(double));
-      ycoords = (double*) malloc( MAX_VALS*sizeof(double));
+      xcoords = (double*) Malloc( MAX_VALS*sizeof(double));
+      ycoords = (double*) Malloc( MAX_VALS*sizeof(double));
       nfiles = operatorArgc();
      
       for ( i2 = 0; i2 < nfiles; i2++ )
@@ -353,11 +452,11 @@ void *Maskbox(void *argument)
 	    }
 	  fclose(fp); 
 	}
-      if ( xcoords ) free ( xcoords );
-      if ( ycoords ) free ( ycoords );
+      if ( xcoords ) Free( xcoords );
+      if ( ycoords ) Free( ycoords );
     }
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       taxisCopyTimestep(taxisID2, taxisID1);
@@ -393,11 +492,11 @@ void *Maskbox(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( vars  ) free(vars);
-  if ( array ) free(array);
-  if ( mask )  free(mask);
+  if ( vars  ) Free(vars);
+  if ( array ) Free(array);
+  if ( mask )  Free(mask);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Mastrfu.c b/src/Mastrfu.c
index 227bc88..e4dd31c 100644
--- a/src/Mastrfu.c
+++ b/src/Mastrfu.c
@@ -38,12 +38,12 @@ void mastrfu(int gridID, int zaxisID, double *array1, double *array2, int nmiss,
 
   int nlat = gridInqSize(gridID);
   int nlev = zaxisInqSize(zaxisID);
-  double *phi    = (double*) malloc(nlat*sizeof(double));
-  double *dummy  = (double*) malloc(nlat*sizeof(double));
-  double *cosphi = (double*) malloc(nlat*sizeof(double));
-  double *plevel = (double*) malloc(nlev*sizeof(double));
-  double **field1 = (double**) malloc(nlev*sizeof(double*));
-  double **field2 = (double**) malloc(nlev*sizeof(double*));
+  double *phi    = (double*) Malloc(nlat*sizeof(double));
+  double *dummy  = (double*) Malloc(nlat*sizeof(double));
+  double *cosphi = (double*) Malloc(nlat*sizeof(double));
+  double *plevel = (double*) Malloc(nlev*sizeof(double));
+  double **field1 = (double**) Malloc(nlev*sizeof(double*));
+  double **field2 = (double**) Malloc(nlev*sizeof(double*));
 
   zaxisInqLevels(zaxisID, plevel);
 
@@ -95,12 +95,12 @@ void mastrfu(int gridID, int zaxisID, double *array1, double *array2, int nmiss,
 	    }
     }
 
-  free(field2);
-  free(field1);
-  free(plevel);
-  free(cosphi);
-  free(dummy);
-  free(phi);
+  Free(field2);
+  Free(field1);
+  Free(plevel);
+  Free(cosphi);
+  Free(dummy);
+  Free(phi);
 }
 
 
@@ -156,8 +156,8 @@ void *Mastrfu(void *argument)
 
   streamDefVlist(streamID2, vlistID2);
 
-  double *array1 = (double*) malloc(gridsize*nlev*sizeof(double));
-  double *array2 = (double*) malloc(gridsize*nlev*sizeof(double));
+  double *array1 = (double*) Malloc(gridsize*nlev*sizeof(double));
+  double *array2 = (double*) Malloc(gridsize*nlev*sizeof(double));
 
   int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -191,10 +191,10 @@ void *Mastrfu(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array1 ) free(array1);
-  if ( array2 ) free(array2);
+  if ( array1 ) Free(array1);
+  if ( array2 ) Free(array2);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Math.c b/src/Math.c
index 5071b71..e7e1300 100644
--- a/src/Math.c
+++ b/src/Math.c
@@ -54,6 +54,7 @@ void *Math(void *argument)
   int vlistID1, vlistID2;
   int nmiss, nmiss2;
   int i;
+  int number;
   double missval1;
   double *array1, *array2;
   double rc = 0;
@@ -97,9 +98,10 @@ void *Math(void *argument)
   vlistDefTaxis(vlistID2, taxisID2);
 
   gridsize = vlistGridsizeMax(vlistID1);
+  if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
 
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
+  array2 = (double*) Malloc(gridsize*sizeof(double));
 
   streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
@@ -119,81 +121,101 @@ void *Math(void *argument)
 
 	  missval1 = vlistInqVarMissval(vlistID1, varID);
 	  gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
-
-	  switch ( operfunc )
-	    {
-	    case ABS:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : fabs(array1[i]);
-	      break;
-	    case FINT:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : (int)(array1[i]);
-	      break;
-	    case FNINT:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : round(array1[i]);
-	      break;
-	    case SQR:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : array1[i]*array1[i];
-	      break;
-	    case SQRT:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : SQRT(array1[i]);
-	      break;
-	    case EXP:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : exp(array1[i]);
-	      break;
-	    case LN:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) || array1[i] < 0 ? missval1 : log(array1[i]);
-	      break;
-	    case LOG10:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) || array1[i] < 0 ? missval1 : log10(array1[i]);
-	      break;
-	    case SIN:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : sin(array1[i]);
-	      break;
-	    case COS:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : cos(array1[i]);
-	      break;
-	    case TAN:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : tan(array1[i]);
-	      break;
-	    case ASIN:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) || array1[i] < -1
-		         || array1[i] > 1 ? missval1 : asin(array1[i]);
-	      break;
-	    case ACOS:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) || array1[i] < -1
-		         || array1[i] > 1 ? missval1 : acos(array1[i]);
-	      break;
-	    case ATAN:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : atan(array1[i]);
-	      break;
-	    case POW:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : pow(array1[i], rc);
-	      break;
-	    case RECI:
-	      for ( i = 0; i < gridsize; i++ )
-		array2[i] = DBL_IS_EQUAL(array1[i], missval1) || DBL_IS_EQUAL(array1[i], 0.) ? missval1 : 1/array1[i];
-	      break;
-	    default:
-	      cdoAbort("operator not implemented!");
-	      break;
-	    }
-
-	  nmiss2 = 0;
+          number   = vlistInqVarNumber(vlistID1, varID);
+
+          if ( number == CDI_REAL )
+            {
+              switch ( operfunc )
+                {
+                case ABS:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : fabs(array1[i]);
+                  break;
+                case FINT:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : (int)(array1[i]);
+                  break;
+                case FNINT:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : round(array1[i]);
+                  break;
+                case SQR:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : array1[i]*array1[i];
+                  break;
+                case SQRT:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : SQRT(array1[i]);
+                  break;
+                case EXP:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : exp(array1[i]);
+                  break;
+                case LN:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) || array1[i] < 0 ? missval1 : log(array1[i]);
+                  break;
+                case LOG10:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) || array1[i] < 0 ? missval1 : log10(array1[i]);
+                  break;
+                case SIN:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : sin(array1[i]);
+                  break;
+                case COS:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : cos(array1[i]);
+                  break;
+                case TAN:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : tan(array1[i]);
+                  break;
+                case ASIN:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) || array1[i] < -1
+                              || array1[i] > 1 ? missval1 : asin(array1[i]);
+                  break;
+                case ACOS:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) || array1[i] < -1
+                              || array1[i] > 1 ? missval1 : acos(array1[i]);
+                  break;
+                case ATAN:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : atan(array1[i]);
+                  break;
+                case POW:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) ? missval1 : pow(array1[i], rc);
+                  break;
+                case RECI:
+                  for ( i = 0; i < gridsize; i++ )
+                    array2[i] = DBL_IS_EQUAL(array1[i], missval1) || DBL_IS_EQUAL(array1[i], 0.) ? missval1 : 1/array1[i];
+                  break;
+                default:
+                  cdoAbort("operator not implemented!");
+                  break;
+                }
+            }
+          else
+            {
+              switch ( operfunc )
+                {
+                case SQR:
+                  for ( i = 0; i < gridsize; i++ )
+                    {
+                      array2[i*2]   = array1[i*2]*array1[i*2] + array1[i*2+1]*array1[i*2+1];
+                      array2[i*2+1] = 0;
+                    }
+                  break;
+                default:
+                  cdoAbort("operator not implemented for complex numbers!");
+                  break;
+                }
+            }
+
+          nmiss2 = 0;
 	  for ( i = 0; i < gridsize; i++ )
 	    if ( DBL_IS_EQUAL(array2[i], missval1) ) nmiss2++;
 
@@ -208,10 +230,10 @@ void *Math(void *argument)
 
   vlistDestroy(vlistID2);
 
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Merge.c b/src/Merge.c
index 13f7133..6bc4254 100644
--- a/src/Merge.c
+++ b/src/Merge.c
@@ -61,7 +61,7 @@ void checkDupEntry(int vlistID1, int vlistID2, const char *filename)
       if ( nlev1 > mlev1 )
 	{
 	  mlev1 = nlev1;
-	  lev1 = (double*) realloc(lev1, mlev1*sizeof(double));
+	  lev1 = (double*) Realloc(lev1, mlev1*sizeof(double));
 	}
       zaxisInqLevels(zaxisID1, lev1);
 
@@ -80,7 +80,7 @@ void checkDupEntry(int vlistID1, int vlistID2, const char *filename)
 	      if ( nlev2 > mlev2 )
 		{
 		  mlev2 = nlev2;
-		  lev2 = (double*) realloc(lev2, mlev2*sizeof(double));
+		  lev2 = (double*) Realloc(lev2, mlev2*sizeof(double));
 		}
 	      zaxisInqLevels(zaxisID2, lev2);
 
@@ -110,8 +110,8 @@ void checkDupEntry(int vlistID1, int vlistID2, const char *filename)
 	}
     }
 
-  if ( lev1 ) free(lev1);
-  if ( lev2 ) free(lev2);
+  if ( lev1 ) Free(lev1);
+  if ( lev2 ) Free(lev2);
 }
 /*
 static
@@ -120,7 +120,7 @@ int vlistConstVars(int vlistID)
   int nvars = vlistNvars(vlistID);
 
   for ( int varID = 0; varID < nvars; ++varID )
-    if ( vlistInqVarTsteptype(vlistID, varID) != TSTEP_CONSTANT ) return (0);
+    if ( vlistInqVarTsteptype(vlistID, varID) != TSTEP_CONSTANT ) return 0;
 
   return (1);
 }
@@ -170,10 +170,10 @@ void *Merge(void *argument)
       if ( !userFileOverwrite(ofilename) )
 	cdoAbort("Outputfile %s already exists!", ofilename);
 
-  int *streamIDs = (int*) malloc(nmerge*sizeof(int));
-  int *vlistIDs  = (int*) malloc(nmerge*sizeof(int));
-  int *numrecs   = (int*) malloc(nmerge*sizeof(int));
-  int *numsteps  = (int*) malloc(nmerge*sizeof(int));
+  int *streamIDs = (int*) Malloc(nmerge*sizeof(int));
+  int *vlistIDs  = (int*) Malloc(nmerge*sizeof(int));
+  int *numrecs   = (int*) Malloc(nmerge*sizeof(int));
+  int *numsteps  = (int*) Malloc(nmerge*sizeof(int));
 
   for ( index = 0; index < nmerge; index++ )
     {
@@ -182,8 +182,21 @@ void *Merge(void *argument)
       vlistIDs[index]  = streamInqVlist(streamID1);
     }
 
+  int taxisindex = 0;
   int vlistID1 = vlistIDs[0];
   int taxisID1 = vlistInqTaxis(vlistID1);
+  if ( vlistNtsteps(vlistID1) == 0 )
+    for ( index = 1; index < nmerge; index++ )
+      {
+        vlistID1 = vlistIDs[index];
+        if ( vlistNtsteps(vlistID1) != 0 )
+          {
+            taxisindex = index;
+            taxisID1 = vlistInqTaxis(vlistID1);
+            break;
+          }
+      }
+
   int taxisID2 = taxisDuplicate(taxisID1);
 
   int vlistID2 = vlistCreate();
@@ -200,7 +213,6 @@ void *Merge(void *argument)
   int numconst = 0;
   for ( index = 0; index < nmerge; index++ )
     {
-      streamID1 = streamIDs[index];
       vlistID1  = vlistIDs[index];
       numsteps[index] = vlistNtsteps(vlistID1);
       if ( numsteps[index] == 0 ) numsteps[index] = 1;
@@ -237,10 +249,9 @@ void *Merge(void *argument)
   if ( ! lcopy )
     {
       gridsize = vlistGridsizeMax(vlistID2);
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
     }
 
-  int firstindex = 0;
   int tsID = 0;
   while ( tsID >= 0 )
     {
@@ -273,11 +284,11 @@ void *Merge(void *argument)
       for ( index = 0; index < nmerge; index++ )
 	printf("tsID %d   %d sID %d vID %d nrecs %d\n", tsID, index, streamIDs[index], vlistIDs[index], numrecs[index]);
       */
-      if ( numrecs[firstindex] == 0 )
+      if ( numrecs[taxisindex] == 0 )
 	{
 	  for ( index = 1; index < nmerge; index++ )
 	    if ( vlistIDs[index] != -1 && numrecs[index] != 0 )
-	      cdoWarning("Input stream %d has %d timestep%s. Stream %d has more timesteps, skipped!", firstindex+1, tsID, tsID==1?"":"s", index+1);
+	      cdoWarning("Input stream %d has %d timestep%s. Stream %d has more timesteps, skipped!", taxisindex+1, tsID, tsID==1?"":"s", index+1);
 	  break;
 	}
       else
@@ -285,12 +296,15 @@ void *Merge(void *argument)
 	  for ( index = 1; index < nmerge; index++ )
 	    if ( vlistIDs[index] != -1 && numrecs[index] == 0 )
 	      {
-		cdoWarning("Input stream %d has %d timestep%s. Stream %d has more timesteps, skipped!", index+1, tsID, tsID==1?"":"s", firstindex+1);
+		cdoWarning("Input stream %d has %d timestep%s. Stream %d has more timesteps, skipped!", index+1, tsID, tsID==1?"":"s", taxisindex+1);
 		break;
 	      }
 	  if ( index < nmerge ) break;
 	}
 
+      taxisCopyTimestep(taxisID2, taxisID1);
+      streamDefTimestep(streamID2, tsID);
+
       for ( index = 0; index < nmerge; index++ )
 	{
 	  streamID1 = streamIDs[index];
@@ -299,12 +313,6 @@ void *Merge(void *argument)
 
 	  if ( vlistID1 == -1 ) continue;
 
-	  if ( index == firstindex )
-	    {
-	      taxisCopyTimestep(taxisID2, taxisID1);
-	      streamDefTimestep(streamID2, tsID);
-	    }
-
 	  for ( recID = 0; recID < nrecs; recID++ )
 	    {
 	      streamInqRecord(streamID1, &varID, &levelID);
@@ -337,15 +345,15 @@ void *Merge(void *argument)
 
   vlistDestroy(vlistID2);
 
-  if ( streamIDs ) free(streamIDs);
-  if ( vlistIDs  ) free(vlistIDs);
-  if ( numrecs   ) free(numrecs);
-  if ( numsteps  ) free(numsteps);
+  if ( streamIDs ) Free(streamIDs);
+  if ( vlistIDs  ) Free(vlistIDs);
+  if ( numrecs   ) Free(numrecs);
+  if ( numsteps  ) Free(numsteps);
  
   if ( ! lcopy )
-    if ( array ) free(array);
+    if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Mergegrid.c b/src/Mergegrid.c
index a6fee70..fdd5229 100644
--- a/src/Mergegrid.c
+++ b/src/Mergegrid.c
@@ -70,13 +70,13 @@ void gen_index(int gridID1, int gridID2, int *index)
       if ( ! (gridInqXvals(gridID2, NULL) && gridInqYvals(gridID2, NULL)) )
 	cdoAbort("Grid 2 has no values!");
 
-      xvals1 = (double*) malloc(nlon1*sizeof(double));
-      yvals1 = (double*) malloc(nlat1*sizeof(double));
-      xvals2 = (double*) malloc(nlon2*sizeof(double));
-      yvals2 = (double*) malloc(nlat2*sizeof(double));
+      xvals1 = (double*) Malloc(nlon1*sizeof(double));
+      yvals1 = (double*) Malloc(nlat1*sizeof(double));
+      xvals2 = (double*) Malloc(nlon2*sizeof(double));
+      yvals2 = (double*) Malloc(nlat2*sizeof(double));
 
-      xindex = (int*) malloc(nlon2*sizeof(int));
-      yindex = (int*) malloc(nlat2*sizeof(int));
+      xindex = (int*) Malloc(nlon2*sizeof(int));
+      yindex = (int*) Malloc(nlat2*sizeof(int));
 
       gridInqXvals(gridID1, xvals1);
       gridInqYvals(gridID1, yvals1);
@@ -155,12 +155,12 @@ void gen_index(int gridID1, int gridID2, int *index)
 	  }
 
 
-      free(xindex);
-      free(yindex);
-      free(xvals1);
-      free(yvals1);
-      free(xvals2);
-      free(yvals2);
+      Free(xindex);
+      Free(yindex);
+      Free(xvals1);
+      Free(yvals1);
+      Free(xvals2);
+      Free(yvals2);
     }
   else
     cdoAbort("Unsupported grid type: %s", gridNamePtr(gridtype1));
@@ -197,7 +197,7 @@ void *Mergegrid(void *argument)
 
   vlistID2 = streamInqVlist(streamID2);
 
-  vlistCompare(vlistID1, vlistID2, CMP_CODE | CMP_NLEVEL);
+  vlistCompare(vlistID1, vlistID2, CMP_NAME | CMP_NLEVEL);
 
   ndiffgrids = 0;
   for ( index = 1; index < vlistNgrids(vlistID1); index++ )
@@ -219,9 +219,9 @@ void *Mergegrid(void *argument)
   gridsize1 = gridInqSize(gridID1);
   gridsize2 = gridInqSize(gridID2);
 
-  array1 = (double*) malloc(gridsize1*sizeof(double));
-  array2 = (double*) malloc(gridsize2*sizeof(double));
-  gindex = (int*) malloc(gridsize2*sizeof(int));
+  array1 = (double*) Malloc(gridsize1*sizeof(double));
+  array2 = (double*) Malloc(gridsize2*sizeof(double));
+  gindex = (int*) Malloc(gridsize2*sizeof(int));
 
   gen_index(gridID1, gridID2, gindex);
 
@@ -284,11 +284,11 @@ void *Mergegrid(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
  
-  if ( gindex ) free(gindex);
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
+  if ( gindex ) Free(gindex);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Mergetime.c b/src/Mergetime.c
index f8b9113..bfc45d5 100644
--- a/src/Mergetime.c
+++ b/src/Mergetime.c
@@ -31,10 +31,10 @@
 
 void *Mergetime(void *argument)
 {
-  int streamID1, streamID2 = CDI_UNDEFID;
+  int streamID1;
   int tsID2 = 0, recID, varID, levelID;
   int vlistID1, vlistID2;
-  int nfiles, fileID;
+  int fileID;
   int taxisID1, taxisID2 = CDI_UNDEFID;
   int lcopy = FALSE;
   int gridsize;
@@ -44,7 +44,6 @@ void *Mergetime(void *argument)
   int next_fileID;
   int skip_same_time = FALSE;
   int process_timestep;
-  const char *ofilename;
   double *array = NULL;
   typedef struct
   {
@@ -56,7 +55,6 @@ void *Mergetime(void *argument)
     int vtime;
     int nrecs;
   } sfile_t;
-  sfile_t *sf = NULL;
 
   cdoInitialize(argument);
 
@@ -78,9 +76,9 @@ void *Mergetime(void *argument)
 
   if ( UNCHANGED_RECORD ) lcopy = TRUE;
 
-  nfiles = cdoStreamCnt() - 1;
+  int nfiles = cdoStreamCnt() - 1;
 
-  sf = (sfile_t*) malloc(nfiles*sizeof(sfile_t));
+  sfile_t *sf = (sfile_t*) Malloc(nfiles*sizeof(sfile_t));
 
   for ( fileID = 0; fileID < nfiles; fileID++ )
     {
@@ -118,19 +116,19 @@ void *Mergetime(void *argument)
 	}
     }
 
-  ofilename = cdoStreamName(nfiles)->args;
+  const char *ofilename = cdoStreamName(nfiles)->args;
 
   if ( !cdoSilentMode && !cdoOverwriteMode )
     if ( fileExists(ofilename) )
       if ( !userFileOverwrite(ofilename) )
 	cdoAbort("Outputfile %s already exists!", ofilename);
 
-  streamID2 = streamOpenWrite(cdoStreamName(nfiles), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(nfiles), cdoFiletype());
 
   if ( ! lcopy )
     {
       gridsize = vlistGridsizeMax(sf[0].vlistID);
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
     }
 
   while ( TRUE )
@@ -225,11 +223,11 @@ void *Mergetime(void *argument)
   streamClose(streamID2);
 
   if ( ! lcopy )
-    if ( array ) free(array);
+    if ( array ) Free(array);
 
-  if ( sf ) free(sf);
+  if ( sf ) Free(sf);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Merstat.c b/src/Merstat.c
index 1b15e20..da85562 100644
--- a/src/Merstat.c
+++ b/src/Merstat.c
@@ -24,7 +24,9 @@
       Merstat    mermean         Meridional mean
       Merstat    meravg          Meridional average
       Merstat    merstd          Meridional standard deviation
+      Merstat    merstd          Meridional standard deviation [Divisor is (n-1)]
       Merstat    mervar          Meridional variance
+      Merstat    mervar          Meridional variance [Divisor is (n-1)]
       Merstat    merpctl         Meridional percentiles
 */
 
@@ -38,22 +40,12 @@
 
 void *Merstat(void *argument)
 {
-  int operatorID;
-  int operfunc;
-  int streamID1, streamID2;
-  int vlistID1, vlistID2;
   int gridID1, gridID2 = -1, lastgrid = -1;
   int wstatus = FALSE;
-  int nlonmax;
-  int index, ngrids;
+  int index;
   int recID, nrecs;
-  int tsID, varID, levelID;
-  int lim;
-  int ndiffgrids;
-  int taxisID1, taxisID2;
+  int varID, levelID;
   int needWeights = FALSE;
-  int pn = 0;
-  field_t field1, field2;
   char varname[CDI_MAX_NAME];
 
   cdoInitialize(argument);
@@ -64,38 +56,38 @@ void *Merstat(void *argument)
   cdoOperatorAdd("mermean", func_mean, 0, NULL);
   cdoOperatorAdd("meravg",  func_avg,  0, NULL);
   cdoOperatorAdd("mervar",  func_var,  0, NULL);
+  cdoOperatorAdd("mervar1", func_var1, 0, NULL);
   cdoOperatorAdd("merstd",  func_std,  0, NULL);
+  cdoOperatorAdd("merstd1", func_std1, 0, NULL);
   cdoOperatorAdd("merpctl", func_pctl, 0, NULL);
  
-  operatorID = cdoOperatorID();
-  operfunc = cdoOperatorF1(operatorID);
+  int operatorID = cdoOperatorID();
+  int operfunc = cdoOperatorF1(operatorID);
 
-  /* RQ */
+  double pn = 0;
   if ( operfunc == func_pctl )
     {
       operatorInputArg("percentile number");
-      pn = parameter2int(operatorArgv()[0]);
-      
-      if ( pn < 1 || pn > 99 )
-        cdoAbort("Illegal argument: percentile number %d is not in the range 1..99!", pn);
+      pn = parameter2double(operatorArgv()[0]);
+      percentile_check_number(pn);
     }
-  /* QR */
 
   if ( operfunc == func_mean || operfunc == func_avg ||
-       operfunc == func_var  || operfunc == func_std )
+       operfunc == func_var  || operfunc == func_std ||
+       operfunc == func_var1 || operfunc == func_std1 )
     needWeights = TRUE;
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = vlistDuplicate(vlistID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  ngrids = vlistNgrids(vlistID1);
-  ndiffgrids = 0;
+  int ngrids = vlistNgrids(vlistID1);
+  int ndiffgrids = 0;
   for ( index = 1; index < ngrids; index++ )
     if ( vlistGrid(vlistID1, 0) != vlistGrid(vlistID1, index))
       ndiffgrids++;
@@ -118,26 +110,27 @@ void *Merstat(void *argument)
 
   vlistChangeGridIndex(vlistID2, index, gridID2);
 
-  streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
   gridID1 = vlistInqVarGrid(vlistID1, 0);
-  nlonmax = gridInqXsize(gridID1); /* max nlon ? */
+  int nlonmax = gridInqXsize(gridID1); /* max nlon ? */
+  int lim = vlistGridsizeMax(vlistID1);
 
+  field_t field1, field2;
   field_init(&field1);
   field_init(&field2);
 
-  lim = vlistGridsizeMax(vlistID1);
-  field1.ptr    = (double*) malloc(lim*sizeof(double));
+  field1.ptr    = (double*) Malloc(lim*sizeof(double));
   field1.weight = NULL;
   if ( needWeights )
-    field1.weight = (double*) malloc(lim*sizeof(double));
+    field1.weight = (double*) Malloc(lim*sizeof(double));
 
-  field2.ptr  = (double*) malloc(nlonmax*sizeof(double));
+  field2.ptr  = (double*) Malloc(nlonmax*sizeof(double));
   field2.grid = gridID2;
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       taxisCopyTimestep(taxisID2, taxisID1);
@@ -177,11 +170,11 @@ void *Merstat(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( field1.ptr )    free(field1.ptr);
-  if ( field1.weight ) free(field1.weight);
-  if ( field2.ptr )    free(field2.ptr);
+  if ( field1.ptr )    Free(field1.ptr);
+  if ( field1.weight ) Free(field1.weight);
+  if ( field2.ptr )    Free(field2.ptr);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Monarith.c b/src/Monarith.c
index 2d557a5..7014e11 100644
--- a/src/Monarith.c
+++ b/src/Monarith.c
@@ -72,8 +72,8 @@ void *Monarith(void *argument)
   field_init(&field1);
   field_init(&field2);
 
-  field1.ptr = (double*) malloc(gridsize*sizeof(double));
-  field2.ptr = (double*) malloc(gridsize*sizeof(double));
+  field1.ptr = (double*) Malloc(gridsize*sizeof(double));
+  field2.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   taxisID1 = vlistInqTaxis(vlistID1);
   taxisID2 = vlistInqTaxis(vlistID2);
@@ -86,15 +86,15 @@ void *Monarith(void *argument)
 
   nvars  = vlistNvars(vlistID2);
 
-  vardata2  = (double **) malloc(nvars*sizeof(double *));
-  varnmiss2 = (int **) malloc(nvars*sizeof(int *));
+  vardata2  = (double **) Malloc(nvars*sizeof(double *));
+  varnmiss2 = (int **) Malloc(nvars*sizeof(int *));
 
   for ( varID = 0; varID < nvars; varID++ )
     {
       gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
       nlev     = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
-      vardata2[varID]  = (double*) malloc(nlev*gridsize*sizeof(double));
-      varnmiss2[varID] = (int*) malloc(nlev*sizeof(int));
+      vardata2[varID]  = (double*) Malloc(nlev*gridsize*sizeof(double));
+      varnmiss2[varID] = (int*) Malloc(nlev*sizeof(int));
     }
 
   tsID  = 0;
@@ -182,17 +182,17 @@ void *Monarith(void *argument)
 
   for ( varID = 0; varID < nvars; varID++ )
     {
-      free(vardata2[varID]);
-      free(varnmiss2[varID]);
+      Free(vardata2[varID]);
+      Free(varnmiss2[varID]);
     }
 
-  free(vardata2);
-  free(varnmiss2);
+  Free(vardata2);
+  Free(varnmiss2);
 
-  if ( field1.ptr ) free(field1.ptr);
-  if ( field2.ptr ) free(field2.ptr);
+  if ( field1.ptr ) Free(field1.ptr);
+  if ( field2.ptr ) Free(field2.ptr);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Mrotuv.c b/src/Mrotuv.c
index b29d41e..3a4b951 100644
--- a/src/Mrotuv.c
+++ b/src/Mrotuv.c
@@ -261,12 +261,12 @@ void *Mrotuv(void *argument)
   nlon    = gridInqXsize(gridID1);
   nlat    = gridInqYsize(gridID1);
 
-  grid1x  = (double*) malloc(gridsize*sizeof(double));
-  grid1y  = (double*) malloc(gridsize*sizeof(double));
-  gridux  = (double*) malloc(gridsize*sizeof(double));
-  griduy  = (double*) malloc(gridsize*sizeof(double));
-  gridvx  = (double*) malloc(gridsize*sizeof(double));
-  gridvy  = (double*) malloc(gridsize*sizeof(double));
+  grid1x  = (double*) Malloc(gridsize*sizeof(double));
+  grid1y  = (double*) Malloc(gridsize*sizeof(double));
+  gridux  = (double*) Malloc(gridsize*sizeof(double));
+  griduy  = (double*) Malloc(gridsize*sizeof(double));
+  gridvx  = (double*) Malloc(gridsize*sizeof(double));
+  gridvy  = (double*) Malloc(gridsize*sizeof(double));
 
   gridsizex = (nlon+2)*nlat;
 
@@ -331,19 +331,19 @@ void *Mrotuv(void *argument)
   missval1 = vlistInqVarMissval(vlistID1, uid);
   missval2 = vlistInqVarMissval(vlistID1, vid);
 
-  ufield  = (double*) malloc(gridsize*sizeof(double));
-  vfield  = (double*) malloc(gridsize*sizeof(double));
+  ufield  = (double*) Malloc(gridsize*sizeof(double));
+  vfield  = (double*) Malloc(gridsize*sizeof(double));
 
-  urfield  = (double**) malloc(nlevs*sizeof(double*));
-  vrfield  = (double**) malloc(nlevs*sizeof(double*));
+  urfield  = (double**) Malloc(nlevs*sizeof(double*));
+  vrfield  = (double**) Malloc(nlevs*sizeof(double*));
   for ( lid = 0; lid < nlevs; lid++ )
     {
-      urfield[lid] = (double*) malloc(gridsize*sizeof(double));
-      vrfield[lid] = (double*) malloc(gridsize*sizeof(double));
+      urfield[lid] = (double*) Malloc(gridsize*sizeof(double));
+      vrfield[lid] = (double*) Malloc(gridsize*sizeof(double));
     }
 
-  uhelp   = (double*) malloc(gridsizex*sizeof(double));
-  vhelp   = (double*) malloc(gridsizex*sizeof(double));
+  uhelp   = (double*) Malloc(gridsizex*sizeof(double));
+  vhelp   = (double*) Malloc(gridsizex*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -425,18 +425,18 @@ void *Mrotuv(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( ufield  ) free(ufield);
-  if ( vfield  ) free(vfield);
-  if ( urfield ) free(urfield);
-  if ( vrfield ) free(vrfield);
-  if ( uhelp   ) free(uhelp);
-  if ( vhelp   ) free(vhelp);
-  if ( gridux  ) free(gridux);
-  if ( griduy  ) free(griduy);
-  if ( gridvx  ) free(gridvx);
-  if ( gridvy  ) free(gridvy);
+  if ( ufield  ) Free(ufield);
+  if ( vfield  ) Free(vfield);
+  if ( urfield ) Free(urfield);
+  if ( vrfield ) Free(vrfield);
+  if ( uhelp   ) Free(uhelp);
+  if ( vhelp   ) Free(vhelp);
+  if ( gridux  ) Free(gridux);
+  if ( griduy  ) Free(griduy);
+  if ( gridvx  ) Free(gridvx);
+  if ( gridvy  ) Free(gridvy);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Mrotuvb.c b/src/Mrotuvb.c
index 964d2c8..26f39c1 100644
--- a/src/Mrotuvb.c
+++ b/src/Mrotuvb.c
@@ -162,8 +162,8 @@ void uv_to_p_grid(int nlon, int nlat, double *grid1x, double *grid1y,
   double *gxhelp, *gyhelp;
 
   gridsizex = (nlon+2)*nlat;
-  gxhelp  = (double*) malloc(gridsizex*sizeof(double));
-  gyhelp  = (double*) malloc(gridsizex*sizeof(double));
+  gxhelp  = (double*) Malloc(gridsizex*sizeof(double));
+  gyhelp  = (double*) Malloc(gridsizex*sizeof(double));
 
   /* load to a help field */
   for ( j = 0; j < nlat; j++ )
@@ -252,12 +252,11 @@ void uv_to_p_grid(int nlon, int nlat, double *grid1x, double *grid1y,
 	/* printf("%d %d %g %g %g %g \n", j, i, gx2, gy2, grid3x[IX2D(j,i,nlon)], grid3y[IX2D(j,i,nlon)]); */
       }
 
-  free(gxhelp);
-  free(gyhelp);
+  Free(gxhelp);
+  Free(gyhelp);
 }
 
 
-
 void *Mrotuvb(void *argument)
 {
   int streamID1, streamID2, streamID3;
@@ -301,7 +300,7 @@ void *Mrotuvb(void *argument)
   gridID1 = vlistGrid(vlistID1, 0);
   gridID2 = vlistGrid(vlistID2, 0);
   gridsize = gridInqSize(gridID1);
-  if ( gpint == TRUE  && gridID1 == gridID2 ) cdoAbort("Input grids are the same!");
+  if ( gpint == TRUE  && gridID1 == gridID2 ) cdoAbort("Input grids are the same, use parameter >noint< to disable interpolation!");
   if ( gpint == FALSE && gridID1 != gridID2 ) cdoAbort("Input grids are not the same!");
   if ( gridsize != gridInqSize(gridID2) ) cdoAbort("Grids have different size!");
 
@@ -323,12 +322,12 @@ void *Mrotuvb(void *argument)
   nlon    = gridInqXsize(gridID1);
   nlat    = gridInqYsize(gridID1);
 
-  grid1x  = (double*) malloc(gridsize*sizeof(double));
-  grid1y  = (double*) malloc(gridsize*sizeof(double));
-  grid2x  = (double*) malloc(gridsize*sizeof(double));
-  grid2y  = (double*) malloc(gridsize*sizeof(double));
-  grid3x  = (double*) malloc(gridsize*sizeof(double));
-  grid3y  = (double*) malloc(gridsize*sizeof(double));
+  grid1x  = (double*) Malloc(gridsize*sizeof(double));
+  grid1y  = (double*) Malloc(gridsize*sizeof(double));
+  grid2x  = (double*) Malloc(gridsize*sizeof(double));
+  grid2y  = (double*) Malloc(gridsize*sizeof(double));
+  grid3x  = (double*) Malloc(gridsize*sizeof(double));
+  grid3y  = (double*) Malloc(gridsize*sizeof(double));
 
   gridInqXvals(gridID1, grid1x);
   gridInqYvals(gridID1, grid1y);
@@ -364,10 +363,10 @@ void *Mrotuvb(void *argument)
       memcpy(grid3y, grid1y, gridsize*sizeof(double));
     }
 
-  if ( grid1x ) free(grid1x);
-  if ( grid1y ) free(grid1y);
-  if ( grid2x ) free(grid2x);
-  if ( grid2y ) free(grid2y);
+  if ( grid1x ) Free(grid1x);
+  if ( grid1y ) Free(grid1y);
+  if ( grid2x ) Free(grid2x);
+  if ( grid2y ) Free(grid2y);
 
   gridID3 = gridCreate(GRID_CURVILINEAR, gridsize);
   gridDefPrec(gridID3, gridInqPrec(gridID1));
@@ -407,16 +406,16 @@ void *Mrotuvb(void *argument)
   missval1 = vlistInqVarMissval(vlistID1, 0);
   missval2 = vlistInqVarMissval(vlistID2, 0);
 
-  ufield  = (double*) malloc(gridsize*sizeof(double));
-  vfield  = (double*) malloc(gridsize*sizeof(double));
-  urfield = (double*) malloc(gridsize*sizeof(double));
-  vrfield = (double*) malloc(gridsize*sizeof(double));
+  ufield  = (double*) Malloc(gridsize*sizeof(double));
+  vfield  = (double*) Malloc(gridsize*sizeof(double));
+  urfield = (double*) Malloc(gridsize*sizeof(double));
+  vrfield = (double*) Malloc(gridsize*sizeof(double));
 
   if ( gpint )
     {
       int gridsizex = (nlon+2)*nlat;
-      uhelp   = (double*) malloc(gridsizex*sizeof(double));
-      vhelp   = (double*) malloc(gridsizex*sizeof(double));
+      uhelp   = (double*) Malloc(gridsizex*sizeof(double));
+      vhelp   = (double*) Malloc(gridsizex*sizeof(double));
     }
 
   tsID = 0;
@@ -522,19 +521,19 @@ void *Mrotuvb(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( ufield  ) free(ufield);
-  if ( vfield  ) free(vfield);
-  if ( urfield ) free(urfield);
-  if ( vrfield ) free(vrfield);
+  if ( ufield  ) Free(ufield);
+  if ( vfield  ) Free(vfield);
+  if ( urfield ) Free(urfield);
+  if ( vrfield ) Free(vrfield);
   if ( gpint )
     {
-      if ( uhelp   ) free(uhelp);
-      if ( vhelp   ) free(vhelp);
+      if ( uhelp   ) Free(uhelp);
+      if ( vhelp   ) Free(vhelp);
     }
-  if ( grid3x  ) free(grid3x);
-  if ( grid3y  ) free(grid3y);
+  if ( grid3x  ) Free(grid3x);
+  if ( grid3y  ) Free(grid3y);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Ninfo.c b/src/Ninfo.c
index 095218c..e70a62e 100644
--- a/src/Ninfo.c
+++ b/src/Ninfo.c
@@ -154,5 +154,5 @@ void *Ninfo(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Nmltest.c b/src/Nmltest.c
index 8cb0881..efbfbcc 100644
--- a/src/Nmltest.c
+++ b/src/Nmltest.c
@@ -53,5 +53,5 @@ void *Nmltest(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Output.c b/src/Output.c
index 1d7a522..f346dda 100644
--- a/src/Output.c
+++ b/src/Output.c
@@ -113,7 +113,7 @@ void *Output(void *argument)
 	for ( i = 0; i < npar; i++ )
 	  cdoPrint("key %d = %s", i+1, parnames[i]);
 
-      keys = (int*) malloc(npar*sizeof(int));
+      keys = (int*) Malloc(npar*sizeof(int));
       nkeys = 0;
       nKeys = sizeof(Keynames)/sizeof(char *);
       for ( i = 0; i < npar; i++ )
@@ -173,7 +173,7 @@ void *Output(void *argument)
       gridsize = gridInqSize(gridID);
       gridtype = gridInqType(gridID);
 
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
 
       if ( operatorID == OUTPUTFLD || operatorID == OUTPUTXYZ || operatorID == OUTPUTTAB )
 	{
@@ -184,8 +184,8 @@ void *Output(void *argument)
 
 	  gridtype = gridInqType(gridID);
 
-	  grid_center_lon = (double*) malloc(gridsize*sizeof(double));
-	  grid_center_lat = (double*) malloc(gridsize*sizeof(double));
+	  grid_center_lon = (double*) Malloc(gridsize*sizeof(double));
+	  grid_center_lat = (double*) Malloc(gridsize*sizeof(double));
 	  gridInqXvals(gridID, grid_center_lon);
 	  gridInqYvals(gridID, grid_center_lat);
 
@@ -333,7 +333,7 @@ void *Output(void *argument)
 		{
 		  if ( tsID == 0 && recID == 0 )
 		    {
-		      char *fname = "frontplane.xyz";
+		      const char *fname = "frontplane.xyz";
 		      FILE *fp;
 		      double fmin = 0;
 		      double dx, x0, y0, z0, x, y, z;
@@ -449,14 +449,14 @@ void *Output(void *argument)
 	}
       streamClose(streamID);
 
-      if ( array ) free(array);
-      if ( grid_center_lon ) free(grid_center_lon);
-      if ( grid_center_lat ) free(grid_center_lat);
+      if ( array ) Free(array);
+      if ( grid_center_lon ) Free(grid_center_lon);
+      if ( grid_center_lat ) Free(grid_center_lat);
     }
 
-  if ( keys ) free(keys);
+  if ( keys ) Free(keys);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Outputgmt.c b/src/Outputgmt.c
index 924ec68..f78be18 100644
--- a/src/Outputgmt.c
+++ b/src/Outputgmt.c
@@ -177,7 +177,7 @@ void verify_grid(int gridtype, int gridsize, int ncorner,
   double lon_bounds[mnv], lat_bounds[mnv];
   double area, sumarea;
 
-  alone_cell = (int*) malloc(gridsize*ncorner*sizeof(int));
+  alone_cell = (int*) Malloc(gridsize*ncorner*sizeof(int));
 
   check_corners = 0; /* don't execute corner checking (last loop) */
   nout = 0;
@@ -462,7 +462,7 @@ void verify_grid(int gridtype, int gridsize, int ncorner,
 	cdoWarning("%d of %d corners are lonely on the grid!", nout, gridsize*ncorner);
     }
 
-  free(alone_cell);
+  Free(alone_cell);
 }
 
 
@@ -476,7 +476,7 @@ void verify_grid_old(int gridtype, int gridsize, int ncorner,
   int isnegative;
   double area;
   double lon, lat;
-  double lon_bounds[9], lat_bounds[9];
+  double lon_bounds[ncorner], lat_bounds[ncorner];
 
   /* check that all centers are inside the bounds */
 
@@ -696,7 +696,7 @@ void *Outputgmt(void *argument)
 
   if ( gridInqMaskGME(gridID, NULL) )
     {
-      grid_mask = (int*) malloc(gridsize*sizeof(int));
+      grid_mask = (int*) Malloc(gridsize*sizeof(int));
       gridInqMaskGME(gridID, grid_mask);
     }
 
@@ -734,8 +734,8 @@ void *Outputgmt(void *argument)
 
   grid_is_circular = gridIsCircular(gridID);
 
-  grid_center_lat = (double*) malloc(gridsize*sizeof(double));
-  grid_center_lon = (double*) malloc(gridsize*sizeof(double));
+  grid_center_lat = (double*) Malloc(gridsize*sizeof(double));
+  grid_center_lon = (double*) Malloc(gridsize*sizeof(double));
 
   gridInqYvals(gridID, grid_center_lat);
   gridInqXvals(gridID, grid_center_lon);
@@ -756,8 +756,8 @@ void *Outputgmt(void *argument)
 
       gridsize2 = nlat*(nlon+1);
 
-      grid_center_lat2 = (double*) malloc(gridsize2*sizeof(double));
-      grid_center_lon2 = (double*) malloc(gridsize2*sizeof(double));
+      grid_center_lat2 = (double*) Malloc(gridsize2*sizeof(double));
+      grid_center_lon2 = (double*) Malloc(gridsize2*sizeof(double));
 
       make_cyclic(grid_center_lat, grid_center_lat2, nlon, nlat);
       make_cyclic(grid_center_lon, grid_center_lon2, nlon, nlat);
@@ -773,9 +773,9 @@ void *Outputgmt(void *argument)
       plat = grid_center_lat2;
     }
 
-  zaxis_center_lev = (double*) malloc(nlev*sizeof(double));
-  zaxis_lower_lev  = (double*) malloc(nlev*sizeof(double));
-  zaxis_upper_lev  = (double*) malloc(nlev*sizeof(double));
+  zaxis_center_lev = (double*) Malloc(nlev*sizeof(double));
+  zaxis_lower_lev  = (double*) Malloc(nlev*sizeof(double));
+  zaxis_upper_lev  = (double*) Malloc(nlev*sizeof(double));
 
   zaxisInqLevels(zaxisID, zaxis_center_lev);
 
@@ -783,8 +783,8 @@ void *Outputgmt(void *argument)
     {
       if ( ncorner == 0 ) cdoAbort("grid corner missing!");
       nalloc = ncorner*gridsize;
-      grid_corner_lat = (double*) realloc(grid_corner_lat, nalloc*sizeof(double));
-      grid_corner_lon = (double*) realloc(grid_corner_lon, nalloc*sizeof(double));
+      grid_corner_lat = (double*) Realloc(grid_corner_lat, nalloc*sizeof(double));
+      grid_corner_lon = (double*) Realloc(grid_corner_lon, nalloc*sizeof(double));
 
       if ( gridInqYbounds(gridID, NULL) && gridInqXbounds(gridID, NULL) )
 	{
@@ -833,21 +833,21 @@ void *Outputgmt(void *argument)
 	}
     }
 
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
   parray = array;
 						
   if ( operatorID == OUTPUTCENTER2 && grid_is_circular )
     {
-      array2 = (double*) malloc(nlat*(nlon+1)*sizeof(double));
+      array2 = (double*) Malloc(nlat*(nlon+1)*sizeof(double));
       parray = array2;
     }
 
   if ( operatorID == OUTPUTVECTOR )
     {
-      uf    = (double*) malloc(gridsize*sizeof(double));
-      vf    = (double*) malloc(gridsize*sizeof(double));
-      alpha = (double*) malloc(gridsize*sizeof(double));
-      auv   = (double*) malloc(gridsize*sizeof(double));
+      uf    = (double*) Malloc(gridsize*sizeof(double));
+      vf    = (double*) Malloc(gridsize*sizeof(double));
+      alpha = (double*) Malloc(gridsize*sizeof(double));
+      auv   = (double*) Malloc(gridsize*sizeof(double));
     }
 
   if ( operatorID == GRIDVERIFY )
@@ -1241,21 +1241,21 @@ void *Outputgmt(void *argument)
 
   streamClose(streamID);
 
-  if ( array  ) free(array);
-  if ( array2 ) free(array2);
-  if ( grid_mask ) free(grid_mask);
-  if ( grid_center_lon ) free(grid_center_lon);
-  if ( grid_center_lat ) free(grid_center_lat);
-  if ( grid_center_lon2 ) free(grid_center_lon2);
-  if ( grid_center_lat2 ) free(grid_center_lat2);
-  if ( grid_corner_lon ) free(grid_corner_lon);
-  if ( grid_corner_lat ) free(grid_corner_lat);
+  if ( array  ) Free(array);
+  if ( array2 ) Free(array2);
+  if ( grid_mask ) Free(grid_mask);
+  if ( grid_center_lon ) Free(grid_center_lon);
+  if ( grid_center_lat ) Free(grid_center_lat);
+  if ( grid_center_lon2 ) Free(grid_center_lon2);
+  if ( grid_center_lat2 ) Free(grid_center_lat2);
+  if ( grid_corner_lon ) Free(grid_corner_lon);
+  if ( grid_corner_lat ) Free(grid_corner_lat);
 
-  free(zaxis_center_lev);
-  free(zaxis_lower_lev);
-  free(zaxis_upper_lev);
+  Free(zaxis_center_lev);
+  Free(zaxis_lower_lev);
+  Free(zaxis_upper_lev);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Pack.c b/src/Pack.c
index fba4354..a55830d 100644
--- a/src/Pack.c
+++ b/src/Pack.c
@@ -113,7 +113,7 @@ void *Pack(void *argument)
       if ( tsID >= nalloc )
 	{
 	  nalloc += NALLOC_INC;
-	  vars   = (field_t ***) realloc(vars, nalloc*sizeof(field_t **));
+	  vars   = (field_t ***) Realloc(vars, nalloc*sizeof(field_t **));
 	}
 
       dtlist_taxisInqTimestep(dtlist, taxisID1, tsID);
@@ -125,7 +125,7 @@ void *Pack(void *argument)
 	  streamInqRecord(streamID1, &varID, &levelID);
 	  gridID   = vlistInqVarGrid(vlistID1, varID);
 	  gridsize = gridInqSize(gridID);
-	  vars[tsID][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+	  vars[tsID][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 	  streamReadRecord(streamID1, vars[tsID][varID][levelID].ptr, &nmiss);
 	  vars[tsID][varID][levelID].nmiss = nmiss;
 	}
@@ -250,7 +250,7 @@ void *Pack(void *argument)
 		  nmiss = vars[tsID][varID][levelID].nmiss;
 		  streamDefRecord(streamID2, varID, levelID);
 		  streamWriteRecord(streamID2, vars[tsID][varID][levelID].ptr, nmiss);
-		  free(vars[tsID][varID][levelID].ptr);
+		  Free(vars[tsID][varID][levelID].ptr);
 		  vars[tsID][varID][levelID].ptr = NULL;
 		}
 	    }
@@ -259,7 +259,7 @@ void *Pack(void *argument)
       field_free(vars[tsID], vlistID1);
     }
 
-  if ( vars  ) free(vars);
+  if ( vars  ) Free(vars);
 
   dtlist_delete(dtlist);
 
@@ -268,5 +268,5 @@ void *Pack(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Pinfo.c b/src/Pinfo.c
index efe805c..d568757 100644
--- a/src/Pinfo.c
+++ b/src/Pinfo.c
@@ -76,8 +76,8 @@ void *Pinfo(void *argument)
 
   gridsize = vlistGridsizeMax(vlistID1);
 
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
+  array2 = (double*) Malloc(gridsize*sizeof(double));
 
   indg = 0;
   tsID = 0;
@@ -196,10 +196,10 @@ void *Pinfo(void *argument)
   streamClose(streamID1);
   streamClose(streamID2);
 
-  if ( array1 ) free(array1);
-  if ( array2 ) free(array2);
+  if ( array1 ) Free(array1);
+  if ( array2 ) Free(array2);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Pressure.c b/src/Pressure.c
index d718faf..b617d47 100644
--- a/src/Pressure.c
+++ b/src/Pressure.c
@@ -38,7 +38,7 @@ void *Pressure(void *argument)
 {
   int mode;
   enum {ECHAM_MODE, WMO_MODE};
-  int geop_code = 0, temp_code = 0, ps_code = 0, lsp_code = 0;
+  int ps_code = 0, lsp_code = 0;
   int streamID2;
   int vlistID2;
   int recID, nrecs;
@@ -46,10 +46,10 @@ void *Pressure(void *argument)
   int tsID, varID, levelID;
   int nvars;
   int zaxisIDp, zaxisIDh = -1, nzaxis;
-  int ngrids, gridID, zaxisID;
-  int nhlev = 0, nhlevf = 0, nhlevh = 0, nlevel;
+  int gridID, zaxisID;
+  int nhlev = 0, nhlevf = 0, nhlevh = 0, nlevel = 0;
   int nvct;
-  int geopID = -1, tempID = -1, psID = -1, lnpsID = -1, pvarID = -1;
+  int psID = -1, lnpsID = -1, pvarID = -1;
   int code, param;
   char paramstr[32];
   char varname[CDI_MAX_NAME];
@@ -93,14 +93,14 @@ void *Pressure(void *argument)
 	{
 	  double *level;
 	  int l;
-	  level = (double*) malloc(nlevel*sizeof(double));
+	  level = (double*) Malloc(nlevel*sizeof(double));
 	  zaxisInqLevels(zaxisID, level);
 	  for ( l = 0; l < nlevel; l++ )
 	    {
 	      if ( (l+1) != (int) (level[l]+0.5) ) break;
 	    }
 	  if ( l == nlevel ) mono_level = TRUE; 
-	  free(level);
+	  Free(level);
 	}
 
       if ( (zaxisInqType(zaxisID) == ZAXIS_HYBRID || zaxisInqType(zaxisID) == ZAXIS_HYBRID_HALF) &&
@@ -117,7 +117,7 @@ void *Pressure(void *argument)
 		  nhlevf   = nhlev;
 		  nhlevh   = nhlevf + 1;
 	      
-		  vct = (double*) malloc(nvct*sizeof(double));
+		  vct = (double*) Malloc(nvct*sizeof(double));
 		  zaxisInqVct(zaxisID, vct);
 		}
 	    }
@@ -131,7 +131,7 @@ void *Pressure(void *argument)
 		  nhlevf   = nhlev - 1;
 		  nhlevh   = nhlev;
 	      
-		  vct = (double*) malloc(nvct*sizeof(double));
+		  vct = (double*) Malloc(nvct*sizeof(double));
 		  zaxisInqVct(zaxisID, vct);
 		}
 	    }
@@ -143,7 +143,7 @@ void *Pressure(void *argument)
 		  int voff = 4;
 		  double *rvct = NULL;
 
-		  rvct = (double*) malloc(nvct*sizeof(double));
+		  rvct = (double*) Malloc(nvct*sizeof(double));
 		  zaxisInqVct(zaxisID,rvct);
 
 		  if ( (int)(rvct[0]+0.5) == 100000 && rvct[voff] < rvct[voff+1] )
@@ -155,7 +155,7 @@ void *Pressure(void *argument)
 		      nhlevh   = nhlev + 1;
 
 		      vctsize = 2*nhlevh;
-		      vct = (double*) malloc(vctsize*sizeof(double));
+		      vct = (double*) Malloc(vctsize*sizeof(double));
 
 		      /* calculate VCT for LM */
 
@@ -179,7 +179,7 @@ void *Pressure(void *argument)
 			    fprintf(stdout, "%5d %25.17f %25.17f\n", i, vct[i], vct[vctsize/2+i]);
 			}
 		    }
-		  free(rvct);
+		  Free(rvct);
 		}
 	    }
 	}
@@ -190,10 +190,10 @@ void *Pressure(void *argument)
 
   if ( zaxisIDh != -1 && gridsize > 0 )
     {
-      ps_prog    = (double*) malloc(gridsize*sizeof(double));
-      deltap     = (double*) malloc(gridsize*nhlevf*sizeof(double));
-      full_press = (double*) malloc(gridsize*nhlevf*sizeof(double));
-      half_press = (double*) malloc(gridsize*nhlevh*sizeof(double));
+      ps_prog    = (double*) Malloc(gridsize*sizeof(double));
+      deltap     = (double*) Malloc(gridsize*nhlevf*sizeof(double));
+      full_press = (double*) Malloc(gridsize*nhlevf*sizeof(double));
+      half_press = (double*) Malloc(gridsize*nhlevh*sizeof(double));
     }
   else
     cdoAbort("No 3D variable with hybrid sigma pressure coordinate found!");
@@ -206,10 +206,10 @@ void *Pressure(void *argument)
   {
     double *level;
     int l;
-    level = (double*) malloc(nhlevh*sizeof(double));
+    level = (double*) Malloc(nhlevh*sizeof(double));
     for ( l = 0; l < nhlevh; l++ ) level[l] = l+1;
     zaxisDefLevels(zaxisIDp, level);
-    free(level);
+    Free(level);
   }
 
   zaxisDefVct(zaxisIDp, 2*nhlevh, vct);
@@ -246,15 +246,11 @@ void *Pressure(void *argument)
 	  if ( tableNum == 2 )
 	    {
 	      mode = WMO_MODE;
-	      geop_code  =   6;
-	      temp_code  =  11;
 	      ps_code    =   1;
 	    }
 	  else if ( tableNum == 128 )
 	    {
 	      mode = ECHAM_MODE;
-	      geop_code  = 129;
-	      temp_code  = 130;
 	      ps_code    = 134;
 	      lsp_code   = 152;
 	    }
@@ -264,8 +260,6 @@ void *Pressure(void *argument)
       else
 	{
 	  mode = ECHAM_MODE;
-	  geop_code  = 129;
-	  temp_code  = 130;
 	  ps_code    = 134;
 	  lsp_code   = 152;
 	}
@@ -290,17 +284,13 @@ void *Pressure(void *argument)
 
       if ( mode == ECHAM_MODE )
 	{
-	  if      ( code == geop_code  && nlevel == 1     ) geopID  = varID;
-	  else if ( code == temp_code  && nlevel == nhlev ) tempID  = varID;
-	  else if ( code == ps_code    && nlevel == 1     ) psID    = varID;
+	  if      ( code == ps_code    && nlevel == 1     ) psID    = varID;
 	  else if ( code == lsp_code   && nlevel == 1     ) lnpsID  = varID;
 	  /* else if ( code == 156 ) gheightID = varID; */
 	}
       else if ( mode == WMO_MODE )
 	{
-	  if      ( code == geop_code  && nlevel == 1     ) geopID  = varID;
-	  else if ( code == temp_code  && nlevel == nhlev ) tempID  = varID;
-	  else if ( code == ps_code    && nlevel == 1     ) psID    = varID;
+	  if ( code == ps_code    && nlevel == 1     ) psID    = varID;
 	}
     }
 
@@ -326,12 +316,12 @@ void *Pressure(void *argument)
   if ( gridInqType(gridID) == GRID_SPECTRAL )
     cdoAbort("%s on spectral representation not supported!", var_stdname(surface_air_pressure));
 
-  pdata = (double*) malloc(gridsize*sizeof(double));
+  pdata = (double*) Malloc(gridsize*sizeof(double));
 
 
   vlistID2 = vlistCreate();
   varID = vlistDefVar(vlistID2, gridID, zaxisIDp, TSTEP_INSTANT);
-  vlistDefVarCode(vlistID2, varID, 1);
+  vlistDefVarParam(vlistID2, varID, cdiEncodeParam(1, 255, 255));
   vlistDefVarName(vlistID2, varID, "pressure");
   vlistDefVarStdname(vlistID2, varID, "air_pressure");
   vlistDefVarUnits(vlistID2, varID, "Pa");
@@ -394,7 +384,7 @@ void *Pressure(void *argument)
 
 	  pout = deltap;
 	}
-      else
+      else if ( operatorID == PRESSURE_HL )
 	{
 	  nlevel = nhlevh;
 	  pout = half_press;
@@ -414,14 +404,14 @@ void *Pressure(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( pdata      ) free(pdata);
-  if ( ps_prog    ) free(ps_prog);
-  if ( deltap     ) free(deltap);
-  if ( full_press ) free(full_press);
-  if ( half_press ) free(half_press);
-  if ( vct        ) free(vct);
+  if ( pdata      ) Free(pdata);
+  if ( ps_prog    ) Free(ps_prog);
+  if ( deltap     ) Free(deltap);
+  if ( full_press ) Free(full_press);
+  if ( half_press ) Free(half_press);
+  if ( vct        ) Free(vct);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Regres.c b/src/Regres.c
index 9890f84..dc16dc2 100644
--- a/src/Regres.c
+++ b/src/Regres.c
@@ -70,15 +70,15 @@ void *Regres(void *argument)
 
   nrecords = vlistNrecs(vlistID1);
 
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = vlistGridsizeMax(vlistID1);
 
   field_init(&field1);
   field_init(&field2);
-  field1.ptr = (double*) malloc(gridsize*sizeof(double));
-  field2.ptr = (double*) malloc(gridsize*sizeof(double));
+  field1.ptr = (double*) Malloc(gridsize*sizeof(double));
+  field2.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   for ( w = 0; w < nwork; w++ )
     work[w] = field_calloc(vlistID1, FIELD_PTR);
@@ -168,11 +168,11 @@ void *Regres(void *argument)
 
   for ( w = 0; w < nwork; w++ ) field_free(work[w], vlistID1);
 
-  if ( field1.ptr ) free(field1.ptr);
-  if ( field2.ptr ) free(field2.ptr);
+  if ( field1.ptr ) Free(field1.ptr);
+  if ( field2.ptr ) Free(field2.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID3);
   /* streamClose(streamID2); */
@@ -180,5 +180,5 @@ void *Regres(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Remap.c b/src/Remap.c
index da2f6d1..81919a8 100644
--- a/src/Remap.c
+++ b/src/Remap.c
@@ -88,7 +88,7 @@ void get_map_type(int operfunc, int *map_type, int *submap_type, int *num_neighb
     case REMAPDIS:
     case GENDIS:
       *map_type = MAP_TYPE_DISTWGT;
-      *num_neighbors = 4;
+      if ( *num_neighbors == 0 ) *num_neighbors = 4;
       break;
     case REMAPNN:
     case GENNN:
@@ -162,7 +162,7 @@ int maptype2operfunc(int map_type, int submap_type, int num_neighbors, int remap
 } 
 
 static
-void print_remap_info(int operfunc, remapgrid_t *src_grid, remapgrid_t *tgt_grid, int nmiss)
+void print_remap_info(int operfunc, int remap_genweights, remapgrid_t *src_grid, remapgrid_t *tgt_grid, int nmiss)
 {
   char line[256];
   char tmpstr[256];
@@ -171,15 +171,19 @@ void print_remap_info(int operfunc, remapgrid_t *src_grid, remapgrid_t *tgt_grid
 
   if      ( operfunc == REMAPBIL  || operfunc == GENBIL  )  strcpy(line, "SCRIP bilinear");
   else if ( operfunc == REMAPBIC  || operfunc == GENBIC  )  strcpy(line, "SCRIP bicubic");
-  else if ( operfunc == REMAPNN   || operfunc == GENNN   )  strcpy(line, "SCRIP nearest neighbor");
-  else if ( operfunc == REMAPDIS  || operfunc == GENDIS  )  strcpy(line, "SCRIP distance-weighted average");
+  else if ( operfunc == REMAPNN   || operfunc == GENNN   )  strcpy(line, "Nearest neighbor");
+  else if ( operfunc == REMAPDIS  || operfunc == GENDIS  )  strcpy(line, "Distance-weighted average");
   else if ( operfunc == REMAPCON  || operfunc == GENCON  )  strcpy(line, "SCRIP first order conservative");
   else if ( operfunc == REMAPCON2 || operfunc == GENCON2 )  strcpy(line, "SCRIP second order conservative");
   else if ( operfunc == REMAPLAF  || operfunc == GENLAF  )  strcpy(line, "YAC largest area fraction");
   else if ( operfunc == REMAPYCON || operfunc == GENYCON )  strcpy(line, "YAC first order conservative");
   else                                                      strcpy(line, "Unknown");
 
-  strcat(line, " remapping from ");
+  if ( remap_genweights )
+    strcat(line, " weights from ");
+  else
+    strcat(line, " remapping from ");
+
   strcat(line, gridNamePtr(gridInqType(src_grid->gridID)));
   if ( src_grid->rank == 2 )
     sprintf(tmpstr, " (%dx%d)", src_grid->dims[0], src_grid->dims[1]);
@@ -204,9 +208,51 @@ void print_remap_info(int operfunc, remapgrid_t *src_grid, remapgrid_t *tgt_grid
   cdoPrint(line);
 }
 
+static
+void print_remap_warning(const char *remap_file, int operfunc, remapgrid_t *src_grid, int nmiss)
+{
+  char line[256];
+  char tmpstr[256];
+
+  line[0] = 0;
+  /*
+  if      ( operfunc == REMAPBIL  || operfunc == GENBIL  )  strcpy(line, "SCRIP bilinear");
+  else if ( operfunc == REMAPBIC  || operfunc == GENBIC  )  strcpy(line, "SCRIP bicubic");
+  else if ( operfunc == REMAPNN   || operfunc == GENNN   )  strcpy(line, "SCRIP nearest neighbor");
+  else if ( operfunc == REMAPDIS  || operfunc == GENDIS  )  strcpy(line, "SCRIP distance-weighted average");
+  else if ( operfunc == REMAPCON  || operfunc == GENCON  )  strcpy(line, "SCRIP first order conservative");
+  else if ( operfunc == REMAPCON2 || operfunc == GENCON2 )  strcpy(line, "SCRIP second order conservative");
+  else if ( operfunc == REMAPLAF  || operfunc == GENLAF  )  strcpy(line, "YAC largest area fraction");
+  else if ( operfunc == REMAPYCON || operfunc == GENYCON )  strcpy(line, "YAC first order conservative");
+  else                                                      strcpy(line, "Unknown");
+
+  strcat(line, " remap weights from ");
+  */
+  strcat(line, "Remap weights from ");
+  strcat(line, remap_file);
+  strcat(line, " not used, ");
+  strcat(line, gridNamePtr(gridInqType(src_grid->gridID)));
+  if ( src_grid->rank == 2 )
+    sprintf(tmpstr, " (%dx%d)", src_grid->dims[0], src_grid->dims[1]);
+  else
+    sprintf(tmpstr, " (%d)", src_grid->dims[0]);
+  strcat(line, tmpstr);
+  strcat(line, " grid");
+
+  if ( nmiss > 0 )
+    {
+      sprintf(tmpstr, " with mask (%d)", gridInqSize(src_grid->gridID)-nmiss);
+      strcat(line, tmpstr);
+    }
+
+  strcat(line, " not found!");
+
+  cdoWarning(line);
+}
+
 
 double remap_threshhold = 2;
-double remap_search_radius = 180;
+double gridsearch_radius = 180;
 int remap_test = 0;
 int remap_order = 1;
 int remap_non_global = FALSE;
@@ -217,7 +263,7 @@ int lextrapolate = FALSE;
 int max_remaps = -1;
 int sort_mode = HEAP_SORT;
 double remap_frac_min = 0;
-
+int remap_genweights = TRUE;
 
 static
 void get_remap_env(void)
@@ -327,14 +373,31 @@ void get_remap_env(void)
 	}
       else
 	{
-	  remap_search_radius = fval;
+	  gridsearch_radius = fval;
 	  if ( cdoVerbose )
-	    cdoPrint("Set CDO_REMAP_RADIUS to %g", remap_search_radius);
+	    cdoPrint("Set CDO_REMAP_RADIUS to %g", gridsearch_radius);
+	}
+    }
+
+  envstr = getenv("CDO_GRIDSEARCH_RADIUS");
+  if ( envstr )
+    {
+      double fval;
+      fval = atof(envstr);
+      if ( fval < 0 || fval > 180 )
+	{
+	  cdoAbort("CDO_GRIDSEARCH_RADIUS=%g out of bounds (0-180)", fval);
+	}
+      else
+	{
+	  gridsearch_radius = fval;
+	  if ( cdoVerbose )
+	    cdoPrint("Set CDO_GRIDSEARCH_RADIUS to %g", gridsearch_radius);
 	}
     }
   
   if ( cdoVerbose )
-    cdoPrint("remap_radius = %g", remap_search_radius);
+    cdoPrint("remap_radius = %g", gridsearch_radius);
 
   envstr = getenv("REMAP_AREA_MIN");
   if ( envstr )
@@ -712,7 +775,7 @@ void *Remap(void *argument)
   int norm_opt = NORM_OPT_NONE;
   int map_type = -1;
   int submap_type = SUBMAP_TYPE_NONE;
-  int num_neighbors = 4;
+  int num_neighbors = 0;
   int need_gradiants = FALSE;
   int grid1sizemax;
   char varname[CDI_MAX_NAME];
@@ -748,6 +811,7 @@ void *Remap(void *argument)
   int operatorID   = cdoOperatorID();
   int operfunc     = cdoOperatorF1(operatorID);
   int lwrite_remap = cdoOperatorF2(operatorID);
+  int lremapxxx    = operfunc == REMAPXXX;
 
   remap_set_int(REMAP_WRITE_REMAP, lwrite_remap);
 
@@ -765,7 +829,7 @@ void *Remap(void *argument)
 	cdoPrint("Extrapolation disabled!");
     }
 
-  if ( operfunc == REMAPXXX )
+  if ( lremapxxx )
     {
       operatorInputArg("grid description file or name, remap weights file (SCRIP netCDF)");
       operatorCheckArgc(2);
@@ -775,8 +839,18 @@ void *Remap(void *argument)
   else
     {
       operatorInputArg("grid description file or name");
-      operatorCheckArgc(1);
-      gridID2 = cdoDefineGrid(operatorArgv()[0]);
+      if ( operfunc == REMAPDIS && operatorArgc() == 2 )
+        {
+          gridID2 = cdoDefineGrid(operatorArgv()[0]);
+          int inum = parameter2int(operatorArgv()[1]);
+          //  if ( inum < 1 || inum > 9 ) cdoAbort("Number of nearest neighbors out of range (1-9)!", inum);
+          num_neighbors = inum;
+        }
+      else
+        {
+          operatorCheckArgc(1);
+          gridID2 = cdoDefineGrid(operatorArgv()[0]);
+        }
     }
 
   if ( gridInqType(gridID2) == GRID_GENERIC ) cdoAbort("Unsupported target grid type (generic)!");
@@ -804,19 +878,20 @@ void *Remap(void *argument)
 
   if ( max_remaps > 0 )
     {
-      remaps = (remap_t*) malloc(max_remaps*sizeof(remap_t));
+      remaps = (remap_t*) Malloc(max_remaps*sizeof(remap_t));
       for ( r = 0; r < max_remaps; r++ )
 	{
+	  remaps[r].nused    = 0;
 	  remaps[r].gridID   = -1;
 	  remaps[r].gridsize = 0;
 	  remaps[r].nmiss    = 0;
 	}
     }
 
-  if ( lwrite_remap || operfunc == REMAPXXX )
+  if ( lwrite_remap || lremapxxx )
     remap_genweights = TRUE;
 
-  if ( operfunc == REMAPXXX )
+  if ( lremapxxx )
     {
       int gridsize2;
 
@@ -824,9 +899,8 @@ void *Remap(void *argument)
 		       &remap_order, &remaps[0].src_grid, &remaps[0].tgt_grid, &remaps[0].vars);
       nremaps = 1;
       gridsize = remaps[0].src_grid.size;
-      remaps[0].gridID = gridID1;
+      remaps[0].gridID   = gridID1;
       remaps[0].gridsize = gridInqSize(gridID1);
-      remaps[0].nmiss = 0;
 
       if ( map_type == MAP_TYPE_DISTWGT && !lextrapolate ) remap_extrapolate = TRUE;
       if ( gridIsCircular(gridID1)      && !lextrapolate ) remap_extrapolate = TRUE;
@@ -854,7 +928,7 @@ void *Remap(void *argument)
 	  int gridID2_gme;
 	  int isize = 0;
 	  remaps[0].tgt_grid.nvgp = gridInqSize(gridID2);
-	  remaps[0].tgt_grid.vgpm = (int*) realloc(remaps[0].tgt_grid.vgpm, gridInqSize(gridID2)*sizeof(int));
+	  remaps[0].tgt_grid.vgpm = (int*) Realloc(remaps[0].tgt_grid.vgpm, gridInqSize(gridID2)*sizeof(int));
 	  gridID2_gme = gridToUnstructured(gridID2, 1);
 	  gridInqMaskGME(gridID2_gme, remaps[0].tgt_grid.vgpm);
 	  for ( i = 0; i < gridsize2; ++i )
@@ -876,9 +950,13 @@ void *Remap(void *argument)
       get_map_type(operfunc, &map_type, &submap_type, &num_neighbors, &remap_order);
     }
 
-  if ( remap_genweights == FALSE && map_type != MAP_TYPE_BILINEAR && map_type != MAP_TYPE_BICUBIC && map_type != MAP_TYPE_CONSERV_YAC )
+  if ( remap_genweights == FALSE &&
+       map_type != MAP_TYPE_BILINEAR && map_type != MAP_TYPE_BICUBIC &&
+       map_type != MAP_TYPE_DISTWGT  && map_type != MAP_TYPE_CONSERV_YAC )
     remap_genweights = TRUE;
 
+  remap_set_int(REMAP_GENWEIGHTS, remap_genweights);
+
   if ( map_type == MAP_TYPE_CONSERV || map_type == MAP_TYPE_CONSERV_YAC ) norm_opt = get_norm_opt();
 
   grid1sizemax = vlistGridsizeMax(vlistID1);
@@ -894,16 +972,16 @@ void *Remap(void *argument)
 
   if ( need_gradiants )
     {
-      grad1_lat    = (double*) malloc(grid1sizemax*sizeof(double));
-      grad1_lon    = (double*) malloc(grid1sizemax*sizeof(double));
-      grad1_latlon = (double*) malloc(grid1sizemax*sizeof(double));
+      grad1_lat    = (double*) Malloc(grid1sizemax*sizeof(double));
+      grad1_lon    = (double*) Malloc(grid1sizemax*sizeof(double));
+      grad1_latlon = (double*) Malloc(grid1sizemax*sizeof(double));
     }
 
-  array1 = (double*) malloc(grid1sizemax*sizeof(double));
-  imask  = (int*) malloc(grid1sizemax*sizeof(int));
+  array1 = (double*) Malloc(grid1sizemax*sizeof(double));
+  imask  = (int*) Malloc(grid1sizemax*sizeof(int));
 
   gridsize = gridInqSize(gridID2);
-  array2   = (double*) malloc(gridsize*sizeof(double));
+  array2   = (double*) Malloc(gridsize*sizeof(double));
 
   if ( ! lwrite_remap )
     {
@@ -958,14 +1036,14 @@ void *Remap(void *argument)
 	      if ( gridsize_new > grid1sizemax )
 		{
 		  grid1sizemax = gridsize_new;
-		  array1 = (double*) realloc(array1, grid1sizemax*sizeof(double));
-		  imask  = (int*) realloc(imask, grid1sizemax*sizeof(int));
+		  array1 = (double*) Realloc(array1, grid1sizemax*sizeof(double));
+		  imask  = (int*) Realloc(imask, grid1sizemax*sizeof(int));
 
 		  if ( need_gradiants )
 		    {
-		      grad1_lat    = (double*) realloc(grad1_lat, grid1sizemax*sizeof(double));
-		      grad1_lon    = (double*) realloc(grad1_lon, grid1sizemax*sizeof(double));
-		      grad1_latlon = (double*) realloc(grad1_latlon, grid1sizemax*sizeof(double));
+		      grad1_lat    = (double*) Realloc(grad1_lat, grid1sizemax*sizeof(double));
+		      grad1_lon    = (double*) Realloc(grad1_lon, grid1sizemax*sizeof(double));
+		      grad1_latlon = (double*) Realloc(grad1_latlon, grid1sizemax*sizeof(double));
 		    }
 		}
 	      
@@ -990,8 +1068,11 @@ void *Remap(void *argument)
 	      if ( gridID1 == remaps[r].gridID && nmiss1 == remaps[r].nmiss )
 		{
 		  if ( memcmp(imask, remaps[r].src_grid.mask, remaps[r].src_grid.size*sizeof(int)) == 0 )
-		    break;
-		}	      
+                    {
+                      remaps[r].nused++;
+                      break;
+                    }
+                }
 	    }
 
 	  if ( cdoVerbose && r >= 0 ) cdoPrint("Using remap %d", r);
@@ -1005,7 +1086,23 @@ void *Remap(void *argument)
 		}
 	      else
 		{
+                  /*
 		  r = nremaps - 1;
+                  remapVarsFree(&remaps[r].vars);
+                  remapGridFree(&remaps[r].src_grid);
+                  remapGridFree(&remaps[r].tgt_grid);
+                  */
+                  int n0 = 0;
+                  if ( max_remaps > 1 && remaps[0].nused > remaps[1].nused ) n0 = 1;
+                  remapVarsFree(&remaps[n0].vars);
+                  remapGridFree(&remaps[n0].src_grid);
+                  remapGridFree(&remaps[n0].tgt_grid);
+                  for ( r = n0+1; r < nremaps; r++ ) memcpy(&remaps[r-1], &remaps[r], sizeof(remap_t));
+                  r = nremaps - 1;
+                  remaps[r].nused    = 0;
+                  remaps[r].gridID   = -1;
+                  remaps[r].gridsize = 0;
+                  remaps[r].nmiss    = 0;
 		}
 
 	      if ( remaps[r].gridID != gridID1 )
@@ -1076,15 +1173,15 @@ void *Remap(void *argument)
 	      remap_vars_init(map_type, remaps[r].src_grid.size, remaps[r].tgt_grid.size, &remaps[r].vars);
 	      if ( cdoTimer ) timer_stop(timer_remap_init);
 
+              print_remap_info(operfunc, remap_genweights, &remaps[r].src_grid, &remaps[r].tgt_grid, nmiss1);
+
 	      if ( remap_genweights )
 		{
-		  print_remap_info(operfunc, &remaps[r].src_grid, &remaps[r].tgt_grid, nmiss1);
-
-		  if      ( map_type == MAP_TYPE_CONSERV     ) scrip_remap_weights_conserv(&remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
-		  else if ( map_type == MAP_TYPE_BILINEAR    ) scrip_remap_weights_bilinear(&remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
-		  else if ( map_type == MAP_TYPE_BICUBIC     ) scrip_remap_weights_bicubic(&remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
-		  else if ( map_type == MAP_TYPE_DISTWGT     ) scrip_remap_weights_distwgt(num_neighbors, &remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
-		  else if ( map_type == MAP_TYPE_CONSERV_YAC ) remap_weights_conserv(&remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
+		  if      ( map_type == MAP_TYPE_CONSERV     ) scrip_remap_conserv_weights(&remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
+		  else if ( map_type == MAP_TYPE_BILINEAR    ) scrip_remap_bilinear_weights(&remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
+		  else if ( map_type == MAP_TYPE_BICUBIC     ) scrip_remap_bicubic_weights(&remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
+		  else if ( map_type == MAP_TYPE_DISTWGT     ) remap_distwgt_weights(num_neighbors, &remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
+		  else if ( map_type == MAP_TYPE_CONSERV_YAC ) remap_conserv_weights(&remaps[r].src_grid, &remaps[r].tgt_grid, &remaps[r].vars);
 
 		  if ( map_type == MAP_TYPE_CONSERV && remaps[r].vars.num_links != remaps[r].vars.max_links )
 		    resize_remap_vars(&remaps[r].vars, remaps[r].vars.num_links-remaps[r].vars.max_links);
@@ -1106,6 +1203,8 @@ void *Remap(void *argument)
 	  
 	  if ( remap_genweights )
 	    {
+              remaps[r].nused++;
+
 	      if ( need_gradiants )
 		{
 		  if ( remaps[r].src_grid.rank != 2 && remap_order == 2 )
@@ -1129,6 +1228,7 @@ void *Remap(void *argument)
 	    {
 	      if      ( map_type == MAP_TYPE_BILINEAR    ) scrip_remap_bilinear(&remaps[r].src_grid, &remaps[r].tgt_grid, array1, array2, missval);
 	      else if ( map_type == MAP_TYPE_BICUBIC     ) scrip_remap_bicubic(&remaps[r].src_grid, &remaps[r].tgt_grid, array1, array2, missval);
+              else if ( map_type == MAP_TYPE_DISTWGT     ) remap_distwgt(num_neighbors, &remaps[r].src_grid, &remaps[r].tgt_grid, array1, array2, missval);
 	      else if ( map_type == MAP_TYPE_CONSERV_YAC ) remap_conserv(&remaps[r].src_grid, &remaps[r].tgt_grid, array1, array2, missval);
 	    }
 
@@ -1206,16 +1306,19 @@ void *Remap(void *argument)
 
   streamClose(streamID1);
 
-  if ( imask )  free(imask);
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
+  if ( imask )  Free(imask);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
 
-  if ( grad1_latlon ) free(grad1_latlon);
-  if ( grad1_lon ) free(grad1_lon);
-  if ( grad1_lat ) free(grad1_lat);
+  if ( grad1_latlon ) Free(grad1_latlon);
+  if ( grad1_lon ) Free(grad1_lon);
+  if ( grad1_lat ) Free(grad1_lat);
 
   if ( max_remaps > 0 )
     {
+      if ( lremapxxx && remap_genweights && remaps[0].nused == 0 )
+        print_remap_warning(remap_file, operfunc, &remaps[0].src_grid, remaps[0].nmiss);
+      
       for ( r = 0; r < nremaps; r++ )
 	{
 	  remapVarsFree(&remaps[r].vars);
@@ -1223,10 +1326,10 @@ void *Remap(void *argument)
 	  remapGridFree(&remaps[r].tgt_grid);
 	}
       
-      if ( remaps ) free(remaps);
+      if ( remaps ) Free(remaps);
     }
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Remapeta.c b/src/Remapeta.c
index f983ee6..35d1146 100644
--- a/src/Remapeta.c
+++ b/src/Remapeta.c
@@ -22,6 +22,7 @@
 
 #include <ctype.h>
 
+#include "hetaeta.h"
 #include <cdi.h>
 #include "cdo.h"
 #include "cdo_int.h"
@@ -29,7 +30,6 @@
 #include "after_vertint.h"
 #include "list.h"
 #include "stdnametable.h"
-#include "hetaeta.h"
 
 
 static 
@@ -111,7 +111,7 @@ double *vctFromFile(const char *filename, int *nvct)
   fp = fopen(filename, "r");
   if ( fp == NULL ) { perror(filename); exit(EXIT_FAILURE); }
 
-  vct2 = (double*) malloc(maxvct*sizeof(double));
+  vct2 = (double*) Malloc(maxvct*sizeof(double));
 
   while ( readline(fp, line, 1024) )
     {
@@ -141,7 +141,7 @@ double *vctFromFile(const char *filename, int *nvct)
   for ( i = 0; i < nlevh2+1; ++i )
     vct2[i+nvct2/2] = vct2[i+maxvct/2];
   
-  vct2 = (double*) realloc(vct2, nvct2*sizeof(double));
+  vct2 = (double*) Realloc(vct2, nvct2*sizeof(double));
 
   *nvct = nvct2;
 
@@ -279,7 +279,7 @@ void *Remapeta(void *argument)
       gridID  = vlistInqVarGrid(vlistID1, varID);
       nfis2gp = gridInqSize(gridID);
 
-      fis2 = (double*) malloc(nfis2gp*sizeof(double));
+      fis2 = (double*) Malloc(nfis2gp*sizeof(double));
 
       streamReadRecord(streamID, fis2, &nmiss);
 
@@ -323,10 +323,10 @@ void *Remapeta(void *argument)
   int gridsize = vlist_check_gridsize(vlistID1);
 
   zaxisID2 = zaxisCreate(ZAXIS_HYBRID, nhlevf2);
-  lev2 = (double*) malloc(nhlevf2*sizeof(double));
+  lev2 = (double*) Malloc(nhlevf2*sizeof(double));
   for ( i = 0; i < nhlevf2; ++i ) lev2[i] = i+1;
   zaxisDefLevels(zaxisID2, lev2);
-  free(lev2);
+  Free(lev2);
 
   if ( nvct2 == 0 ) cdoAbort("Internal problem, vct2 undefined!");
   zaxisDefVct(zaxisID2, nvct2, vct2);
@@ -363,7 +363,7 @@ void *Remapeta(void *argument)
                       if ( cdoVerbose )
                         cdoPrint("lhavevct=TRUE  zaxisIDh = %d, nhlevf1   = %d", zaxisIDh, nlevel);
  
-		      vct1 = (double*) malloc(nvct1*sizeof(double));
+		      vct1 = (double*) Malloc(nvct1*sizeof(double));
 		      zaxisInqVct(zaxisID, vct1);
 		      
 		      vlistChangeZaxisIndex(vlistID2, i, zaxisID2);
@@ -492,50 +492,50 @@ void *Remapeta(void *argument)
 
   if ( operatorID == REMAPETAS || operatorID == REMAPETAZ)
     {
-      sum1 = (double*) malloc(gridsize*sizeof(double));
-      sum2 = (double*) malloc(gridsize*sizeof(double));
+      sum1 = (double*) Malloc(gridsize*sizeof(double));
+      sum2 = (double*) Malloc(gridsize*sizeof(double));
     }
 
   if ( operatorID == REMAPETAZ )
     {
-      deltap1 = (double*) malloc(gridsize*nhlevf1*sizeof(double));
-      deltap2 = (double*) malloc(gridsize*nhlevf2*sizeof(double));
-      half_press1 = (double*) malloc(gridsize*(nhlevf1+1)*sizeof(double));
-      half_press2 = (double*) malloc(gridsize*(nhlevf2+1)*sizeof(double));
+      deltap1 = (double*) Malloc(gridsize*nhlevf1*sizeof(double));
+      deltap2 = (double*) Malloc(gridsize*nhlevf2*sizeof(double));
+      half_press1 = (double*) Malloc(gridsize*(nhlevf1+1)*sizeof(double));
+      half_press2 = (double*) Malloc(gridsize*(nhlevf2+1)*sizeof(double));
     }
 
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
-  fis1  = (double*) malloc(gridsize*sizeof(double));
-  ps1   = (double*) malloc(gridsize*sizeof(double));
+  fis1  = (double*) Malloc(gridsize*sizeof(double));
+  ps1   = (double*) Malloc(gridsize*sizeof(double));
 
-  if ( lfis2 == FALSE ) fis2  = (double*) malloc(gridsize*sizeof(double));
+  if ( lfis2 == FALSE ) fis2  = (double*) Malloc(gridsize*sizeof(double));
   if ( lfis2 == TRUE && gridsize != nfis2gp ) cdoAbort("Orographies have different grid size!");
 
-  ps2   = (double*) malloc(gridsize*sizeof(double));
+  ps2   = (double*) Malloc(gridsize*sizeof(double));
 
   if ( ltq )
     {
-      tscor = (double*) malloc(gridsize*sizeof(double));
-      pscor = (double*) malloc(gridsize*sizeof(double));
-      secor = (double*) malloc(gridsize*sizeof(double));
+      tscor = (double*) Malloc(gridsize*sizeof(double));
+      pscor = (double*) Malloc(gridsize*sizeof(double));
+      secor = (double*) Malloc(gridsize*sizeof(double));
 
-      t1    = (double*) malloc(gridsize*nhlevf1*sizeof(double));
-      q1    = (double*) malloc(gridsize*nhlevf1*sizeof(double));
+      t1    = (double*) Malloc(gridsize*nhlevf1*sizeof(double));
+      q1    = (double*) Malloc(gridsize*nhlevf1*sizeof(double));
 
-      t2    = (double*) malloc(gridsize*nhlevf2*sizeof(double));
-      q2    = (double*) malloc(gridsize*nhlevf2*sizeof(double));
+      t2    = (double*) Malloc(gridsize*nhlevf2*sizeof(double));
+      q2    = (double*) Malloc(gridsize*nhlevf2*sizeof(double));
     }
 
   if ( nvars3D )
     {
-      vars1  = (double**) malloc(nvars*sizeof(double*));
-      vars2  = (double**) malloc(nvars*sizeof(double*));
+      vars1  = (double**) Malloc(nvars*sizeof(double*));
+      vars2  = (double**) Malloc(nvars*sizeof(double*));
 
       for ( varID = 0; varID < nvars3D; ++varID )
 	{
-	  vars1[varID] = (double*) malloc(gridsize*nhlevf1*sizeof(double));
-	  vars2[varID] = (double*) malloc(gridsize*nhlevf2*sizeof(double));
+	  vars1[varID] = (double*) Malloc(gridsize*nhlevf1*sizeof(double));
+	  vars2[varID] = (double*) Malloc(gridsize*nhlevf2*sizeof(double));
 	}
     }
 
@@ -751,22 +751,17 @@ void *Remapeta(void *argument)
 	{
 	  varID = varids[iv];
 
-	  nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
+	  nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
 
 	  if ( operatorID == REMAPETAS )
 	    {
-	      nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	      vert_sum(sum1, vars1[iv], gridsize, nhlevf1);
-
-	      nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
 	      vert_sum(sum2, vars2[iv], gridsize, nhlevf2);
 	    }
 	  else if ( operatorID == REMAPETAZ )
 	    {
 	      int k;
 
-	      nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
-
 	      presh(NULL, half_press1, vct1, ps1, nhlevf1, gridsize);
 	      for ( k = 0; k < nhlevf1; ++k )
 		for ( i = 0; i < gridsize; ++i )
@@ -776,8 +771,6 @@ void *Remapeta(void *argument)
 		  }
 	      vert_sumw(sum1, vars1[iv], gridsize, nhlevf1, deltap1);
 
-	      nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
-
 	      presh(NULL, half_press2, vct2, ps1, nhlevf2, gridsize);
 	      for ( k = 0; k < nhlevf2; ++k )
 		for ( i = 0; i < gridsize; ++i )
@@ -820,45 +813,45 @@ void *Remapeta(void *argument)
     {
       for ( varID = 0; varID < nvars3D; varID++ )
 	{
-	  free(vars2[varID]);
-	  free(vars1[varID]);
+	  Free(vars2[varID]);
+	  Free(vars1[varID]);
 	}
-      free(vars2);
-      free(vars1);
+      Free(vars2);
+      Free(vars1);
     }
 
   if ( ltq )
     {
-      free(q2);
-      free(t2);
-      free(q1);
-      free(t1);
-      free(secor);
-      free(pscor);
-      free(tscor);
+      Free(q2);
+      Free(t2);
+      Free(q1);
+      Free(t1);
+      Free(secor);
+      Free(pscor);
+      Free(tscor);
     }
 
-  if ( imiss ) free(imiss);
+  if ( imiss ) Free(imiss);
 
-  free(ps2);
-  free(fis2);
-  free(ps1);
-  free(fis1);
+  Free(ps2);
+  Free(fis2);
+  Free(ps1);
+  Free(fis1);
 
-  if ( sum1 ) free(sum1);
-  if ( sum2 ) free(sum2);
+  if ( sum1 ) Free(sum1);
+  if ( sum2 ) Free(sum2);
 
-  if ( deltap1 ) free(deltap1);
-  if ( deltap2 ) free(deltap2);
+  if ( deltap1 ) Free(deltap1);
+  if ( deltap2 ) Free(deltap2);
 
-  if ( half_press1 ) free(half_press1);
-  if ( half_press2 ) free(half_press2);
+  if ( half_press1 ) Free(half_press1);
+  if ( half_press2 ) Free(half_press2);
 
-  free(array);
-  free(vct2);
-  if ( vct1 ) free(vct1);
+  Free(array);
+  Free(vct2);
+  if ( vct1 ) Free(vct1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Replace.c b/src/Replace.c
index 48730e8..4cedf6b 100644
--- a/src/Replace.c
+++ b/src/Replace.c
@@ -31,69 +31,50 @@
 
 void *Replace(void *argument)
 {
-  int varID;
-  int varID1, nvars1;
-  int varID2, nvars2;
+  int varID, varID1, varID2;
   int nrecs = 0;
-  int tsID, recID, levelID, levelID2;
+  int recID, levelID, levelID2;
   int nrecs2;
   int nchvars = 0;
   int idx;
-  int streamID1, streamID2, streamID3;
-  int vlistID1 , vlistID2, vlistID3;
-  int code1 = 0, code2;
   int nlevel1, nlevel2;
   char varname1[CDI_MAX_NAME], varname2[CDI_MAX_NAME];
-  int gridsize;
   int nmiss;
-  int taxisID1, taxisID3;
+  int gridsize;
   int offset;
-  int nts2;
   int varlist1[MAX_VARS], varlist2[MAX_VARS];
   int **varlevel = NULL;
   int **varnmiss2 = NULL;
   double **vardata2 = NULL;
-  double *array = NULL, *parray;
+  double *parray;
 
   cdoInitialize(argument);
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID3 = taxisDuplicate(taxisID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID3 = taxisDuplicate(taxisID1);
 
-  streamID2 = streamOpenRead(cdoStreamName(1));
+  int streamID2 = streamOpenRead(cdoStreamName(1));
 
-  vlistID2 = streamInqVlist(streamID2);
+  int vlistID2 = streamInqVlist(streamID2);
 
   /* compare all variables in vlistID2 */
 
-  nvars1 = vlistNvars(vlistID1);
-  nvars2 = vlistNvars(vlistID2);
+  int nvars1 = vlistNvars(vlistID1);
+  int nvars2 = vlistNvars(vlistID2);
 
   for ( varID2 = 0; varID2 < nvars2; varID2++ )
     {
-      code2 = vlistInqVarCode(vlistID2, varID2);
       vlistInqVarName(vlistID2, varID2, varname2);
 
       for ( varID1 = 0; varID1 < nvars1; varID1++ )
 	{
-	  code1 = vlistInqVarCode(vlistID1, varID1);
 	  vlistInqVarName(vlistID1, varID1, varname1);
 	  if ( strcmp(varname1, varname2) == 0 ) break;
 	}
 
-      if ( code2 > 0 && varID1 == nvars1 )
-	{
-	  for ( varID1 = 0; varID1 < nvars1; varID1++ )
-	    {
-	      code1 = vlistInqVarCode(vlistID1, varID1);
-	      vlistInqVarName(vlistID1, varID1, varname1);
-	      if ( code1 == code2 ) break;
-	    }
-	}
-
       if ( varID1 < nvars1 )
 	{
 	  int gridsize1, gridsize2, nlevel1, nlevel2;
@@ -110,9 +91,7 @@ void *Replace(void *argument)
 	  if ( nlevel1 < nlevel2 )
 	    cdoAbort("Variables have different number of levels!");
 
-	  if ( cdoVerbose )
-	    cdoPrint("Variable %s (code %d) replaced by  %s (code %d)",
-		     varname1, code1, varname2, code2);
+	  if ( cdoVerbose ) cdoPrint("Variable %s replaced.", varname1);
 
 	  varlist1[nchvars] = varID1;
 	  varlist2[nchvars] = varID2;
@@ -121,15 +100,15 @@ void *Replace(void *argument)
 	}
       else
 	{
-	  cdoPrint("Variable %s (code %d) not found!", varname2, code2);
+	  cdoPrint("Variable %s not found!", varname2);
 	}
     }
 
   if ( nchvars )
     {
-      vardata2  = (double **) malloc(nchvars*sizeof(double *));
-      varnmiss2 = (int **) malloc(nchvars*sizeof(int *));
-      varlevel  = (int **) malloc(nchvars*sizeof(int *));
+      vardata2  = (double **) Malloc(nchvars*sizeof(double *));
+      varnmiss2 = (int **) Malloc(nchvars*sizeof(int *));
+      varlevel  = (int **) Malloc(nchvars*sizeof(int *));
       for ( idx = 0; idx < nchvars; idx++ )
 	{
 	  varID1 = varlist1[idx];
@@ -137,17 +116,17 @@ void *Replace(void *argument)
 	  nlevel1  = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID1));
 	  nlevel2  = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID2));
 	  gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID2));
-	  vardata2[idx]  = (double*) malloc(nlevel2*gridsize*sizeof(double));
-	  varnmiss2[idx] = (int*) malloc(nlevel2*sizeof(int));
-	  varlevel[idx] = (int*) malloc(nlevel1*sizeof(int));
+	  vardata2[idx]  = (double*) Malloc(nlevel2*gridsize*sizeof(double));
+	  varnmiss2[idx] = (int*) Malloc(nlevel2*sizeof(int));
+	  varlevel[idx] = (int*) Malloc(nlevel1*sizeof(int));
 	  /*
 	  for ( levelID = 0; levelID < nlevel1; levelID++ )
 	    varlevel[idx][levelID] = levelID;
 	  */
 	  if ( nlevel2 <= nlevel1 )
 	    {
-	      double *level1 = (double*) malloc(nlevel1*sizeof(double));
-	      double *level2 = (double*) malloc(nlevel2*sizeof(double));
+	      double *level1 = (double*) Malloc(nlevel1*sizeof(double));
+	      double *level2 = (double*) Malloc(nlevel2*sizeof(double));
 	      zaxisInqLevels(vlistInqVarZaxis(vlistID1, varID1), level1);
 	      zaxisInqLevels(vlistInqVarZaxis(vlistID2, varID2), level2);
 
@@ -167,25 +146,25 @@ void *Replace(void *argument)
 		  if ( l1 == nlevel1 ) cdoWarning("Level %g not found!", level2[l2]);
 		}
 
-	      free(level1);
-	      free(level2);
+	      Free(level1);
+	      Free(level2);
 	    }
 	}
     }
 
-  vlistID3 = vlistDuplicate(vlistID1);
+  int vlistID3 = vlistDuplicate(vlistID1);
 
-  streamID3 = streamOpenWrite(cdoStreamName(2), cdoFiletype());
+  int streamID3 = streamOpenWrite(cdoStreamName(2), cdoFiletype());
 
   vlistDefTaxis(vlistID3, taxisID3);
   streamDefVlist(streamID3, vlistID3);
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array = (double*) malloc(gridsize*sizeof(double));
+  double *array = (double*) Malloc(gridsize*sizeof(double));
 
-  nts2 = vlistNtsteps(vlistID2);
+  int nts2 = vlistNtsteps(vlistID2);
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       taxisCopyTimestep(taxisID3, taxisID1);
@@ -252,19 +231,19 @@ void *Replace(void *argument)
     {
       for ( idx = 0; idx < nchvars; idx++ )
 	{
-	  free(vardata2[idx]);
-	  free(varnmiss2[idx]);
-	  free(varlevel[idx]);
+	  Free(vardata2[idx]);
+	  Free(varnmiss2[idx]);
+	  Free(varlevel[idx]);
 	}
 
-      free(vardata2);
-      free(varnmiss2);
-      free(varlevel);
+      Free(vardata2);
+      Free(varnmiss2);
+      Free(varlevel);
     }
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Replacevalues.c b/src/Replacevalues.c
index c3ef91c..1de165f 100644
--- a/src/Replacevalues.c
+++ b/src/Replacevalues.c
@@ -100,7 +100,7 @@ void *Replacevalues(void *argument)
 
   gridsize = vlistGridsizeMax(vlistID1);
 
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -171,11 +171,11 @@ void *Replacevalues(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   listDelete(flist);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Rhopot.c b/src/Rhopot.c
index b4ebf0b..e6b3fcb 100644
--- a/src/Rhopot.c
+++ b/src/Rhopot.c
@@ -121,7 +121,7 @@ int main (int argc, char *argv[])
       printf("%d %5g %3g %8g %8g %8g %10.3f\n", i, p, s[i], t[i], x[i], r[i], r[i]-x[i]);
   }
 
-  return (0);
+  return 0;
 }
 */
 
@@ -234,7 +234,7 @@ void *Rhopot(void *argument)
   if ( nlevel1 != nlevel2 ) cdoAbort("temperature and salinity have different number of levels!");
   nlevel = nlevel1;
 
-  pressure = (double*) malloc(nlevel*sizeof(double));
+  pressure = (double*) Malloc(nlevel*sizeof(double));
   zaxisInqLevels(zaxisID, pressure);
 
   if ( pin >= 0 ) 
@@ -252,9 +252,9 @@ void *Rhopot(void *argument)
   field_init(&to);
   field_init(&sao);
   field_init(&rho);
-  to.ptr = (double*) malloc(gridsize*nlevel*sizeof(double));
-  sao.ptr = (double*) malloc(gridsize*nlevel*sizeof(double));
-  rho.ptr = (double*) malloc(gridsize*nlevel*sizeof(double));
+  to.ptr = (double*) Malloc(gridsize*nlevel*sizeof(double));
+  sao.ptr = (double*) Malloc(gridsize*nlevel*sizeof(double));
+  rho.ptr = (double*) Malloc(gridsize*nlevel*sizeof(double));
 
   to.nmiss = 0;
   sao.nmiss = 0;
@@ -323,12 +323,12 @@ void *Rhopot(void *argument)
 
   vlistDestroy(vlistID2);
 
-  free(pressure);
-  free(rho.ptr);
-  free(to.ptr);
-  free(sao.ptr);
+  Free(pressure);
+  Free(rho.ptr);
+  Free(to.ptr);
+  Free(sao.ptr);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Rotuv.c b/src/Rotuv.c
index 84dcb0f..f5e9f10 100644
--- a/src/Rotuv.c
+++ b/src/Rotuv.c
@@ -46,8 +46,8 @@ void rot_uv_back(int gridID, double *us, double *vs)
   ypole = gridInqYpole(gridID);
   angle = gridInqAngle(gridID);
 
-  xvals = (double*) malloc(nlon*sizeof(double));
-  yvals = (double*) malloc(nlat*sizeof(double));
+  xvals = (double*) Malloc(nlon*sizeof(double));
+  yvals = (double*) Malloc(nlat*sizeof(double));
 
   gridInqXvals(gridID, xvals);
   gridInqYvals(gridID, yvals);
@@ -81,42 +81,45 @@ void rot_uv_back(int gridID, double *us, double *vs)
 	vs[i] = v;
       }
 
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
 }
 
 #define  MAXARG     16384
 
 void *Rotuv(void *argument)
 {
-  int streamID1, streamID2;
-  int nrecs;
-  int tsID, recID, varID, levelID;
+  int recID, varID, levelID;
   int varID1, varID2, nlevel1, nlevel2;
   int gridsize;
-  int nvars, code, gridID;
-  int vlistID1, vlistID2;
+  int code, gridID;
   int offset;
   int nlevel;
   int lvar = FALSE;
-  int i, nch;
+  int i;
   int lfound[MAXARG];
   int chcodes[MAXARG];
   char *chvars[MAXARG];
   char varname[CDI_MAX_NAME];
-  int taxisID1, taxisID2;
-  int *recVarID, *recLevelID;
-  int **varnmiss;
-  double **vardata, *single, *usvar = NULL, *vsvar = NULL;
+  double *single, *usvar = NULL, *vsvar = NULL;
 
   cdoInitialize(argument);
 
   operatorInputArg("pairs of u and v in the rotated system");
 
-  nch = operatorArgc();
+  int nch = operatorArgc();
   if ( nch%2 ) cdoAbort("Odd number of input arguments!");
 
-  if ( isdigit(*operatorArgv()[0]) )
+  int lcode = TRUE;
+  int len = (int)strlen(operatorArgv()[0]);
+  for ( i = 0; i < len; ++i )
+    if ( !isdigit(operatorArgv()[0][i]) )
+      {
+        lcode = FALSE;
+        break;
+      }
+
+  if ( lcode )
     {
       lvar = FALSE;
       for ( i = 0; i < nch; i++ )
@@ -129,19 +132,19 @@ void *Rotuv(void *argument)
 	chvars[i] = operatorArgv()[i];
     }
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = vlistDuplicate(vlistID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
 
-  nvars = vlistNvars(vlistID1);
-  nrecs = vlistNrecs(vlistID1);
+  int nvars = vlistNvars(vlistID1);
+  int nrecs = vlistNrecs(vlistID1);
 
-  recVarID   = (int*) malloc(nrecs*sizeof(int));
-  recLevelID = (int*) malloc(nrecs*sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecs*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecs*sizeof(int));
 
-  varnmiss   = (int **) malloc(nvars*sizeof(int *));
-  vardata    = (double **) malloc(nvars*sizeof(double *));
+  int **varnmiss    = (int **) Malloc(nvars*sizeof(int *));
+  double **vardata  = (double **) Malloc(nvars*sizeof(double *));
 
   for ( i = 0; i < nch; i++ ) lfound[i] = FALSE;
 
@@ -176,19 +179,19 @@ void *Rotuv(void *argument)
 
       gridsize = gridInqSize(gridID);
       nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
-      varnmiss[varID] = (int*) malloc(nlevel*sizeof(int));
-      vardata[varID]  = (double*) malloc(gridsize*nlevel*sizeof(double));
+      varnmiss[varID] = (int*) Malloc(nlevel*sizeof(int));
+      vardata[varID]  = (double*) Malloc(gridsize*nlevel*sizeof(double));
     }
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       taxisCopyTimestep(taxisID2, taxisID1);
@@ -294,11 +297,11 @@ void *Rotuv(void *argument)
 
   for ( varID = 0; varID < nvars; varID++ )
     {
-      free(varnmiss[varID]);
-      free(vardata[varID]);
+      Free(varnmiss[varID]);
+      Free(vardata[varID]);
     }
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Runpctl.c b/src/Runpctl.c
index 9958a27..0fae864 100644
--- a/src/Runpctl.c
+++ b/src/Runpctl.c
@@ -25,7 +25,7 @@
 #include "cdo.h"
 #include "cdo_int.h"
 #include "pstream.h"
-#include "nth_element.h"
+#include "percentiles.h"
 
 
 void *Runpctl(void *argument)
@@ -51,12 +51,10 @@ void *Runpctl(void *argument)
 
   operatorInputArg("percentile number, number of timesteps");
   operatorCheckArgc(2);
-  int pn     = parameter2int(operatorArgv()[0]);
+  double pn  = parameter2double(operatorArgv()[0]);
+  percentile_check_number(pn);
   int ndates = parameter2int(operatorArgv()[1]);
 
-  if ( pn < 1 || pn > 99 )
-    cdoAbort("Illegal argument: percentile number %d is not in the range 1..99!", pn);
-
   int streamID1 = streamOpenRead(cdoStreamName(0));
 
   int vlistID1 = streamInqVlist(streamID1);
@@ -73,15 +71,15 @@ void *Runpctl(void *argument)
   int nvars    = vlistNvars(vlistID1);
   int nrecords = vlistNrecs(vlistID1);
 
-  int *recVarID   = (int*) malloc(nrecords*sizeof(int));
-  int *recLevelID = (int*) malloc(nrecords*sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   dtlist_type *dtlist = dtlist_new();
   dtlist_set_stat(dtlist, timestat_date);
   dtlist_set_calendar(dtlist, taxisInqCalendar(taxisID1));
 
-  vars1 = (field_t ***) malloc((ndates+1)*sizeof(field_t **));
-  array = (double*) malloc(ndates*sizeof(double));
+  vars1 = (field_t ***) Malloc((ndates+1)*sizeof(field_t **));
+  array = (double*) Malloc(ndates*sizeof(double));
   
   for ( its = 0; its < ndates; its++ )
     {
@@ -135,7 +133,7 @@ void *Runpctl(void *argument)
                   
                   if ( j > 0 )
                     {
-                      vars1[0][varID][levelID].ptr[i] = nth_element(array, j, (int)ceil(j*(pn/100.0))-1);
+                      vars1[0][varID][levelID].ptr[i] = percentile(array, j, pn);
                     }
                   else
                     {
@@ -192,11 +190,11 @@ void *Runpctl(void *argument)
       field_free(vars1[its], vlistID1);
     }
 
-  free(vars1);
-  free(array);
+  Free(vars1);
+  Free(array);
   
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   dtlist_delete(dtlist);
 
@@ -205,5 +203,5 @@ void *Runpctl(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Runstat.c b/src/Runstat.c
index b7b583e..c973f19 100644
--- a/src/Runstat.c
+++ b/src/Runstat.c
@@ -46,7 +46,7 @@ void *Runstat(void *argument)
   int levelID;
   int tsID;
   int otsID;
-  int inp, its;
+  int its;
   int nmiss;
   int nlevel;
   int runstat_nomiss = 0;
@@ -100,18 +100,18 @@ void *Runstat(void *argument)
   int nvars    = vlistNvars(vlistID1);
   int nrecords = vlistNrecs(vlistID1);
 
-  int *recVarID   = (int*) malloc(nrecords*sizeof(int));
-  int *recLevelID = (int*) malloc(nrecords*sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   dtlist_type *dtlist = dtlist_new();
   dtlist_set_stat(dtlist, timestat_date);
   dtlist_set_calendar(dtlist, taxisInqCalendar(taxisID1));
 
-  vars1 = (field_t ***) malloc((ndates+1)*sizeof(field_t **));
+  vars1 = (field_t ***) Malloc((ndates+1)*sizeof(field_t **));
   if ( !runstat_nomiss )
-    samp1 = (field_t ***) malloc((ndates+1)*sizeof(field_t **));
+    samp1 = (field_t ***) Malloc((ndates+1)*sizeof(field_t **));
   if ( lvarstd )
-    vars2 = (field_t ***) malloc((ndates+1)*sizeof(field_t **));
+    vars2 = (field_t ***) Malloc((ndates+1)*sizeof(field_t **));
 
   for ( its = 0; its < ndates; its++ )
     {
@@ -123,7 +123,7 @@ void *Runstat(void *argument)
     }
 
   int gridsizemax = vlistGridsizeMax(vlistID1);
-  int *imask = (int*) malloc(gridsizemax*sizeof(int));
+  int *imask = (int*) Malloc(gridsizemax*sizeof(int));
 
   for ( tsID = 0; tsID < ndates; tsID++ )
     {
@@ -162,12 +162,12 @@ void *Runstat(void *argument)
 		samp1[tsID][varID][levelID].ptr[i] = (double) imask[i];
 
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(i, inp)
+#pragma omp parallel for default(none) shared(tsID,gridsize,imask,samp1,varID,levelID)
 #endif
-	      for ( inp = 0; inp < tsID; inp++ )
+	      for ( int inp = 0; inp < tsID; inp++ )
 		{
 		  double *ptr = samp1[inp][varID][levelID].ptr;
-		  for ( i = 0; i < gridsize; i++ )
+		  for ( int i = 0; i < gridsize; i++ )
 		    if ( imask[i] > 0 ) ptr[i]++;
 		}
 	    }
@@ -176,9 +176,9 @@ void *Runstat(void *argument)
 	    {
 	      farmoq(&vars2[tsID][varID][levelID], vars1[tsID][varID][levelID]);
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared)
+#pragma omp parallel for default(none) shared(tsID,vars1,vars2,varID,levelID)
 #endif
-	      for ( inp = 0; inp < tsID; inp++ )
+	      for ( int inp = 0; inp < tsID; inp++ )
 		{
 		  farsumq(&vars2[inp][varID][levelID], vars1[tsID][varID][levelID]);
 		  farsum(&vars1[inp][varID][levelID], vars1[tsID][varID][levelID]);
@@ -187,9 +187,9 @@ void *Runstat(void *argument)
 	  else
 	    {
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared)
+#pragma omp parallel for default(none) shared(tsID,vars1,operfunc,varID,levelID)
 #endif
-	      for ( inp = 0; inp < tsID; inp++ )
+	      for ( int inp = 0; inp < tsID; inp++ )
 		{
 		  farfun(&vars1[inp][varID][levelID], vars1[tsID][varID][levelID], operfunc);
 		}
@@ -208,7 +208,7 @@ void *Runstat(void *argument)
 	    for ( levelID = 0; levelID < nlevel; levelID++ )
 	      {
 		if ( runstat_nomiss )
-		  farcmul(&vars1[0][varID][levelID], 1.0/ndates);
+		  farcdiv(&vars1[0][varID][levelID], (double)ndates);
 		else
 		  fardiv(&vars1[0][varID][levelID], samp1[0][varID][levelID]);
 	      }
@@ -223,16 +223,16 @@ void *Runstat(void *argument)
 		if ( runstat_nomiss )
 		  {
 		    if ( lstd )
-		      farcstdx(&vars1[0][varID][levelID], vars2[0][varID][levelID], ndates, divisor);
+		      farcstd(&vars1[0][varID][levelID], vars2[0][varID][levelID], ndates, divisor);
 		    else
-		      farcvarx(&vars1[0][varID][levelID], vars2[0][varID][levelID], ndates, divisor);
+		      farcvar(&vars1[0][varID][levelID], vars2[0][varID][levelID], ndates, divisor);
 		  }
 		else
 		  {
 		    if ( lstd )
-		      farstdx(&vars1[0][varID][levelID], vars2[0][varID][levelID], samp1[0][varID][levelID], divisor);
+		      farstd(&vars1[0][varID][levelID], vars2[0][varID][levelID], samp1[0][varID][levelID], divisor);
 		    else
-		      farvarx(&vars1[0][varID][levelID], vars2[0][varID][levelID], samp1[0][varID][levelID], divisor);
+		      farvar(&vars1[0][varID][levelID], vars2[0][varID][levelID], samp1[0][varID][levelID], divisor);
 		  }
 	      }
 	  }
@@ -261,7 +261,7 @@ void *Runstat(void *argument)
       if ( lvarstd )
         vars2[ndates] = vars2[0];
 
-      for ( inp = 0; inp < ndates; inp++ )
+      for ( int inp = 0; inp < ndates; inp++ )
 	{
 	  vars1[inp] = vars1[inp+1];
 	  if ( !runstat_nomiss )
@@ -299,12 +299,12 @@ void *Runstat(void *argument)
 		samp1[ndates-1][varID][levelID].ptr[i] = (double) imask[i];
 
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(i, inp)
+#pragma omp parallel for default(none) shared(ndates,imask,gridsize,samp1,varID,levelID)
 #endif
-	      for ( inp = 0; inp < ndates-1; inp++ )
+	      for ( int inp = 0; inp < ndates-1; inp++ )
 		{
 		  double *ptr = samp1[inp][varID][levelID].ptr;
-		  for ( i = 0; i < gridsize; i++ )
+		  for ( int i = 0; i < gridsize; i++ )
 		    if ( imask[i] > 0 ) ptr[i]++;
 		}
 	    }
@@ -313,9 +313,9 @@ void *Runstat(void *argument)
 	    {
 	      farmoq(&vars2[ndates-1][varID][levelID], vars1[ndates-1][varID][levelID]);
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared)
+#pragma omp parallel for default(none) shared(ndates,vars1,vars2,varID,levelID)
 #endif
-	      for ( inp = 0; inp < ndates-1; inp++ )
+	      for ( int inp = 0; inp < ndates-1; inp++ )
 		{
 		  farsumq(&vars2[inp][varID][levelID], vars1[ndates-1][varID][levelID]);
 		  farsum(&vars1[inp][varID][levelID], vars1[ndates-1][varID][levelID]);
@@ -324,9 +324,9 @@ void *Runstat(void *argument)
 	  else
 	    {
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared)
+#pragma omp parallel for default(none) shared(ndates,vars1,varID,levelID,operfunc)
 #endif
-	      for ( inp = 0; inp < ndates-1; inp++ )
+	      for ( int inp = 0; inp < ndates-1; inp++ )
 		{
 		  farfun(&vars1[inp][varID][levelID], vars1[ndates-1][varID][levelID], operfunc);
 		}
@@ -343,13 +343,13 @@ void *Runstat(void *argument)
       if ( lvarstd ) field_free(vars2[its], vlistID1);
     }
 
-  free(vars1);
-  if ( !runstat_nomiss ) free(samp1);
-  if ( lvarstd ) free(vars2);
+  Free(vars1);
+  if ( !runstat_nomiss ) Free(samp1);
+  if ( lvarstd ) Free(vars2);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
-  if ( imask )      free(imask);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
+  if ( imask )      Free(imask);
 
   dtlist_delete(dtlist);
 
@@ -358,5 +358,5 @@ void *Runstat(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/SSOpar.c b/src/SSOpar.c
index 69e3949..d735501 100644
--- a/src/SSOpar.c
+++ b/src/SSOpar.c
@@ -42,10 +42,10 @@ void data_treat(double *zdata, double *xdata, double *ydata, long nx, long ny)
   int *iscale = NULL;
   long i, j;
 
-  zwork  = (double*) malloc(3*nx*ny*sizeof(double));
-  xwork  = (double*) malloc(3*nx*sizeof(double));
-  xscale = (double*) malloc(ny*sizeof(double));
-  iscale = (int*) malloc(ny*sizeof(int));
+  zwork  = (double*) Malloc(3*nx*ny*sizeof(double));
+  xwork  = (double*) Malloc(3*nx*sizeof(double));
+  xscale = (double*) Malloc(ny*sizeof(double));
+  iscale = (int*) Malloc(ny*sizeof(int));
 
   double pi2 = 2*acos(-1.);
   for ( i = 0; i < nx; ++i )
@@ -97,10 +97,10 @@ void data_treat(double *zdata, double *xdata, double *ydata, long nx, long ny)
   ENDDO
   */
 
-  free(zwork);
-  free(xwork);
-  free(xscale);
-  free(iscale);
+  Free(zwork);
+  Free(xwork);
+  Free(xscale);
+  Free(iscale);
 } // data_treat
 
 static
@@ -762,7 +762,7 @@ void *SSOpar(void *argument)
                       if ( cdoVerbose )
                         cdoPrint("lhavevct=TRUE  zaxisIDh = %d, nhlevf   = %d", zaxisIDh, nlevel);
  
-		      vct = (double*) malloc(nvct*sizeof(double));
+		      vct = (double*) Malloc(nvct*sizeof(double));
 		      zaxisInqVct(zaxisID, vct);
 
 		      if ( cdoVerbose )
@@ -844,18 +844,18 @@ void *SSOpar(void *argument)
 
   if ( tempID == -1 ) cdoAbort("Temperature not found!");
 
-  array  = (double*) malloc(gridsize*sizeof(double));
+  array  = (double*) Malloc(gridsize*sizeof(double));
 
-  geop   = (double*) malloc(gridsize*sizeof(double));
-  ps     = (double*) malloc(gridsize*sizeof(double));
+  geop   = (double*) Malloc(gridsize*sizeof(double));
+  ps     = (double*) Malloc(gridsize*sizeof(double));
 
-  temp   = (double*) malloc(gridsize*nhlevf*sizeof(double));
-  hum    = (double*) malloc(gridsize*nhlevf*sizeof(double));
-  lwater = (double*) malloc(gridsize*nhlevf*sizeof(double));
-  iwater = (double*) malloc(gridsize*nhlevf*sizeof(double));
+  temp   = (double*) Malloc(gridsize*nhlevf*sizeof(double));
+  hum    = (double*) Malloc(gridsize*nhlevf*sizeof(double));
+  lwater = (double*) Malloc(gridsize*nhlevf*sizeof(double));
+  iwater = (double*) Malloc(gridsize*nhlevf*sizeof(double));
 
-  half_press   = (double*) malloc(gridsize*(nhlevf+1)*sizeof(double));
-  geopotheight = (double*) malloc(gridsize*(nhlevf+1)*sizeof(double));
+  half_press   = (double*) Malloc(gridsize*(nhlevf+1)*sizeof(double));
+  geopotheight = (double*) Malloc(gridsize*(nhlevf+1)*sizeof(double));
 
   if ( zaxisIDh != -1 && geopID == -1 )
     {
@@ -976,18 +976,18 @@ void *SSOpar(void *argument)
 
   vlistDestroy(vlistID2);
 
-  free(ps);
-  free(geop);
-  free(temp);
-  free(geopotheight);
-  if ( hum ) free(hum);
+  Free(ps);
+  Free(geop);
+  Free(temp);
+  Free(geopotheight);
+  if ( hum ) Free(hum);
 
-  if ( half_press ) free(half_press);
+  if ( half_press ) Free(half_press);
 
-  free(array);
-  if ( vct ) free(vct);
+  Free(array);
+  if ( vct ) Free(vct);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Seascount.c b/src/Seascount.c
index 1318c18..9c5c3c8 100644
--- a/src/Seascount.c
+++ b/src/Seascount.c
@@ -71,14 +71,14 @@ void *Seascount(void *argument)
 
   nrecords = vlistNrecs(vlistID1);
 
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = vlistGridsizeMax(vlistID1);
   if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
 
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   vars1 = field_malloc(vlistID1, FIELD_PTR);
 
@@ -93,30 +93,11 @@ void *Seascount(void *argument)
           vdate = taxisInqVdate(taxisID1);
           vtime = taxisInqVtime(taxisID1);
 	  cdiDecodeDate(vdate, &year, &month, &day);
-          if ( month < 0 || month > 16 )
-            cdoAbort("Month %d out of range!", month);
 
 	  newmon = month;
+	  if ( season_start == START_DEC && newmon == 12 ) newmon = 0;
 
-	  if ( season_start == START_DEC )
-	    {
-	      if ( newmon == 12 ) newmon = 0;
-
-	      if ( month <= 12 )
-		seas = (month % 12) / 3;
-	      else
-		seas = month - 13;
-	    }
-	  else
-	    {
-	      if ( month <= 12 )
-		seas = (month - 1) / 3;
-	      else
-		seas = month - 13;
-	    }
-
-          if ( seas < 0 || seas > 3 )
-            cdoAbort("Season %d out of range!", seas+1);
+          seas = month_to_season(month);
 
           if ( nsets == 0 )
             {
@@ -186,15 +167,15 @@ void *Seascount(void *argument)
 
   field_free(vars1, vlistID1);
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID2);
   streamClose(streamID1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Seaspctl.c b/src/Seaspctl.c
index 0df7940..f5f85b5 100644
--- a/src/Seaspctl.c
+++ b/src/Seaspctl.c
@@ -26,7 +26,7 @@
 #include "cdo.h"
 #include "cdo_int.h"
 #include "pstream.h"
-#include "percentiles.h"
+#include "percentiles_hist.h"
 #include "util.h"
 
 
@@ -57,9 +57,7 @@ void *Seaspctl(void *argument)
 
   operatorInputArg("percentile number");
   double pn = parameter2double(operatorArgv()[0]);
-      
-  if ( !(pn > 0 && pn < 100) )
-    cdoAbort("Illegal argument: percentile number %g is not in the range 0..100!", pn);
+  percentile_check_number(pn);
 
   season_start = get_season_start();
 
@@ -90,8 +88,8 @@ void *Seaspctl(void *argument)
   int nvars    = vlistNvars(vlistID1);
   int nrecords = vlistNrecs(vlistID1);
 
-  int *recVarID   = (int*) malloc(nrecords * sizeof(int));
-  int *recLevelID = (int*) malloc(nrecords * sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecords * sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords * sizeof(int));
 
   dtlist_type *dtlist = dtlist_new();
   dtlist_set_stat(dtlist, timestat_date);
@@ -99,9 +97,9 @@ void *Seaspctl(void *argument)
 
   int gridsize = vlistGridsizeMax(vlistID1);
 
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
-  vars1 = (field_t **) malloc(nvars * sizeof(field_t *));
+  vars1 = (field_t **) Malloc(nvars * sizeof(field_t *));
   hset = hsetCreate(nvars);
 
   for ( varID = 0; varID < nvars; varID++ )
@@ -111,7 +109,7 @@ void *Seaspctl(void *argument)
       nlevels   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
       missval  = vlistInqVarMissval(vlistID1, varID);
 
-      vars1[varID] = (field_t*) malloc(nlevels * sizeof(field_t));
+      vars1[varID] = (field_t*) Malloc(nlevels * sizeof(field_t));
       hsetCreateVarLevels(hset, varID, nlevels, gridID);
 
       for ( levelID = 0; levelID < nlevels; levelID++ )
@@ -119,7 +117,7 @@ void *Seaspctl(void *argument)
 	  vars1[varID][levelID].grid    = gridID;
 	  vars1[varID][levelID].nmiss   = 0;
 	  vars1[varID][levelID].missval = missval;
-	  vars1[varID][levelID].ptr     = (double*) malloc(gridsize * sizeof(double));
+	  vars1[varID][levelID].ptr     = (double*) Malloc(gridsize * sizeof(double));
 	}
     }
 
@@ -164,30 +162,12 @@ void *Seaspctl(void *argument)
 	  vdate1 = dtlist_get_vdate(dtlist, nsets);
 
 	  cdiDecodeDate(vdate1, &year, &month, &day);
-	  if ( month < 0 || month > 16 )
-	    cdoAbort("Month %d out of range!", month);
 
 	  newmon = month;
 
-	  if ( season_start == START_DEC )
-	    {
-	      if ( newmon == 12 ) newmon = 0;
-
-	      if ( month <= 12 )
-		seas = (month % 12) / 3;
-	      else
-		seas = month - 13;
-	    }
-	  else
-	    {
-	      if ( month <= 12 )
-		seas = (month - 1) / 3;
-	      else
-		seas = month - 13;
-	    }
+	  if ( season_start == START_DEC && newmon == 12 ) newmon = 0;
 
-	  if ( seas < 0 || seas > 3 )
-	    cdoAbort("Season %d out of range!", seas + 1);
+          seas = month_to_season(month);
 
 	  if ( nsets == 0 )
 	    {
@@ -252,19 +232,19 @@ void *Seaspctl(void *argument)
     {
       nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
       for ( levelID = 0; levelID < nlevels; levelID++ )
-	free(vars1[varID][levelID].ptr);
-      free(vars1[varID]);
+        Free(vars1[varID][levelID].ptr);
+      Free(vars1[varID]);
     }
 
-  free(vars1);
+  Free(vars1);
   hsetDestroy(hset);
 
   dtlist_delete(dtlist);
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID4);
   streamClose(streamID3);
@@ -273,5 +253,5 @@ void *Seaspctl(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Seasstat.c b/src/Seasstat.c
index d4326e0..6ea36fa 100644
--- a/src/Seasstat.c
+++ b/src/Seasstat.c
@@ -24,7 +24,9 @@
       Seasstat   seasmean        Seasonal mean
       Seasstat   seasavg         Seasonal average
       Seasstat   seasvar         Seasonal variance
+      Seasstat   seasvar1        Seasonal variance [Divisor is (n-1)]
       Seasstat   seasstd         Seasonal standard deviation
+      Seasstat   seasstd1        Seasonal standard deviation [Divisor is (n-1)]
 */
 
 
@@ -44,8 +46,6 @@ void *Seasstat(void *argument)
   int vdate1 = 0, vtime1 = 0;
   int nrecs;
   int varID, levelID, recID;
-  int tsID;
-  int otsID;
   long nsets;
   int i;
   int year, month, day, seas, seas0 = 0;
@@ -53,9 +53,6 @@ void *Seasstat(void *argument)
   int nlevel;
   int newseas, oldmon = 0, newmon;
   int nseason = 0;
-  field_t **vars1 = NULL, **vars2 = NULL, **samp1 = NULL;
-  field_t field;
-  int season_start;
   const char *seas_name[4];
 
   cdoInitialize(argument);
@@ -66,14 +63,21 @@ void *Seasstat(void *argument)
   cdoOperatorAdd("seasmean", func_mean, 0, NULL);
   cdoOperatorAdd("seasavg",  func_avg,  0, NULL);
   cdoOperatorAdd("seasvar",  func_var,  0, NULL);
+  cdoOperatorAdd("seasvar1", func_var1, 0, NULL);
   cdoOperatorAdd("seasstd",  func_std,  0, NULL);
+  cdoOperatorAdd("seasstd1", func_std1, 0, NULL);
 
   int operatorID = cdoOperatorID();
   int operfunc = cdoOperatorF1(operatorID);
 
-  season_start = get_season_start();
+  int season_start = get_season_start();
   get_season_name(seas_name);
 
+  int lmean   = operfunc == func_mean || operfunc == func_avg;
+  int lstd    = operfunc == func_std || operfunc == func_std1;
+  int lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
+  double divisor = operfunc == func_std1 || operfunc == func_var1;
+
   int streamID1 = streamOpenRead(cdoStreamName(0));
 
   int vlistID1 = streamInqVlist(streamID1);
@@ -91,8 +95,8 @@ void *Seasstat(void *argument)
   int nvars    = vlistNvars(vlistID1);
   int nrecords = vlistNrecs(vlistID1);
 
-  int *recVarID   = (int*) malloc(nrecords*sizeof(int));
-  int *recLevelID = (int*) malloc(nrecords*sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   dtlist_type *dtlist = dtlist_new();
   dtlist_set_stat(dtlist, timestat_date);
@@ -100,16 +104,17 @@ void *Seasstat(void *argument)
 
   gridsize = vlistGridsizeMax(vlistID1);
 
+  field_t field;
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
-  vars1 = field_malloc(vlistID1, FIELD_PTR);
-  samp1 = field_malloc(vlistID1, FIELD_NONE);
-  if ( operfunc == func_std || operfunc == func_var )
-    vars2 = field_malloc(vlistID1, FIELD_PTR);
+  field_t **samp1 = field_malloc(vlistID1, FIELD_NONE);
+  field_t **vars1 = field_malloc(vlistID1, FIELD_PTR);
+  field_t **vars2 = NULL;
+  if ( lvarstd ) vars2 = field_malloc(vlistID1, FIELD_PTR);
 
-  tsID    = 0;
-  otsID   = 0;
+  int tsID    = 0;
+  int otsID   = 0;
   while ( TRUE )
     {
       nsets = 0;
@@ -121,30 +126,12 @@ void *Seasstat(void *argument)
 	  vtime = dtlist_get_vtime(dtlist, nsets);
 
 	  cdiDecodeDate(vdate, &year, &month, &day);
-	  if ( month < 1 || month > 12 )
-	    cdoAbort("Month %d out of range!", month);
 
 	  newmon = month;
 
-	  if ( season_start == START_DEC )
-	    {
-	      if ( newmon == 12 ) newmon = 0;
-
-	      if ( month <= 12 )
-		seas = (month % 12) / 3;
-	      else
-		seas = month - 13;
-	    }
-	  else
-	    {
-	      if ( month <= 12 )
-		seas = (month - 1) / 3;
-	      else
-		seas = month - 13;
-	    }
+	  if ( season_start == START_DEC && newmon == 12 ) newmon = 0;
 
-	  if ( seas < 0 || seas > 3 )
-	    cdoAbort("Season %d out of range!", seas+1);
+          seas = month_to_season(month);
 
 	  if ( nsets == 0 )
 	    {
@@ -181,7 +168,7 @@ void *Seasstat(void *argument)
 		  if ( nmiss > 0 || samp1[varID][levelID].ptr )
 		    {
 		      if ( samp1[varID][levelID].ptr == NULL )
-			samp1[varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+			samp1[varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 
 		      for ( i = 0; i < gridsize; i++ )
 			if ( DBL_IS_EQUAL(vars1[varID][levelID].ptr[i],
@@ -201,7 +188,7 @@ void *Seasstat(void *argument)
 		    {
 		      if ( samp1[varID][levelID].ptr == NULL )
 			{
-			  samp1[varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+			  samp1[varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 			  for ( i = 0; i < gridsize; i++ )
 			    samp1[varID][levelID].ptr[i] = nsets;
 			}
@@ -211,7 +198,7 @@ void *Seasstat(void *argument)
 			  samp1[varID][levelID].ptr[i]++;
 		    }
 
-		  if ( operfunc == func_std || operfunc == func_var )
+		  if ( lvarstd )
 		    {
 		      farsumq(&vars2[varID][levelID], field);
 		      farsum(&vars1[varID][levelID], field);
@@ -223,7 +210,7 @@ void *Seasstat(void *argument)
 		}
 	    }
 
-	  if ( nsets == 0 && (operfunc == func_std || operfunc == func_var) )
+	  if ( nsets == 0 && lvarstd )
 	    for ( varID = 0; varID < nvars; varID++ )
 	      {
 		if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
@@ -240,7 +227,7 @@ void *Seasstat(void *argument)
 
       if ( nrecs == 0 && nsets == 0 ) break;
 
-      if ( operfunc == func_mean || operfunc == func_avg )
+      if ( lmean )
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
 	    if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
@@ -248,12 +235,12 @@ void *Seasstat(void *argument)
 	    for ( levelID = 0; levelID < nlevel; levelID++ )
 	      {
 		if ( samp1[varID][levelID].ptr == NULL )
-		  farcmul(&vars1[varID][levelID], 1.0/nsets);
+		  farcdiv(&vars1[varID][levelID], (double)nsets);
 		else
 		  fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
 	      }
 	  }
-      else if ( operfunc == func_std || operfunc == func_var )
+      else if ( lvarstd )
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
 	    if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
@@ -262,18 +249,17 @@ void *Seasstat(void *argument)
 	      {
 		if ( samp1[varID][levelID].ptr == NULL )
 		  {
-		    if ( operfunc == func_std )
-		      farcstd(&vars1[varID][levelID], vars2[varID][levelID], 1.0/nsets);
+		    if ( lstd )
+		      farcstd(&vars1[varID][levelID], vars2[varID][levelID], nsets, divisor);
 		    else
-		      farcvar(&vars1[varID][levelID], vars2[varID][levelID], 1.0/nsets);
+		      farcvar(&vars1[varID][levelID], vars2[varID][levelID], nsets, divisor);
 		  }
 		else
 		  {
-		    farinv(&samp1[varID][levelID]);
-		    if ( operfunc == func_std )
-		      farstd(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID]);
+		    if ( lstd )
+		      farstd(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID], divisor);
 		    else
-		      farvar(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID]);
+		      farvar(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID], divisor);
 		  }
 	      }
 	  }
@@ -287,8 +273,7 @@ void *Seasstat(void *argument)
 	  date2str(vdate1, vdatestr1, sizeof(vdatestr1));
 	  time2str(vtime1, vtimestr1, sizeof(vtimestr1));
 	  cdoPrint("season %3d %3s start %s %s end %s %s ntimesteps %d", 
-		   nseason, seas_name[seas0],
-		   vdatestr0, vtimestr0, vdatestr1, vtimestr1, nsets);
+		   nseason, seas_name[seas0], vdatestr0, vtimestr0, vdatestr1, vtimestr1, nsets);
 	}
 
       dtlist_stat_taxisDefTimestep(dtlist, taxisID2, nsets);
@@ -320,12 +305,12 @@ void *Seasstat(void *argument)
 
   field_free(vars1, vlistID1);
   field_free(samp1, vlistID1);
-  if ( operfunc == func_std || operfunc == func_var ) field_free(vars2, vlistID1);
+  if ( lvarstd ) field_free(vars2, vlistID1);
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   dtlist_delete(dtlist);
 
@@ -334,5 +319,5 @@ void *Seasstat(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Selbox.c b/src/Selbox.c
index 8054247..f33887d 100644
--- a/src/Selbox.c
+++ b/src/Selbox.c
@@ -54,12 +54,7 @@ void correct_xvals(long nlon, long inc, double *xvals)
 static
 int gengrid(int gridID1, int lat1, int lat2, int lon11, int lon12, int lon21, int lon22)
 {
-  int gridtype, gridID2;
-  int nlon1, nlat1;
-  int nlon2, nlat2;
-  int nlon21, nlon22;
   int i;
-  int prec;
   int ilat, ilon;
   int lxvals, lyvals;
   char xname[CDI_MAX_NAME], xlongname[CDI_MAX_NAME], xunits[CDI_MAX_NAME];
@@ -71,18 +66,18 @@ int gengrid(int gridID1, int lat1, int lat2, int lon11, int lon12, int lon21, in
   double *pxvals2 = NULL, *pyvals2 = NULL;
   double *pxbounds2 = NULL, *pybounds2 = NULL;
 
-  nlon1 = gridInqXsize(gridID1);
-  nlat1 = gridInqYsize(gridID1);
+  int nlon = gridInqXsize(gridID1);
+  int nlat = gridInqYsize(gridID1);
 
-  nlon21 = lon12 - lon11 + 1;
-  nlon22 = lon22 - lon21 + 1;
-  nlon2 = nlon21 + nlon22;
-  nlat2 = lat2 - lat1 + 1;
+  int nlon21 = lon12 - lon11 + 1;
+  int nlon22 = lon22 - lon21 + 1;
+  int nlon2 = nlon21 + nlon22;
+  int nlat2 = lat2 - lat1 + 1;
 
-  gridtype = gridInqType(gridID1);
-  prec     = gridInqPrec(gridID1);
+  int gridtype = gridInqType(gridID1);
+  int prec     = gridInqPrec(gridID1);
 
-  gridID2 = gridCreate(gridtype, nlon2*nlat2);
+  int gridID2 = gridCreate(gridtype, nlon2*nlat2);
   gridDefXsize(gridID2, nlon2);
   gridDefYsize(gridID2, nlat2);
 
@@ -118,18 +113,18 @@ int gengrid(int gridID1, int lat1, int lat2, int lon11, int lon12, int lon21, in
     {
       if ( lxvals && lyvals )
 	{
-	  xvals1 = (double*) malloc(nlon1*nlat1*sizeof(double));
-	  yvals1 = (double*) malloc(nlon1*nlat1*sizeof(double));
-	  xvals2 = (double*) malloc(nlon2*nlat2*sizeof(double));
-	  yvals2 = (double*) malloc(nlon2*nlat2*sizeof(double));
+	  xvals1 = (double*) Malloc(nlon*nlat*sizeof(double));
+	  yvals1 = (double*) Malloc(nlon*nlat*sizeof(double));
+	  xvals2 = (double*) Malloc(nlon2*nlat2*sizeof(double));
+	  yvals2 = (double*) Malloc(nlon2*nlat2*sizeof(double));
 	}
     }
   else
     {
-      if ( lxvals ) xvals1 = (double*) malloc(nlon1*sizeof(double));
-      if ( lyvals ) yvals1 = (double*) malloc(nlat1*sizeof(double));
-      if ( lxvals ) xvals2 = (double*) malloc(nlon2*sizeof(double));
-      if ( lyvals ) yvals2 = (double*) malloc(nlat2*sizeof(double));
+      if ( lxvals ) xvals1 = (double*) Malloc(nlon*sizeof(double));
+      if ( lyvals ) yvals1 = (double*) Malloc(nlat*sizeof(double));
+      if ( lxvals ) xvals2 = (double*) Malloc(nlon2*sizeof(double));
+      if ( lyvals ) yvals2 = (double*) Malloc(nlat2*sizeof(double));
     }
 
   pxvals2 = xvals2;
@@ -145,13 +140,13 @@ int gengrid(int gridID1, int lat1, int lat2, int lon11, int lon12, int lon21, in
 	  {
 	    for ( ilon = lon21; ilon <= lon22; ilon++ )
 	      {
-		*pxvals2++ = xvals1[ilat*nlon1 + ilon];
-		*pyvals2++ = yvals1[ilat*nlon1 + ilon];
+		*pxvals2++ = xvals1[ilat*nlon + ilon];
+		*pyvals2++ = yvals1[ilat*nlon + ilon];
 	      }
 	    for ( ilon = lon11; ilon <= lon12; ilon++ )
 	      {
-		*pxvals2++ = xvals1[ilat*nlon1 + ilon];
-		*pyvals2++ = yvals1[ilat*nlon1 + ilon];
+		*pxvals2++ = xvals1[ilat*nlon + ilon];
+		*pyvals2++ = yvals1[ilat*nlon + ilon];
 	      }
 	  }
     }
@@ -173,26 +168,26 @@ int gengrid(int gridID1, int lat1, int lat2, int lon11, int lon12, int lon21, in
   if ( xvals2 ) gridDefXvals(gridID2, xvals2);
   if ( yvals2 ) gridDefYvals(gridID2, yvals2);
 
-  if ( xvals1 ) free(xvals1);
-  if ( yvals1 ) free(yvals1);
-  if ( xvals2 ) free(xvals2);
-  if ( yvals2 ) free(yvals2);
+  if ( xvals1 ) Free(xvals1);
+  if ( yvals1 ) Free(yvals1);
+  if ( xvals2 ) Free(xvals2);
+  if ( yvals2 ) Free(yvals2);
 
   if ( gridInqXbounds(gridID1, NULL) && gridInqYbounds(gridID1, NULL) )
     {
       if ( gridtype == GRID_CURVILINEAR )
 	{
-	  xbounds1 = (double*) malloc(4*nlon1*nlat1*sizeof(double));
-	  ybounds1 = (double*) malloc(4*nlon1*nlat1*sizeof(double));
-	  xbounds2 = (double*) malloc(4*nlon2*nlat2*sizeof(double));
-	  ybounds2 = (double*) malloc(4*nlon2*nlat2*sizeof(double));
+	  xbounds1 = (double*) Malloc(4*nlon*nlat*sizeof(double));
+	  ybounds1 = (double*) Malloc(4*nlon*nlat*sizeof(double));
+	  xbounds2 = (double*) Malloc(4*nlon2*nlat2*sizeof(double));
+	  ybounds2 = (double*) Malloc(4*nlon2*nlat2*sizeof(double));
 	}
       else
 	{
-	  xbounds1 = (double*) malloc(2*nlon1*sizeof(double));
-	  ybounds1 = (double*) malloc(2*nlat1*sizeof(double));
-	  xbounds2 = (double*) malloc(2*nlon2*sizeof(double));
-	  ybounds2 = (double*) malloc(2*nlat2*sizeof(double));
+	  xbounds1 = (double*) Malloc(2*nlon*sizeof(double));
+	  ybounds1 = (double*) Malloc(2*nlat*sizeof(double));
+	  xbounds2 = (double*) Malloc(2*nlon2*sizeof(double));
+	  ybounds2 = (double*) Malloc(2*nlat2*sizeof(double));
 	}
 
       pxbounds2 = xbounds2;
@@ -208,13 +203,13 @@ int gengrid(int gridID1, int lat1, int lat2, int lon11, int lon12, int lon21, in
 	    {
 	      for ( ilon = 4*lon21; ilon < 4*(lon22+1); ilon++ )
 		{
-		  *pxbounds2++ = xbounds1[4*ilat*nlon1 + ilon];
-		  *pybounds2++ = ybounds1[4*ilat*nlon1 + ilon];
+		  *pxbounds2++ = xbounds1[4*ilat*nlon + ilon];
+		  *pybounds2++ = ybounds1[4*ilat*nlon + ilon];
 		}
 	      for ( ilon = 4*lon11; ilon < 4*(lon12+1); ilon++ )
 		{
-		  *pxbounds2++ = xbounds1[4*ilat*nlon1 + ilon];
-		  *pybounds2++ = ybounds1[4*ilat*nlon1 + ilon];
+		  *pxbounds2++ = xbounds1[4*ilat*nlon + ilon];
+		  *pybounds2++ = ybounds1[4*ilat*nlon + ilon];
 		}
 	    }
 	}
@@ -235,10 +230,10 @@ int gengrid(int gridID1, int lat1, int lat2, int lon11, int lon12, int lon21, in
       gridDefXbounds(gridID2, xbounds2);
       gridDefYbounds(gridID2, ybounds2);
 
-      free(xbounds1);
-      free(ybounds1);
-      free(xbounds2);
-      free(ybounds2);
+      Free(xbounds1);
+      Free(ybounds1);
+      Free(xbounds2);
+      Free(ybounds2);
     }
 
   return (gridID2);
@@ -247,10 +242,7 @@ int gengrid(int gridID1, int lat1, int lat2, int lon11, int lon12, int lon21, in
 static
 int gengridcell(int gridID1, int gridsize2, int *cellidx)
 {
-  int gridtype, gridID2;
-  int gridsize1;
   int i, k, nv;
-  int prec;
   char xname[CDI_MAX_NAME], xlongname[CDI_MAX_NAME], xunits[CDI_MAX_NAME];
   char yname[CDI_MAX_NAME], ylongname[CDI_MAX_NAME], yunits[CDI_MAX_NAME];
   double *xvals1 = NULL, *yvals1 = NULL;
@@ -258,14 +250,14 @@ int gengridcell(int gridID1, int gridsize2, int *cellidx)
   double *xbounds1 = NULL, *ybounds1 = NULL;
   double *xbounds2 = NULL, *ybounds2 = NULL;
 
-  gridsize1 = gridInqSize(gridID1);
+  int gridsize1 = gridInqSize(gridID1);
 
   /* printf("gridsize1 = %d, gridsize2 = %d\n", gridsize1, gridsize2); */
 
-  gridtype = gridInqType(gridID1);
-  prec     = gridInqPrec(gridID1);
+  int gridtype = gridInqType(gridID1);
+  int prec     = gridInqPrec(gridID1);
 
-  gridID2 = gridCreate(gridtype, gridsize2);
+  int gridID2 = gridCreate(gridtype, gridsize2);
 
   gridDefPrec(gridID2, prec);
 
@@ -285,10 +277,10 @@ int gengridcell(int gridID1, int gridsize2, int *cellidx)
 
   if ( gridInqXvals(gridID1, NULL) && gridInqYvals(gridID1, NULL) )
     {
-      xvals1 = (double*) malloc(gridsize1*sizeof(double));
-      yvals1 = (double*) malloc(gridsize1*sizeof(double));
-      xvals2 = (double*) malloc(gridsize2*sizeof(double));
-      yvals2 = (double*) malloc(gridsize2*sizeof(double));
+      xvals1 = (double*) Malloc(gridsize1*sizeof(double));
+      yvals1 = (double*) Malloc(gridsize1*sizeof(double));
+      xvals2 = (double*) Malloc(gridsize2*sizeof(double));
+      yvals2 = (double*) Malloc(gridsize2*sizeof(double));
 
       gridInqXvals(gridID1, xvals1);
       gridInqYvals(gridID1, yvals1);
@@ -305,20 +297,20 @@ int gengridcell(int gridID1, int gridsize2, int *cellidx)
       gridDefXvals(gridID2, xvals2);
       gridDefYvals(gridID2, yvals2);
 
-      free(xvals1);
-      free(yvals1);
-      free(xvals2);
-      free(yvals2);
+      Free(xvals1);
+      Free(yvals1);
+      Free(xvals2);
+      Free(yvals2);
     }
 
   if ( gridInqXbounds(gridID1, NULL) && gridInqYbounds(gridID1, NULL) )
     {
       nv = gridInqNvertex(gridID1);
 
-      xbounds1 = (double*) malloc(nv*gridsize1*sizeof(double));
-      ybounds1 = (double*) malloc(nv*gridsize1*sizeof(double));
-      xbounds2 = (double*) malloc(nv*gridsize2*sizeof(double));
-      ybounds2 = (double*) malloc(nv*gridsize2*sizeof(double));
+      xbounds1 = (double*) Malloc(nv*gridsize1*sizeof(double));
+      ybounds1 = (double*) Malloc(nv*gridsize1*sizeof(double));
+      xbounds2 = (double*) Malloc(nv*gridsize2*sizeof(double));
+      ybounds2 = (double*) Malloc(nv*gridsize2*sizeof(double));
 
       gridInqXbounds(gridID1, xbounds1);
       gridInqYbounds(gridID1, ybounds1);
@@ -337,20 +329,42 @@ int gengridcell(int gridID1, int gridsize2, int *cellidx)
       gridDefXbounds(gridID2, xbounds2);
       gridDefYbounds(gridID2, ybounds2);
 
-      free(xbounds1);
-      free(ybounds1);
-      free(xbounds2);
-      free(ybounds2);
+      Free(xbounds1);
+      Free(ybounds1);
+      Free(xbounds2);
+      Free(ybounds2);
     }
 
   return (gridID2);
 }
 
 
-void genlonlatbox_reg(double xlon1, double xlon2, double xlat1, double xlat2,
-		      int nlon1, int nlat1, double *xvals1, double *yvals1,
+void genlonlatbox_reg(int gridID, double xlon1, double xlon2, double xlat1, double xlat2,
 		      int *lat1, int *lat2, int *lon11, int *lon12, int *lon21, int *lon22)
 {
+  int ilon, ilat;
+
+  int nlon = gridInqXsize(gridID);
+  int nlat = gridInqYsize(gridID);
+
+  double *xvals = (double*) Malloc(nlon*sizeof(double));
+  double *yvals = (double*) Malloc(nlat*sizeof(double));
+
+  gridInqXvals(gridID, xvals);
+  gridInqYvals(gridID, yvals);
+
+  char xunits[CDI_MAX_NAME];
+  char yunits[CDI_MAX_NAME];
+  gridInqXunits(gridID, xunits);
+  gridInqYunits(gridID, yunits);
+
+  double xfact = 1, yfact = 1;
+  if ( strncmp(xunits, "radian", 6) == 0 ) xfact = RAD2DEG;
+  if ( strncmp(yunits, "radian", 6) == 0 ) yfact = RAD2DEG;
+
+  for ( ilat = 0; ilat < nlat; ilat++ ) yvals[ilat] *= yfact;
+  for ( ilon = 0; ilon < nlon; ilon++ ) xvals[ilon] *= xfact;
+
   if ( IS_NOT_EQUAL(xlon1, xlon2) )
     {
       xlon2 -= 360 * floor ((xlon2 - xlon1) / 360);
@@ -361,212 +375,231 @@ void genlonlatbox_reg(double xlon1, double xlon2, double xlat1, double xlat2,
       xlon2 += 0.00001;
     }
 
-  xlon2 -= 360 * floor ((xlon1 - xvals1[0]) / 360);
-  xlon1 -= 360 * floor ((xlon1 - xvals1[0]) / 360);
+  xlon2 -= 360 * floor ((xlon1 - xvals[0]) / 360);
+  xlon1 -= 360 * floor ((xlon1 - xvals[0]) / 360);
 
-  // while ( nlon1 == 1 || (xvals1[nlon1-1] - xvals1[0]) >= 360 ) nlon1--;
+  // while ( nlon == 1 || (xvals[nlon-1] - xvals[0]) >= 360 ) nlon--;
 
-  for ( *lon21 = 0; *lon21 < nlon1 && xvals1[*lon21] < xlon1; (*lon21)++ );
-  for ( *lon22 = *lon21; *lon22 < nlon1 && xvals1[*lon22] < xlon2; (*lon22)++ );
+  for ( *lon21 = 0; *lon21 < nlon && xvals[*lon21] < xlon1; (*lon21)++ );
+  for ( *lon22 = *lon21; *lon22 < nlon && xvals[*lon22] < xlon2; (*lon22)++ );
 
-  if ( *lon22 >= nlon1 || xvals1[*lon22] > xlon2 ) (*lon22)--;
+  if ( *lon22 >= nlon || xvals[*lon22] > xlon2 ) (*lon22)--;
 
   xlon1 -= 360;
   xlon2 -= 360;
 
-  for ( *lon11 = 0; xvals1[*lon11] < xlon1; (*lon11)++ );
-  for ( *lon12 = *lon11; *lon12 < nlon1 && xvals1[*lon12] < xlon2; (*lon12)++ );
+  for ( *lon11 = 0; xvals[*lon11] < xlon1; (*lon11)++ );
+  for ( *lon12 = *lon11; *lon12 < nlon && xvals[*lon12] < xlon2; (*lon12)++ );
   
   // (*lon12)--;
-  if ( *lon12 >= nlon1 || xvals1[*lon12] > xlon2 ) (*lon12)--;
+  if ( *lon12 >= nlon || xvals[*lon12] > xlon2 ) (*lon12)--;
   if ( *lon12 >= 0 )
-    if ( IS_EQUAL(xvals1[*lon12], xvals1[*lon21]) ) (*lon12)--;
+    if ( IS_EQUAL(xvals[*lon12], xvals[*lon21]) ) (*lon12)--;
 
   if ( *lon12 - *lon11 + 1 + *lon22 - *lon21 + 1 <= 0 )
     cdoAbort("Longitudinal dimension is too small!");
   
-  if ( yvals1[0] > yvals1[nlat1 - 1] )
+  if ( yvals[0] > yvals[nlat - 1] )
     {
       if ( xlat1 > xlat2 )
 	{
-	  for ( *lat1 = 0; *lat1 < nlat1 && yvals1[*lat1] > xlat1; (*lat1)++ );
-	  for ( *lat2 = nlat1 - 1; *lat2 && yvals1[*lat2] < xlat2; (*lat2)-- );
+	  for ( *lat1 = 0; *lat1 < nlat && yvals[*lat1] > xlat1; (*lat1)++ );
+	  for ( *lat2 = nlat - 1; *lat2 && yvals[*lat2] < xlat2; (*lat2)-- );
 	}
       else
 	{
-	  for ( *lat1 = 0; *lat1 < nlat1 && yvals1[*lat1] > xlat2; (*lat1)++ );
-	  for ( *lat2 = nlat1 - 1; *lat2 && yvals1[*lat2] < xlat1; (*lat2)-- );
+	  for ( *lat1 = 0; *lat1 < nlat && yvals[*lat1] > xlat2; (*lat1)++ );
+	  for ( *lat2 = nlat - 1; *lat2 && yvals[*lat2] < xlat1; (*lat2)-- );
 	}
     }
   else
     {
       if ( xlat1 < xlat2 )
 	{
-	  for ( *lat1 = 0; *lat1 < nlat1 && yvals1[*lat1] < xlat1; (*lat1)++ );
-	  for ( *lat2 = nlat1 - 1; *lat2 && yvals1[*lat2] > xlat2; (*lat2)-- );
+	  for ( *lat1 = 0; *lat1 < nlat && yvals[*lat1] < xlat1; (*lat1)++ );
+	  for ( *lat2 = nlat - 1; *lat2 && yvals[*lat2] > xlat2; (*lat2)-- );
 	}
       else
 	{
-	  for ( *lat1 = 0; *lat1 < nlat1 && yvals1[*lat1] < xlat2; (*lat1)++ );
-	  for ( *lat2 = nlat1 - 1; *lat2 && yvals1[*lat2] > xlat1; (*lat2)-- );
+	  for ( *lat1 = 0; *lat1 < nlat && yvals[*lat1] < xlat2; (*lat1)++ );
+	  for ( *lat2 = nlat - 1; *lat2 && yvals[*lat2] > xlat1; (*lat2)-- );
 	}
     }
-  
+
+  Free(xvals);
+  Free(yvals);
+
   if ( *lat2 - *lat1 + 1 <= 0 )
     cdoAbort("Latitudinal dimension is too small!");
 }
 
 
-void genlonlatbox(int argc_offset, int gridID1, int *lat1, int *lat2, int *lon11, int *lon12, int *lon21, int *lon22)
+void genlonlatbox_curv(int gridID, double xlon1, double xlon2, double xlat1, double xlat2,
+                       int *lat1, int *lat2, int *lon11, int *lon12, int *lon21, int *lon22)
 {
   int ilon, ilat;
-  int nlon1, nlat1;
-  int gridtype;
-  double *xvals1, *yvals1;
-  double xlon1, xlon2, xlat1, xlat2;
-  int grid_is_circular;
-  char xunits[CDI_MAX_NAME];
-  char yunits[CDI_MAX_NAME];
-  double xfact = 1, yfact = 1;
+  
+  int nlon = gridInqXsize(gridID);
+  int nlat = gridInqYsize(gridID);
+  int gridsize = nlon*nlat;
 
-  operatorCheckArgc(argc_offset+4);
+  int grid_is_circular = gridIsCircular(gridID);
 
-  xlon1 = parameter2double(operatorArgv()[argc_offset+0]);
-  xlon2 = parameter2double(operatorArgv()[argc_offset+1]);
-  xlat1 = parameter2double(operatorArgv()[argc_offset+2]);
-  xlat2 = parameter2double(operatorArgv()[argc_offset+3]);
+  double *xvals = (double *) Malloc(gridsize*sizeof(double));
+  double *yvals = (double *) Malloc(gridsize*sizeof(double));
 
-  gridtype = gridInqType(gridID1);
+  gridInqXvals(gridID, xvals);
+  gridInqYvals(gridID, yvals);
+
+  char xunits[CDI_MAX_NAME];
+  char yunits[CDI_MAX_NAME];
+  gridInqXunits(gridID, xunits);
+  gridInqYunits(gridID, yunits);
+
+  double xfact = 1, yfact = 1;
+  if ( strncmp(xunits, "radian", 6) == 0 ) xfact = RAD2DEG;
+  if ( strncmp(yunits, "radian", 6) == 0 ) yfact = RAD2DEG;
 
-  nlon1 = gridInqXsize(gridID1);
-  nlat1 = gridInqYsize(gridID1);
+  double xval, yval, xfirst, xlast, ylast;
+  int lp2 = FALSE;
 
-  grid_is_circular = gridIsCircular(gridID1);
+  if ( xlon1 > xlon2 ) 
+    cdoAbort("The second longitude have to be greater than the first one!");
 
-  if ( gridtype == GRID_CURVILINEAR )
+  if ( xlat1 > xlat2 )
     {
-      xvals1 = (double*) malloc(nlon1*nlat1*sizeof(double));
-      yvals1 = (double*) malloc(nlon1*nlat1*sizeof(double));
+      double xtemp = xlat1;
+      xlat1 = xlat2;
+      xlat2 = xtemp;
     }
-  else
+	  
+  *lat1 = nlat-1;
+  *lat2 = 0;
+  *lon11 = 0;
+  *lon12 = -1;
+  *lon21 = nlon-1;
+  *lon22 = 0;
+
+  for ( ilat = 0; ilat < nlat; ilat++ )
     {
-      xvals1 = (double*) malloc(nlon1*sizeof(double));
-      yvals1 = (double*) malloc(nlat1*sizeof(double));
+      xlast = xfact * xvals[ilat*nlon + nlon-1];
+      ylast = yfact * yvals[ilat*nlon + nlon-1];
+      if ( ylast >= xlat1 && ylast <= xlat2 )
+        if ( grid_is_circular && xlon1 <= xlast && xlon2 > xlast && (xlon2-xlon1) < 360 )
+          {
+            *lon11 = nlon-1;
+            *lon12 = 0;
+            lp2 = TRUE;
+          }
     }
 
-  gridInqXvals(gridID1, xvals1);
-  gridInqYvals(gridID1, yvals1);
+  for ( ilat = 0; ilat < nlat; ilat++ )
+    {
+      for ( ilon = 0; ilon < nlon; ilon++ )
+        {
+          xval = xvals[ilat*nlon + ilon];
+          yval = yvals[ilat*nlon + ilon];
+
+          xval *= xfact;
+          yval *= yfact;
+
+          if ( yval >= xlat1 && yval <= xlat2 )
+            {
+              if ( lp2 )
+                {
+                  xfirst = xfact * xvals[ilat*nlon];
+                  if ( xfirst < xlon1 ) xfirst = xlon1;
+                  
+                  xlast = xfact * xvals[ilat*nlon + nlon-1];
+                  if ( xlast > xlon2 ) xlast = xlon2;
+
+                  if ( xval >= xlon1 && xval <= xlast )
+                    {
+                      if ( ilon < *lon21 ) *lon21 = ilon;
+                      if ( ilon > *lon22 ) *lon22 = ilon;
+                      if ( ilat < *lat1 ) *lat1 = ilat;
+                      if ( ilat > *lat2 ) *lat2 = ilat;
+                    }
+                  else if ( xval >= xfirst && xval <= xlon2 )
+                    {
+                      if ( ilon < *lon11 ) *lon11 = ilon;
+                      if ( ilon > *lon12 ) *lon12 = ilon;
+                      if ( ilat < *lat1 ) *lat1 = ilat;
+                      if ( ilat > *lat2 ) *lat2 = ilat;
+                    }
+                }
+              else
+                {
+                  if ( ((xval     >= xlon1 && xval     <= xlon2) ||
+                        (xval-360 >= xlon1 && xval-360 <= xlon2) ||
+                        (xval+360 >= xlon1 && xval+360 <= xlon2)) )
+                    {
+                      if ( ilon < *lon21 ) *lon21 = ilon;
+                      if ( ilon > *lon22 ) *lon22 = ilon;
+                      if ( ilat < *lat1 ) *lat1 = ilat;
+                      if ( ilat > *lat2 ) *lat2 = ilat;
+                    }
+                }
+            }
+        }
+    }
 
-  gridInqXunits(gridID1, xunits);
-  gridInqYunits(gridID1, yunits);
+  // printf("lon11, lon12, lon21, lon22, lat1, lat2 %d %d %d %d %d %d\n", *lon11, *lon12, *lon21, *lon22, *lat1, *lat2);
+  if ( *lon12 == 0 && *lon11 > 0 ) *lon11 = -1;
 
-  if ( strncmp(xunits, "radian", 6) == 0 ) xfact = RAD2DEG;
-  if ( strncmp(yunits, "radian", 6) == 0 ) yfact = RAD2DEG;
+  if ( *lat2 - *lat1 + 1 <= 0 )
+    cdoAbort("Latitudinal dimension is too small!");
 
-  if ( gridtype == GRID_CURVILINEAR )
-    {
-      double xval, yval, xfirst, xlast, ylast;
-      int lp2 = FALSE;
+  Free(xvals);
+  Free(yvals);
+}
 
-      if ( xlon1 > xlon2 ) 
-	cdoAbort("The second longitude have to be greater than the first one!");
 
-      if ( xlat1 > xlat2 )
-	{
-	  double xtemp = xlat1;
-	  xlat1 = xlat2;
-	  xlat2 = xtemp;
-	}
-	  
-      *lat1 = nlat1-1;
-      *lat2 = 0;
-      *lon11 = 0;
-      *lon12 = -1;
-      *lon21 = nlon1-1;
-      *lon22 = 0;
+void getlonlatparams(int argc_offset, double *xlon1, double *xlon2, double *xlat1, double *xlat2)
+{
+  int lset = FALSE;
+  int nargc = operatorArgc() - argc_offset;
 
-      for ( ilat = 0; ilat < nlat1; ilat++ )
-	{
-	  xlast = xfact * xvals1[ilat*nlon1 + nlon1-1];
-	  ylast = yfact * yvals1[ilat*nlon1 + nlon1-1];
-	  if ( ylast >= xlat1 && ylast <= xlat2 )
-	    if ( grid_is_circular && xlon1 <= xlast && xlon2 > xlast && (xlon2-xlon1) < 360 )
-	      {
-		*lon11 = nlon1-1;
-		*lon12 = 0;
-		lp2 = TRUE;
-	      }
-	}
+  if ( nargc == 1 )
+    {
+      const char *gridname = operatorArgv()[argc_offset+0];
+      if ( strcmp(gridname, "europe") == 0 )
+        {
+          *xlon1 = -30;
+          *xlon2 =  60;
+          *xlat1 =  30;
+          *xlat2 =  80;
+          lset = TRUE;
+        }
+    }
 
-      for ( ilat = 0; ilat < nlat1; ilat++ )
-	{
-	  for ( ilon = 0; ilon < nlon1; ilon++ )
-	    {
-	      xval = xvals1[ilat*nlon1 + ilon];
-	      yval = yvals1[ilat*nlon1 + ilon];
+  if ( !lset )
+    {
+      operatorCheckArgc(argc_offset+4);
 
-	      xval *= xfact;
-	      yval *= yfact;
+      *xlon1 = parameter2double(operatorArgv()[argc_offset+0]);
+      *xlon2 = parameter2double(operatorArgv()[argc_offset+1]);
+      *xlat1 = parameter2double(operatorArgv()[argc_offset+2]);
+      *xlat2 = parameter2double(operatorArgv()[argc_offset+3]);
+    }
+}
 
-	      if ( yval >= xlat1 && yval <= xlat2 )
-		{
-		  if ( lp2 )
-		    {
-		      xfirst = xfact * xvals1[ilat*nlon1];
-		      if ( xfirst < xlon1 ) xfirst = xlon1;
-
-		      xlast = xfact * xvals1[ilat*nlon1 + nlon1-1];
-		      if ( xlast > xlon2 ) xlast = xlon2;
-
-		      if ( xval >= xlon1 && xval <= xlast )
-			{
-			  if ( ilon < *lon21 ) *lon21 = ilon;
-			  if ( ilon > *lon22 ) *lon22 = ilon;
-			  if ( ilat < *lat1 ) *lat1 = ilat;
-			  if ( ilat > *lat2 ) *lat2 = ilat;
-			}
-		      else if ( xval >= xfirst && xval <= xlon2 )
-			{
-			  if ( ilon < *lon11 ) *lon11 = ilon;
-			  if ( ilon > *lon12 ) *lon12 = ilon;
-			  if ( ilat < *lat1 ) *lat1 = ilat;
-			  if ( ilat > *lat2 ) *lat2 = ilat;
-			}
-		    }
-		  else
-		    {
-		      if ( ((xval     >= xlon1 && xval     <= xlon2) ||
-			    (xval-360 >= xlon1 && xval-360 <= xlon2) ||
-			    (xval+360 >= xlon1 && xval+360 <= xlon2)) )
-			{
-			  if ( ilon < *lon21 ) *lon21 = ilon;
-			  if ( ilon > *lon22 ) *lon22 = ilon;
-			  if ( ilat < *lat1 ) *lat1 = ilat;
-			  if ( ilat > *lat2 ) *lat2 = ilat;
-			}
-		    }
-		}
-	    }
-	}
 
-      // printf("lon11, lon12, lon21, lon22, lat1, lat2 %d %d %d %d %d %d\n", *lon11, *lon12, *lon21, *lon22, *lat1, *lat2);
-      if ( *lon12 == 0 && *lon11 > 0 ) *lon11 = -1;
+void genlonlatbox(int argc_offset, int gridID, int *lat1, int *lat2, int *lon11, int *lon12, int *lon21, int *lon22)
+{
+  double xlon1 = 0, xlon2 = 0, xlat1 = 0, xlat2 = 0;
+  getlonlatparams(argc_offset, &xlon1, &xlon2, &xlat1, &xlat2);
+
+  int gridtype = gridInqType(gridID);
 
-      if ( *lat2 - *lat1 + 1 <= 0 )
-	cdoAbort("Latitudinal dimension is too small!");
+  if ( gridtype == GRID_CURVILINEAR )
+    {
+      genlonlatbox_curv(gridID, xlon1, xlon2, xlat1, xlat2, lat1, lat2, lon11, lon12, lon21, lon22);
     }
   else
     {
-      for ( ilat = 0; ilat < nlat1; ilat++ ) yvals1[ilat] *= yfact;
-      for ( ilon = 0; ilon < nlon1; ilon++ ) xvals1[ilon] *= xfact;
-
-      genlonlatbox_reg(xlon1, xlon2, xlat1, xlat2,
-		       nlon1, nlat1, xvals1, yvals1,
-		       lat1, lat2, lon11, lon12, lon21, lon22);
+      genlonlatbox_reg(gridID, xlon1, xlon2, xlat1, xlat2, lat1, lat2, lon11, lon12, lon21, lon22);
     }
-
-  free(xvals1);
-  free(yvals1);
 }
 
 static
@@ -585,7 +618,7 @@ static
 int gencellgrid(int gridID1, int *gridsize2, int **cellidx)
 {
   int gridtype, gridID2;
-  double *xvals1, *yvals1;
+  double *xvals, *yvals;
   double xlon1, xlon2, xlat1, xlat2, x, xval, yval;
   int i, gridsize1;
   int nvals = 0;
@@ -612,11 +645,11 @@ int gencellgrid(int gridID1, int *gridsize2, int **cellidx)
 
   if ( gridtype != GRID_UNSTRUCTURED ) cdoAbort("Internal problem, wrong grid type!");
 
-  xvals1 = (double*) malloc(gridsize1*sizeof(double));
-  yvals1 = (double*) malloc(gridsize1*sizeof(double));
+  xvals = (double*) Malloc(gridsize1*sizeof(double));
+  yvals = (double*) Malloc(gridsize1*sizeof(double));
 
-  gridInqXvals(gridID1, xvals1);
-  gridInqYvals(gridID1, yvals1);
+  gridInqXvals(gridID1, xvals);
+  gridInqYvals(gridID1, yvals);
 
   gridInqXunits(gridID1, xunits);
   gridInqYunits(gridID1, yunits);
@@ -628,8 +661,8 @@ int gencellgrid(int gridID1, int *gridsize2, int **cellidx)
   *cellidx = NULL;
   for ( i = 0; i < gridsize1; ++i )
     {
-      xval = xvals1[i]*xfact;
-      yval = yvals1[i]*yfact;
+      xval = xvals[i]*xfact;
+      yval = yvals[i]*yfact;
       if ( yval >= xlat1 && yval <= xlat2 )
 	if ( (xval >= xlon1 && xval <= xlon2) ||
 	     (xval+360 >= xlon1 && xval+360 <= xlon2) ||
@@ -639,7 +672,7 @@ int gencellgrid(int gridID1, int *gridsize2, int **cellidx)
 	    if ( nvals > maxcell )
 	      {
 		maxcell += cellinc;
-		*cellidx = (int*) realloc(*cellidx, maxcell*sizeof(int));
+		*cellidx = (int*) Realloc(*cellidx, maxcell*sizeof(int));
 	      }
 	    (*cellidx)[nvals-1] = i;
 	  }
@@ -649,8 +682,8 @@ int gencellgrid(int gridID1, int *gridsize2, int **cellidx)
 
   *gridsize2 = nvals;
 
-  free(xvals1);
-  free(yvals1);
+  Free(xvals);
+  Free(yvals);
 
   gridID2 = gengridcell(gridID1, *gridsize2, *cellidx);
 
@@ -660,7 +693,7 @@ int gencellgrid(int gridID1, int *gridsize2, int **cellidx)
 
 void genindexbox(int argc_offset, int gridID1, int *lat1, int *lat2, int *lon11, int *lon12, int *lon21, int *lon22)
 {
-  int nlon1, nlat1;
+  int nlon, nlat;
   int temp;
 
   operatorCheckArgc(argc_offset+4);
@@ -677,38 +710,38 @@ void genindexbox(int argc_offset, int gridID1, int *lat1, int *lat2, int *lon11,
       *lat2 = temp;
     }
 
-  nlon1 = gridInqXsize(gridID1);
-  nlat1 = gridInqYsize(gridID1);
+  nlon = gridInqXsize(gridID1);
+  nlat = gridInqYsize(gridID1);
 
   if ( *lat1 < 1 )
     {
       cdoWarning("First latitude index out of range, set to 1!");
       *lat1 = 1;
     }
-  if ( *lat2 > nlat1 )
+  if ( *lat2 > nlat )
     {
-      cdoWarning("First latitude index out of range, set to %d!", nlat1);
-      *lat1 = nlat1;
+      cdoWarning("First latitude index out of range, set to %d!", nlat);
+      *lat1 = nlat;
     }
   if ( *lat2 < 1 )
     {
       cdoWarning("First latitude index out of range, set to 1!");
       *lat2 = 1;
     }
-  if ( *lat2 > nlat1 )
+  if ( *lat2 > nlat )
     {
-      cdoWarning("Last latitude index out of range, set to %d!", nlat1);
-      *lat2 = nlat1;
+      cdoWarning("Last latitude index out of range, set to %d!", nlat);
+      *lat2 = nlat;
     }
   if ( *lon11 < 1 )
     {
       cdoWarning("First longitude index out of range, set to 1!");
       *lon11 = 1;
     }
-  if ( *lon12 > nlon1+1 )
+  if ( *lon12 > nlon+1 )
     {
-      cdoWarning("Last longitude index out of range, set to %d!", nlon1);
-      *lon12 = nlon1;
+      cdoWarning("Last longitude index out of range, set to %d!", nlon);
+      *lon12 = nlon;
     }
 
   (*lon11)--;
@@ -719,15 +752,15 @@ void genindexbox(int argc_offset, int gridID1, int *lat1, int *lat2, int *lon11,
   if ( *lon11 > *lon12 )
     {
       *lon21 = *lon11;
-      *lon22 = nlon1 - 1;
+      *lon22 = nlon - 1;
       *lon11 = 0;
     }
   else
     {
-      if ( *lon12 > nlon1-1 )
+      if ( *lon12 > nlon-1 )
 	{
 	  *lon21 = *lon11;
-	  *lon22 = nlon1 - 1;
+	  *lon22 = nlon - 1;
 	  *lon11 = 0;
 	  *lon12 = 0;
 	}
@@ -755,10 +788,10 @@ static
 void window(int nwpv, double *array1, int gridID1, double *array2,
 	    long lat1, long lat2, long lon11, long lon12, long lon21, long lon22)
 {
-  long nlon1;
+  long nlon;
   long ilat, ilon;
 
-  nlon1 = gridInqXsize(gridID1);
+  nlon = gridInqXsize(gridID1);
 
   if ( nwpv == 2 )
     {
@@ -766,13 +799,13 @@ void window(int nwpv, double *array1, int gridID1, double *array2,
 	{
 	  for ( ilon = lon21; ilon <= lon22; ilon++ )
 	    {
-	      *array2++ = array1[ilat*nlon1*2 + ilon*2];
-	      *array2++ = array1[ilat*nlon1*2 + ilon*2+1];
+	      *array2++ = array1[ilat*nlon*2 + ilon*2];
+	      *array2++ = array1[ilat*nlon*2 + ilon*2+1];
 	    }
 	  for ( ilon = lon11; ilon <= lon12; ilon++ )
 	    {
-	      *array2++ = array1[ilat*nlon1*2 + ilon*2];
-	      *array2++ = array1[ilat*nlon1*2 + ilon*2+1];
+	      *array2++ = array1[ilat*nlon*2 + ilon*2];
+	      *array2++ = array1[ilat*nlon*2 + ilon*2+1];
 	    }
 	}
     }
@@ -781,9 +814,9 @@ void window(int nwpv, double *array1, int gridID1, double *array2,
       for ( ilat = lat1; ilat <= lat2; ilat++ )
 	{
 	  for ( ilon = lon21; ilon <= lon22; ilon++ )
-	    *array2++ = array1[ilat*nlon1 + ilon];
+	    *array2++ = array1[ilat*nlon + ilon];
 	  for ( ilon = lon11; ilon <= lon12; ilon++ )
-	    *array2++ = array1[ilat*nlon1 + ilon];
+	    *array2++ = array1[ilat*nlon + ilon];
 	}
     }
 }
@@ -811,53 +844,44 @@ void window_cell(int nwpv, double *array1, int gridID1, double *array2, long gri
 
 void *Selbox(void *argument)
 {
-  int SELLONLATBOX, SELINDEXBOX;
-  int operatorID;
-  int streamID1, streamID2;
-  int nrecs, nvars;
-  int tsID, recID, varID, levelID;
-  int gridsize, gridsize2;
-  int vlistID1, vlistID2;
+  int nrecs;
+  int recID, varID, levelID;
   int gridID1 = -1, gridID2;
-  int index, ngrids, gridtype = -1;
+  int index, gridtype = -1;
   int nmiss;
-  int *vars = NULL;
   int i;
   int nwpv; // number of words per value; real:1  complex:2
   double missval;
-  double *array1 = NULL, *array2 = NULL;
-  int taxisID1, taxisID2;
   typedef struct {
     int gridID1, gridID2;
     int *cellidx, nvals;
     int lat1, lat2, lon11, lon12, lon21, lon22; 
   } sbox_t;
-  sbox_t *sbox = NULL;
 
   cdoInitialize(argument);
 
-  SELLONLATBOX = cdoOperatorAdd("sellonlatbox", 0, 0, "western and eastern longitude and southern and northern latitude");
-  SELINDEXBOX  = cdoOperatorAdd("selindexbox",  0, 0, "index of first and last longitude and index of first and last latitude");
+  int SELLONLATBOX = cdoOperatorAdd("sellonlatbox", 0, 0, "western and eastern longitude and southern and northern latitude");
+  int SELINDEXBOX  = cdoOperatorAdd("selindexbox",  0, 0, "index of first and last longitude and index of first and last latitude");
 
-  operatorID = cdoOperatorID();
+  int operatorID = cdoOperatorID();
 
   operatorInputArg(cdoOperatorEnter(operatorID));
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = vlistDuplicate(vlistID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  nvars = vlistNvars(vlistID1);
-  vars  = (int*) malloc(nvars*sizeof(int));
+  int nvars = vlistNvars(vlistID1);
+  int *vars  = (int *) Malloc(nvars*sizeof(int));
   for ( varID = 0; varID < nvars; varID++ ) vars[varID] = FALSE;
 
-  ngrids = vlistNgrids(vlistID1);
-  sbox = (sbox_t*) malloc(ngrids*sizeof(sbox_t));
+  int ngrids = vlistNgrids(vlistID1);
+  sbox_t *sbox = (sbox_t *) Malloc(ngrids*sizeof(sbox_t));
 
   for ( index = 0; index < ngrids; index++ )
     {
@@ -921,19 +945,19 @@ void *Selbox(void *argument)
 
   if ( varID >= nvars ) cdoWarning("No variables selected!");
 
-  streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
-  gridsize = vlistGridsizeMax(vlistID1);
+  int gridsize = vlistGridsizeMax(vlistID1);
   if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-  array1 = (double*) malloc(gridsize*sizeof(double));
+  double *array1 = (double*) Malloc(gridsize*sizeof(double));
 
-  gridsize2 = vlistGridsizeMax(vlistID2);
+  int gridsize2 = vlistGridsizeMax(vlistID2);
   if ( vlistNumber(vlistID2) != CDI_REAL ) gridsize2 *= 2;
-  array2 = (double*) malloc(gridsize2*sizeof(double));
+  double *array2 = (double*) Malloc(gridsize2*sizeof(double));
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       taxisCopyTimestep(taxisID2, taxisID1);
@@ -989,21 +1013,21 @@ void *Selbox(void *argument)
 
   vlistDestroy(vlistID2);
 
-  if ( vars   ) free(vars);
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
+  if ( vars   ) Free(vars);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
 
   if ( sbox )
     {
       if ( operatorID == SELLONLATBOX  && gridtype == GRID_UNSTRUCTURED )
 	{
 	  for ( index = 0; index < ngrids; index++ )
-	    if ( sbox[index].cellidx ) free(sbox[index].cellidx);
+	    if ( sbox[index].cellidx ) Free(sbox[index].cellidx);
 	}
-      free(sbox);
+      Free(sbox);
     }
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Select.c b/src/Select.c
index 090d3d4..1e7c0bb 100644
--- a/src/Select.c
+++ b/src/Select.c
@@ -29,7 +29,7 @@
 #include "util.h"
 //#include "list.h"
 
-double datestr_to_double(const char *datestr);
+double datestr_to_double(const char *datestr, int opt);
 
 #define  PML_INT         1
 #define  PML_FLT         2
@@ -132,7 +132,7 @@ pml_t *pmlNew(const char *name)
 {
   pml_t *pml;
 
-  pml = (pml_t*) malloc(sizeof(pml_t));
+  pml = (pml_t*) Malloc(sizeof(pml_t));
 
   pml_init(pml, name);
 
@@ -146,10 +146,10 @@ void pmlDestroy(pml_t *pml)
 
   for ( int i = 0; i < pml->size; ++i )
     {
-      if ( pml->entry[i] ) free(pml->entry[i]);
+      if ( pml->entry[i] ) Free(pml->entry[i]);
     }
 
-  free(pml);
+  Free(pml);
 }
 
 
@@ -195,10 +195,10 @@ int pmlAdd(pml_t *pml, const char *name, int type, int dis, void *ptr, size_t si
   if ( pml->size >= MAX_PML_ENTRY )
     {
       fprintf(stderr, "Too many entries in parameter list %s! (Max = %d)\n", pml->name, MAX_PML_ENTRY);
-      return (-1);
+      return -1;
     }
 
-  pml_entry = (pml_entry_t*) malloc(sizeof(pml_entry_t));
+  pml_entry = (pml_entry_t*) Malloc(sizeof(pml_entry_t));
 
   pml_entry->name = strdup(name);
   pml_entry->len  = strlen(name);
@@ -329,7 +329,7 @@ int pmlRead(pml_t *pml, int argc, char **argv)
       bufsize += len+1;
     }
 
-  parbuf = (char*) malloc(bufsize*sizeof(char));
+  parbuf = (char*) Malloc(bufsize*sizeof(char));
   memset(parbuf, 0, bufsize*sizeof(char));
 
   istart = 0;
@@ -386,7 +386,7 @@ int pmlRead(pml_t *pml, int argc, char **argv)
 
  END_LABEL:
 
-  free(parbuf);
+  Free(parbuf);
 
   return (status);
 }
@@ -464,6 +464,34 @@ void par_check_word_flag(int npar, char **parlist, int *flaglist, const char *tx
 }
 
 
+int vlist_get_psvarid(int vlistID, int zaxisID)
+{
+  int psvarid = -1;
+  char name[CDI_MAX_NAME];
+  char psname[CDI_MAX_NAME];
+  psname[0] = 0;
+  zaxisInqPsName(zaxisID, psname);
+
+  if ( psname[0] )
+    {
+      int nvars = vlistNvars(vlistID);
+      for ( int varID = 0; varID < nvars; ++varID )
+        {
+          vlistInqVarName(vlistID, varID, name);
+          if ( strcmp(name, psname) == 0 )
+            {
+              psvarid = varID;
+              break;
+            }
+        }
+      if ( cdoVerbose && psvarid == -1 )
+        cdoWarning("Surface pressure variable not found - %s", psname);
+    }
+  
+  return psvarid;
+}
+
+
 void *Select(void *argument)
 {
   int streamID2 = CDI_UNDEFID;
@@ -473,13 +501,11 @@ void *Select(void *argument)
   int varID2, levelID2;
   int recID, varID, levelID;
   int iparam;
-  int nsel;
   int vdate, vtime;
   int last_year = -999999999;
   char paramstr[32];
   char varname[CDI_MAX_NAME];
   char stdname[CDI_MAX_NAME];
-  char **argnames = NULL;
   int vlistID0 = -1, vlistID2 = -1;
   int i;
   int result = FALSE;
@@ -541,8 +567,8 @@ void *Select(void *argument)
 
   operatorInputArg(cdoOperatorEnter(operatorID));
 
-  nsel     = operatorArgc();
-  argnames = operatorArgv();
+  int nsel = operatorArgc();
+  char **argnames = operatorArgv();
 
   if ( cdoVerbose )
     for ( i = 0; i < nsel; i++ )
@@ -613,7 +639,7 @@ void *Select(void *argument)
 
 	  vlistClearFlag(vlistID1);
 	  nvars = vlistNvars(vlistID1);
-	  vars  = (int*) malloc(nvars*sizeof(int));
+	  vars  = (int*) Malloc(nvars*sizeof(int));
 
 	  if ( operatorID == DELETE )
 	    {
@@ -693,6 +719,19 @@ void *Select(void *argument)
 	      if ( vars[varID] )
 		{
 		  zaxisID = vlistInqVarZaxis(vlistID1, varID);
+                  if ( zaxisInqType(zaxisID) == ZAXIS_HYBRID )
+                    {
+                      int psvarid = vlist_get_psvarid(vlistID1, zaxisID);
+                      if ( psvarid != -1 && !vars[psvarid] ) vars[psvarid] = TRUE;
+                    }
+                }
+            }
+
+	  for ( varID = 0; varID < nvars; varID++ )
+	    {
+	      if ( vars[varID] )
+		{
+		  zaxisID = vlistInqVarZaxis(vlistID1, varID);
 		  nlevs   = zaxisInqSize(zaxisID);
 
 		  for ( levID = 0; levID < nlevs; levID++ )
@@ -829,13 +868,13 @@ void *Select(void *argument)
 	    {
 	      gridsize = vlistGridsizeMax(vlistID1);
 	      if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-	      array = (double*) malloc(gridsize*sizeof(double));
+	      array = (double*) Malloc(gridsize*sizeof(double));
 	    }
 
 	  startdate = par_startdate[0];
 	  enddate   = par_enddate[0];
-	  if ( npar_startdate ) fstartdate = datestr_to_double(startdate);
-	  if ( npar_enddate   ) fenddate   = datestr_to_double(enddate);
+	  if ( npar_startdate ) fstartdate = datestr_to_double(startdate, 0);
+	  if ( npar_enddate   ) fenddate   = datestr_to_double(enddate, 1);
 	}
       else
 	{
@@ -997,7 +1036,8 @@ void *Select(void *argument)
   PAR_CHECK_INT_FLAG(hour);
   PAR_CHECK_INT_FLAG(minute);
   PAR_CHECK_WORD_FLAG(startdate);
-  PAR_CHECK_WORD_FLAG(enddate);
+  UNUSED(str_enddate);
+  //  PAR_CHECK_WORD_FLAG(enddate);
   PAR_CHECK_WORD_FLAG(date);
 
   if ( streamID2 != CDI_UNDEFID ) streamClose(streamID2);
@@ -1007,8 +1047,8 @@ void *Select(void *argument)
 
   pmlDestroy(pml);
 
-  if ( array ) free(array);
-  if ( vars ) free(vars);
+  if ( array ) Free(array);
+  if ( vars ) Free(vars);
 
   if ( tsID2 == 0 ) cdoAbort("No timesteps selected!");
 
diff --git a/src/Seloperator.c b/src/Seloperator.c
index faef11f..7cab6cb 100644
--- a/src/Seloperator.c
+++ b/src/Seloperator.c
@@ -107,7 +107,7 @@ void *Seloperator(void *argument)
   if ( ! lcopy )
     {
       gridsize = vlistGridsizeMax(vlistID1);
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
     }
 
   tsID = 0;
@@ -148,9 +148,9 @@ void *Seloperator(void *argument)
   vlistDestroy(vlistID2);
 
   if ( ! lcopy )
-    if ( array ) free(array);
+    if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Seltime.c b/src/Seltime.c
index 4a63a78..eb7fa9b 100644
--- a/src/Seltime.c
+++ b/src/Seltime.c
@@ -40,8 +40,6 @@
 #include "list.h"
 
 
-#define  NOPERATORS  32
-
 static
 int seaslist(LIST *ilist)
 {
@@ -116,11 +114,13 @@ int seaslist(LIST *ilist)
 }
 
 
-double datestr_to_double(const char *datestr)
+double datestr_to_double(const char *datestr, int opt)
 {
   int year = 1, month = 1, day = 1, hour = 0, minute = 0, second = 0;
   double fval = 0;
 
+  if ( opt ) {hour = 23; minute = 59; second = 59;}
+
   if ( strchr(datestr, '-') == NULL )
     {
       fval = parameter2double(datestr);
@@ -135,7 +135,9 @@ double datestr_to_double(const char *datestr)
   else
     {
       sscanf(datestr, "%d-%d-%d", &year, &month, &day);
-      fval = cdiEncodeDate(year, month, day);
+      fval = cdiEncodeTime(hour, minute, second);
+      if ( fabs(fval) > 0 ) fval /= 1000000;
+      fval += cdiEncodeDate(year, month, day);
     }
 
   return fval;
@@ -164,7 +166,7 @@ int datelist(LIST *flist)
 	}
       else
 	{
-	  fval = datestr_to_double(operatorArgv()[i]);
+	  fval = datestr_to_double(operatorArgv()[i], 0);
 	  if ( strchr(operatorArgv()[i], 'T') )
 	    set2 = FALSE;
 	  else if ( nsel > 1 && i > 0 )
@@ -216,32 +218,19 @@ void *Seltime(void *argument)
 
   cdoInitialize(argument);
 
-  int SELTIMESTEP = cdoOperatorAdd("seltimestep", func_step,     1, "timesteps");
-  int SELDATE     = cdoOperatorAdd("seldate",     func_datetime, 1, "start date and end date (format YYYY-MM-DDThh:mm:ss)");
-  int SELTIME     = cdoOperatorAdd("seltime",     func_time,     1, "times (format hh:mm:ss)");
-  int SELHOUR     = cdoOperatorAdd("selhour",     func_time, 10000, "hours");
-  int SELDAY      = cdoOperatorAdd("selday",      func_date,     1, "days");
-  int SELMON      = cdoOperatorAdd("selmon",      func_date,   100, "months");
-  int SELYEAR     = cdoOperatorAdd("selyear",     func_date, 10000, "years");
-  int SELSEAS     = cdoOperatorAdd("selseas",     func_date,   100, "seasons");
-  int SELSMON     = cdoOperatorAdd("selsmon",     func_date,   100, "month[,nts1[,nts2]]");
-
-  int moddat[NOPERATORS];
-  moddat[SELTIMESTEP] =          1;
-  /*  moddat[SELDATE]     = 1000000000; */
-  moddat[SELDATE]     =          0;
-  moddat[SELTIME]     =    1000000;
-  moddat[SELHOUR]     =      10000;
-  moddat[SELDAY]      =        100;
-  moddat[SELMON]      =        100;
-  moddat[SELYEAR]     = 1000000000;
-  moddat[SELSEAS]     =        100;
-  moddat[SELSMON]     =        100;
+  int SELTIMESTEP = cdoOperatorAdd("seltimestep", func_step,     0, "timesteps");
+  int SELDATE     = cdoOperatorAdd("seldate",     func_datetime, 0, "start date and end date (format YYYY-MM-DDThh:mm:ss)");
+  int SELTIME     = cdoOperatorAdd("seltime",     func_time,     0, "times (format hh:mm:ss)");
+  int SELHOUR     = cdoOperatorAdd("selhour",     func_time,     0, "hours");
+  int SELDAY      = cdoOperatorAdd("selday",      func_date,     0, "days");
+  int SELMON      = cdoOperatorAdd("selmon",      func_date,     0, "months");
+  int SELYEAR     = cdoOperatorAdd("selyear",     func_date,     0, "years");
+  int SELSEAS     = cdoOperatorAdd("selseas",     func_date,     0, "seasons");
+  int SELSMON     = cdoOperatorAdd("selsmon",     func_date,     0, "month[,nts1[,nts2]]");
 
   int operatorID = cdoOperatorID();
 
   int operfunc = cdoOperatorF1(operatorID);
-  int intval   = cdoOperatorF2(operatorID);
 
   int lcopy = FALSE;
   if ( UNCHANGED_RECORD ) lcopy = TRUE;
@@ -299,7 +288,7 @@ void *Seltime(void *argument)
 
   if ( nsel )
     {
-      selfound = (int*) malloc(nsel*sizeof(int));
+      selfound = (int*) Malloc(nsel*sizeof(int));
       for ( i = 0; i < nsel; i++ ) selfound[i] = FALSE;
     }
 
@@ -319,7 +308,7 @@ void *Seltime(void *argument)
     {
       gridsize = vlistGridsizeMax(vlistID1);
       if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
     }
 
   int ntsteps = vlistNtsteps(vlistID1);
@@ -358,15 +347,15 @@ void *Seltime(void *argument)
     {
       if ( lnts1 )
 	{
-	  vdate_list = (int*) malloc(nts1*sizeof(int));
-	  vtime_list = (int*) malloc(nts1*sizeof(int));
+	  vdate_list = (int*) Malloc(nts1*sizeof(int));
+	  vtime_list = (int*) Malloc(nts1*sizeof(int));
 	}
       else
 	{
 	  nts1 = 1;
 	}
 
-      vars  = (field_t ***) malloc(nts1*sizeof(field_t **));
+      vars  = (field_t ***) Malloc(nts1*sizeof(field_t **));
 
       for ( int tsID = 0; tsID < nts1; tsID++ )
 	{
@@ -382,7 +371,7 @@ void *Seltime(void *argument)
 		  
 		  for ( levelID = 0; levelID < nlevel; levelID++ )
 		    {
-		      vars[tsID][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+		      vars[tsID][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 		    }
 		}
 	    }
@@ -406,11 +395,18 @@ void *Seltime(void *argument)
 	}
       else if ( operfunc == func_date )
 	{
-	  selival = (vdate/intval)%moddat[operatorID];
+          int year, month, day;
+          cdiDecodeDate(vdate, &year, &month, &day);
+          if      ( operatorID == SELYEAR ) selival = year;
+          else if ( operatorID == SELDAY  ) selival = day;
+          else                              selival = month;
 	}
       else if ( operfunc == func_time )
 	{
-	  selival = (vtime/intval)%moddat[operatorID];
+          int hour, minute, second;
+          cdiDecodeTime(vtime, &hour, &minute, &second);
+          if      ( operatorID == SELHOUR ) selival = hour;
+          else if ( operatorID == SELTIME ) selival = vtime;
 	}
       else if ( operfunc == func_datetime )
 	{
@@ -608,7 +604,7 @@ void *Seltime(void *argument)
       cdoWarning("%d timesteps missing after the last month!", nts2-its2);
 
   if ( ! lcopy )
-    if ( array ) free(array);
+    if ( array ) Free(array);
 
   for ( isel = 0; isel < nsel; isel++ )
     {
@@ -672,7 +668,7 @@ void *Seltime(void *argument)
 	}
     }
 
-  if ( selfound ) free(selfound);
+  if ( selfound ) Free(selfound);
 
   listDelete(ilist);
 
@@ -680,9 +676,9 @@ void *Seltime(void *argument)
     {
       for ( tsID = 0; tsID < nts1; tsID++ ) field_free(vars[tsID], vlistID2);
 
-      if ( vars  ) free(vars);
-      if ( vdate_list ) free(vdate_list);
-      if ( vtime_list ) free(vtime_list);
+      if ( vars  ) Free(vars);
+      if ( vdate_list ) Free(vdate_list);
+      if ( vtime_list ) Free(vtime_list);
     }
 
   vlistDestroy(vlistID2);
diff --git a/src/Selvar.c b/src/Selvar.c
index 9a4ca6f..f0fd924 100644
--- a/src/Selvar.c
+++ b/src/Selvar.c
@@ -67,6 +67,7 @@ void *Selvar(void *argument)
   int lcopy = FALSE;
   int gridsize;
   int nmiss;
+  int gridnum = 0;
   double *array = NULL;
   LIST *ilist = listNew(INT_LIST);
   LIST *flist = listNew(FLT_LIST);
@@ -78,20 +79,20 @@ void *Selvar(void *argument)
 # define TAKES_INTEGERS(id) (cdoOperatorF2(id) & 4)
 # define TAKES_FLOATS(id) (cdoOperatorF2(id) & 8)
 
-  int SELPARAM     = cdoOperatorAdd("selparam",     0, 2, "parameters");
-  int SELCODE      = cdoOperatorAdd("selcode",      0, 4, "code numbers");
-  int SELNAME      = cdoOperatorAdd("selname",      0, 2, "variable names");
-  int SELSTDNAME   = cdoOperatorAdd("selstdname",   0, 2, "standard names");
-  int SELLEVEL     = cdoOperatorAdd("sellevel",     0, 8, "levels");
-  int SELLEVIDX    = cdoOperatorAdd("sellevidx",    0, 4, "index of levels");
+  int SELPARAM     = cdoOperatorAdd("selparam",     0, 2,   "parameters");
+  int SELCODE      = cdoOperatorAdd("selcode",      0, 4,   "code numbers");
+  int SELNAME      = cdoOperatorAdd("selname",      0, 2,   "variable names");
+  int SELSTDNAME   = cdoOperatorAdd("selstdname",   0, 2,   "standard names");
+  int SELLEVEL     = cdoOperatorAdd("sellevel",     0, 8,   "levels");
+  int SELLEVIDX    = cdoOperatorAdd("sellevidx",    0, 4,   "index of levels");
   int SELGRID      = cdoOperatorAdd("selgrid",      0, 4|2, "list of grid names or numbers");
   int SELZAXIS     = cdoOperatorAdd("selzaxis",     0, 4|2, "list of zaxis types or numbers");
-  int SELZAXISNAME = cdoOperatorAdd("selzaxisname", 0, 2, "list of zaxis names");
-  int SELTABNUM    = cdoOperatorAdd("seltabnum",    0, 4, "table numbers");
+  int SELZAXISNAME = cdoOperatorAdd("selzaxisname", 0, 2,   "list of zaxis names");
+  int SELTABNUM    = cdoOperatorAdd("seltabnum",    0, 4,   "table numbers");
   int DELPARAM     = cdoOperatorAdd("delparam",     0, 2|1, "parameter");
-  int DELCODE      = cdoOperatorAdd("delcode",      0, 1, "code numbers");
+  int DELCODE      = cdoOperatorAdd("delcode",      0, 1,   "code numbers");
   int DELNAME      = cdoOperatorAdd("delname",      0, 2|1, "variable names");
-  int SELLTYPE     = cdoOperatorAdd("selltype",     0, 4, "GRIB level types"); 
+  int SELLTYPE     = cdoOperatorAdd("selltype",     0, 4,   "GRIB level types"); 
 
   if ( UNCHANGED_RECORD ) lcopy = TRUE;
 
@@ -131,7 +132,7 @@ void *Selvar(void *argument)
 
   if ( nsel )
     {
-      selfound = (int*) malloc(nsel*sizeof(int));
+      selfound = (int*) Malloc(nsel*sizeof(int));
       for ( i = 0; i < nsel; i++ ) selfound[i] = FALSE;
     }
 
@@ -142,9 +143,31 @@ void *Selvar(void *argument)
   int streamID1 = streamOpenRead(cdoStreamName(0));
 
   int vlistID1 = streamInqVlist(streamID1);
+  int nvars = vlistNvars(vlistID1);
+
+  if ( operatorID == SELGRID && !args_are_numeric && nsel == 1 && strncmp(argnames[0], "var=", 4) == 0 )
+    {
+      const char *gridvarname = argnames[0] + 4;
+
+      if ( *gridvarname == 0 ) cdoAbort("Variable name missing!", gridvarname);
+      
+      for ( varID = 0; varID < nvars; varID++ )
+        {
+          vlistInqVarName(vlistID1, varID, varname);
+          if ( strcmp(varname, gridvarname) == 0 )
+            {
+              gridID = vlistInqVarGrid(vlistID1, varID);
+              gridnum = 1 + vlistGridIndex(vlistID1, gridID);
+              args_are_numeric = TRUE;
+              intarr = &gridnum;
+              break;
+            }
+        }
+
+      if ( !gridnum ) cdoAbort("Variable %s not found!", gridvarname);
+    }
 
   vlistClearFlag(vlistID1);
-  int nvars = vlistNvars(vlistID1);
   for ( varID = 0; varID < nvars; varID++ )
     {
       vlistInqVarName(vlistID1, varID, varname);
@@ -343,7 +366,7 @@ void *Selvar(void *argument)
     {
       gridsize = vlistGridsizeMax(vlistID1);
       if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
     }
 
   int tsID = 0;
@@ -383,9 +406,9 @@ void *Selvar(void *argument)
   vlistDestroy(vlistID2);
 
   if ( ! lcopy )
-    if ( array ) free(array);
+    if ( array ) Free(array);
 
-  if ( selfound ) free(selfound);
+  if ( selfound ) Free(selfound);
 
   listDelete(ilist);
   listDelete(flist);
diff --git a/src/Set.c b/src/Set.c
index 7d9099c..bb90b0b 100644
--- a/src/Set.c
+++ b/src/Set.c
@@ -147,12 +147,12 @@ void *Set(void *argument)
 	  zaxisID1 = vlistZaxis(vlistID2, index);
 	  zaxisID2 = zaxisDuplicate(zaxisID1);
 	  nlevs = zaxisInqSize(zaxisID2);
-	  levels = (double*) malloc(nlevs*sizeof(double));
+	  levels = (double*) Malloc(nlevs*sizeof(double));
 	  zaxisInqLevels(zaxisID2, levels);
 	  levels[0] = newlevel;
 	  zaxisDefLevels(zaxisID2, levels);
 	  vlistChangeZaxis(vlistID2, zaxisID1, zaxisID2);
-	  free(levels);
+	  Free(levels);
 	}
     }
   else if ( operatorID == SETLTYPE )
@@ -177,7 +177,7 @@ void *Set(void *argument)
 
   gridsize = vlistGridsizeMax(vlistID1);
   if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
   tsID1 = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID1)) )
@@ -200,9 +200,9 @@ void *Set(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Setbox.c b/src/Setbox.c
index 631fac0..d5cb8b3 100644
--- a/src/Setbox.c
+++ b/src/Setbox.c
@@ -125,7 +125,7 @@ void *Setbox(void *argument)
   vlistDefTaxis(vlistID2, taxisID2);
 
   nvars = vlistNvars(vlistID1);
-  vars  = (int*) malloc(nvars*sizeof(int));
+  vars  = (int*) Malloc(nvars*sizeof(int));
   for ( varID = 0; varID < nvars; varID++ )
     {
       if ( gridID == vlistInqVarGrid(vlistID1, varID) )
@@ -139,7 +139,7 @@ void *Setbox(void *argument)
   streamDefVlist(streamID2, vlistID2);
 
   gridsize = gridInqSize(gridID);
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -173,10 +173,10 @@ void *Setbox(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( vars  ) free(vars);
-  if ( array ) free(array);
+  if ( vars  ) Free(vars);
+  if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Setgatt.c b/src/Setgatt.c
index b2f16b4..27573bc 100644
--- a/src/Setgatt.c
+++ b/src/Setgatt.c
@@ -121,7 +121,7 @@ void *Setgatt(void *argument)
 
   gridsize = vlistGridsizeMax(vlistID1);
   if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -144,9 +144,9 @@ void *Setgatt(void *argument)
   streamClose(streamID1);
   streamClose(streamID2);
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Setgrid.c b/src/Setgrid.c
index 62568db..ff1a1f2 100644
--- a/src/Setgrid.c
+++ b/src/Setgrid.c
@@ -53,6 +53,7 @@ void *Setgrid(void *argument)
   int ligme = 0;
   int number = 0, position = 0;
   int grid2_nvgp;
+  int lbounds = TRUE;
   int *grid2_vgpm = NULL;
   char *gridname = NULL;
   char *griduri = NULL;
@@ -85,13 +86,16 @@ void *Setgrid(void *argument)
       operatorCheckArgc(1);
       gridname = operatorArgv()[0];
 
-      if      ( strcmp(gridname, "curvilinear") == 0 )   gridtype = GRID_CURVILINEAR;
-      else if ( strcmp(gridname, "cell") == 0 )          gridtype = GRID_UNSTRUCTURED;
-      else if ( strcmp(gridname, "unstructured") == 0 )  gridtype = GRID_UNSTRUCTURED;
-      else if ( strcmp(gridname, "dereference") == 0 )   ldereference = 1;
-      else if ( strcmp(gridname, "lonlat") == 0 )        gridtype = GRID_LONLAT;
-      else if ( strcmp(gridname, "gaussian") == 0 )      gridtype = GRID_GAUSSIAN;
-      else if ( strcmp(gridname, "regular") == 0 )      {gridtype = GRID_GAUSSIAN; lregular = 1;}
+      if      ( strcmp(gridname, "curvilinear0") == 0 )  {gridtype = GRID_CURVILINEAR; lbounds = 0;}
+      else if ( strcmp(gridname, "curvilinear") == 0 )   {gridtype = GRID_CURVILINEAR; lbounds = 1;}
+      else if ( strcmp(gridname, "cell") == 0 )           gridtype = GRID_UNSTRUCTURED;
+      else if ( strcmp(gridname, "unstructured0") == 0 ) {gridtype = GRID_UNSTRUCTURED; lbounds = 0;}
+      else if ( strcmp(gridname, "unstructured") == 0 )  {gridtype = GRID_UNSTRUCTURED; lbounds = 1;}
+      else if ( strcmp(gridname, "generic") == 0 )        gridtype = GRID_GENERIC;
+      else if ( strcmp(gridname, "dereference") == 0 )    ldereference = 1;
+      else if ( strcmp(gridname, "lonlat") == 0 )         gridtype = GRID_LONLAT;
+      else if ( strcmp(gridname, "gaussian") == 0 )       gridtype = GRID_GAUSSIAN;
+      else if ( strcmp(gridname, "regular") == 0 )       {gridtype = GRID_GAUSSIAN; lregular = 1;}
       else cdoAbort("Unsupported grid name: %s", gridname);
     }
   else if ( operatorID == SETGRIDAREA )
@@ -113,7 +117,7 @@ void *Setgrid(void *argument)
 
       gridID = vlistInqVarGrid(vlistID, varID);
       areasize = gridInqSize(gridID);
-      areaweight = (double*) malloc(areasize*sizeof(double));
+      areaweight = (double*) Malloc(areasize*sizeof(double));
   
       streamReadRecord(streamID, areaweight, &nmiss);
 
@@ -157,7 +161,7 @@ void *Setgrid(void *argument)
       missval  = vlistInqVarMissval(vlistID, varID);
       gridID   = vlistInqVarGrid(vlistID, varID);
       masksize = gridInqSize(gridID);
-      gridmask = (double*) malloc(masksize*sizeof(double));
+      gridmask = (double*) Malloc(masksize*sizeof(double));
   
       streamReadRecord(streamID, gridmask, &nmiss);
 
@@ -265,7 +269,7 @@ void *Setgrid(void *argument)
 	    {
 	      if      ( gridtype == GRID_CURVILINEAR  )
 		{
-		  gridID2 = gridToCurvilinear(gridID1, 1);
+		  gridID2 = gridToCurvilinear(gridID1, lbounds);
 		}
 	      else if ( gridtype == GRID_UNSTRUCTURED )
 		{
@@ -275,7 +279,7 @@ void *Setgrid(void *argument)
 		  if ( ligme )
 		    {
 		      grid2_nvgp = gridInqSize(gridID2);
-		      grid2_vgpm = (int*) malloc(grid2_nvgp*sizeof(int));
+		      grid2_vgpm = (int*) Malloc(grid2_nvgp*sizeof(int));
 		      gridInqMaskGME(gridID2, grid2_vgpm);
 		      gridCompress(gridID2);
 		    }
@@ -331,7 +335,7 @@ void *Setgrid(void *argument)
 	  gridsize = gridInqSize(gridID1);
 	  if ( gridsize == masksize )
 	    {
-	      int *mask = (int*) malloc(masksize*sizeof(int));
+	      int *mask = (int*) Malloc(masksize*sizeof(int));
 	      for ( i = 0; i < masksize; i++ )
 		{
 		  if ( gridmask[i] < 0 || gridmask[i] > 255 )
@@ -342,7 +346,7 @@ void *Setgrid(void *argument)
 	      gridID2 = gridDuplicate(gridID1);
 	      gridDefMask(gridID2, mask);
 	      vlistChangeGridIndex(vlistID2, index, gridID2);
-	      free(mask);
+	      Free(mask);
 	    }
 	}
     }
@@ -369,7 +373,7 @@ void *Setgrid(void *argument)
     gridsize = vlistGridsizeMax(vlistID1);
 
   if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -411,12 +415,12 @@ void *Setgrid(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( gridmask ) free(gridmask);
-  if ( areaweight ) free(areaweight);
-  if ( array ) free(array);
-  if ( grid2_vgpm ) free(grid2_vgpm);
+  if ( gridmask ) Free(gridmask);
+  if ( areaweight ) Free(areaweight);
+  if ( array ) Free(array);
+  if ( grid2_vgpm ) Free(grid2_vgpm);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Sethalo.c b/src/Sethalo.c
index 3c2d06c..7b55569 100644
--- a/src/Sethalo.c
+++ b/src/Sethalo.c
@@ -75,10 +75,10 @@ int gentpngrid(int gridID1)
     {
       if ( gridtype == GRID_CURVILINEAR )
 	{
-	  xvals1 = (double*) malloc(nlon1*nlat1*sizeof(double));
-	  yvals1 = (double*) malloc(nlon1*nlat1*sizeof(double));
-	  xvals2 = (double*) malloc(nlon2*nlat2*sizeof(double));
-	  yvals2 = (double*) malloc(nlon2*nlat2*sizeof(double));
+	  xvals1 = (double*) Malloc(nlon1*nlat1*sizeof(double));
+	  yvals1 = (double*) Malloc(nlon1*nlat1*sizeof(double));
+	  xvals2 = (double*) Malloc(nlon2*nlat2*sizeof(double));
+	  yvals2 = (double*) Malloc(nlon2*nlat2*sizeof(double));
 
 	  gridInqXvals(gridID1, xvals1);
 	  gridInqYvals(gridID1, yvals1);
@@ -104,10 +104,10 @@ int gentpngrid(int gridID1)
 	  gridDefXvals(gridID2, xvals2);
 	  gridDefYvals(gridID2, yvals2);
 	  
-	  free(xvals1);
-	  free(yvals1);
-	  free(xvals2);
-	  free(yvals2);
+	  Free(xvals1);
+	  Free(yvals1);
+	  Free(xvals2);
+	  Free(yvals2);
 	}
     }
 
@@ -115,10 +115,10 @@ int gentpngrid(int gridID1)
     {
       if ( gridtype == GRID_CURVILINEAR )
 	{
-	  xbounds1 = (double*) malloc(4*nlon1*nlat1*sizeof(double));
-	  ybounds1 = (double*) malloc(4*nlon1*nlat1*sizeof(double));
-	  xbounds2 = (double*) malloc(4*nlon2*nlat2*sizeof(double));
-	  ybounds2 = (double*) malloc(4*nlon2*nlat2*sizeof(double));
+	  xbounds1 = (double*) Malloc(4*nlon1*nlat1*sizeof(double));
+	  ybounds1 = (double*) Malloc(4*nlon1*nlat1*sizeof(double));
+	  xbounds2 = (double*) Malloc(4*nlon2*nlat2*sizeof(double));
+	  ybounds2 = (double*) Malloc(4*nlon2*nlat2*sizeof(double));
 
 	  gridInqXbounds(gridID1, xbounds1);
 	  gridInqYbounds(gridID1, ybounds1);
@@ -165,10 +165,10 @@ int gentpngrid(int gridID1)
 	  gridDefXbounds(gridID2, xbounds2);
 	  gridDefYbounds(gridID2, ybounds2);
 
-	  free(xbounds1);
-	  free(ybounds1);
-	  free(xbounds2);
-	  free(ybounds2);
+	  Free(xbounds1);
+	  Free(ybounds1);
+	  Free(xbounds2);
+	  Free(ybounds2);
 	}
     }
 
@@ -238,17 +238,17 @@ int gengrid(int gridID1, int lhalo, int rhalo)
     {
       if ( gridtype == GRID_CURVILINEAR )
 	{
-	  xvals1 = (double*) malloc(nlon1*nlat1*sizeof(double));
-	  yvals1 = (double*) malloc(nlon1*nlat1*sizeof(double));
-	  xvals2 = (double*) malloc(nlon2*nlat2*sizeof(double));
-	  yvals2 = (double*) malloc(nlon2*nlat2*sizeof(double));
+	  xvals1 = (double*) Malloc(nlon1*nlat1*sizeof(double));
+	  yvals1 = (double*) Malloc(nlon1*nlat1*sizeof(double));
+	  xvals2 = (double*) Malloc(nlon2*nlat2*sizeof(double));
+	  yvals2 = (double*) Malloc(nlon2*nlat2*sizeof(double));
 	}
       else
 	{
-	  xvals1 = (double*) malloc(nlon1*sizeof(double));
-	  yvals1 = (double*) malloc(nlat1*sizeof(double));
-	  xvals2 = (double*) malloc(nlon2*sizeof(double));
-	  yvals2 = (double*) malloc(nlat2*sizeof(double));
+	  xvals1 = (double*) Malloc(nlon1*sizeof(double));
+	  yvals1 = (double*) Malloc(nlat1*sizeof(double));
+	  xvals2 = (double*) Malloc(nlon2*sizeof(double));
+	  yvals2 = (double*) Malloc(nlat2*sizeof(double));
 	}
 
       pxvals2 = xvals2;
@@ -295,27 +295,27 @@ int gengrid(int gridID1, int lhalo, int rhalo)
       gridDefXvals(gridID2, xvals2);
       gridDefYvals(gridID2, yvals2);
 
-      free(xvals1);
-      free(yvals1);
-      free(xvals2);
-      free(yvals2);
+      Free(xvals1);
+      Free(yvals1);
+      Free(xvals2);
+      Free(yvals2);
     }
 
   if ( gridInqXbounds(gridID1, NULL) && gridInqYbounds(gridID1, NULL) )
     {
       if ( gridtype == GRID_CURVILINEAR )
 	{
-	  xbounds1 = (double*) malloc(4*nlon1*nlat1*sizeof(double));
-	  ybounds1 = (double*) malloc(4*nlon1*nlat1*sizeof(double));
-	  xbounds2 = (double*) malloc(4*nlon2*nlat2*sizeof(double));
-	  ybounds2 = (double*) malloc(4*nlon2*nlat2*sizeof(double));
+	  xbounds1 = (double*) Malloc(4*nlon1*nlat1*sizeof(double));
+	  ybounds1 = (double*) Malloc(4*nlon1*nlat1*sizeof(double));
+	  xbounds2 = (double*) Malloc(4*nlon2*nlat2*sizeof(double));
+	  ybounds2 = (double*) Malloc(4*nlon2*nlat2*sizeof(double));
 	}
       else
 	{
-	  xbounds1 = (double*) malloc(2*nlon1*sizeof(double));
-	  ybounds1 = (double*) malloc(2*nlat1*sizeof(double));
-	  xbounds2 = (double*) malloc(2*nlon2*sizeof(double));
-	  ybounds2 = (double*) malloc(2*nlat2*sizeof(double));
+	  xbounds1 = (double*) Malloc(2*nlon1*sizeof(double));
+	  ybounds1 = (double*) Malloc(2*nlat1*sizeof(double));
+	  xbounds2 = (double*) Malloc(2*nlon2*sizeof(double));
+	  ybounds2 = (double*) Malloc(2*nlat2*sizeof(double));
 	}
 
       pxbounds2 = xbounds2;
@@ -361,10 +361,10 @@ int gengrid(int gridID1, int lhalo, int rhalo)
       gridDefXbounds(gridID2, xbounds2);
       gridDefYbounds(gridID2, ybounds2);
 
-      free(xbounds1);
-      free(ybounds1);
-      free(xbounds2);
-      free(ybounds2);
+      Free(xbounds1);
+      Free(ybounds1);
+      Free(xbounds2);
+      Free(ybounds2);
     }
 
   return (gridID2);
@@ -547,7 +547,7 @@ void *Sethalo(void *argument)
     }
 
   nvars = vlistNvars(vlistID1);
-  vars  = (int*) malloc(nvars*sizeof(int));
+  vars  = (int*) Malloc(nvars*sizeof(int));
   for ( varID = 0; varID < nvars; varID++ )
     {
       if ( gridID1 == vlistInqVarGrid(vlistID1, varID) )
@@ -561,10 +561,10 @@ void *Sethalo(void *argument)
   streamDefVlist(streamID2, vlistID2);
 
   gridsize = gridInqSize(gridID1);
-  array1 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
 
   gridsize2 = gridInqSize(gridID2);
-  array2 = (double*) malloc(gridsize2*sizeof(double));
+  array2 = (double*) Malloc(gridsize2*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -604,11 +604,11 @@ void *Sethalo(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( vars   ) free(vars);
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
+  if ( vars   ) Free(vars);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Setmiss.c b/src/Setmiss.c
index e135584..8328734 100644
--- a/src/Setmiss.c
+++ b/src/Setmiss.c
@@ -133,7 +133,7 @@ void *Setmiss(void *argument)
 
   int gridsize = vlistGridsizeMax(vlistID1);
 
-  double *array = (double*) malloc(gridsize*sizeof(double));
+  double *array = (double*) Malloc(gridsize*sizeof(double));
 
   int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -222,9 +222,9 @@ void *Setmiss(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Setpartab.c b/src/Setpartab.c
index a801219..fdabb6e 100644
--- a/src/Setpartab.c
+++ b/src/Setpartab.c
@@ -245,7 +245,7 @@ void convertVarUnits(var_t *vars, int varID, char *name)
 	  // if ( cdoVerbose )
 	    {
 	      char buf[64];
-	      cv_get_expression(vars[varID].ut_converter, buf, 64, name);
+	      cv_get_expression((const cv_converter*)vars[varID].ut_converter, buf, 64, name);
 	      cdoPrint("%s - convert units from [%s] to [%s] (expression: %s).", name, units_old, units, buf);
 	    }
 	}
@@ -265,11 +265,10 @@ static
 void defineVarUnits(var_t *vars, int vlistID2, int varID, char *units)
 {
   char units_old[CDI_MAX_NAME];
-  size_t len1, len2;
 
   vlistInqVarUnits(vlistID2, varID, units_old);
-  len1 = strlen(units_old);
-  len2 = strlen(units);
+  size_t len1 = strlen(units_old);
+  size_t len2 = strlen(units);
 
   if ( strcmp(units, units_old) != 0 )
     {
@@ -288,7 +287,7 @@ void defineVarUnits(var_t *vars, int vlistID2, int varID, char *units)
 static
 void read_partab(pt_mode_t ptmode, int nvars, int vlistID2, var_t *vars)
 {
-  FILE *fp;
+  FILE *fp = NULL;
   namelist_t *nml;
   int nml_code, nml_out_code, nml_table, nml_param, nml_out_param, nml_chunktype, nml_datatype, nml_type, nml_name, nml_out_name, nml_stdname;
   int nml_longname, nml_units, nml_comment, nml_ltype, nml_delete, nml_convert, nml_missval, nml_factor;
@@ -319,7 +318,7 @@ void read_partab(pt_mode_t ptmode, int nvars, int vlistID2, var_t *vars)
   for ( int fileID = 0; fileID < num_pt_files; ++fileID )
     {
       partab = operatorArgv()[fileID];
-      fp = fopen(partab, "r");
+      if ( fileExists(partab) ) fp = fopen(partab, "r");
       if ( fp == NULL ) cdoAbort("Open failed on parameter table %d file name %s!", fileID+1, partab);
 
       nml_index = 0;
@@ -433,8 +432,10 @@ void read_partab(pt_mode_t ptmode, int nvars, int vlistID2, var_t *vars)
 
 	      if ( varID < nvars )
 		{
-		  if ( nml->entry[nml_code]->occ     )  vlistDefVarCode(vlistID2, varID, code);
-		  if ( nml->entry[nml_out_code]->occ )  vlistDefVarCode(vlistID2, varID, out_code);
+                  int pnum, ptab, pdum;
+                  cdiDecodeParam(vlistInqVarParam(vlistID2, varID), &pnum, &ptab, &pdum);
+		  if ( nml->entry[nml_code]->occ     )  vlistDefVarParam(vlistID2, varID, cdiEncodeParam(code, ptab, 255));
+		  if ( nml->entry[nml_out_code]->occ )  vlistDefVarParam(vlistID2, varID, cdiEncodeParam(out_code, ptab, 255));
 		  if ( nml->entry[nml_name]->occ     )  strcpy(vars[varID].name, name);
 		  if ( nml->entry[nml_name]->occ     )  vlistDefVarName(vlistID2, varID, name);
 		  if ( nml->entry[nml_out_name]->occ )  vlistDefVarName(vlistID2, varID, out_name);
@@ -636,12 +637,13 @@ void *Setpartab(void *argument)
   if ( ptmode == CODE_NUMBER )
     {
       char *partab = operatorArgv()[0];
-      FILE *fp = fopen(partab, "r");
+      FILE *fp = NULL;
+      if ( fileExists(partab) ) fp = fopen(partab, "r");
       if ( fp != NULL )
 	{
 	  fseek(fp, 0L, SEEK_END);
 	  size_t fsize = (size_t) ftell(fp);
-	  char *parbuf = (char *) malloc(fsize+1);
+	  char *parbuf = (char *) Malloc(fsize+1);
 	  fseek(fp, 0L, SEEK_SET);
 	  fread(parbuf, fsize, 1, fp);
 	  parbuf[fsize] = 0;
@@ -650,7 +652,7 @@ void *Setpartab(void *argument)
 	  if ( atoi(parbuf) == 0 ) tableformat = 1;
 
 	  fclose(fp);
-	  free(parbuf);
+	  Free(parbuf);
 	}
 
       if ( tableformat == 0 ) tableID = defineTable(partab);
@@ -671,7 +673,7 @@ void *Setpartab(void *argument)
   /* vlistPrint(vlistID2);*/
 
   int nvars = vlistNvars(vlistID2);
-  var_t *vars = (var_t *) malloc(nvars*sizeof(var_t));
+  var_t *vars = (var_t *) Malloc(nvars*sizeof(var_t));
   memset(vars, 0, nvars*sizeof(var_t));
 
   if ( convert_data )
@@ -738,7 +740,7 @@ void *Setpartab(void *argument)
 
   long gridsize = vlistGridsizeMax(vlistID1);
   if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-  double *array = (double *) malloc(gridsize*sizeof(double));
+  double *array = (double *) Malloc(gridsize*sizeof(double));
 
   int tsID1 = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID1)) )
@@ -797,7 +799,7 @@ void *Setpartab(void *argument)
 		{
 		  if ( !DBL_IS_EQUAL(array[i], missval) )
 		    {
-		      array[i] = cv_convert_double(vars[varID].ut_converter, array[i]);
+		      array[i] = cv_convert_double((const cv_converter*)vars[varID].ut_converter, array[i]);
 		      if ( ut_get_status() != UT_SUCCESS ) nerr++;
 		    }
 		}
@@ -825,7 +827,7 @@ void *Setpartab(void *argument)
   UDUNITS_LOCK();
 
   for ( varID = 0; varID < nvars; varID++ )
-    if ( vars[varID].ut_converter ) cv_free(vars[varID].ut_converter);
+    if ( vars[varID].ut_converter ) cv_free((cv_converter*)vars[varID].ut_converter);
 
   if ( ut_read )
     { 
@@ -836,10 +838,10 @@ void *Setpartab(void *argument)
   UDUNITS_UNLOCK();
 #endif
 
-  if ( array ) free(array);
-  if ( vars  ) free(vars);
+  if ( array ) Free(array);
+  if ( vars  ) Free(vars);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Setrcaname.c b/src/Setrcaname.c
index 3e7a692..d7d4407 100644
--- a/src/Setrcaname.c
+++ b/src/Setrcaname.c
@@ -121,7 +121,7 @@ void *Setrcaname(void *argument)
   if ( ! lcopy )
     {
       gridsize = vlistGridsizeMax(vlistID1);
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
     }
 
   tsID = 0;
@@ -156,9 +156,9 @@ void *Setrcaname(void *argument)
   vlistDestroy(vlistID2);
 
   if ( ! lcopy )
-    if ( array ) free(array);
+    if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Settime.c b/src/Settime.c
index 1f3fadf..f6fe1e7 100644
--- a/src/Settime.c
+++ b/src/Settime.c
@@ -62,7 +62,7 @@ int get_tunits(const char *unit, int *incperiod, int *incunit, int *tunit)
       else if ( *incperiod == 12 ) { *incperiod = 1; *incunit = 43200; *tunit = TUNIT_12HOURS; }
     }
 
-  return (0);
+  return 0;
 }
 
 static
@@ -151,7 +151,7 @@ void *Settime(void *argument)
       datestr = operatorArgv()[0];
       timestr = operatorArgv()[1];
 
-      if ( strchr(datestr, '-') )
+      if ( strchr(datestr+1, '-') )
 	{
 	  sscanf(datestr, "%d-%d-%d", &year, &month, &day);
 	  sdate = cdiEncodeDate(year, month, day);
@@ -369,7 +369,7 @@ void *Settime(void *argument)
 
   gridsize = vlistGridsizeMax(vlistID1);
   if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
   tsID1 = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID1)) )
@@ -479,9 +479,9 @@ void *Settime(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Setzaxis.c b/src/Setzaxis.c
index 4d21bc4..2f94240 100644
--- a/src/Setzaxis.c
+++ b/src/Setzaxis.c
@@ -124,9 +124,9 @@ void *Setzaxis(void *argument)
 	{
 	  zaxisID1 = vlistZaxis(vlistID1, index);
           int nlev = zaxisInqSize(zaxisID1);
-          double *levels  = (double *) malloc(nlev*sizeof(double));
-          double *lbounds = (double *) malloc(nlev*sizeof(double));
-          double *ubounds = (double *) malloc(nlev*sizeof(double));
+          double *levels  = (double *) Malloc(nlev*sizeof(double));
+          double *lbounds = (double *) Malloc(nlev*sizeof(double));
+          double *ubounds = (double *) Malloc(nlev*sizeof(double));
 
           if ( nlev > 1 )
             {
@@ -142,9 +142,9 @@ void *Setzaxis(void *argument)
 	      vlistChangeZaxisIndex(vlistID2, index, zaxisID2);
             }
 
-          free(levels);
-          free(lbounds);
-          free(ubounds);
+          Free(levels);
+          Free(lbounds);
+          Free(ubounds);
 	}
     }
 
@@ -152,7 +152,7 @@ void *Setzaxis(void *argument)
 
   int gridsize = vlistGridsizeMax(vlistID1);
   if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-  double *array = (double*) malloc(gridsize*sizeof(double));
+  double *array = (double*) Malloc(gridsize*sizeof(double));
 
   int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -175,9 +175,9 @@ void *Setzaxis(void *argument)
   streamClose(streamID1);
   streamClose(streamID2);
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Showinfo.c b/src/Showinfo.c
index 2a3025a..e1a804c 100644
--- a/src/Showinfo.c
+++ b/src/Showinfo.c
@@ -41,56 +41,45 @@
 
 void *Showinfo(void *argument)
 {
-  int SHOWYEAR, SHOWMON, SHOWDATE, SHOWTIME, SHOWTIMESTAMP, SHOWCODE, SHOWUNIT;
-  int SHOWPARAM, SHOWNAME, SHOWSTDNAME, SHOWLEVEL, SHOWLTYPE, SHOWFORMAT;
-  int operatorID;
-  int varID, zaxisID;
+  int zaxisID;
   int vdate, vtime;
-  int nrecs, nvars, nout, ntsteps;
+  int nrecs;
   int nlevs, levelID;
   int ltype;
-  int index, nzaxis;
-  int tsID, ndate, date0 = 0;
-  int taxisID;
-  int streamID;
-  int vlistID;
+  int date0 = 0;
   int year, month, day;
-  int month0 = 0, nmonth, year0 = 0, nyear;
-  char varname[CDI_MAX_NAME];
-  char stdname[CDI_MAX_NAME];
-  char varunits[CDI_MAX_NAME];
-  char vdatetimestr[64], vdatestr[32], vtimestr[32];
+  int month0 = 0, year0 = 0;
 
   cdoInitialize(argument);
 
-  SHOWYEAR      = cdoOperatorAdd("showyear",      0, 0, NULL);
-  SHOWMON       = cdoOperatorAdd("showmon",       0, 0, NULL);
-  SHOWDATE      = cdoOperatorAdd("showdate",      0, 0, NULL);
-  SHOWTIME      = cdoOperatorAdd("showtime",      0, 0, NULL);
-  SHOWTIMESTAMP = cdoOperatorAdd("showtimestamp", 0, 0, NULL);
-  SHOWCODE      = cdoOperatorAdd("showcode",      0, 0, NULL);
-  SHOWUNIT      = cdoOperatorAdd("showunit",      0, 0, NULL);
-  SHOWPARAM     = cdoOperatorAdd("showparam",     0, 0, NULL);
-  SHOWNAME      = cdoOperatorAdd("showname",      0, 0, NULL);
-  SHOWSTDNAME   = cdoOperatorAdd("showstdname",   0, 0, NULL);
-  SHOWLEVEL     = cdoOperatorAdd("showlevel",     0, 0, NULL);
-  SHOWLTYPE     = cdoOperatorAdd("showltype",     0, 0, NULL);
-  SHOWFORMAT    = cdoOperatorAdd("showformat",    0, 0, NULL);
+  int SHOWYEAR      = cdoOperatorAdd("showyear",      0, 0, NULL);
+  int SHOWMON       = cdoOperatorAdd("showmon",       0, 0, NULL);
+  int SHOWDATE      = cdoOperatorAdd("showdate",      0, 0, NULL);
+  int SHOWTIME      = cdoOperatorAdd("showtime",      0, 0, NULL);
+  int SHOWTIMESTAMP = cdoOperatorAdd("showtimestamp", 0, 0, NULL);
+  int SHOWCODE      = cdoOperatorAdd("showcode",      0, 0, NULL);
+  int SHOWUNIT      = cdoOperatorAdd("showunit",      0, 0, NULL);
+  int SHOWPARAM     = cdoOperatorAdd("showparam",     0, 0, NULL);
+  int SHOWNAME      = cdoOperatorAdd("showname",      0, 0, NULL);
+  int SHOWSTDNAME   = cdoOperatorAdd("showstdname",   0, 0, NULL);
+  int SHOWLEVEL     = cdoOperatorAdd("showlevel",     0, 0, NULL);
+  int SHOWLTYPE     = cdoOperatorAdd("showltype",     0, 0, NULL);
+  int SHOWFORMAT    = cdoOperatorAdd("showformat",    0, 0, NULL);
 
-  operatorID = cdoOperatorID();
+  int operatorID = cdoOperatorID();
 
-  streamID = streamOpenRead(cdoStreamName(0));
+  int streamID = streamOpenRead(cdoStreamName(0));
 
-  vlistID = streamInqVlist(streamID);
+  int vlistID = streamInqVlist(streamID);
 
-  nvars   = vlistNvars(vlistID);
-  taxisID = vlistInqTaxis(vlistID);
-  ntsteps = vlistNtsteps(vlistID);
+  int nvars   = vlistNvars(vlistID);
+  int taxisID = vlistInqTaxis(vlistID);
+  int ntsteps = vlistNtsteps(vlistID);
 
   if ( operatorID == SHOWYEAR )
     {
-      nyear = 0;
-      tsID = 0;
+      // int nyear = 0;
+      int tsID = 0;
       if ( ntsteps != 0 )
 	while ( (nrecs = streamInqTimestep(streamID, tsID)) )
 	  {
@@ -100,10 +89,10 @@ void *Showinfo(void *argument)
 	 
 	    if ( tsID == 0 || year0 != year )
 	      {
-		/* if ( nyear == 10 ) { nyear = 0; fprintf(stdout, "\n"); } */
+		// if ( nyear == 10 ) { nyear = 0; fprintf(stdout, "\n"); }
 		year0 = year;
 		fprintf(stdout, " %4d", year0);
-		nyear++;
+		// nyear++;
 	      }
 
 	    tsID++;
@@ -112,8 +101,8 @@ void *Showinfo(void *argument)
     }
   else if ( operatorID == SHOWMON )
     {
-      nmonth = 0;
-      tsID = 0;
+      // int nmonth = 0;
+      int tsID = 0;
       if ( ntsteps != 0 )
 	while ( (nrecs = streamInqTimestep(streamID, tsID)) )
 	  {
@@ -123,10 +112,10 @@ void *Showinfo(void *argument)
 	 
 	    if ( tsID == 0 || month0 != month )
 	      {
-		/* if ( nmonth == 12 ) { nmonth = 0; fprintf(stdout, "\n"); } */
+		// if ( nmonth == 12 ) { nmonth = 0; fprintf(stdout, "\n"); }
 		month0 = month;
 		fprintf(stdout, " %2d", month0);
-		nmonth++;
+		// nmonth++;
 	      }
 
 	    tsID++;
@@ -135,8 +124,9 @@ void *Showinfo(void *argument)
     }
   else if ( operatorID == SHOWDATE )
     {
-      ndate = 0;
-      tsID  = 0;
+      char vdatestr[32];
+      // int ndate = 0;
+      int tsID  = 0;
       if ( ntsteps != 0 )
 	while ( (nrecs = streamInqTimestep(streamID, tsID)) )
 	  {
@@ -146,10 +136,10 @@ void *Showinfo(void *argument)
 
 	    if ( tsID == 0 || date0 != vdate )
 	      {
-		/* if ( ndate == 10 ) { ndate = 0; fprintf(stdout, "\n"); } */
+		// if ( ndate == 10 ) { ndate = 0; fprintf(stdout, "\n"); }
 		date0 = vdate;
 		fprintf(stdout, " %s", vdatestr);
-		ndate++;
+		// ndate++;
 	      }
 
 	    tsID++;
@@ -158,30 +148,32 @@ void *Showinfo(void *argument)
     }
   else if ( operatorID == SHOWTIME )
     {
-      nout = 0;
-      tsID = 0;
+      char vtimestr[32];
+      // int nout = 0;
+      int tsID = 0;
       if ( ntsteps != 0 )
 	while ( (nrecs = streamInqTimestep(streamID, tsID)) )
 	  {
-	    /* if ( nout == 4 ) { nout = 0; fprintf(stdout, "\n"); } */
+	    // if ( nout == 4 ) { nout = 0; fprintf(stdout, "\n"); }
 	    vtime = taxisInqVtime(taxisID);
 
 	    time2str(vtime, vtimestr, sizeof(vtimestr));
 	    fprintf(stdout, " %s", vtimestr);
 
 	    tsID++;
-	    nout++;
+	    // nout++;
 	  }
       fprintf(stdout, "\n");
     }
   else if ( operatorID == SHOWTIMESTAMP )
     {
-      nout = 0;
-      tsID = 0;
+      char vdatetimestr[64];
+      // int nout = 0;
+      int tsID = 0;
       if ( ntsteps != 0 )
 	while ( (nrecs = streamInqTimestep(streamID, tsID)) )
 	  {
-	    /* if ( nout == 4 ) { nout = 0; fprintf(stdout, "\n"); } */
+	    // if ( nout == 4 ) { nout = 0; fprintf(stdout, "\n"); }
 	    vdate = taxisInqVdate(taxisID);
 	    vtime = taxisInqVtime(taxisID);
 
@@ -189,32 +181,32 @@ void *Showinfo(void *argument)
 	    fprintf(stdout, " %s", vdatetimestr);
 
 	    tsID++;
-	    nout++;
+            // nout++;
 	  }
       fprintf(stdout, "\n");
     }
   else if ( operatorID == SHOWCODE )
     {
-      nout = 0;
-      for ( varID = 0; varID < nvars; varID++ )
+      // int nout = 0;
+      for ( int varID = 0; varID < nvars; varID++ )
 	{
-	  /* if ( nout == 20 ) { nout = 0; fprintf(stdout, "\n"); } */
+	  // if ( nout == 20 ) { nout = 0; fprintf(stdout, "\n"); }
 	  fprintf(stdout, " %d", vlistInqVarCode(vlistID, varID));
-	  nout++;
+	  // nout++;
 	}
       fprintf(stdout, "\n");
     }
   else if ( operatorID == SHOWUNIT )
     {
-      nout = 0;
-      for ( varID = 0; varID < nvars; varID++ )
+      char varunits[CDI_MAX_NAME];
+      //int nout = 0;
+      for ( int varID = 0; varID < nvars; varID++ )
 	{
 	  varunits[0] = 0;
 	  vlistInqVarUnits(vlistID, varID, varunits);
-	  /* if ( nout == 20 ) { nout = 0; fprintf(stdout, "\n"); } */
-          if ( strlen(varunits) )
-            fprintf(stdout, " %s", varunits);
-	  nout++;
+	  // if ( nout == 20 ) { nout = 0; fprintf(stdout, "\n"); }
+          if ( strlen(varunits) ) fprintf(stdout, " %s", varunits);
+	  // nout++;
 	}
       fprintf(stdout, "\n");
     }
@@ -223,9 +215,9 @@ void *Showinfo(void *argument)
       int param;
       char paramstr[32];
       
-      for ( varID = 0; varID < nvars; varID++ )
+      for ( int varID = 0; varID < nvars; varID++ )
 	{
-	  param   = vlistInqVarParam(vlistID, varID);
+	  param = vlistInqVarParam(vlistID, varID);
 	  cdiParamToString(param, paramstr, sizeof(paramstr));
 
 	  fprintf(stdout, " %s", paramstr);
@@ -234,7 +226,8 @@ void *Showinfo(void *argument)
     }
   else if ( operatorID == SHOWNAME )
     {
-      for ( varID = 0; varID < nvars; varID++ )
+      char varname[CDI_MAX_NAME];
+      for ( int varID = 0; varID < nvars; varID++ )
 	{
 	  vlistInqVarName(vlistID, varID, varname);
 	  fprintf(stdout, " %s", varname);
@@ -243,7 +236,8 @@ void *Showinfo(void *argument)
     }
   else if ( operatorID == SHOWSTDNAME )
     {
-      for ( varID = 0; varID < nvars; varID++ )
+      char stdname[CDI_MAX_NAME];
+      for ( int varID = 0; varID < nvars; varID++ )
 	{
 	  vlistInqVarStdname(vlistID, varID, stdname);
 	  if ( stdname[0] != 0 )
@@ -255,7 +249,7 @@ void *Showinfo(void *argument)
     }
   else if ( operatorID == SHOWLEVEL )
     {
-      for ( varID = 0; varID < nvars; varID++ )
+      for ( int varID = 0; varID < nvars; varID++ )
 	{
 	  zaxisID = vlistInqVarZaxis(vlistID, varID);
 	  nlevs = zaxisInqSize(zaxisID);
@@ -266,8 +260,8 @@ void *Showinfo(void *argument)
     }
   else if ( operatorID == SHOWLTYPE )
     {
-      nzaxis = vlistNzaxis(vlistID);
-      for ( index = 0; index < nzaxis; index++ )
+      int nzaxis = vlistNzaxis(vlistID);
+      for ( int index = 0; index < nzaxis; index++ )
 	{
 	  zaxisID = vlistZaxis(vlistID, index);
 
@@ -286,5 +280,5 @@ void *Showinfo(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Sinfo.c b/src/Sinfo.c
index e4df17c..bea40a0 100644
--- a/src/Sinfo.c
+++ b/src/Sinfo.c
@@ -29,7 +29,7 @@
 
 #include "printinfo.h"
 
-const char * tunit2str(int tunits)
+const char *tunit2str(int tunits)
 {
   if      ( tunits == TUNIT_YEAR )       return ("years");
   else if ( tunits == TUNIT_MONTH )      return ("months");
@@ -46,7 +46,7 @@ const char * tunit2str(int tunits)
 }
 
 
-const char* calendar2str(int calendar)
+const char *calendar2str(int calendar)
 {
   if      ( calendar == CALENDAR_STANDARD )  return ("standard");
   else if ( calendar == CALENDAR_PROLEPTIC ) return ("proleptic_gregorian");
@@ -77,14 +77,11 @@ void limit_string_length(char* string, size_t maxlen)
 void *Sinfo(void *argument)
 {
   enum {func_generic, func_param, func_name, func_code};
-  int operatorID;
-  int operfunc, lensemble;
-  int indf;
   int varID;
   int gridsize = 0;
   int gridID, zaxisID, code, tabnum, param;
   int vdate, vtime;
-  int nvars, ntsteps;
+  int ntsteps;
   int levelsize;
   int tsteptype, taxisID;
   char tmpname[CDI_MAX_NAME];
@@ -108,12 +105,12 @@ void *Sinfo(void *argument)
   cdoOperatorAdd("seinfon", func_name,    1, NULL);
   cdoOperatorAdd("seinfoc", func_code,    1, NULL);
 
-  operatorID = cdoOperatorID();
+  int operatorID = cdoOperatorID();
 
-  operfunc  = cdoOperatorF1(operatorID);
-  lensemble = cdoOperatorF2(operatorID);
+  int operfunc  = cdoOperatorF1(operatorID);
+  int lensemble = cdoOperatorF2(operatorID);
 
-  for ( indf = 0; indf < cdoStreamCnt(); indf++ )
+  for ( int indf = 0; indf < cdoStreamCnt(); indf++ )
     {
       streamID = streamOpenRead(cdoStreamName(indf));
 
@@ -125,9 +122,14 @@ void *Sinfo(void *argument)
       fprintf(stdout, " : ");
       printFiletype(streamID, vlistID);
 
+      int nvars = vlistNvars(vlistID);
+      int nsubtypes = vlistNsubtypes(vlistID);
+
       set_text_color(stdout, BRIGHT, BLACK);
       if ( lensemble )
 	fprintf(stdout, "%6d : Institut Source   Ttype    Einfo Levels Num    Points Num Dtype : ",  -(indf+1));
+      else if ( nsubtypes > 0 )
+	fprintf(stdout, "%6d : Institut Source   Ttype    Subtypes Levels Num    Points Num Dtype : ",  -(indf+1));
       else
 	fprintf(stdout, "%6d : Institut Source   Ttype    Levels Num    Points Num Dtype : ",  -(indf+1));
 
@@ -139,8 +141,6 @@ void *Sinfo(void *argument)
       reset_text_color(stdout);
       fprintf(stdout, "\n" );              
 
-      nvars = vlistNvars(vlistID);
-
       for ( varID = 0; varID < nvars; varID++ )
 	{
 	  param   = vlistInqVarParam(vlistID, varID);
@@ -195,6 +195,14 @@ void *Sinfo(void *argument)
 		fprintf(stdout, "--/-- ");
 	    }
 
+          if ( nsubtypes > 0 )
+            {
+              int subtypeID = vlistInqVarSubtype(vlistID, varID);
+              int subtypesize = subtypeInqSize(subtypeID);
+              fprintf(stdout, " %6d  ", subtypesize);
+              fprintf(stdout, "%3d ", vlistSubtypeIndex(vlistID, subtypeID) + 1);
+            }
+
 	  /* layer info */
 	  levelsize = zaxisInqSize(zaxisID);
 	  fprintf(stdout, "%6d ", levelsize);
@@ -260,6 +268,14 @@ void *Sinfo(void *argument)
 
       printZaxisInfo(vlistID);
 
+      if ( nsubtypes > 0 )
+        {
+          fprintf(stdout, "   Subtypes");
+          fprintf(stdout, " :\n");
+
+          printSubtypeInfo(vlistID);
+        }
+
       taxisID = vlistInqTaxis(vlistID);
       ntsteps = vlistNtsteps(vlistID);
 
@@ -325,5 +341,5 @@ void *Sinfo(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Smooth9.c b/src/Smooth9.c
index e1afea6..b482901 100644
--- a/src/Smooth9.c
+++ b/src/Smooth9.c
@@ -66,7 +66,7 @@ void *Smooth9(void *argument)
   vlistDefTaxis(vlistID2, taxisID2);
 
   nvars = vlistNvars(vlistID1);
-  varIDs  = (int*) malloc(nvars*sizeof(int)); 
+  varIDs  = (int*) Malloc(nvars*sizeof(int)); 
 
   for ( varID = 0; varID < nvars; ++varID )
     {
@@ -86,9 +86,9 @@ void *Smooth9(void *argument)
     }
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize *sizeof(double));
-  mask   = (int*) malloc(gridsize *sizeof(int));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
+  array2 = (double*) Malloc(gridsize *sizeof(double));
+  mask   = (int*) Malloc(gridsize *sizeof(int));
  
   streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
@@ -301,11 +301,11 @@ void *Smooth9(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  free(varIDs);
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
+  Free(varIDs);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Sort.c b/src/Sort.c
index a2c9b31..8941dbc 100644
--- a/src/Sort.c
+++ b/src/Sort.c
@@ -40,6 +40,7 @@ typedef struct
   int        varID;
   int        nlevs;
   int        code;
+  char       param[CDI_MAX_NAME];
   char       name[CDI_MAX_NAME];
   levinfo_t *levInfo;
 }
@@ -48,16 +49,25 @@ varinfo_t;
 static
 int cmpvarcode(const void *s1, const void *s2)
 {
-  int cmp = 0;
   const varinfo_t *x = (const varinfo_t *) s1;
   const varinfo_t *y = (const varinfo_t *) s2;
+  int cmp = 0;
   /*
   printf("%d %d  %d %d\n", x->code, y->code, x, y);
   */
   if      ( x->code < y->code ) cmp = -1;
   else if ( x->code > y->code ) cmp =  1;
 
-  return (cmp);
+  return cmp;
+}
+
+static
+int cmpvarparam(const void *s1, const void *s2)
+{
+  const varinfo_t *x = (const varinfo_t *) s1;
+  const varinfo_t *y = (const varinfo_t *) s2;
+
+  return strcmp(x->param, y->param);
 }
 
 static
@@ -66,47 +76,46 @@ int cmpvarname(const void *s1, const void *s2)
   const varinfo_t *x = (const varinfo_t *) s1;
   const varinfo_t *y = (const varinfo_t *) s2;
 
-  return (strcmp(x->name, y->name));
+  return strcmp(x->name, y->name);
 }
 
 static
 int cmpvarlevel(const void *s1, const void *s2)
 {
-  int cmp = 0;
   const levinfo_t *x = (const levinfo_t *) s1;
   const levinfo_t *y = (const levinfo_t *) s2;
+  int cmp = 0;
 
   if      ( x->level < y->level ) cmp = -1;
   else if ( x->level > y->level ) cmp =  1;
 
-  return (cmp);
+  return cmp;
 }
 
 static
 int cmpvarlevelrev(const void *s1, const void *s2)
 {
-  int cmp = 0;
   const levinfo_t *x = (const levinfo_t *) s1;
   const levinfo_t *y = (const levinfo_t *) s2;
+  int cmp = 0;
 
   if      ( x->level > y->level ) cmp = -1;
   else if ( x->level < y->level ) cmp =  1;
 
-  return (cmp);
+  return cmp;
 }
 
 static
 void setNmiss(int varID, int levelID, int nvars, varinfo_t *varInfo, int nmiss)
 {
   int vindex, lindex;
-  int nlevs;
 
   for ( vindex = 0; vindex < nvars; vindex++ )
     if ( varInfo[vindex].varID == varID ) break;
 
   if ( vindex == nvars ) cdoAbort("Internal problem; varID not found!");
 
-  nlevs = varInfo[vindex].nlevs; 
+  int nlevs = varInfo[vindex].nlevs; 
   for ( lindex = 0; lindex < nlevs; lindex++ )
     if ( varInfo[vindex].levInfo[lindex].levelID == levelID ) break;
 
@@ -116,31 +125,44 @@ void setNmiss(int varID, int levelID, int nvars, varinfo_t *varInfo, int nmiss)
 }
 
 
+void paramToStringLong(int param, char *paramstr, int maxlen)
+{
+  int dis, cat, num;
+  int len;
+
+  cdiDecodeParam(param, &num, &cat, &dis);
+
+  size_t umaxlen = maxlen >= 0 ? (unsigned)maxlen : 0U;
+  if ( dis == 255 && (cat == 255 || cat == 0 ) )
+    len = snprintf(paramstr, umaxlen, "%03d", num);
+  else  if ( dis == 255 )
+    len = snprintf(paramstr, umaxlen, "%03d.%03d", num, cat);
+  else
+    len = snprintf(paramstr, umaxlen, "%03d.%03d.%03d", num, cat, dis);
+
+  if ( len >= maxlen || len < 0)
+    fprintf(stderr, "Internal problem (%s): size of input string is too small!\n", __func__);
+}
+
+
 void *Sort(void *argument)
 {
-  int SORTCODE, SORTNAME, SORTLEVEL;
-  int operatorID;
-  int streamID1, streamID2;
-  int nrecs;
-  int tsID, recID, varID, levelID, zaxisID;
+  int recID, varID, levelID, zaxisID;
   int vindex, lindex;
-  int nvars, nlevs, offset;
-  int vlistID1, vlistID2;
+  int nrecs, nlevs, offset;
   int gridsize;
   int nmiss;
   double *single;
-  double **vardata = NULL;
-  varinfo_t *varInfo;
-  int taxisID1, taxisID2;
   int (*cmpvarlev)(const void *, const void *) = cmpvarlevel;
 
   cdoInitialize(argument);
 
-  SORTCODE  = cdoOperatorAdd("sortcode",  0, 0, NULL);
-  SORTNAME  = cdoOperatorAdd("sortname",  0, 0, NULL);
-  SORTLEVEL = cdoOperatorAdd("sortlevel", 0, 0, NULL);
+  int SORTCODE  = cdoOperatorAdd("sortcode",  0, 0, NULL);
+  int SORTPARAM = cdoOperatorAdd("sortparam", 0, 0, NULL);
+  int SORTNAME  = cdoOperatorAdd("sortname",  0, 0, NULL);
+  int SORTLEVEL = cdoOperatorAdd("sortlevel", 0, 0, NULL);
 
-  operatorID = cdoOperatorID();
+  int operatorID = cdoOperatorID();
 
   if ( operatorArgc() > 1 ) cdoAbort("Too many arguments!");
 
@@ -150,13 +172,13 @@ void *Sort(void *argument)
       if ( iarg < 0 ) cmpvarlev = cmpvarlevelrev;
     }
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = vlistDuplicate(vlistID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID2, taxisID2);
   /*
   if ( operatorID == SORTCODE )
@@ -167,30 +189,30 @@ void *Sort(void *argument)
       ;
   */
 
-  streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
-  nvars   = vlistNvars(vlistID1);
+  int nvars   = vlistNvars(vlistID1);
 
-  varInfo = (varinfo_t*) malloc(nvars*sizeof(varinfo_t));
+  varinfo_t *varInfo = (varinfo_t*) Malloc(nvars*sizeof(varinfo_t));
   for ( varID = 0; varID < nvars; ++varID )
     {
       nlevs = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
       varInfo[varID].nlevs = nlevs;
-      varInfo[varID].levInfo = (levinfo_t*) malloc(nlevs*sizeof(levinfo_t));
+      varInfo[varID].levInfo = (levinfo_t*) Malloc(nlevs*sizeof(levinfo_t));
     }
 
-  vardata = (double**) malloc(nvars*sizeof(double*));
+  double **vardata = (double**) Malloc(nvars*sizeof(double*));
 
   for ( varID = 0; varID < nvars; varID++ )
     {
       gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
       nlevs    = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
-      vardata[varID] = (double*) malloc(gridsize*nlevs*sizeof(double));
+      vardata[varID] = (double*) Malloc(gridsize*nlevs*sizeof(double));
     }
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       taxisCopyTimestep(taxisID2, taxisID1);
@@ -205,6 +227,8 @@ void *Sort(void *argument)
 	    {
 	      varInfo[varID].varID = varID;
 	      varInfo[varID].code  = vlistInqVarCode(vlistID1, varID);
+	      int iparam  = vlistInqVarParam(vlistID1, varID);
+	      paramToStringLong(iparam, varInfo[varID].param, sizeof(varInfo[varID].param));
 	      vlistInqVarName(vlistID1, varID, varInfo[varID].name);
 	      zaxisID = vlistInqVarZaxis(vlistID1, varID);
 	      varInfo[varID].levInfo[levelID].levelID = levelID;
@@ -234,6 +258,8 @@ void *Sort(void *argument)
 
 	  if      ( operatorID == SORTCODE )
 	    qsort(varInfo, nvars, sizeof(varinfo_t), cmpvarcode);
+	  else if ( operatorID == SORTPARAM )
+	    qsort(varInfo, nvars, sizeof(varinfo_t), cmpvarparam);
 	  else if ( operatorID == SORTNAME )
 	    qsort(varInfo, nvars, sizeof(varinfo_t), cmpvarname);
 	  else if ( operatorID == SORTLEVEL )
@@ -282,13 +308,13 @@ void *Sort(void *argument)
   streamClose(streamID1);
   streamClose(streamID2);
 
-  for ( varID = 0; varID < nvars; varID++ ) free(vardata[varID]);
-  free(vardata);
+  for ( varID = 0; varID < nvars; varID++ ) Free(vardata[varID]);
+  Free(vardata);
 
-  for ( vindex = 0; vindex < nvars; vindex++ ) free(varInfo[vindex].levInfo);
-  free(varInfo);
+  for ( vindex = 0; vindex < nvars; vindex++ ) Free(varInfo[vindex].levInfo);
+  Free(varInfo);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Sorttimestamp.c b/src/Sorttimestamp.c
index 607eca6..e9b4449 100644
--- a/src/Sorttimestamp.c
+++ b/src/Sorttimestamp.c
@@ -41,8 +41,8 @@ static
 int cmpdatetime(const void *s1, const void *s2)
 {
   int cmp = 0;
-  const timeinfo_t *x = s1;
-  const timeinfo_t *y = s2;
+  const timeinfo_t *x = (timeinfo_t *)s1;
+  const timeinfo_t *y = (timeinfo_t *)s2;
   /*
   printf("%g %g  %d %d\n", x->datetime, y->datetime, x, y);
   */
@@ -105,9 +105,9 @@ void *Sorttimestamp(void *argument)
 	  if ( xtsID >= nalloc )
 	    {
 	      nalloc += NALLOC_INC;
-	      vdate = (int*) realloc(vdate, nalloc*sizeof(int));
-	      vtime = (int*) realloc(vtime, nalloc*sizeof(int));
-	      vars  = (field_t ***) realloc(vars, nalloc*sizeof(field_t **));
+	      vdate = (int*) Realloc(vdate, nalloc*sizeof(int));
+	      vtime = (int*) Realloc(vtime, nalloc*sizeof(int));
+	      vars  = (field_t ***) Realloc(vars, nalloc*sizeof(field_t **));
 	    }
 
 	  vdate[xtsID] = taxisInqVdate(taxisID1);
@@ -120,7 +120,7 @@ void *Sorttimestamp(void *argument)
 	      streamInqRecord(streamID1, &varID, &levelID);
 	      gridID   = vlistInqVarGrid(vlistID1, varID);
 	      gridsize = gridInqSize(gridID);
-	      vars[xtsID][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+	      vars[xtsID][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 	      streamReadRecord(streamID1, vars[xtsID][varID][levelID].ptr, &nmiss);
 	      vars[xtsID][varID][levelID].nmiss = nmiss;
 	    }
@@ -134,7 +134,7 @@ void *Sorttimestamp(void *argument)
 
   nts = xtsID;
 
-  timeinfo= (timeinfo_t*) malloc(nts*sizeof(timeinfo_t));
+  timeinfo= (timeinfo_t*) Malloc(nts*sizeof(timeinfo_t));
 
   for ( tsID = 0; tsID < nts; tsID++ )
     {
@@ -202,13 +202,13 @@ void *Sorttimestamp(void *argument)
       field_free(vars[xtsID], vlistID2);      
     }
 
-  if ( vars  ) free(vars);
-  if ( vdate ) free(vdate);
-  if ( vtime ) free(vtime);
+  if ( vars  ) Free(vars);
+  if ( vdate ) Free(vdate);
+  if ( vtime ) Free(vtime);
 
   streamClose(streamID2);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Specinfo.c b/src/Specinfo.c
index 2c69924..71c8e11 100644
--- a/src/Specinfo.c
+++ b/src/Specinfo.c
@@ -486,5 +486,5 @@ void *Specinfo(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Spectral.c b/src/Spectral.c
index b83cfaf..b4680d8 100644
--- a/src/Spectral.c
+++ b/src/Spectral.c
@@ -210,7 +210,7 @@ void *Spectral(void *argument)
 	  maxntr = 1+gridInqTrunc(gridID1);
 	  ncut = args2intlist(operatorArgc(), operatorArgv(), ilist);
 	  wnums = (int *) listArrayPtr(ilist);
-	  waves = (int*) malloc(maxntr*sizeof(int));
+	  waves = (int*) Malloc(maxntr*sizeof(int));
 	  for ( i = 0; i < maxntr; i++ ) waves[i] = 1;
 	  for ( i = 0; i < ncut; i++ )
 	    {
@@ -227,7 +227,7 @@ void *Spectral(void *argument)
     }
 
   nvars = vlistNvars(vlistID2);
-  vars  = (int*) malloc(nvars*sizeof(int));
+  vars  = (int*) Malloc(nvars*sizeof(int));
   for ( varID = 0; varID < nvars; varID++ )
     {
       if ( gridID1 == vlistInqVarGrid(vlistID1, varID) )
@@ -243,12 +243,12 @@ void *Spectral(void *argument)
   streamDefVlist(streamID2, vlistID2);
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array1 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
 
   if ( gridID2 != -1 )
     {
       gridsize = gridInqSize(gridID2);
-      array2 = (double*) malloc(gridsize*sizeof(double));
+      array2 = (double*) Malloc(gridsize*sizeof(double));
     }
 
   tsID = 0;
@@ -300,10 +300,10 @@ void *Spectral(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
-  if ( vars )   free(vars);
-  if ( waves )  free(waves);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
+  if ( vars )   Free(vars);
+  if ( waves )  Free(waves);
 
   listDelete(ilist);
 
@@ -311,5 +311,5 @@ void *Spectral(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Spectrum.c b/src/Spectrum.c
index 4cdb7cc..8843729 100644
--- a/src/Spectrum.c
+++ b/src/Spectrum.c
@@ -70,8 +70,8 @@ void spectrum(int nrec, double *data, double *spectrum, double *real, double *im
 
   if ( bit != 1 )
     {
-      work_r = (double*) malloc(seg_l*sizeof(double));
-      work_i = (double*) malloc(seg_l*sizeof(double));
+      work_r = (double*) Malloc(seg_l*sizeof(double));
+      work_i = (double*) Malloc(seg_l*sizeof(double));
     }
 	
   for (seg_i = 0; seg_i < seg_n; seg_i += 2)
@@ -149,8 +149,8 @@ void spectrum(int nrec, double *data, double *spectrum, double *real, double *im
 
   if ( bit != 1 )
     {
-      free(work_r);
-      free(work_i);
+      Free(work_r);
+      Free(work_i);
     }
 	
   for (k = 0; k <= seg_l / 2; k++)
@@ -207,9 +207,9 @@ void *Spectrum(void *argument)
       if ( tsID >= nalloc )
 	{
 	  nalloc += NALLOC_INC;
-	  vdate = (int*) realloc(vdate, nalloc*sizeof(int));
-	  vtime = (int*) realloc(vtime, nalloc*sizeof(int));
-	  vars  = (field_t ***) realloc(vars, nalloc*sizeof(field_t **));
+	  vdate = (int*) Realloc(vdate, nalloc*sizeof(int));
+	  vtime = (int*) Realloc(vtime, nalloc*sizeof(int));
+	  vars  = (field_t ***) Realloc(vars, nalloc*sizeof(field_t **));
 	}
 
       vdate[tsID] = taxisInqVdate(taxisID1);
@@ -222,7 +222,7 @@ void *Spectrum(void *argument)
 	  streamInqRecord(streamID1, &varID, &levelID);
 	  gridID   = vlistInqVarGrid(vlistID1, varID);
 	  gridsize = gridInqSize(gridID);
-	  vars[tsID][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+	  vars[tsID][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 	  streamReadRecord(streamID1, vars[tsID][varID][levelID].ptr, &nmiss);
 	  vars[tsID][varID][levelID].nmiss = nmiss;
 
@@ -264,15 +264,15 @@ void *Spectrum(void *argument)
 
   nfreq = seg_l/2 + 1;
 
-  vars2 = (field_t ***) malloc(nfreq*sizeof(field_t **));
+  vars2 = (field_t ***) Malloc(nfreq*sizeof(field_t **));
   for ( freq = 0; freq < nfreq; freq++ )
     vars2[freq] = field_malloc(vlistID1, FIELD_PTR);
 
-  array1  = (double*) malloc(nts   * sizeof(double));
-  array2  = (double*) malloc(nfreq * sizeof(double));
-  real    = (double*) malloc(seg_l * sizeof(double));
-  imag    = (double*) malloc(seg_l * sizeof(double));
-  window  = (double*) malloc(seg_l * sizeof(double));
+  array1  = (double*) Malloc(nts   * sizeof(double));
+  array2  = (double*) Malloc(nfreq * sizeof(double));
+  real    = (double*) Malloc(seg_l * sizeof(double));
+  imag    = (double*) Malloc(seg_l * sizeof(double));
+  window  = (double*) Malloc(seg_l * sizeof(double));
   	   
   switch (which_window)
     {
@@ -328,8 +328,8 @@ void *Spectrum(void *argument)
 	}
     }
 
-  if ( array1 ) free(array1);
-  if ( array2 ) free(array2);
+  if ( array1 ) Free(array1);
+  if ( array2 ) Free(array2);
 
   for ( tsID = 0; tsID < nts; tsID++ ) field_free(vars[tsID], vlistID1);
 
@@ -356,15 +356,15 @@ void *Spectrum(void *argument)
       field_free(vars2[tsID], vlistID1);
     }
 
-  if ( vars  ) free(vars);
-  if ( vars2 ) free(vars2);
-  if ( vdate ) free(vdate);
-  if ( vtime ) free(vtime);
+  if ( vars  ) Free(vars);
+  if ( vars2 ) Free(vars2);
+  if ( vdate ) Free(vdate);
+  if ( vtime ) Free(vtime);
 
   streamClose(streamID2);
   streamClose(streamID1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Split.c b/src/Split.c
index ea1b802..44f38ed 100644
--- a/src/Split.c
+++ b/src/Split.c
@@ -33,19 +33,6 @@
 #include "cdo_int.h"
 #include "pstream.h"
 
-void create_uuid(unsigned char uuid[CDI_UUID_SIZE]);
-void uuid2str(const unsigned char *uuid, char *uuidstr);
-
-
-#define UUIDSTR_SIZE (CDI_UUID_SIZE*2 + 4)
-
-static
-void get_uuid(char uuidstr[UUIDSTR_SIZE])
-{
-  unsigned char uuid[CDI_UUID_SIZE];
-  create_uuid(uuid);
-  uuid2str(uuid, uuidstr);
-}
 
 static
 void gen_filename(char *filename, int swap_obase, const char *obase, const char *suffix)
@@ -109,8 +96,6 @@ void *Split(void *argument)
   int vlistID1 = streamInqVlist(streamID1);
 
   int nvars  = vlistNvars(vlistID1);
-  int nrecs  = vlistNrecs(vlistID1);
-  int nzaxis = vlistNzaxis(vlistID1);
 
   if ( swap_obase == 0 )
     {
@@ -124,7 +109,6 @@ void *Split(void *argument)
   
   if ( operatorID == SPLITCODE )
     {
-      int *codes = NULL;
       nsplit = 0;
       for ( varID = 0; varID < nvars; varID++ )
 	{
@@ -139,9 +123,9 @@ void *Split(void *argument)
 	    }
 	}
 
-      codes     = (int*) malloc(nsplit*sizeof(int));
-      vlistIDs  = (int*) malloc(nsplit*sizeof(int));
-      streamIDs = (int*) malloc(nsplit*sizeof(int));
+      vlistIDs  = (int*) Malloc(nsplit*sizeof(int));
+      streamIDs = (int*) Malloc(nsplit*sizeof(int));
+      int codes[nsplit];
       memcpy(codes, itmp, nsplit*sizeof(int));
 
       for ( index = 0; index < nsplit; index++ )
@@ -186,12 +170,10 @@ void *Split(void *argument)
 	  streamIDs[index] = streamOpenWrite(fileargument, cdoFiletype());
 	  file_argument_free(fileargument);
 	}
-      if ( codes ) free(codes);
     }
   else if ( operatorID == SPLITPARAM )
     {
       char paramstr[32];
-      int *params = NULL;
       nsplit = 0;
       for ( varID = 0; varID < nvars; varID++ )
 	{
@@ -206,9 +188,9 @@ void *Split(void *argument)
 	    }
 	}
 
-      params    = (int*) malloc(nsplit*sizeof(int));
-      vlistIDs  = (int*) malloc(nsplit*sizeof(int));
-      streamIDs = (int*) malloc(nsplit*sizeof(int));
+      vlistIDs  = (int*) Malloc(nsplit*sizeof(int));
+      streamIDs = (int*) Malloc(nsplit*sizeof(int));
+      int params[nsplit];
       memcpy(params, itmp, nsplit*sizeof(int));
 
       for ( index = 0; index < nsplit; index++ )
@@ -243,11 +225,9 @@ void *Split(void *argument)
 	  streamIDs[index] = streamOpenWrite(fileargument, cdoFiletype());
 	  file_argument_free(fileargument);
 	}
-      if ( params ) free(params);
     }
   else if ( operatorID == SPLITTABNUM )
     {
-      int *tabnums = NULL;
       nsplit = 0;
       for ( varID = 0; varID < nvars; varID++ )
 	{
@@ -262,9 +242,9 @@ void *Split(void *argument)
 	    }
 	}
 
-      tabnums   = (int*) malloc(nsplit*sizeof(int));
-      vlistIDs  = (int*) malloc(nsplit*sizeof(int));
-      streamIDs = (int*) malloc(nsplit*sizeof(int));
+      vlistIDs  = (int*) Malloc(nsplit*sizeof(int));
+      streamIDs = (int*) Malloc(nsplit*sizeof(int));
+      int tabnums[nsplit];
       memcpy(tabnums, itmp, nsplit*sizeof(int));
 
       for ( index = 0; index < nsplit; index++ )
@@ -295,15 +275,14 @@ void *Split(void *argument)
 	  streamIDs[index] = streamOpenWrite(fileargument, cdoFiletype());
 	  file_argument_free(fileargument);
 	}
-      if ( tabnums ) free(tabnums);
     }
   else if ( operatorID == SPLITNAME )
     {
       char varname[CDI_MAX_NAME];
       nsplit = nvars;
 
-      vlistIDs  = (int*) malloc(nsplit*sizeof(int));
-      streamIDs = (int*) malloc(nsplit*sizeof(int));
+      vlistIDs  = (int*) Malloc(nsplit*sizeof(int));
+      streamIDs = (int*) Malloc(nsplit*sizeof(int));
 
       for ( index = 0; index < nsplit; index++ )
 	{
@@ -333,8 +312,8 @@ void *Split(void *argument)
     }
   else if ( operatorID == SPLITLEVEL )
     {
-      double level, *levels = NULL;
-      nzaxis = vlistNzaxis(vlistID1);
+      double level;
+      int nzaxis = vlistNzaxis(vlistID1);
       nsplit = 0;
       for ( index = 0; index < nzaxis; index++ )
 	{
@@ -350,9 +329,9 @@ void *Split(void *argument)
 	    }
 	}
 
-      levels    = (double*) malloc(nsplit*sizeof(double));
-      vlistIDs  = (int*) malloc(nsplit*sizeof(int));
-      streamIDs = (int*) malloc(nsplit*sizeof(int));
+      vlistIDs  = (int*) Malloc(nsplit*sizeof(int));
+      streamIDs = (int*) Malloc(nsplit*sizeof(int));
+      double levels[nsplit];
       memcpy(levels, ftmp, nsplit*sizeof(double));
 
       for ( index = 0; index < nsplit; index++ )
@@ -383,18 +362,16 @@ void *Split(void *argument)
 	  streamIDs[index] = streamOpenWrite(fileargument, cdoFiletype());
 	  file_argument_free(fileargument);
 	}
-      if ( levels ) free(levels);
     }
   else if ( operatorID == SPLITGRID )
     {
-      int gridID, *gridIDs = NULL;
+      int gridID;
 
       nsplit = vlistNgrids(vlistID1);
 
-      gridIDs   = (int*) malloc(nsplit*sizeof(int));
-      vlistIDs  = (int*) malloc(nsplit*sizeof(int));
-      streamIDs = (int*) malloc(nsplit*sizeof(int));
-
+      vlistIDs  = (int*) Malloc(nsplit*sizeof(int));
+      streamIDs = (int*) Malloc(nsplit*sizeof(int));
+      int gridIDs[nsplit];
       for ( index = 0; index < nsplit; index++ )
 	gridIDs[index] = vlistGrid(vlistID1, index);
 
@@ -426,18 +403,16 @@ void *Split(void *argument)
 	  streamIDs[index] = streamOpenWrite(fileargument, cdoFiletype());
 	  file_argument_free(fileargument);
 	}
-      if ( gridIDs ) free(gridIDs);
     }
   else if ( operatorID == SPLITZAXIS )
     {
-      int zaxisID, *zaxisIDs = NULL;
+      int zaxisID;
 
       nsplit = vlistNzaxis(vlistID1);
 
-      zaxisIDs  = (int*) malloc(nsplit*sizeof(int));
-      vlistIDs  = (int*) malloc(nsplit*sizeof(int));
-      streamIDs = (int*) malloc(nsplit*sizeof(int));
-
+      vlistIDs  = (int*) Malloc(nsplit*sizeof(int));
+      streamIDs = (int*) Malloc(nsplit*sizeof(int));
+      int zaxisIDs[nsplit];
       for ( index = 0; index < nsplit; index++ )
 	zaxisIDs[index] = vlistZaxis(vlistID1, index);
 
@@ -468,7 +443,6 @@ void *Split(void *argument)
 	  streamIDs[index] = streamOpenWrite(fileargument, cdoFiletype());
 	  file_argument_free(fileargument);
 	}
-      if ( zaxisIDs ) free(zaxisIDs);
     }
   else
     {
@@ -477,13 +451,7 @@ void *Split(void *argument)
 
   for ( index = 0; index < nsplit; index++ )
     {
-      if ( uuid_attribute )
-        {
-          char uuidstr[UUIDSTR_SIZE];
-          get_uuid(uuidstr);
-          vlistDefAttTxt(vlistIDs[index], CDI_GLOBAL, uuid_attribute, 
-                         UUIDSTR_SIZE, uuidstr);
-        }
+      if ( uuid_attribute ) cdo_def_tracking_id(vlistIDs[index], uuid_attribute);
 
       streamDefVlist(streamIDs[index], vlistIDs[index]);
     }
@@ -493,9 +461,10 @@ void *Split(void *argument)
     {
       gridsize = vlistGridsizeMax(vlistID1);
       if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-      array = (double *) malloc(gridsize*sizeof(double));
+      array = (double *) Malloc(gridsize*sizeof(double));
     }
 
+  int nrecs;
   int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
@@ -537,12 +506,12 @@ void *Split(void *argument)
     }
  
   if ( ! lcopy )
-    if ( array ) free(array);
+    if ( array ) Free(array);
 
-  if ( vlistIDs  ) free(vlistIDs);
-  if ( streamIDs ) free(streamIDs);
+  if ( vlistIDs  ) Free(vlistIDs);
+  if ( streamIDs ) Free(streamIDs);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Splitrec.c b/src/Splitrec.c
index 38b476a..c0d2605 100644
--- a/src/Splitrec.c
+++ b/src/Splitrec.c
@@ -68,7 +68,7 @@ void *Splitrec(void *argument)
     {
       gridsize = vlistGridsizeMax(vlistID1);
       if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
     }
 
   index = 0;
@@ -123,9 +123,9 @@ void *Splitrec(void *argument)
   streamClose(streamID1);
 
   if ( ! lcopy )
-    if ( array ) free(array);
+    if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Splitsel.c b/src/Splitsel.c
index 0ecb5d3..71951db 100644
--- a/src/Splitsel.c
+++ b/src/Splitsel.c
@@ -103,7 +103,7 @@ void *Splitsel(void *argument)
     {
       gridsize = vlistGridsizeMax(vlistID1);
       if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
     }
 
   nvars = vlistNvars(vlistID1);
@@ -113,7 +113,7 @@ void *Splitsel(void *argument)
 
   if ( nconst )
     {
-      vars = (field_t **) malloc(nvars*sizeof(field_t *));
+      vars = (field_t **) Malloc(nvars*sizeof(field_t *));
 
       for ( varID = 0; varID < nvars; varID++ )
 	{
@@ -123,13 +123,13 @@ void *Splitsel(void *argument)
 	      nlevel  = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	      gridsize = gridInqSize(gridID);
 		  
-	      vars[varID] = (field_t*) malloc(nlevel*sizeof(field_t));
+	      vars[varID] = (field_t*) Malloc(nlevel*sizeof(field_t));
 
 	      for ( levelID = 0; levelID < nlevel; levelID++ )
 		{
 		  field_init(&vars[varID][levelID]);
 		  vars[varID][levelID].grid    = gridID;
-		  vars[varID][levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+		  vars[varID][levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
 		}
 	    }
 	}
@@ -256,7 +256,7 @@ void *Splitsel(void *argument)
 
   streamClose(streamID1);
  
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   if ( nconst )
     {
@@ -267,18 +267,18 @@ void *Splitsel(void *argument)
 	      nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
 	      for ( levelID = 0; levelID < nlevel; levelID++ )
 		if ( vars[varID][levelID].ptr )
-		  free(vars[varID][levelID].ptr);
+		  Free(vars[varID][levelID].ptr);
 
-	      free(vars[varID]);
+	      Free(vars[varID]);
 	    }
 	}
 
-      if ( vars  ) free(vars);
+      if ( vars  ) Free(vars);
     }
 
   vlistDestroy(vlistID2);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Splittime.c b/src/Splittime.c
index 640ea12..53589df 100644
--- a/src/Splittime.c
+++ b/src/Splittime.c
@@ -78,6 +78,8 @@ void *Splittime(void *argument)
 
   if ( processSelf() != 0 ) cdoAbort("This operator can't be combined with other operators!");
 
+  if ( UNCHANGED_RECORD ) lcopy = TRUE;
+
   int SPLITHOUR = cdoOperatorAdd("splithour", func_time, 10000, NULL);
   int SPLITDAY  = cdoOperatorAdd("splitday",  func_date,     1, NULL);
   int SPLITMON  = cdoOperatorAdd("splitmon",  func_date,   100, NULL);
@@ -90,14 +92,11 @@ void *Splittime(void *argument)
   int operfunc   = cdoOperatorF1(operatorID);
   int operintval = cdoOperatorF2(operatorID);
 
-  if ( UNCHANGED_RECORD ) lcopy = TRUE;
-
   if ( operatorID == SPLITMON )
     {
       if ( operatorArgc() == 1 ) format = operatorArgv()[0];
     }
 
-  int season_start = get_season_start();
   const char *seas_name[4];
   get_season_name(seas_name);
 
@@ -124,7 +123,7 @@ void *Splittime(void *argument)
     {
       gridsize = vlistGridsizeMax(vlistID1);
       if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
     }
 
   int nvars = vlistNvars(vlistID1);
@@ -134,7 +133,7 @@ void *Splittime(void *argument)
 
   if ( nconst )
     {
-      vars = (field_t **) malloc(nvars*sizeof(field_t *));
+      vars = (field_t **) Malloc(nvars*sizeof(field_t *));
 
       for ( varID = 0; varID < nvars; varID++ )
 	{
@@ -144,13 +143,13 @@ void *Splittime(void *argument)
 	      nlevel  = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	      gridsize = gridInqSize(gridID);
 		  
-	      vars[varID] = (field_t*) malloc(nlevel*sizeof(field_t));
+	      vars[varID] = (field_t*) Malloc(nlevel*sizeof(field_t));
 
 	      for ( levelID = 0; levelID < nlevel; levelID++ )
 		{
 		  field_init(&vars[varID][levelID]);
-		  vars[varID][levelID].grid    = gridID;
-		  vars[varID][levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+		  vars[varID][levelID].grid = gridID;
+		  vars[varID][levelID].ptr  = (double*) Malloc(gridsize*sizeof(double));
 		}
 	    }
 	}
@@ -167,29 +166,7 @@ void *Splittime(void *argument)
 	  index = (vdate/operintval)%100;
 	  if ( index < 0 ) index = -index;
 
-	  if ( operatorID == SPLITSEAS )
-	    {
-	      if ( index < 0 || index > 16 )
-		cdoAbort("Month %d out of range!", index);
-
-	      if ( season_start == START_DEC )
-		{
-		  if ( index <= 12 )
-		    index = (index % 12) / 3;
-		  else
-		    index = index - 13;
-		}
-	      else
-		{
-		  if ( index <= 12 )
-		    index = (index - 1) / 3;
-		  else
-		    index = index - 13;
-		}
-	      
-	      if ( index < 0 || index > 3 )
-		cdoAbort("Season %d out of range!", index+1);
-	    }
+	  if ( operatorID == SPLITSEAS ) index = month_to_season(index);
 	}
       else if ( operfunc == func_time )
 	{
@@ -263,6 +240,7 @@ void *Splittime(void *argument)
 	{
 	  streamInqRecord(streamID1, &varID, &levelID);
 	  streamDefRecord(streamID2,  varID,  levelID);
+
 	  if ( lcopy && !(tsID == 0 && nconst) )
 	    {
 	      streamCopyRecord(streamID2, streamID1);
@@ -290,14 +268,8 @@ void *Splittime(void *argument)
     }
 
   streamClose(streamID1);
-
-  for ( index = 0; index < MAX_STREAMS; index++ )
-    {
-      streamID2 = streamIDs[index];
-      if ( streamID2 >= 0 ) streamClose(streamID2);
-    }
  
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   if ( nconst )
     {
@@ -308,18 +280,24 @@ void *Splittime(void *argument)
 	      nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
 	      for ( levelID = 0; levelID < nlevel; levelID++ )
 		if ( vars[varID][levelID].ptr )
-		  free(vars[varID][levelID].ptr);
+		  Free(vars[varID][levelID].ptr);
 
-	      free(vars[varID]);
+	      Free(vars[varID]);
 	    }
 	}
 
-      if ( vars  ) free(vars);
+      if ( vars ) Free(vars);
+    }
+
+  for ( index = 0; index < MAX_STREAMS; index++ )
+    {
+      streamID2 = streamIDs[index];
+      if ( streamID2 >= 0 ) streamClose(streamID2);
     }
 
   vlistDestroy(vlistID2);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Splityear.c b/src/Splityear.c
index f20ef3a..507a2b7 100644
--- a/src/Splityear.c
+++ b/src/Splityear.c
@@ -47,7 +47,10 @@ void *Splityear(void *argument)
   int ic = 0;
   int cyear[MAX_YEARS];
   int nmiss;
+  int gridID;
+  int nlevel;
   double *array = NULL;
+  field_t **vars = NULL;
 
   cdoInitialize(argument);
 
@@ -55,11 +58,10 @@ void *Splityear(void *argument)
 
   if ( UNCHANGED_RECORD ) lcopy = TRUE;
 
-  int SPLITYEAR    = cdoOperatorAdd("splityear",     func_date, 10000, NULL);
-  int SPLITYEARMON = cdoOperatorAdd("splityearmon",  func_date,   100, NULL);
+  int SPLITYEAR    = cdoOperatorAdd("splityear",     0, 10000, NULL);
+  int SPLITYEARMON = cdoOperatorAdd("splityearmon",  0,   100, NULL);
   
   int operatorID = cdoOperatorID();
-  int operfunc   = cdoOperatorF1(operatorID);
   int operintval = cdoOperatorF2(operatorID);
 
   memset(cyear, 0, MAX_YEARS*sizeof(int));
@@ -69,6 +71,10 @@ void *Splityear(void *argument)
   int vlistID1 = streamInqVlist(streamID1);
   int vlistID2 = vlistDuplicate(vlistID1);
 
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
+  vlistDefTaxis(vlistID2, taxisID2);
+
   strcpy(filename, cdoStreamName(1)->args);
   int nchars = strlen(filename);
 
@@ -76,16 +82,41 @@ void *Splityear(void *argument)
   filesuffix[0] = 0;
   cdoGenFileSuffix(filesuffix, sizeof(filesuffix), streamInqFiletype(streamID1), vlistID1, refname);
 
-  if ( ! lcopy )
+  // if ( ! lcopy )
     {
       gridsize = vlistGridsizeMax(vlistID1);
       if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
     }
 
-  int taxisID1 = vlistInqTaxis(vlistID1);
-  int taxisID2 = taxisDuplicate(taxisID1);
-  vlistDefTaxis(vlistID2, taxisID2);
+  int nvars = vlistNvars(vlistID1);
+  int nconst = 0;
+  for ( varID = 0; varID < nvars; varID++ )
+    if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) nconst++;
+
+  if ( nconst )
+    {
+      vars = (field_t **) Malloc(nvars*sizeof(field_t *));
+
+      for ( varID = 0; varID < nvars; varID++ )
+	{
+	  if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT )
+	    {
+	      gridID  = vlistInqVarGrid(vlistID1, varID);
+	      nlevel  = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
+	      gridsize = gridInqSize(gridID);
+		  
+	      vars[varID] = (field_t*) Malloc(nlevel*sizeof(field_t));
+
+	      for ( levelID = 0; levelID < nlevel; levelID++ )
+		{
+		  field_init(&vars[varID][levelID]);
+		  vars[varID][levelID].grid = gridID;
+		  vars[varID][levelID].ptr  = (double*) Malloc(gridsize*sizeof(double));
+		}
+	    }
+	}
+    }
 
   int index1 = - 1<<31;
   int index2;
@@ -160,14 +191,31 @@ void *Splityear(void *argument)
 	}
       
       taxisCopyTimestep(taxisID2, taxisID1);
+      streamDefTimestep(streamID2, tsID2);
 
-      streamDefTimestep(streamID2, tsID2++);
+      if ( tsID > 0 && tsID2 == 0 && nconst )
+	{
+	  for ( varID = 0; varID < nvars; varID++ )
+	    {
+	      if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT )
+		{
+		  nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
+		  for ( levelID = 0; levelID < nlevel; levelID++ )
+		    {
+		      streamDefRecord(streamID2, varID, levelID);
+		      nmiss = vars[varID][levelID].nmiss;
+		      streamWriteRecord(streamID2, vars[varID][levelID].ptr, nmiss);
+		    }
+		}
+	    }
+	}
 
       for ( recID = 0; recID < nrecs; recID++ )
 	{
 	  streamInqRecord(streamID1, &varID, &levelID);
 	  streamDefRecord(streamID2,  varID,  levelID);
-	  if ( lcopy )
+
+	  if ( lcopy && !(tsID == 0 && nconst) )
 	    {
 	      streamCopyRecord(streamID2, streamID1);
 	    }
@@ -175,19 +223,48 @@ void *Splityear(void *argument)
 	    {
 	      streamReadRecord(streamID1, array, &nmiss);
 	      streamWriteRecord(streamID2, array, nmiss);
+
+	      if ( tsID == 0 && nconst )
+		{
+		  if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT )
+		    {
+		      gridID  = vlistInqVarGrid(vlistID1, varID);
+		      gridsize = gridInqSize(gridID);
+		      memcpy(vars[varID][levelID].ptr, array, gridsize*sizeof(double));
+		      vars[varID][levelID].nmiss = nmiss;
+		    }
+		}
 	    }
 	}
 
+      tsID2++;
       tsID++;
     }
 
   streamClose(streamID1);
   streamClose(streamID2);
  
-  if ( ! lcopy )
-    if ( array ) free(array);
+  if ( array ) Free(array);
+
+  if ( nconst )
+    {
+      for ( varID = 0; varID < nvars; varID++ )
+	{
+	  if ( vlistInqVarTsteptype(vlistID2, varID) == TSTEP_CONSTANT )
+	    {
+	      nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
+	      for ( levelID = 0; levelID < nlevel; levelID++ )
+		if ( vars[varID][levelID].ptr )
+		  Free(vars[varID][levelID].ptr);
+
+	      Free(vars[varID]);
+	    }
+	}
+
+      if ( vars ) Free(vars);
+    }
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/StringUtilities.c b/src/StringUtilities.c
index 07d5f88..2181dcd 100644
--- a/src/StringUtilities.c
+++ b/src/StringUtilities.c
@@ -25,7 +25,7 @@ int StringSplitWithSeperator(  char *source_string, char *seperator, char*** ptr
 		   sep_count++;
 	  }	
  
-	temp_list  = (char**) malloc( sizeof( char* ) * (sep_count+1));
+	temp_list  = (char**) Malloc( sizeof( char* ) * (sep_count+1));
 	
 	if( DBG )
 	  fprintf(stderr, "Input str %s , seperator %s  sep count %d\n", duplicate_src, seperator, sep_count );
diff --git a/src/Subtrend.c b/src/Subtrend.c
index 3f5671c..e364634 100644
--- a/src/Subtrend.c
+++ b/src/Subtrend.c
@@ -68,8 +68,8 @@ void *Subtrend(void *argument)
 
   field_init(&field1);
   field_init(&field4);
-  field1.ptr = (double*) malloc(gridsize*sizeof(double));
-  field4.ptr = (double*) malloc(gridsize*sizeof(double));
+  field1.ptr = (double*) Malloc(gridsize*sizeof(double));
+  field4.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   vars2 = field_malloc(vlistID1, FIELD_PTR);
   vars3 = field_malloc(vlistID1, FIELD_PTR);
@@ -129,8 +129,8 @@ void *Subtrend(void *argument)
   field_free(vars2, vlistID1);
   field_free(vars3, vlistID1);
 
-  if ( field1.ptr ) free(field1.ptr);
-  if ( field4.ptr ) free(field4.ptr);
+  if ( field1.ptr ) Free(field1.ptr);
+  if ( field4.ptr ) Free(field4.ptr);
 
   streamClose(streamID4);
   streamClose(streamID3);
@@ -139,5 +139,5 @@ void *Subtrend(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Tee.c b/src/Tee.c
index fc56326..4b91160 100644
--- a/src/Tee.c
+++ b/src/Tee.c
@@ -58,7 +58,7 @@ void *Tee(void *argument)
   streamDefVlist(streamID3, vlistID3);
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -102,9 +102,9 @@ void *Tee(void *argument)
   streamClose(streamID2);
   streamClose(streamID3);
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Templates.c b/src/Templates.c
index 7ff8385..8954256 100644
--- a/src/Templates.c
+++ b/src/Templates.c
@@ -52,7 +52,7 @@ void *Template1(void *argument)
   if ( ! lcopy )
     {
       gridsize = vlistGridsizeMax(vlistID1);
-      array = (double*) malloc(gridsize*sizeof(double));
+      array = (double*) Malloc(gridsize*sizeof(double));
     }
 
   tsID = 0;
@@ -87,11 +87,11 @@ void *Template1(void *argument)
   vlistDestroy(vlistID2);
 
   if ( ! lcopy )
-    if ( array ) free(array);
+    if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
 
 
@@ -122,7 +122,7 @@ void *Template2(void *argument)
   streamDefVlist(streamID2, vlistID2);
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array = (double*) malloc(gridsize*sizeof(double));
+  array = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -148,9 +148,9 @@ void *Template2(void *argument)
 
   vlistDestroy(vlistID2);
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Test.c b/src/Test.c
index eb3efca..07c8a14 100644
--- a/src/Test.c
+++ b/src/Test.c
@@ -38,7 +38,7 @@ void *Test(void *argument)
   */
   cdoFinish();
 
-  return (0);
+  return 0;
 }
 
 
@@ -61,7 +61,7 @@ void *Test2(void *argument)
   */
   cdoFinish();
 
-  return (0);
+  return 0;
 }
 
 
@@ -99,11 +99,11 @@ void *Testdata(void *argument)
   streamDefVlist(streamID2, vlistID2);
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array = (double*) malloc(gridsize*sizeof(double));
-  fval = (float*) malloc(gridsize*sizeof(float));
-  ival = (int*) malloc(gridsize*sizeof(int));
-  cval = (unsigned char*) malloc(gridsize*sizeof(unsigned char)*4);
-  cval2 = (unsigned char*) malloc(gridsize*sizeof(unsigned char)*4);
+  array = (double*) Malloc(gridsize*sizeof(double));
+  fval = (float*) Malloc(gridsize*sizeof(float));
+  ival = (int*) Malloc(gridsize*sizeof(int));
+  cval = (unsigned char*) Malloc(gridsize*sizeof(unsigned char)*4);
+  cval2 = (unsigned char*) Malloc(gridsize*sizeof(unsigned char)*4);
 
   fp = fopen("testdata", "w");
 
@@ -152,9 +152,9 @@ void *Testdata(void *argument)
   streamClose(streamID1);
   streamClose(streamID2);
 
-  if ( array ) free(array);
+  if ( array ) Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Tests.c b/src/Tests.c
index f0efedf..d7ab0f6 100644
--- a/src/Tests.c
+++ b/src/Tests.c
@@ -98,8 +98,8 @@ void *Tests(void *argument)
   streamDefVlist(streamID2, vlistID2);
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
+  array2 = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -168,10 +168,10 @@ void *Tests(void *argument)
 
   vlistDestroy(vlistID2);
 
-  if ( array1 ) free(array1);
-  if ( array2 ) free(array2);
+  if ( array1 ) Free(array1);
+  if ( array2 ) Free(array2);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Timcount.c b/src/Timcount.c
index 6caa34e..241230d 100644
--- a/src/Timcount.c
+++ b/src/Timcount.c
@@ -86,14 +86,14 @@ void *Timcount(void *argument)
   streamDefVlist(streamID2, vlistID2);
 
   nrecords = vlistNrecs(vlistID1);
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = vlistGridsizeMax(vlistID1);
   if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
 
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   vars1 = field_malloc(vlistID1, FIELD_PTR);
 
@@ -168,15 +168,15 @@ void *Timcount(void *argument)
 
   field_free(vars1, vlistID1);
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID2);
   streamClose(streamID1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Timpctl.c b/src/Timpctl.c
index ebfe8e3..fdfb0df 100644
--- a/src/Timpctl.c
+++ b/src/Timpctl.c
@@ -30,7 +30,7 @@
 #include "cdo.h"
 #include "cdo_int.h"
 #include "pstream.h"
-#include "percentiles.h"
+#include "percentiles_hist.h"
 
 
 static
@@ -54,9 +54,7 @@ void timpctl(int operatorID)
   
   operatorInputArg("percentile number");
   double pn = parameter2double(operatorArgv()[0]);
-      
-  if ( !(pn >= 0 && pn <= 100) )
-    cdoAbort("Illegal argument: percentile number %g is not in the range 0..100!", pn);
+  percentile_check_number(pn);
 
   int cmplen = DATE_LEN - cdoOperatorF2(operatorID);
 
@@ -89,8 +87,8 @@ void timpctl(int operatorID)
   int nvars    = vlistNvars(vlistID1);
   int nrecords = vlistNrecs(vlistID1);
 
-  int *recVarID   = (int*) malloc(nrecords * sizeof(int));
-  int *recLevelID = (int*) malloc(nrecords * sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecords * sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords * sizeof(int));
 
   dtlist_type *dtlist = dtlist_new();
   dtlist_set_stat(dtlist, timestat_date);
@@ -99,7 +97,7 @@ void timpctl(int operatorID)
   int gridsize = vlistGridsizeMax(vlistID1);
 
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize * sizeof(double));
+  field.ptr = (double*) Malloc(gridsize * sizeof(double));
 
   vars1 = field_malloc(vlistID1, FIELD_PTR);
   hset = hsetCreate(nvars);
@@ -209,10 +207,10 @@ void timpctl(int operatorID)
 
   dtlist_delete(dtlist);
   
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID4);
   streamClose(streamID3);
@@ -238,5 +236,5 @@ void *Timpctl(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Timselpctl.c b/src/Timselpctl.c
index 933c077..2ad4de3 100644
--- a/src/Timselpctl.c
+++ b/src/Timselpctl.c
@@ -26,7 +26,7 @@
 #include "cdo.h"
 #include "cdo_int.h"
 #include "pstream.h"
-#include "percentiles.h"
+#include "percentiles_hist.h"
 
 
 void *Timselpctl(void *argument)
@@ -55,14 +55,12 @@ void *Timselpctl(void *argument)
   if ( nargc < 2 ) cdoAbort("Too few arguments! Need %d found %d.", 2, nargc);
 
   double pn  = parameter2double(operatorArgv()[0]);
+  percentile_check_number(pn);
   int ndates = parameter2int(operatorArgv()[1]);
   int noffset = 0, nskip = 0;
   if ( nargc > 2 ) noffset = parameter2int(operatorArgv()[2]);
   if ( nargc > 3 ) nskip   = parameter2int(operatorArgv()[3]);
 
-  if ( !(pn > 0 && pn < 100) )
-    cdoAbort("Illegal argument: percentile number %g is not in the range 0..100!", pn);
-
   if ( cdoVerbose ) cdoPrint("nsets = %d, noffset = %d, nskip = %d", ndates, noffset, nskip);
 
   int streamID1 = streamOpenRead(cdoStreamName(0));
@@ -92,8 +90,8 @@ void *Timselpctl(void *argument)
   int nvars    = vlistNvars(vlistID1);
   int nrecords = vlistNrecs(vlistID1);
 
-  int *recVarID   = (int*) malloc(nrecords*sizeof(int));
-  int *recLevelID = (int*) malloc(nrecords*sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   dtlist_type *dtlist = dtlist_new();
   dtlist_set_stat(dtlist, timestat_date);
@@ -102,7 +100,7 @@ void *Timselpctl(void *argument)
   int gridsize = vlistGridsizeMax(vlistID1);
 
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize * sizeof(double));
+  field.ptr = (double*) Malloc(gridsize * sizeof(double));
 
   vars1 = field_malloc(vlistID1, FIELD_PTR);
   hset = hsetCreate(nvars);
@@ -132,13 +130,13 @@ void *Timselpctl(void *argument)
 	}
     }
 
+  int otsID = 0;
   if ( tsID < noffset )
     {
       cdoWarning("noffset is larger than number of timesteps!");
       goto LABEL_END;
     }
 
-  int otsID = 0;
   while ( TRUE )
     {
       nrecs = streamInqTimestep(streamID2, otsID);
@@ -243,10 +241,10 @@ void *Timselpctl(void *argument)
 
   dtlist_delete(dtlist);
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID4);
   streamClose(streamID3);
@@ -255,5 +253,5 @@ void *Timselpctl(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Timselstat.c b/src/Timselstat.c
index 890551e..906e31b 100644
--- a/src/Timselstat.c
+++ b/src/Timselstat.c
@@ -39,7 +39,6 @@
 void *Timselstat(void *argument)
 {
   int timestat_date = TIMESTAT_MEAN;
-  int gridsize;
   int nrecs = 0;
   int varID, levelID, recID;
   int tsID;
@@ -47,8 +46,6 @@ void *Timselstat(void *argument)
   int i;
   int nmiss;
   int nlevel;
-  field_t **vars1 = NULL, **vars2 = NULL, **samp1 = NULL;
-  field_t field;
 
   cdoInitialize(argument);
 
@@ -96,22 +93,23 @@ void *Timselstat(void *argument)
   int nvars    = vlistNvars(vlistID1);
   int nrecords = vlistNrecs(vlistID1);
 
-  int *recVarID   = (int*) malloc(nrecords*sizeof(int));
-  int *recLevelID = (int*) malloc(nrecords*sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   dtlist_type *dtlist = dtlist_new();
   dtlist_set_stat(dtlist, timestat_date);
   dtlist_set_calendar(dtlist, taxisInqCalendar(taxisID1));
 
-  gridsize = vlistGridsizeMax(vlistID1);
+  int gridsize = vlistGridsizeMax(vlistID1);
 
+  field_t field;
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
-  vars1 = field_malloc(vlistID1, FIELD_PTR);
-  samp1 = field_malloc(vlistID1, FIELD_NONE);
-  if ( lvarstd )
-    vars2 = field_malloc(vlistID1, FIELD_PTR);
+  field_t **samp1 = field_malloc(vlistID1, FIELD_NONE);
+  field_t **vars1 = field_malloc(vlistID1, FIELD_PTR);
+  field_t **vars2 = NULL;
+  if ( lvarstd ) vars2 = field_malloc(vlistID1, FIELD_PTR);
 
   for ( tsID = 0; tsID < noffset; tsID++ )
     {
@@ -130,13 +128,13 @@ void *Timselstat(void *argument)
 	}
     }
 
+  int otsID   = 0;
   if ( tsID < noffset )
     {
       cdoWarning("noffset is larger than number of timesteps!");
       goto LABEL_END;
     }
 
-  int otsID   = 0;
   while ( TRUE )
     {
       for ( nsets = 0; nsets < ndates; nsets++ )
@@ -166,7 +164,7 @@ void *Timselstat(void *argument)
 		  if ( nmiss > 0 || samp1[varID][levelID].ptr )
 		    {
 		      if ( samp1[varID][levelID].ptr == NULL )
-			samp1[varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+			samp1[varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 
 		      for ( i = 0; i < gridsize; i++ )
 			if ( DBL_IS_EQUAL(vars1[varID][levelID].ptr[i],
@@ -186,7 +184,7 @@ void *Timselstat(void *argument)
 		    {
 		      if ( samp1[varID][levelID].ptr == NULL )
 			{
-			  samp1[varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+			  samp1[varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 			  for ( i = 0; i < gridsize; i++ )
 			    samp1[varID][levelID].ptr[i] = nsets;
 			}
@@ -226,11 +224,11 @@ void *Timselstat(void *argument)
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
 	    if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
-	    nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
+	    nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	    for ( levelID = 0; levelID < nlevel; levelID++ )
 	      {
 		if ( samp1[varID][levelID].ptr == NULL )
-		  farcmul(&vars1[varID][levelID], 1.0/nsets);
+		  farcdiv(&vars1[varID][levelID], (double)nsets);
 		else
 		  fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
 	      }
@@ -239,22 +237,22 @@ void *Timselstat(void *argument)
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
 	    if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
-	    nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
+	    nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	    for ( levelID = 0; levelID < nlevel; levelID++ )
 	      {
 		if ( samp1[varID][levelID].ptr == NULL )
 		  {
 		    if ( lstd )
-		      farcstdx(&vars1[varID][levelID], vars2[varID][levelID], nsets, divisor);
+		      farcstd(&vars1[varID][levelID], vars2[varID][levelID], nsets, divisor);
 		    else
-		      farcvarx(&vars1[varID][levelID], vars2[varID][levelID], nsets, divisor);
+		      farcvar(&vars1[varID][levelID], vars2[varID][levelID], nsets, divisor);
 		  }
 		else
 		  {
 		    if ( lstd )
-		      farstdx(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID], divisor);
+		      farstd(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID], divisor);
 		    else
-		      farvarx(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID], divisor);
+		      farvar(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID], divisor);
 		  }
 	      }
 	  }
@@ -295,15 +293,15 @@ void *Timselstat(void *argument)
 
   dtlist_delete(dtlist);
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID2);
   streamClose(streamID1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Timsort.c b/src/Timsort.c
index bd72bd2..0fa5c85 100644
--- a/src/Timsort.c
+++ b/src/Timsort.c
@@ -34,8 +34,8 @@ static
 int cmpdarray(const void *s1, const void *s2)
 {
   int cmp = 0;
-  const double *x = s1;
-  const double *y = s2;
+  const double *x = (double *)s1;
+  const double *y = (double *)s2;
 
   if      ( *x < *y ) cmp = -1;
   else if ( *x > *y ) cmp =  1;
@@ -84,9 +84,9 @@ void *Timsort(void *argument)
       if ( tsID >= nalloc )
 	{
 	  nalloc += NALLOC_INC;
-	  vdate = (int*) realloc(vdate, nalloc*sizeof(int));
-	  vtime = (int*) realloc(vtime, nalloc*sizeof(int));
-	  vars  = (field_t ***) realloc(vars, nalloc*sizeof(field_t **));
+	  vdate = (int*) Realloc(vdate, nalloc*sizeof(int));
+	  vtime = (int*) Realloc(vtime, nalloc*sizeof(int));
+	  vars  = (field_t ***) Realloc(vars, nalloc*sizeof(field_t **));
 	}
 
       vdate[tsID] = taxisInqVdate(taxisID1);
@@ -99,7 +99,7 @@ void *Timsort(void *argument)
 	  streamInqRecord(streamID1, &varID, &levelID);
 	  gridID   = vlistInqVarGrid(vlistID1, varID);
 	  gridsize = gridInqSize(gridID);
-	  vars[tsID][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+	  vars[tsID][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 	  streamReadRecord(streamID1, vars[tsID][varID][levelID].ptr, &nmiss);
 	  vars[tsID][varID][levelID].nmiss = nmiss;
 	}
@@ -109,9 +109,9 @@ void *Timsort(void *argument)
 
   nts = tsID;
 
-  sarray = (double **) malloc(ompNumThreads*sizeof(double *));
+  sarray = (double **) Malloc(ompNumThreads*sizeof(double *));
   for ( i = 0; i < ompNumThreads; i++ )
-    sarray[i] = (double*) malloc(nts*sizeof(double));
+    sarray[i] = (double*) Malloc(nts*sizeof(double));
 
   for ( varID = 0; varID < nvars; varID++ )
     {
@@ -123,27 +123,27 @@ void *Timsort(void *argument)
       for ( levelID = 0; levelID < nlevel; levelID++ )
 	{
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(i, tsID)
+#pragma omp parallel for default(none) shared(gridsize,nts,sarray,vars,varID,levelID)
 #endif
-	  for ( i = 0; i < gridsize; i++ )
+	  for ( int i = 0; i < gridsize; i++ )
 	    {
 	      int ompthID = cdo_omp_get_thread_num();
 
-	      for ( tsID = 0; tsID < nts; tsID++ )
+	      for ( int tsID = 0; tsID < nts; tsID++ )
 		sarray[ompthID][tsID] = vars[tsID][varID][levelID].ptr[i];
 
 	      qsort(sarray[ompthID], nts, sizeof(double), cmpdarray);  	      
 
-	      for ( tsID = 0; tsID < nts; tsID++ )
+	      for ( int tsID = 0; tsID < nts; tsID++ )
 		vars[tsID][varID][levelID].ptr[i] = sarray[ompthID][tsID];
 	    }
 	}
     }
 
   for ( i = 0; i < ompNumThreads; i++ )
-    if ( sarray[i] ) free(sarray[i]);
+    if ( sarray[i] ) Free(sarray[i]);
 
-  if ( sarray ) free(sarray);
+  if ( sarray ) Free(sarray);
 
   for ( tsID = 0; tsID < nts; tsID++ )
     {
@@ -168,14 +168,14 @@ void *Timsort(void *argument)
       field_free(vars[tsID], vlistID1);      
     }
 
-  if ( vars  ) free(vars);
-  if ( vdate ) free(vdate);
-  if ( vtime ) free(vtime);
+  if ( vars  ) Free(vars);
+  if ( vdate ) Free(vdate);
+  if ( vtime ) Free(vtime);
 
   streamClose(streamID2);
   streamClose(streamID1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Timstat.c b/src/Timstat.c
index d28f34c..dd65735 100644
--- a/src/Timstat.c
+++ b/src/Timstat.c
@@ -206,6 +206,7 @@ void *Timstat(void *argument)
       for ( varID = 0; varID < nvars; ++varID )
 	{
 	  vlistDefVarDatatype(vlistID3, varID, DATATYPE_INT32);
+	  vlistDefVarMissval(vlistID3, varID, -1);
 	  vlistDefVarUnits(vlistID3, varID, "");
 	  vlistDefVarAddoffset(vlistID3, varID, 0);
 	  vlistDefVarScalefactor(vlistID3, varID, 1);
@@ -217,8 +218,8 @@ void *Timstat(void *argument)
       streamDefVlist(streamID3, vlistID3);
     }
 
-  int *recVarID   = (int*) malloc(nrecords*sizeof(int));
-  int *recLevelID = (int*) malloc(nrecords*sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   dtlist_type *dtlist = dtlist_new();
   dtlist_set_stat(dtlist, timestat_date);
@@ -229,7 +230,7 @@ void *Timstat(void *argument)
 
   field_t field;
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   field_t **vars1 = field_malloc(vlistID1, FIELD_PTR);
   field_t **samp1 = field_malloc(vlistID1, FIELD_NONE);
@@ -269,11 +270,10 @@ void *Timstat(void *argument)
 		{
 		  streamReadRecord(streamID1, vars1[varID][levelID].ptr, &nmiss);
 		  vars1[varID][levelID].nmiss = nmiss;
-
 		  if ( nmiss > 0 || samp1[varID][levelID].ptr )
 		    {
 		      if ( samp1[varID][levelID].ptr == NULL )
-			samp1[varID][levelID].ptr = (double*) malloc(nwpv*gridsize*sizeof(double));
+			samp1[varID][levelID].ptr = (double*) Malloc(nwpv*gridsize*sizeof(double));
 
 		      for ( i = 0; i < nwpv*gridsize; i++ )
 			if ( DBL_IS_EQUAL(vars1[varID][levelID].ptr[i], vars1[varID][levelID].missval) )
@@ -287,12 +287,11 @@ void *Timstat(void *argument)
 		  streamReadRecord(streamID1, field.ptr, &field.nmiss);
 		  field.grid    = vars1[varID][levelID].grid;
 		  field.missval = vars1[varID][levelID].missval;
-
 		  if ( field.nmiss > 0 || samp1[varID][levelID].ptr )
 		    {
 		      if ( samp1[varID][levelID].ptr == NULL )
 			{
-			  samp1[varID][levelID].ptr = (double*) malloc(nwpv*gridsize*sizeof(double));
+			  samp1[varID][levelID].ptr = (double*) Malloc(nwpv*gridsize*sizeof(double));
 			  for ( i = 0; i < nwpv*gridsize; i++ )
 			    samp1[varID][levelID].ptr[i] = nsets;
 			}
@@ -339,10 +338,13 @@ void *Timstat(void *argument)
 	    for ( levelID = 0; levelID < nlevel; levelID++ )
 	      {
 		if ( samp1[varID][levelID].ptr == NULL )
-		  farcmul(&vars1[varID][levelID], 1.0/nsets);
+		  farcdiv(&vars1[varID][levelID], (double)nsets);
 		else
-		  fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
-	      }
+                  {
+                    //   farround(&samp1[varID][levelID]); not necessary
+                    fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
+                  }
+              }
 	  }
       else if ( lvarstd )
 	for ( varID = 0; varID < nvars; varID++ )
@@ -354,16 +356,16 @@ void *Timstat(void *argument)
 		if ( samp1[varID][levelID].ptr == NULL )
 		  {
 		    if ( lstd )
-		      farcstdx(&vars1[varID][levelID], vars2[varID][levelID], nsets, divisor);
+		      farcstd(&vars1[varID][levelID], vars2[varID][levelID], nsets, divisor);
 		    else
-		      farcvarx(&vars1[varID][levelID], vars2[varID][levelID], nsets, divisor);
+		      farcvar(&vars1[varID][levelID], vars2[varID][levelID], nsets, divisor);
 		  }
 		else
 		  {
 		    if ( lstd )
-		      farstdx(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID], divisor);
+		      farstd(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID], divisor);
 		    else
-		      farvarx(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID], divisor);
+		      farvar(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID], divisor);
 		  }
 	      }
 	  }
@@ -380,12 +382,12 @@ void *Timstat(void *argument)
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
 	    if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
-	    nwpv     = vars1[varID][levelID].nwpv;
-	    gridsize = gridInqSize(vars1[varID][levelID].grid);
-	    nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
+	    nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	    for ( levelID = 0; levelID < nlevel; levelID++ )
 	      {
-		missval = vars1[varID][levelID].missval;
+                nwpv     = vars1[varID][levelID].nwpv;
+                gridsize = gridInqSize(vars1[varID][levelID].grid);
+		missval  = vars1[varID][levelID].missval;
 		if ( samp1[varID][levelID].ptr )
 		  {
 		    int irun = 0;
@@ -452,12 +454,12 @@ void *Timstat(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Timstat2.c b/src/Timstat2.c
index 94e3fd1..b33791e 100644
--- a/src/Timstat2.c
+++ b/src/Timstat2.c
@@ -138,8 +138,8 @@ void *Timstat2(void *argument)
   int nvars  = vlistNvars(vlistID1);
   int nrecs  = vlistNrecs(vlistID1);
   int nrecs3 = nrecs;
-  int *recVarID   = (int*) malloc(nrecs*sizeof(int));
-  int *recLevelID = (int*) malloc(nrecs*sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecs*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecs*sizeof(int));
 
   int taxisID1 = vlistInqTaxis(vlistID1);
   //int taxisID2 = vlistInqTaxis(vlistID2);
@@ -152,11 +152,11 @@ void *Timstat2(void *argument)
  
   gridsize = vlistGridsizeMax(vlistID1);
 
-  double *array1  = (double*) malloc(gridsize*sizeof(double));
-  double *array2  = (double*) malloc(gridsize*sizeof(double));
+  double *array1  = (double*) Malloc(gridsize*sizeof(double));
+  double *array2  = (double*) Malloc(gridsize*sizeof(double));
   				 
-  double ****work = (double ****) malloc(nvars*sizeof(double ***));
-  int ***nofvals  = (int ***) malloc(nvars*sizeof(int **));
+  double ****work = (double ****) Malloc(nvars*sizeof(double ***));
+  int ***nofvals  = (int ***) Malloc(nvars*sizeof(int **));
 
   for ( varID = 0; varID < nvars; varID++ )
     {
@@ -164,18 +164,18 @@ void *Timstat2(void *argument)
       gridsize = gridInqSize(gridID);
       nlevs    = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 
-      work[varID]    = (double ***) malloc(nlevs*sizeof(double **));
-      nofvals[varID] = (int **) malloc(nlevs*sizeof(int *));  
+      work[varID]    = (double ***) Malloc(nlevs*sizeof(double **));
+      nofvals[varID] = (int **) Malloc(nlevs*sizeof(int *));  
 
       for ( levelID = 0; levelID < nlevs; levelID++ )
 	{
-	  nofvals[varID][levelID] = (int*) malloc(gridsize*sizeof(int));
+	  nofvals[varID][levelID] = (int*) Malloc(gridsize*sizeof(int));
 	  memset(nofvals[varID][levelID], 0, gridsize*sizeof(int));
       
-	  work[varID][levelID] = (double **) malloc(nwork*sizeof(double *));
+	  work[varID][levelID] = (double **) Malloc(nwork*sizeof(double *));
 	  for ( i = 0; i < nwork; i++ )
 	    {
-	      work[varID][levelID][i] = (double*) malloc(gridsize*sizeof(double));
+	      work[varID][levelID][i] = (double*) Malloc(gridsize*sizeof(double));
 	      memset(work[varID][levelID][i], 0, gridsize*sizeof(double));
 	    }
 	}
@@ -188,6 +188,8 @@ void *Timstat2(void *argument)
       vtime = taxisInqVtime(taxisID1);
 
       nrecs2 = streamInqTimestep(streamID2, tsID);
+      if ( nrecs != nrecs2 )
+        cdoWarning("Input streams have different number of records!");
 
       for ( recID = 0; recID < nrecs; recID++ )
 	{
@@ -281,29 +283,29 @@ void *Timstat2(void *argument)
       nlevs = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
       for ( levelID = 0; levelID < nlevs; levelID++ )
 	{
-	  free(nofvals[varID][levelID]);
+	  Free(nofvals[varID][levelID]);
 	  for ( i = 0; i < nwork; i++ )
-	    free(work[varID][levelID][i]);
-	  free(work[varID][levelID]);
+	    Free(work[varID][levelID][i]);
+	  Free(work[varID][levelID]);
 	}
     
-      free(nofvals[varID]);
-      free(work[varID]);
+      Free(nofvals[varID]);
+      Free(work[varID]);
     }
     
-  free(nofvals);
-  free(work);
+  Free(nofvals);
+  Free(work);
 
   streamClose(streamID3);
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array1 )     free(array1);
-  if ( array2 )     free(array2);
-  if ( recVarID )   free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( array1 )     Free(array1);
+  if ( array2 )     Free(array2);
+  if ( recVarID )   Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
     
   cdoFinish();   
  
-  return (0);
+  return 0;
 }
diff --git a/src/Timstat3.c b/src/Timstat3.c
index fee2eaf..05060d3 100644
--- a/src/Timstat3.c
+++ b/src/Timstat3.c
@@ -96,8 +96,8 @@ void *Timstat3(void *argument)
   int nvars = vlistNvars(vlistID[0]);
   int nrecs = vlistNrecs(vlistID[0]);
   int nrecs3 = nrecs;
-  int *recVarID   = (int*) malloc(nrecs*sizeof(int));
-  int *recLevelID = (int*) malloc(nrecs*sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecs*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecs*sizeof(int));
 
   int taxisID1 = vlistInqTaxis(vlistID[0]);
   int taxisID3 = taxisDuplicate(taxisID1);
@@ -112,19 +112,19 @@ void *Timstat3(void *argument)
   for ( i = 0; i < NIN; ++i )
     {
       field_init(&in[i]);
-      in[i].ptr = (double*) malloc(gridsize*sizeof(double));
+      in[i].ptr = (double*) Malloc(gridsize*sizeof(double));
     }
 				 
   for ( i = 0; i < NOUT; ++i )
     {
       field_init(&out[i]);
-      out[i].ptr = (double*) malloc(gridsize*sizeof(double));
+      out[i].ptr = (double*) Malloc(gridsize*sizeof(double));
     }
 				 
   for ( iw = 0; iw < NFWORK; ++iw )
-    fwork[iw] = (field_t **) malloc(nvars*sizeof(field_t *));
+    fwork[iw] = (field_t **) Malloc(nvars*sizeof(field_t *));
   for ( iw = 0; iw < NIWORK; ++iw )
-    iwork[iw] = (int ***) malloc(nvars*sizeof(int **));
+    iwork[iw] = (int ***) Malloc(nvars*sizeof(int **));
 
   for ( varID = 0; varID < nvars; ++varID )
     {
@@ -132,12 +132,12 @@ void *Timstat3(void *argument)
       gridsize = vlistGridsizeMax(vlistID[0]);
       nlevs    = zaxisInqSize(vlistInqVarZaxis(vlistID[0], varID));
       missval  = missval1 = vlistInqVarMissval(vlistID[0], varID);
-      missval2 = vlistInqVarMissval(vlistID[1], varID); 
+      // missval2 = vlistInqVarMissval(vlistID[1], varID); 
 
       for ( iw = 0; iw < NFWORK; ++iw )
-	fwork[iw][varID] = (field_t*) malloc(nlevs*sizeof(field_t));
+	fwork[iw][varID] = (field_t*) Malloc(nlevs*sizeof(field_t));
       for ( iw = 0; iw < NIWORK; ++iw )
-	iwork[iw][varID] = (int **) malloc(nlevs*sizeof(int *));  
+	iwork[iw][varID] = (int **) Malloc(nlevs*sizeof(int *));  
 
       for ( levelID = 0; levelID < nlevs; ++levelID )
 	{
@@ -147,13 +147,13 @@ void *Timstat3(void *argument)
 	      fwork[iw][varID][levelID].grid    = gridID;
 	      fwork[iw][varID][levelID].nmiss   = 0;
 	      fwork[iw][varID][levelID].missval = missval;
-	      fwork[iw][varID][levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+	      fwork[iw][varID][levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
 	      memset(fwork[iw][varID][levelID].ptr, 0, gridsize*sizeof(double));
 	    }
 
 	  for ( iw = 0; iw < NIWORK; ++iw )
 	    {
-	      iwork[iw][varID][levelID] = (int*) malloc(gridsize*sizeof(int));
+	      iwork[iw][varID][levelID] = (int*) Malloc(gridsize*sizeof(int));
 	      memset(iwork[iw][varID][levelID], 0, gridsize*sizeof(int));
 	    }
 	}
@@ -322,30 +322,30 @@ void *Timstat3(void *argument)
       for ( levelID = 0; levelID < nlevs; levelID++ )
 	{
 	  for ( iw = 0; iw < NFWORK; ++iw )
-	    free(fwork[iw][varID][levelID].ptr);
+	    Free(fwork[iw][varID][levelID].ptr);
 	  for ( iw = 0; iw < NIWORK; ++iw )
-	    free(iwork[iw][varID][levelID]);
+	    Free(iwork[iw][varID][levelID]);
 	}
     
-      for ( iw = 0; iw < NFWORK; ++iw ) free(fwork[iw][varID]);
-      for ( iw = 0; iw < NIWORK; ++iw ) free(iwork[iw][varID]);
+      for ( iw = 0; iw < NFWORK; ++iw ) Free(fwork[iw][varID]);
+      for ( iw = 0; iw < NIWORK; ++iw ) Free(iwork[iw][varID]);
     }
 
-  for ( iw = 0; iw < NFWORK; iw++ ) free(fwork[iw]);
-  for ( iw = 0; iw < NIWORK; iw++ ) free(iwork[iw]);
+  for ( iw = 0; iw < NFWORK; iw++ ) Free(fwork[iw]);
+  for ( iw = 0; iw < NIWORK; iw++ ) Free(iwork[iw]);
 
 
   streamClose(streamID3);
   for ( is = 0; is < NIN; ++is )
     streamClose(streamID[is]);
 
-  for ( i = 0; i < NIN; ++i ) free(in[i].ptr);
-  for ( i = 0; i < NOUT; ++i ) free(out[i].ptr);
+  for ( i = 0; i < NIN; ++i ) Free(in[i].ptr);
+  for ( i = 0; i < NOUT; ++i ) Free(out[i].ptr);
 
-  free(recVarID);
-  free(recLevelID);
+  Free(recVarID);
+  Free(recLevelID);
     
   cdoFinish();   
  
-  return (0);
+  return 0;
 }
diff --git a/src/Tinfo.c b/src/Tinfo.c
index ef60e5e..c4b84aa 100644
--- a/src/Tinfo.c
+++ b/src/Tinfo.c
@@ -25,7 +25,6 @@
 #include "cdo.h"
 #include "cdo_int.h"
 #include "pstream.h"
-#include "dtypes.h"
 
 
 #define MAX_GAPS   64
@@ -33,15 +32,12 @@
 #define LIM_NTSM 1024
 
 enum {TU_SECONDS=0, TU_MINUTES, TU_HOURS, TU_DAYS, TU_MONTHS, TU_YEARS};
-char *tunits[] = {"second", "minute", "hour", "day", "month", "year"};
+const char *tunits[] = {"second", "minute", "hour", "day", "month", "year"};
 int   iunits[] = {1, 60, 3600, 86400, 1, 12};
 
 
 void getTimeInc(double jdelta, int vdate0, int vdate1, int *incperiod, int *incunit)
 {
-  int year0, month0, day0;
-  int year1, month1, day1;
-  int deltam, deltay;
   int lperiod;
   int sign = 1;
 
@@ -65,38 +61,42 @@ void getTimeInc(double jdelta, int vdate0, int vdate1, int *incperiod, int *incu
 
   // printf("\n%d %d %d\n",lperiod, vdate0, vdate1);
 
+  int year0, month0, day0;
   cdiDecodeDate(vdate0, &year0, &month0, &day0);
+  int year1, month1, day1;
   cdiDecodeDate(vdate1, &year1, &month1, &day1);
 
-  deltay = year1-year0;
-  deltam = deltay*12 + (month1-month0);
+  int deltay = year1-year0;
+  int deltam = deltay*12 + (month1-month0);
+  if ( deltay == 0 ) deltay = 1;
+  if ( deltam == 0 ) deltam = 1;
 
-  if ( lperiod/60 > 0 && lperiod/60 < 60 )
+  if ( lperiod/60 >= 1 && lperiod/60 < 60 )
     {
       *incperiod = lperiod/60;
       *incunit = TU_MINUTES;
     }
-  else if ( lperiod/3600 > 0 && lperiod/3600 < 24 )
+  else if ( lperiod/3600 >= 1 && lperiod/3600 < 24 )
     {
       *incperiod = lperiod/3600;
       *incunit = TU_HOURS;
     }
-  else if ( lperiod/(3600*24) > 0 && lperiod/(3600*24) < 32 )
+  else if ( lperiod/(3600*24) >= 1 && lperiod/(3600*24) < 32 )
     {
       *incperiod = lperiod/(3600*24);
       *incunit = TU_DAYS;
-      if ( *incperiod > 27 && deltam == 1 )
+      if ( *incperiod >= 27 && deltam == 1 )
 	{
 	  *incperiod = 1;
 	  *incunit = TU_MONTHS;
 	}
     }
-  else if ( lperiod/(3600*24*30) > 0 && lperiod/(3600*24*30) < 12 )
+  else if ( lperiod/(3600*24*30) >= 1 && lperiod/(3600*24*30) < 12 )
     {
       *incperiod = deltam;
       *incunit = TU_MONTHS;
     }
-  else if ( lperiod/(3600*24*30*12) > 0 )
+  else if ( lperiod/(3600*24*30*12) >= 1 )
     {
       *incperiod = deltay;
       *incunit = TU_YEARS;
@@ -114,17 +114,12 @@ static
 void printBounds(int taxisID, int calendar)
 {
   int vdate0, vdate1;
-  int vtime0, vtime1;
-  int incperiod = 0, incunit = 0;
-  juldate_t juldate1, juldate0;
-  double jdelta;
-  int i, len;
-  char vdatestr[32], vtimestr[32];
-
   taxisInqVdateBounds(taxisID, &vdate0, &vdate1);
+  int vtime0, vtime1;
   taxisInqVtimeBounds(taxisID, &vtime0, &vtime1);
 
-  date2str(vdate0, vdatestr, sizeof(vdatestr));
+   char vdatestr[32], vtimestr[32];
+   date2str(vdate0, vdatestr, sizeof(vdatestr));
   time2str(vtime0, vtimestr, sizeof(vtimestr));	  
   fprintf(stdout, " %s %s", vdatestr, vtimestr);
 
@@ -132,15 +127,16 @@ void printBounds(int taxisID, int calendar)
   time2str(vtime1, vtimestr, sizeof(vtimestr));	  
   fprintf(stdout, " %s %s", vdatestr, vtimestr);
 
-  juldate0  = juldate_encode(calendar, vdate0, vtime0);
-  juldate1  = juldate_encode(calendar, vdate1, vtime1);
-  jdelta    = juldate_to_seconds(juldate_sub(juldate1, juldate0));
+  juldate_t juldate0  = juldate_encode(calendar, vdate0, vtime0);
+  juldate_t juldate1  = juldate_encode(calendar, vdate1, vtime1);
+  double    jdelta    = juldate_to_seconds(juldate_sub(juldate1, juldate0));
 
+  int incperiod = 0, incunit = 0;
   getTimeInc(jdelta, vdate0, vdate1, &incperiod, &incunit);
   
   /* fprintf(stdout, "  %g  %g  %g  %d", jdelta, jdelta/3600, fmod(jdelta,3600), incperiod%3600);*/
-  len = fprintf(stdout, " %3d %s%s", incperiod, tunits[incunit], abs(incperiod)>1?"s":"");
-  for ( i = 0; i < 11-len; ++i ) fprintf(stdout, " ");
+  int len = fprintf(stdout, " %3d %s%s", incperiod, tunits[incunit], abs(incperiod)!=1?"s":"");
+  for ( int i = 0; i < 11-len; ++i ) fprintf(stdout, " ");
 }
 
 static
@@ -223,14 +219,12 @@ void *Tinfo(void *argument)
   int vdate0 = 0, vtime0 = 0;
   int vdate = 0, vtime = 0;
   int fdate = 0, ftime = 0;
-  int nrecs, ntsteps;
+  int nrecs;
   int tsID = 0, ntimeout;
-  int taxisID;
-  int streamID;
-  int vlistID;
+  int calendar;
   int year0, month0, day0;
   int year, month, day;
-  int calendar, unit;
+  int unit;
   int lforecast = FALSE;
   int incperiod0 = 0, incunit0 = 0;
   int incperiod = 0, incunit = 0;
@@ -248,14 +242,14 @@ void *Tinfo(void *argument)
 
   cdoInitialize(argument);
 
-  streamID = streamOpenRead(cdoStreamName(0));
+  int streamID = streamOpenRead(cdoStreamName(0));
 
-  vlistID = streamInqVlist(streamID);
+  int vlistID = streamInqVlist(streamID);
 
   fprintf(stdout, "\n");
 
-  taxisID = vlistInqTaxis(vlistID);
-  ntsteps = vlistNtsteps(vlistID);
+  int taxisID = vlistInqTaxis(vlistID);
+  int ntsteps = vlistNtsteps(vlistID);
 
   if ( ntsteps != 0 )
     {
@@ -346,7 +340,7 @@ void *Tinfo(void *argument)
 	      getTimeInc(jdelta, vdate0, vdate, &incperiod, &incunit);
 
 	      /* fprintf(stdout, "  %g  %g  %g  %d", jdelta, jdelta/3600, fmod(jdelta,3600), incperiod%3600);*/
-	      len = fprintf(stdout, " %3d %s%s", incperiod, tunits[incunit], abs(incperiod)>1?"s":"");
+	      len = fprintf(stdout, " %3d %s%s", incperiod, tunits[incunit], abs(incperiod)!=1?"s":"");
 	      for ( i = 0; i < 11-len; ++i ) fprintf(stdout, " ");
 	    }
 	  else
@@ -408,7 +402,7 @@ void *Tinfo(void *argument)
 		  ngaps++;
 		  if ( cdoVerbose )
 		    fprintf(stdout, "  %c--- Gap %d, missing %s%d timestep%s",
-			    arrow, ngaps, its>=LIM_NTSM?"more than ":"", its, its>1?"s":"");
+			    arrow, ngaps, its>=LIM_NTSM?"more than ":"", its, its!=1?"s":"");
 		}
 	      else if ( its < 0 )
 		{
@@ -446,13 +440,13 @@ void *Tinfo(void *argument)
   fprintf(stdout, " End date            : %s %s\n", vdatestr, vtimestr);
 
   fprintf(stdout, " Increment           : %3d %s%s\n", 
-	  incperiod0, tunits[incunit0], incperiod0>1?"s":"");
+	  incperiod0, tunits[incunit0], incperiod0!=1?"s":"");
   fprintf(stdout, " Number of timesteps : %d\n", tsID);
   fprintf(stdout, " Gaps identified     : %d\n", ngaps);
 
   if ( cdoVerbose && ngaps )
     {
-      fprintf(stdout, "\nFound potentially %d gap%s in the time series", ngaps, ngaps>1?"s":"");
+      fprintf(stdout, "\nFound potentially %d gap%s in the time series", ngaps, ngaps!=1?"s":"");
       if ( ngaps >= MAX_GAPS )
 	{
 	  ngaps = MAX_GAPS;
@@ -462,7 +456,7 @@ void *Tinfo(void *argument)
       for ( igap = 0; igap < ngaps; ++igap )
 	{
 	  fprintf(stdout, "  Gap %d between timestep %d and %d, missing %d timestep%s",
-		  igap+1, rangetsm[igap][0], rangetsm[igap][1], ntsm[igap], ntsm[igap]>1?"s":"");
+		  igap+1, rangetsm[igap][0], rangetsm[igap][1], ntsm[igap], ntsm[igap]!=1?"s":"");
 	  if ( ntsm[igap] >= MAX_NTSM )
 	    {
 	      ntsm[igap] = MAX_NTSM;
@@ -495,5 +489,5 @@ void *Tinfo(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Tocomplex.c b/src/Tocomplex.c
index d106448..fd55574 100644
--- a/src/Tocomplex.c
+++ b/src/Tocomplex.c
@@ -70,8 +70,8 @@ void *Tocomplex(void *argument)
   streamDefVlist(streamID2, vlistID2);
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(2*gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
+  array2 = (double*) Malloc(2*gridsize*sizeof(double));
       
   tsID  = 0;
   tsID2 = 0;
@@ -116,8 +116,8 @@ void *Tocomplex(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array1 ) free(array1);
-  if ( array2 ) free(array2);
+  if ( array1 ) Free(array1);
+  if ( array2 ) Free(array2);
 
   vlistDestroy(vlistID2);
 
diff --git a/src/Transpose.c b/src/Transpose.c
index 9b2af4c..d1d217d 100644
--- a/src/Transpose.c
+++ b/src/Transpose.c
@@ -37,8 +37,8 @@ void transxy(int gridID, double *array1, double *array2)
   nx = gridInqXsize(gridID);
   ny = gridInqYsize(gridID);
 
-  a2D1 = (double **) malloc(ny*sizeof(double *));
-  a2D2 = (double **) malloc(nx*sizeof(double *));
+  a2D1 = (double **) Malloc(ny*sizeof(double *));
+  a2D2 = (double **) Malloc(nx*sizeof(double *));
 
   for ( j = 0; j < ny; ++j ) a2D1[j] = array1+j*nx;
   for ( i = 0; i < nx; ++i ) a2D2[i] = array2+i*ny;
@@ -47,8 +47,8 @@ void transxy(int gridID, double *array1, double *array2)
     for ( i = 0; i < nx; ++i )
       a2D2[i][j] = a2D1[j][i];
 
-  free(a2D1);
-  free(a2D2);
+  Free(a2D1);
+  Free(a2D2);
 }
 
 
@@ -98,8 +98,8 @@ void *Transpose(void *argument)
 
   gridsize = vlistGridsizeMax(vlistID1);
 
-  array1 = (double*) malloc(gridsize*sizeof(double));
-  array2 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
+  array2 = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -126,10 +126,10 @@ void *Transpose(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  free(array1);
-  free(array2);
+  Free(array1);
+  Free(array2);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Trend.c b/src/Trend.c
index 75ea5aa..322589f 100644
--- a/src/Trend.c
+++ b/src/Trend.c
@@ -73,16 +73,16 @@ void *Trend(void *argument)
   streamDefVlist(streamID2, vlistID2);
   streamDefVlist(streamID3, vlistID2);
 
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = vlistGridsizeMax(vlistID1);
 
   field_init(&field1);
   field_init(&field2);
 
-  field1.ptr = (double*) malloc(gridsize*sizeof(double));
-  field2.ptr = (double*) malloc(gridsize*sizeof(double));
+  field1.ptr = (double*) Malloc(gridsize*sizeof(double));
+  field2.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   for ( w = 0; w < nwork; w++ )
     work[w] = field_calloc(vlistID1, FIELD_PTR);
@@ -173,11 +173,11 @@ void *Trend(void *argument)
 
   for ( w = 0; w < nwork; w++ ) field_free(work[w], vlistID1);
 
-  if ( field1.ptr ) free(field1.ptr);
-  if ( field2.ptr ) free(field2.ptr);
+  if ( field1.ptr ) Free(field1.ptr);
+  if ( field2.ptr ) Free(field2.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID3);
   streamClose(streamID2);
@@ -185,5 +185,5 @@ void *Trend(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Trms.c b/src/Trms.c
index 63c2e35..026731b 100644
--- a/src/Trms.c
+++ b/src/Trms.c
@@ -170,19 +170,19 @@ void *Trms(void *argument)
 
   streamDefVlist(streamID3, vlistID3);
 
-  vardata1 = (double**) malloc(nvars*sizeof(double*));
-  vardata2 = (double**) malloc(nvars*sizeof(double*));
+  vardata1 = (double**) Malloc(nvars*sizeof(double*));
+  vardata2 = (double**) Malloc(nvars*sizeof(double*));
 
   gridsize = gridInqSize(vlistInqVarGrid(vlistID1, pvarID));
   nlevel   = vctsize/2 - 1;
-  dp = (double*) malloc(gridsize*nlevel*sizeof(double));
+  dp = (double*) Malloc(gridsize*nlevel*sizeof(double));
 
   for ( varID = 0; varID < nvars; varID++ )
     {
       gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
       nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
-      vardata1[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
-      vardata2[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
+      vardata1[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
+      vardata2[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
     }
 
   field_init(&field1);
@@ -192,7 +192,7 @@ void *Trms(void *argument)
   lim = vlistGridsizeMax(vlistID1);
   field1.weight = NULL;
   if ( needWeights )
-    field1.weight = (double*) malloc(lim*sizeof(double));
+    field1.weight = (double*) Malloc(lim*sizeof(double));
 
   field2.weight = NULL;
 
@@ -282,19 +282,19 @@ void *Trms(void *argument)
 
   vlistDestroy(vlistID3);
 
-  if ( field1.weight ) free(field1.weight);
+  if ( field1.weight ) Free(field1.weight);
 
   for ( varID = 0; varID < nvars; varID++ )
     {
-      free(vardata1[varID]);
-      free(vardata2[varID]);
+      Free(vardata1[varID]);
+      Free(vardata2[varID]);
     }
 
-  free(vardata1);
-  free(vardata2);
-  free(dp);
+  Free(vardata1);
+  Free(vardata2);
+  Free(dp);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Tstepcount.c b/src/Tstepcount.c
index a7cf9c6..94267f9 100644
--- a/src/Tstepcount.c
+++ b/src/Tstepcount.c
@@ -67,7 +67,6 @@ void *Tstepcount(void *argument)
   int vdate = 0, vtime = 0;
   double missval;
   double refval = 0;
-  double count;
   field_t ***vars = NULL;
   typedef struct
   {
@@ -106,7 +105,7 @@ void *Tstepcount(void *argument)
       if ( tsID >= nalloc )
 	{
 	  nalloc += NALLOC_INC;
-	  vars  = (field_t ***) realloc(vars, nalloc*sizeof(field_t **));
+	  vars  = (field_t ***) Realloc(vars, nalloc*sizeof(field_t **));
 	}
 
       vdate = taxisInqVdate(taxisID1);
@@ -119,7 +118,7 @@ void *Tstepcount(void *argument)
 	  streamInqRecord(streamID1, &varID, &levelID);
 	  gridID   = vlistInqVarGrid(vlistID1, varID);
 	  gridsize = gridInqSize(gridID);
-	  vars[tsID][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+	  vars[tsID][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 	  streamReadRecord(streamID1, vars[tsID][varID][levelID].ptr, &nmiss);
 	  vars[tsID][varID][levelID].nmiss = nmiss;
 	}
@@ -129,10 +128,10 @@ void *Tstepcount(void *argument)
 
   nts = tsID;
 
-  mem = (memory_t*) malloc(ompNumThreads*sizeof(memory_t));
+  mem = (memory_t*) Malloc(ompNumThreads*sizeof(memory_t));
   for ( i = 0; i < ompNumThreads; i++ )
     {
-      mem[i].array1 = (double*) malloc(nts*sizeof(double));
+      mem[i].array1 = (double*) Malloc(nts*sizeof(double));
     }
 
   for ( varID = 0; varID < nvars; varID++ )
@@ -144,17 +143,16 @@ void *Tstepcount(void *argument)
       for ( levelID = 0; levelID < nlevel; levelID++ )
 	{
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(i, tsID) \
-  schedule(dynamic,1)
+#pragma omp parallel for default(none) shared(gridsize,mem,vars,varID,levelID,nts,missval,refval) schedule(dynamic,1)
 #endif
-	  for ( i = 0; i < gridsize; i++ )
+	  for ( int i = 0; i < gridsize; i++ )
 	    {
 	      int ompthID = cdo_omp_get_thread_num();
 
-	      for ( tsID = 0; tsID < nts; tsID++ )
+	      for ( int tsID = 0; tsID < nts; tsID++ )
 		mem[ompthID].array1[tsID] = vars[tsID][varID][levelID].ptr[i];
 
-	      count = tstepcount(nts, missval, mem[ompthID].array1, refval);
+	      double count = tstepcount(nts, missval, mem[ompthID].array1, refval);
 	      vars[0][varID][levelID].ptr[i] = count;
 	    }
 	}
@@ -162,9 +160,9 @@ void *Tstepcount(void *argument)
 
   for ( i = 0; i < ompNumThreads; i++ )
     {
-      free(mem[i].array1);
+      Free(mem[i].array1);
     }
-  free(mem);
+  Free(mem);
 
   taxisDefVdate(taxisID2, vdate);
   taxisDefVtime(taxisID2, vtime);
@@ -191,12 +189,12 @@ void *Tstepcount(void *argument)
 
   for ( tsID = 0; tsID < nts; tsID++ ) field_free(vars[tsID], vlistID1);
 
-  if ( vars  ) free(vars);
+  if ( vars  ) Free(vars);
 
   streamClose(streamID2);
   streamClose(streamID1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Vardup.c b/src/Vardup.c
index d48d366..0f7ebc3 100644
--- a/src/Vardup.c
+++ b/src/Vardup.c
@@ -30,30 +30,21 @@
 
 void *Vardup(void *argument)
 {
-  int PARDUP, PARMUL;
-  int operatorID;
-  int streamID1, streamID2;
-  int nrecs, nrecords;
-  int tsID, recID, varID, varID2, levelID;
-  int gridsize, i;
-  int vlistID1, vlistID2;
+  int nrecs;
+  int recID, varID, varID2, levelID;
+  int i;
   long offset;
   int nmul = 0;
   int nmiss;
-  int nvars, nlevel;
-  int *recVarID, *recLevelID;
-  int **varnmiss;
+  int nlevel;
   double *single;
-  double **vardata;
-  double *array;
-  int taxisID1, taxisID2;
 
   cdoInitialize(argument);
 
-  PARDUP = cdoOperatorAdd("pardup", 0, 0, NULL);
-  PARMUL = cdoOperatorAdd("parmul", 0, 0, NULL);
+  int PARDUP = cdoOperatorAdd("pardup", 0, 0, NULL);
+  int PARMUL = cdoOperatorAdd("parmul", 0, 0, NULL);
 
-  operatorID = cdoOperatorID();
+  int operatorID = cdoOperatorID();
 
   if ( operatorID == PARDUP )
     {
@@ -67,46 +58,46 @@ void *Vardup(void *argument)
   else
     cdoAbort("operator not implemented!");
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = vlistDuplicate(vlistID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  nvars    = vlistNvars(vlistID1);
-  nrecords = vlistNrecs(vlistID1);
+  int nvars    = vlistNvars(vlistID1);
+  int nrecords = vlistNrecs(vlistID1);
 
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
-  gridsize = vlistGridsizeMax(vlistID1);
-  array    = (double*) malloc(gridsize*sizeof(double));
-  vardata  = (double **) malloc(nvars*sizeof(double *));
-  varnmiss = (int **) malloc(nvars*sizeof(int *));
+  int gridsize = vlistGridsizeMax(vlistID1);
+  double *array    = (double*) Malloc(gridsize*sizeof(double));
+  double **vardata = (double **) Malloc(nvars*sizeof(double *));
+  int **varnmiss   = (int **) Malloc(nvars*sizeof(int *));
 
   for ( varID = 0; varID < nvars; varID++ )
     {
       gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
       nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
-      vardata[varID]  = (double*) malloc(gridsize*nlevel*sizeof(double));
-      varnmiss[varID] = (int*) malloc(nlevel*sizeof(int));
+      vardata[varID]  = (double*) Malloc(gridsize*nlevel*sizeof(double));
+      varnmiss[varID] = (int*) Malloc(nlevel*sizeof(int));
     }
 
   for ( i = 1; i < nmul; i++ )
     {
       vlistCat(vlistID2, vlistID1);
       for ( varID = 0; varID < nvars; varID++ )
-	vlistDefVarCode(vlistID2, varID+nvars*i, -(varID+nvars*i+1));
+	vlistDefVarParam(vlistID2, varID+nvars*i, cdiEncodeParam(-(varID+nvars*i+1), 255, 255));
     }
 
-  streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       taxisCopyTimestep(taxisID2, taxisID1);
@@ -152,13 +143,13 @@ void *Vardup(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  for ( varID = 0; varID < nvars; varID++ )  free(vardata[varID]);
-  for ( varID = 0; varID < nvars; varID++ )  free(varnmiss[varID]);
-  free(vardata);
-  free(varnmiss);
-  free(array);
+  for ( varID = 0; varID < nvars; varID++ ) Free(vardata[varID]);
+  for ( varID = 0; varID < nvars; varID++ ) Free(varnmiss[varID]);
+  Free(vardata);
+  Free(varnmiss);
+  Free(array);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Vargen.c b/src/Vargen.c
index 9f5c503..4e89d3d 100644
--- a/src/Vargen.c
+++ b/src/Vargen.c
@@ -40,20 +40,20 @@
 
 
 #if defined(ENABLE_DATA)
-  static double etopo_scale  = 3;
-  static double etopo_offset = 11000;
+  static const double etopo_scale  = 3;
+  static const double etopo_offset = 11000;
   static const unsigned short etopo[] = {
 #include "etopo.h"
   };
 
-  static double temp_scale  =  500;
-  static double temp_offset = -220;
+  static const double temp_scale  =  500;
+  static const double temp_offset = -220;
   static const unsigned short temp[] = {
 #include "temp.h"
   };
 
-  static double mask_scale  =  1;
-  static double mask_offset =  0;
+  static const double mask_scale  =  1;
+  static const double mask_offset =  0;
   static const unsigned short mask[] = {
 #include "mask.h"
   };
@@ -67,8 +67,8 @@
 #define CC_R             (287.05)  /* specific gas constant for air */
 static double TMP4PRESSURE = (C_EARTH_GRAV*SCALEHEIGHT)/(CC_R*T_ZERO);
 
-static double
-std_atm_temperatur(double height)
+static
+double std_atm_temperatur(double height)
 {
   /*
     Compute the temperatur for the given height (in meters) according to the
@@ -77,8 +77,8 @@ std_atm_temperatur(double height)
    return (T_ZERO + T_DELTA * exp((-1)*(height/SCALEHEIGHT)));
 }
 
-static double
-std_atm_pressure(double height)
+static
+double std_atm_pressure(double height)
 {
   /*
     Compute the pressure for the given height (in meters) according to the
@@ -87,35 +87,130 @@ std_atm_pressure(double height)
   return (P_ZERO * exp((-1)*TMP4PRESSURE*log((exp(height/SCALEHEIGHT)*T_ZERO + T_DELTA)/(T_ZERO + T_DELTA))));
 }
 
+static
+void remap_nn_reg2d_reg2d(int nx, int ny, const double *restrict data, int gridID, double *restrict array)
+{
+  if ( !(gridInqType(gridID) == GRID_LONLAT && !gridIsRotated(gridID)) )
+    cdoAbort("Internal error, wrong grid type!");
+
+  int nxvals = gridInqXsize(gridID);
+  int nyvals = gridInqYsize(gridID);
+  double *xvals = (double*) Malloc(nxvals*sizeof(double));
+  double *yvals = (double*) Malloc(nyvals*sizeof(double));
+
+  gridInqXvals(gridID, xvals);
+  gridInqYvals(gridID, yvals);
+
+  /* Convert lat/lon units if required */
+  char units[CDI_MAX_NAME];
+  gridInqXunits(gridID, units);
+  grid_to_degree(units, nxvals, xvals, "grid center lon");
+  gridInqYunits(gridID, units);
+  grid_to_degree(units, nyvals, yvals, "grid center lat");
+
+  int ii, jj;
+  double xval, yval;
+  for ( int j = 0; j < nyvals; j++ )
+    {
+      yval = yvals[j];
+      for ( int i = 0; i < nxvals; i++ )
+        {
+          xval = xvals[i];
+          if ( xval >=  180 ) xval -= 360;
+          if ( xval <  -180 ) xval += 360;
+          ii = (xval + 180)*2;
+          jj = (yval +  90)*2;
+          if ( ii >= nx ) ii = nx-1;
+          if ( jj >= ny ) jj = ny-1;
+          array[j*nxvals+i] = data[jj*nx+ii];
+        }
+    }
+
+  Free(xvals);
+  Free(yvals);
+}
+
+static
+void remap_nn_reg2d_nonreg2d(int nx, int ny, const double *restrict data, int gridID, double *restrict array)
+{
+  int gridID2 = gridID;
+  int gridsize = gridInqSize(gridID2);
+  double *xvals = (double*) Malloc(gridsize*sizeof(double));
+  double *yvals = (double*) Malloc(gridsize*sizeof(double));
+
+  if ( gridInqType(gridID2) == GRID_GME ) gridID2 = gridToUnstructured(gridID2, 0);
+
+  if ( gridInqType(gridID2) != GRID_UNSTRUCTURED && gridInqType(gridID2) != GRID_CURVILINEAR )
+    gridID2 = gridToCurvilinear(gridID2, 0);
+
+  gridInqXvals(gridID2, xvals);
+  gridInqYvals(gridID2, yvals);
+
+  /* Convert lat/lon units if required */
+  char units[CDI_MAX_NAME];
+  gridInqXunits(gridID2, units);
+  grid_to_degree(units, gridsize, xvals, "grid center lon");
+  gridInqYunits(gridID2, units);
+  grid_to_degree(units, gridsize, yvals, "grid center lat");
+
+  int ii, jj;
+  double xval, yval;
+  for ( int i = 0; i < gridsize; i++ )
+    {
+      xval = xvals[i];
+      yval = yvals[i];
+      if ( xval >=  180 ) xval -= 360;
+      if ( xval <  -180 ) xval += 360;
+      ii = (xval + 180)*2;
+      jj = (yval +  90)*2;
+      if ( ii >= nx ) ii = nx-1;
+      if ( jj >= ny ) jj = ny-1;
+      array[i] = data[jj*nx+ii];
+    }
+
+  Free(xvals);
+  Free(yvals);
+
+  if ( gridID != gridID2 ) gridDestroy(gridID2);
+}
+
+static
+void remap_nn_reg2d(int nx, int ny, const double *restrict data, int gridID, double *restrict array)
+{
+  if ( gridInqType(gridID) == GRID_LONLAT && !gridIsRotated(gridID) )
+    remap_nn_reg2d_reg2d(nx, ny, data, gridID, array);
+  else
+    remap_nn_reg2d_nonreg2d(nx, ny, data, gridID, array);
+}
+
+
 void *Vargen(void *argument)
 {
-  int RANDOM, SINCOS, COSHILL, CONST, FOR, TOPO, TEMP, MASK, STDATM;
-  int operatorID;
-  int streamID;
-  int nvars, ntimesteps, nlevels = 1;
-  int tsID, varID, varID2 = -1, levelID;
-  int gridsize, i;
-  int vlistID;
-  int gridID = -1, zaxisID, taxisID;
-  int vdate, vtime, julday;
-  const char *gridfile;
+  int ntimesteps, nlevels = 1;
+  int varID, varID2 = -1, levelID;
+  int i;
+  int gridID = -1, gridIDdata = -1, zaxisID;
+  int vdate, vtime;
   double rval, rstart = 0, rstop = 0, rinc = 0;
   double rconst = 0;
-  double *array, *levels = NULL;
+  double *levels = NULL;
+  double lon[720], lat[360];
+  int nlon = 720;
+  int nlat = 360;
 
   cdoInitialize(argument);
 
-  RANDOM  = cdoOperatorAdd("random",  0, 0, "grid description file or name, <seed>");
-  SINCOS  = cdoOperatorAdd("sincos",  0, 0, "grid description file or name");
-  COSHILL = cdoOperatorAdd("coshill", 0, 0, "grid description file or name");
-  CONST   = cdoOperatorAdd("const",   0, 0, "constant value, grid description file or name");
-  FOR     = cdoOperatorAdd("for",     0, 0, "start, end, <increment>");
-  TOPO    = cdoOperatorAdd("topo",    0, 0, NULL);
-  TEMP    = cdoOperatorAdd("temp",    0, 0, NULL);
-  MASK    = cdoOperatorAdd("mask",    0, 0, NULL);
-  STDATM  = cdoOperatorAdd("stdatm",  0, 0, "height levels [m]");
+  int RANDOM  = cdoOperatorAdd("random",  0, 0, "grid description file or name, <seed>");
+  int SINCOS  = cdoOperatorAdd("sincos",  0, 0, "grid description file or name");
+  int COSHILL = cdoOperatorAdd("coshill", 0, 0, "grid description file or name");
+  int CONST   = cdoOperatorAdd("const",   0, 0, "constant value, grid description file or name");
+  int FOR     = cdoOperatorAdd("for",     0, 0, "start, end, <increment>");
+  int TOPO    = cdoOperatorAdd("topo",    0, 0, NULL);
+  int TEMP    = cdoOperatorAdd("temp",    0, 0, NULL);
+  int MASK    = cdoOperatorAdd("mask",    0, 0, NULL);
+  int STDATM  = cdoOperatorAdd("stdatm",  0, 0, "height levels [m]");
 
-  operatorID = cdoOperatorID();
+  int operatorID = cdoOperatorID();
 
   if ( operatorID == RANDOM )
     {
@@ -123,13 +218,11 @@ void *Vargen(void *argument)
       operatorInputArg(cdoOperatorEnter(operatorID));
       if ( operatorArgc() < 1 ) cdoAbort("Too few arguments!");
       if ( operatorArgc() > 2 ) cdoAbort("Too many arguments!");
-      gridfile = operatorArgv()[0];
-      gridID   = cdoDefineGrid(gridfile);
+      gridID = cdoDefineGrid(operatorArgv()[0]);
       if ( operatorArgc() == 2 )
         {
           int idum = parameter2int(operatorArgv()[1]);
-          if ( idum >= 0 && idum < 0x7FFFFFFF )
-            seed = idum;
+          if ( idum >= 0 && idum < 0x7FFFFFFF ) seed = idum;
         }
       srand(seed);
     }
@@ -137,32 +230,30 @@ void *Vargen(void *argument)
     {
       operatorInputArg(cdoOperatorEnter(operatorID));
       operatorCheckArgc(1);
-      gridfile = operatorArgv()[0];
-      gridID   = cdoDefineGrid(gridfile);
+      gridID = cdoDefineGrid(operatorArgv()[0]);
     }
   else if ( operatorID == CONST )
     {
       operatorInputArg(cdoOperatorEnter(operatorID));
       operatorCheckArgc(2);
-      rconst   = parameter2double(operatorArgv()[0]);
-      gridfile = operatorArgv()[1];
-      gridID   = cdoDefineGrid(gridfile);
+      rconst = parameter2double(operatorArgv()[0]);
+      gridID = cdoDefineGrid(operatorArgv()[1]);
     }
   else if ( operatorID == TOPO || operatorID == TEMP || operatorID == MASK )
     {
-      int nlon, nlat, i;
-      double lon[720], lat[360];
-      nlon = 720;
-      nlat = 360;
-      gridID = gridCreate(GRID_LONLAT, nlon*nlat);
-      gridDefXsize(gridID, nlon);
-      gridDefYsize(gridID, nlat);
-
-      for ( i = 0; i < nlon; i++ ) lon[i] = -179.75 + i*0.5;
-      for ( i = 0; i < nlat; i++ ) lat[i] = -89.75 + i*0.5;
-
-      gridDefXvals(gridID, lon);
-      gridDefYvals(gridID, lat);
+      gridIDdata = gridCreate(GRID_LONLAT, nlon*nlat);
+      gridDefXsize(gridIDdata, nlon);
+      gridDefYsize(gridIDdata, nlat);
+
+      for ( int i = 0; i < nlon; i++ ) lon[i] = -179.75 + i*0.5;
+      for ( int i = 0; i < nlat; i++ ) lat[i] = -89.75 + i*0.5;
+
+      gridDefXvals(gridIDdata, lon);
+      gridDefYvals(gridIDdata, lat);
+
+      gridID = gridIDdata;
+
+      if ( operatorArgc() == 1 ) gridID = cdoDefineGrid(operatorArgv()[0]);
     }
   else if ( operatorID == FOR )
     {
@@ -219,12 +310,12 @@ void *Vargen(void *argument)
       nlevels = 1;
     }
 
-  vlistID = vlistCreate();
+  int vlistID = vlistCreate();
 
-  if ( operatorID == FOR )
-    varID = vlistDefVar(vlistID, gridID, zaxisID, TSTEP_INSTANT);
-  else
-    varID = vlistDefVar(vlistID, gridID, zaxisID, TSTEP_CONSTANT);
+  int tsteptype = TSTEP_CONSTANT;
+  if ( operatorID == FOR ) tsteptype = TSTEP_INSTANT;
+
+  varID = vlistDefVar(vlistID, gridID, zaxisID, tsteptype);
   /*
      For the standard atmosphere two output variables are generated: pressure and
      temperatur. The first (varID) is pressure, second (varID2) is temperatur.
@@ -239,12 +330,13 @@ void *Vargen(void *argument)
   if ( operatorID == STDATM )
     {
       vlistDefVarName(vlistID    , varID , "P");
-      vlistDefVarCode(vlistID    , varID , 1);
+      vlistDefVarParam(vlistID   , varID , cdiEncodeParam(1, 255, 255));
       vlistDefVarStdname(vlistID , varID , "air_pressure");
       vlistDefVarLongname(vlistID, varID , "pressure");
       vlistDefVarUnits(vlistID   , varID , "hPa");
+
       vlistDefVarName(vlistID    , varID2, "T");
-      vlistDefVarCode(vlistID    , varID2, 130);
+      vlistDefVarParam(vlistID   , varID2, cdiEncodeParam(130, 128, 255));
       vlistDefVarStdname(vlistID , varID2, var_stdname(air_temperature));
       vlistDefVarLongname(vlistID, varID2, "temperature");
       vlistDefVarUnits(vlistID   , varID2, "K");
@@ -252,26 +344,31 @@ void *Vargen(void *argument)
   else
     {
       vlistDefVarName(vlistID, varID, cdoOperatorName(operatorID));
-      if ( operatorID == TOPO )
-	vlistDefVarUnits(vlistID, varID , "m");	
-      if ( operatorID == TEMP )
-	vlistDefVarUnits(vlistID, varID , "K");	
+      if ( operatorID == TOPO ) vlistDefVarUnits(vlistID, varID , "m");	
+      if ( operatorID == TEMP ) vlistDefVarUnits(vlistID, varID , "K");	
     }
 
-  taxisID = taxisCreate(TAXIS_RELATIVE);
+  int taxisID = taxisCreate(TAXIS_RELATIVE);
   vlistDefTaxis(vlistID, taxisID);
 
-  if ( operatorID == RANDOM || operatorID == SINCOS || operatorID == COSHILL || operatorID == CONST || operatorID == TOPO ||
-       operatorID == TEMP || operatorID == MASK || operatorID == STDATM )
+  if ( operatorID == RANDOM || operatorID == SINCOS || operatorID == COSHILL || operatorID == CONST ||
+       operatorID == TOPO || operatorID == TEMP || operatorID == MASK || operatorID == STDATM )
     vlistDefNtsteps(vlistID, 1);
 
-  streamID = streamOpenWrite(cdoStreamName(0), cdoFiletype());
+  int streamID = streamOpenWrite(cdoStreamName(0), cdoFiletype());
 
   streamDefVlist(streamID, vlistID);
 
-  gridsize = gridInqSize(gridID);
-  array = (double*) malloc(gridsize*sizeof(double));
-
+  int gridsize = gridInqSize(gridID);
+  int datasize = gridsize;
+  double *array = (double*) Malloc(gridsize*sizeof(double));
+  double *data = array;
+  if ( gridID != gridIDdata && gridIDdata != -1 )
+    {
+      datasize = gridInqSize(gridIDdata);
+      data = (double*) Malloc(datasize*sizeof(double));
+    }
+  
   if ( operatorID == FOR )
     ntimesteps = 1.001 + ((rstop-rstart)/rinc);
   else
@@ -280,11 +377,11 @@ void *Vargen(void *argument)
       ntimesteps = 1;
     }
 
-  julday = date_to_julday(CALENDAR_PROLEPTIC, 10101);
+  int julday = date_to_julday(CALENDAR_PROLEPTIC, 10101);
 
-  nvars = vlistNvars(vlistID);
+  int nvars = vlistNvars(vlistID);
 
-  for ( tsID = 0; tsID < ntimesteps; tsID++ )
+  for ( int tsID = 0; tsID < ntimesteps; tsID++ )
     {
       rval  = rstart + rinc*tsID;
       vdate = julday_to_date(CALENDAR_PROLEPTIC, julday + tsID);
@@ -307,8 +404,8 @@ void *Vargen(void *argument)
                 }
               else if ( operatorID == SINCOS || operatorID == COSHILL )
                 {
-		  double *xvals = (double*) malloc(gridsize*sizeof(double));
-		  double *yvals = (double*) malloc(gridsize*sizeof(double));
+		  double *xvals = (double*) Malloc(gridsize*sizeof(double));
+		  double *yvals = (double*) Malloc(gridsize*sizeof(double));
 
 		  if ( gridInqType(gridID) == GRID_GME ) gridID = gridToUnstructured(gridID, 0);
 
@@ -336,8 +433,8 @@ void *Vargen(void *argument)
 			array[i] = 2 - cos(acos(cos(xvals[i]) * cos(yvals[i]))/1.2);
 		    }
 
-		  free(xvals);
-		  free(yvals);
+		  Free(xvals);
+		  Free(yvals);
 		}
               else if ( operatorID == CONST )
                 {
@@ -347,8 +444,8 @@ void *Vargen(void *argument)
               else if ( operatorID == TOPO )
                 {
 #if defined(ENABLE_DATA)
-                  for ( i = 0; i < gridsize; i++ )
-                    array[i] = etopo[i]/etopo_scale - etopo_offset;
+                  for ( i = 0; i < datasize; i++ )
+                    data[i] = etopo[i]/etopo_scale - etopo_offset;
 #else
                   cdoAbort("Operator support disabled!");
 #endif
@@ -356,8 +453,8 @@ void *Vargen(void *argument)
               else if ( operatorID == TEMP )
                 {
 #if defined(ENABLE_DATA)
-                  for ( i = 0; i < gridsize; i++ )
-                    array[i] = temp[i]/temp_scale - temp_offset;
+                  for ( i = 0; i < datasize; i++ )
+                    data[i] = temp[i]/temp_scale - temp_offset;
 #else
                   cdoAbort("Operator support disabled!");
 #endif
@@ -365,8 +462,8 @@ void *Vargen(void *argument)
               else if ( operatorID == MASK )
                 {
 #if defined(ENABLE_DATA)
-                  for ( i = 0; i < gridsize; i++ )
-                    array[i] = mask[i]/mask_scale - mask_offset;
+                  for ( i = 0; i < datasize; i++ )
+                    data[i] = mask[i]/mask_scale - mask_offset;
 #else
                   cdoAbort("Operator support disabled!");
 #endif
@@ -380,6 +477,11 @@ void *Vargen(void *argument)
                   array[0] = (varID == varID2) ? std_atm_temperatur(levels[levelID]) : std_atm_pressure(levels[levelID]);
                 }
 
+              if ( gridID != gridIDdata && (operatorID == TOPO || operatorID == TEMP || operatorID == MASK) )
+                {
+                  remap_nn_reg2d(nlon, nlat, data, gridID, array);
+                }
+
               streamWriteRecord(streamID, array, 0);
             }
         }
@@ -389,10 +491,11 @@ void *Vargen(void *argument)
 
   vlistDestroy(vlistID);
 
-  if ( array ) free(array);
-  if ( levels ) free(levels); 
+  if ( gridID != gridIDdata && gridIDdata != -1 ) Free(data);
+  if ( array ) Free(array);
+  if ( levels ) Free(levels); 
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Varrms.c b/src/Varrms.c
index c5e11d8..0a68f2c 100644
--- a/src/Varrms.c
+++ b/src/Varrms.c
@@ -32,7 +32,7 @@ void *Varrms(void *argument)
 {
   int streamID1, streamID2, streamID3;
   int vlistID1, vlistID2, vlistID3;
-  int gridID1, gridID2, gridID3, lastgrid = -1;
+  int gridID1, gridID3, lastgrid = -1;
   int wstatus = FALSE;
   int code = 0, oldcode = 0;
   int index, ngrids;
@@ -84,7 +84,6 @@ void *Varrms(void *argument)
   ngrids = vlistNgrids(vlistID1);
   index = 0;
   gridID1 = vlistGrid(vlistID1, index);
-  gridID2 = vlistGrid(vlistID1, index);
   
   if ( needWeights &&
        gridInqType(gridID1) != GRID_LONLAT &&
@@ -98,15 +97,15 @@ void *Varrms(void *argument)
 
   streamDefVlist(streamID3, vlistID3);
 
-  vardata1 = (double**) malloc(nvars*sizeof(double*));
-  vardata2 = (double**) malloc(nvars*sizeof(double*));
+  vardata1 = (double**) Malloc(nvars*sizeof(double*));
+  vardata2 = (double**) Malloc(nvars*sizeof(double*));
 
   for ( varID = 0; varID < nvars; varID++ )
     {
       gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
       nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
-      vardata1[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
-      vardata2[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
+      vardata1[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
+      vardata2[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
     }
 
   field_init(&field1);
@@ -116,7 +115,7 @@ void *Varrms(void *argument)
   lim = vlistGridsizeMax(vlistID1);
   field1.weight = NULL;
   if ( needWeights )
-    field1.weight = (double*) malloc(lim*sizeof(double));
+    field1.weight = (double*) Malloc(lim*sizeof(double));
 
   field2.weight = NULL;
 
@@ -186,18 +185,18 @@ void *Varrms(void *argument)
 
   vlistDestroy(vlistID3);
 
-  if ( field1.weight ) free(field1.weight);
+  if ( field1.weight ) Free(field1.weight);
 
   for ( varID = 0; varID < nvars; varID++ )
     {
-      free(vardata1[varID]);
-      free(vardata2[varID]);
+      Free(vardata1[varID]);
+      Free(vardata2[varID]);
     }
 
-  free(vardata1);
-  free(vardata2);
+  Free(vardata1);
+  Free(vardata2);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Vertcum.c b/src/Vertcum.c
new file mode 100644
index 0000000..4d8be4a
--- /dev/null
+++ b/src/Vertcum.c
@@ -0,0 +1,247 @@
+/*
+  This file is part of CDO. CDO is a collection of Operators to
+  manipulate and analyse Climate model Data.
+
+  Copyright (C) 2003-2015 Uwe Schulzweida, <uwe.schulzweida AT mpimet.mpg.de>
+  See COPYING file for copying and redistribution conditions.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+*/
+
+/*
+   This module contains the following operators:
+
+      Vertcum    vertcum         Vertical cumulative
+      Vertcum    vertcumhl       Vertical cumulative on hybrid sigma half level
+*/
+
+
+#include <cdi.h>
+#include "cdo.h"
+#include "cdo_int.h"
+#include "pstream.h"
+#include "field.h"
+
+
+#define IS_SURFACE_LEVEL(zaxisID)  (zaxisInqType(zaxisID) == ZAXIS_SURFACE && zaxisInqSize(zaxisID) == 1)
+
+static
+void add_vars_mv(int gridsize, double missval, const double *restrict var1, const double *restrict var2, double *restrict var3)
+{
+  double missval1 = missval;
+  double missval2 = missval;
+  /*
+  for ( int i = 0; i < gridsize; ++i )
+    var3[i] = ADD(var2[i], var1[i]);
+  */
+  for ( int i = 0; i < gridsize; ++i )
+    {
+      var3[i] = var2[i]; 
+      if ( !DBL_IS_EQUAL(var1[i], missval1) )
+        {
+          if ( !DBL_IS_EQUAL(var2[i], missval2) )
+            var3[i] += var1[i];
+          else
+            var3[i] = var1[i];
+        }      
+    }
+}
+
+
+void *Vertcum(void *argument)
+{
+  int recID, nrecs;
+  int i, gridsize, nlevs = 0, nlevs2 = 0, nlevshl = 0;
+  int varID, levelID, zaxisID;
+  int nmiss;
+  double *single;
+  double missval;
+
+  cdoInitialize(argument);
+
+                  cdoOperatorAdd("vertcum",    0,  0, NULL);
+  int VERTCUMHL = cdoOperatorAdd("vertcumhl",  0,  0, NULL);
+
+  int operatorID = cdoOperatorID();
+
+  int streamID1 = streamOpenRead(cdoStreamName(0));
+
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
+
+  int nvars = vlistNvars(vlistID1);
+  int *varnmiss[nvars];
+  double **vardata1[nvars];
+  double **vardata2[nvars];
+
+  int zaxisIDhl = -1;
+
+  if ( operatorID == VERTCUMHL )
+    {
+      double *vct = NULL;
+      int lhybrid = FALSE;
+      int nzaxis  = vlistNzaxis(vlistID1);
+      for ( i = 0; i < nzaxis; ++i )
+        {
+          zaxisID = vlistZaxis(vlistID1, i);
+          nlevs   = zaxisInqSize(zaxisID);
+
+          if ( zaxisInqType(zaxisID) == ZAXIS_HYBRID && nlevs > 1 )
+            {
+              int nvct = zaxisInqVctSize(zaxisID);
+              if ( nlevs == (nvct/2 - 1) )
+                {
+                  if ( lhybrid == FALSE )
+                    {
+                      lhybrid = TRUE;
+                      nlevshl = nlevs+1;
+
+                      double *vct = (double*) Malloc(nvct*sizeof(double));
+                      zaxisInqVct(zaxisID, vct);
+
+                      zaxisIDhl = zaxisCreate(ZAXIS_HYBRID_HALF, nlevshl);
+                      double levels[nlevshl];
+                      for ( levelID = 0; levelID < nlevshl; ++levelID ) levels[levelID] = levelID+1;
+                      zaxisDefLevels(zaxisIDhl, levels);
+                      zaxisDefVct(zaxisIDhl, nvct, vct);
+                      vlistChangeZaxisIndex(vlistID2, i, zaxisIDhl);
+                    }
+                  else
+                    {
+                      if ( memcmp(vct, zaxisInqVctPtr(zaxisID), nvct*sizeof(double)) == 0 )
+                        vlistChangeZaxisIndex(vlistID2, i, zaxisIDhl);
+                    }
+                }
+            }
+        }
+      if ( vct ) Free(vct);
+    }
+
+  for ( varID = 0; varID < nvars; varID++ )
+    {
+      gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
+      nlevs    = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
+      nlevs2   = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
+
+      varnmiss[varID] = (int*) Malloc(nlevs*sizeof(int));
+      vardata1[varID] = (double**) Malloc(nlevs*sizeof(double*));
+      vardata2[varID] = (double**) Malloc(nlevs2*sizeof(double*));
+      for ( levelID = 0; levelID < nlevs; ++levelID )
+        vardata1[varID][levelID] = (double*) Malloc(gridsize*sizeof(double));
+      for ( levelID = 0; levelID < nlevs2; ++levelID )
+        vardata2[varID][levelID] = (double*) Malloc(gridsize*sizeof(double));
+    }
+
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
+  vlistDefTaxis(vlistID2, taxisID2);
+
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+
+  streamDefVlist(streamID2, vlistID2);
+
+  int tsID = 0;
+  while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
+    {
+      taxisCopyTimestep(taxisID2, taxisID1);
+
+      streamDefTimestep(streamID2, tsID);
+
+      for ( recID = 0; recID < nrecs; recID++ )
+	{
+	  streamInqRecord(streamID1, &varID, &levelID);
+          streamReadRecord(streamID1, vardata1[varID][levelID], &varnmiss[varID][levelID]);
+        }
+
+      for ( varID = 0; varID < nvars; ++varID )
+	{
+          missval  = vlistInqVarMissval(vlistID2, varID);
+          gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
+          nlevs2   = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
+
+          if ( operatorID == VERTCUMHL && nlevs2 == nlevshl )
+            {
+              for ( i = 0; i < gridsize; ++i ) vardata2[varID][0][i] = 0;
+            }
+          else
+            {
+              for ( i = 0; i < gridsize; ++i ) vardata2[varID][0][i] = vardata1[varID][0][i];
+            }
+
+          for ( levelID = 1; levelID < nlevs2; ++levelID )
+            {
+              if ( operatorID == VERTCUMHL && nlevs2 == nlevshl )
+                {
+                  add_vars_mv(gridsize, missval, vardata1[varID][levelID-1], vardata2[varID][levelID-1], vardata2[varID][levelID]);
+                }
+              else
+                {
+                  add_vars_mv(gridsize, missval, vardata1[varID][levelID], vardata2[varID][levelID-1], vardata2[varID][levelID]);
+                }
+            }
+
+          if ( operatorID == VERTCUMHL && nlevs2 == nlevshl )
+            {
+              double *var1 = vardata2[varID][nlevs2-1];
+              for ( levelID = 0; levelID < nlevs2; ++levelID )
+                {
+                  double *var2 = vardata2[varID][levelID];
+                  for ( i = 0; i < gridsize; ++i )
+                    {
+                      if ( IS_NOT_EQUAL(var1[i], 0) )
+                        var2[i] /= var1[i];
+                      else
+                        var2[i] = 0;
+                    }
+                }
+            }
+	}
+
+      for ( varID = 0; varID < nvars; ++varID )
+	{
+          missval  = vlistInqVarMissval(vlistID2, varID);
+          gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
+          nlevs2   = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
+          for ( levelID = 0; levelID < nlevs2; ++levelID )
+	    {
+              single = vardata2[varID][levelID];
+
+              nmiss = 0;
+              for ( i = 0; i < gridsize; ++i )
+                if ( DBL_IS_EQUAL(single[i], missval) ) nmiss++;
+
+              streamDefRecord(streamID2, varID, levelID);
+              streamWriteRecord(streamID2, single, nmiss);
+	    }
+	}
+
+      tsID++;
+    }
+
+  for ( varID = 0; varID < nvars; ++varID )
+    {
+      nlevs  = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
+      nlevs2 = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
+      for ( levelID = 0; levelID < nlevs; ++levelID ) Free(vardata1[varID][levelID]);
+      for ( levelID = 0; levelID < nlevs2; ++levelID ) Free(vardata2[varID][levelID]);
+      Free(vardata1[varID]);
+      Free(vardata2[varID]);
+      Free(varnmiss[varID]);
+    }
+
+  streamClose(streamID2);
+  streamClose(streamID1);
+
+  vlistDestroy(vlistID2);
+
+  cdoFinish();
+
+  return 0;
+}
diff --git a/src/Vertintap.c b/src/Vertintap.c
index e8d7aea..6c06773 100644
--- a/src/Vertintap.c
+++ b/src/Vertintap.c
@@ -32,10 +32,37 @@
 #include "list.h"
 #include "stdnametable.h"
 
+static
+int is_height_axis(int zaxisID, int nlevel)
+{
+  int isheight = FALSE;
+  if ( nlevel > 1 )
+    {
+      if ( zaxisInqType(zaxisID) == ZAXIS_REFERENCE )
+        {
+          char units[CDI_MAX_NAME];
+          char stdname[CDI_MAX_NAME];
+          zaxisInqUnits(zaxisID, units);
+          zaxisInqStdname(zaxisID, stdname);
+          if ( strcmp(stdname, "height") == 0 && *units == 0 )
+            isheight = TRUE;
+        }
+    }
+  return isheight;
+}
+
+static
+int is_hybrid_axis(int zaxisID, int nlevel)
+{
+  int ishybrid = FALSE;
+  if ( (zaxisInqType(zaxisID) == ZAXIS_HYBRID || zaxisInqType(zaxisID) == ZAXIS_HYBRID_HALF) &&
+       nlevel > 1 ) ishybrid = TRUE;
+  return ishybrid;
+}
+
 
 void *Vertintap(void *argument)
 {
-  enum {ECHAM_MODE, WMO_MODE};
   enum {func_pl, func_hl};
   enum {type_lin, type_log};
   int recID, nrecs;
@@ -43,11 +70,11 @@ void *Vertintap(void *argument)
   int varID, levelID;
   int zaxisIDp, zaxisIDh = -1, nzaxis;
   int gridID, zaxisID;
-  int nplev, nhlev = 0, nhlevf = 0, nhlevh = 0, nlevel;
+  int nhlev = 0, nhlevf = 0, nhlevh = 0, nlevel;
   int *vert_index = NULL;
   int nvct;
   int apressID = -1, dpressID = -1;
-  int tempID = -1;
+  int psID = -1, tempID = -1;
   int param;
   //int sortlevels = TRUE;
   int *pnmiss = NULL;
@@ -55,12 +82,11 @@ void *Vertintap(void *argument)
   char stdname[CDI_MAX_NAME];
   double minval, maxval;
   double missval;
-  double *plev = NULL, *vct = NULL;
+  double *vct = NULL;
   double *single1, *single2;
   double *ps_prog = NULL, *full_press = NULL, *dpress = NULL;
   double *hyb_press = NULL;
   int Extrapolate = 0;
-  int lhavevct;
   int mono_level;
   LIST *flist = listNew(FLT_LIST);
 
@@ -77,17 +103,13 @@ void *Vertintap(void *argument)
 
   if ( operatorID == AP2PL || operatorID == AP2PL_LP )
     {
-      char *envstr;
-      envstr = getenv("EXTRAPOLATE");
+      char *envstr = getenv("EXTRAPOLATE");
 
-      if ( envstr )
+      if ( envstr && isdigit((int) envstr[0]) )
 	{
-	  if ( isdigit((int) envstr[0]) )
-	    {
-	      Extrapolate = atoi(envstr);
-	      if ( Extrapolate == 1 )
-		cdoPrint("Extrapolation of missing values enabled!");
-	    }
+          Extrapolate = atoi(envstr);
+          if ( Extrapolate == 1 )
+            cdoPrint("Extrapolation of missing values enabled!");
 	}
     }
   else if ( operatorID == AP2PLX || operatorID == AP2PLX_LP )
@@ -97,8 +119,25 @@ void *Vertintap(void *argument)
 
   operatorInputArg(cdoOperatorEnter(operatorID));
 
-  nplev = args2fltlist(operatorArgc(), operatorArgv(), flist);
-  plev  = (double *) listArrayPtr(flist);
+  int nplev = 0;
+  double *plev = NULL;
+  if ( operatorArgc() == 1 && strcmp(operatorArgv()[0], "default") == 0 )
+    {
+      /*
+      double stdlev[] = {100000, 92500, 85000, 77500, 70000, 60000, 50000, 40000, 30000, 25000, 20000,
+                          15000, 10000, 7000, 5000, 3000, 2000, 1000, 700, 500, 300, 200, 100, 50, 20, 10};
+      */
+      double stdlev[] = {100000, 92500, 85000, 70000, 60000, 50000, 40000, 30000, 25000, 20000, 15000,
+                          10000,  7000,  5000,  3000,  2000, 1000 };
+      nplev = sizeof(stdlev)/sizeof(*stdlev);
+      plev  = (double *) Malloc(nplev*sizeof(double));
+      for ( i = 0; i < nplev; ++i ) plev[i] = stdlev[i];
+    }
+  else
+    {
+      nplev = args2fltlist(operatorArgc(), operatorArgv(), flist);
+      plev  = (double *) listArrayPtr(flist);
+    }
 
   int streamID1 = streamOpenRead(cdoStreamName(0));
 
@@ -118,7 +157,42 @@ void *Vertintap(void *argument)
 
   zaxisDefLevels(zaxisIDp, plev);
   nzaxis  = vlistNzaxis(vlistID1);
-  lhavevct = FALSE;
+
+  int lheight = FALSE;
+  for ( i = 0; i < nzaxis; i++ )
+    {
+      mono_level = TRUE;
+      zaxisID = vlistZaxis(vlistID1, i);
+      nlevel  = zaxisInqSize(zaxisID);
+
+      if ( is_height_axis(zaxisID, nlevel) )
+        {
+	  double *level = (double *) Malloc(nlevel*sizeof(double));
+	  zaxisInqLevels(zaxisID, level);
+	  int l;
+	  for ( l = 0; l < nlevel; l++ )
+	    {
+	      if ( (l+1) != (int) (level[l]+0.5) ) break;
+	    }
+	  if ( l == nlevel ) mono_level = TRUE; 
+	  Free(level);          
+        }
+      
+      if ( is_height_axis(zaxisID, nlevel) && mono_level )
+        {
+          lheight  = TRUE;
+          zaxisIDh = zaxisID;
+          nhlev    = nlevel;
+          nhlevf   = nhlev;
+          nhlevh   = nhlevf + 1;
+
+          vlistChangeZaxisIndex(vlistID2, i, zaxisIDp);
+          break;
+        }
+    }
+
+  if ( ! lheight ) { // old version, not needed anymore!!
+  int lhavevct = FALSE;
   for ( i = 0; i < nzaxis; i++ )
     {
       /* mono_level = FALSE; */
@@ -126,23 +200,20 @@ void *Vertintap(void *argument)
       zaxisID = vlistZaxis(vlistID1, i);
       nlevel  = zaxisInqSize(zaxisID);
 
-      if ( (zaxisInqType(zaxisID) == ZAXIS_HYBRID || zaxisInqType(zaxisID) == ZAXIS_HYBRID_HALF) &&
-	   nlevel > 1 )
+      if ( is_hybrid_axis(zaxisID, nlevel) )
 	{
-	  double *level;
-	  int l;
-	  level = (double*) malloc(nlevel*sizeof(double));
+	  double *level = (double *) Malloc(nlevel*sizeof(double));
 	  zaxisInqLevels(zaxisID, level);
+	  int l;
 	  for ( l = 0; l < nlevel; l++ )
 	    {
 	      if ( (l+1) != (int) (level[l]+0.5) ) break;
 	    }
 	  if ( l == nlevel ) mono_level = TRUE; 
-	  free(level);
+	  Free(level);
 	}
 
-      if ( (zaxisInqType(zaxisID) == ZAXIS_HYBRID || zaxisInqType(zaxisID) == ZAXIS_HYBRID_HALF) &&
-	   nlevel > 1 && mono_level )
+      if ( is_hybrid_axis(zaxisID, nlevel) && mono_level )
 	{
 	  nvct = zaxisInqVctSize(zaxisID);
 	  if ( nlevel == (nvct/2 - 1) )
@@ -155,7 +226,7 @@ void *Vertintap(void *argument)
 		  nhlevf   = nhlev;
 		  nhlevh   = nhlevf + 1;
 	      
-		  vct = (double*) malloc(nvct*sizeof(double));
+		  vct = (double*) Malloc(nvct*sizeof(double));
 		  zaxisInqVct(zaxisID, vct);
 
 		  vlistChangeZaxisIndex(vlistID2, i, zaxisIDp);
@@ -176,7 +247,7 @@ void *Vertintap(void *argument)
 		  nhlevf   = nhlev - 1;
 		  nhlevh   = nhlev;
 	      
-		  vct = (double*) malloc(nvct*sizeof(double));
+		  vct = (double*) Malloc(nvct*sizeof(double));
 		  zaxisInqVct(zaxisID, vct);
 
 		  vlistChangeZaxisIndex(vlistID2, i, zaxisIDp);
@@ -189,7 +260,8 @@ void *Vertintap(void *argument)
 	    }
 	}
     }
-
+  }
+  
   int nvars = vlistNvars(vlistID1);
 
   int vars[nvars];
@@ -198,16 +270,16 @@ void *Vertintap(void *argument)
   int *varnmiss[nvars];
   int varinterp[nvars];
 
-  int maxlev   = nhlevh > nplev ? nhlevh : nplev;
+  int maxlev = nhlevh > nplev ? nhlevh : nplev;
 
   if ( Extrapolate == 0 )
-    pnmiss = (int*) malloc(nplev*sizeof(int));
+    pnmiss = (int *) Malloc(nplev*sizeof(int));
 
   // check levels
   if ( zaxisIDh != -1 )
     {
       int nlev = zaxisInqSize(zaxisIDh);
-      if ( nlev != nhlev ) cdoAbort("Internal error, wrong numner of hybrid level!");
+      if ( nlev != nhlev ) cdoAbort("Internal error, wrong number of height level!");
       double levels[nlev];
       zaxisInqLevels(zaxisIDh, levels);
 
@@ -223,13 +295,13 @@ void *Vertintap(void *argument)
 
   if ( zaxisIDh != -1 && gridsize > 0 )
     {
-      vert_index = (int*) malloc(gridsize*nplev*sizeof(int));
-      ps_prog    = (double*) malloc(gridsize*sizeof(double));
-      full_press = (double*) malloc(gridsize*nhlevf*sizeof(double));
-      dpress     = (double*) malloc(gridsize*nhlevf*sizeof(double));
+      vert_index = (int *) Malloc(gridsize*nplev*sizeof(int));
+      ps_prog    = (double *) Malloc(gridsize*sizeof(double));
+      full_press = (double *) Malloc(gridsize*nhlevf*sizeof(double));
+      dpress     = (double *) Malloc(gridsize*nhlevf*sizeof(double));
     }
   else
-    cdoWarning("No 3D variable with hybrid sigma pressure coordinate found!");
+    cdoWarning("No 3D variable with generalized height level found!");
 
   if ( operfunc == func_hl )
     {
@@ -252,52 +324,46 @@ void *Vertintap(void *argument)
       zaxisID  = vlistInqVarZaxis(vlistID1, varID);
       nlevel   = zaxisInqSize(zaxisID);
 
-      param    = vlistInqVarParam(vlistID1, varID);
-
       vlistInqVarStdname(vlistID1, varID, stdname);
       strtolower(stdname);
 
-      if      ( strcmp(stdname, var_stdname(air_pressure))       == 0 ) apressID = varID; 
-      else if ( strcmp(stdname, var_stdname(pressure_thickness)) == 0 ) dpressID = varID; 
-      else if ( strcmp(stdname, var_stdname(air_temperature))    == 0 ) tempID = varID; 
-
-
-      if ( gridInqType(gridID) == GRID_SPECTRAL && zaxisInqType(zaxisID) == ZAXIS_HYBRID )
-	cdoAbort("Spectral data on model level unsupported!");
+      if      ( strcmp(stdname, var_stdname(surface_air_pressure)) == 0 ) psID = varID; 
+      else if ( strcmp(stdname, var_stdname(air_pressure))         == 0 ) apressID = varID; 
+      else if ( strcmp(stdname, var_stdname(pressure_thickness))   == 0 ) dpressID = varID; 
+      else if ( strcmp(stdname, var_stdname(air_temperature))      == 0 ) tempID = varID; 
 
       if ( gridInqType(gridID) == GRID_SPECTRAL )
 	cdoAbort("Spectral data unsupported!");
 
-      vardata1[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
+      vardata1[varID] = (double *) Malloc(gridsize*nlevel*sizeof(double));
 
-      if ( zaxisID == zaxisIDh ||
-	   (zaxisInqType(zaxisID) == ZAXIS_HYBRID && zaxisIDh != -1 && (nlevel == nhlevh || nlevel == nhlevf)) )
+      if ( zaxisID == zaxisIDh )
 	{
 	  varinterp[varID] = TRUE;
-	  vardata2[varID]  = (double*) malloc(gridsize*nplev*sizeof(double));
-	  varnmiss[varID]  = (int*) malloc(maxlev*sizeof(int));
+	  vardata2[varID]  = (double *) Malloc(gridsize*nplev*sizeof(double));
+	  varnmiss[varID]  = (int *) Malloc(maxlev*sizeof(int));
 	  memset(varnmiss[varID], 0, maxlev*sizeof(int));
 	}
       else
 	{
-	  if ( zaxisInqType(zaxisID) == ZAXIS_HYBRID && zaxisIDh != -1 && nlevel > 1 )
-	    cdoWarning("Parameter %d has wrong number of levels, skipped! (param=%s nlevel=%d)",
-		       varID+1, paramstr, nlevel);
 	  varinterp[varID] = FALSE;
 	  vardata2[varID]  = vardata1[varID];
-	  varnmiss[varID]  = (int*) malloc(nlevel*sizeof(int));
+	  varnmiss[varID]  = (int *) Malloc(nlevel*sizeof(int));
 	}
     }
 
   if ( cdoVerbose )
     {
       cdoPrint("Found:");
+      if ( psID      != -1 ) cdoPrint("  %s", var_stdname(surface_air_pressure));
       if ( apressID  != -1 ) cdoPrint("  %s", var_stdname(air_pressure));
       if ( dpressID  != -1 ) cdoPrint("  %s", var_stdname(pressure_thickness));
       if ( tempID    != -1 ) cdoPrint("  %s", var_stdname(air_temperature));
     }
 
-  if ( apressID == -1 )  cdoAbort("%s not found!", var_stdname(air_pressure));
+  if ( apressID == -1 ) cdoAbort("%s not found!", var_stdname(air_pressure));
+  if ( zaxisIDh != -1 && psID == -1 && dpressID )
+    cdoWarning("Surface pressure not found - set to upper level of %s!", var_stdname(air_pressure));
 
   for ( varID = 0; varID < nvars; ++varID )
     {
@@ -312,9 +378,9 @@ void *Vertintap(void *argument)
   int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
-      for ( varID = 0; varID < nvars; ++varID ) vars[varID] = FALSE;
       for ( varID = 0; varID < nvars; ++varID )
 	{
+          vars[varID] = FALSE;
 	  nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	  for ( levelID = 0; levelID < nlevel; levelID++ )
 	    varnmiss[varID][levelID] = 0;
@@ -327,9 +393,9 @@ void *Vertintap(void *argument)
       for ( recID = 0; recID < nrecs; recID++ )
 	{
 	  streamInqRecord(streamID1, &varID, &levelID);
+	  /*
 	  zaxisID  = vlistInqVarZaxis(vlistID1, varID);
 	  nlevel   = zaxisInqSize(zaxisID);
-	  /*
 	  if ( sortlevels && zaxisIDh != -1 && zaxisID == zaxisIDh && nlevel == nhlev )
 	    {
 	      levelID = (int) (zaxisInqLevel(zaxisIDh, levelID)-1);
@@ -349,7 +415,11 @@ void *Vertintap(void *argument)
 
       if ( zaxisIDh != -1 )
 	{
-	  if ( dpressID != -1 )
+	  if ( psID != -1 )
+	    {
+	      memcpy(ps_prog, vardata1[psID], gridsize*sizeof(double)); 
+	    }
+          else if ( dpressID != -1 )
 	    {
 	      memcpy(dpress, vardata1[dpressID], gridsize*nhlevf*sizeof(double)); 
 	      for ( i = 0; i < gridsize; i++ )  ps_prog[i] = 0;
@@ -359,7 +429,8 @@ void *Vertintap(void *argument)
 	    }
 	  else
 	    {
-	      for ( i = 0; i < gridsize; i++ )  ps_prog[i] = 110000;
+	      memcpy(ps_prog, vardata1[apressID]+gridsize*(nhlevf-1), gridsize*sizeof(double)); 
+	      //for ( i = 0; i < gridsize; i++ )  ps_prog[i] = 110000;
 	    }
 
 	  /* check range of ps_prog */
@@ -388,7 +459,6 @@ void *Vertintap(void *argument)
 	{
 	  if ( vars[varID] )
 	    {
-	      gridID   = vlistInqVarGrid(vlistID1, varID);
 	      zaxisID  = vlistInqVarZaxis(vlistID1, varID);
 	      missval  = vlistInqVarMissval(vlistID1, varID);
 	      nlevel   = zaxisInqSize(zaxisID);
@@ -402,7 +472,7 @@ void *Vertintap(void *argument)
 		    {
 		      param = vlistInqVarParam(vlistID1, varID);
 		      cdiParamToString(param, paramstr, sizeof(paramstr));
-		      cdoAbort("Number of hybrid level differ from full/half level (param=%s)!", paramstr);
+		      cdoAbort("Number of generalized height level differ from full/half level (param=%s)!", paramstr);
 		    }
 
 		  for ( levelID = 0; levelID < nlevel; levelID++ )
@@ -443,22 +513,21 @@ void *Vertintap(void *argument)
 
   for ( varID = 0; varID < nvars; varID++ )
     {
-      free(varnmiss[varID]);
-      free(vardata1[varID]);
-      if ( varinterp[varID] ) free(vardata2[varID]);
+      Free(varnmiss[varID]);
+      Free(vardata1[varID]);
+      if ( varinterp[varID] ) Free(vardata2[varID]);
     }
 
-  if ( pnmiss     ) free(pnmiss);
-
-  if ( ps_prog    ) free(ps_prog);
-  if ( vert_index ) free(vert_index);
-  if ( full_press ) free(full_press);
-  if ( dpress )     free(dpress);
-  if ( vct        ) free(vct);
+  if ( pnmiss     ) Free(pnmiss);
+  if ( ps_prog    ) Free(ps_prog);
+  if ( vert_index ) Free(vert_index);
+  if ( full_press ) Free(full_press);
+  if ( dpress     ) Free(dpress);
+  if ( vct        ) Free(vct);
 
   listDelete(flist);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Vertintml.c b/src/Vertintml.c
index a107364..325d16b 100644
--- a/src/Vertintml.c
+++ b/src/Vertintml.c
@@ -41,15 +41,14 @@ void *Vertintml(void *argument)
   enum {ECHAM_MODE, WMO_MODE};
   enum {func_pl, func_hl};
   enum {type_lin, type_log};
-  int gridsize;
   int recID, nrecs;
   int i, k, offset;
-  int tsID, varID, levelID;
-  int zaxisIDp, zaxisIDh = -1, nzaxis;
+  int varID, levelID;
+  int zaxisIDp, zaxisIDh = -1;
   int gridID, zaxisID;
   int nhlev = 0, nhlevf = 0, nhlevh = 0, nlevel;
   int *vert_index = NULL;
-  int nvct;
+  int nvct = 0;
   int sgeopot_needed = FALSE;
   int sgeopotID = -1, geopotID = -1, tempID = -1, psID = -1, lnpsID = -1, presID = -1, gheightID = -1;
   int code, param;
@@ -66,7 +65,6 @@ void *Vertintml(void *argument)
   double *sgeopot = NULL, *ps_prog = NULL, *full_press = NULL, *half_press = NULL;
   double *hyb_press = NULL;
   int Extrapolate = 0;
-  int lhavevct;
   int mono_level;
   int instNum, tableNum;
   int useTable;
@@ -90,17 +88,13 @@ void *Vertintml(void *argument)
 
   if ( operatorID == ML2PL || operatorID == ML2HL || operatorID == ML2PL_LP || operatorID == ML2HL_LP )
     {
-      char *envstr;
-      envstr = getenv("EXTRAPOLATE");
+      char *envstr = getenv("EXTRAPOLATE");
 
-      if ( envstr )
+      if ( envstr && isdigit((int) envstr[0]) )
 	{
-	  if ( isdigit((int) envstr[0]) )
-	    {
-	      Extrapolate = atoi(envstr);
-	      if ( Extrapolate == 1 )
-		cdoPrint("Extrapolation of missing values enabled!");
-	    }
+          Extrapolate = atoi(envstr);
+          if ( Extrapolate == 1 )
+            cdoPrint("Extrapolation of missing values enabled!");
 	}
     }
   else if ( operatorID == ML2PLX || operatorID == ML2HLX || operatorID == ML2PLX_LP || operatorID == ML2HLX_LP )
@@ -114,10 +108,14 @@ void *Vertintml(void *argument)
   double *plev = NULL;
   if ( operatorArgc() == 1 && strcmp(operatorArgv()[0], "default") == 0 )
     {
+      /*
       double stdlev[] = {100000, 92500, 85000, 77500, 70000, 60000, 50000, 40000, 30000, 25000, 20000,
-                         15000, 10000, 7000, 5000, 3000, 2000, 1000, 700, 500, 300, 200, 100, 50, 20, 10};
+                          15000, 10000, 7000, 5000, 3000, 2000, 1000, 700, 500, 300, 200, 100, 50, 20, 10};
+      */
+      double stdlev[] = {100000, 92500, 85000, 70000, 60000, 50000, 40000, 30000, 25000, 20000, 15000,
+                          10000,  7000,  5000,  3000,  2000, 1000 };
       nplev = sizeof(stdlev)/sizeof(*stdlev);
-      plev  = (double *) malloc(nplev*sizeof(double));
+      plev  = (double *) Malloc(nplev*sizeof(double));
       for ( i = 0; i < nplev; ++i ) plev[i] = stdlev[i];
     }
   else
@@ -135,7 +133,7 @@ void *Vertintml(void *argument)
   int taxisID2 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  gridsize = vlist_check_gridsize(vlistID1);
+  int gridsize = vlist_check_gridsize(vlistID1);
 
   if ( operfunc == func_hl )
     zaxisIDp = zaxisCreate(ZAXIS_HEIGHT, nplev);
@@ -143,8 +141,8 @@ void *Vertintml(void *argument)
     zaxisIDp = zaxisCreate(ZAXIS_PRESSURE, nplev);
 
   zaxisDefLevels(zaxisIDp, plev);
-  nzaxis  = vlistNzaxis(vlistID1);
-  lhavevct = FALSE;
+  int nzaxis  = vlistNzaxis(vlistID1);
+  int lhavevct = FALSE;
   for ( i = 0; i < nzaxis; i++ )
     {
       /* mono_level = FALSE; */
@@ -155,16 +153,14 @@ void *Vertintml(void *argument)
       if ( (zaxisInqType(zaxisID) == ZAXIS_HYBRID || zaxisInqType(zaxisID) == ZAXIS_HYBRID_HALF) &&
 	   nlevel > 1 )
 	{
-	  double *level;
-	  int l;
-	  level = (double*) malloc(nlevel*sizeof(double));
+	  double level[nlevel];
 	  zaxisInqLevels(zaxisID, level);
+	  int l;
 	  for ( l = 0; l < nlevel; l++ )
 	    {
 	      if ( (l+1) != (int) (level[l]+0.5) ) break;
 	    }
 	  if ( l == nlevel ) mono_level = TRUE; 
-	  free(level);
 	}
 
       if ( (zaxisInqType(zaxisID) == ZAXIS_HYBRID || zaxisInqType(zaxisID) == ZAXIS_HYBRID_HALF) &&
@@ -179,9 +175,9 @@ void *Vertintml(void *argument)
 		  zaxisIDh = zaxisID;
 		  nhlev    = nlevel;
 		  nhlevf   = nhlev;
-		  nhlevh   = nhlevf + 1;
-	      
-		  vct = (double*) malloc(nvct*sizeof(double));
+		  nhlevh   = nhlev + 1;
+
+		  vct = (double*) Malloc(nvct*sizeof(double));
 		  zaxisInqVct(zaxisID, vct);
 
 		  vlistChangeZaxisIndex(vlistID2, i, zaxisIDp);
@@ -202,7 +198,7 @@ void *Vertintml(void *argument)
 		  nhlevf   = nhlev - 1;
 		  nhlevh   = nhlev;
 	      
-		  vct = (double*) malloc(nvct*sizeof(double));
+		  vct = (double*) Malloc(nvct*sizeof(double));
 		  zaxisInqVct(zaxisID, vct);
 
 		  vlistChangeZaxisIndex(vlistID2, i, zaxisIDp);
@@ -220,7 +216,7 @@ void *Vertintml(void *argument)
 		  int vctsize;
 		  int voff = 4;
 		  
-		  rvct = (double*) malloc(nvct*sizeof(double));
+		  rvct = (double*) Malloc(nvct*sizeof(double));
 		  zaxisInqVct(zaxisID, rvct);
 
 		  if ( (int)(rvct[0]+0.5) == 100000 && rvct[voff] < rvct[voff+1] )
@@ -232,7 +228,7 @@ void *Vertintml(void *argument)
 		      nhlevh   = nhlev + 1;
 
 		      vctsize = 2*nhlevh;
-		      vct = (double*) malloc(vctsize*sizeof(double));
+		      vct = (double*) Malloc(vctsize*sizeof(double));
 
 		      vlistChangeZaxisIndex(vlistID2, i, zaxisIDp);
 
@@ -268,6 +264,31 @@ void *Vertintml(void *argument)
 	}
     }
 
+  int psvarID = -1;
+  int linvertvct = FALSE;
+  if ( lhavevct && nvct && nvct%2 == 0 )
+    {
+      psvarID = vlist_get_psvarid(vlistID1, zaxisIDh);
+
+      for ( i = nvct/2+1; i < nvct; i++ )
+        if ( vct[i] > vct[i-1] ) break;
+
+      if ( i == nvct ) linvertvct = TRUE;
+    }
+
+  if ( cdoVerbose ) cdoPrint("linvertvct = %d", linvertvct);
+
+  if ( linvertvct )
+    {
+      double vctbuf[nvct];
+      memcpy(vctbuf, vct, nvct*sizeof(double));
+      for ( i = 0; i < nvct/2; i++ )
+        {
+          vct[nvct/2-1-i] = vctbuf[i];
+          vct[nvct-1-i] = vctbuf[i+nvct/2];
+        }
+    }
+
   int nvars = vlistNvars(vlistID1);
 
   int vars[nvars];
@@ -279,13 +300,13 @@ void *Vertintml(void *argument)
   int maxlev   = nhlevh > nplev ? nhlevh : nplev;
 
   if ( Extrapolate == 0 )
-    pnmiss = (int*) malloc(nplev*sizeof(int));
+    pnmiss = (int*) Malloc(nplev*sizeof(int));
 
   // check levels
   if ( zaxisIDh != -1 )
     {
       int nlev = zaxisInqSize(zaxisIDh);
-      if ( nlev != nhlev ) cdoAbort("Internal error, wrong numner of hybrid level!");
+      if ( nlev != nhlev ) cdoAbort("Internal error, wrong number of hybrid level!");
       double levels[nlev];
       zaxisInqLevels(zaxisIDh, levels);
 
@@ -301,10 +322,10 @@ void *Vertintml(void *argument)
 
   if ( zaxisIDh != -1 && gridsize > 0 )
     {
-      vert_index = (int*) malloc(gridsize*nplev*sizeof(int));
-      ps_prog    = (double*) malloc(gridsize*sizeof(double));
-      full_press = (double*) malloc(gridsize*nhlevf*sizeof(double));
-      half_press = (double*) malloc(gridsize*nhlevh*sizeof(double));
+      vert_index = (int*) Malloc(gridsize*nplev*sizeof(int));
+      ps_prog    = (double*) Malloc(gridsize*sizeof(double));
+      full_press = (double*) Malloc(gridsize*nhlevf*sizeof(double));
+      half_press = (double*) Malloc(gridsize*nhlevh*sizeof(double));
     }
   else
     cdoWarning("No 3D variable with hybrid sigma pressure coordinate found!");
@@ -423,17 +444,17 @@ void *Vertintml(void *argument)
 	cdoAbort("Spectral data unsupported!");
 
       if ( varID == gheightID )
-	vardata1[varID] = (double*) malloc(gridsize*(nlevel+1)*sizeof(double));
+	vardata1[varID] = (double*) Malloc(gridsize*(nlevel+1)*sizeof(double));
       else
-	vardata1[varID] = (double*) malloc(gridsize*nlevel*sizeof(double));
+	vardata1[varID] = (double*) Malloc(gridsize*nlevel*sizeof(double));
 
       /* if ( zaxisInqType(zaxisID) == ZAXIS_HYBRID && zaxisIDh != -1 && nlevel == nhlev ) */
       if ( zaxisID == zaxisIDh ||
 	   (zaxisInqType(zaxisID) == ZAXIS_HYBRID && zaxisIDh != -1 && (nlevel == nhlevh || nlevel == nhlevf)) )
 	{
 	  varinterp[varID] = TRUE;
-	  vardata2[varID]  = (double*) malloc(gridsize*nplev*sizeof(double));
-	  varnmiss[varID]  = (int*) malloc(maxlev*sizeof(int));
+	  vardata2[varID]  = (double*) Malloc(gridsize*nplev*sizeof(double));
+	  varnmiss[varID]  = (int*) Malloc(maxlev*sizeof(int));
 	  memset(varnmiss[varID], 0, maxlev*sizeof(int));
 	}
       else
@@ -443,7 +464,7 @@ void *Vertintml(void *argument)
 		       varID+1, paramstr, nlevel);
 	  varinterp[varID] = FALSE;
 	  vardata2[varID]  = vardata1[varID];
-	  varnmiss[varID]  = (int*) malloc(nlevel*sizeof(int));
+	  varnmiss[varID]  = (int*) Malloc(nlevel*sizeof(int));
 	}
     }
 
@@ -462,7 +483,7 @@ void *Vertintml(void *argument)
 
   if ( zaxisIDh != -1 && sgeopot_needed )
     {
-      sgeopot = (double*) malloc(gridsize*sizeof(double));
+      sgeopot = (double*) Malloc(gridsize*sizeof(double));
       if ( sgeopotID == -1 )
 	{
 	  if ( geopotID == -1 )
@@ -475,10 +496,12 @@ void *Vertintml(void *argument)
     }
 
   if ( zaxisIDh != -1 && gheightID != -1 && tempID == -1 )
-    cdoAbort("Temperature not found, needed to compute geopotheight!");
+    cdoAbort("Temperature not found, needed for vertical interpolation of geopotheight!");
 
   presID = lnpsID;
-  if ( zaxisIDh != -1 && lnpsID == -1 )
+  if ( psvarID != -1 ) presID = psvarID;
+
+  if ( zaxisIDh != -1 && presID == -1 )
     {
       if ( psID == -1 )
 	cdoAbort("%s not found!", var_stdname(surface_air_pressure));
@@ -488,17 +511,30 @@ void *Vertintml(void *argument)
 
   if ( cdoVerbose )
     {
+      vlistInqVarName(vlistID1, presID, varname);
       if ( presID == lnpsID )
-	cdoPrint("using LOG(%s)", var_stdname(surface_air_pressure));      
+        cdoPrint("using LOG(%s) from %s", var_stdname(surface_air_pressure), varname);
       else
-	cdoPrint("using %s", var_stdname(surface_air_pressure));
+        cdoPrint("using %s from %s", var_stdname(surface_air_pressure), varname);
+    }
+
+  // check VCT
+  if ( zaxisIDh != -1 )
+    {
+      double suma = 0, sumb = 0;
+      for ( i = 0; i < nhlevh; i++ )
+        {
+          suma += vct[i];
+          sumb += vct[i+nhlevh];
+        }
+      if ( !(suma>0&&sumb>0) ) cdoWarning("VCT is empty!");
     }
 
   int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       for ( varID = 0; varID < nvars; ++varID ) vars[varID] = FALSE;
@@ -520,6 +556,9 @@ void *Vertintml(void *argument)
 	      printf("levelID %d\n", levelID);
 	    }
 	  */
+          if ( linvertvct && zaxisIDh != -1 && zaxisID == zaxisIDh )
+            levelID = nlevel-1-levelID;
+
 	  offset   = gridsize*levelID;
 	  single1  = vardata1[varID] + offset;
 
@@ -541,21 +580,21 @@ void *Vertintml(void *argument)
 		{
 		  minmaxval(gridsize, sgeopot, NULL, &minval, &maxval);
 		  if ( minval < MIN_FIS || maxval > MAX_FIS )
-		    cdoWarning("Surface geopotential out of range (min=%g max=%g)!", minval, maxval);
+		    cdoWarning("Surface geopotential out of range (min=%g max=%g) [timestep:%d]!", minval, maxval, tsID+1);
 		  if ( gridsize > 1 && minval >= 0 && maxval <= 9000 )
-		    cdoWarning("Surface geopotential has an unexpected range (min=%g max=%g)!", minval, maxval);
+		    cdoWarning("Surface geopotential has an unexpected range (min=%g max=%g) [timestep:%d]!", minval, maxval, tsID+1);
 		}
 	    }
 
-	  if ( lnpsID != -1 )
+	  if ( presID == lnpsID )
 	    for ( i = 0; i < gridsize; i++ ) ps_prog[i] = exp(vardata1[lnpsID][i]);
-	  else if ( psID != -1 )
-	    memcpy(ps_prog, vardata1[psID], gridsize*sizeof(double));
+	  else if ( presID != -1 )
+	    memcpy(ps_prog, vardata1[presID], gridsize*sizeof(double));
 
 	  /* check range of ps_prog */
 	  minmaxval(gridsize, ps_prog, NULL, &minval, &maxval);
 	  if ( minval < MIN_PS || maxval > MAX_PS )
-	    cdoWarning("Surface pressure out of range (min=%g max=%g)!", minval, maxval);
+	    cdoWarning("Surface pressure out of range (min=%g max=%g) [timestep:%d]!", minval, maxval, tsID+1);
 
 
 	  presh(full_press, half_press, vct, ps_prog, nhlevf, gridsize);
@@ -685,24 +724,24 @@ void *Vertintml(void *argument)
 
   for ( varID = 0; varID < nvars; varID++ )
     {
-      free(varnmiss[varID]);
-      free(vardata1[varID]);
-      if ( varinterp[varID] ) free(vardata2[varID]);
+      Free(varnmiss[varID]);
+      Free(vardata1[varID]);
+      if ( varinterp[varID] ) Free(vardata2[varID]);
     }
 
-  if ( pnmiss     ) free(pnmiss);
+  if ( pnmiss     ) Free(pnmiss);
 
-  if ( sgeopot    ) free(sgeopot);
-  if ( ps_prog    ) free(ps_prog);
-  if ( vert_index ) free(vert_index);
-  if ( full_press ) free(full_press);
-  if ( half_press ) free(half_press);
-  if ( vct        ) free(vct);
-  if ( rvct       ) free(rvct);
+  if ( sgeopot    ) Free(sgeopot);
+  if ( ps_prog    ) Free(ps_prog);
+  if ( vert_index ) Free(vert_index);
+  if ( full_press ) Free(full_press);
+  if ( half_press ) Free(half_press);
+  if ( vct        ) Free(vct);
+  if ( rvct       ) Free(rvct);
 
   listDelete(flist);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Vertstat.c b/src/Vertstat.c
index 859e200..a513a7e 100644
--- a/src/Vertstat.c
+++ b/src/Vertstat.c
@@ -25,7 +25,9 @@
       Vertstat   vertmean        Vertical mean
       Vertstat   vertavg         Vertical average
       Vertstat   vertvar         Vertical variance
+      Vertstat   vertvar1        Vertical variance [Divisor is (n-1)]
       Vertstat   vertstd         Vertical standard deviation
+      Vertstat   vertstd1        Vertical standard deviation [Divisor is (n-1)]
 */
 
 
@@ -99,9 +101,9 @@ int getLayerThickness(int genbounds, int index, int zaxisID, int nlev, double *t
 {
   int status = 0;
   int i;
-  double *levels  = (double *) malloc(nlev*sizeof(double));
-  double *lbounds = (double *) malloc(nlev*sizeof(double));
-  double *ubounds = (double *) malloc(nlev*sizeof(double));
+  double *levels  = (double *) Malloc(nlev*sizeof(double));
+  double *lbounds = (double *) Malloc(nlev*sizeof(double));
+  double *ubounds = (double *) Malloc(nlev*sizeof(double));
 
   zaxisInqLevels(zaxisID, levels);
   if ( genbounds )
@@ -144,9 +146,9 @@ int getLayerThickness(int genbounds, int index, int zaxisID, int nlev, double *t
 	printf("   %3d  %6g  %6g/%-6g  %6g  %6g\n", i+1, levels[i], lbounds[i], ubounds[i], thickness[i], weights[i]);
     }
 
-  free(levels);
-  free(lbounds);
-  free(ubounds);
+  Free(levels);
+  Free(lbounds);
+  Free(ubounds);
 
   return status;
 }
@@ -175,15 +177,24 @@ void *Vertstat(void *argument)
                  cdoOperatorAdd("vertmax",  func_max,  0, NULL);
                  cdoOperatorAdd("vertsum",  func_sum,  0, NULL);
   int VERTINT  = cdoOperatorAdd("vertint",  func_sum,  1, NULL);
-  int VERTMEAN = cdoOperatorAdd("vertmean", func_mean, 1, NULL);
-  int VERTAVG  = cdoOperatorAdd("vertavg",  func_avg,  1, NULL);
-                 cdoOperatorAdd("vertvar",  func_var,  0, NULL);
-                 cdoOperatorAdd("vertstd",  func_std,  0, NULL);
+                 cdoOperatorAdd("vertmean", func_mean, 1, NULL);
+                 cdoOperatorAdd("vertavg",  func_avg,  1, NULL);
+                 cdoOperatorAdd("vertvar",  func_var,  1, NULL);
+                 cdoOperatorAdd("vertvar1", func_var1, 1, NULL);
+                 cdoOperatorAdd("vertstd",  func_std,  1, NULL);
+                 cdoOperatorAdd("vertstd1", func_std1, 1, NULL);
 
   int operatorID  = cdoOperatorID();
   int operfunc    = cdoOperatorF1(operatorID);
   int needWeights = cdoOperatorF2(operatorID);
 
+  int lmean   = operfunc == func_mean || operfunc == func_avg;
+  int lstd    = operfunc == func_std || operfunc == func_std1;
+  int lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
+  double divisor = operfunc == func_std1 || operfunc == func_var1;
+
+  //int applyWeights = lmean;
+
   int streamID1 = streamOpenRead(cdoStreamName(0));
 
   int vlistID1 = streamInqVlist(streamID1);
@@ -232,8 +243,8 @@ void *Vertstat(void *argument)
 	  // if ( nlev > 1 )
 	    {
 	      vert[index].numlevel = nlev;
-	      vert[index].thickness = (double *) malloc(nlev*sizeof(double));
-	      vert[index].weights = (double *) malloc(nlev*sizeof(double));
+	      vert[index].thickness = (double *) Malloc(nlev*sizeof(double));
+	      vert[index].weights = (double *) Malloc(nlev*sizeof(double));
 	      vert[index].status = getLayerThickness(genbounds, index, zaxisID, nlev, vert[index].thickness, vert[index].weights); 
 	    }
 	}
@@ -247,13 +258,13 @@ void *Vertstat(void *argument)
 
   field_t field;
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
-  field_t *vars1 = (field_t*) malloc(nvars*sizeof(field_t));
-  field_t *samp1 = (field_t*) malloc(nvars*sizeof(field_t));
+  field_t *vars1 = (field_t*) Malloc(nvars*sizeof(field_t));
+  field_t *samp1 = (field_t*) Malloc(nvars*sizeof(field_t));
   field_t *vars2 = NULL;
-  if ( operfunc == func_std || operfunc == func_var )
-    vars2 = (field_t*) malloc(nvars*sizeof(field_t));
+  if ( lvarstd )
+    vars2 = (field_t*) Malloc(nvars*sizeof(field_t));
 
   for ( varID = 0; varID < nvars; varID++ )
     {
@@ -269,18 +280,18 @@ void *Vertstat(void *argument)
       vars1[varID].nsamp   = 0;
       vars1[varID].nmiss   = 0;
       vars1[varID].missval = missval;
-      vars1[varID].ptr     = (double*) malloc(gridsize*sizeof(double));
+      vars1[varID].ptr     = (double*) Malloc(gridsize*sizeof(double));
       samp1[varID].grid    = gridID;
       samp1[varID].nmiss   = 0;
       samp1[varID].missval = missval;
       samp1[varID].ptr     = NULL;
-      if ( operfunc == func_std || operfunc == func_var )
+      if ( lvarstd )
 	{
 	  field_init(&vars2[varID]);
 	  vars2[varID].grid    = gridID;
 	  vars2[varID].nmiss   = 0;
 	  vars2[varID].missval = missval;
-	  vars2[varID].ptr     = (double*) malloc(gridsize*sizeof(double));
+	  vars2[varID].ptr     = (double*) Malloc(gridsize*sizeof(double));
 	}
     }
 
@@ -329,16 +340,25 @@ void *Vertstat(void *argument)
 	      vars1[varID].nmiss = nmiss;
 
 	      if ( operatorID == VERTINT && IS_NOT_EQUAL(layer_thickness, 1.0) ) farcmul(&vars1[varID], layer_thickness);
-	      if ( (operatorID == VERTMEAN || operatorID == VERTAVG) && IS_NOT_EQUAL(layer_weight, 1.0) )
-		farcmul(&vars1[varID], layer_weight);
-
-	      if ( operfunc == func_std || operfunc == func_var )
-		farmoq(&vars2[varID], vars1[varID]);
+	      if ( lmean && IS_NOT_EQUAL(layer_weight, 1.0) ) farcmul(&vars1[varID], layer_weight);
+
+	      if ( lvarstd )
+                {
+                  if ( IS_NOT_EQUAL(layer_weight, 1.0) )
+                    {
+                      farmoqw(&vars2[varID], vars1[varID], layer_weight);
+                      farcmul(&vars1[varID], layer_weight);
+                    }
+                  else
+                    {
+                      farmoq(&vars2[varID], vars1[varID]);
+                    }
+                }
 
 	      if ( nmiss > 0 || samp1[varID].ptr || needWeights )
 		{
 		  if ( samp1[varID].ptr == NULL )
-		    samp1[varID].ptr = (double *) malloc(gridsize*sizeof(double));
+		    samp1[varID].ptr = (double *) Malloc(gridsize*sizeof(double));
 
 		  for ( i = 0; i < gridsize; i++ )
 		    if ( DBL_IS_EQUAL(vars1[varID].ptr[i], vars1[varID].missval) )
@@ -354,14 +374,13 @@ void *Vertstat(void *argument)
 	      field.missval = vars1[varID].missval;
 
 	      if ( operatorID == VERTINT && IS_NOT_EQUAL(layer_thickness, 1.0) ) farcmul(&field, layer_thickness);
-	      if ( (operatorID == VERTMEAN || operatorID == VERTAVG) && IS_NOT_EQUAL(layer_weight, 1.0) )
-		 farcmul(&field, layer_weight);
+	      if ( lmean && IS_NOT_EQUAL(layer_weight, 1.0) ) farcmul(&field, layer_weight);
 
 	      if ( field.nmiss > 0 || samp1[varID].ptr )
 		{
 		  if ( samp1[varID].ptr == NULL )
 		    {
-		      samp1[varID].ptr = (double*) malloc(gridsize*sizeof(double));
+		      samp1[varID].ptr = (double*) Malloc(gridsize*sizeof(double));
 		      for ( i = 0; i < gridsize; i++ )
 			samp1[varID].ptr[i] = vars1[varID].nsamp;
 		    }
@@ -371,10 +390,18 @@ void *Vertstat(void *argument)
 		      samp1[varID].ptr[i] += layer_weight;
 		}
 
-	      if ( operfunc == func_std || operfunc == func_var )
+	      if ( lvarstd )
 		{
-		  farsumq(&vars2[varID], field);
-		  farsum(&vars1[varID], field);
+                  if ( IS_NOT_EQUAL(layer_weight, 1.0) )
+                    {
+                      farsumqw(&vars2[varID], field, layer_weight);
+                      farsumw(&vars1[varID], field, layer_weight);
+                    }
+                  else
+                    {
+                      farsumq(&vars2[varID], field);
+                      farsum(&vars1[varID], field);
+                    }
 		}
 	      else
 		{
@@ -387,29 +414,28 @@ void *Vertstat(void *argument)
 	{
 	  if ( vars1[varID].nsamp )
 	    {
-	      if ( operfunc == func_mean || operfunc == func_avg )
+	      if ( lmean )
 		{
 		  if ( samp1[varID].ptr == NULL )
-		    farcmul(&vars1[varID], 1.0/vars1[varID].nsamp);
+		    farcdiv(&vars1[varID], (double)vars1[varID].nsamp);
 		  else
 		    fardiv(&vars1[varID], samp1[varID]);
 		}
-	      else if ( operfunc == func_std || operfunc == func_var )
+	      else if ( lvarstd )
 		{
 		  if ( samp1[varID].ptr == NULL )
 		    {
-		      if ( operfunc == func_std )
-			farcstd(&vars1[varID], vars2[varID], 1.0/vars1[varID].nsamp);
+		      if ( lstd )
+			farcstd(&vars1[varID], vars2[varID], vars1[varID].nsamp, divisor);
 		      else
-			farcvar(&vars1[varID], vars2[varID], 1.0/vars1[varID].nsamp);
+			farcvar(&vars1[varID], vars2[varID], vars1[varID].nsamp, divisor);
 		    }
 		  else
 		    {
-		      farinv(&samp1[varID]);
-		      if ( operfunc == func_std )
-			farstd(&vars1[varID], vars2[varID], samp1[varID]);
+		      if ( lstd )
+			farstd(&vars1[varID], vars2[varID], samp1[varID], divisor);
 		      else
-			farvar(&vars1[varID], vars2[varID], samp1[varID]);
+			farvar(&vars1[varID], vars2[varID], samp1[varID], divisor);
 		    }
 		}
 
@@ -424,20 +450,20 @@ void *Vertstat(void *argument)
 
   for ( varID = 0; varID < nvars; varID++ )
     {
-      free(vars1[varID].ptr);
-      if ( samp1[varID].ptr ) free(samp1[varID].ptr);
-      if ( operfunc == func_std || operfunc == func_var ) free(vars2[varID].ptr);
+      Free(vars1[varID].ptr);
+      if ( samp1[varID].ptr ) Free(samp1[varID].ptr);
+      if ( lvarstd ) Free(vars2[varID].ptr);
     }
 
-  free(vars1);
-  free(samp1);
-  if ( operfunc == func_std || operfunc == func_var ) free(vars2);
+  Free(vars1);
+  Free(samp1);
+  if ( lvarstd ) Free(vars2);
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
   if ( needWeights )
     for ( int index = 0; index < nzaxis; ++index )
-      if ( vert[index].numlevel > 1 )  free(vert[index].weights);
+      if ( vert[index].numlevel > 1 )  Free(vert[index].weights);
 
   streamClose(streamID2);
   streamClose(streamID1);
@@ -446,5 +472,5 @@ void *Vertstat(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Vertwind.c b/src/Vertwind.c
index 692dd38..92c2419 100644
--- a/src/Vertwind.c
+++ b/src/Vertwind.c
@@ -45,8 +45,8 @@ void *Vertwind(void *argument)
   int gridsize, i;
   int offset;
   int nmiss, nmiss_out;
-  int temp_code, sq_code, ps_code, omega_code, lsp_code;
-  int tempID = -1, sqID = -1, psID = -1, omegaID = -1, lnpsID = -1;
+  int temp_code, sq_code, ps_code, omega_code;
+  int tempID = -1, sqID = -1, psID = -1, omegaID = -1;
   char varname[CDI_MAX_NAME];
   double *vct = NULL;
   double tv, rho;
@@ -61,13 +61,12 @@ void *Vertwind(void *argument)
 
   int vlistID1 = streamInqVlist(streamID1);
 
-  int ngp = vlist_check_gridsize(vlistID1);
+  vlist_check_gridsize(vlistID1);
 
   temp_code  = 130;
   sq_code    = 133;
   ps_code    = 134;
   omega_code = 135;
-  lsp_code   = 152;
 
   nvars = vlistNvars(vlistID1);
   for ( varID = 0; varID < nvars; ++varID )
@@ -89,14 +88,12 @@ void *Vertwind(void *argument)
 	  else if ( strcmp(varname, "sq")    == 0 ) code = 133;
 	  else if ( strcmp(varname, "aps")   == 0 ) code = 134;
 	  else if ( strcmp(varname, "omega") == 0 ) code = 135;
-	  else if ( strcmp(varname, "lsp")   == 0 ) code = 152;
 	}
 
       if      ( code == temp_code  ) tempID  = varID;
       else if ( code == sq_code    ) sqID    = varID;
       else if ( code == ps_code    ) psID    = varID;
       else if ( code == omega_code ) omegaID = varID;
-      else if ( code == lsp_code   ) lnpsID  = varID;
     }
 
   if ( tempID == -1 || sqID == -1 || omegaID == -1 )
@@ -121,14 +118,14 @@ void *Vertwind(void *argument)
 
   gridsize = gridInqSize(gridID);
   nlevel = zaxisInqSize(zaxisID);
-  level  = (double*) malloc(nlevel*sizeof(double));
+  level  = (double*) Malloc(nlevel*sizeof(double));
   zaxisInqLevels(zaxisID, level);
 
-  temp    = (double*) malloc(gridsize*nlevel*sizeof(double));
-  sq      = (double*) malloc(gridsize*nlevel*sizeof(double));
-  omega   = (double*) malloc(gridsize*nlevel*sizeof(double));
-  wms     = (double*) malloc(gridsize*nlevel*sizeof(double));
-  fpress  = (double*) malloc(gridsize*nlevel*sizeof(double));
+  temp    = (double*) Malloc(gridsize*nlevel*sizeof(double));
+  sq      = (double*) Malloc(gridsize*nlevel*sizeof(double));
+  omega   = (double*) Malloc(gridsize*nlevel*sizeof(double));
+  wms     = (double*) Malloc(gridsize*nlevel*sizeof(double));
+  fpress  = (double*) Malloc(gridsize*nlevel*sizeof(double));
 
 
   if ( zaxisInqType(zaxisID) == ZAXIS_PRESSURE )
@@ -142,13 +139,13 @@ void *Vertwind(void *argument)
     }
   else if ( zaxisInqType(zaxisID) == ZAXIS_HYBRID )
     {
-      ps_prog = (double*) malloc(gridsize*sizeof(double));
-      hpress  = (double*) malloc(gridsize*(nlevel+1)*sizeof(double));
+      ps_prog = (double*) Malloc(gridsize*sizeof(double));
+      hpress  = (double*) Malloc(gridsize*(nlevel+1)*sizeof(double));
   
       nvct = zaxisInqVctSize(zaxisID);
       if ( nlevel == (nvct/2 - 1) )
 	{
-	  vct = (double*) malloc(nvct*sizeof(double));
+	  vct = (double*) Malloc(nvct*sizeof(double));
 	  zaxisInqVct(zaxisID, vct);
 	}
       else
@@ -258,19 +255,19 @@ void *Vertwind(void *argument)
  
   vlistDestroy(vlistID2);
 
-  free(temp);
-  free(sq);
-  free(omega);
-  free(wms);
-  free(fpress);
+  Free(temp);
+  Free(sq);
+  Free(omega);
+  Free(wms);
+  Free(fpress);
 
-  if ( ps_prog ) free(ps_prog);
-  if ( hpress )  free(hpress);
-  if ( vct ) free(vct);
+  if ( ps_prog ) Free(ps_prog);
+  if ( hpress )  Free(hpress);
+  if ( vct ) Free(vct);
 
-  free(level);
+  Free(level);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Wct.c b/src/Wct.c
index 53a2557..306e3a2 100755
--- a/src/Wct.c
+++ b/src/Wct.c
@@ -112,8 +112,8 @@ void *Wct(void *argument)
   field_init(&field1);
   field_init(&field2);
 
-  field1.ptr = (double*) malloc(gridsize*sizeof(double));
-  field2.ptr = (double*) malloc(gridsize*sizeof(double));
+  field1.ptr = (double*) Malloc(gridsize*sizeof(double));
+  field2.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   if ( cdoVerbose )
     cdoPrint("Number of timesteps: file1 %d, file2 %d", vlistNtsteps(vlistID1), vlistNtsteps(vlistID2));
@@ -181,10 +181,10 @@ void *Wct(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( field1.ptr ) free(field1.ptr);
-  if ( field2.ptr ) free(field2.ptr);
+  if ( field1.ptr ) Free(field1.ptr);
+  if ( field2.ptr ) Free(field2.ptr);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Wind.c b/src/Wind.c
index 17a95c5..8b1c2ab 100644
--- a/src/Wind.c
+++ b/src/Wind.c
@@ -304,19 +304,19 @@ void *Wind(void *argument)
   streamDefVlist(streamID2, vlistID2);
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array1 = (double*) malloc(gridsize*sizeof(double));
+  array1 = (double*) Malloc(gridsize*sizeof(double));
 
   if ( varID1 != -1 && varID2 != -1 )
     {
       nlev     = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID1));
 
       gridsize = gridInqSize(gridID1);
-      ivar1 = (double*) malloc(nlev*gridsize*sizeof(double));
-      ivar2 = (double*) malloc(nlev*gridsize*sizeof(double));
+      ivar1 = (double*) Malloc(nlev*gridsize*sizeof(double));
+      ivar2 = (double*) Malloc(nlev*gridsize*sizeof(double));
   
       gridsize = gridInqSize(gridID2);
-      ovar1 = (double*) malloc(nlev*gridsize*sizeof(double));
-      ovar2 = (double*) malloc(nlev*gridsize*sizeof(double));
+      ovar1 = (double*) Malloc(nlev*gridsize*sizeof(double));
+      ovar2 = (double*) Malloc(nlev*gridsize*sizeof(double));
     }
 
   tsID = 0;
@@ -409,17 +409,17 @@ void *Wind(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array1 ) free(array1);
+  if ( array1 ) Free(array1);
 
-  if ( ivar1 ) free(ivar1);
-  if ( ivar2 ) free(ivar2);
-  if ( ovar1 ) free(ovar1);
-  if ( ovar2 ) free(ovar2);
+  if ( ivar1 ) Free(ivar1);
+  if ( ivar2 ) Free(ivar2);
+  if ( ovar1 ) Free(ovar1);
+  if ( ovar2 ) Free(ovar2);
 
   sptrans_delete(sptrans);
   if ( dvtrans ) dvtrans_delete(dvtrans);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Writegrid.c b/src/Writegrid.c
index bd404f6..0fcfa4c 100644
--- a/src/Writegrid.c
+++ b/src/Writegrid.c
@@ -55,7 +55,7 @@ void *Writegrid(void *argument)
   if ( gridInqXbounds(gridID, NULL) == 0 || gridInqYbounds(gridID, NULL) == 0 )
     cdoAbort("Grid corner missing!");
 
-  mask = (int*) malloc(gridsize*sizeof(int));
+  mask = (int*) Malloc(gridsize*sizeof(int));
 
   if ( gridInqMask(gridID, NULL) )
     {
@@ -70,9 +70,9 @@ void *Writegrid(void *argument)
 
   streamClose(streamID);
 
-  if ( mask ) free(mask);
+  if ( mask ) Free(mask);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Writerandom.c b/src/Writerandom.c
index 9e1c5d2..528bd76 100644
--- a/src/Writerandom.c
+++ b/src/Writerandom.c
@@ -62,11 +62,11 @@ void *Writerandom(void *argument)
 
       streamDefTimestep(streamID2, tsID);
 
-      recdata    = (double**) malloc(nrecs*sizeof(double*));
-      recvarID   = (int*) malloc(nrecs*sizeof(int));
-      reclevelID = (int*) malloc(nrecs*sizeof(int));
-      recnmiss   = (int*) malloc(nrecs*sizeof(int));
-      recindex   = (int*) malloc(nrecs*sizeof(int));
+      recdata    = (double**) Malloc(nrecs*sizeof(double*));
+      recvarID   = (int*) Malloc(nrecs*sizeof(int));
+      reclevelID = (int*) Malloc(nrecs*sizeof(int));
+      recnmiss   = (int*) Malloc(nrecs*sizeof(int));
+      recindex   = (int*) Malloc(nrecs*sizeof(int));
 
       for ( recID = 0; recID < nrecs; recID++ )
 	{
@@ -74,7 +74,7 @@ void *Writerandom(void *argument)
 	  gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
 	  recvarID[recID] = varID;
 	  reclevelID[recID] = levelID;
-	  recdata[recID] = (double*) malloc(gridsize*sizeof(double));
+	  recdata[recID] = (double*) Malloc(gridsize*sizeof(double));
 	  streamReadRecord(streamID1, recdata[recID], &recnmiss[recID]);
 	}
 
@@ -114,13 +114,13 @@ void *Writerandom(void *argument)
 	  streamWriteRecord(streamID2, recdata[rindex], recnmiss[rindex]);
 	}
 
-      for ( recID = 0; recID < nrecs; recID++ ) free(recdata[recID]);
+      for ( recID = 0; recID < nrecs; recID++ ) Free(recdata[recID]);
 
-      free(recdata);
-      free(recvarID);
-      free(reclevelID);
-      free(recnmiss);
-      free(recindex);
+      Free(recdata);
+      Free(recvarID);
+      Free(reclevelID);
+      Free(recnmiss);
+      Free(recindex);
 
       tsID++;
     }
@@ -130,5 +130,5 @@ void *Writerandom(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/XTimstat.c b/src/XTimstat.c
new file mode 100644
index 0000000..d87a9cf
--- /dev/null
+++ b/src/XTimstat.c
@@ -0,0 +1,539 @@
+/*
+  This file is part of CDO. CDO is a collection of Operators to
+  manipulate and analyse Climate model Data.
+
+  Copyright (C) 2003-2015 Uwe Schulzweida, <uwe.schulzweida AT mpimet.mpg.de>
+  See COPYING file for copying and redistribution conditions.
+
+  This program is free software; you can redistribute it and/or modify
+  it under the terms of the GNU General Public License as published by
+  the Free Software Foundation; version 2 of the License.
+
+  This program is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  GNU General Public License for more details.
+*/
+
+/*
+   This module contains the following operators:
+
+      Timstat    timmin          Time minimum
+      Timstat    timmax          Time maximum
+      Timstat    timsum          Time sum
+      Timstat    timmean         Time mean
+      Timstat    timavg          Time average
+      Timstat    timvar          Time variance
+      Timstat    timvar1         Time variance [Divisor is (n-1)]
+      Timstat    timstd          Time standard deviation
+      Timstat    timstd1         Time standard deviation [Divisor is (n-1)]
+      Hourstat   hourmin         Hourly minimum
+      Hourstat   hourmax         Hourly maximum
+      Hourstat   hoursum         Hourly sum
+      Hourstat   hourmean        Hourly mean
+      Hourstat   houravg         Hourly average
+      Hourstat   hourvar         Hourly variance
+      Hourstat   hourvar1        Hourly variance [Divisor is (n-1)]
+      Hourstat   hourstd         Hourly standard deviation
+      Hourstat   hourstd1        Hourly standard deviation [Divisor is (n-1)]
+      Daystat    daymin          Daily minimum
+      Daystat    daymax          Daily maximum
+      Daystat    daysum          Daily sum
+      Daystat    daymean         Daily mean
+      Daystat    dayavg          Daily average
+      Daystat    dayvar          Daily variance
+      Daystat    dayvar1         Daily variance [Divisor is (n-1)]
+      Daystat    daystd          Daily standard deviation
+      Daystat    daystd1         Daily standard deviation [Divisor is (n-1)]
+      Monstat    monmin          Monthly minimum
+      Monstat    monmax          Monthly maximum
+      Monstat    monsum          Monthly sum
+      Monstat    monmean         Monthly mean
+      Monstat    monavg          Monthly average
+      Monstat    monvar          Monthly variance
+      Monstat    monvar1         Monthly variance [Divisor is (n-1)]
+      Monstat    monstd          Monthly standard deviation
+      Monstat    monstd1         Monthly standard deviation [Divisor is (n-1)]
+      Yearstat   yearmin         Yearly minimum
+      Yearstat   yearmax         Yearly maximum
+      Yearstat   yearsum         Yearly sum
+      Yearstat   yearmean        Yearly mean
+      Yearstat   yearavg         Yearly average
+      Yearstat   yearvar         Yearly variance
+      Yearstat   yearvar1        Yearly variance [Divisor is (n-1)]
+      Yearstat   yearstd         Yearly standard deviation
+      Yearstat   yearstd1        Yearly standard deviation [Divisor is (n-1)]
+*/
+
+
+#include <cdi.h>
+#include "cdo.h"
+#include "cdo_int.h"
+#include "cdo_task.h"
+//#include "pstream.h"
+#include "pstream_write.h"
+
+
+typedef struct {
+  int tsIDnext;
+  int streamID, nrecs;
+  field_t **vars;
+}
+readarg_t;
+
+static int num_recs = 0;
+
+static
+void *cdoReadTimestep(void *rarg)
+{
+  int varID, levelID, nmiss;
+  readarg_t *readarg = (readarg_t *) rarg;
+  field_t **input_vars = readarg->vars;
+  int streamID = readarg->streamID;
+  int tsIDnext = readarg->tsIDnext;
+  int nrecs = readarg->nrecs;
+
+  for ( int recID = 0; recID < nrecs; ++recID )
+    {
+      streamInqRecord(streamID, &varID, &levelID);
+      streamReadRecord(streamID, input_vars[varID][levelID].ptr2, &nmiss);
+      input_vars[varID][levelID].nmiss2 = nmiss;
+    }
+
+  num_recs = streamInqTimestep(streamID, tsIDnext);
+
+  return ((void *) &num_recs);
+}
+
+static
+void cdoUpdateVars(int nvars, int vlistID, field_t **vars)
+{
+  for ( int varID = 0; varID < nvars; varID++ )
+    {
+      int nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID, varID));
+      for ( int levelID = 0; levelID < nlevels; levelID++ )
+        {
+          double *tmp = vars[varID][levelID].ptr;
+          vars[varID][levelID].ptr   = vars[varID][levelID].ptr2;
+          vars[varID][levelID].ptr2  = tmp;
+          vars[varID][levelID].nmiss = vars[varID][levelID].nmiss2;
+        }
+    }
+}
+
+
+void *XTimstat(void *argument)
+{
+  int timestat_date = TIMESTAT_MEAN;
+  int gridsize;
+  int vdate = 0, vtime = 0;
+  int vdate0 = 0, vtime0 = 0;
+  int nrecs;
+  int varID, levelID;
+  long nsets;
+  int i;
+  int streamID3 = -1;
+  int vlistID3, taxisID3 = -1;
+  int nmiss;
+  int nlevels;
+  int lvfrac = FALSE;
+  int nwpv; // number of words per value; real:1  complex:2
+  char indate1[DATE_LEN+1], indate2[DATE_LEN+1];
+  double vfrac = 1;
+  double missval;
+
+  cdoInitialize(argument);
+
+  cdoOperatorAdd("xtimmin",    func_min,  DATE_LEN, NULL);
+  cdoOperatorAdd("xtimmax",    func_max,  DATE_LEN, NULL);
+  cdoOperatorAdd("xtimsum",    func_sum,  DATE_LEN, NULL);
+  cdoOperatorAdd("xtimmean",   func_mean, DATE_LEN, NULL);
+  cdoOperatorAdd("xtimavg",    func_avg,  DATE_LEN, NULL);
+  cdoOperatorAdd("xtimvar",    func_var,  DATE_LEN, NULL);
+  cdoOperatorAdd("xtimvar1",   func_var1, DATE_LEN, NULL);
+  cdoOperatorAdd("xtimstd",    func_std,  DATE_LEN, NULL);
+  cdoOperatorAdd("xtimstd1",   func_std1, DATE_LEN, NULL);
+  cdoOperatorAdd("xyearmin",   func_min,  10, NULL);
+  cdoOperatorAdd("xyearmax",   func_max,  10, NULL);
+  cdoOperatorAdd("xyearsum",   func_sum,  10, NULL);
+  cdoOperatorAdd("xyearmean",  func_mean, 10, NULL);
+  cdoOperatorAdd("xyearavg",   func_avg,  10, NULL);
+  cdoOperatorAdd("xyearvar",   func_var,  10, NULL);
+  cdoOperatorAdd("xyearvar1",  func_var1, 10, NULL);
+  cdoOperatorAdd("xyearstd",   func_std,  10, NULL);
+  cdoOperatorAdd("xyearstd1",  func_std1, 10, NULL);
+  cdoOperatorAdd("xmonmin",    func_min,   8, NULL);
+  cdoOperatorAdd("xmonmax",    func_max,   8, NULL);
+  cdoOperatorAdd("xmonsum",    func_sum,   8, NULL);
+  cdoOperatorAdd("xmonmean",   func_mean,  8, NULL);
+  cdoOperatorAdd("xmonavg",    func_avg,   8, NULL);
+  cdoOperatorAdd("xmonvar",    func_var,   8, NULL);
+  cdoOperatorAdd("xmonvar1",   func_var1,  8, NULL);
+  cdoOperatorAdd("xmonstd",    func_std,   8, NULL);
+  cdoOperatorAdd("xmonstd1",   func_std1,  8, NULL);
+
+  int operatorID = cdoOperatorID();
+  int operfunc   = cdoOperatorF1(operatorID);
+  int comparelen = cdoOperatorF2(operatorID);
+
+  int lmean   = operfunc == func_mean || operfunc == func_avg;
+  int lstd    = operfunc == func_std || operfunc == func_std1;
+  int lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
+  double divisor = operfunc == func_std1 || operfunc == func_var1;
+
+  if ( operfunc == func_mean )
+    {
+      int oargc = operatorArgc();
+      char **oargv = operatorArgv();
+
+      if ( oargc == 1 )
+	{
+	  lvfrac = TRUE;
+	  vfrac = atof(oargv[0]);
+	  if ( cdoVerbose ) cdoPrint("Set vfrac to %g", vfrac);
+	  if ( vfrac < 0 || vfrac > 1 ) cdoAbort("vfrac out of range!");
+	}
+      else if ( oargc > 1 )
+	cdoAbort("Too many arguments!");
+    }
+
+  int cmplen = DATE_LEN - comparelen;
+
+  // int streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0)->args);
+
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
+
+  if ( cmplen == 0 ) vlistDefNtsteps(vlistID2, 1);
+
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
+  if ( taxisInqType(taxisID2) == TAXIS_FORECAST ) taxisDefType(taxisID2, TAXIS_RELATIVE);
+  vlistDefTaxis(vlistID2, taxisID2);
+
+  int nvars = vlistNvars(vlistID1);
+
+  if ( cmplen == 0 && CDO_Reduce_Dim )
+    for ( varID = 0; varID < nvars; ++varID )
+      vlistDefVarTsteptype(vlistID2, varID, TSTEP_CONSTANT);
+
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+
+  streamDefVlist(streamID2, vlistID2);
+
+  if ( cdoDiag )
+    {
+      char filename[8192];
+
+      strcpy(filename, cdoOperatorName(operatorID));
+      strcat(filename, "_");
+      strcat(filename, cdoStreamName(1)->args);
+      argument_t *fileargument = file_argument_new(filename);
+      streamID3 = streamOpenWrite(fileargument, cdoFiletype());
+      file_argument_free(fileargument);
+
+      vlistID3 = vlistDuplicate(vlistID1);
+
+      for ( varID = 0; varID < nvars; ++varID )
+	{
+	  vlistDefVarDatatype(vlistID3, varID, DATATYPE_INT32);
+	  vlistDefVarMissval(vlistID3, varID, -1);
+	  vlistDefVarUnits(vlistID3, varID, "");
+	  vlistDefVarAddoffset(vlistID3, varID, 0);
+	  vlistDefVarScalefactor(vlistID3, varID, 1);
+	}
+
+      taxisID3 = taxisDuplicate(taxisID1);
+      vlistDefTaxis(vlistID3, taxisID3);
+
+      streamDefVlist(streamID3, vlistID3);
+    }
+
+  dtlist_type *dtlist = dtlist_new();
+  dtlist_set_stat(dtlist, timestat_date);
+  dtlist_set_calendar(dtlist, taxisInqCalendar(taxisID1));
+
+  gridsize = vlistGridsizeMax(vlistID1);
+  if ( vlistNumber(vlistID1) != CDI_REAL ) gridsize *= 2;
+
+  field_t **input_vars = field_malloc(vlistID1, FIELD_PTR | FIELD_PTR2);
+  field_t **vars1 = field_malloc(vlistID1, FIELD_PTR);
+  field_t **samp1 = field_malloc(vlistID1, FIELD_NONE);
+  field_t **vars2 = NULL;
+  if ( lvarstd ) vars2 = field_malloc(vlistID1, FIELD_PTR);
+
+  readarg_t readarg;
+  readarg.streamID = streamID1;
+  readarg.vars = input_vars;
+
+  int lparallelread = TRUE;
+  int ltsfirst = TRUE;
+  void *read_task = NULL;
+  void *readresult = NULL;
+
+  if ( lparallelread )
+    {
+      read_task = cdo_task_new();
+      if ( read_task == NULL )
+        {
+          lparallelread = FALSE;
+          cdoWarning("CDO tasks not available!");
+        }
+    }
+
+  int tsID  = 0;
+  int otsID = 0;
+  nrecs = streamInqTimestep(streamID1, tsID);
+  tsID++;
+  while ( TRUE )
+    {
+      nsets = 0;
+      while ( nrecs > 0 )
+	{
+	  dtlist_taxisInqTimestep(dtlist, taxisID1, nsets);
+	  vdate = dtlist_get_vdate(dtlist, nsets);
+	  vtime = dtlist_get_vtime(dtlist, nsets);
+
+	  if ( nsets == 0 ) SET_DATE(indate2, vdate, vtime);
+	  SET_DATE(indate1, vdate, vtime);
+
+	  if ( DATE_IS_NEQ(indate1, indate2, cmplen) ) break;
+
+          readarg.tsIDnext = tsID;
+          readarg.nrecs = nrecs;
+
+          if ( ltsfirst || lparallelread  == FALSE )
+            {
+              if ( lparallelread )
+                {
+                  cdo_task_start(read_task, cdoReadTimestep, &readarg);
+                }
+              else
+                {
+                  readresult = cdoReadTimestep(&readarg);
+                }
+              
+              if ( lparallelread )
+                {
+                  readresult = cdo_task_wait(read_task);
+                }
+              ltsfirst = FALSE;
+            }
+          else
+            {
+              readresult = cdo_task_wait(read_task);
+            }
+          
+          nrecs = *(int *)readresult;
+
+          cdoUpdateVars(nvars, vlistID1, input_vars);
+
+          if ( nrecs && lparallelread )
+            {
+              readarg.tsIDnext = tsID+1;
+              cdo_task_start(read_task, cdoReadTimestep, &readarg);
+            }
+
+          for ( varID = 0; varID < nvars; varID++ )
+            {
+              nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
+              for ( levelID = 0; levelID < nlevels; levelID++ )
+                {
+                  nwpv     = vars1[varID][levelID].nwpv;
+                  gridsize = gridInqSize(vars1[varID][levelID].grid);
+
+                  if ( nsets == 0 )
+                    {
+                      memcpy(vars1[varID][levelID].ptr, input_vars[varID][levelID].ptr, nwpv*gridsize*sizeof(double));
+                      nmiss = input_vars[varID][levelID].nmiss;
+                      vars1[varID][levelID].nmiss = nmiss;
+                      if ( nmiss > 0 || samp1[varID][levelID].ptr )
+                        {
+                          if ( samp1[varID][levelID].ptr == NULL )
+                            samp1[varID][levelID].ptr = (double*) Malloc(nwpv*gridsize*sizeof(double));
+
+                          for ( i = 0; i < nwpv*gridsize; i++ )
+                            if ( DBL_IS_EQUAL(vars1[varID][levelID].ptr[i], vars1[varID][levelID].missval) )
+                              samp1[varID][levelID].ptr[i] = 0;
+                            else
+                              samp1[varID][levelID].ptr[i] = 1;
+                        }
+                    }
+                  else
+                    {
+                      nmiss = input_vars[varID][levelID].nmiss;
+                      if ( nmiss > 0 || samp1[varID][levelID].ptr )
+                        {
+                          if ( samp1[varID][levelID].ptr == NULL )
+                            {
+                              samp1[varID][levelID].ptr = (double*) Malloc(nwpv*gridsize*sizeof(double));
+                              for ( i = 0; i < nwpv*gridsize; i++ )
+                                samp1[varID][levelID].ptr[i] = nsets;
+                            }
+                          
+                          for ( i = 0; i < nwpv*gridsize; i++ )
+                            if ( !DBL_IS_EQUAL(input_vars[varID][levelID].ptr[i], vars1[varID][levelID].missval) )
+                              samp1[varID][levelID].ptr[i]++;
+                        }
+                  
+                      if ( lvarstd )
+                        {
+                          farsumq(&vars2[varID][levelID], input_vars[varID][levelID]);
+                          farsum(&vars1[varID][levelID], input_vars[varID][levelID]);
+                        }
+                      else
+                        {
+                          farfun(&vars1[varID][levelID], input_vars[varID][levelID], operfunc);
+                        }
+                    }
+		}
+	    }
+
+	  if ( nsets == 0 && lvarstd )
+	    for ( varID = 0; varID < nvars; varID++ )
+	      {
+		if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
+		nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
+		for ( levelID = 0; levelID < nlevels; levelID++ )
+		  farmoq(&vars2[varID][levelID], vars1[varID][levelID]);
+	      }
+
+	  vdate0 = vdate;
+	  vtime0 = vtime;
+	  nsets++;
+	  tsID++;
+	}
+
+      if ( nrecs == 0 && nsets == 0 ) break;
+
+      if ( lmean )
+	for ( varID = 0; varID < nvars; varID++ )
+	  {
+	    if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
+	    nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
+	    for ( levelID = 0; levelID < nlevels; levelID++ )
+	      {
+		if ( samp1[varID][levelID].ptr == NULL )
+		  farcdiv(&vars1[varID][levelID], (double)nsets);
+		else
+                  {
+                    //   farround(&samp1[varID][levelID]); not necessary
+                    fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
+                  }
+              }
+	  }
+      else if ( lvarstd )
+	for ( varID = 0; varID < nvars; varID++ )
+	  {
+	    if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
+	    nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
+	    for ( levelID = 0; levelID < nlevels; levelID++ )
+	      {
+		if ( samp1[varID][levelID].ptr == NULL )
+		  {
+		    if ( lstd )
+		      farcstd(&vars1[varID][levelID], vars2[varID][levelID], nsets, divisor);
+		    else
+		      farcvar(&vars1[varID][levelID], vars2[varID][levelID], nsets, divisor);
+		  }
+		else
+		  {
+		    if ( lstd )
+		      farstd(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID], divisor);
+		    else
+		      farvar(&vars1[varID][levelID], vars2[varID][levelID], samp1[varID][levelID], divisor);
+		  }
+	      }
+	  }
+
+      if ( cdoVerbose )
+	{
+	  char vdatestr[32], vtimestr[32];
+	  date2str(vdate0, vdatestr, sizeof(vdatestr));
+	  time2str(vtime0, vtimestr, sizeof(vtimestr));
+	  cdoPrint("%s %s  vfrac = %g, nsets = %d", vdatestr, vtimestr, vfrac, nsets);
+	}
+
+      if ( lvfrac && operfunc == func_mean )
+	for ( varID = 0; varID < nvars; varID++ )
+	  {
+	    if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
+	    nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
+	    for ( levelID = 0; levelID < nlevels; levelID++ )
+	      {
+                nwpv     = vars1[varID][levelID].nwpv;
+                gridsize = gridInqSize(vars1[varID][levelID].grid);
+		missval  = vars1[varID][levelID].missval;
+		if ( samp1[varID][levelID].ptr )
+		  {
+		    int irun = 0;
+		    for ( i = 0; i < nwpv*gridsize; ++i )
+		      {
+			if ( (samp1[varID][levelID].ptr[i] / nsets) < vfrac )
+			  {
+			    vars1[varID][levelID].ptr[i] = missval;
+			    irun++;
+			  }
+		      }
+
+		    if ( irun )
+		      {
+			nmiss = 0;
+			for ( i = 0; i < nwpv*gridsize; ++i )
+			  if ( DBL_IS_EQUAL(vars1[varID][levelID].ptr[i], missval) ) nmiss++;
+			vars1[varID][levelID].nmiss = nmiss;
+		      }
+		  }
+	      }
+	  }
+
+      dtlist_stat_taxisDefTimestep(dtlist, taxisID2, nsets);
+      streamDefTimestep(streamID2, otsID);
+
+      if ( cdoDiag )
+	{
+	  dtlist_stat_taxisDefTimestep(dtlist, taxisID3, nsets);
+	  streamDefTimestep(streamID3, otsID);
+	}
+
+      for ( varID = 0; varID < nvars; ++varID )
+	{
+	  if ( otsID && vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
+
+          nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
+          for ( levelID = 0; levelID < nlevels; ++ levelID )
+            {
+              streamDefRecord(streamID2, varID, levelID);
+              streamWriteRecord(streamID2, vars1[varID][levelID].ptr,  vars1[varID][levelID].nmiss);
+              if ( cdoDiag )
+                {
+                  if ( samp1[varID][levelID].ptr )
+                    {
+                      streamDefRecord(streamID3, varID, levelID);
+                      streamWriteRecord(streamID3, samp1[varID][levelID].ptr, 0);
+                    }
+                }
+            }
+	}
+
+      if ( nrecs == 0 ) break;
+      otsID++;
+    }
+
+
+  field_free(input_vars, vlistID1);
+  field_free(vars1, vlistID1);
+  field_free(samp1, vlistID1);
+  if ( lvarstd ) field_free(vars2, vlistID1);
+
+  dtlist_delete(dtlist);
+
+  if ( cdoDiag ) pstreamClose(streamID3);
+  pstreamClose(streamID2);
+  streamClose(streamID1);
+
+  cdoFinish();
+
+  return 0;
+}
diff --git a/src/YAR.c b/src/YAR.c
index ff8e09a..6869fa1 100644
--- a/src/YAR.c
+++ b/src/YAR.c
@@ -217,15 +217,15 @@ void yar_remap_bil(field_t *field1, field_t *field2)
   nlonIn = gridInqXsize(gridIDin);
   nlatIn = gridInqYsize(gridIDin);
   gridsize1 = gridInqSize(gridIDin);
-  lonIn = (double*) malloc(nlonIn*sizeof(double));
-  latIn = (double*) malloc(nlatIn*sizeof(double));
+  lonIn = (double*) Malloc(nlonIn*sizeof(double));
+  latIn = (double*) Malloc(nlatIn*sizeof(double));
   gridInqXvals(gridIDin, lonIn);
   gridInqYvals(gridIDin, latIn);
   for ( int i = 0; i < nlonIn; ++i ) lonIn[i] *= DEG2RAD;
   for ( int i = 0; i < nlatIn; ++i ) latIn[i] *= DEG2RAD;
 
-  xlonIn = (double*) malloc((nlonIn+1)*sizeof(double));
-  xlatIn = (double*) malloc((nlatIn+1)*sizeof(double));
+  xlonIn = (double*) Malloc((nlonIn+1)*sizeof(double));
+  xlatIn = (double*) Malloc((nlatIn+1)*sizeof(double));
   gridInqXvals(gridIDin, xlonIn);
   gridInqYvals(gridIDin, xlatIn);
   dxIn = xlonIn[1] - xlonIn[0];
@@ -242,15 +242,15 @@ void yar_remap_bil(field_t *field1, field_t *field2)
   nlonOut = gridInqXsize(gridIDout);
   nlatOut = gridInqYsize(gridIDout);
   gridsize2 = gridInqSize(gridIDout);
-  lonOut = (double*) malloc(nlonOut*sizeof(double));
-  latOut = (double*) malloc(nlatOut*sizeof(double));
+  lonOut = (double*) Malloc(nlonOut*sizeof(double));
+  latOut = (double*) Malloc(nlatOut*sizeof(double));
   gridInqXvals(gridIDout, lonOut);
   gridInqYvals(gridIDout, latOut);
   for ( int i = 0; i < nlonOut; ++i ) lonOut[i] *= DEG2RAD;
   for ( int i = 0; i < nlatOut; ++i ) latOut[i] *= DEG2RAD;
 
-  xlonOut = (double*) malloc((nlonOut+1)*sizeof(double));
-  xlatOut = (double*) malloc((nlatOut+1)*sizeof(double));
+  xlonOut = (double*) Malloc((nlonOut+1)*sizeof(double));
+  xlatOut = (double*) Malloc((nlatOut+1)*sizeof(double));
   gridInqXvals(gridIDout, xlonOut);
   gridInqYvals(gridIDout, xlatOut);
   dxOut = xlonOut[1] - xlonOut[0];
@@ -413,7 +413,7 @@ void yar_remap_bil(field_t *field1, field_t *field2)
 
   field2->nmiss = nmiss;
 
-  // if (array) free(array);
+  // if (array) Free(array);
   //free(lonIn);
   //free(latIn);
   //free(lonOut);
@@ -466,12 +466,12 @@ void yar_remap_con(field_t *field1, field_t *field2)
   nlonIn = gridInqXsize(gridIDin);
   nlatIn = gridInqYsize(gridIDin);
   gridsize1 = gridInqSize(gridIDin);
-  lonIn = (double*) malloc((nlonIn+1)*sizeof(double));
-  latIn = (double*) malloc((nlatIn+1)*sizeof(double));
+  lonIn = (double*) Malloc((nlonIn+1)*sizeof(double));
+  latIn = (double*) Malloc((nlatIn+1)*sizeof(double));
   gridInqXvals(gridIDin, lonIn);
   gridInqYvals(gridIDin, latIn);
-  xlonIn = (double*) malloc((nlonIn)*sizeof(double));
-  xlatIn = (double*) malloc((nlatIn)*sizeof(double));
+  xlonIn = (double*) Malloc((nlonIn)*sizeof(double));
+  xlatIn = (double*) Malloc((nlatIn)*sizeof(double));
   gridInqXvals(gridIDin, xlonIn);
   gridInqYvals(gridIDin, xlatIn);
   dxIn = lonIn[1] - lonIn[0];
@@ -488,12 +488,12 @@ void yar_remap_con(field_t *field1, field_t *field2)
   nlonOut = gridInqXsize(gridIDout);
   nlatOut = gridInqYsize(gridIDout);
   gridsize2 = gridInqSize(gridIDout);
-  lonOut = (double*) malloc((nlonOut+1)*sizeof(double));
-  latOut = (double*) malloc((nlatOut+1)*sizeof(double));
+  lonOut = (double*) Malloc((nlonOut+1)*sizeof(double));
+  latOut = (double*) Malloc((nlatOut+1)*sizeof(double));
   gridInqXvals(gridIDout, lonOut);
   gridInqYvals(gridIDout, latOut);
-  xlonOut = (double*) malloc((nlonOut+1)*sizeof(double));
-  xlatOut = (double*) malloc((nlatOut+1)*sizeof(double));
+  xlonOut = (double*) Malloc((nlonOut+1)*sizeof(double));
+  xlatOut = (double*) Malloc((nlatOut+1)*sizeof(double));
   gridInqXvals(gridIDout, xlonOut);
   gridInqYvals(gridIDout, xlatOut);
   dxOut = lonOut[1] - lonOut[0];
@@ -573,20 +573,20 @@ void yar_remap_con(field_t *field1, field_t *field2)
   double const epsilon = 1.0e-10; // relative precision 
 
   double *weight;
-  weight = (double*) malloc(gridsize1*sizeof(double));
+  weight = (double*) Malloc(gridsize1*sizeof(double));
 
   double tgt_area;
   double *area;
-  area = (double*) malloc(gridsize1*sizeof(double));
+  area = (double*) Malloc(gridsize1*sizeof(double));
 
   struct grid_cell *SourceCell;
-  SourceCell = (struct grid_cell*) malloc(gridsize1  * sizeof(struct grid_cell));
+  SourceCell = (struct grid_cell*) Malloc(gridsize1  * sizeof(struct grid_cell));
 
   for ( int n = 0; n <  gridsize1; n++ ) {
     SourceCell[n].num_corners   = 4;
     SourceCell[n].edge_type     = quad_type;
-    SourceCell[n].coordinates_x = (double*) malloc( 4 * sizeof(double));
-    SourceCell[n].coordinates_y = (double*) malloc( 4 * sizeof(double));
+    SourceCell[n].coordinates_x = (double*) Malloc( 4 * sizeof(double));
+    SourceCell[n].coordinates_y = (double*) Malloc( 4 * sizeof(double));
   }
 
   struct grid_cell  TargetCell;
@@ -594,8 +594,8 @@ void yar_remap_con(field_t *field1, field_t *field2)
   TargetCell.num_corners   = 4;
   TargetCell.edge_type     = quad_type;
 
-  TargetCell.coordinates_x = (double*) malloc( 4 * sizeof(double));
-  TargetCell.coordinates_y = (double*) malloc( 4 * sizeof(double));
+  TargetCell.coordinates_x = (double*) Malloc( 4 * sizeof(double));
+  TargetCell.coordinates_y = (double*) Malloc( 4 * sizeof(double));
 
   unsigned const * curr_deps;
   //struct polygons polygons;
@@ -725,8 +725,8 @@ void yar_remap_con(field_t *field1, field_t *field2)
   delete_grid(source_grid);
   delete_grid(target_grid);
 
-  free(weight);
-  free(area);
+  Free(weight);
+  Free(area);
 
   //free(lonIn);
   //free(latIn);
@@ -806,10 +806,10 @@ void *YAR(void *argument)
   streamDefVlist(streamID2, vlistID2);
 
   gridsize = vlistGridsizeMax(vlistID1);
-  array1   = (double*) malloc(gridsize*sizeof(double));
+  array1   = (double*) Malloc(gridsize*sizeof(double));
 
   gridsize = gridInqSize(gridID2);
-  array2   = (double*) malloc(gridsize*sizeof(double));
+  array2   = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
@@ -852,10 +852,10 @@ void *YAR(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( array2 ) free(array2);
-  if ( array1 ) free(array1);
+  if ( array2 ) Free(array2);
+  if ( array1 ) Free(array1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Ydayarith.c b/src/Ydayarith.c
index 4b0ab8f..aab9042 100644
--- a/src/Ydayarith.c
+++ b/src/Ydayarith.c
@@ -72,8 +72,8 @@ void *Ydayarith(void *argument)
 
   field_init(&field1);
   field_init(&field2);
-  field1.ptr = (double*) malloc(gridsize*sizeof(double));
-  field2.ptr = (double*) malloc(gridsize*sizeof(double));
+  field1.ptr = (double*) Malloc(gridsize*sizeof(double));
+  field2.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   taxisID1 = vlistInqTaxis(vlistID1);
   taxisID2 = vlistInqTaxis(vlistID2);
@@ -99,15 +99,15 @@ void *Ydayarith(void *argument)
 
       if ( vardata2[day] != NULL ) cdoAbort("Day %d already allocatd!", day);
 
-      vardata2[day]  = (double **) malloc(nvars*sizeof(double *));
-      varnmiss2[day] = (int **) malloc(nvars*sizeof(int *));
+      vardata2[day]  = (double **) Malloc(nvars*sizeof(double *));
+      varnmiss2[day] = (int **) Malloc(nvars*sizeof(int *));
 
       for ( varID = 0; varID < nvars; varID++ )
 	{
 	  gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
 	  nlev     = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
-	  vardata2[day][varID]  = (double*) malloc(nlev*gridsize*sizeof(double));
-	  varnmiss2[day][varID] = (int*) malloc(nlev*sizeof(int));
+	  vardata2[day][varID]  = (double*) Malloc(nlev*gridsize*sizeof(double));
+	  varnmiss2[day][varID] = (int*) Malloc(nlev*sizeof(int));
 	}
 
       for ( recID = 0; recID < nrecs; recID++ )
@@ -172,18 +172,18 @@ void *Ydayarith(void *argument)
       {
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
-	    free(vardata2[day][varID]);
-	    free(varnmiss2[day][varID]);
+	    Free(vardata2[day][varID]);
+	    Free(varnmiss2[day][varID]);
 	  }
 
-	free(vardata2[day]);
-	free(varnmiss2[day]);
+        Free(vardata2[day]);
+        Free(varnmiss2[day]);
       }
 
-  if ( field1.ptr ) free(field1.ptr);
-  if ( field2.ptr ) free(field2.ptr);
+  if ( field1.ptr ) Free(field1.ptr);
+  if ( field2.ptr ) Free(field2.ptr);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Ydaypctl.c b/src/Ydaypctl.c
index 78a7bf9..e76b09c 100644
--- a/src/Ydaypctl.c
+++ b/src/Ydaypctl.c
@@ -26,10 +26,11 @@
 #include "cdo.h"
 #include "cdo_int.h"
 #include "pstream.h"
-#include "percentiles.h"
+#include "percentiles_hist.h"
 
 #define  NDAY       373
 
+int getmonthday(int date);
 
 void *Ydaypctl(void *argument)
 {
@@ -53,17 +54,14 @@ void *Ydaypctl(void *argument)
   int vdates2[NDAY], vtimes2[NDAY];
   field_t **vars1[NDAY];
   field_t field;
-  double pn;
   HISTOGRAM_SET *hsets[NDAY];
 
   cdoInitialize(argument);
   cdoOperatorAdd("ydaypctl", func_pctl, 0, NULL);
 
   operatorInputArg("percentile number");
-  pn = parameter2double(operatorArgv()[0]);
-      
-  if ( !(pn > 0 && pn < 100) )
-    cdoAbort("Illegal argument: percentile number %g is not in the range 0..100!", pn);
+  double pn = parameter2double(operatorArgv()[0]);
+  percentile_check_number(pn);
 
   for ( dayoy = 0; dayoy < NDAY; dayoy++ )
     {
@@ -100,12 +98,12 @@ void *Ydaypctl(void *argument)
   nvars    = vlistNvars(vlistID1);
   nrecords = vlistNrecs(vlistID1);
 
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = vlistGridsizeMax(vlistID1);
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID2, tsID)) )
@@ -257,10 +255,10 @@ void *Ydaypctl(void *argument)
 	}
     }
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID4);
   streamClose(streamID3);
@@ -269,5 +267,5 @@ void *Ydaypctl(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Ydaystat.c b/src/Ydaystat.c
index ff9465f..d7edce8 100644
--- a/src/Ydaystat.c
+++ b/src/Ydaystat.c
@@ -40,29 +40,18 @@
 
 void *Ydaystat(void *argument)
 {
-  int operatorID;
-  int operfunc;
-  int gridsize;
   int i;
   int varID;
   int recID;
   int vdate, vtime;
   int year, month, day, dayoy;
-  int nrecs, nrecords;
+  int nrecs;
   int levelID;
-  int tsID;
-  int otsID;
   long nsets[NDAY];
-  int streamID1, streamID2;
-  int vlistID1, vlistID2, taxisID1, taxisID2;
   int nmiss;
-  int nvars, nlevel;
-  int *recVarID, *recLevelID;
+  int nlevel;
   int vdates[NDAY], vtimes[NDAY];
-  int lmean = FALSE, lvarstd = FALSE, lstd = FALSE;
-  double divisor;
   field_t **vars1[NDAY], **vars2[NDAY], **samp1[NDAY];
-  field_t field;
 
   cdoInitialize(argument);
 
@@ -76,13 +65,13 @@ void *Ydaystat(void *argument)
   cdoOperatorAdd("ydaystd",  func_std,  0, NULL);
   cdoOperatorAdd("ydaystd1", func_std1, 0, NULL);
 
-  operatorID = cdoOperatorID();
-  operfunc = cdoOperatorF1(operatorID);
+  int operatorID = cdoOperatorID();
+  int operfunc = cdoOperatorF1(operatorID);
 
-  lmean   = operfunc == func_mean || operfunc == func_avg;
-  lstd    = operfunc == func_std || operfunc == func_std1;
-  lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
-  divisor = operfunc == func_std1 || operfunc == func_var1;
+  int lmean   = operfunc == func_mean || operfunc == func_avg;
+  int lstd    = operfunc == func_std || operfunc == func_std1;
+  int lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
+  double divisor = operfunc == func_std1 || operfunc == func_var1;
 
   for ( dayoy = 0; dayoy < NDAY; dayoy++ )
     {
@@ -92,32 +81,34 @@ void *Ydaystat(void *argument)
       nsets[dayoy] = 0;
     }
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = vlistDuplicate(vlistID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   if ( taxisHasBounds(taxisID2) ) taxisDeleteBounds(taxisID2);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
-  nvars    = vlistNvars(vlistID1);
-  nrecords = vlistNrecs(vlistID1);
+  int nvars    = vlistNvars(vlistID1);
+  int nrecords = vlistNrecs(vlistID1);
+
+  int *recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  int gridsize = vlistGridsizeMax(vlistID1);
 
-  gridsize = vlistGridsizeMax(vlistID1);
+  field_t field;
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
-  tsID = 0;
-  otsID = 0;
+  int tsID = 0;
+  int otsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       vdate = taxisInqVdate(taxisID1);
@@ -166,7 +157,7 @@ void *Ydaystat(void *argument)
 	      if ( nmiss > 0 || samp1[dayoy][varID][levelID].ptr )
 		{
 		  if ( samp1[dayoy][varID][levelID].ptr == NULL )
-		    samp1[dayoy][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+		    samp1[dayoy][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 
 		  for ( i = 0; i < gridsize; i++ )
 		    if ( DBL_IS_EQUAL(vars1[dayoy][varID][levelID].ptr[i],
@@ -186,7 +177,7 @@ void *Ydaystat(void *argument)
 		{
 		  if ( samp1[dayoy][varID][levelID].ptr == NULL )
 		    {
-		      samp1[dayoy][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+		      samp1[dayoy][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 		      for ( i = 0; i < gridsize; i++ )
 			samp1[dayoy][varID][levelID].ptr[i] = nsets[dayoy];
 		    }
@@ -212,7 +203,6 @@ void *Ydaystat(void *argument)
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
 	    if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
-	    gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
 	    nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	    for ( levelID = 0; levelID < nlevel; levelID++ )
 	      farmoq(&vars2[dayoy][varID][levelID], vars1[dayoy][varID][levelID]);
@@ -222,6 +212,22 @@ void *Ydaystat(void *argument)
       tsID++;
     }
 
+  // set the year to the minimum of years found on output timestep
+  int outyear = 1e9;
+  for ( dayoy = 0; dayoy < NDAY; dayoy++ )
+    if ( nsets[dayoy] )
+      {
+        cdiDecodeDate(vdates[dayoy], &year, &month, &day);
+        if ( year < outyear ) outyear = year;
+      }
+  for ( dayoy = 0; dayoy < NDAY; dayoy++ )
+    if ( nsets[dayoy] )
+      {
+        cdiDecodeDate(vdates[dayoy], &year, &month, &day);
+        if ( year > outyear ) vdates[dayoy] = cdiEncodeDate(outyear, month, day);
+        //  printf("vdates[%d] = %d  nsets = %d\n", dayoy, vdates[dayoy], nsets[dayoy]);
+      }
+
   for ( dayoy = 0; dayoy < NDAY; dayoy++ )
     if ( nsets[dayoy] )
       {
@@ -233,7 +239,7 @@ void *Ydaystat(void *argument)
 	      for ( levelID = 0; levelID < nlevel; levelID++ )
 		{
 		  if ( samp1[dayoy][varID][levelID].ptr == NULL )
-		    farcmul(&vars1[dayoy][varID][levelID], 1.0/nsets[dayoy]);
+		    farcdiv(&vars1[dayoy][varID][levelID], (double)nsets[dayoy]);
 		  else
 		    fardiv(&vars1[dayoy][varID][levelID], samp1[dayoy][varID][levelID]);
 		}
@@ -248,16 +254,16 @@ void *Ydaystat(void *argument)
 		  if ( samp1[dayoy][varID][levelID].ptr == NULL )
 		    {
 		      if ( lstd )
-			farcstdx(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], nsets[dayoy], divisor);
+			farcstd(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], nsets[dayoy], divisor);
 		      else
-			farcvarx(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], nsets[dayoy], divisor);
+			farcvar(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], nsets[dayoy], divisor);
 		    }
 		  else
 		    {
 		      if ( lstd )
-			farstdx(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], samp1[dayoy][varID][levelID], divisor);
+			farstd(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], samp1[dayoy][varID][levelID], divisor);
 		      else
-			farvarx(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], samp1[dayoy][varID][levelID], divisor);
+			farvar(&vars1[dayoy][varID][levelID], vars2[dayoy][varID][levelID], samp1[dayoy][varID][levelID], divisor);
 		    }
 		}
 	    }
@@ -268,8 +274,8 @@ void *Ydaystat(void *argument)
 
 	for ( recID = 0; recID < nrecords; recID++ )
 	  {
-	    varID    = recVarID[recID];
-	    levelID  = recLevelID[recID];
+	    varID   = recVarID[recID];
+	    levelID = recLevelID[recID];
 
 	    if ( otsID && vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
 
@@ -291,15 +297,15 @@ void *Ydaystat(void *argument)
 	}
     }
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID2);
   streamClose(streamID1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Ydrunpctl.c b/src/Ydrunpctl.c
index 3d7e75e..327d705 100644
--- a/src/Ydrunpctl.c
+++ b/src/Ydrunpctl.c
@@ -25,12 +25,11 @@
 #include "cdo.h"
 #include "cdo_int.h"
 #include "pstream.h"
-#include "percentiles.h"
+#include "percentiles_hist.h"
 
 
 #define NDAY 373
 
-static
 int getmonthday(int date)
 {
   int year, month, day;
@@ -68,10 +67,8 @@ void *Ydrunpctl(void *argument)
   operatorInputArg("percentile number, number of timesteps");
   operatorCheckArgc(2);
   double pn  = parameter2double(operatorArgv()[0]);
+  percentile_check_number(pn);
   int ndates = parameter2int(operatorArgv()[1]);
-
-  if ( !(pn > 0 && pn < 100) )
-    cdoAbort("Illegal argument: percentile number %g is not in the range 0..100!", pn);
   
   for ( dayoy = 0; dayoy < NDAY; dayoy++ )
     {
@@ -111,16 +108,16 @@ void *Ydrunpctl(void *argument)
   int nvars    = vlistNvars(vlistID1);
   int nrecords = vlistNrecs(vlistID1);
 
-  int *recVarID   = (int*) malloc(nrecords*sizeof(int));
-  int *recLevelID = (int*) malloc(nrecords*sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = vlistGridsizeMax(vlistID1);
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
-  datetime = (datetime_t*) malloc((ndates+1)*sizeof(datetime_t));
+  datetime = (datetime_t*) Malloc((ndates+1)*sizeof(datetime_t));
   
-  vars1 = (field_t ***) malloc((ndates+1)*sizeof(field_t **));
+  vars1 = (field_t ***) Malloc((ndates+1)*sizeof(field_t **));
   
   for ( its = 0; its < ndates; its++ )
     {
@@ -294,11 +291,9 @@ void *Ydrunpctl(void *argument)
     if ( nsets[dayoy] )
       {
         if ( getmonthday(vdates1[dayoy]) != getmonthday(vdates2[dayoy]) )
-          cdoAbort("Verification dates for day %d of %s, %s and %s are different!", dayoy, cdoStreamName(1)->args, cdoStreamName(2)->args, cdoStreamName(3)->args);
-        /*
-        if ( vtimes1[dayoy] != vtimes2[dayoy] )
-          cdoAbort("Verification times for day %d of %s, %s and %s are different!", dayoy, cdoStreamName(1)->args, cdoStreamName(2)->args, cdoStreamName(3)->args);
-        */
+          cdoAbort("Verification dates for day %d of %s, %s and %s are different!",
+                   dayoy, cdoStreamName(1)->args, cdoStreamName(2)->args, cdoStreamName(3)->args);
+
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
 	    if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
@@ -333,12 +328,12 @@ void *Ydrunpctl(void *argument)
 	{
 	  nlevels = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	  for ( levelID = 0; levelID < nlevels; levelID++ )
-	    free(vars1[its][varID][levelID].ptr);
-	  free(vars1[its][varID]);
+	    Free(vars1[its][varID][levelID].ptr);
+	  Free(vars1[its][varID]);
 	}
-      free(vars1[its]);
+      Free(vars1[its]);
     }
-  free(vars1);
+  Free(vars1);
 
   for ( dayoy = 0; dayoy < NDAY; dayoy++ )
     {
@@ -349,10 +344,10 @@ void *Ydrunpctl(void *argument)
 	}
     }
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
   
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID4);
   streamClose(streamID3);
@@ -361,5 +356,5 @@ void *Ydrunpctl(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Ydrunstat.c b/src/Ydrunstat.c
index 5870bd9..2d00b2a 100644
--- a/src/Ydrunstat.c
+++ b/src/Ydrunstat.c
@@ -108,16 +108,16 @@ void *Ydrunstat(void *argument)
 
   int nrecords = vlistNrecs(vlistID1);
 
-  int *recVarID   = (int*) malloc(nrecords*sizeof(int));
-  int *recLevelID = (int*) malloc(nrecords*sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
-  datetime_t *datetime = (datetime_t*) malloc((ndates+1)*sizeof(datetime_t));
+  datetime_t *datetime = (datetime_t*) Malloc((ndates+1)*sizeof(datetime_t));
   
   YDAY_STATS *stats = ydstatCreate(vlistID1);
-  field_t ***vars1 = (field_t ***) malloc((ndates+1)*sizeof(field_t **));
+  field_t ***vars1 = (field_t ***) Malloc((ndates+1)*sizeof(field_t **));
   field_t ***vars2 = NULL;
   if ( lvarstd )
-    vars2 = (field_t ***) malloc((ndates+1)*sizeof(field_t **));
+    vars2 = (field_t ***) Malloc((ndates+1)*sizeof(field_t **));
   
   for ( its = 0; its < ndates; its++ )
     {
@@ -226,23 +226,24 @@ void *Ydrunstat(void *argument)
       tsID++;
     }
 
+  /*
+  // set the year to the minimum of years found on output timestep
   int outyear = 1e9;
+  int year, month, day;
   for ( dayoy = 0; dayoy < NDAY; dayoy++ )
     if ( stats->nsets[dayoy] )
       {
-	int year, month, day;
 	cdiDecodeDate(stats->vdate[dayoy], &year, &month, &day);
 	if ( year < outyear ) outyear = year;
       }
-
   for ( dayoy = 0; dayoy < NDAY; dayoy++ )
     if ( stats->nsets[dayoy] )
       {
-	int year, month, day;
 	cdiDecodeDate(stats->vdate[dayoy], &year, &month, &day);
-	stats->vdate[dayoy] = cdiEncodeDate(outyear, month, day);
+        // printf("vdates[%d] = %d  nsets = %d\n", dayoy, stats->vdate[dayoy], stats->nsets[dayoy]);
+	if ( year > outyear ) stats->vdate[dayoy] = cdiEncodeDate(outyear, month, day);
       }
-
+  */
   ydstatFinalize(stats, operfunc);
 
   otsID = 0;
@@ -276,20 +277,20 @@ void *Ydrunstat(void *argument)
     }
   
   ydstatDestroy(stats);
-  free(vars1);
-  if ( lvarstd ) free(vars2);
+  Free(vars1);
+  if ( lvarstd ) Free(vars2);
 
-  if ( datetime ) free(datetime);
+  if ( datetime ) Free(datetime);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID2);
   streamClose(streamID1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
 
 static
@@ -297,7 +298,7 @@ YDAY_STATS *ydstatCreate(int vlistID)
 {
   int dayoy;
   
-  YDAY_STATS *stats = (YDAY_STATS*) malloc(sizeof(YDAY_STATS));
+  YDAY_STATS *stats = (YDAY_STATS*) Malloc(sizeof(YDAY_STATS));
   
   for ( dayoy = 0; dayoy < NDAY; dayoy++ )
     {
@@ -329,10 +330,10 @@ void ydstatDestroy(YDAY_STATS *stats)
                 {
               	  nlevels = zaxisInqSize(vlistInqVarZaxis(stats->vlist, varID));
               	  for ( levelID = 0; levelID < nlevels; levelID++ )
-              	    free(stats->vars1[dayoy][varID][levelID].ptr);
-              	  free(stats->vars1[dayoy][varID]);
+              	    Free(stats->vars1[dayoy][varID][levelID].ptr);
+              	  Free(stats->vars1[dayoy][varID]);
                 }
-              free(stats->vars1[dayoy]);
+              Free(stats->vars1[dayoy]);
             }
           if ( stats->vars2[dayoy] != NULL )
             {
@@ -340,13 +341,13 @@ void ydstatDestroy(YDAY_STATS *stats)
                 {
               	  nlevels = zaxisInqSize(vlistInqVarZaxis(stats->vlist, varID));
               	  for ( levelID = 0; levelID < nlevels; levelID++ )
-              	    free(stats->vars2[dayoy][varID][levelID].ptr);
-              	  free(stats->vars2[dayoy][varID]);
+              	    Free(stats->vars2[dayoy][varID][levelID].ptr);
+              	  Free(stats->vars2[dayoy][varID]);
                 }
-              free(stats->vars2[dayoy]);
+              Free(stats->vars2[dayoy]);
             }
         }
-      free(stats);    
+      Free(stats);    
     }
 }
 
@@ -444,7 +445,7 @@ void ydstatFinalize(YDAY_STATS *stats, int operfunc)
 	          if ( vlistInqVarTsteptype(stats->vlist, varID) == TSTEP_CONSTANT ) continue;
 	          nlevels = zaxisInqSize(vlistInqVarZaxis(stats->vlist, varID));
 	          for ( levelID = 0; levelID < nlevels; levelID++ )
-		    farcmul(&stats->vars1[dayoy][varID][levelID], 1.0 / stats->nsets[dayoy]);
+		    farcdiv(&stats->vars1[dayoy][varID][levelID], (double) stats->nsets[dayoy]);
 	        }
 	      break;
 	      
@@ -455,8 +456,8 @@ void ydstatFinalize(YDAY_STATS *stats, int operfunc)
 	          if ( vlistInqVarTsteptype(stats->vlist, varID) == TSTEP_CONSTANT ) continue;
 	          nlevels = zaxisInqSize(vlistInqVarZaxis(stats->vlist, varID));
 	          for ( levelID = 0; levelID < nlevels; levelID++ )
-		    farcstdx(&stats->vars1[dayoy][varID][levelID], stats->vars2[dayoy][varID][levelID],
-			     stats->nsets[dayoy], divisor);
+		    farcstd(&stats->vars1[dayoy][varID][levelID], stats->vars2[dayoy][varID][levelID],
+                            stats->nsets[dayoy], divisor);
 	        }
 	      break;
 	      
@@ -467,7 +468,7 @@ void ydstatFinalize(YDAY_STATS *stats, int operfunc)
 	          if ( vlistInqVarTsteptype(stats->vlist, varID) == TSTEP_CONSTANT ) continue;
 	          nlevels = zaxisInqSize(vlistInqVarZaxis(stats->vlist, varID));
 	          for ( levelID = 0; levelID < nlevels; levelID++ )
-		    farcvarx(&stats->vars1[dayoy][varID][levelID], stats->vars2[dayoy][varID][levelID],
+		    farcvar(&stats->vars1[dayoy][varID][levelID], stats->vars2[dayoy][varID][levelID],
 			    stats->nsets[dayoy], divisor);
 	        }
 	      break;
diff --git a/src/Yearmonstat.c b/src/Yearmonstat.c
index 3e66ce9..eb35e3e 100644
--- a/src/Yearmonstat.c
+++ b/src/Yearmonstat.c
@@ -75,8 +75,8 @@ void *Yearmonstat(void *argument)
   int nvars    = vlistNvars(vlistID1);
   int nrecords = vlistNrecs(vlistID1);
 
-  int *recVarID   = (int*) malloc(nrecords*sizeof(int));
-  int *recLevelID = (int*) malloc(nrecords*sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   int calendar = taxisInqCalendar(taxisID1);
   dtlist_type *dtlist = dtlist_new();
@@ -86,7 +86,7 @@ void *Yearmonstat(void *argument)
   gridsize = vlistGridsizeMax(vlistID1);
 
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   vars1 = field_malloc(vlistID1, FIELD_PTR);
   samp1 = field_malloc(vlistID1, FIELD_NONE);
@@ -143,7 +143,7 @@ void *Yearmonstat(void *argument)
 		  if ( nmiss > 0 || samp1[varID][levelID].ptr )
 		    {
 		      if ( samp1[varID][levelID].ptr == NULL )
-			samp1[varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+			samp1[varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 
 		      for ( i = 0; i < gridsize; i++ )
 			if ( DBL_IS_EQUAL(vars1[varID][levelID].ptr[i], vars1[varID][levelID].missval) )
@@ -164,7 +164,7 @@ void *Yearmonstat(void *argument)
 		    {
 		      if ( samp1[varID][levelID].ptr == NULL )
 			{
-			  samp1[varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+			  samp1[varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 			  for ( i = 0; i < gridsize; i++ )
 			    samp1[varID][levelID].ptr[i] = dsets;
 			}
@@ -195,7 +195,7 @@ void *Yearmonstat(void *argument)
 	  for ( levelID = 0; levelID < nlevel; levelID++ )
 	    {
 	      if ( samp1[varID][levelID].ptr == NULL )
-		farcmul(&vars1[varID][levelID], 1.0/dsets);
+		farcdiv(&vars1[varID][levelID], dsets);
 	      else
 		fardiv(&vars1[varID][levelID], samp1[varID][levelID]);
 	    }
@@ -230,10 +230,10 @@ void *Yearmonstat(void *argument)
   field_free(vars1, vlistID1);
   field_free(samp1, vlistID1);
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   dtlist_delete(dtlist);
 
@@ -242,5 +242,5 @@ void *Yearmonstat(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Yhourarith.c b/src/Yhourarith.c
index 19173e6..41e080e 100644
--- a/src/Yhourarith.c
+++ b/src/Yhourarith.c
@@ -99,8 +99,8 @@ void *Yhourarith(void *argument)
 
   field_init(&field1);
   field_init(&field2);
-  field1.ptr = (double*) malloc(gridsize*sizeof(double));
-  field2.ptr = (double*) malloc(gridsize*sizeof(double));
+  field1.ptr = (double*) Malloc(gridsize*sizeof(double));
+  field2.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   taxisID1 = vlistInqTaxis(vlistID1);
   taxisID2 = vlistInqTaxis(vlistID2);
@@ -124,15 +124,15 @@ void *Yhourarith(void *argument)
       houroy = hour_of_year(vdate, vtime);
       if ( vardata2[houroy] != NULL ) cdoAbort("Hour of year %d already allocatd!", houroy);
 
-      vardata2[houroy]  = (double **) malloc(nvars*sizeof(double *));
-      varnmiss2[houroy] = (int **) malloc(nvars*sizeof(int *));
+      vardata2[houroy]  = (double **) Malloc(nvars*sizeof(double *));
+      varnmiss2[houroy] = (int **) Malloc(nvars*sizeof(int *));
 
       for ( varID = 0; varID < nvars; varID++ )
 	{
 	  gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
 	  nlev     = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
-	  vardata2[houroy][varID]  = (double*) malloc(nlev*gridsize*sizeof(double));
-	  varnmiss2[houroy][varID] = (int*) malloc(nlev*sizeof(int));
+	  vardata2[houroy][varID]  = (double*) Malloc(nlev*gridsize*sizeof(double));
+	  varnmiss2[houroy][varID] = (int*) Malloc(nlev*sizeof(int));
 	}
 
       for ( recID = 0; recID < nrecs; recID++ )
@@ -197,18 +197,18 @@ void *Yhourarith(void *argument)
       {
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
-	    free(vardata2[houroy][varID]);
-	    free(varnmiss2[houroy][varID]);
+	    Free(vardata2[houroy][varID]);
+	    Free(varnmiss2[houroy][varID]);
 	  }
 
-	free(vardata2[houroy]);
-	free(varnmiss2[houroy]);
+        Free(vardata2[houroy]);
+        Free(varnmiss2[houroy]);
       }
 
-  if ( field1.ptr ) free(field1.ptr);
-  if ( field2.ptr ) free(field2.ptr);
+  if ( field1.ptr ) Free(field1.ptr);
+  if ( field2.ptr ) Free(field2.ptr);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Yhourstat.c b/src/Yhourstat.c
index 1eba3d6..8eddbb0 100644
--- a/src/Yhourstat.c
+++ b/src/Yhourstat.c
@@ -134,12 +134,12 @@ void *Yhourstat(void *argument)
   nvars    = vlistNvars(vlistID1);
   nrecords = vlistNrecs(vlistID1);
 
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = vlistGridsizeMax(vlistID1);
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   otsID = 0;
@@ -183,7 +183,7 @@ void *Yhourstat(void *argument)
 	      if ( nmiss > 0 || samp1[houroy][varID][levelID].ptr )
 		{
 		  if ( samp1[houroy][varID][levelID].ptr == NULL )
-		    samp1[houroy][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+		    samp1[houroy][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 
 		  for ( i = 0; i < gridsize; i++ )
 		    if ( DBL_IS_EQUAL(vars1[houroy][varID][levelID].ptr[i],
@@ -203,7 +203,7 @@ void *Yhourstat(void *argument)
 		{
 		  if ( samp1[houroy][varID][levelID].ptr == NULL )
 		    {
-		      samp1[houroy][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+		      samp1[houroy][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 		      for ( i = 0; i < gridsize; i++ )
 			samp1[houroy][varID][levelID].ptr[i] = nsets[houroy];
 		    }
@@ -229,7 +229,6 @@ void *Yhourstat(void *argument)
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
 	    if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
-	    gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
 	    nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	    for ( levelID = 0; levelID < nlevel; levelID++ )
 	      farmoq(&vars2[houroy][varID][levelID], vars1[houroy][varID][levelID]);
@@ -250,7 +249,7 @@ void *Yhourstat(void *argument)
 	      for ( levelID = 0; levelID < nlevel; levelID++ )
 		{
 		  if ( samp1[houroy][varID][levelID].ptr == NULL )
-		    farcmul(&vars1[houroy][varID][levelID], 1.0/nsets[houroy]);
+		    farcdiv(&vars1[houroy][varID][levelID], (double)nsets[houroy]);
 		  else
 		    fardiv(&vars1[houroy][varID][levelID], samp1[houroy][varID][levelID]);
 		}
@@ -265,16 +264,16 @@ void *Yhourstat(void *argument)
 		  if ( samp1[houroy][varID][levelID].ptr == NULL )
 		    {
 		      if ( lstd )
-			farcstdx(&vars1[houroy][varID][levelID], vars2[houroy][varID][levelID], nsets[houroy], divisor);
+			farcstd(&vars1[houroy][varID][levelID], vars2[houroy][varID][levelID], nsets[houroy], divisor);
 		      else
-			farcvarx(&vars1[houroy][varID][levelID], vars2[houroy][varID][levelID], nsets[houroy], divisor);
+			farcvar(&vars1[houroy][varID][levelID], vars2[houroy][varID][levelID], nsets[houroy], divisor);
 		    }
 		  else
 		    {
 		      if ( lstd )
-			farstdx(&vars1[houroy][varID][levelID], vars2[houroy][varID][levelID], samp1[houroy][varID][levelID], divisor);
+			farstd(&vars1[houroy][varID][levelID], vars2[houroy][varID][levelID], samp1[houroy][varID][levelID], divisor);
 		      else
-			farvarx(&vars1[houroy][varID][levelID], vars2[houroy][varID][levelID], samp1[houroy][varID][levelID], divisor);
+			farvar(&vars1[houroy][varID][levelID], vars2[houroy][varID][levelID], samp1[houroy][varID][levelID], divisor);
 		    }
 		}
 	    }
@@ -308,15 +307,15 @@ void *Yhourstat(void *argument)
 	}
     }
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID2);
   streamClose(streamID1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Ymonarith.c b/src/Ymonarith.c
index 8ba824e..3b4e170 100644
--- a/src/Ymonarith.c
+++ b/src/Ymonarith.c
@@ -36,34 +36,6 @@
 
 #define  MAX_MON    12
 
-static
-int month_to_season(int mon)
-{
-  int seas = -1;
-
-  switch ( mon )
-    {
-    case 12:
-    case  1:
-    case  2:
-      seas = 0; break;
-    case  3:
-    case  4:
-    case  5:
-      seas = 1; break;
-    case  6:
-    case  7:
-    case  8:
-      seas = 2; break;
-    case  9:
-    case 10:
-    case 11:
-      seas = 3; break;
-    }
-
-  return seas;
-}
-
 
 void *Ymonarith(void *argument)
 {
@@ -106,8 +78,8 @@ void *Ymonarith(void *argument)
 
   field_init(&field1);
   field_init(&field2);
-  field1.ptr = (double*) malloc(gridsize*sizeof(double));
-  field2.ptr = (double*) malloc(gridsize*sizeof(double));
+  field1.ptr = (double*) Malloc(gridsize*sizeof(double));
+  field2.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   int taxisID1 = vlistInqTaxis(vlistID1);
   int taxisID2 = vlistInqTaxis(vlistID2);
@@ -143,15 +115,15 @@ void *Ymonarith(void *argument)
 	    cdoAbort("Month %d already allocatd!", mon);
 	}
 
-      vardata2[mon]  = (double **) malloc(nvars*sizeof(double *));
-      varnmiss2[mon] = (int **) malloc(nvars*sizeof(int *));
+      vardata2[mon]  = (double **) Malloc(nvars*sizeof(double *));
+      varnmiss2[mon] = (int **) Malloc(nvars*sizeof(int *));
 
       for ( varID = 0; varID < nvars; varID++ )
 	{
 	  gridsize = gridInqSize(vlistInqVarGrid(vlistID2, varID));
 	  nlev     = zaxisInqSize(vlistInqVarZaxis(vlistID2, varID));
-	  vardata2[mon][varID]  = (double*) malloc(nlev*gridsize*sizeof(double));
-	  varnmiss2[mon][varID] = (int*) malloc(nlev*sizeof(int));
+	  vardata2[mon][varID]  = (double*) Malloc(nlev*gridsize*sizeof(double));
+	  varnmiss2[mon][varID] = (int*) Malloc(nlev*sizeof(int));
 	}
 
       for ( recID = 0; recID < nrecs; recID++ )
@@ -226,18 +198,18 @@ void *Ymonarith(void *argument)
       {
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
-	    free(vardata2[mon][varID]);
-	    free(varnmiss2[mon][varID]);
+	    Free(vardata2[mon][varID]);
+	    Free(varnmiss2[mon][varID]);
 	  }
 
-	free(vardata2[mon]);
-	free(varnmiss2[mon]);
+        Free(vardata2[mon]);
+        Free(varnmiss2[mon]);
       }
 
-  if ( field1.ptr ) free(field1.ptr);
-  if ( field2.ptr ) free(field2.ptr);
+  if ( field1.ptr ) Free(field1.ptr);
+  if ( field2.ptr ) Free(field2.ptr);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Ymonpctl.c b/src/Ymonpctl.c
index 262ec57..92b32b0 100644
--- a/src/Ymonpctl.c
+++ b/src/Ymonpctl.c
@@ -25,10 +25,18 @@
 #include "cdo.h"
 #include "cdo_int.h"
 #include "pstream.h"
-#include "percentiles.h"
+#include "percentiles_hist.h"
 
 #define  NMONTH     17
 
+static
+int getmonth(int date)
+{
+  int year, month, day;
+  cdiDecodeDate(date, &year, &month, &day);
+  return month;
+}
+
 void *Ymonpctl(void *argument)
 {
   int gridsize;
@@ -48,20 +56,17 @@ void *Ymonpctl(void *argument)
   int nvars, nlevels;
   int *recVarID, *recLevelID;
   int vdates1[NMONTH], vtimes1[NMONTH];
-  int vdates2[NMONTH], vtimes2[NMONTH];
+  int vdates2[NMONTH];
   field_t **vars1[NMONTH];
   field_t field;
-  double pn;
   HISTOGRAM_SET *hsets[NMONTH];
 
   cdoInitialize(argument);
   cdoOperatorAdd("ymonpctl", func_pctl, 0, NULL);
 
   operatorInputArg("percentile number");
-  pn = parameter2double(operatorArgv()[0]);
-      
-  if ( !(pn > 0 && pn < 100) )
-    cdoAbort("Illegal argument: percentile number %g is not in the range 0..100!", pn);
+  double pn = parameter2double(operatorArgv()[0]);
+  percentile_check_number(pn);
 
   for ( month = 0; month < NMONTH; month++ )
     {
@@ -98,12 +103,12 @@ void *Ymonpctl(void *argument)
   nvars    = vlistNvars(vlistID1);
   nrecords = vlistNrecs(vlistID1);
 
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = vlistGridsizeMax(vlistID1);
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID2, tsID)) )
@@ -124,7 +129,6 @@ void *Ymonpctl(void *argument)
 	cdoAbort("Month %d out of range!", month);
 
       vdates2[month] = vdate;
-      vtimes2[month] = vtime;
 
       if ( vars1[month] == NULL )
 	{
@@ -202,10 +206,9 @@ void *Ymonpctl(void *argument)
   for ( month = 0; month < NMONTH; month++ )
     if ( nsets[month] )
       {
-        if ( vdates1[month] != vdates2[month] )
-          cdoAbort("Verification dates for month %d of %s, %s and %s are different!", month, cdoStreamName(1)->args, cdoStreamName(2)->args, cdoStreamName(3)->args);
-        if ( vtimes1[month] != vtimes2[month] )
-          cdoAbort("Verification times for month %d of %s, %s and %s are different!", month, cdoStreamName(1)->args, cdoStreamName(2)->args, cdoStreamName(3)->args);
+        if ( getmonth(vdates1[month]) != getmonth(vdates2[month]) )
+          cdoAbort("Verification dates for month %d of %s, %s and %s are different!",
+                   month, cdoStreamName(1)->args, cdoStreamName(2)->args, cdoStreamName(3)->args);
 
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
@@ -243,10 +246,10 @@ void *Ymonpctl(void *argument)
 	}
     }
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID4);
   streamClose(streamID3);
@@ -255,5 +258,5 @@ void *Ymonpctl(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Ymonstat.c b/src/Ymonstat.c
index a39da45..de72f65 100644
--- a/src/Ymonstat.c
+++ b/src/Ymonstat.c
@@ -126,12 +126,12 @@ void *Ymonstat(void *argument)
   nvars    = vlistNvars(vlistID1);
   nrecords = vlistNrecs(vlistID1);
 
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = vlistGridsizeMax(vlistID1);
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   tsID = 0;
   otsID = 0;
@@ -179,7 +179,7 @@ void *Ymonstat(void *argument)
 	      if ( nmiss > 0 || samp1[month][varID][levelID].ptr )
 		{
 		  if ( samp1[month][varID][levelID].ptr == NULL )
-		    samp1[month][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+		    samp1[month][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 
 		  for ( i = 0; i < gridsize; i++ )
 		    if ( DBL_IS_EQUAL(vars1[month][varID][levelID].ptr[i],
@@ -199,7 +199,7 @@ void *Ymonstat(void *argument)
 		{
 		  if ( samp1[month][varID][levelID].ptr == NULL )
 		    {
-		      samp1[month][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+		      samp1[month][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 		      for ( i = 0; i < gridsize; i++ )
 			samp1[month][varID][levelID].ptr[i] = nsets[month];
 		    }
@@ -225,7 +225,6 @@ void *Ymonstat(void *argument)
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
 	    if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
-	    gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
 	    nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	    for ( levelID = 0; levelID < nlevel; levelID++ )
 	      farmoq(&vars2[month][varID][levelID], vars1[month][varID][levelID]);
@@ -274,7 +273,7 @@ void *Ymonstat(void *argument)
 	    for ( levelID = 0; levelID < nlevel; levelID++ )
 	      {
 		if ( samp1[month][varID][levelID].ptr == NULL )
-		  farcmul(&vars1[month][varID][levelID], 1.0/nsets[month]);
+		  farcdiv(&vars1[month][varID][levelID], (double)nsets[month]);
 		else
 		  fardiv(&vars1[month][varID][levelID], samp1[month][varID][levelID]);
 	      }
@@ -289,16 +288,16 @@ void *Ymonstat(void *argument)
 		if ( samp1[month][varID][levelID].ptr == NULL )
 		  {
 		    if ( lstd )
-		      farcstdx(&vars1[month][varID][levelID], vars2[month][varID][levelID], nsets[month], divisor);
+		      farcstd(&vars1[month][varID][levelID], vars2[month][varID][levelID], nsets[month], divisor);
 		    else
-		      farcvarx(&vars1[month][varID][levelID], vars2[month][varID][levelID], nsets[month], divisor);
+		      farcvar(&vars1[month][varID][levelID], vars2[month][varID][levelID], nsets[month], divisor);
 		  }
 		else
 		  {
 		    if ( lstd )
-		      farstdx(&vars1[month][varID][levelID], vars2[month][varID][levelID], samp1[month][varID][levelID], divisor);
+		      farstd(&vars1[month][varID][levelID], vars2[month][varID][levelID], samp1[month][varID][levelID], divisor);
 		    else
-		      farvarx(&vars1[month][varID][levelID], vars2[month][varID][levelID], samp1[month][varID][levelID], divisor);
+		      farvar(&vars1[month][varID][levelID], vars2[month][varID][levelID], samp1[month][varID][levelID], divisor);
 		  }
 	      }
 	  }
@@ -335,12 +334,12 @@ void *Ymonstat(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Yseaspctl.c b/src/Yseaspctl.c
index 1c629f5..5501679 100644
--- a/src/Yseaspctl.c
+++ b/src/Yseaspctl.c
@@ -25,90 +25,93 @@
 #include "cdo.h"
 #include "cdo_int.h"
 #include "pstream.h"
-#include "percentiles.h"
+#include "percentiles_hist.h"
 #include "util.h"
 
 #define  NSEAS       4
 
+typedef struct {
+  int vdate;
+  int vtime;
+}
+date_time_t;
+
+void set_date(int vdate_new, int vtime_new, date_time_t *datetime);
+
+int getmonthday(int date);
+
 void *Yseaspctl(void *argument)
 {
-  int gridsize;
   int varID;
   int recID;
   int gridID;
   int vdate, vtime;
   int year, month, day, seas;
-  int nrecs, nrecords;
+  int nrecs;
   int levelID;
-  int tsID;
-  int otsID;
   long nsets[NSEAS];
-  int streamID1, streamID2, streamID3, streamID4;
-  int vlistID1, vlistID2, vlistID3, vlistID4, taxisID1, taxisID2, taxisID3, taxisID4;
   int nmiss;
-  int nvars, nlevels;
-  int *recVarID, *recLevelID;
-  int vdates1[NSEAS], vtimes1[NSEAS];
-  int vdates2[NSEAS], vtimes2[NSEAS];
+  int nlevels;
+  date_time_t datetime1[NSEAS], datetime2[NSEAS];
   field_t **vars1[NSEAS];
-  field_t field;
-  double pn;
   HISTOGRAM_SET *hsets[NSEAS];
-  int season_start;
 
   cdoInitialize(argument);
   cdoOperatorAdd("yseaspctl", func_pctl, 0, NULL);
 
   operatorInputArg("percentile number");
-  pn = parameter2double(operatorArgv()[0]);
-      
-  if ( !(pn > 0 && pn < 100) )
-    cdoAbort("Illegal argument: percentile number %g is not in the range 0..100!", pn);
+  double pn = parameter2double(operatorArgv()[0]);
+  percentile_check_number(pn);
 
-  season_start = get_season_start();
   for ( seas = 0; seas < NSEAS; seas++ )
     {
       vars1[seas] = NULL;
       hsets[seas] = NULL;
       nsets[seas] = 0;
+      datetime1[seas].vdate = 0;
+      datetime1[seas].vtime = 0;
+      datetime2[seas].vdate = 0;
+      datetime2[seas].vtime = 0;
     }
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
-  streamID2 = streamOpenRead(cdoStreamName(1));
-  streamID3 = streamOpenRead(cdoStreamName(2));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID2 = streamOpenRead(cdoStreamName(1));
+  int streamID3 = streamOpenRead(cdoStreamName(2));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = streamInqVlist(streamID2);
-  vlistID3 = streamInqVlist(streamID3);
-  vlistID4 = vlistDuplicate(vlistID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = streamInqVlist(streamID2);
+  int vlistID3 = streamInqVlist(streamID3);
+  int vlistID4 = vlistDuplicate(vlistID1);
 
   vlistCompare(vlistID1, vlistID2, CMP_ALL);
   vlistCompare(vlistID1, vlistID3, CMP_ALL);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = vlistInqTaxis(vlistID2);
-  taxisID3 = vlistInqTaxis(vlistID3);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = vlistInqTaxis(vlistID2);
+  int taxisID3 = vlistInqTaxis(vlistID3);
   /* TODO - check that time axes 2 and 3 are equal */
 
-  taxisID4 = taxisDuplicate(taxisID1);
+  int taxisID4 = taxisDuplicate(taxisID1);
   if ( taxisHasBounds(taxisID4) ) taxisDeleteBounds(taxisID4);
   vlistDefTaxis(vlistID4, taxisID4);
 
-  streamID4 = streamOpenWrite(cdoStreamName(3), cdoFiletype());
+  int streamID4 = streamOpenWrite(cdoStreamName(3), cdoFiletype());
 
   streamDefVlist(streamID4, vlistID4);
 
-  nvars    = vlistNvars(vlistID1);
-  nrecords = vlistNrecs(vlistID1);
+  int nvars    = vlistNvars(vlistID1);
+  int nrecords = vlistNrecs(vlistID1);
+
+  int *recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  int gridsize = vlistGridsizeMax(vlistID1);
 
-  gridsize = vlistGridsizeMax(vlistID1);
+  field_t field;
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID2, tsID)) )
     {
       if ( nrecs != streamInqTimestep(streamID3, tsID) )
@@ -123,29 +126,10 @@ void *Yseaspctl(void *argument)
       if ( cdoVerbose ) cdoPrint("process timestep: %d %d %d", tsID+1, vdate, vtime);
 
       cdiDecodeDate(vdate, &year, &month, &day);
-      if ( month < 0 || month > 16 )
-	cdoAbort("Month %d out of range!", month);
 
-      if ( season_start == START_DEC )
-	{
-	  if ( month <= 12 )
-	    seas = (month % 12) / 3;
-	  else
-	    seas = month - 13;
-	}
-      else
-	{
-	  if ( month <= 12 )
-	    seas = (month - 1) / 3;
-	  else
-	    seas = month - 13;
-	}
-
-      if ( seas < 0 || seas > 3 )
-	cdoAbort("Season %d out of range!", seas+1);
+      seas = month_to_season(month);
 
-      vdates2[seas] = vdate;
-      vtimes2[seas] = vtime;
+      set_date(vdate, vtime, &datetime2[seas]);
 
       if ( vars1[seas] == NULL )
 	{
@@ -198,8 +182,7 @@ void *Yseaspctl(void *argument)
       if ( seas < 0 || seas > 3 )
 	cdoAbort("Season %d out of range!", seas+1);
 
-      vdates1[seas] = vdate;
-      vtimes1[seas] = vtime;
+      set_date(vdate, vtime, &datetime1[seas]);
 
       if ( vars1[seas] == NULL )
         cdoAbort("No data for season %d in %s and %s", seas, cdoStreamName(1)->args, cdoStreamName(2)->args);
@@ -224,14 +207,13 @@ void *Yseaspctl(void *argument)
       tsID++;
     }
 
-  otsID = 0;
+  int otsID = 0;
   for ( seas = 0; seas < NSEAS; seas++ )
     if ( nsets[seas] )
       {
-        if ( vdates1[seas] != vdates2[seas] )
-          cdoAbort("Verification dates for season %d of %s, %s and %s are different!", seas, cdoStreamName(1)->args, cdoStreamName(2)->args, cdoStreamName(3)->args);
-        if ( vtimes1[seas] != vtimes2[seas] )
-          cdoAbort("Verification times for season %d of %s, %s and %s are different!", seas, cdoStreamName(1)->args, cdoStreamName(2)->args, cdoStreamName(3)->args);
+        if ( getmonthday(datetime1[seas].vdate) != getmonthday(datetime2[seas].vdate) )
+          cdoAbort("Verification dates for season %d of %s, %s and %s are different!",
+                   seas, cdoStreamName(1)->args, cdoStreamName(2)->args, cdoStreamName(3)->args);
 
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
@@ -242,8 +224,8 @@ void *Yseaspctl(void *argument)
 	      hsetGetVarLevelPercentiles(&vars1[seas][varID][levelID], hsets[seas], varID, levelID, pn);
 	  }
 
-	taxisDefVdate(taxisID4, vdates1[seas]);
-	taxisDefVtime(taxisID4, vtimes1[seas]);
+	taxisDefVdate(taxisID4, datetime1[seas].vdate);
+	taxisDefVtime(taxisID4, datetime1[seas].vtime);
 	streamDefTimestep(streamID4, otsID);
 
 	for ( recID = 0; recID < nrecords; recID++ )
@@ -269,10 +251,10 @@ void *Yseaspctl(void *argument)
 	}
     }
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID4);
   streamClose(streamID3);
@@ -281,5 +263,5 @@ void *Yseaspctl(void *argument)
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Yseasstat.c b/src/Yseasstat.c
index 0327ae9..18559c2 100644
--- a/src/Yseasstat.c
+++ b/src/Yseasstat.c
@@ -24,7 +24,9 @@
       Yseasstat  yseasmean       Multi-year seasonally mean
       Yseasstat  yseasavg        Multi-year seasonally average
       Yseasstat  yseasvar        Multi-year seasonally variance
+      Yseasstat  yseasvar1       Multi-year seasonally variance [Divisor is (n-1)]
       Yseasstat  yseasstd        Multi-year seasonally standard deviation
+      Yseasstat  yseasstd1       Multi-year seasonally standard deviation [Divisor is (n-1)]
 */
 
 #include <cdi.h>
@@ -42,8 +44,6 @@ typedef struct {
 }
 date_time_t;
 
-
-static 
 void set_date(int vdate_new, int vtime_new, date_time_t *datetime)
 {
   int year, month, day;
@@ -61,28 +61,18 @@ void set_date(int vdate_new, int vtime_new, date_time_t *datetime)
 
 void *Yseasstat(void *argument)
 {
-  int operatorID;
-  int operfunc;
-  int gridsize;
   int i;
   int varID;
   int recID;
   int vdate, vtime;
   int year, month, day, seas;
-  int nrecs, nrecords;
+  int nrecs;
   int levelID;
-  int tsID;
-  int otsID;
   long nsets[NSEAS];
-  int streamID1, streamID2;
-  int vlistID1, vlistID2, taxisID1, taxisID2;
   int nmiss;
-  int nvars, nlevel;
-  int *recVarID, *recLevelID;
+  int nlevel;
   date_time_t datetime[NSEAS];
   field_t **vars1[NSEAS], **vars2[NSEAS], **samp1[NSEAS];
-  field_t field;
-  int season_start;
 
   cdoInitialize(argument);
 
@@ -92,12 +82,13 @@ void *Yseasstat(void *argument)
   cdoOperatorAdd("yseasmean", func_mean, 0, NULL);
   cdoOperatorAdd("yseasavg",  func_avg,  0, NULL);
   cdoOperatorAdd("yseasvar",  func_var,  0, NULL);
+  cdoOperatorAdd("yseasvar1", func_var1, 0, NULL);
   cdoOperatorAdd("yseasstd",  func_std,  0, NULL);
+  cdoOperatorAdd("yseasstd1", func_std1, 0, NULL);
 
-  operatorID = cdoOperatorID();
-  operfunc = cdoOperatorF1(operatorID);
+  int operatorID = cdoOperatorID();
+  int operfunc = cdoOperatorF1(operatorID);
 
-  season_start = get_season_start();
   for ( seas = 0; seas < NSEAS; seas++ )
     {
       vars1[seas]  = NULL;
@@ -108,57 +99,46 @@ void *Yseasstat(void *argument)
       datetime[seas].vtime = 0;
     }
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int lmean   = operfunc == func_mean || operfunc == func_avg;
+  int lstd    = operfunc == func_std || operfunc == func_std1;
+  int lvarstd = operfunc == func_std || operfunc == func_var || operfunc == func_std1 || operfunc == func_var1;
+  double divisor = operfunc == func_std1 || operfunc == func_var1;
+
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = vlistDuplicate(vlistID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   if ( taxisHasBounds(taxisID2) ) taxisDeleteBounds(taxisID2);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
-  nvars    = vlistNvars(vlistID1);
-  nrecords = vlistNrecs(vlistID1);
+  int nvars    = vlistNvars(vlistID1);
+  int nrecords = vlistNrecs(vlistID1);
 
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  int *recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  int *recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
-  gridsize = vlistGridsizeMax(vlistID1);
+  int gridsize = vlistGridsizeMax(vlistID1);
+
+  field_t field;
   field_init(&field);
-  field.ptr = (double*) malloc(gridsize*sizeof(double));
+  field.ptr = (double*) Malloc(gridsize*sizeof(double));
 
-  tsID = 0;
-  otsID = 0;
+  int tsID = 0;
+  int otsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       vdate = taxisInqVdate(taxisID1);
       vtime = taxisInqVtime(taxisID1);
       cdiDecodeDate(vdate, &year, &month, &day);
-      if ( month < 0 || month > 16 )
-	cdoAbort("Month %d out of range!", month);
-
-      if ( season_start == START_DEC )
-	{
-	  if ( month <= 12 )
-	    seas = (month % 12) / 3;
-	  else
-	    seas = month - 13;
-	}
-      else
-	{
-	  if ( month <= 12 )
-	    seas = (month - 1) / 3;
-	  else
-	    seas = month - 13;
-	}
 
-      if ( seas < 0 || seas > 3 )
-	cdoAbort("Season %d out of range!", seas+1);
+      seas = month_to_season(month); 
 
       set_date(vdate, vtime, &datetime[seas]);
 
@@ -166,7 +146,7 @@ void *Yseasstat(void *argument)
 	{
 	  vars1[seas] = field_malloc(vlistID1, FIELD_PTR);
 	  samp1[seas] = field_malloc(vlistID1, FIELD_NONE);
-	  if ( operfunc == func_std || operfunc == func_var )
+	  if ( lvarstd )
 	    vars2[seas] = field_malloc(vlistID1, FIELD_PTR);
 	}
 
@@ -190,7 +170,7 @@ void *Yseasstat(void *argument)
 	      if ( nmiss > 0 || samp1[seas][varID][levelID].ptr )
 		{
 		  if ( samp1[seas][varID][levelID].ptr == NULL )
-		    samp1[seas][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+		    samp1[seas][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 
 		  for ( i = 0; i < gridsize; i++ )
 		    if ( DBL_IS_EQUAL(vars1[seas][varID][levelID].ptr[i],
@@ -210,7 +190,7 @@ void *Yseasstat(void *argument)
 		{
 		  if ( samp1[seas][varID][levelID].ptr == NULL )
 		    {
-		      samp1[seas][varID][levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+		      samp1[seas][varID][levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
 		      for ( i = 0; i < gridsize; i++ )
 			samp1[seas][varID][levelID].ptr[i] = nsets[seas];
 		    }
@@ -220,7 +200,7 @@ void *Yseasstat(void *argument)
 		      samp1[seas][varID][levelID].ptr[i]++;
 		}
 
-	      if ( operfunc == func_std || operfunc == func_var )
+	      if ( lvarstd )
 		{
 		  farsumq(&vars2[seas][varID][levelID], field);
 		  farsum(&vars1[seas][varID][levelID], field);
@@ -232,11 +212,10 @@ void *Yseasstat(void *argument)
 	    }
 	}
 
-      if ( nsets[seas] == 0 && (operfunc == func_std || operfunc == func_var) )
+      if ( nsets[seas] == 0 && lvarstd )
 	for ( varID = 0; varID < nvars; varID++ )
 	  {
 	    if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
-	    gridsize = gridInqSize(vlistInqVarGrid(vlistID1, varID));
 	    nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	    for ( levelID = 0; levelID < nlevel; levelID++ )
 	      farmoq(&vars2[seas][varID][levelID], vars1[seas][varID][levelID]);
@@ -249,40 +228,39 @@ void *Yseasstat(void *argument)
   for ( seas = 0; seas < NSEAS; seas++ )
     if ( nsets[seas] )
       {
-	if ( operfunc == func_mean || operfunc == func_avg )
+	if ( lmean )
 	  for ( varID = 0; varID < nvars; varID++ )
 	    {
 	      if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
-	      nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
+	      nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	      for ( levelID = 0; levelID < nlevel; levelID++ )
 		{
 		  if ( samp1[seas][varID][levelID].ptr == NULL )
-		    farcmul(&vars1[seas][varID][levelID], 1.0/nsets[seas]);
+		    farcdiv(&vars1[seas][varID][levelID], (double)nsets[seas]);
 		  else
 		    fardiv(&vars1[seas][varID][levelID], samp1[seas][varID][levelID]);
 		}
 	    }
-	else if ( operfunc == func_std || operfunc == func_var )
+	else if ( lvarstd )
 	  for ( varID = 0; varID < nvars; varID++ )
 	    {
 	      if ( vlistInqVarTsteptype(vlistID1, varID) == TSTEP_CONSTANT ) continue;
-	      nlevel   = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
+	      nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID1, varID));
 	      for ( levelID = 0; levelID < nlevel; levelID++ )
 		{
 		  if ( samp1[seas][varID][levelID].ptr == NULL )
 		    {
-		      if ( operfunc == func_std )
-			farcstd(&vars1[seas][varID][levelID], vars2[seas][varID][levelID], 1.0/nsets[seas]);
+		      if ( lstd )
+			farcstd(&vars1[seas][varID][levelID], vars2[seas][varID][levelID], nsets[seas], divisor);
 		      else
-			farcvar(&vars1[seas][varID][levelID], vars2[seas][varID][levelID], 1.0/nsets[seas]);
+			farcvar(&vars1[seas][varID][levelID], vars2[seas][varID][levelID], nsets[seas], divisor);
 		    }
 		  else
 		    {
-		      farinv(&samp1[seas][varID][levelID]);
-		      if ( operfunc == func_std )
-			farstd(&vars1[seas][varID][levelID], vars2[seas][varID][levelID], samp1[seas][varID][levelID]);
+		      if ( lstd )
+			farstd(&vars1[seas][varID][levelID], vars2[seas][varID][levelID], samp1[seas][varID][levelID], divisor);
 		      else
-			farvar(&vars1[seas][varID][levelID], vars2[seas][varID][levelID], samp1[seas][varID][levelID]);
+			farvar(&vars1[seas][varID][levelID], vars2[seas][varID][levelID], samp1[seas][varID][levelID], divisor);
 		    }
 		}
 	    }
@@ -312,19 +290,19 @@ void *Yseasstat(void *argument)
 	{
 	  field_free(vars1[seas], vlistID1);
 	  field_free(samp1[seas], vlistID1);
-	  if ( operfunc == func_std || operfunc == func_var ) free(vars2[seas]);
+	  if ( lvarstd ) Free(vars2[seas]);
 	}
     }
 
-  if ( field.ptr ) free(field.ptr);
+  if ( field.ptr ) Free(field.ptr);
 
-  if ( recVarID   ) free(recVarID);
-  if ( recLevelID ) free(recLevelID);
+  if ( recVarID   ) Free(recVarID);
+  if ( recLevelID ) Free(recLevelID);
 
   streamClose(streamID2);
   streamClose(streamID1);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/Zonstat.c b/src/Zonstat.c
index 689eee3..59bec47 100644
--- a/src/Zonstat.c
+++ b/src/Zonstat.c
@@ -25,7 +25,9 @@
       Zonstat    zonmean         Zonal mean
       Zonstat    zonavg          Zonal average
       Zonstat    zonstd          Zonal standard deviation
+      Zonstat    zonstd1         Zonal standard deviation [Divisor is (n-1)]
       Zonstat    zonvar          Zonal variance
+      Zonstat    zonvar1         Zonal variance [Divisor is (n-1)]
       Zonstat    zonpctl         Zonal percentiles
 */
 
@@ -33,29 +35,17 @@
 #include <cdi.h>
 #include "cdo.h"
 #include "cdo_int.h"
-#include "grid.h"
 #include "pstream.h"
+#include "grid.h"
 
 
 void *Zonstat(void *argument)
 {
-  int operatorID;
-  int operfunc;
-  int streamID1, streamID2;
-  int vlistID1, vlistID2;
   int gridID1 = -1, gridID2 = -1;
   int zongridID = -1;
-  int nlatmax;
-  int index, ngrids;
+  int index;
   int recID, nrecs;
-  int tsID, varID, levelID;
-  int lim;
-  int ndiffgrids;
-  int taxisID1, taxisID2;
-  field_t field1, field2;
-  /* RQ */
-  int pn = 0;
-  /* QR */
+  int varID, levelID;
 
   cdoInitialize(argument);
 
@@ -66,31 +56,32 @@ void *Zonstat(void *argument)
   cdoOperatorAdd("zonmean",  func_mean,  0, NULL);
   cdoOperatorAdd("zonavg",   func_avg,   0, NULL);
   cdoOperatorAdd("zonvar",   func_var,   0, NULL);
+  cdoOperatorAdd("zonvar1",  func_var1,  0, NULL);
   cdoOperatorAdd("zonstd",   func_std,   0, NULL);
+  cdoOperatorAdd("zonstd1",  func_std1,  0, NULL);
   cdoOperatorAdd("zonpctl",  func_pctl,  0, NULL);
 
-  operatorID = cdoOperatorID();
-  operfunc = cdoOperatorF1(operatorID);
+  int operatorID = cdoOperatorID();
+  int operfunc = cdoOperatorF1(operatorID);
 
+  double pn = 0;
   if ( operfunc == func_pctl )
     {
       operatorInputArg("percentile number");
-      pn = parameter2int(operatorArgv()[0]);
-      
-      if ( pn < 1 || pn > 99 )
-        cdoAbort("Illegal argument: percentile number %d is not in the range 1..99!", pn);
+      pn = parameter2double(operatorArgv()[0]);
+      percentile_check_number(pn);
     }
 
-  streamID1 = streamOpenRead(cdoStreamName(0));
+  int streamID1 = streamOpenRead(cdoStreamName(0));
 
-  vlistID1 = streamInqVlist(streamID1);
-  vlistID2 = vlistDuplicate(vlistID1);
+  int vlistID1 = streamInqVlist(streamID1);
+  int vlistID2 = vlistDuplicate(vlistID1);
 
-  taxisID1 = vlistInqTaxis(vlistID1);
-  taxisID2 = taxisDuplicate(taxisID1);
+  int taxisID1 = vlistInqTaxis(vlistID1);
+  int taxisID2 = taxisDuplicate(taxisID1);
   vlistDefTaxis(vlistID2, taxisID2);
 
-  ngrids = vlistNgrids(vlistID1);
+  int ngrids = vlistNgrids(vlistID1);
   for ( index = 0; index < ngrids; index++ )
     {
       if ( gridInqXsize(vlistGrid(vlistID1, index)) > 1 ) 
@@ -103,7 +94,7 @@ void *Zonstat(void *argument)
 	}
     }
 
-  ndiffgrids = 0;
+  int ndiffgrids = 0;
   for ( index = 0; index < ngrids; index++ )
     {
       if ( zongridID != -1 && zongridID == vlistGrid(vlistID1, index) ) continue;
@@ -136,21 +127,23 @@ void *Zonstat(void *argument)
   for ( index = 0; index < ngrids; index++ )
     vlistChangeGridIndex(vlistID2, index, gridID2);
 
-  streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
+  int streamID2 = streamOpenWrite(cdoStreamName(1), cdoFiletype());
 
   streamDefVlist(streamID2, vlistID2);
 
   gridID1 = vlistInqVarGrid(vlistID1, 0);
-  nlatmax = gridInqYsize(gridID1); /* max nlat ? */
+  int nlatmax = gridInqYsize(gridID1); /* max nlat ? */
 
-  lim = vlistGridsizeMax(vlistID1);
+  int lim = vlistGridsizeMax(vlistID1);
+
+  field_t field1, field2;
   field_init(&field2);
   field_init(&field2);
-  field1.ptr  = (double*) malloc(lim*sizeof(double));
-  field2.ptr  = (double*) malloc(nlatmax*sizeof(double));
+  field1.ptr  = (double*) Malloc(lim*sizeof(double));
+  field2.ptr  = (double*) Malloc(nlatmax*sizeof(double));
   field2.grid = gridID2;
 
-  tsID = 0;
+  int tsID = 0;
   while ( (nrecs = streamInqTimestep(streamID1, tsID)) )
     {
       taxisCopyTimestep(taxisID2, taxisID1);
@@ -188,10 +181,10 @@ void *Zonstat(void *argument)
   streamClose(streamID2);
   streamClose(streamID1);
 
-  if ( field1.ptr ) free(field1.ptr);
-  if ( field2.ptr ) free(field2.ptr);
+  if ( field1.ptr ) Free(field1.ptr);
+  if ( field2.ptr ) Free(field2.ptr);
 
   cdoFinish();
 
-  return (0);
+  return 0;
 }
diff --git a/src/after_dvtrans.c b/src/after_dvtrans.c
index ed3faad..adce322 100644
--- a/src/after_dvtrans.c
+++ b/src/after_dvtrans.c
@@ -1,11 +1,15 @@
 #include <math.h>
 
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
 #include "constants.h"
 
 
 #define  SQUARE_RADIUS   (-PlanetRadius * PlanetRadius)
 
-void dv2ps(const double * restrict div, double * restrict pot, long nlev, long ntr)
+void dv2ps(const double *restrict div, double *restrict pot, long nlev, long ntr)
 {
   long l, m, n;
   double fact;
diff --git a/src/after_fctrans.c b/src/after_fctrans.c
index 7587ffe..6b84069 100644
--- a/src/after_fctrans.c
+++ b/src/after_fctrans.c
@@ -2,6 +2,10 @@
 #include <stdlib.h>
 #include <math.h>
 
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
 #ifndef _DMEMORY_H
 #  include "dmemory.h"
 #endif
@@ -2134,9 +2138,9 @@ void fc2gp(double *restrict trig, long *restrict ifax, double *restrict fc, doub
   long jump = (nlon + 2);
   long lot  = nlev * nlat;
 
-  double *restrict wfc = (double*) malloc(lot*jump*sizeof(double));
+  double *restrict wfc = (double*) Malloc(lot*jump*sizeof(double));
 #if ! defined(_OPENMP)
-  double *restrict wgp = (double*) malloc(lot*jump*sizeof(double));
+  double *restrict wgp = (double*) Malloc(lot*jump*sizeof(double));
 #endif
 
   for ( lev = 0; lev < nlev; ++lev )
@@ -2160,7 +2164,7 @@ void fc2gp(double *restrict trig, long *restrict ifax, double *restrict fc, doub
   nvex  = lot - (nblox-1)*NFFT;
   nvex0 = nvex;
 
-  istartv = (long*) malloc(nblox*sizeof(long));
+  istartv = (long*) Malloc(nblox*sizeof(long));
 
   istart = 0;
   for ( nb = 0; nb < nblox; nb++ )
@@ -2176,7 +2180,7 @@ void fc2gp(double *restrict trig, long *restrict ifax, double *restrict fc, doub
   for ( nb = 0; nb < nblox; nb++ )
     {
 #if defined(_OPENMP)
-      double *restrict wgp = (double*) malloc(lot*jump*sizeof(double));
+      double *restrict wgp = (double*) Malloc(lot*jump*sizeof(double));
 #endif
       istart = istartv[nb];
       if ( nb == 0 ) nvex = nvex0;
@@ -2251,7 +2255,7 @@ void fc2gp(double *restrict trig, long *restrict ifax, double *restrict fc, doub
 	}
 
 #if defined(_OPENMP)
-      free(wgp);
+      Free(wgp);
 #endif
     }
 
@@ -2264,11 +2268,11 @@ void fc2gp(double *restrict trig, long *restrict ifax, double *restrict fc, doub
     for ( lon = 0; lon < nlon; ++lon )
       gp[lon + j*nlon] = wpt[lon + j*jump];
 
-  free(istartv);
+  Free(istartv);
 #if ! defined(_OPENMP)
-  free(wgp);
+  Free(wgp);
 #endif
-  free(wfc);
+  Free(wfc);
 }
 
 
@@ -2299,8 +2303,8 @@ void gp2fc(double *trig, long *ifax, const double *restrict gp, double *restrict
   jump = (nlon + 2);
   lot  = nlev * nlat;
 
-  double *restrict wfc = (double*) malloc(lot * jump * sizeof(double));
-  double *restrict wgp = (double*) malloc(lot * jump * sizeof(double));
+  double *restrict wfc = (double*) Malloc(lot * jump * sizeof(double));
+  double *restrict wgp = (double*) Malloc(lot * jump * sizeof(double));
 
   rix = 0;
   wix = 0;
@@ -2402,6 +2406,6 @@ void gp2fc(double *trig, long *ifax, const double *restrict gp, double *restrict
 	}
     }
 
-  free(wgp);
-  free(wfc);
+  Free(wgp);
+  Free(wfc);
 }
diff --git a/src/after_namelist.c b/src/after_namelist.c
index fb592a8..817eaf6 100644
--- a/src/after_namelist.c
+++ b/src/after_namelist.c
@@ -6,7 +6,7 @@
 
 
 static
-char *amatch(char *msr, char *sub)
+char *amatch(char *msr, const char *sub)
 {
   int i,nm,ns;
 
@@ -20,7 +20,7 @@ char *amatch(char *msr, char *sub)
 }
 
 
-int scan_par_obsolate(char *namelist, char *name, int def)
+int scan_par_obsolate(char *namelist, const char *name, int def)
 {
   char *cp;
   int value;
@@ -38,7 +38,7 @@ int scan_par_obsolate(char *namelist, char *name, int def)
 }
 
 
-int scan_par(int verbose, char *namelist, char *name, int def)
+int scan_par(int verbose, char *namelist, const char *name, int def)
 {
   char *cp;
   int value;
@@ -115,7 +115,7 @@ void scan_code(char *namelist, struct Variable *vars, int maxCodes, int *numCode
 }
 
 
-void scan_darray(char *namelist, char *name, double *values, int maxValues, int *numValues)
+void scan_darray(char *namelist, const char *name, double *values, int maxValues, int *numValues)
 {
   char *cp,*icp;
   double val;
diff --git a/src/after_sptrans.c b/src/after_sptrans.c
index d78d757..8492960 100644
--- a/src/after_sptrans.c
+++ b/src/after_sptrans.c
@@ -3,6 +3,14 @@
 #include <string.h>
 #include <math.h>
 
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
+#ifndef _DMEMORY_H
+#  include "dmemory.h"
+#endif
+
 #include "constants.h"
 
 #define  OPENMP4  201307
@@ -10,7 +18,7 @@
 #define  HAVE_OPENMP4  1
 #endif
 
-void gaussaw(double *pa, double *pw, int nlat);
+void gaussaw(double *pa, double *pw, size_t nlat);
 
 static
 void jspleg1(double *pleg, double plat, int ktrunc, double *work)
@@ -278,16 +286,16 @@ void after_legini_full(int ntr, int nlat, double *restrict poli, double *restric
   int waves =  ntr + 1;
   int dimsp = (ntr + 1) * (ntr + 2);
 
-  double *gmu = (double*) malloc(nlat * sizeof(double));
-  double *gwt = (double*) malloc(nlat * sizeof(double));
+  double *gmu = (double*) Malloc(nlat * sizeof(double));
+  double *gwt = (double*) Malloc(nlat * sizeof(double));
 
   gaussaw(gmu, gwt, nlat);
 
 #if ! defined(_OPENMP)
-  double *pnm    = (double*) malloc(dimsp * sizeof(double));
-  double *hnm    = (double*) malloc(dimsp * sizeof(double));
-  double *ztemp1 = (double*) malloc((waves<<1) * sizeof(double));
-  double *ztemp2 = (double*) malloc((waves<<1) * sizeof(double));
+  double *pnm    = (double*) Malloc(dimsp * sizeof(double));
+  double *hnm    = (double*) Malloc(dimsp * sizeof(double));
+  double *ztemp1 = (double*) Malloc((waves<<1) * sizeof(double));
+  double *ztemp2 = (double*) Malloc((waves<<1) * sizeof(double));
 #endif
 
 #if defined(_OPENMP)
@@ -296,10 +304,10 @@ void after_legini_full(int ntr, int nlat, double *restrict poli, double *restric
   for ( jgl = 0; jgl < nlat; jgl++ )
     {
 #if defined(_OPENMP)
-      double *pnm    = (double*) malloc(dimsp * sizeof(double));
-      double *hnm    = (double*) malloc(dimsp * sizeof(double));
-      double *ztemp1 = (double*) malloc((waves<<1) * sizeof(double));
-      double *ztemp2 = (double*) malloc((waves<<1) * sizeof(double));
+      double *pnm    = (double*) Malloc(dimsp * sizeof(double));
+      double *hnm    = (double*) Malloc(dimsp * sizeof(double));
+      double *ztemp1 = (double*) Malloc((waves<<1) * sizeof(double));
+      double *ztemp2 = (double*) Malloc((waves<<1) * sizeof(double));
 #endif
       gmusq = 1.0 - gmu[jgl]*gmu[jgl];
       coslat[jgl] = sqrt(gmusq);
@@ -328,21 +336,21 @@ void after_legini_full(int ntr, int nlat, double *restrict poli, double *restric
 	  }
       
 #if defined(_OPENMP)
-      free(ztemp2);
-      free(ztemp1);
-      free(pnm);
-      free(hnm);
+      Free(ztemp2);
+      Free(ztemp1);
+      Free(pnm);
+      Free(hnm);
 #endif
     }
 
 #if ! defined(_OPENMP)
-  free(ztemp2);
-  free(ztemp1);
-  free(pnm);
-  free(hnm);
+  Free(ztemp2);
+  Free(ztemp1);
+  Free(pnm);
+  Free(hnm);
 #endif
-  free(gwt);
-  free(gmu);
+  Free(gwt);
+  Free(gmu);
 }
 
 
@@ -354,10 +362,10 @@ void after_legini(int ntr, int nlat, double *restrict poli, double *restrict pol
   int waves  =  ntr + 1;
   int dimpnm = (ntr + 1)*(ntr + 4)/2;
 
-  double *gmu  = (double*) malloc(nlat * sizeof(double));
-  double *gwt  = (double*) malloc(nlat * sizeof(double));
-  double *pnm  = (double*) malloc(dimpnm * sizeof(double));
-  double *work = (double*) malloc(3*waves * sizeof(double));
+  double *gmu  = (double*) Malloc(nlat * sizeof(double));
+  double *gwt  = (double*) Malloc(nlat * sizeof(double));
+  double *pnm  = (double*) Malloc(dimpnm * sizeof(double));
+  double *work = (double*) Malloc(3*waves * sizeof(double));
 
   gaussaw(gmu, gwt, nlat);
   for ( jgl = 0; jgl < nlat; ++jgl ) gwt[jgl] *= 0.5;
@@ -396,10 +404,10 @@ void after_legini(int ntr, int nlat, double *restrict poli, double *restrict pol
 	}
     }
 
-  free(work);
-  free(pnm);
-  free(gwt);
-  free(gmu);
+  Free(work);
+  Free(pnm);
+  Free(gwt);
+  Free(gmu);
 }
 
 
diff --git a/src/after_vertint.c b/src/after_vertint.c
index 8b894d0..f750c50 100644
--- a/src/after_vertint.c
+++ b/src/after_vertint.c
@@ -2,6 +2,7 @@
 #include <stdlib.h> /* exit */
 #include <string.h>
 #include <math.h>
+#include <assert.h>
 
 #include "compare.h"
 #include "constants.h"
@@ -197,14 +198,6 @@ double extra_T(double pres, double halfp, double fullp, double geop, double temp
 
   if ( ztmsl > 290.5 && tstar <= 290.5 ) ztmsl=290.5;
 
-  zalph = PlanetRD*zlapse*zrg;
-
-  if ( ztmsl-tstar < 0.000001 && tstar-ztmsl < 0.000001 ) zalph=0.0;
-
-  if ( (ztmsl-tstar > 0.000001 || tstar-ztmsl > 0.000001 ) &&
-       (geop > 0.0001 || geop < -0.0001) )
-    zalph = PlanetRD*(ztmsl-tstar)/geop;
-
   if ( pres <= halfp )
     peval = ((halfp-pres)*temp+ (pres-fullp)*tstar)/ (halfp-fullp);
   else
@@ -276,18 +269,15 @@ void interp_X(const double * restrict gt, double *pt, const double * restrict hy
 {
   long lp, i;
   long nl, nh;
-  const int *nxl;
-  double *ptl;
-  double pres;
 
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(i, pres, nl, nh, nxl, ptl)
+#pragma omp parallel for default(shared) private(i, nl, nh)
 #endif
   for ( lp = 0; lp < nplev; lp++ )
     {
-      pres = plev[lp];
-      nxl  = nx + lp*ngp;
-      ptl  = pt + lp*ngp;
+      double pres = plev[lp];
+      const int *nxl  = nx + lp*ngp;
+      double *ptl  = pt + lp*ngp;
       for ( i = 0; i < ngp; i++ )
 	{
 	  if ( nxl[i] == -1 )
@@ -297,10 +287,11 @@ void interp_X(const double * restrict gt, double *pt, const double * restrict hy
 	      nl = nxl[i] * ngp + i;
 	      nh = nl + ngp;
 	      if ( nh >= ngp*nhlev )
-		ptl[i] = gt[nl];
+		ptl[i] =  gt[nl];
 	      else
 		ptl[i] =  gt[nl] + (pres-hyb_press[nl])
-		       * (gt[nh] - gt[nl]) / (hyb_press[nh] - hyb_press[nl]);
+		       * (gt[nh] - gt[nl])
+                       / (hyb_press[nh] - hyb_press[nl]);
 	    }
 	}
     }
@@ -313,18 +304,15 @@ void interp_T(const double * restrict geop, const double * restrict gt, double *
 {
   long lp, i;
   long nl, nh;
-  const int *nxl;
-  double *ptl;
-  double pres;
 
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(i, pres, nl, nh, nxl, ptl)
+#pragma omp parallel for default(shared) private(i, nl, nh)
 #endif
   for ( lp = 0; lp < nplev; lp++ )
     {
-      pres = plev[lp];
-      nxl  = nx + lp*ngp;
-      ptl  = pt + lp*ngp;
+      double pres = plev[lp];
+      const int *nxl  = nx + lp*ngp;
+      double *ptl  = pt + lp*ngp;
 #if defined(CRAY)
 #pragma _CRI inline extra_T
 #endif
@@ -366,18 +354,21 @@ void interp_Z(const double * restrict geop, const double * restrict gz, double *
 {
   long lp, i;
   long nl, nh;
-  const int *nxl;
-  double *pzl;
-  double pres;
+
+  assert(geop != NULL);
+  assert(gz != NULL);
+  assert(pz != NULL);
+  assert(fullp != NULL);
+  assert(halfp != NULL);
 
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) private(i, pres, nl, nh, nxl, pzl)
+#pragma omp parallel for default(shared) private(i, nl, nh)
 #endif
   for ( lp = 0; lp < nplev; lp++ )
     {
-      pres = plev[lp];
-      nxl  = nx + lp*ngp;
-      pzl  = pz + lp*ngp;
+      double pres = plev[lp];
+      const int *nxl  = nx + lp*ngp;
+      double *pzl  = pz + lp*ngp;
 #if defined(CRAY)
 #pragma _CRI inline extra_Z
 #endif
diff --git a/src/afterburner.h b/src/afterburner.h
index 0b801a4..887b581 100644
--- a/src/afterburner.h
+++ b/src/afterburner.h
@@ -1,6 +1,9 @@
 #ifndef _AFTERBURNER_H
 #define _AFTERBURNER_H
 
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
 /* =============================================== */
 /* These include files should be standard on all   */
 /* UNIX systems.                                   */
diff --git a/src/afterburnerlib.c b/src/afterburnerlib.c
index 89c03a9..19f1ba7 100644
--- a/src/afterburnerlib.c
+++ b/src/afterburnerlib.c
@@ -43,7 +43,7 @@ char *FieldName(int code, const char *text)
 static
 void *FreeMemory(void *ptr)
 {
-  free(ptr);
+  Free(ptr);
 
   return (NULL);
 }
@@ -55,7 +55,7 @@ void FreeSpectral(struct Variable *vars)
 
   for ( code = MaxCodes-1; code >= 0; --code )
     if ( vars[code].spectral )
-      vars[code].spectral = FreeMemory(vars[code].spectral);
+      vars[code].spectral = (double *)FreeMemory(vars[code].spectral);
 }
 
 static
@@ -65,7 +65,7 @@ void FreeFourier(struct Variable *vars)
 
   for ( code = 0; code < MaxCodes; code++ )
     if ( vars[code].fourier )
-      vars[code].fourier = FreeMemory(vars[code].fourier);
+      vars[code].fourier = (double *)FreeMemory(vars[code].fourier);
 }
 
 static
@@ -75,7 +75,7 @@ void FreeHybrid(struct Variable *vars)
 
   for ( code = 0; code < MaxCodes; code++ )
     if ( vars[code].hybrid )
-      vars[code].hybrid = FreeMemory(vars[code].hybrid);
+      vars[code].hybrid = (double *)FreeMemory(vars[code].hybrid);
 }
 
 static
@@ -85,7 +85,7 @@ void FreeGrid(struct Variable *vars)
 
   for ( code = 0; code < MaxCodes; code++ )
     if ( vars[code].grid )
-      vars[code].grid = FreeMemory(vars[code].grid);
+      vars[code].grid = (double *)FreeMemory(vars[code].grid);
 }
 
 static
@@ -95,18 +95,18 @@ void FreeSamp(struct Variable *vars)
 
   for ( code = 0; code < MaxCodes; code++ )
     if ( vars[code].samp )
-      vars[code].samp = FreeMemory(vars[code].samp);
+      vars[code].samp = (int *)FreeMemory(vars[code].samp);
 }
 
 /* alloc_dp - Allocate space for double array */
 static
-double *alloc_dp(int words, char *array_name)
+double *alloc_dp(int words, const char *array_name)
 {
   double *result = NULL;
 
   if ( words > 0 )
     {
-      result = (double *) malloc(words * sizeof(double));
+      result = (double *) Malloc(words * sizeof(double));
 
       if ( result == NULL ) SysError(array_name, "No Memory!");
     }
@@ -264,7 +264,7 @@ void after_read_vct(const char *vctfile, double **vct, int *nvct)
   while ( fgets(line, 1023, fp) ) nvct++;
 
   *nvct *= 2;
-  *vct = (double *) malloc(*nvct*sizeof(double));
+  *vct = (double *) Malloc(*nvct*sizeof(double));
 
   rewind(fp);
   for ( int i = 0; i < *nvct/2; i++ )
@@ -314,8 +314,8 @@ void after_GP2FC(double *gp, double *fc, long nlat, long nlon, long nlev, long n
 
   if ( ifax[9] != nlon )
     {
-      if ( trig ) free (trig);
-      trig = (double *) malloc(nlon * sizeof(double));
+      if ( trig ) Free(trig);
+      trig = (double *) Malloc(nlon * sizeof(double));
       fft_set (trig, ifax, nlon);
     }
 
@@ -330,8 +330,8 @@ void after_FC2GP(double *fc, double *gp, long nlat, long nlon, long nlev, long n
 
   if ( ifax[9] != nlon )
     {
-      if ( trig ) free (trig);
-      trig = (double *) malloc(nlon * sizeof(double));
+      if ( trig ) Free(trig);
+      trig = (double *) Malloc(nlon * sizeof(double));
       fft_set (trig, ifax, nlon);
     }
 
@@ -464,9 +464,9 @@ void after_FCrh2FCsh(struct Control *globs, struct Variable *vars)
    after_GP2FC(vars[HUMIDITY].grid, vars[HUMIDITY].fourier,
 	       globs->Latitudes, globs->Longitudes, vars[HUMIDITY].plev, globs->Fouriers);
 
-   vars[HUMIDITY].grid    = FreeMemory(vars[HUMIDITY].grid);
-   vars[RHUMIDITY].grid   = FreeMemory(vars[RHUMIDITY].grid);
-   vars[TEMPERATURE].grid = FreeMemory(vars[TEMPERATURE].grid);
+   vars[HUMIDITY].grid    = (double *)FreeMemory(vars[HUMIDITY].grid);
+   vars[RHUMIDITY].grid   = (double *)FreeMemory(vars[RHUMIDITY].grid);
+   vars[TEMPERATURE].grid = (double *)FreeMemory(vars[TEMPERATURE].grid);
 }
 
 
@@ -492,8 +492,8 @@ void after_SPuv2SPdv(struct Control *globs, struct Variable *vars)
    uv2dv(vars[U_WIND].fourier, vars[V_WIND].fourier, Div, Vor,
          globs->pol2, globs->pol3, globs->NumLevelRequest, globs->Latitudes, globs->Truncation);
 
-   vars[U_WIND].fourier = FreeMemory(vars[U_WIND].fourier);
-   vars[V_WIND].fourier = FreeMemory(vars[V_WIND].fourier);
+   vars[U_WIND].fourier = (double *)FreeMemory(vars[U_WIND].fourier);
+   vars[V_WIND].fourier = (double *)FreeMemory(vars[V_WIND].fourier);
 
    for (i = 0; i < globs->NumLevelRequest; ++i) {
       sp2sp(Div, globs->Truncation, DivOut, globs->Truncation);
@@ -530,9 +530,9 @@ void after_FCsh2FCrh(struct Control *globs, struct Variable *vars)
    after_GP2FC(vars[RHUMIDITY].grid, vars[RHUMIDITY].fourier,
 	       globs->Latitudes, globs->Longitudes, vars[RHUMIDITY].plev, globs->Fouriers);
 
-   vars[HUMIDITY].grid    = FreeMemory(vars[HUMIDITY].grid);
-   vars[RHUMIDITY].grid   = FreeMemory(vars[RHUMIDITY].grid);
-   vars[TEMPERATURE].grid = FreeMemory(vars[TEMPERATURE].grid);
+   vars[HUMIDITY].grid    = (double *)FreeMemory(vars[HUMIDITY].grid);
+   vars[RHUMIDITY].grid   = (double *)FreeMemory(vars[RHUMIDITY].grid);
+   vars[TEMPERATURE].grid = (double *)FreeMemory(vars[TEMPERATURE].grid);
 }
 /* ENDE HUMTEST */
 
@@ -540,7 +540,7 @@ static
 void CheckAnalyses(struct Variable *vars)
 {
   for ( int code = 0; code < 272; code++ )
-    if ( vars[code].needed      && 
+    if ( vars[code].needed     && 
 	 code != DIVERGENCE    &&
 	 code != VORTICITY     &&
 	 code != STREAM        &&
@@ -1223,8 +1223,6 @@ void LayerCloud(double *cc, double *ll, double pmax, double pmin,
 /* Grid Point Computations */
 void after_EchamCompGP(struct Control *globs, struct Variable *vars)
 {
-  int l;
-
   if ( vars[GEOPOTHEIGHT].comp || vars[SLP].comp || vars[THETAF].needed ||
        vars[HALF_PRESS].needed || vars[RHUMIDITY].comp || vars[OMEGA].comp ||
        globs->Type >= 30 )
@@ -1243,7 +1241,7 @@ void after_EchamCompGP(struct Control *globs, struct Variable *vars)
 	    globs->NumLevel, globs->DimGP);
     }
 
-  if ( globs->unitsel > 2 ) vars[FULL_PRESS].hybrid = FreeMemory(vars[FULL_PRESS].hybrid);
+  if ( globs->unitsel > 2 ) vars[FULL_PRESS].hybrid = (double *)FreeMemory(vars[FULL_PRESS].hybrid);
 
   if ( vars[THETAF].needed )
     {
@@ -1271,9 +1269,17 @@ void after_EchamCompGP(struct Control *globs, struct Variable *vars)
 
       vars[HUMIDITY].needed = vars[HUMIDITY].selected;
     }
+  else if ( vars[GEOPOTHEIGHT].hybrid && vars[GEOPOTHEIGHT].hlev == globs->NumLevel )
+    {
+      vars[GEOPOTHEIGHT].hlev = globs->NumLevel+1;
+      vars[GEOPOTHEIGHT].sfit = TRUE;
+      vars[GEOPOTHEIGHT].hybrid = (double *) Realloc(vars[GEOPOTHEIGHT].hybrid, (globs->Dim3GP+globs->DimGP)*sizeof(double));
+      after_copy_array(vars[GEOPOTHEIGHT].hybrid+globs->Dim3GP, globs->Orography, globs->DimGP);
+      for ( int i = 0; i < globs->DimGP; i++ ) vars[GEOPOTHEIGHT].hybrid[globs->Dim3GP+i] /= PlanetGrav;
+    }
 
   if ( vars[DPSDX].needed || vars[DPSDY].needed )
-    for (l = 0; l < globs->DimGP; l++)
+    for ( int l = 0; l < globs->DimGP; l++ )
       {
 	vars[DPSDX].hybrid[l] *= vars[PS_PROG].hybrid[l];
 	vars[DPSDY].hybrid[l] *= vars[PS_PROG].hybrid[l];
@@ -1324,7 +1330,7 @@ void after_EchamCompGP(struct Control *globs, struct Variable *vars)
       vars[PS].plev = 1;
       vars[PS].sfit = TRUE; /* ??? */
       vars[PS].hybrid = alloc_dp(globs->DimGP, "vars[PS].hybrid");
-      for (l = 0; l < globs->DimGP; l++) vars[PS].hybrid[l] = exp(vars[LNPS].hybrid[l]);
+      for ( int l = 0; l < globs->DimGP; l++ ) vars[PS].hybrid[l] = exp(vars[LNPS].hybrid[l]);
     }
 
   if ( vars[SLP].comp )
@@ -1715,10 +1721,10 @@ void after_processML(struct Control *globs, struct Variable *vars)
      }
 
    if ( vars[VORTICITY].spectral && !vars[VORTICITY].needed )
-        vars[VORTICITY].spectral = FreeMemory(vars[VORTICITY].spectral);
+        vars[VORTICITY].spectral = (double *)FreeMemory(vars[VORTICITY].spectral);
 
    if ( vars[DIVERGENCE].spectral && !vars[DIVERGENCE].needed )
-        vars[DIVERGENCE].spectral = FreeMemory(vars[DIVERGENCE].spectral);
+        vars[DIVERGENCE].spectral = (double *)FreeMemory(vars[DIVERGENCE].spectral);
 
   /* --------------------------- */
   /*  Output of spectral fields  */
@@ -1762,7 +1768,7 @@ void after_processML(struct Control *globs, struct Variable *vars)
 		      vars[code].hlev, globs->Latitudes, globs->Fouriers, globs->Truncation);
 	      }
 	    if ( code != LNPS )
-	      vars[code].spectral = FreeMemory(vars[code].spectral);
+	      vars[code].spectral = (double *)FreeMemory(vars[code].spectral);
 	  }
 
       /*    if (globs->Type < 60) globs->poli = FreeMemory(globs->poli); */
@@ -1862,7 +1868,7 @@ void after_processML(struct Control *globs, struct Variable *vars)
 		after_FC2GP(vars[code].fourier,vars[code].hybrid,
 			    globs->Latitudes,globs->Longitudes,vars[code].hlev,globs->Fouriers);
 	      }
-	    vars[code].fourier = FreeMemory(vars[code].fourier);
+	    vars[code].fourier = (double *)FreeMemory(vars[code].fourier);
 	  }
 
       if ( vars[PS_PROG].comp && vars[PS_PROG].hybrid == NULL )
@@ -1998,7 +2004,7 @@ void after_processML(struct Control *globs, struct Variable *vars)
   if ( globs->Type >= 30 )
     {
       if ( globs->vert_index == NULL )
-	globs->vert_index = (int *) malloc(globs->NumLevelRequest*globs->DimGP*sizeof(int));
+	globs->vert_index = (int *) Malloc(globs->NumLevelRequest*globs->DimGP*sizeof(int));
 
       if ( globs->unitsel )
 	{
@@ -2016,7 +2022,7 @@ void after_processML(struct Control *globs, struct Variable *vars)
       nmiss = 0;
       if ( ! globs->Extrapolate )
 	{
-	  if ( globs->pnmiss == NULL ) globs->pnmiss = (int *) malloc(globs->NumLevelRequest*sizeof(int));  
+	  if ( globs->pnmiss == NULL ) globs->pnmiss = (int *) Malloc(globs->NumLevelRequest*sizeof(int));  
 	  genindmiss(globs->vert_index, pressureLevel, globs->DimGP, globs->NumLevelRequest, vars[PS_PROG].hybrid, globs->pnmiss);
 	  for ( i = 0; i < globs->NumLevelRequest; i++ ) nmiss += globs->pnmiss[i];
 	}
@@ -2062,7 +2068,7 @@ void after_processML(struct Control *globs, struct Variable *vars)
 		if ( ! globs->Extrapolate ) vars[code].nmiss = nmiss;
 
 		if ( code != TEMPERATURE )
-		  vars[code].hybrid = FreeMemory(vars[code].hybrid);
+		  vars[code].hybrid = (double *)FreeMemory(vars[code].hybrid);
 	      }
 	  }
     }
@@ -2070,7 +2076,7 @@ void after_processML(struct Control *globs, struct Variable *vars)
   vars[TEMPERATURE].needed = vars[TEMPERATURE].selected;
   FreeHybrid(vars);
   if ( vars[HALF_PRESS].hybrid )
-    vars[HALF_PRESS].hybrid = FreeMemory(vars[HALF_PRESS].hybrid);
+    vars[HALF_PRESS].hybrid = (double *)FreeMemory(vars[HALF_PRESS].hybrid);
 
   /* -------------------------------- */
   /*  Output of pressure level grids  */
@@ -2195,8 +2201,8 @@ void after_processML(struct Control *globs, struct Variable *vars)
     for ( code = 0; code < MaxCodes; code++ )
       if ( vars[code].mean )
 	{
-	  if ( vars[code].variance ) vars[code].variance = FreeMemory(vars[code].variance);
-	  if ( vars[code].grid )     vars[code].grid     = FreeMemory(vars[code].grid);
+	  if ( vars[code].variance ) vars[code].variance = (double *)FreeMemory(vars[code].variance);
+	  if ( vars[code].grid )     vars[code].grid     = (double *)FreeMemory(vars[code].grid);
 	  vars[code].grid = vars[code].mean;
 	  vars[code].mean = NULL;
 	}
@@ -2223,13 +2229,13 @@ void after_processML(struct Control *globs, struct Variable *vars)
 			globs->Latitudes, globs->Longitudes, vars[code].plev, globs->Fouriers);
 
 	    if ( vars[code].grid && (vars[code].sfit || globs->Type < 70) )
-	      vars[code].grid = FreeMemory(vars[code].grid);
+	      vars[code].grid = (double *)FreeMemory(vars[code].grid);
 	  }
     }
 
   for (code = 0; code < MaxCodes; code++)
     if (vars[code].grid && (vars[code].sfit || globs->Type < 70))
-      vars[code].grid = FreeMemory(vars[code].grid);
+      vars[code].grid = (double *)FreeMemory(vars[code].grid);
 
   /* -------------------------- */
   /*  Output of fourier fields  */
@@ -2342,7 +2348,7 @@ void after_processML(struct Control *globs, struct Variable *vars)
 
   for ( code = 0; code < MaxCodes; code++ )
     if ( vars[code].fourier && (vars[code].sfit || globs->Type < 61) )
-      vars[code].fourier = FreeMemory(vars[code].fourier);
+      vars[code].fourier = (double *)FreeMemory(vars[code].fourier);
 
   /* --------------------------- */
   /*  Output of spectral fields  */
@@ -2556,7 +2562,7 @@ void after_AnalysisAddRecord(struct Control *globs, struct Variable *vars, int c
 	  int i;
 	  if ( vars[code].samp == NULL )
 	    {
-	      vars[code].samp = (int *) malloc(dataSize*sizeof(int));
+	      vars[code].samp = (int *) Malloc(dataSize*sizeof(int));
 	      for ( i = 0; i < dataSize; i++ ) vars[code].samp[i] = globs->MeanCount0;
 	    }
 
@@ -2619,7 +2625,7 @@ void after_EchamAddRecord(struct Control *globs, struct Variable *vars, int code
 	  int i;
 	  if ( vars[code].samp == NULL )
 	    {
-	      vars[code].samp = (int *) malloc(dataSize*sizeof(int));
+	      vars[code].samp = (int *) Malloc(dataSize*sizeof(int));
 	      for ( i = 0; i < dataSize; i++ ) vars[code].samp[i] = globs->MeanCount0;
 	    }
 
@@ -2906,26 +2912,26 @@ void after_legini_setup(struct Control *globs, struct Variable *vars)
   int dimsp = (ntr + 1) * (ntr + 2);
   int pdim  = dimsp / 2 * nlat;
 
-  globs->poli = (double *) malloc(pdim*sizeof(double));
+  globs->poli = (double *) Malloc(pdim*sizeof(double));
   
   if ( ! globs->AnalysisData )
     {
-      if ( globs->Type >= 20 )  globs->pold = (double *) malloc(pdim*sizeof(double));
-      if ( vars[DPSDY].needed ) globs->pdev = (double *) malloc(pdim*sizeof(double));
+      if ( globs->Type >= 20 )  globs->pold = (double *) Malloc(pdim*sizeof(double));
+      if ( vars[DPSDY].needed ) globs->pdev = (double *) Malloc(pdim*sizeof(double));
     }
   
   if ( (vars[DIVERGENCE].needed || vars[VORTICITY].needed ||
 	vars[VELOPOT].needed || vars[STREAM].needed ) && globs->Type > 20 )
     {
-      globs->pol2 = (double *) malloc(pdim*sizeof(double));
-      globs->pol3 = (double *) malloc(pdim*sizeof(double));
+      globs->pol2 = (double *) Malloc(pdim*sizeof(double));
+      globs->pol3 = (double *) Malloc(pdim*sizeof(double));
     }
 
   if ( globs->AnalysisData && (globs->Type == 70) && globs->Gaussian && !globs->Spectral )
     {
-      if ( globs->poli ) { free(globs->poli); globs->poli = NULL;}
-      if ( globs->pol2 ) { free(globs->pol2); globs->pol2 = NULL;}
-      if ( globs->pol3 ) { free(globs->pol3); globs->pol3 = NULL;}
+      if ( globs->poli ) { Free(globs->poli); globs->poli = NULL;}
+      if ( globs->pol2 ) { Free(globs->pol2); globs->pol2 = NULL;}
+      if ( globs->pol3 ) { Free(globs->pol3); globs->pol3 = NULL;}
       return;
     }
 
diff --git a/src/cdo.c b/src/cdo.c
index e91631a..4105d2e 100644
--- a/src/cdo.c
+++ b/src/cdo.c
@@ -20,13 +20,9 @@
 #endif
 
 #ifndef _XOPEN_SOURCE
-#define _XOPEN_SOURCE 600 /* gethostname */
+//#define _XOPEN_SOURCE 600 /* gethostname */
 #endif
 
-#include <limits.h>
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
 #include <ctype.h>
 /*#include <malloc.h>*/ /* mallopt and malloc_stats */
 #include <sys/stat.h>
@@ -75,8 +71,10 @@ static int Help = 0;
 static int DebugLevel = 0;
 static int numThreads = 0;
 static int timer_total;
-static int CDO_netcdf_hdr_pad   = 0;
+static int CDO_netcdf_hdr_pad = 0;
+static int CDO_Rusage = 0;
 
+void gridsearch_set_method(const char *methodstr);
 
 #define PRINT_RLIMIT(resource) \
       { \
@@ -171,13 +169,16 @@ void cdo_usage(void)
 #if defined(_OPENMP)
   fprintf(stderr, "    -P <nthreads>  Set number of OpenMP threads\n");
 #endif
+  fprintf(stderr, "    --percentile <method>\n");
+  fprintf(stderr, "                   Percentile method: nrank, nist, numpy, numpy_lower, numpy_higher, numpy_nearest\n");
   fprintf(stderr, "    -Q             Alphanumeric sorting of netCDF parameter names\n");
+  fprintf(stderr, "    --reduce_dim   Reduce netCDF dimensions (module: TIMSTAT, FLDSTAT)\n");
   fprintf(stderr, "    -R, --regular  Convert GRIB1 data from reduced to regular grid (only with cgribex)\n");
   fprintf(stderr, "    -r             Generate a relative time axis\n");
   fprintf(stderr, "    -S             Create an extra output stream for the module TIMSTAT. This stream\n");
   fprintf(stderr, "                   contains the number of non missing values for each output period.\n");
   fprintf(stderr, "    -s, --silent   Silent mode\n");
-  fprintf(stderr, "    -t <partab>    Set default parameter table name or file\n");
+  fprintf(stderr, "    -t <partab>    Set GRIB1 default parameter table name or file\n");
   fprintf(stderr, "                   Predefined tables: ");
   for ( int id = 0; id < tableInqNumber(); id++ )
     if ( (name = tableInqNamePtr(id)) )
@@ -218,7 +219,7 @@ void cdo_init_is_tty(void)
 }
 
 static
-void cdoPrintHelp(char *phelp[]/*, char *xoperator*/)
+void cdoPrintHelp(const char *phelp[]/*, char *xoperator*/)
 {
   if ( phelp == NULL )
     fprintf(stderr, "No help available for this operator!\n");
@@ -243,6 +244,7 @@ void cdoPrintHelp(char *phelp[]/*, char *xoperator*/)
                        (strcmp(*phelp, "NAMELIST")    == 0) ||
                        (strcmp(*phelp, "PARAMETER")   == 0) ||
                        (strcmp(*phelp, "ENVIRONMENT") == 0) ||
+                       (strcmp(*phelp, "NOTE")        == 0) ||
                        (strcmp(*phelp, "EXAMPLES")    == 0) )
                     {
                       set_text_color(stdout, BRIGHT, BLACK);
@@ -294,7 +296,7 @@ void cdoSetDebug(int level)
 #define IsBigendian()  ( u_byteorder.c[sizeof(long) - 1] )
 
 static
-void setDefaultDataType(char *datatypestr)
+void setDefaultDataType(const char *datatypestr)
 {
   static union {unsigned long l; unsigned char c[sizeof(long)];} u_byteorder = {1};
   int nbits = -1;
@@ -418,7 +420,7 @@ void setDefaultDataType(char *datatypestr)
         }
     }
 }
-
+/*
 static
 void setDefaultDataTypeByte(char *datatypestr)
 {
@@ -448,7 +450,7 @@ void setDefaultDataTypeByte(char *datatypestr)
       if ( *datatypestr == 'l' || *datatypestr == 'L' )
         {
           if ( IsBigendian() ) cdoDefaultByteorder = CDI_LITTLEENDIAN;
-          datatypestr++;
+          datatypestr++;setDefaultDataTypeByte
         }
       else if ( *datatypestr == 'b' || *datatypestr == 'B' )
         {
@@ -462,13 +464,13 @@ void setDefaultDataTypeByte(char *datatypestr)
         }
     }
 }
-
+*/
 static
-void setDefaultFileType(char *filetypestr, int labort)
+void setDefaultFileType(const char *filetypestr, int labort)
 {
   if ( filetypestr )
     {
-      char *ftstr = filetypestr;
+      const char *ftstr = filetypestr;
       size_t len;
 
       if      ( cmpstrlen(filetypestr, "grb2", len)  == 0 ) { ftstr += len; cdoDefaultFileType = FILETYPE_GRB2;}
@@ -535,19 +537,19 @@ int getMemAlignment(void)
 
   for ( i = 0; i < NTESTS; ++i )
     {
-      ptr[i] = (double*) malloc(tsize[i]);
+      ptr[i] = (double*) Malloc(tsize[i]);
       iptr = (int64_t) ptr[i];
       for ( k = 0; k < 4; ++k ) if ( iptr%ma_check[k] ) ma_result[k] = 0; 
     }
-  for ( i = 0; i < NTESTS; ++i ) free(ptr[i]);
+  for ( i = 0; i < NTESTS; ++i ) Free(ptr[i]);
 
   for ( i = NTESTS-1; i >= 0; i-- )
     {
-      ptr[i] = (double*)malloc(tsize[i]+5);
+      ptr[i] = (double*) Malloc(tsize[i]+5);
       iptr = (int64_t) ptr[i];
       for ( k = 0; k < 4; ++k ) if ( iptr%ma_check[k] ) ma_result[k] = 0; 
     }
-  for ( i = 0; i < NTESTS; ++i ) free(ptr[i]);
+  for ( i = 0; i < NTESTS; ++i ) Free(ptr[i]);
 
   for ( k = 0; k < 4; ++k ) if ( ma_result[k] ) ma = ma_check[k];
 
@@ -608,22 +610,18 @@ void defineVarnames(const char *arg)
 {
   size_t len = strlen(arg);
   size_t istart = 0;
-  char *pbuf;
-
   while ( istart < len && (arg[istart] == ' ' || arg[istart] == ',') ) istart++;
 
   len -= istart;
 
   if ( len )
-    {
-      char *commapos;
-      
-      cdoVarnames = (char **) malloc(MAX_NUM_VARNAMES*sizeof(char *));
+    {      
+      cdoVarnames = (char **) Malloc(MAX_NUM_VARNAMES*sizeof(char *));
 
-      pbuf = strdup(arg+istart);
+      char *pbuf = strdup(arg+istart);
       cdoVarnames[cdoNumVarnames++] = pbuf;    
 
-      commapos = pbuf;
+      char *commapos = pbuf;
       while ( (commapos = strchr(commapos, ',')) != NULL )
         {
           *commapos++ = '\0';
@@ -654,7 +652,7 @@ void get_env_vars(void)
       if ( len > 0 )
         {
           len += 2;
-          cdoGridSearchDir = (char*) malloc(len);
+          cdoGridSearchDir = (char*) Malloc(len);
           memcpy(cdoGridSearchDir, envstr, len-1);
           if ( cdoGridSearchDir[len-3] != '/' )
             {
@@ -697,6 +695,18 @@ void get_env_vars(void)
         }
     }
 
+  envstr = getenv("CDO_HISTORY_INFO");
+  if ( envstr )
+    {
+      int ival = atoi(envstr);
+      if ( ival == 0 || ival == 1 )
+        {
+          CDO_Append_History = ival;
+          if ( cdoVerbose )
+            fprintf(stderr, "CDO_HISTORY_INFO = %s\n", envstr);
+        }
+    }
+
   CDO_File_Suffix[0] = 0;
 
   envstr = getenv("CDO_FILE_SUFFIX");
@@ -744,6 +754,18 @@ void get_env_vars(void)
         }
     }
 
+  envstr = getenv("CDO_VERSION_INFO");
+  if ( envstr )
+    {
+      int ival = atoi(envstr);
+      if ( ival == 0 || ival == 1 )
+        {
+          CDO_Version_Info = ival;
+          if ( cdoVerbose )
+            fprintf(stderr, "CDO_Version_Info = %s\n", envstr);
+        }
+    }
+
   envstr = getenv("CDO_COLOR");
   if ( envstr )
     {
@@ -759,8 +781,7 @@ void get_env_vars(void)
     {
       if ( CDO_Color == FALSE )
         {
-          char *username;
-          username = getenv("LOGNAME");
+          const char *username = getenv("LOGNAME");
           if ( username == NULL )
             {
               username = getenv("USER");
@@ -774,10 +795,6 @@ void get_env_vars(void)
 static
 void print_system_info()
 {
-  char *envstr;
-
-  if ( DebugLevel == 0 ) DebugLevel = 1;
-  cdoSetDebug(DebugLevel);
   fprintf(stderr, "\n");
   fprintf(stderr, "CDO_Color           = %d\n", CDO_Color);
   fprintf(stderr, "CDO_Reset_History   = %d\n", CDO_Reset_History);
@@ -788,6 +805,7 @@ void print_system_info()
   fprintf(stderr, "cdoDefaultTableID   = %d\n", cdoDefaultTableID);
   fprintf(stderr, "\n");
 
+  const char *envstr;
   envstr = getenv("HOSTTYPE");
   if ( envstr ) fprintf(stderr, "HOSTTYPE            = %s\n", envstr);
   envstr = getenv("VENDOR");
@@ -943,22 +961,23 @@ void check_stacksize()
 #endif
 }
 
-
 static
 void cdo_set_options(void)
 {
   if ( Debug )
     {
+      fprintf(stderr, "CDO_CMOR_Mode       = %d\n", CDO_CMOR_Mode);
       fprintf(stderr, "CDO_netcdf_hdr_pad  = %d\n", CDO_netcdf_hdr_pad);
       fprintf(stderr, "\n");
     }
   
-  if ( CDO_netcdf_hdr_pad > 0 ) cdiDefGlobal("NETCDF_HDR_PAD", CDO_netcdf_hdr_pad);
+  if ( CDO_CMOR_Mode )          cdiDefGlobal("CMOR_MODE", CDO_CMOR_Mode);
+  if ( CDO_netcdf_hdr_pad > 0 ) cdiDefGlobal("NETCDF_HDR_PAD", CDO_netcdf_hdr_pad);  
 }
 
 
 static
-long str_to_int(char *intstring)
+long str_to_int(const char *intstring)
 {
   long intval = -1;
   long fact = 1;
@@ -989,27 +1008,35 @@ long str_to_int(char *intstring)
   return (intval);
 }
 
-
 static
 int parse_options_long(int argc, char *argv[])
 {
   int c;
   int lnetcdf_hdr_pad;
   int luse_fftw;
+  int lgridsearchnn;
+  int lgridsearchradius;
   int lremap_genweights;
+  int lpercentile;
 
   struct cdo_option opt_long[] =
     {
-      { "netcdf_hdr_pad",    required_argument,    &lnetcdf_hdr_pad,  1 },
-      { "header_pad",        required_argument,    &lnetcdf_hdr_pad,  1 },
-      { "hdr_pad",           required_argument,    &lnetcdf_hdr_pad,  1 },
-      { "use_fftw",          required_argument,          &luse_fftw,  1 },
-      { "remap_genweights",  required_argument,  &lremap_genweights,  1 },
-      { "reduce_dim",              no_argument,     &CDO_Reduce_Dim,  1 },
-      { "no_warnings",             no_argument,           &_Verbose,  0 },
+      { "percentile",        required_argument,        &lpercentile,  1  },
+      { "netcdf_hdr_pad",    required_argument,    &lnetcdf_hdr_pad,  1  },
+      { "header_pad",        required_argument,    &lnetcdf_hdr_pad,  1  },
+      { "hdr_pad",           required_argument,    &lnetcdf_hdr_pad,  1  },
+      { "use_fftw",          required_argument,          &luse_fftw,  1  },
+      { "gridsearchnn",      required_argument,      &lgridsearchnn,  1  },
+      { "gridsearchradius",  required_argument,  &lgridsearchradius,  1  },
+      { "remap_genweights",  required_argument,  &lremap_genweights,  1  },
+      { "cmor",                    no_argument,      &CDO_CMOR_Mode,  1  },
+      { "reduce_dim",              no_argument,     &CDO_Reduce_Dim,  1  },
+      { "rusage",                  no_argument,         &CDO_Rusage,  1  },
+      { "no_warnings",             no_argument,           &_Verbose,  0  },
       { "format",            required_argument,                NULL, 'f' },
       { "help",                    no_argument,                NULL, 'h' },
-      { "history",                 no_argument,                NULL, 'H' },
+      { "history",                 no_argument, &CDO_Append_History,  0  },
+      { "no_history",              no_argument, &CDO_Append_History,  0  },
       { "regular",                 no_argument,                NULL, 'R' },
       { "silent",                  no_argument,                NULL, 's' },
       { "table",             required_argument,                NULL, 't' },
@@ -1022,11 +1049,14 @@ int parse_options_long(int argc, char *argv[])
 
   while ( 1 )
     {
+      lpercentile = 0;
       lnetcdf_hdr_pad = 0;
       luse_fftw = 0;
+      lgridsearchnn = 0;
+      lgridsearchradius = 0;
       lremap_genweights = 0;
 
-      c = cdo_getopt_long(argc, argv, "f:b:e:P:p:g:i:k:l:m:n:t:D:z:aBCcdhHLMOQRrsSTuVvWXZ", opt_long, NULL);
+      c = cdo_getopt_long(argc, argv, "f:b:e:P:p:g:i:k:l:m:n:t:D:z:aBCcdhLMOQRrsSTuVvWXZ", opt_long, NULL);
       if ( c == -1 ) break;
 
       switch (c)
@@ -1034,12 +1064,12 @@ int parse_options_long(int argc, char *argv[])
         case '?':
           //cdo_usage();
           //fprintf(stderr, "Illegal option!\n");
-          return (-1);
+          return -1;
           break;
         case ':':
           //cdo_usage();
           //fprintf(stderr, "Option requires an argument!\n");
-          return (-1);
+          return -1;
           break;
         case 0:
           if ( lnetcdf_hdr_pad )
@@ -1047,16 +1077,36 @@ int parse_options_long(int argc, char *argv[])
               int netcdf_hdr_pad = str_to_int(CDO_optarg);
               if ( netcdf_hdr_pad >= 0 ) CDO_netcdf_hdr_pad = netcdf_hdr_pad;
             }
+          else if ( lpercentile )
+            {
+              percentile_set_method(CDO_optarg);
+            }
           else if ( luse_fftw )
             {
-              int use_fftw = str_to_int(CDO_optarg);
-              if ( use_fftw != 0 && use_fftw != 1 )
-                cdoAbort("Unsupported value for option --use_fftw=%d [range: 0-1]", use_fftw);
-              CDO_Use_FFTW = use_fftw;
+              int intarg = parameter2int(CDO_optarg);
+              if ( intarg != 0 && intarg != 1 )
+                cdoAbort("Unsupported value for option --use_fftw=%d [range: 0-1]", intarg);
+              CDO_Use_FFTW = intarg;
+            }
+          else if ( lgridsearchnn )
+            {
+              gridsearch_set_method(CDO_optarg);
+            }
+          else if ( lgridsearchradius )
+            {
+              extern double gridsearch_radius;
+              double fval = atof(CDO_optarg);
+              if ( fval < 0 || fval > 180 )
+                cdoAbort("gridsearchradius=%g out of bounds (0-180)", fval);
+              else
+                gridsearch_radius = fval;
             }
           else if ( lremap_genweights )
             {
-              remap_genweights = str_to_int(CDO_optarg);
+              int intarg = parameter2int(CDO_optarg);
+              if ( intarg != 0 && intarg != 1 )
+                cdoAbort("Unsupported value for option --remap_genweights=%d [range: 0-1]", intarg);
+              remap_genweights = intarg;
             }
           break;
         case 'a':
@@ -1107,9 +1157,6 @@ int parse_options_long(int argc, char *argv[])
         case 'h':        
           Help = 1;
           break;
-        case 'H':        
-          CDO_Append_History = FALSE;
-          break;
         case 'i':
           defineInstitution(CDO_optarg);
           break;
@@ -1143,8 +1190,8 @@ int parse_options_long(int argc, char *argv[])
           numThreads = atoi(CDO_optarg);
           break;
         case 'p':
-          fprintf(stderr, "CDO option -p is obsolete and will be removed in the next release, please switch to -b <bits>!\n");
-          setDefaultDataTypeByte(CDO_optarg);
+          fprintf(stderr, "CDO option -p is not available anymore, please use -b <bits>!\n");
+          //setDefaultDataTypeByte(CDO_optarg);
           break;
         case 'Q':
           cdiDefGlobal("SORTNAME", TRUE);
@@ -1192,156 +1239,32 @@ int parse_options_long(int argc, char *argv[])
         }
     }
 
-  return (0);
+  return 0;
 }
 
 static
-int parse_options(int argc, char *argv[])
+void cdo_rusage(void)
 {
-  int c;
+#if defined(HAVE_SYS_RESOURCE_H) && defined(RUSAGE_SELF)
+  struct rusage ru;
+  int status = getrusage(RUSAGE_SELF, &ru);
 
-  while ( (c = cdo_getopt(argc, argv, "f:b:e:P:p:g:i:k:l:m:n:t:D:z:aBCcdhHLMOQRrsSTuVvWXZ")) != -1 )
+  if ( status == 0 )
     {
-      switch (c)
-        {
-        case 'a':
-          cdoDefaultTimeType = TAXIS_ABSOLUTE;
-          break;
-        case 'b':
-          setDefaultDataType(CDO_optarg);
-          break;
-        case 'B':
-          cdoBenchmark = TRUE;
-          break;
-        case 'C':
-          CDO_Color = TRUE;
-          break;
-        case 'c':
-          cdoCheckDatarange = TRUE;
-          break;
-        case 'd':
-          Debug = 1;
-          break;
-        case 'D':
-          Debug = 1;
-          DebugLevel = atoi(CDO_optarg);
-          break;
-        case 'e':
-          {
-#if defined(HAVE_GETHOSTNAME)
-          char host[1024];
-          gethostname(host, sizeof(host));
-          cdoExpName = CDO_optarg;
-          /* printf("host: %s %s\n", host, cdoExpName); */
-          if ( strcmp(host, cdoExpName) == 0 )
-            cdoExpMode = CDO_EXP_REMOTE;
-          else
-            cdoExpMode = CDO_EXP_LOCAL;
-#else
-          fprintf(stderr, "Function gethostname not available!\n");
-          exit(EXIT_FAILURE);
-#endif
-          break;
-          }
-        case 'f':
-          setDefaultFileType(CDO_optarg, 1);
-          break;
-        case 'g':
-          defineGrid(CDO_optarg);
-          break;
-        case 'h':        
-          Help = 1;
-          break;
-        case 'H':        
-          CDO_Append_History = FALSE;
-          break;
-        case 'i':
-          defineInstitution(CDO_optarg);
-          break;
-        case 'k':
-          defineChunktype(CDO_optarg);
-          break;
-        case 'L':        
-          cdoLockIO = TRUE;
-          break;
-        case 'l':
-          defineZaxis(CDO_optarg);
-          break;
-        case 'm':
-          cdiDefMissval(atof(CDO_optarg));
-          break;
-        case 'M':
-          cdiDefGlobal("HAVE_MISSVAL", TRUE);
-          break;
-        case 'n':
-          defineVarnames(CDO_optarg);
-          break;
-        case 'O':
-          cdoOverwriteMode = TRUE;
-          break;
-        case 'P':
-          if ( *CDO_optarg < '1' || *CDO_optarg > '9' )
-            {
-              fprintf(stderr, "Unexpected character in number of OpenMP threads (-P <nthreads>): %s!\n", CDO_optarg);
-              exit(EXIT_FAILURE);
-            }
-          numThreads = atoi(CDO_optarg);
-          break;
-        case 'p':
-          fprintf(stderr, "CDO option -p is obsolete and will be removed in the next release, please switch to -b <bits>!\n");
-          setDefaultDataTypeByte(CDO_optarg);
-          break;
-        case 'Q':
-          cdiDefGlobal("SORTNAME", TRUE);
-          break;
-        case 'R':
-          cdoRegulargrid = TRUE;
-          cdiDefGlobal("REGULARGRID", TRUE);
-          break;
-        case 'r':
-          cdoDefaultTimeType = TAXIS_RELATIVE;
-          break;
-        case 'S':
-          cdoDiag = TRUE;
-          break;
-        case 's':
-          cdoSilentMode = TRUE;
-          break;
-        case 'T':
-          cdoTimer = TRUE;
-          break;
-        case 't':
-          cdoDefaultTableID = defineTable(CDO_optarg);
-          break;
-        case 'u':
-          cdoInteractive = TRUE;
-          break;
-        case 'V':
-          Version = 1;
-          break;
-        case 'v':
-          cdoVerbose = TRUE;
-          break;
-        case 'W': /* Warning messages */
-          _Verbose = 1;
-          break;
-        case 'X': /* multi threaded I/O */
-          cdoParIO = TRUE;
-          break;
-        case 'Z':
-          cdoCompress = TRUE;
-          break;
-        case 'z':
-          defineCompress(CDO_optarg);
-          break;
-        case ':':
-          fprintf(stderr, "\nmissing parameter for one of the options\n\n");
-          Help = 1;
-          break;
-        }
+      double ut = ru.ru_utime.tv_sec + 0.000001 * ru.ru_utime.tv_usec;
+      double st = ru.ru_stime.tv_sec + 0.000001 * ru.ru_stime.tv_usec;
+
+      fprintf(stderr, "  User time:     %.3f seconds\n", ut);
+      fprintf(stderr, "  System time:   %.3f seconds\n", st);
+      fprintf(stderr, "  Total time:    %.3f seconds\n", ut+st);
+      fprintf(stderr, "  Memory usage:  %.2f MBytes\n", ru.ru_maxrss/(1024.*1024.));
+      fprintf(stderr, "  Page reclaims: %5ld page%s\n", ru.ru_minflt, ADD_PLURAL(ru.ru_minflt));
+      fprintf(stderr, "  Page faults:   %5ld page%s\n", ru.ru_majflt, ADD_PLURAL(ru.ru_majflt));
+      fprintf(stderr, "  Swaps:         %5ld\n", ru.ru_nswap);
+      fprintf(stderr, "  Disk read:     %5ld block%s\n", ru.ru_inblock, ADD_PLURAL(ru.ru_inblock));
+      fprintf(stderr, "  Disk Write:    %5ld block%s\n", ru.ru_oublock, ADD_PLURAL(ru.ru_oublock));
     }
-
-  return (0);
+#endif
 }
 
 
@@ -1373,12 +1296,9 @@ int main(int argc, char *argv[])
 
   get_env_vars();
 
-  if ( 1 )
-    status = parse_options_long(argc, argv);
-  else
-    status = parse_options(argc, argv);
+  status = parse_options_long(argc, argv);
 
-  if ( status != 0 ) return (-1);
+  if ( status != 0 ) return -1;
 
   cdo_set_options();
 
@@ -1393,13 +1313,40 @@ int main(int argc, char *argv[])
 #if defined(_OPENMP)
   if ( numThreads <= 0 ) numThreads = 1;
   omp_set_num_threads(numThreads);
+
+  if ( Debug )
+    {
+      fprintf(stderr, "OMP num procs       = %d\n", omp_get_num_procs());
+      fprintf(stderr, "OMP max threads     = %d\n", omp_get_max_threads());
+      fprintf(stderr, "OMP num threads     = %d\n", omp_get_num_threads());
+      fprintf(stderr, "OMP thread limit    = %d\n", omp_get_thread_limit());
+      omp_sched_t kind;
+      int modifer;
+      omp_get_schedule(&kind, &modifer);
+      fprintf(stderr, "OMP schedule        = %d (1:static; 2:dynamic; 3:guided; 4:auto)\n", (int) kind);
+#if defined(HAVE_OPENMP4)
+      fprintf(stderr, "OMP proc bind       = %d (0:false; 1:true; 2:master; 3:close; 4:spread)\n", (int) omp_get_proc_bind());
+#if !defined(__ICC)
+      fprintf(stderr, "OMP num devices     = %d\n", omp_get_num_devices());
+#endif
+#endif
+    }
+
   ompNumThreads = omp_get_max_threads();
   if ( omp_get_max_threads() > omp_get_num_procs() )
     fprintf(stderr, "Warning: Number of OMP threads is greater than number of Cores=%d!\n", omp_get_num_procs());
   if ( ompNumThreads < numThreads )
     fprintf(stderr, "Warning: omp_get_max_threads() returns %d!\n", ompNumThreads);
   if ( cdoVerbose )
-    fprintf(stderr, " OpenMP:  num_procs = %d  max_threads = %d\n", omp_get_num_procs(), omp_get_max_threads());
+    {
+      fprintf(stderr, " OpenMP:  num_procs = %d  max_threads = %d", omp_get_num_procs(), omp_get_max_threads());
+#if defined(HAVE_OPENMP4)
+#if !defined(__ICC)
+      fprintf(stderr, "  num_devices = %d", omp_get_num_devices());
+#endif
+#endif
+      fprintf(stderr, "\n");
+    }
 #else
   if ( numThreads > 0 )
     {
@@ -1444,6 +1391,12 @@ int main(int argc, char *argv[])
     }
   else
     {
+      if ( Debug )
+        {
+          if ( DebugLevel == 0 ) DebugLevel = 1;
+          cdoSetDebug(DebugLevel);
+         }
+
       timer_total      = timer_new("total");
       timer_read       = timer_new("read");
       timer_write      = timer_new("write");
@@ -1461,15 +1414,17 @@ int main(int argc, char *argv[])
 
   if ( cdoVarnames )
     {
-      if ( cdoNumVarnames ) free(cdoVarnames[0]);
-      free(cdoVarnames);
+      if ( cdoNumVarnames ) Free(cdoVarnames[0]);
+      Free(cdoVarnames);
     }
 
-  /* problems with alias!!! if ( operatorName ) free(operatorName); */ 
+  /* problems with alias!!! if ( operatorName ) Free(operatorName); */ 
 
   /* malloc_stats(); */
 
-  if ( cdoGridSearchDir ) free(cdoGridSearchDir);
+  if ( cdoGridSearchDir ) Free(cdoGridSearchDir);
+
+  if ( CDO_Rusage ) cdo_rusage();
 
   return (status);
 }
diff --git a/src/cdo.h b/src/cdo.h
index 0918c42..569c938 100644
--- a/src/cdo.h
+++ b/src/cdo.h
@@ -18,12 +18,6 @@
 #ifndef _CDO_H
 #define _CDO_H
 
-#include <stdio.h>
-#include <stdbool.h>
-#include "dmemory.h"
-#include "util.h"
 #include "text.h"
 
-
-
 #endif  /* _CDO_H */
diff --git a/src/cdo_getopt.c b/src/cdo_getopt.c
index 9f540ad..b188657 100644
--- a/src/cdo_getopt.c
+++ b/src/cdo_getopt.c
@@ -100,7 +100,7 @@ char *__progname(char *nargv0)
 static
 int cdo_getopt_internal(int nargc, char * const *nargv, const char *ostr)
 {
-  static char *place = EMSG;		/* option letter processing */
+  static const char *place = EMSG;		/* option letter processing */
   char *oli;				/* option letter list index */
 
   assert(nargv != NULL);
@@ -112,7 +112,7 @@ int cdo_getopt_internal(int nargc, char * const *nargv, const char *ostr)
       if ( CDO_optind >= nargc || *(place = nargv[CDO_optind]) != '-' )
 	{
 	  place = EMSG;
-	  return (-1);
+	  return -1;
 	}
       
       if ( place[1] && *++place == '-' )
@@ -122,14 +122,14 @@ int cdo_getopt_internal(int nargc, char * const *nargv, const char *ostr)
 	  return (-2);
 	}
 
-      if ( place[1] ) return (-1);
+      if ( place[1] ) return -1;
     } 
 
   /* option letter okay? */
-  if ( (CDO_optopt = (int)*place++) == (int)':' || !(oli = strchr(ostr, CDO_optopt)) )
+  if ( (CDO_optopt = (int)*place++) == (int)':' || !(oli = (char *)strchr(ostr, CDO_optopt)) )
     {
       /* if the user didn't specify '-' as an option, assume it means -1. */
-      if ( CDO_optopt == (int)'-' ) return (-1);
+      if ( CDO_optopt == (int)'-' ) return -1;
 
       if ( !*place ) ++CDO_optind;
 
diff --git a/src/cdo_history.c b/src/cdo_history.c
index 88f447b..2753385 100644
--- a/src/cdo_history.c
+++ b/src/cdo_history.c
@@ -26,6 +26,7 @@ static char *ghistory = NULL;
 static size_t ghistorysize = 0;
 
 static char strtime[32];
+static char datetimestr[32];
 
 static
 void init_strtime()
@@ -39,16 +40,16 @@ void init_strtime()
     {
       ltime = localtime(&tp);
       (void) strftime(strtime, sizeof(strtime), "%a %b %d %H:%M:%S %Y: ", ltime);
+      (void) strftime(datetimestr, sizeof(datetimestr), "%Y-%m-%dT%H:%M:%SZ", ltime);
     }
 }
 
 static
 char *get_strtimeptr()
 {
-  if ( strlen(strtime) == 0 )
-    init_strtime();
+  if ( strlen(strtime) == 0 ) init_strtime();
 
-  return (strtime);
+  return strtime;
 }
 
 
@@ -56,7 +57,7 @@ void cdoInqHistory(int fileID)
 {
   if ( ghistory )
     {
-      free(ghistory);
+      Free(ghistory);
       ghistorysize = 0;
       ghistory = NULL;
     }
@@ -65,7 +66,7 @@ void cdoInqHistory(int fileID)
   if ( ghistorysize > 0 )
     {
       size_t len;
-      ghistory = (char*) malloc(ghistorysize+1);
+      ghistory = (char*) Malloc(ghistorysize+1);
       ghistory[ghistorysize] = 0;
       streamInqHistoryString(fileID, ghistory);
       len = strlen(ghistory);
@@ -78,10 +79,9 @@ void cdoInqHistory(int fileID)
 }
 
 
-void cdoDefHistory(int fileID, char* histstring)
+void cdoDefHistory(int fileID, char *histstring)
 {
-  char* strtimeptr = NULL;
-  char* history = NULL;
+  char *strtimeptr = NULL;
   size_t historysize = 0;
 
   if ( !CDO_Reset_History ) historysize += ghistorysize+1;
@@ -94,26 +94,53 @@ void cdoDefHistory(int fileID, char* histstring)
 
   if ( historysize )
     {
-      history = (char*) malloc(historysize);
+      char *history = (char*) Malloc(historysize);
       history[0] = 0;
-    }
-
-  if ( CDO_Append_History )
-    {
-      strcpy(history, strtimeptr);
-      strcat(history, histstring);
-    }
 
-  if ( !CDO_Reset_History )
-    if ( ghistory )
-      {
-	if ( CDO_Append_History ) strcat(history, "\n");
-	strcat(history, ghistory);
-      }
+      if ( CDO_Append_History )
+        {
+          if ( strtimeptr ) strcpy(history, strtimeptr);
+          strcat(history, histstring);
+        }
+
+      if ( !CDO_Reset_History )
+        if ( ghistory )
+          {
+            if ( CDO_Append_History ) strcat(history, "\n");
+            strcat(history, ghistory);
+          }
   
-  if ( historysize )
-    {
       streamDefHistory(fileID, strlen(history), history);
-      free(history);
+      Free(history);
     }
 }
+
+
+void cdo_def_creation_date(int vlistID)
+{
+  if ( strlen(datetimestr) == 0 ) init_strtime();
+  vlistDefAttTxt(vlistID, CDI_GLOBAL, "creation_date", (int)strlen(datetimestr)+1, datetimestr);
+}
+
+
+void create_uuid(unsigned char uuid[CDI_UUID_SIZE]);
+void uuid2str(const unsigned char *uuid, char *uuidstr);
+
+
+#define UUIDSTR_SIZE (CDI_UUID_SIZE*2 + 4)
+
+static
+void get_uuid(char uuidstr[UUIDSTR_SIZE])
+{
+  unsigned char uuid[CDI_UUID_SIZE];
+  create_uuid(uuid);
+  uuid2str(uuid, uuidstr);
+}
+
+
+void cdo_def_tracking_id(int vlistID, const char *uuid_attribute)
+{
+  char uuidstr[UUIDSTR_SIZE];
+  get_uuid(uuidstr);
+  vlistDefAttTxt(vlistID, CDI_GLOBAL, uuid_attribute, UUIDSTR_SIZE, uuidstr);
+}
diff --git a/src/cdo_int.h b/src/cdo_int.h
index 37632ce..e9d490f 100644
--- a/src/cdo_int.h
+++ b/src/cdo_int.h
@@ -24,9 +24,13 @@
 
 #include <assert.h>
 #include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
 #include <string.h>
 #include <math.h>
 #include <float.h>
+#include <ctype.h>
+#include <stdarg.h>
 
 #include "compare.h"
 #include "timebase.h"
@@ -54,7 +58,7 @@ char *strdup(const char *s);
 ({					      	  \
    const char *__old = (s);			  \
    size_t __len = strlen(__old) + 1;		  \
-   char *__new = malloc(__len);	  \
+   char *__new = Malloc(__len);	  \
    (char *) memcpy(__new, __old, __len);	  \
 })
 */
@@ -122,8 +126,8 @@ int     days_per_year(int calendar, int year);
 int     calendar_dpy(int calendar);
 
 void    defineGrid(const char *gridarg);
-void    defineInstitution(char *instarg);
-int     defineTable(char *tablearg);
+void    defineInstitution(const char *instarg);
+int     defineTable(const char *tablearg);
 
 void    cdolog(const char *prompt, double cputime);
 void    cdologs(int noper);
@@ -138,11 +142,9 @@ int  cdf_openread(const char *filename);
 
 void printFiletype(int streamID, int vlistID);
 
-void job_submit(const char *expname, const char *jobfilename, const char *jobname, const char *tmppath, const char *ftppath);
-
 void minmaxval(long nvals, double *array, int *imiss, double *minval, double *maxval);
 
-off_t filesize(const char *filename);
+off_t fileSize(const char *restrict filename);
 
 char *expand_filename(const char *string);
 
@@ -150,5 +152,4 @@ double parameter2double(const char *string);
 int    parameter2int(const char *string);
 int    parameter2intlist(const char *string);
 
-
 #endif  /* _CDO_INT_H */
diff --git a/src/cdo_task.c b/src/cdo_task.c
new file mode 100644
index 0000000..fba286f
--- /dev/null
+++ b/src/cdo_task.c
@@ -0,0 +1,233 @@
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
+#include <stdlib.h>
+#include <stdio.h>
+
+#if defined(HAVE_LIBPTHREAD)
+#include <pthread.h>
+#endif
+
+#include "cdo_task.h"
+
+enum cdo_pt_state {
+  SETUP,
+  IDLE,
+  JOB,
+  DIE
+};
+
+typedef struct cdo_task_info {
+  void *(*routine)(void *);
+  void *arg;
+  void *result;
+  enum cdo_pt_state state;
+#if defined(HAVE_LIBPTHREAD)
+  pthread_t thread;
+  pthread_cond_t work_cond;
+  pthread_mutex_t work_mtx;
+  pthread_cond_t boss_cond;
+  pthread_mutex_t boss_mtx;
+#endif
+} cdo_task_t;
+
+
+#if defined(HAVE_LIBPTHREAD)
+static
+void *cdo_task(void *task)
+{
+  cdo_task_t *task_info = (cdo_task_t *) task;
+
+  // cond_wait mutex must be locked before we can wait
+  pthread_mutex_lock(&(task_info->work_mtx));
+
+  //printf("<worker> start\n");
+
+  // ensure boss is waiting
+  pthread_mutex_lock(&(task_info->boss_mtx));
+
+  // signal to boss that setup is complete
+  task_info->state = IDLE;
+
+  // wake-up signal
+  pthread_cond_signal(&(task_info->boss_cond));
+  pthread_mutex_unlock(&(task_info->boss_mtx));
+
+  while ( 1 )
+    {
+      pthread_cond_wait(&(task_info->work_cond), &(task_info->work_mtx));
+
+      if ( DIE == task_info->state )
+        {
+          // kill thread
+          break;
+        }
+
+      if ( IDLE == task_info->state )
+        {
+          // accidental wake-up
+          continue;
+        }
+      
+      // do blocking task
+      //printf("<worker> JOB start\n");
+      task_info->result = task_info->routine(task_info->arg);
+      //printf("<worker> JOB end\n");
+
+      // ensure boss is waiting
+      pthread_mutex_lock(&(task_info->boss_mtx));
+
+      // indicate that job is done
+      task_info->state = IDLE;
+
+      // wake-up signal
+      pthread_cond_signal(&(task_info->boss_cond));
+      pthread_mutex_unlock(&(task_info->boss_mtx));
+    }
+
+  pthread_mutex_unlock(&(task_info->work_mtx));
+  pthread_exit(NULL);
+}
+#endif
+
+void cdo_task_start(void *task, void *(*task_routine)(void *), void *task_arg)
+{
+  if ( !task ) return;
+
+  cdo_task_t *task_info = (cdo_task_t *) task;
+
+  // ensure worker is waiting
+#if defined(HAVE_LIBPTHREAD)
+  pthread_mutex_lock(&(task_info->work_mtx));
+#endif
+
+  // set job information & state
+  task_info->routine = task_routine;
+  task_info->arg = task_arg;
+  task_info->state = JOB;
+
+  // wake-up signal
+#if defined(HAVE_LIBPTHREAD)
+  pthread_cond_signal(&(task_info->work_cond));
+  pthread_mutex_unlock(&(task_info->work_mtx));
+#endif
+}
+
+
+void *cdo_task_wait(void *task)
+{
+  if ( !task ) return NULL;
+
+  cdo_task_t *task_info = (cdo_task_t *) task;
+
+#if defined(HAVE_LIBPTHREAD)
+  while (1)
+    {
+      pthread_cond_wait(&(task_info->boss_cond), &(task_info->boss_mtx));
+
+      if ( IDLE == task_info->state ) break;
+    }
+#endif
+
+  return task_info->result;
+}
+
+
+void *cdo_task_new()
+{
+  cdo_task_t *task_info = NULL;
+
+#if defined(HAVE_LIBPTHREAD)
+  task_info = (cdo_task_t *) malloc(sizeof(cdo_task_t));
+  task_info->routine = NULL;
+  task_info->arg = NULL;
+  task_info->result = NULL;
+  task_info->state = SETUP;
+
+  pthread_attr_t attr;
+  size_t stacksize;
+  pthread_attr_init(&attr);
+  pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+  pthread_attr_getstacksize(&attr, &stacksize);
+  if ( stacksize < 2097152 )
+    {
+      stacksize = 2097152;
+      pthread_attr_setstacksize(&attr, stacksize);
+    }
+
+  pthread_cond_init(&(task_info->work_cond), NULL);
+  pthread_mutex_init(&(task_info->work_mtx), NULL);
+  pthread_cond_init(&(task_info->boss_cond), NULL);
+  pthread_mutex_init(&(task_info->boss_mtx), NULL);
+
+  pthread_mutex_lock(&(task_info->boss_mtx));
+
+  pthread_create(&(task_info->thread), &attr, cdo_task, (void *)task_info);
+
+  cdo_task_wait(task_info);
+#endif
+
+  return (void *)task_info;
+}
+
+
+void cdo_task_delete(void *task)
+{
+  cdo_task_t *task_info = (cdo_task_t *) task;
+
+#if defined(HAVE_LIBPTHREAD)
+  // ensure the worker is waiting
+  pthread_mutex_lock(&(task_info->work_mtx));
+
+  //printf("cdo_task_delete: send DIE to <worker>\n");
+  task_info->state = DIE;
+
+  // wake-up signal
+  pthread_cond_signal(&(task_info->work_cond));
+  pthread_mutex_unlock(&(task_info->work_mtx));
+
+  // wait for thread to exit
+  pthread_join(task_info->thread, NULL);
+
+  pthread_mutex_destroy(&(task_info->work_mtx));
+  pthread_cond_destroy(&(task_info->work_cond));
+
+  pthread_mutex_unlock(&(task_info->boss_mtx));
+  pthread_mutex_destroy(&(task_info->boss_mtx));
+  pthread_cond_destroy(&(task_info->boss_cond));
+#endif
+
+  if ( task_info ) free(task_info);
+}
+
+#ifdef TEST_CDO_TASK
+
+void *mytask(void *arg)
+{
+  printf("run mytask\n");
+}
+
+
+int main(int argc, char **argv)
+{
+  void *task = cdo_task_new();
+
+  printf("Init done\n");
+  void *myarg;
+  void *myresult;
+
+  cdo_task_start(task, mytask, myarg);
+
+  myresult = cdo_task_wait(task);
+  
+  cdo_task_start(task, mytask, myarg);
+
+  myresult = cdo_task_wait(task);
+
+  cdo_task_delete(task);
+
+  return 0;
+}
+#endif
+
diff --git a/src/cdo_task.h b/src/cdo_task.h
new file mode 100644
index 0000000..4202ed2
--- /dev/null
+++ b/src/cdo_task.h
@@ -0,0 +1,9 @@
+#ifndef _CDO_TASK_H
+#define _CDO_TASK_H
+
+void cdo_task_start(void *task, void *(*task_routine)(void *), void *task_arg);
+void *cdo_task_wait(void *task);
+void *cdo_task_new();
+void cdo_task_delete(void *task);
+
+#endif  /* _CDO_TASK_H */
diff --git a/src/cdo_vlist.c b/src/cdo_vlist.c
index ce7adb5..ff12869 100644
--- a/src/cdo_vlist.c
+++ b/src/cdo_vlist.c
@@ -15,6 +15,7 @@
   GNU General Public License for more details.
 */
 
+#include <stdlib.h>
 #include <cdi.h>
 #include "cdo.h"
 #include "cdo_int.h"
@@ -25,11 +26,9 @@ static
 void compare_lat_reg2d(int ysize, int gridID1, int gridID2)
 {
   if ( ysize > 1 )
-    {
-      double *yvals1, *yvals2;
-      
-      yvals1 = (double*) malloc(ysize*sizeof(double));
-      yvals2 = (double*) malloc(ysize*sizeof(double));
+    {      
+      double *yvals1 = (double*) Malloc(ysize*sizeof(double));
+      double *yvals2 = (double*) Malloc(ysize*sizeof(double));
 
       gridInqYvals(gridID1, yvals1);
       gridInqYvals(gridID2, yvals2);
@@ -53,8 +52,8 @@ void compare_lat_reg2d(int ysize, int gridID1, int gridID2)
 	      }
 	}
 
-      free(yvals1);
-      free(yvals2);
+      Free(yvals1);
+      Free(yvals2);
     }
 }
 
@@ -63,10 +62,8 @@ void compare_lon_reg2d(int xsize, int gridID1, int gridID2)
 {
   if ( xsize > 1 )
     {
-      double *xvals1, *xvals2;
-
-      xvals1 = (double*) malloc(xsize*sizeof(double));
-      xvals2 = (double*) malloc(xsize*sizeof(double));
+      double *xvals1 = (double*) Malloc(xsize*sizeof(double));
+      double *xvals2 = (double*) Malloc(xsize*sizeof(double));
 
       gridInqXvals(gridID1, xvals1);
       gridInqXvals(gridID2, xvals2);
@@ -78,55 +75,52 @@ void compare_lon_reg2d(int xsize, int gridID1, int gridID2)
 	    break;
 	  }
       
-      free(xvals1);
-      free(xvals2);
+      Free(xvals1);
+      Free(xvals2);
     }
 }
 
 static
 void compare_grid_unstructured(int gridID1, int gridID2)
 {
-  double *xvals1, *xvals2;
-  double *yvals1, *yvals2;
-  int gridsize;
+  int gridsize = gridInqSize(gridID1);
 
-  gridsize = gridInqSize(gridID1);
-
-  xvals1 = (double*) malloc(gridsize*sizeof(double));
-  xvals2 = (double*) malloc(gridsize*sizeof(double));
-  yvals1 = (double*) malloc(gridsize*sizeof(double));
-  yvals2 = (double*) malloc(gridsize*sizeof(double));
+  double *xvals1 = (double*) Malloc(gridsize*sizeof(double));
+  double *xvals2 = (double*) Malloc(gridsize*sizeof(double));
+  double *yvals1 = (double*) Malloc(gridsize*sizeof(double));
+  double *yvals2 = (double*) Malloc(gridsize*sizeof(double));
 
   gridInqXvals(gridID1, xvals1);
   gridInqXvals(gridID2, xvals2);
   gridInqYvals(gridID1, yvals1);
   gridInqYvals(gridID2, yvals2);
-		  
-  for ( int i = 0; i < gridsize; ++i )
-    if ( fabs(xvals1[i] - xvals2[i]) > 1.e-5 || fabs(yvals1[i] - yvals2[i]) > 1.e-5 )
+
+  int inc = gridsize > 10000 ? gridsize/1000 : 1;
+  for ( int i = 0; i < gridsize; i += inc )
+    if ( fabs(xvals1[i] - xvals2[i]) > 2.e-5 || fabs(yvals1[i] - yvals2[i]) > 2.e-5 )
       {
+        // printf("%g %g %g %g %g %g\n", xvals1[i], xvals2[i], yvals1[i], yvals2[i], xvals1[i] - xvals2[i], yvals1[i] - yvals2[i]);
 	cdoWarning("Geographic location of some grid points differ!");
 	break;
       }
       
-  free(xvals1);
-  free(xvals2);
-  free(yvals1); 
-  free(yvals2); 
+  Free(xvals1);
+  Free(xvals2);
+  Free(yvals1); 
+  Free(yvals2); 
 }
 
 static
 void compareGrids(int gridID1, int gridID2)
 {
   /* compare grids of first variable */
-  int xsize, ysize;
 
   if ( gridInqType(gridID1) == gridInqType(gridID2) )
     {
       if ( gridInqType(gridID1) == GRID_GAUSSIAN || gridInqType(gridID1) == GRID_LONLAT )
 	{
-	  xsize = gridInqXsize(gridID1);
-	  ysize = gridInqYsize(gridID1);
+	  int xsize = gridInqXsize(gridID1);
+	  int ysize = gridInqYsize(gridID1);
 		
 	  if ( ysize == gridInqYsize(gridID2) )
 	    compare_lat_reg2d(ysize, gridID1, gridID2);
@@ -153,16 +147,16 @@ void compareGrids(int gridID1, int gridID2)
 static
 int cmpnames(const void *s1, const void *s2)
 {
-  const char *name1 = s1;
-  const char *name2 = s2;
+  const char *name1 = (const char *)s1;
+  const char *name2 = (const char *)s2;
 
-  return (strcmp(name1, name2));
+  return strcmp(name1, name2);
 }
 
 
 void vlistCompare(int vlistID1, int vlistID2, int flag)
 {
-  int varID, nvars;
+  int varID;
   int lchecknames = FALSE;
 
   if ( vlistNvars(vlistID1) != vlistNvars(vlistID2) )
@@ -171,16 +165,12 @@ void vlistCompare(int vlistID1, int vlistID2, int flag)
   if ( vlistNrecs(vlistID1) != vlistNrecs(vlistID2) )
     cdoAbort("Input streams have different number of records per timestep!");
 
-  nvars = vlistNvars(vlistID1);
+  int nvars = vlistNvars(vlistID1);
 
   for ( varID = 0; varID < nvars; varID++ )
     {
       if ( nvars > 1 )
 	{
-	  if ( flag & CMP_CODE )
-	    if ( vlistInqVarCode(vlistID1, varID) != vlistInqVarCode(vlistID2, varID) )
-	      cdoAbort("Input streams have different structure!");
-
 	  if ( flag & CMP_NAME )
 	    {
 	      char name1[CDI_MAX_NAME], name2[CDI_MAX_NAME];
@@ -244,11 +234,11 @@ void vlistCompare(int vlistID1, int vlistID2, int flag)
 
 int vlistCompareX(int vlistID1, int vlistID2, int flag)
 {
-  int varID, nvars, nvars2, nlevels2;
+  int varID;
 
-  nvars = vlistNvars(vlistID1);
-  nvars2 = vlistNvars(vlistID2);
-  nlevels2 = zaxisInqSize(vlistInqVarZaxis(vlistID2, 0));
+  int nvars = vlistNvars(vlistID1);
+  int nvars2 = vlistNvars(vlistID2);
+  int nlevels2 = zaxisInqSize(vlistInqVarZaxis(vlistID2, 0));
 
   if ( nvars2 != 1 )
     cdoAbort("Internal problem, vlistCompareX() called with unexpected vlistID2 argument!");
@@ -280,20 +270,18 @@ int vlistCompareX(int vlistID1, int vlistID2, int flag)
       compareGrids(gridID1, gridID2);
     }
 
-  return (nlevels2);
+  return nlevels2;
 }
 
 
 int vlistIsSzipped(int vlistID)
 {
   int lszip = FALSE;
-  int nvars, varID, comptype;
+  int nvars = vlistNvars(vlistID);
 
-  nvars = vlistNvars(vlistID);
-
-  for ( varID = 0; varID < nvars; varID++ )
+  for ( int varID = 0; varID < nvars; varID++ )
     {						
-      comptype = vlistInqVarCompType(vlistID, varID);
+      int comptype = vlistInqVarCompType(vlistID, varID);
       if ( comptype == COMPRESS_SZIP )
 	{
 	  lszip = TRUE;
@@ -301,7 +289,7 @@ int vlistIsSzipped(int vlistID)
 	}
     }      
 
-  return (lszip);
+  return lszip;
 }
 
 
@@ -315,7 +303,7 @@ int vlistInqNWPV(int vlistID, int varID)
   else
     nwpv = 1;
 
-  return (nwpv);
+  return nwpv;
 }
 
 
diff --git a/src/cdotest.c b/src/cdotest.c
index 9d4f241..0b0bf69 100755
--- a/src/cdotest.c
+++ b/src/cdotest.c
@@ -35,7 +35,7 @@ int equals(double expected, double actual, double eps)
 {
   return (int) fabs(expected - actual) < eps; 
 }
-
+/*
 static 
 double humidityIndex(double t, double p, double r, double missval)
 {
@@ -47,7 +47,7 @@ double humidityIndex(double t, double p, double r, double missval)
     
   return t + (5.0 / 9.0) * ((0.01 * r * p * 6.112 * pow(10.0, (7.5 * t) / (237.7 + t))) - 10.0);
 }
-
+*/
 /* reads a NetCDF file containing data for a single grid point */ 
 static
 void readNcFile(const char path[], double **vars, int nvars, int nts)
@@ -154,8 +154,8 @@ void writeNcFile(const char path[], const double array[], int length)
 static
 double **createVars(int nvars, int nts)
 {  
-  double *array = (double*) malloc(nvars*nts*sizeof(double));
-  double **vars = (double**) malloc(nvars*sizeof(double*));
+  double *array = (double*) Malloc(nvars*nts*sizeof(double));
+  double **vars = (double**) Malloc(nvars*sizeof(double*));
   
   int i;
   
@@ -171,14 +171,14 @@ void destroyVars(double **vars)
 {  
   if ( vars != NULL)
     {
-      free(vars[0]);
-      free(vars);
+      Free(vars[0]);
+      Free(vars);
     }
 }
 
 /* gets the path of the CDO binary executable */
 static 
-char *getCdoPath()
+const char *getCdoPath()
 {
   char *cdoPath = getenv("CDO_PATH");
   
@@ -204,7 +204,7 @@ static
 int submitCdoCommand(const char *argument)
 {  
   const char *cdoPath = getCdoPath();
-  char *cdoCommand = (char*) malloc(strlen(cdoPath) + strlen(argument) + 8);
+  char *cdoCommand = (char*) Malloc(strlen(cdoPath) + strlen(argument) + 8);
   
   int status;
   
@@ -214,7 +214,7 @@ int submitCdoCommand(const char *argument)
   strcat(cdoCommand, argument);
   
   status = system(cdoCommand);
-  free(cdoCommand);
+  Free(cdoCommand);
   
   return status;
 }
@@ -396,7 +396,7 @@ void testEcaGsl()
  
   destroyVars(vars);
 }
-
+/*
 static
 void testHi()
 {
@@ -424,7 +424,7 @@ void testHi()
 
   destroyVars(vars);
 }
-
+*/
 static
 void testTimcount()
 {
@@ -463,14 +463,14 @@ void testTimcount()
   
   destroyVars(vars);
 }
-
+/*
 static
 void testSeascount()
 {
   const double array[] = {MISSVAL, MISSVAL, TO_KELVIN(1.0), MISSVAL, 
     TO_KELVIN(1.0), TO_KELVIN(1.0)};
   
-  /* number of output variables and time steps */
+  // number of output variables and time steps
   int nvars = 1;
   int nts   = 1;
   
@@ -502,7 +502,7 @@ void testSeascount()
   
   destroyVars(vars);
 }
-
+*/
 static
 void testWct()
 {
diff --git a/src/clipping/area.c b/src/clipping/area.c
index ba05a10..2fa0e5c 100644
--- a/src/clipping/area.c
+++ b/src/clipping/area.c
@@ -263,7 +263,7 @@ double yac_girards_area ( struct grid_cell cell  ) {
   int M = cell.num_corners;
   if (M < 3) return area;  // a degenerate cell
 
-  double * theta = malloc ( M * sizeof(theta[0]) );
+  double * theta = (double *)malloc ( M * sizeof(theta[0]) );
 
   for ( m = 0; m < M; m++ ) {
      theta[m] = yac_partial_area(cell.coordinates_x[(m+1)%M], cell.coordinates_y[(m+1)%M],
@@ -393,7 +393,7 @@ lat_edge_correction(double base_point[3], double a[3], double b[3],
 
   double lat_area = fabs((1.0 - h) * get_angle(lon_a, lon_b));
 
-  double pole[3] = {0, 0, (a[2] >= 0.0)?1:-1};
+  double pole[3] = {0, 0, (a[2] >= 0.0)?1.0:-1.0};
   double gc_area = tri_area(a, b, pole);
 
   double correction = MAX(lat_area - gc_area, 0.0);
@@ -420,7 +420,7 @@ lat_edge_correction(double base_point[3], double a[3], double b[3],
   if (fabs(scalar_base) < 1e-11) {
 
     double norm_middle[3];
-    double pole[3] = {0,0,((a[2]>0)?1:-1)};
+    double pole[3] = {0,0,((a[2]>0)?1.0:-1.0)};
 
     if (compute_norm_vector(middle_lat, pole, norm_middle)) return 0.0;
 
@@ -450,7 +450,7 @@ double yac_pole_area ( struct grid_cell cell ) {
 
   int closer_to_south_pole = cell.coordinates_y[0] < 0;
 
-  double pole_vec[3] = {0, 0, (closer_to_south_pole)?-1:1};
+  double pole_vec[3] = {0, 0, (closer_to_south_pole)?-1.0:1.0};
 
   // it would also be possible to use the equator instead
   // of the poles as the baseline
diff --git a/src/clipping/clipping.c b/src/clipping/clipping.c
index 1826257..b86ad0b 100644
--- a/src/clipping/clipping.c
+++ b/src/clipping/clipping.c
@@ -155,6 +155,17 @@ void yac_compute_concave_overlap_areas (unsigned N,
                                "(x_coordinates == NULL || y_coordinates == NULL)",
                                __FILE__ , __LINE__);
 
+#ifdef __cplusplus
+  double init_value[3] = {-1};
+  double init_2d_array_value[3*3] = {-1};
+  enum yac_edge_type edge_type_init_value[3]= {GREAT_CIRCLE};
+  struct grid_cell target_partial_cell;
+    target_partial_cell.coordinates_x    = init_value;
+     target_partial_cell.coordinates_y   = init_value;
+     target_partial_cell.coordinates_xyz = init_2d_array_value;
+     target_partial_cell.edge_type       = edge_type_init_value;
+     target_partial_cell.num_corners     = 3;
+#else
   struct grid_cell target_partial_cell =
     {.coordinates_x   = (double[3]){-1},
      .coordinates_y   = (double[3]){-1},
@@ -162,6 +173,7 @@ void yac_compute_concave_overlap_areas (unsigned N,
      .edge_type       = (enum yac_edge_type[3]) {GREAT_CIRCLE},
      .num_corners     = 3};
 
+#endif
   static struct grid_cell * overlap_buffer = NULL;
   static unsigned overlap_buffer_size = 0;
 
@@ -864,22 +876,22 @@ static void copy_point_list(struct point_list in, struct point_list * out) {
 
   if (curr == NULL) return;
 
-  struct point_list_element * new = get_free_point_list_element(out);
-  out->first = new;
-  *new = *curr;
+  struct point_list_element * new_point_list = get_free_point_list_element(out);
+  out->first = new_point_list;
+  *new_point_list = *curr;
   curr = curr->next;
 
   do {
 
-    new->next = get_free_point_list_element(out);
-    new = new->next;
-    *new = *curr;
+    new_point_list->next = get_free_point_list_element(out);
+    new_point_list = new_point_list->next;
+    *new_point_list = *curr;
     curr = curr->next;
 
   } while (curr != in.first);
 
-  new->next = out->first;
-  out->last = new;
+  new_point_list->next = out->first;
+  out->last = new_point_list;
 }
 
 void yac_cell_clipping (unsigned N,
@@ -928,7 +940,7 @@ void yac_cell_clipping (unsigned N,
     prev_tgt_point = prev_tgt_point->next;
   } while (prev_tgt_point != target_list.first);
 
-  norm_vec = malloc(3 * nct * sizeof(*norm_vec));
+  norm_vec = (double *)malloc(3 * nct * sizeof(*norm_vec));
 
   // compute norm vectors for all edges
   // or for lat circle edges a special z value
@@ -1271,13 +1283,13 @@ get_free_point_list_element(struct point_list * list) {
 
     for (int i = 0; i < 7; ++i) {
 
-      element = malloc(1 * sizeof(*element));
+      element = (struct point_list_element *)malloc(1 * sizeof(*element));
 
       element->next = list->free_elements;
       list->free_elements = element;
     }
 
-    element = malloc(1 * sizeof(*element));
+    element = (struct point_list_element *)malloc(1 * sizeof(*element));
 
   } else {
 
@@ -1381,10 +1393,10 @@ static void generate_overlap_cell(struct point_list * list,
     free(cell->coordinates_y);
     free(cell->coordinates_xyz);
     free(cell->edge_type);
-    cell->coordinates_x = malloc(num_edges * sizeof(*cell->coordinates_x));
-    cell->coordinates_y = malloc(num_edges * sizeof(*cell->coordinates_y));
-    cell->coordinates_xyz = malloc(3 * num_edges * sizeof(*cell->coordinates_xyz));
-    cell->edge_type = malloc(num_edges * sizeof(*cell->edge_type));
+    cell->coordinates_x = (double *)malloc(num_edges * sizeof(*cell->coordinates_x));
+    cell->coordinates_y = (double *)malloc(num_edges * sizeof(*cell->coordinates_y));
+    cell->coordinates_xyz = (double *)malloc(3 * num_edges * sizeof(*cell->coordinates_xyz));
+    cell->edge_type = (enum yac_edge_type *)malloc(num_edges * sizeof(*cell->edge_type));
     cell->array_size = num_edges;
   }
   cell->num_corners = num_edges;
diff --git a/src/clipping/grid.h b/src/clipping/grid.h
index 7ca381d..cf26ebe 100644
--- a/src/clipping/grid.h
+++ b/src/clipping/grid.h
@@ -109,7 +109,7 @@ struct grid_vtable {
    void (*pack_grid)(struct grid *, double **, unsigned, unsigned *, unsigned *,
                      unsigned **, unsigned, unsigned *, unsigned *);
    struct grid_search * (*get_grid_search)(struct grid * grid);
-   void (*delete)(struct grid *);
+   void (*grid_delete)(struct grid *);
 };
 
 struct grid {
diff --git a/src/clipping/grid_cell.c b/src/clipping/grid_cell.c
index cb54473..ce15c64 100644
--- a/src/clipping/grid_cell.c
+++ b/src/clipping/grid_cell.c
@@ -60,13 +60,13 @@ void yac_copy_grid_cell(struct grid_cell in_cell, struct grid_cell * out_cell) {
       free(out_cell->coordinates_y);
       free(out_cell->coordinates_xyz);
       free(out_cell->edge_type);
-      out_cell->coordinates_x = malloc(in_cell.num_corners *
+      out_cell->coordinates_x = (double *)malloc(in_cell.num_corners *
                                        sizeof(*(out_cell->coordinates_x)));
-      out_cell->coordinates_y = malloc(in_cell.num_corners *
+      out_cell->coordinates_y = (double *)malloc(in_cell.num_corners *
                                        sizeof(*(out_cell->coordinates_y)));
-      out_cell->coordinates_xyz = malloc(3 * in_cell.num_corners *
+      out_cell->coordinates_xyz = (double *)malloc(3 * in_cell.num_corners *
                                          sizeof(*(out_cell->coordinates_xyz)));
-      out_cell->edge_type = malloc(in_cell.num_corners *
+      out_cell->edge_type = (enum yac_edge_type *)malloc(in_cell.num_corners *
                                    sizeof(*(out_cell->edge_type)));
       out_cell->array_size = in_cell.num_corners;
    }
diff --git a/src/clipping/intersection.c b/src/clipping/intersection.c
index 65da69e..aefc75f 100644
--- a/src/clipping/intersection.c
+++ b/src/clipping/intersection.c
@@ -226,9 +226,9 @@ static int vector_is_between_lat (double a[], double b[], double p[]) {
 
          // dot product is most accurate for angles around half PI
          // (for angles very close to half PI: alpha = fabs(acos(alpha))
-         double angle = fabs(cross_cd[0] * a[0] +
+         double angle = fabs((double)(cross_cd[0] * a[0] +
                              cross_cd[1] * a[1] +
-                             cross_cd[2] * a[2]) / length_cross_cd ;
+                             cross_cd[2] * a[2])) / length_cross_cd ;
 
          // if ab is on the plane of cd
          if (fabs(angle) < tol) {
@@ -258,9 +258,9 @@ static int vector_is_between_lat (double a[], double b[], double p[]) {
 
          // dot product is most accurate for angles around half PI
          // (for angles very close to half PI: alpha = fabs(acos(alpha))
-         double angle = fabs(cross_ab[0] * c[0] +
+         double angle = fabs((double)(cross_ab[0] * c[0] +
                              cross_ab[1] * c[1] +
-                             cross_ab[2] * c[2]) / length_cross_ab;
+                             cross_ab[2] * c[2])) / length_cross_ab;
 
          // if cd is on the plane of ab
          if (fabs(angle) < tol) {
@@ -447,9 +447,9 @@ int gcxgc_vec_ (double a[3], double b[3], double c[3], double d[3]) {
 
          // dot product is most accurate for angles around half PI
          // (for angles very close to half PI: alpha = fabs(acos(alpha))
-         double angle = fabs(cross_cd[0] * a[0] +
+         double angle = fabs((double)(cross_cd[0] * a[0] +
                              cross_cd[1] * a[1] +
-                             cross_cd[2] * a[2]) / length_cross_cd ;
+                             cross_cd[2] * a[2])) / length_cross_cd ;
 
          // if ab is not on the plane of cd
          if (fabs(angle) >= tol)
@@ -467,9 +467,9 @@ int gcxgc_vec_ (double a[3], double b[3], double c[3], double d[3]) {
 
          // dot product is most accurate for angles around half PI
          // (for angles very close to half PI: alpha = fabs(acos(alpha))
-         double angle = fabs(cross_ab[0] * c[0] +
+         double angle = fabs((double)(cross_ab[0] * c[0] +
                              cross_ab[1] * c[1] +
-                             cross_ab[2] * c[2]) / length_cross_ab;
+                             cross_ab[2] * c[2])) / length_cross_ab;
 
          // if cd is not on the plane of ab
          if (fabs(angle) >= tol)
@@ -1038,6 +1038,7 @@ int yac_loncxlonc_vec (double a[3], double b[3], double c[3], double d[3],
    return ret_value;
 }
 
+#if !defined(CDO) 
 static
 int loncxlonc_ (struct edge edge_a, struct edge edge_b) {
 
@@ -1110,6 +1111,7 @@ int loncxlonc_ (struct edge edge_a, struct edge edge_b) {
           ((angle_ac + angle_ad) < angle_cd) ||
           ((angle_bc + angle_bd) < angle_cd);
 }
+#endif
 
 /** \brief compute the intersection point of a meridian and a parallel
  *
@@ -1376,25 +1378,23 @@ static int loncxlatc_ (struct edge edge_a, struct edge edge_b) {
    if (fabs(get_angle(edge_a.points[0].lon, edge_a.points[1].lon)) > tol) {
 
       double lat = (edge_a.points[0].lat > 0)?M_PI_2:-M_PI_2;
-
+    
+      struct edge edge_new_1;
+      edge_new_1.edge_type = LON_CIRCLE;
+      edge_new_1.points[0] = edge_a.points[0];
+      edge_new_1.points[1].lon = edge_a.points[0].lon;
+      edge_new_1.points[1].lat = lat;
+      
+      struct edge edge_new_2;
+      edge_new_2.edge_type = LON_CIRCLE;
+      edge_new_2.points[0] = edge_a.points[1];
+      edge_new_2.points[1].lon = edge_a.points[1].lon;
+      edge_new_2.points[1].lat = lat;
       return
-         loncxlatc_(
-            (struct edge){
-               .edge_type = LON_CIRCLE,
-               .points = {{.lon = edge_a.points[0].lon,
-                           .lat = edge_a.points[0].lat},
-                          {.lon = edge_a.points[0].lon,
-                           .lat = lat}}}, edge_b)
+         loncxlatc_(edge_new_1, edge_b)
          ||
-         loncxlatc_(
-            (struct edge){
-               .edge_type = LON_CIRCLE,
-               .points = {{.lon = edge_a.points[1].lon,
-                           .lat = edge_a.points[1].lat},
-                          {.lon = edge_a.points[1].lon,
-                           .lat = lat}}}, edge_b);
+         loncxlatc_(edge_new_2, edge_b);
    }
-
    // if edge b is at the pole
    if (fabs(fabs(edge_b.points[0].lat) - M_PI_2) < tol) {
 
@@ -1913,7 +1913,11 @@ int yac_do_intersect (struct edge edge_a, double a[3], double b[3],
       case ((1 << 1) | (1 << 3)):
          return loncxlatc_(edge_a, edge_b);
       case ((1 << 1) | (1 << 4)):
+#if defined(CDO)
+         yac_internal_abort_message ( "flag not supported in CDO.", __FILE__, __LINE__ );
+#else
          return loncxlonc_(edge_a, edge_b);
+#endif
       case ((1 << 1) | (1 << 5)):
       case ((1 << 2) | (1 << 4)):
       case ((1 << 2) | (1 << 5)):
diff --git a/src/clipping/utils.c b/src/clipping/utils.c
index d212a31..b0ee9a5 100644
--- a/src/clipping/utils.c
+++ b/src/clipping/utils.c
@@ -39,7 +39,7 @@ static unsigned pointer_lookup_table_size = 0;
 
 unsigned yac_pointer_to_unique_id(void * pointer) {
 
-   pointer_lookup_table = realloc (pointer_lookup_table,
+   pointer_lookup_table = (void **)realloc (pointer_lookup_table,
       ++pointer_lookup_table_size * sizeof(pointer_lookup_table[0]));
 
    pointer_lookup_table[pointer_lookup_table_size-1] = pointer;
@@ -62,7 +62,7 @@ void yac_free_pointer_unique_lookup() {
   pointer_lookup_table_size = 0;
 }
 
-void yac_internal_abort_message ( char * text, char * file, int line )
+void yac_internal_abort_message ( const char * text, const char * file, int line )
 {
   fprintf(stderr, "%s \n", text); 
   fprintf(stderr, "Aborting in file %s, line %i ...\n", file, line );
diff --git a/src/clipping/utils.h b/src/clipping/utils.h
index 500eab2..0de753f 100644
--- a/src/clipping/utils.h
+++ b/src/clipping/utils.h
@@ -69,7 +69,7 @@ void yac_free_pointer_unique_lookup();
  * prints a short error message and info from where it was called
  * followed by an exit. 
  */
-void yac_internal_abort_message ( char * text, char * file, int line );
+void yac_internal_abort_message ( const char * text, const char * file, int line );
 
 /** \example test_quicksort.c
  * This contains an example of how to use quicksort_index.
diff --git a/src/color.c b/src/color.c
index 89ffafd..0dd7a83 100644
--- a/src/color.c
+++ b/src/color.c
@@ -3,6 +3,7 @@
 #include <string.h>
 #include <math.h>
 
+#include "dmemory.h"
 #include "color.h"
 
 
@@ -171,7 +172,7 @@ int cptRead(FILE *fp, CPT *cpt)
 	
   cptInit(cpt);
 
-  cpt->lut = (LUT*) calloc(1, n_alloc*sizeof(LUT));
+  cpt->lut = (LUT*) Calloc(1, n_alloc*sizeof(LUT));
 	
   /* Save the original setting since it may be modified by settings in the CPT file */
   color_model = RGB; 
@@ -320,7 +321,7 @@ int cptRead(FILE *fp, CPT *cpt)
       if (n == n_alloc) {
 	i = n_alloc;
 	n_alloc += small_chunk;
-	cpt->lut = (LUT*) realloc((void *)cpt->lut, (size_t)n_alloc*sizeof (LUT));
+	cpt->lut = (LUT*) Realloc((void *)cpt->lut, (size_t)n_alloc*sizeof (LUT));
 	memset ((void *)&cpt->lut[i], 0, (size_t)(small_chunk * sizeof (LUT)));  /* Initialize new structs to zero */
       }
     }
@@ -339,7 +340,7 @@ int cptRead(FILE *fp, CPT *cpt)
       return (READERR);
     }
 		
-  cpt->lut = (LUT*) realloc((void *)cpt->lut, (size_t)n*sizeof (LUT));
+  cpt->lut = (LUT*) Realloc((void *)cpt->lut, (size_t)n*sizeof (LUT));
   ncolors = n;
   for (i = annot = 0, gap = FALSE; i < ncolors - 1; i++) {
     if ( fabs(cpt->lut[i].z_high - cpt->lut[i+1].z_low) > 0 ) gap = TRUE;
diff --git a/src/config.h.in b/src/config.h.in
index f261a59..574c13c 100644
--- a/src/config.h.in
+++ b/src/config.h.in
@@ -12,6 +12,9 @@
 /* Define to 1 for DATA support */
 #undef ENABLE_DATA
 
+/* Define to 1 if you have the <cmor.h> header file. */
+#undef HAVE_CMOR_H
+
 /* Define to 1 if you have the <curl/curl.h> header file. */
 #undef HAVE_CURL_CURL_H
 
@@ -49,12 +52,12 @@
 /* Define to 1 if you have the <inttypes.h> header file. */
 #undef HAVE_INTTYPES_H
 
-/* Define to 1 if you have the <jasper.h> header file. */
-#undef HAVE_JASPER_H
-
 /* Define to 1 for GRIB1 decoding/encoding with cgribex */
 #undef HAVE_LIBCGRIBEX
 
+/* Define to 1 for CMOR support */
+#undef HAVE_LIBCMOR
+
 /* Define to 1 for CURL support */
 #undef HAVE_LIBCURL
 
@@ -76,9 +79,6 @@
 /* Define to 1 for IEG interface */
 #undef HAVE_LIBIEG
 
-/* Define to 1 for JPEG compression for GRIB2 */
-#undef HAVE_LIBJASPER
-
 /* Define to 1 if you have the `m' library (-lm). */
 #undef HAVE_LIBM
 
diff --git a/src/datetime.c b/src/datetime.c
index d086cfc..4043225 100644
--- a/src/datetime.c
+++ b/src/datetime.c
@@ -1,8 +1,5 @@
-#include <string.h>
-#include <math.h>
-
 #include <cdi.h>
-#include "cdo.h"
+#include "cdo_int.h"
 #include "datetime.h"
 
 static int timestat_date = -1;
@@ -12,7 +9,7 @@ void get_timestat_date(int *tstat_date)
 {
   char *envstr;
 
-  envstr = getenv("TIMESTAT_DATE");
+  envstr = getenv("CDO_TIMESTAT_DATE");
   if ( envstr == NULL ) envstr = getenv("RUNSTAT_DATE");
   if ( envstr )
     {
@@ -31,7 +28,7 @@ void get_timestat_date(int *tstat_date)
 	{
 	  *tstat_date = env_date;
 
-	  if ( cdoVerbose ) cdoPrint("Set TIMESTAT_DATE to %s", envstr);
+	  if ( cdoVerbose ) cdoPrint("Set CDO_TIMESTAT_DATE to %s", envstr);
 	}
     }
 }
@@ -56,7 +53,7 @@ void dtlist_init(dtlist_type *dtlist)
 
 dtlist_type *dtlist_new(void)
 {
-  dtlist_type *dtlist = (dtlist_type *) malloc(sizeof(dtlist_type));
+  dtlist_type *dtlist = (dtlist_type *) Malloc(sizeof(dtlist_type));
 
   dtlist_init(dtlist);
 
@@ -67,9 +64,9 @@ dtlist_type *dtlist_new(void)
 void dtlist_delete(dtlist_type *dtlist)
 {
   if ( dtlist->nalloc > 0 && dtlist->dtinfo )
-    free(dtlist->dtinfo);
+    Free(dtlist->dtinfo);
 
-  free(dtlist);
+  Free(dtlist);
 }
 
 
@@ -80,7 +77,7 @@ void dtlist_taxisInqTimestep(dtlist_type *dtlist, int taxisID, int tsID)
   if ( (size_t)tsID >= dtlist->nalloc )
     {
       dtlist->nalloc += NALLOC;
-      dtlist->dtinfo = (dtinfo_type *) realloc(dtlist->dtinfo, dtlist->nalloc*sizeof(dtinfo_type));
+      dtlist->dtinfo = (dtinfo_type *) Realloc(dtlist->dtinfo, dtlist->nalloc*sizeof(dtinfo_type));
     }
 
   if ( (size_t)tsID >= dtlist->size ) dtlist->size = (size_t)tsID + 1;
diff --git a/src/datetime.h b/src/datetime.h
index 63b7202..18b5caa 100644
--- a/src/datetime.h
+++ b/src/datetime.h
@@ -1,3 +1,6 @@
+#ifndef _DATETIME_H
+#define _DATETIME_H
+
 #include <stdio.h>
 
 #define  TIMESTAT_FIRST  1
@@ -61,3 +64,5 @@ int  dtlist_get_vtime(dtlist_type *dtlist, int tsID);
 void dtlist_taxisInqTimestep(dtlist_type *dtlist, int taxisID, int tsID);
 void dtlist_taxisDefTimestep(dtlist_type *dtlist, int taxisID, int tsID);
 void dtlist_stat_taxisDefTimestep(dtlist_type *dtlist, int taxisID, int nsteps);
+
+#endif  /* _DATETIME_H */
diff --git a/src/dmemory.h b/src/dmemory.h
index 1a17b00..d59d136 100644
--- a/src/dmemory.h
+++ b/src/dmemory.h
@@ -1,16 +1,13 @@
 #ifndef _DMEMORY_H
 #define _DMEMORY_H
 
-#include <stdlib.h>
-
-/*
- * if DEBUG_MEMORY is defined setenv MEMORY_DEBUG to debug memory
- */
+#include <stdio.h>
 
+// if DEBUG_MEMORY is defined setenv MEMORY_DEBUG to debug memory
 #define  DEBUG_MEMORY
 
-#ifndef  WITH_CALLER_NAME
-#define  WITH_CALLER_NAME
+#ifndef  WITH_FUNCTION_NAME
+#define  WITH_FUNCTION_NAME
 #endif
 
 extern size_t  memTotal(void);
@@ -19,27 +16,41 @@ extern void    memExitOnError(void);
 
 #if  defined  DEBUG_MEMORY
 
-extern void   *Realloc(const char *caller, const char *file, int line, void *ptr, size_t size);
-extern void   *Calloc (const char *caller, const char *file, int line, size_t nmemb, size_t size);
-extern void   *Malloc (const char *caller, const char *file, int line, size_t size);
-extern void    Free   (const char *caller, const char *file, int line, void *ptr);
-
-#if  defined  calloc
-#  undef  calloc
-#endif
+extern void   *memRealloc(void *ptr, size_t size, const char *file, const char *functionname, int line);
+extern void   *memCalloc (size_t nmemb, size_t size, const char *file, const char *functionname, int line);
+extern void   *memMalloc (size_t size, const char *file, const char *functionname, int line);
+extern void    memFree   (void *ptr, const char *file, const char *functionname, int line);
 
-#if  defined  WITH_CALLER_NAME
-#  define  realloc(p, s)  Realloc(__func__, __FILE__, __LINE__, (p), (s))
-#  define   calloc(n, s)   Calloc(__func__, __FILE__, __LINE__, (n), (s))
-#  define   malloc(s)      Malloc(__func__, __FILE__, __LINE__, (s))
-#  define     free(p)        Free(__func__, __FILE__, __LINE__, (p))
+#if  defined  WITH_FUNCTION_NAME
+#  define  Realloc(p, s)  memRealloc((p), (s), __FILE__, __func__, __LINE__)
+#  define   Calloc(n, s)   memCalloc((n), (s), __FILE__, __func__, __LINE__)
+#  define   Malloc(s)      memMalloc((s), __FILE__, __func__, __LINE__)
+#  define     Free(p)        memFree((p), __FILE__, __func__, __LINE__)
 #else
-#  define  realloc(p, s)  Realloc((void *) NULL, __FILE__, __LINE__, (p), (s))
-#  define   calloc(n, s)   Calloc((void *) NULL, __FILE__, __LINE__, (n), (s))
-#  define   malloc(s)      Malloc((void *) NULL, __FILE__, __LINE__, (s))
-#  define     free(p)        Free((void *) NULL, __FILE__, __LINE__, (p))
+#  define  Realloc(p, s)  memRealloc((p), (s), __FILE__, (void *) NULL, __LINE__)
+#  define   Calloc(n, s)   memCalloc((n), (s), __FILE__, (void *) NULL, __LINE__)
+#  define   Malloc(s)      memMalloc((s), __FILE__, (void *) NULL, __LINE__)
+#  define     Free(p)        memFree((p), __FILE__, (void *) NULL, __LINE__)
 #endif
 
 #endif /* DEBUG_MEMORY */
 
+void *cdiXmalloc(size_t, const char *, const char *, int);
+#define xmalloc(size) cdiXmalloc((size), __FILE__, __func__,  __LINE__ )
+
+void *cdiXcalloc(size_t, size_t, const char *, const char *, int);
+#define xcalloc(nmemb,size) cdiXcalloc((nmemb), (size), __FILE__, __func__, __LINE__)
+
+void *cdiXrealloc(void *, size_t, const char *, const char *, int);
+#define xrealloc(p,size) cdiXrealloc((p), (size), __FILE__, __func__, __LINE__)
+
 #endif /* _DMEMORY_H */
+/*
+ * Local Variables:
+ * c-file-style: "Java"
+ * c-basic-offset: 2
+ * indent-tabs-mode: nil
+ * show-trailing-whitespace: t
+ * require-trailing-newline: t
+ * End:
+ */
diff --git a/src/dtypes.h b/src/dtypes.h
deleted file mode 100644
index 1a7c516..0000000
--- a/src/dtypes.h
+++ /dev/null
@@ -1,48 +0,0 @@
-#ifndef _DTYPES_H
-#define _DTYPES_H
-
-#include <stdio.h>
-#include <limits.h>
-
-/* INT32 */
-
-#if ! defined(INT_MAX)
-#  error INT_MAX undefined
-#endif
-
-#undef  INT32
-#if  INT_MAX == 2147483647L
-#  define  INT32  int
-#elif LONG_MAX == 2147483647L
-#  define  INT32  long
-#endif
-
-/* INT64 */
-
-#if ! defined(LONG_MAX)
-#  error LONG_MAX undefined
-#endif
-
-#undef  INT64
-#if  LONG_MAX > 2147483647L
-#  define  INT64  long
-#else
-#  define  INT64  long long
-#endif
-
-/* FLT32 */
-
-#undef   FLT32
-#define  FLT32  float
-
-/* FLT64 */
-
-#undef   FLT64
-#define  FLT64  double
-
-/* UINT32 and UINT64 */
-
-#define  UINT32   unsigned INT32
-#define  UINT64   unsigned INT64
-
-#endif  /* _DTYPES_H */
diff --git a/src/ecacore.c b/src/ecacore.c
index 758bfcb..a5edf9f 100755
--- a/src/ecacore.c
+++ b/src/ecacore.c
@@ -23,7 +23,6 @@
 #include "cdo_int.h"
 #include "grid.h"
 #include "pstream.h"
-#include "dtypes.h"
 #include "ecacore.h"
 #include "ecautil.h"
 
@@ -108,32 +107,32 @@ void eca1(const ECA_REQUEST_1 *request)
   streamDefVlist(ostreamID, ovlistID);
 
   nrecords   = vlistNrecs(ivlistID);
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = gridInqSize(gridID);
 
   field_init(&field1);
   field_init(&field2);
 
-  field1.ptr = (double*) malloc(gridsize*sizeof(double));
+  field1.ptr = (double*) Malloc(gridsize*sizeof(double));
   if ( IS_SET(request->var2.h2) || IS_SET(request->var2.h3) ) 
-    field2.ptr = (double*) malloc(gridsize*sizeof(double));
+    field2.ptr = (double*) Malloc(gridsize*sizeof(double));
   else
     field2.ptr = NULL;
 
   nlevels = zaxisInqSize(zaxisID);
 
-  var12 = (field_t*) malloc(nlevels*sizeof(field_t));
-  samp1 = (field_t*) malloc(nlevels*sizeof(field_t));
-  samp2 = (field_t*) malloc(nlevels*sizeof(field_t));
+  var12 = (field_t*) Malloc(nlevels*sizeof(field_t));
+  samp1 = (field_t*) Malloc(nlevels*sizeof(field_t));
+  samp2 = (field_t*) Malloc(nlevels*sizeof(field_t));
   if ( IS_SET(request->var1.f3) ) 
-    var13 = (field_t*) malloc(nlevels*sizeof(field_t));
+    var13 = (field_t*) Malloc(nlevels*sizeof(field_t));
     
   if ( IS_SET(request->var2.h2) ) 
-    var21 = (field_t*) malloc(nlevels*sizeof(field_t));
+    var21 = (field_t*) Malloc(nlevels*sizeof(field_t));
   if ( IS_SET(request->var2.h3) ) 
-    var23 = (field_t*) malloc(nlevels*sizeof(field_t));
+    var23 = (field_t*) Malloc(nlevels*sizeof(field_t));
       
   for ( levelID = 0; levelID < nlevels; levelID++ )
     {
@@ -141,13 +140,13 @@ void eca1(const ECA_REQUEST_1 *request)
       var12[levelID].grid    = gridID;
       var12[levelID].nmiss   = 0;
       var12[levelID].missval = missval;
-      var12[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+      var12[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
 
       field_init(&samp1[levelID]);
       samp1[levelID].grid    = gridID;
       samp1[levelID].nmiss   = 0;
       samp1[levelID].missval = missval;
-      samp1[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+      samp1[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
 
       field_init(&samp2[levelID]);
       samp2[levelID].grid    = gridID;
@@ -161,7 +160,7 @@ void eca1(const ECA_REQUEST_1 *request)
           var13[levelID].grid    = gridID;
           var13[levelID].nmiss   = 0;
           var13[levelID].missval = missval;
-          var13[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+          var13[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
         }
       if ( IS_SET(request->var2.h2) )
         {
@@ -169,7 +168,7 @@ void eca1(const ECA_REQUEST_1 *request)
           var21[levelID].grid    = gridID;
           var21[levelID].nmiss   = 0;
           var21[levelID].missval = missval;
-          var21[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+          var21[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
         }
       if ( IS_SET(request->var2.h3) )
         {
@@ -177,7 +176,7 @@ void eca1(const ECA_REQUEST_1 *request)
           var23[levelID].grid    = gridID;
           var23[levelID].nmiss   = 0;
           var23[levelID].missval = missval;
-          var23[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+          var23[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
         }
     }
 
@@ -246,7 +245,7 @@ void eca1(const ECA_REQUEST_1 *request)
                 {
                   if ( IS_NOT_SET(samp2[levelID].ptr) )
                     {
-                      samp2[levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+                      samp2[levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
                       for ( i = 0; i < gridsize; i++ )
                         samp2[levelID].ptr[i] = nsets;
                     }
@@ -361,38 +360,38 @@ void eca1(const ECA_REQUEST_1 *request)
 
   for ( levelID = 0; levelID < nlevels; levelID++ )
     {
-      free(var12[levelID].ptr);
-      free(samp1[levelID].ptr);
-      if ( IS_SET(samp2[levelID].ptr) ) free(samp2[levelID].ptr);
+      Free(var12[levelID].ptr);
+      Free(samp1[levelID].ptr);
+      if ( IS_SET(samp2[levelID].ptr) ) Free(samp2[levelID].ptr);
     }  
-  free(var12);
-  free(samp1);
-  free(samp2);
+  Free(var12);
+  Free(samp1);
+  Free(samp2);
   
   if ( IS_SET(var13) ) 
     {
       for ( levelID = 0; levelID < nlevels; levelID++ )
-        free(var13[levelID].ptr);
-      free(var13);
+        Free(var13[levelID].ptr);
+      Free(var13);
     }
   if ( IS_SET(var21) ) 
     {
       for ( levelID = 0; levelID < nlevels; levelID++ )
-        free(var21[levelID].ptr);
-      free(var21);
+        Free(var21[levelID].ptr);
+      Free(var21);
     }
   if ( IS_SET(var23) ) 
     {
       for ( levelID = 0; levelID < nlevels; levelID++ )
-        free(var23[levelID].ptr);
-      free(var23);
+        Free(var23[levelID].ptr);
+      Free(var23);
     }
     
-  if ( IS_SET(field1.ptr) ) free(field1.ptr);
-  if ( IS_SET(field2.ptr) ) free(field2.ptr);
+  if ( IS_SET(field1.ptr) ) Free(field1.ptr);
+  if ( IS_SET(field2.ptr) ) Free(field2.ptr);
 
-  if ( IS_SET(recVarID) )   free(recVarID);
-  if ( IS_SET(recLevelID) ) free(recLevelID);
+  if ( IS_SET(recVarID) )   Free(recVarID);
+  if ( IS_SET(recLevelID) ) Free(recLevelID);
 
   streamClose(ostreamID);
   streamClose(istreamID);
@@ -479,29 +478,29 @@ void eca2(const ECA_REQUEST_2 *request)
   streamDefVlist(ostreamID, ovlistID);
 
   nrecords   = vlistNrecs(ivlistID1);
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = gridInqSize(gridID);
 
   field_init(&field1);
   field_init(&field2);
-  field1.ptr = (double*) malloc(gridsize*sizeof(double));
-  field2.ptr = (double*) malloc(gridsize*sizeof(double));
+  field1.ptr = (double*) Malloc(gridsize*sizeof(double));
+  field2.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   nlevels = zaxisInqSize(zaxisID);
   
-  var14 = (field_t*) malloc(nlevels*sizeof(field_t));
-  samp1 = (field_t*) malloc(nlevels*sizeof(field_t));
-  samp2 = (field_t*) malloc(nlevels*sizeof(field_t));
-  samp3 = (field_t*) malloc(nlevels*sizeof(field_t));
+  var14 = (field_t*) Malloc(nlevels*sizeof(field_t));
+  samp1 = (field_t*) Malloc(nlevels*sizeof(field_t));
+  samp2 = (field_t*) Malloc(nlevels*sizeof(field_t));
+  samp3 = (field_t*) Malloc(nlevels*sizeof(field_t));
   
   if ( request->var1.epilog == PERCENT_OF_TOTAL_AMOUNT )
-    total = (field_t*) malloc(nlevels*sizeof(field_t));
+    total = (field_t*) Malloc(nlevels*sizeof(field_t));
   if ( IS_SET(request->var1.f5) )
-    var15 = (field_t*) malloc(nlevels*sizeof(field_t));
+    var15 = (field_t*) Malloc(nlevels*sizeof(field_t));
   if ( IS_SET(request->var2.h2) )
-    var22 = (field_t*) malloc(nlevels*sizeof(field_t));
+    var22 = (field_t*) Malloc(nlevels*sizeof(field_t));
       
   for ( levelID = 0; levelID < nlevels; levelID++ )
     {
@@ -509,19 +508,19 @@ void eca2(const ECA_REQUEST_2 *request)
       var14[levelID].grid    = gridID;
       var14[levelID].nmiss   = 0;
       var14[levelID].missval = missval1;
-      var14[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+      var14[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
       
       field_init(&samp1[levelID]);
       samp1[levelID].grid    = gridID;
       samp1[levelID].nmiss   = 0;
       samp1[levelID].missval = missval1;
-      samp1[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+      samp1[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
 
       field_init(&samp2[levelID]);
       samp2[levelID].grid    = gridID;
       samp2[levelID].nmiss   = 0;
       samp2[levelID].missval = missval1;
-      samp2[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+      samp2[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
 
       field_init(&samp3[levelID]);
       samp3[levelID].grid    = gridID;
@@ -535,7 +534,7 @@ void eca2(const ECA_REQUEST_2 *request)
           total[levelID].grid    = gridID;
           total[levelID].nmiss   = 0;
           total[levelID].missval = missval1;
-          total[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+          total[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
         }
       if ( IS_SET(request->var1.f5) )
         {
@@ -543,7 +542,7 @@ void eca2(const ECA_REQUEST_2 *request)
           var15[levelID].grid    = gridID;
           var15[levelID].nmiss   = 0;
           var15[levelID].missval = missval1;
-          var15[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+          var15[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
         }
       if ( IS_SET(request->var2.h2) )
         {
@@ -551,7 +550,7 @@ void eca2(const ECA_REQUEST_2 *request)
           var22[levelID].grid    = gridID;
           var22[levelID].nmiss   = 0;
           var22[levelID].missval = missval1;
-          var22[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+          var22[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
         }
     }
 
@@ -636,7 +635,7 @@ void eca2(const ECA_REQUEST_2 *request)
                 {
                   if ( IS_NOT_SET(samp3[levelID].ptr) )
                     {
-                      samp3[levelID].ptr = (double*) malloc(gridsize*sizeof(double));
+                      samp3[levelID].ptr = (double*) Malloc(gridsize*sizeof(double));
                       for ( i = 0; i < gridsize; i++ )
                         samp3[levelID].ptr[i] = nsets;
                     }
@@ -745,40 +744,40 @@ void eca2(const ECA_REQUEST_2 *request)
 
   for ( levelID = 0; levelID < nlevels; levelID++ )
     {
-      free(var14[levelID].ptr);
-      free(samp1[levelID].ptr);
-      free(samp2[levelID].ptr);
-      if ( IS_SET(samp3[levelID].ptr) ) free(samp3[levelID].ptr);
+      Free(var14[levelID].ptr);
+      Free(samp1[levelID].ptr);
+      Free(samp2[levelID].ptr);
+      if ( IS_SET(samp3[levelID].ptr) ) Free(samp3[levelID].ptr);
     }
-  free(var14);
-  free(samp1);
-  free(samp2);
-  free(samp3);
+  Free(var14);
+  Free(samp1);
+  Free(samp2);
+  Free(samp3);
   
   if ( IS_SET(total) ) 
     {
       for ( levelID = 0; levelID < nlevels; levelID++ )
-        free(total[levelID].ptr);
-      free(total);
+        Free(total[levelID].ptr);
+      Free(total);
     }
   if ( IS_SET(var15) ) 
     {
       for ( levelID = 0; levelID < nlevels; levelID++ )
-        free(var15[levelID].ptr);
-      free(var15);
+        Free(var15[levelID].ptr);
+      Free(var15);
     }
   if ( IS_SET(var22) ) 
     {
       for ( levelID = 0; levelID < nlevels; levelID++ )
-        free(var22[levelID].ptr);
-      free(var22);
+        Free(var22[levelID].ptr);
+      Free(var22);
     }
   
-  if ( IS_SET(field1.ptr) ) free(field1.ptr);
-  if ( IS_SET(field2.ptr) ) free(field2.ptr);
+  if ( IS_SET(field1.ptr) ) Free(field1.ptr);
+  if ( IS_SET(field2.ptr) ) Free(field2.ptr);
 
-  if ( IS_SET(recVarID) )   free(recVarID);
-  if ( IS_SET(recLevelID) ) free(recLevelID);
+  if ( IS_SET(recVarID) )   Free(recVarID);
+  if ( IS_SET(recLevelID) ) Free(recLevelID);
 
   streamClose(ostreamID);
   streamClose(istreamID2);
@@ -853,20 +852,20 @@ void eca3(const ECA_REQUEST_3 *request)
   streamDefVlist(ostreamID, ovlistID);
 
   nrecords   = vlistNrecs(ivlistID1);
-  recVarID   = (int*) malloc(nrecords*sizeof(int));
-  recLevelID = (int*) malloc(nrecords*sizeof(int));
+  recVarID   = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID = (int*) Malloc(nrecords*sizeof(int));
 
   gridsize = gridInqSize(gridID);
 
   field_init(&field1);
   field_init(&field2);
-  field1.ptr = (double*) malloc(gridsize*sizeof(double));
-  field2.ptr = (double*) malloc(gridsize*sizeof(double));
+  field1.ptr = (double*) Malloc(gridsize*sizeof(double));
+  field2.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   nlevels = zaxisInqSize(zaxisID);
 
-  var1 = (field_t*) malloc(nlevels*sizeof(field_t));
-  var2 = (field_t*) malloc(nlevels*sizeof(field_t));
+  var1 = (field_t*) Malloc(nlevels*sizeof(field_t));
+  var2 = (field_t*) Malloc(nlevels*sizeof(field_t));
         
   for ( levelID = 0; levelID < nlevels; levelID++ )
     {
@@ -874,13 +873,13 @@ void eca3(const ECA_REQUEST_3 *request)
       var1[levelID].grid    = gridID;
       var1[levelID].nmiss   = 0;
       var1[levelID].missval = missval;
-      var1[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+      var1[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
             
       field_init(&var2[levelID]);
       var2[levelID].grid    = gridID;
       var2[levelID].nmiss   = 0;
       var2[levelID].missval = missval;
-      var2[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+      var2[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
     }
 
   itsID   = 0;
@@ -973,17 +972,17 @@ void eca3(const ECA_REQUEST_3 *request)
 
   for ( levelID = 0; levelID < nlevels; levelID++ )
     {
-      free(var1[levelID].ptr);
-      free(var2[levelID].ptr);
+      Free(var1[levelID].ptr);
+      Free(var2[levelID].ptr);
     }
-  free(var1);
-  free(var2);
+  Free(var1);
+  Free(var2);
     
-  if ( IS_SET(field1.ptr) ) free(field1.ptr);
-  if ( IS_SET(field2.ptr) ) free(field2.ptr);
+  if ( IS_SET(field1.ptr) ) Free(field1.ptr);
+  if ( IS_SET(field2.ptr) ) Free(field2.ptr);
 
-  if ( IS_SET(recVarID) )   free(recVarID);
-  if ( IS_SET(recLevelID) ) free(recLevelID);
+  if ( IS_SET(recVarID) )   Free(recVarID);
+  if ( IS_SET(recLevelID) ) Free(recLevelID);
 
   streamClose(ostreamID);
   streamClose(istreamID2);
@@ -1073,8 +1072,8 @@ void eca4(const ECA_REQUEST_4 *request)
   streamDefVlist(ostreamID, ovlistID);
 
   nrecords    = vlistNrecs(ivlistID1);
-  recVarID    = (int*) malloc(nrecords*sizeof(int));
-  recLevelID  = (int*) malloc(nrecords*sizeof(int));
+  recVarID    = (int*) Malloc(nrecords*sizeof(int));
+  recLevelID  = (int*) Malloc(nrecords*sizeof(int));
 
   gridtype = gridInqType(gridID);
   if ( gridtype != GRID_UNSTRUCTURED && gridtype != GRID_CURVILINEAR ) 
@@ -1086,34 +1085,34 @@ void eca4(const ECA_REQUEST_4 *request)
     }
   gridsize    = gridInqSize(gridID);
   /* for later check on northern\southern hemisphere */
-  yvals   = (double*) malloc(gridsize*sizeof(double));
+  yvals   = (double*) Malloc(gridsize*sizeof(double));
   gridInqYvals(gridID,yvals);
 
   /* Two fields are needed because of the definition of gsl for northern and
   * southern hemisphere                                                      */
   field_init(&fieldGt);
   field_init(&fieldLt);
-  fieldGt.ptr = (double*) malloc(gridsize*sizeof(double));
-  fieldLt.ptr = (double*) malloc(gridsize*sizeof(double));
+  fieldGt.ptr = (double*) Malloc(gridsize*sizeof(double));
+  fieldLt.ptr = (double*) Malloc(gridsize*sizeof(double));
 
   /* field for the land-water-distribution */
   field_init(&mask);
-  mask.ptr    = (double*) malloc(gridsize*sizeof(double));
+  mask.ptr    = (double*) Malloc(gridsize*sizeof(double));
 
   nlevels     = zaxisInqSize(zaxisID);
 
-  startCount  = (field_t*) malloc(nlevels*sizeof(field_t));
-  endCount    = (field_t*) malloc(nlevels*sizeof(field_t));
-  gslDuration = (field_t*) malloc(nlevels*sizeof(field_t));
-  gslFirstDay = (field_t*) malloc(nlevels*sizeof(field_t));
+  startCount  = (field_t*) Malloc(nlevels*sizeof(field_t));
+  endCount    = (field_t*) Malloc(nlevels*sizeof(field_t));
+  gslDuration = (field_t*) Malloc(nlevels*sizeof(field_t));
+  gslFirstDay = (field_t*) Malloc(nlevels*sizeof(field_t));
 
   /* because of the different definitions for northern and southern hemisphere,
    * the values of the last year have to be present
    * THE LAST YEAR HAS THE INDEX 1 */
   for ( int h = 0; h < 2; h++ )
   {
-    startDateWithHist[h] = (field_t*) malloc(nlevels*sizeof(field_t));
-    endDateWithHist[h]   = (field_t*) malloc(nlevels*sizeof(field_t));
+    startDateWithHist[h] = (field_t*) Malloc(nlevels*sizeof(field_t));
+    endDateWithHist[h]   = (field_t*) Malloc(nlevels*sizeof(field_t));
   }
 
   for ( levelID = 0; levelID < nlevels; levelID++ )
@@ -1123,7 +1122,7 @@ void eca4(const ECA_REQUEST_4 *request)
     startCount[levelID].size     = gridsize;
     startCount[levelID].nmiss    = 0;
     startCount[levelID].missval  = missval;
-    startCount[levelID].ptr      = (double*) malloc(gridsize*sizeof(double));
+    startCount[levelID].ptr      = (double*) Malloc(gridsize*sizeof(double));
     memset(startCount[levelID].ptr, 0, gridsize*sizeof(double));
 
     field_init(&endCount[levelID]);
@@ -1131,7 +1130,7 @@ void eca4(const ECA_REQUEST_4 *request)
     endCount[levelID].size       = gridsize;
     endCount[levelID].nmiss      = 0;
     endCount[levelID].missval    = missval;
-    endCount[levelID].ptr        = (double*) malloc(gridsize*sizeof(double));
+    endCount[levelID].ptr        = (double*) Malloc(gridsize*sizeof(double));
     memset(endCount[levelID].ptr, 0, gridsize*sizeof(double));
 
     field_init(&gslDuration[levelID]);
@@ -1139,14 +1138,14 @@ void eca4(const ECA_REQUEST_4 *request)
     gslDuration[levelID].size    = gridsize;
     gslDuration[levelID].nmiss   = 0;
     gslDuration[levelID].missval = missval;
-    gslDuration[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+    gslDuration[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
 
     field_init(&gslFirstDay[levelID]);
     gslFirstDay[levelID].grid    = gridID;
     gslFirstDay[levelID].size    = gridsize;
     gslFirstDay[levelID].nmiss   = 0;
     gslFirstDay[levelID].missval = missval;
-    gslFirstDay[levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+    gslFirstDay[levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
 
     for ( int h = 0; h < 2; h++ )
     {
@@ -1155,14 +1154,14 @@ void eca4(const ECA_REQUEST_4 *request)
       startDateWithHist[h][levelID].size    = gridsize;
       startDateWithHist[h][levelID].nmiss   = 0;
       startDateWithHist[h][levelID].missval = missval;
-      startDateWithHist[h][levelID].ptr     = (double*) malloc(gridsize*sizeof(double));
+      startDateWithHist[h][levelID].ptr     = (double*) Malloc(gridsize*sizeof(double));
 
       field_init(&endDateWithHist[h][levelID]);
       endDateWithHist[h][levelID].grid      = gridID;
       endDateWithHist[h][levelID].size      = gridsize;
       endDateWithHist[h][levelID].nmiss     = 0;
       endDateWithHist[h][levelID].missval   = missval;
-      endDateWithHist[h][levelID].ptr       = (double*) malloc(gridsize*sizeof(double));
+      endDateWithHist[h][levelID].ptr       = (double*) Malloc(gridsize*sizeof(double));
     }
   }
 
@@ -1503,31 +1502,31 @@ void eca4(const ECA_REQUEST_4 *request)
 
   for ( levelID = 0; levelID < nlevels; levelID++ )
     {
-      free(startCount[levelID].ptr);
-      free(endCount[levelID].ptr);
-      free(gslDuration[levelID].ptr);
-      free(gslFirstDay[levelID].ptr);
+      Free(startCount[levelID].ptr);
+      Free(endCount[levelID].ptr);
+      Free(gslDuration[levelID].ptr);
+      Free(gslFirstDay[levelID].ptr);
       for (int h = 0; h < 2; h++)
         {
-          free(startDateWithHist[h][levelID].ptr);
-          free(endDateWithHist[h][levelID].ptr);
+          Free(startDateWithHist[h][levelID].ptr);
+          Free(endDateWithHist[h][levelID].ptr);
         }
     }
   for (int h = 0; h < 2; h++)
     {
-      free(startDateWithHist[h]);
-      free(endDateWithHist[h]);
+      Free(startDateWithHist[h]);
+      Free(endDateWithHist[h]);
     }
-  free(startCount);
-  free(endCount);
-  free(gslDuration);
-  free(gslFirstDay);
+  Free(startCount);
+  Free(endCount);
+  Free(gslDuration);
+  Free(gslFirstDay);
 
-  if ( IS_SET(fieldGt.ptr) ) free(fieldGt.ptr);
-  if ( IS_SET(fieldLt.ptr) ) free(fieldLt.ptr);
+  if ( IS_SET(fieldGt.ptr) ) Free(fieldGt.ptr);
+  if ( IS_SET(fieldLt.ptr) ) Free(fieldLt.ptr);
 
-  if ( IS_SET(recVarID) )   free(recVarID);
-  if ( IS_SET(recLevelID) ) free(recLevelID);
+  if ( IS_SET(recVarID) )   Free(recVarID);
+  if ( IS_SET(recLevelID) ) Free(recLevelID);
 
   streamClose(ostreamID);
   streamClose(istreamID1);
diff --git a/src/exception.c b/src/exception.c
index 63abca1..5aa0cf1 100644
--- a/src/exception.c
+++ b/src/exception.c
@@ -1,13 +1,15 @@
-#include <stdio.h>
-#include <stdlib.h>
+#if defined(HAVE_CONFIG_H)
+#  include "config.h"
+#endif
+
 #include <stdarg.h>
 #include <errno.h>
 #include <cdi.h>
 #include "cdo.h"
+#include "cdo_int.h"
 #include "process.h"
 #include "error.h"
 
-#include "config.h"
 
 void cdiOpenError(int cdiErrno, const char *fmt, const char *path)
 {	
diff --git a/src/expr.c b/src/expr.c
index 5754171..6bf2d8f 100644
--- a/src/expr.c
+++ b/src/expr.c
@@ -37,7 +37,7 @@ static double f_sqr(double x)  { return (x*x);      }
 
 typedef struct {
   int type;
-  char *name;                      /* function name            */
+  const char *name;                      /* function name            */
   double (*func)(double);          /* pointer to function      */
 }
 func_t;
@@ -86,7 +86,7 @@ static int NumFunc = sizeof(fun_sym_tbl) / sizeof(fun_sym_tbl[0]);
 static
 nodeType *expr_con_con(int oper, nodeType *p1, nodeType *p2)
 {
-  nodeType *p = (nodeType*) malloc(sizeof(nodeType));
+  nodeType *p = (nodeType*) Malloc(sizeof(nodeType));
 
   p->type = typeCon;
 
@@ -103,37 +103,17 @@ nodeType *expr_con_con(int oper, nodeType *p1, nodeType *p2)
     default:   cdoAbort("%s: operator %c unsupported!", __func__, oper); break;
     }
 
+  p->u.con.value = cval1;
+
   return (p);
 }
 
 static
-nodeType *expr_con_var(int oper, nodeType *p1, nodeType *p2)
+void oper_expr_con_var(int oper, int nmiss, long n, double missval1, double missval2,
+                       double *restrict odat, double cval, const double *restrict idat)
 {
-  int gridID   = p2->gridID;
-  int zaxisID  = p2->zaxisID;
-  int nmiss    = p2->nmiss;
-  double missval1 = p2->missval;
-  double missval2 = p2->missval;
-
-  int ngp  = gridInqSize(gridID);
-  int nlev = zaxisInqSize(zaxisID);
-  long n   = ngp*nlev;
   long i;
 
-  nodeType *p = (nodeType*) malloc(sizeof(nodeType));
-
-  p->type     = typeVar;
-  p->tmpvar   = 1;
-  p->u.var.nm = strdupx("tmp");
-  p->gridID   = gridID;
-  p->zaxisID  = zaxisID;
-  p->missval  = missval1;
-
-  p->data = (double*) malloc(n*sizeof(double));
-  double *restrict odat = p->data;
-  const double *restrict idat = p2->data;
-  double cval = p1->u.con.value;
-
   switch ( oper )
     {
     case '+':
@@ -194,46 +174,14 @@ nodeType *expr_con_var(int oper, nodeType *p1, nodeType *p2)
       cdoAbort("%s: operator %c unsupported!", __func__, oper);
       break;
     }
-
-  nmiss = 0;
-  for ( i = 0; i < n; i++ )
-    if ( DBL_IS_EQUAL(p->data[i], missval1) ) nmiss++;
-
-  p->nmiss = nmiss;
-
-  if ( p2->tmpvar ) free(p2->data);
-
-  return (p);
 }
 
 static
-nodeType *expr_var_con(int oper, nodeType *p1, nodeType *p2)
+void oper_expr_var_con(int oper, int nmiss, long n, double missval1, double missval2,
+                       double *restrict odat, const double *restrict idat, double cval)
 {
-  int gridID   = p1->gridID;
-  int zaxisID  = p1->zaxisID;
-  int nmiss    = p1->nmiss;
-  double missval1 = p1->missval;
-  double missval2 = p1->missval;
-
-  int ngp  = gridInqSize(gridID);
-  int nlev = zaxisInqSize(zaxisID);
-  long n   = ngp*nlev;
   long i;
 
-  nodeType *p = (nodeType*) malloc(sizeof(nodeType));
-
-  p->type     = typeVar;
-  p->tmpvar   = 1;
-  p->u.var.nm = strdupx("tmp");
-  p->gridID   = gridID;
-  p->zaxisID  = zaxisID;
-  p->missval  = missval1;
-
-  p->data = (double*) malloc(n*sizeof(double));
-  double *restrict odat = p->data;
-  const double *restrict idat = p1->data;
-  double cval = p2->u.con.value;
-
   switch ( oper )
     {
     case '+':
@@ -296,6 +244,155 @@ nodeType *expr_var_con(int oper, nodeType *p1, nodeType *p2)
       cdoAbort("%s: operator %c unsupported!", __func__, oper);
       break;
     }
+}
+
+static
+void oper_expr_var_var(int oper, int nmiss, long ngp, double missval1, double missval2,
+                       double *restrict odat, const double *restrict idat1, const double *restrict idat2)
+{
+  long i;
+
+  switch ( oper )
+    {
+    case '+':
+      if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = ADD(idat1[i], idat2[i]);
+      else         for ( i=0; i<ngp; ++i ) odat[i] = idat1[i] + idat2[i];
+      break;
+    case '-':
+      if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = SUB(idat1[i], idat2[i]);
+      else         for ( i=0; i<ngp; ++i ) odat[i] = idat1[i] - idat2[i];
+      break;
+    case '*':
+      if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MUL(idat1[i], idat2[i]);
+      else         for ( i=0; i<ngp; ++i ) odat[i] = idat1[i] * idat2[i];
+      break;
+    case '/':
+      if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = DIV(idat1[i], idat2[i]);
+      else
+        {
+          for ( i = 0; i < ngp; ++i )
+            {
+              if ( IS_EQUAL(idat2[i], 0.) ) odat[i] = missval1;
+              else                          odat[i] = idat1[i] / idat2[i];
+            }
+        }
+      break;
+    case '^':
+      if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = POW(idat1[i], idat2[i]);
+      else         for ( i=0; i<ngp; ++i ) odat[i] = pow(idat1[i], idat2[i]);
+      break;
+    case '<':
+      if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPLT(idat1[i], idat2[i]);
+      else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPLT(idat1[i], idat2[i]);
+      break;
+    case '>':
+      if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPGT(idat1[i], idat2[i]);
+      else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPGT(idat1[i], idat2[i]);
+      break;
+    case LE:
+      if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPLE(idat1[i], idat2[i]);
+      else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPLE(idat1[i], idat2[i]);
+      break;
+    case GE:
+      if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPGE(idat1[i], idat2[i]);
+      else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPGE(idat1[i], idat2[i]);
+      break;
+    case NE:
+      if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPNE(idat1[i], idat2[i]);
+      else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPNE(idat1[i], idat2[i]);
+      break;
+    case EQ:
+      if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPEQ(idat1[i], idat2[i]);
+      else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPEQ(idat1[i], idat2[i]);
+      break;
+    case LEG:
+      if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPLEG(idat1[i], idat2[i]);
+      else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPLEG(idat1[i], idat2[i]);
+      break;
+    case AND:
+      if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPAND(idat1[i], idat2[i]);
+      else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPAND(idat1[i], idat2[i]);
+      break;
+    case OR:
+      if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPOR(idat1[i], idat2[i]);
+      else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPOR(idat1[i], idat2[i]);
+      break;
+    default:
+      cdoAbort("%s: operator %d (%c) unsupported!", __func__, (int)oper, oper);
+      break;
+    }
+}
+
+static
+nodeType *expr_con_var(int oper, nodeType *p1, nodeType *p2)
+{
+  int gridID   = p2->gridID;
+  int zaxisID  = p2->zaxisID;
+  int nmiss    = p2->nmiss;
+  double missval1 = p2->missval;
+  double missval2 = p2->missval;
+
+  int ngp  = gridInqSize(gridID);
+  int nlev = zaxisInqSize(zaxisID);
+  long n   = ngp*nlev;
+  long i;
+
+  nodeType *p = (nodeType*) Malloc(sizeof(nodeType));
+
+  p->type     = typeVar;
+  p->tmpvar   = 1;
+  p->u.var.nm = strdupx("tmp");
+  p->gridID   = gridID;
+  p->zaxisID  = zaxisID;
+  p->missval  = missval1;
+
+  p->data = (double*) Malloc(n*sizeof(double));
+  double *restrict odat = p->data;
+  const double *restrict idat = p2->data;
+  double cval = p1->u.con.value;
+
+  oper_expr_con_var(oper, nmiss, n, missval1, missval2, odat, cval, idat);
+
+  nmiss = 0;
+  for ( i = 0; i < n; i++ )
+    if ( DBL_IS_EQUAL(p->data[i], missval1) ) nmiss++;
+
+  p->nmiss = nmiss;
+
+  if ( p2->tmpvar ) Free(p2->data);
+
+  return (p);
+}
+
+static
+nodeType *expr_var_con(int oper, nodeType *p1, nodeType *p2)
+{
+  int gridID   = p1->gridID;
+  int zaxisID  = p1->zaxisID;
+  int nmiss    = p1->nmiss;
+  double missval1 = p1->missval;
+  double missval2 = p1->missval;
+
+  int ngp  = gridInqSize(gridID);
+  int nlev = zaxisInqSize(zaxisID);
+  long n   = ngp*nlev;
+  long i;
+
+  nodeType *p = (nodeType*) Malloc(sizeof(nodeType));
+
+  p->type     = typeVar;
+  p->tmpvar   = 1;
+  p->u.var.nm = strdupx("tmp");
+  p->gridID   = gridID;
+  p->zaxisID  = zaxisID;
+  p->missval  = missval1;
+
+  p->data = (double*) Malloc(n*sizeof(double));
+  double *restrict odat = p->data;
+  const double *restrict idat = p1->data;
+  double cval = p2->u.con.value;
+
+  oper_expr_var_con(oper, nmiss, n, missval1, missval2, odat, idat, cval);
 
   nmiss = 0;
   for ( i = 0; i < n; i++ )
@@ -303,7 +400,7 @@ nodeType *expr_var_con(int oper, nodeType *p1, nodeType *p2)
 
   p->nmiss = nmiss;
 
-  if ( p1->tmpvar ) free(p1->data);
+  if ( p1->tmpvar ) Free(p1->data);
 
   return (p);
 }
@@ -324,14 +421,14 @@ nodeType *expr_var_var(int oper, nodeType *p1, nodeType *p2)
   long ngp1 = gridInqSize(p1->gridID);
   long ngp2 = gridInqSize(p2->gridID);
 
-  if ( ngp1 != ngp2 ) cdoAbort("Number of grid points differ. ngp1 = %ld, ngp2 = %ld", ngp1, ngp2);
+  if ( ngp1 != ngp2 && ngp2 != 1 ) cdoAbort("Number of grid points differ. ngp1 = %ld, ngp2 = %ld", ngp1, ngp2);
 
   long ngp = ngp1;
 
   long nlev1 = zaxisInqSize(p1->zaxisID);
   long nlev2 = zaxisInqSize(p2->zaxisID);
 
-  nodeType *p = (nodeType*) malloc(sizeof(nodeType));
+  nodeType *p = (nodeType*) Malloc(sizeof(nodeType));
 
   p->type     = typeVar;
   p->tmpvar   = 1;
@@ -361,92 +458,27 @@ nodeType *expr_var_var(int oper, nodeType *p1, nodeType *p2)
       p->missval = p1->missval;
     }
 
-  p->data = (double*) malloc(ngp*nlev*sizeof(double));
+  p->data = (double*) Malloc(ngp*nlev*sizeof(double));
 
   for ( k = 0; k < nlev; k++ )
     {
       loff = k*ngp;
 
       if ( nlev1 == 1 ) loff1 = 0;
-      else              loff1 = k*ngp;
+      else              loff1 = k*ngp1;
 
       if ( nlev2 == 1 ) loff2 = 0;
-      else              loff2 = k*ngp;
+      else              loff2 = k*ngp2;
 
       const double *restrict idat1 = p1->data+loff1;
       const double *restrict idat2 = p2->data+loff2;
       double *restrict odat = p->data+loff;
       int nmiss = nmiss1 > 0 || nmiss2 > 0;
 
-      switch ( oper )
-	{
-	case '+':
-	  if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = ADD(idat1[i], idat2[i]);
-	  else         for ( i=0; i<ngp; ++i ) odat[i] = idat1[i] + idat2[i];
-	  break;
-	case '-':
-	  if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = SUB(idat1[i], idat2[i]);
-	  else         for ( i=0; i<ngp; ++i ) odat[i] = idat1[i] - idat2[i];
-	  break;
-	case '*':
-	  if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MUL(idat1[i], idat2[i]);
-	  else         for ( i=0; i<ngp; ++i ) odat[i] = idat1[i] * idat2[i];
-	  break;
-	case '/':
-	  if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = DIV(idat1[i], idat2[i]);
-	  else
-	    {
-	      for ( i = 0; i < ngp; ++i )
-		{
-		  if ( IS_EQUAL(idat2[i], 0.) ) odat[i] = missval1;
-		  else                          odat[i] = idat1[i] / idat2[i];
-		}
-	    }
-	  break;
-	case '^':
-	  if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = POW(idat1[i], idat2[i]);
-	  else         for ( i=0; i<ngp; ++i ) odat[i] = pow(idat1[i], idat2[i]);
-	  break;
-	case '<':
-	  if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPLT(idat1[i], idat2[i]);
-	  else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPLT(idat1[i], idat2[i]);
-	  break;
-	case '>':
-	  if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPGT(idat1[i], idat2[i]);
-	  else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPGT(idat1[i], idat2[i]);
-	  break;
-	case LE:
-	  if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPLE(idat1[i], idat2[i]);
-	  else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPLE(idat1[i], idat2[i]);
-	  break;
-	case GE:
-	  if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPGE(idat1[i], idat2[i]);
-	  else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPGE(idat1[i], idat2[i]);
-	  break;
-	case NE:
-	  if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPNE(idat1[i], idat2[i]);
-	  else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPNE(idat1[i], idat2[i]);
-	  break;
-	case EQ:
-	  if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPEQ(idat1[i], idat2[i]);
-	  else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPEQ(idat1[i], idat2[i]);
-	  break;
-	case LEG:
-	  if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPLEG(idat1[i], idat2[i]);
-	  else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPLEG(idat1[i], idat2[i]);
-	  break;
-	case AND:
-	  if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPAND(idat1[i], idat2[i]);
-	  else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPAND(idat1[i], idat2[i]);
-	  break;
-	case OR:
-	  if ( nmiss ) for ( i=0; i<ngp; ++i ) odat[i] = MVCOMPOR(idat1[i], idat2[i]);
-	  else         for ( i=0; i<ngp; ++i ) odat[i] =   COMPOR(idat1[i], idat2[i]);
-	  break;
-	default:
-	  cdoAbort("%s: operator %d (%c) unsupported!", __func__, (int)oper, oper);
-          break;
-	}
+      if ( ngp2 == 1 )
+        oper_expr_var_con(oper, nmiss, ngp, missval1, missval2, odat, idat1, idat2[0]);
+      else
+        oper_expr_var_var(oper, nmiss, ngp, missval1, missval2, odat, idat1, idat2);
     }
 
   nmiss = 0;
@@ -455,8 +487,8 @@ nodeType *expr_var_var(int oper, nodeType *p1, nodeType *p2)
 
   p->nmiss = nmiss;
 
-  if ( p1->tmpvar ) free(p1->data);
-  if ( p2->tmpvar ) free(p2->data);
+  if ( p1->tmpvar ) Free(p1->data);
+  if ( p2->tmpvar ) Free(p2->data);
 
   return (p);
 }
@@ -464,23 +496,20 @@ nodeType *expr_var_var(int oper, nodeType *p1, nodeType *p2)
 static
 void ex_copy(nodeType *p2, nodeType *p1)
 {
-  long ngp, ngp1, ngp2, i;
-  long nlev;
+  long i;
 
-  if ( cdoVerbose )
-    printf("\tcopy %s\n", p1->u.var.nm);
+  if ( cdoVerbose ) printf("\tcopy %s\n", p1->u.var.nm);
 
-  ngp1 = gridInqSize(p1->gridID);
-  ngp2 = gridInqSize(p2->gridID);
+  long ngp1 = gridInqSize(p1->gridID);
+  long ngp2 = gridInqSize(p2->gridID);
 
   if ( ngp1 != ngp2 )
     cdoAbort("Number of grid points differ. ngp1 = %d, ngp2 = %d", ngp1, ngp2);
 
-  ngp = ngp2;
-  nlev = zaxisInqSize(p2->zaxisID);
+  long ngp = ngp2;
+  long nlev = zaxisInqSize(p2->zaxisID);
 
-  for ( i = 0; i < ngp*nlev; i++ )
-    p2->data[i] = p1->data[i];
+  for ( i = 0; i < ngp*nlev; i++ ) p2->data[i] = p1->data[i];
 
   p2->missval = p1->missval;
   p2->nmiss   = p1->nmiss;
@@ -527,7 +556,7 @@ nodeType *ex_fun_con(char *fun, nodeType *p1)
   int i;
   int funcID = -1;
 
-  nodeType *p = (nodeType*) malloc(sizeof(nodeType));
+  nodeType *p = (nodeType*) Malloc(sizeof(nodeType));
 
   p->type = typeCon;
 
@@ -560,7 +589,7 @@ nodeType *ex_fun_var(char *fun, nodeType *p1)
   long ngp  = gridInqSize(gridID);
   long nlev = zaxisInqSize(zaxisID);
 
-  nodeType *p = (nodeType*) malloc(sizeof(nodeType));
+  nodeType *p = (nodeType*) Malloc(sizeof(nodeType));
 
   p->type     = typeVar;
   p->tmpvar   = 1;
@@ -569,7 +598,7 @@ nodeType *ex_fun_var(char *fun, nodeType *p1)
   p->zaxisID  = zaxisID;
   p->missval  = missval;
 
-  p->data = (double*) malloc(ngp*nlev*sizeof(double));
+  p->data = (double*) Malloc(ngp*nlev*sizeof(double));
 
   for ( i = 0; i < NumFunc; i++)
     if ( strcmp(fun, fun_sym_tbl[i].name) == 0 )
@@ -608,7 +637,7 @@ nodeType *ex_fun_var(char *fun, nodeType *p1)
 
   p->nmiss = nmiss;
 
-  if ( p1->tmpvar ) free(p1->data);
+  if ( p1->tmpvar ) Free(p1->data);
 
   return (p);
 }
@@ -645,7 +674,7 @@ nodeType *ex_uminus_var(nodeType *p1)
   long ngp  = gridInqSize(gridID);
   long nlev = zaxisInqSize(zaxisID);
 
-  nodeType *p = (nodeType*) malloc(sizeof(nodeType));
+  nodeType *p = (nodeType*) Malloc(sizeof(nodeType));
 
   p->type     = typeVar;
   p->tmpvar   = 1;
@@ -654,7 +683,7 @@ nodeType *ex_uminus_var(nodeType *p1)
   p->zaxisID  = zaxisID;
   p->missval  = missval;
 
-  p->data = (double*) malloc(ngp*nlev*sizeof(double));
+  p->data = (double*) Malloc(ngp*nlev*sizeof(double));
 
   if ( nmiss > 0 )
     {
@@ -675,7 +704,7 @@ nodeType *ex_uminus_var(nodeType *p1)
 static
 nodeType *ex_uminus_con(nodeType *p1)
 {
-  nodeType *p = (nodeType*) malloc(sizeof(nodeType));
+  nodeType *p = (nodeType*) Malloc(sizeof(nodeType));
 
   p->type = typeCon;
 
@@ -780,7 +809,7 @@ nodeType *ex_ifelse(nodeType *p1, nodeType *p2, nodeType *p3)
 	}
     }
 
-  nodeType *p = (nodeType*) malloc(sizeof(nodeType));
+  nodeType *p = (nodeType*) Malloc(sizeof(nodeType));
 
   p->type     = typeVar;
   p->tmpvar   = 1;
@@ -790,7 +819,7 @@ nodeType *ex_ifelse(nodeType *p1, nodeType *p2, nodeType *p3)
   p->zaxisID = px->zaxisID;
   p->missval = px->missval;
 
-  p->data = (double*) malloc(ngp*nlev*sizeof(double));
+  p->data = (double*) Malloc(ngp*nlev*sizeof(double));
 
   long loff, loff1, loff2, loff3;
 
@@ -839,7 +868,7 @@ int exNode(nodeType *p, parse_parm_t *parse_arg)
   /* node is leaf */
   if ( p->type == typeCon || p->type == typeVar || p->u.opr.nops == 0 )
     {
-      return (0);
+      return 0;
     }
 
   /* node has children */
@@ -848,7 +877,7 @@ int exNode(nodeType *p, parse_parm_t *parse_arg)
       exNode(p->u.opr.op[k], parse_arg);
     }
 
-  return (0);
+  return 0;
 }
 
 
@@ -862,7 +891,7 @@ nodeType *expr_run(nodeType *p, parse_parm_t *parse_arg)
 
   if ( ! p ) return (rnode);
 
-  /*  if ( ! parse_arg->init ) { exNode(p, parse_arg); return (0); } */
+  /*  if ( ! parse_arg->init ) { exNode(p, parse_arg); return 0; } */
 
   switch ( p->type )
     {
@@ -1024,7 +1053,7 @@ nodeType *expr_run(nodeType *p, parse_parm_t *parse_arg)
 
 		  ex_copy(p, rnode);
 
-		  if ( rnode->tmpvar ) free(rnode->data);
+		  if ( rnode->tmpvar ) Free(rnode->data);
 		}
 	    }
 
diff --git a/src/expr.h b/src/expr.h
index ba66b2b..6d3cebc 100644
--- a/src/expr.h
+++ b/src/expr.h
@@ -1,8 +1,14 @@
 #include <stdio.h>
 
+#ifndef register
+#define register
+#endif
+
+#ifdef __cplusplus
 #ifndef fileno
 int fileno(FILE *stream);
 #endif
+#endif
 
 #ifndef strdupx
 #ifndef strdup
@@ -14,7 +20,7 @@ char *strdup(const char *s);
 ({					      	  \
    const char *__old = (s);			  \
    size_t __len = strlen(__old) + 1;		  \
-   char *__new = malloc(__len);	  \
+   char *__new = Malloc(__len);	  \
    (char *) memcpy(__new, __old, __len);	  \
 })
 */
@@ -98,7 +104,7 @@ typedef union{
 YY_DECL;
 
 int  yyparse(parse_parm_t *parse_arg, void*);
-void yyerror(void *parse_arg, void *scanner, char *errstr);
+void yyerror(void *parse_arg, void *scanner, const char *errstr);
 
 int  yylex_init(void **);
 int  yylex_destroy(void *);
diff --git a/src/expr_yacc.c b/src/expr_yacc.c
index a26dbcd..2b69bca 100644
--- a/src/expr_yacc.c
+++ b/src/expr_yacc.c
@@ -1,19 +1,19 @@
-/* A Bison parser, made by GNU Bison 2.7.12-4996.  */
+/* A Bison parser, made by GNU Bison 3.0.4.  */
 
 /* Bison implementation for Yacc-like parsers in C
-   
-      Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
-   
+
+   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
@@ -26,7 +26,7 @@
    special exception, which will cause the skeleton and the resulting
    Bison output files to be licensed under the GNU General Public
    License without this special exception.
-   
+
    This special exception was added by the Free Software Foundation in
    version 2.2 of Bison.  */
 
@@ -44,7 +44,7 @@
 #define YYBISON 1
 
 /* Bison version.  */
-#define YYBISON_VERSION "2.7.12-4996"
+#define YYBISON_VERSION "3.0.4"
 
 /* Skeleton name.  */
 #define YYSKELETON_NAME "yacc.c"
@@ -62,8 +62,7 @@
 
 
 /* Copy the first part of user declarations.  */
-/* Line 371 of yacc.c  */
-#line 2 "expr_yacc.y"
+#line 2 "expr_yacc.y" /* yacc.c:339  */
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -89,14 +88,13 @@ void freeNode(nodeType *p);
 int expr_run(nodeType *p, parse_parm_t *parse_arg);
 
 
-/* Line 371 of yacc.c  */
-#line 94 "expr_yacc.c"
+#line 92 "expr_yacc.c" /* yacc.c:339  */
 
-# ifndef YY_NULL
+# ifndef YY_NULLPTR
 #  if defined __cplusplus && 201103L <= __cplusplus
-#   define YY_NULL nullptr
+#   define YY_NULLPTR nullptr
 #  else
-#   define YY_NULL 0
+#   define YY_NULLPTR 0
 #  endif
 # endif
 
@@ -112,7 +110,7 @@ int expr_run(nodeType *p, parse_parm_t *parse_arg);
    by #include "expr_yacc.h".  */
 #ifndef YY_YY_EXPR_YACC_H_INCLUDED
 # define YY_YY_EXPR_YACC_H_INCLUDED
-/* Enabling traces.  */
+/* Debug traces.  */
 #ifndef YYDEBUG
 # define YYDEBUG 0
 #endif
@@ -120,67 +118,48 @@ int expr_run(nodeType *p, parse_parm_t *parse_arg);
 extern int yydebug;
 #endif
 
-/* Tokens.  */
+/* Token type.  */
 #ifndef YYTOKENTYPE
 # define YYTOKENTYPE
-   /* Put the tokens into the symbol table, so that GDB and other debuggers
-      know about them.  */
-   enum yytokentype {
-     CONSTANT = 258,
-     VARIABLE = 259,
-     FUNCTION = 260,
-     NE = 261,
-     EQ = 262,
-     LE = 263,
-     GE = 264,
-     LEG = 265,
-     OR = 266,
-     AND = 267,
-     UMINUS = 268
-   };
+  enum yytokentype
+  {
+    CONSTANT = 258,
+    VARIABLE = 259,
+    FUNCTION = 260,
+    LEG = 261,
+    GE = 262,
+    LE = 263,
+    EQ = 264,
+    NE = 265,
+    AND = 266,
+    OR = 267,
+    UMINUS = 268
+  };
 #endif
 /* Tokens.  */
 #define CONSTANT 258
 #define VARIABLE 259
 #define FUNCTION 260
-#define NE 261
-#define EQ 262
+#define LEG 261
+#define GE 262
 #define LE 263
-#define GE 264
-#define LEG 265
-#define OR 266
-#define AND 267
+#define EQ 264
+#define NE 265
+#define AND 266
+#define OR 267
 #define UMINUS 268
 
+/* Value type.  */
 
 
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-#endif
-
-
-#ifdef YYPARSE_PARAM
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void *YYPARSE_PARAM);
-#else
-int yyparse ();
-#endif
-#else /* ! YYPARSE_PARAM */
-#if defined __STDC__ || defined __cplusplus
 int yyparse (parse_parm_t *parse_arg, void *scanner);
-#else
-int yyparse ();
-#endif
-#endif /* ! YYPARSE_PARAM */
 
 #endif /* !YY_YY_EXPR_YACC_H_INCLUDED  */
 
 /* Copy the second part of user declarations.  */
 
-/* Line 390 of yacc.c  */
-#line 184 "expr_yacc.c"
+#line 163 "expr_yacc.c" /* yacc.c:358  */
 
 #ifdef short
 # undef short
@@ -194,11 +173,8 @@ typedef unsigned char yytype_uint8;
 
 #ifdef YYTYPE_INT8
 typedef YYTYPE_INT8 yytype_int8;
-#elif (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-typedef signed char yytype_int8;
 #else
-typedef short int yytype_int8;
+typedef signed char yytype_int8;
 #endif
 
 #ifdef YYTYPE_UINT16
@@ -218,8 +194,7 @@ typedef short int yytype_int16;
 #  define YYSIZE_T __SIZE_TYPE__
 # elif defined size_t
 #  define YYSIZE_T size_t
-# elif ! defined YYSIZE_T && (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
+# elif ! defined YYSIZE_T
 #  include <stddef.h> /* INFRINGES ON USER NAME SPACE */
 #  define YYSIZE_T size_t
 # else
@@ -241,11 +216,30 @@ typedef short int yytype_int16;
 # endif
 #endif
 
-#ifndef __attribute__
-/* This feature is available in gcc versions 2.5 and later.  */
-# if (! defined __GNUC__ || __GNUC__ < 2 \
-      || (__GNUC__ == 2 && __GNUC_MINOR__ < 5))
-#  define __attribute__(Spec) /* empty */
+#ifndef YY_ATTRIBUTE
+# if (defined __GNUC__                                               \
+      && (2 < __GNUC__ || (__GNUC__ == 2 && 96 <= __GNUC_MINOR__)))  \
+     || defined __SUNPRO_C && 0x5110 <= __SUNPRO_C
+#  define YY_ATTRIBUTE(Spec) __attribute__(Spec)
+# else
+#  define YY_ATTRIBUTE(Spec) /* empty */
+# endif
+#endif
+
+#ifndef YY_ATTRIBUTE_PURE
+# define YY_ATTRIBUTE_PURE   YY_ATTRIBUTE ((__pure__))
+#endif
+
+#ifndef YY_ATTRIBUTE_UNUSED
+# define YY_ATTRIBUTE_UNUSED YY_ATTRIBUTE ((__unused__))
+#endif
+
+#if !defined _Noreturn \
+     && (!defined __STDC_VERSION__ || __STDC_VERSION__ < 201112)
+# if defined _MSC_VER && 1200 <= _MSC_VER
+#  define _Noreturn __declspec (noreturn)
+# else
+#  define _Noreturn YY_ATTRIBUTE ((__noreturn__))
 # endif
 #endif
 
@@ -256,25 +250,26 @@ typedef short int yytype_int16;
 # define YYUSE(E) /* empty */
 #endif
 
-
-/* Identity function, used to suppress warnings about constant conditions.  */
-#ifndef lint
-# define YYID(N) (N)
-#else
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-static int
-YYID (int yyi)
+#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
+/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
+    _Pragma ("GCC diagnostic push") \
+    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
+    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
+    _Pragma ("GCC diagnostic pop")
 #else
-static int
-YYID (yyi)
-    int yyi;
+# define YY_INITIAL_VALUE(Value) Value
 #endif
-{
-  return yyi;
-}
+#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
+# define YY_IGNORE_MAYBE_UNINITIALIZED_END
+#endif
+#ifndef YY_INITIAL_VALUE
+# define YY_INITIAL_VALUE(Value) /* Nothing. */
 #endif
 
+
 #if ! defined yyoverflow || YYERROR_VERBOSE
 
 /* The parser invokes alloca or malloc; define the necessary symbols.  */
@@ -292,8 +287,7 @@ YYID (yyi)
 #    define alloca _alloca
 #   else
 #    define YYSTACK_ALLOC alloca
-#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
+#    if ! defined _ALLOCA_H && ! defined EXIT_SUCCESS
 #     include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
       /* Use EXIT_SUCCESS as a witness for stdlib.h.  */
 #     ifndef EXIT_SUCCESS
@@ -305,8 +299,8 @@ YYID (yyi)
 # endif
 
 # ifdef YYSTACK_ALLOC
-   /* Pacify GCC's `empty if-body' warning.  */
-#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (YYID (0))
+   /* Pacify GCC's 'empty if-body' warning.  */
+#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
 #  ifndef YYSTACK_ALLOC_MAXIMUM
     /* The OS might guarantee only one guard page at the bottom of the stack,
        and a page size can be as small as 4096 bytes.  So we cannot safely
@@ -322,7 +316,7 @@ YYID (yyi)
 #  endif
 #  if (defined __cplusplus && ! defined EXIT_SUCCESS \
        && ! ((defined YYMALLOC || defined malloc) \
-	     && (defined YYFREE || defined free)))
+             && (defined YYFREE || defined free)))
 #   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
 #   ifndef EXIT_SUCCESS
 #    define EXIT_SUCCESS 0
@@ -330,15 +324,13 @@ YYID (yyi)
 #  endif
 #  ifndef YYMALLOC
 #   define YYMALLOC malloc
-#   if ! defined malloc && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
+#   if ! defined malloc && ! defined EXIT_SUCCESS
 void *malloc (YYSIZE_T); /* INFRINGES ON USER NAME SPACE */
 #   endif
 #  endif
 #  ifndef YYFREE
 #   define YYFREE free
-#   if ! defined free && ! defined EXIT_SUCCESS && (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
+#   if ! defined free && ! defined EXIT_SUCCESS
 void free (void *); /* INFRINGES ON USER NAME SPACE */
 #   endif
 #  endif
@@ -348,7 +340,7 @@ void free (void *); /* INFRINGES ON USER NAME SPACE */
 
 #if (! defined yyoverflow \
      && (! defined __cplusplus \
-	 || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
+         || (defined YYSTYPE_IS_TRIVIAL && YYSTYPE_IS_TRIVIAL)))
 
 /* A type that is properly aligned for any stack member.  */
 union yyalloc
@@ -373,16 +365,16 @@ union yyalloc
    elements in the stack, and YYPTR gives the new location of the
    stack.  Advance YYPTR to a properly aligned location for the next
    stack.  */
-# define YYSTACK_RELOCATE(Stack_alloc, Stack)				\
-    do									\
-      {									\
-	YYSIZE_T yynewbytes;						\
-	YYCOPY (&yyptr->Stack_alloc, Stack, yysize);			\
-	Stack = &yyptr->Stack_alloc;					\
-	yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
-	yyptr += yynewbytes / sizeof (*yyptr);				\
-      }									\
-    while (YYID (0))
+# define YYSTACK_RELOCATE(Stack_alloc, Stack)                           \
+    do                                                                  \
+      {                                                                 \
+        YYSIZE_T yynewbytes;                                            \
+        YYCOPY (&yyptr->Stack_alloc, Stack, yysize);                    \
+        Stack = &yyptr->Stack_alloc;                                    \
+        yynewbytes = yystacksize * sizeof (*Stack) + YYSTACK_GAP_MAXIMUM; \
+        yyptr += yynewbytes / sizeof (*yyptr);                          \
+      }                                                                 \
+    while (0)
 
 #endif
 
@@ -401,7 +393,7 @@ union yyalloc
           for (yyi = 0; yyi < (Count); yyi++)   \
             (Dst)[yyi] = (Src)[yyi];            \
         }                                       \
-      while (YYID (0))
+      while (0)
 #  endif
 # endif
 #endif /* !YYCOPY_NEEDED */
@@ -417,17 +409,19 @@ union yyalloc
 #define YYNNTS  6
 /* YYNRULES -- Number of rules.  */
 #define YYNRULES  31
-/* YYNRULES -- Number of states.  */
+/* YYNSTATES -- Number of states.  */
 #define YYNSTATES  61
 
-/* YYTRANSLATE(YYLEX) -- Bison symbol number corresponding to YYLEX.  */
+/* YYTRANSLATE[YYX] -- Symbol number corresponding to YYX as returned
+   by yylex, with out-of-bounds checking.  */
 #define YYUNDEFTOK  2
 #define YYMAXUTOK   268
 
-#define YYTRANSLATE(YYX)						\
+#define YYTRANSLATE(YYX)                                                \
   ((unsigned int) (YYX) <= YYMAXUTOK ? yytranslate[YYX] : YYUNDEFTOK)
 
-/* YYTRANSLATE[YYLEX] -- Bison symbol number corresponding to YYLEX.  */
+/* YYTRANSLATE[TOKEN-NUM] -- Symbol number corresponding to TOKEN-NUM
+   as returned by yylex, without out-of-bounds checking.  */
 static const yytype_uint8 yytranslate[] =
 {
        0,     2,     2,     2,     2,     2,     2,     2,     2,     2,
@@ -436,7 +430,7 @@ static const yytype_uint8 yytranslate[] =
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
       27,    28,    15,    13,     2,    14,     2,    16,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,    21,    24,
-       7,    19,     6,    20,     2,     2,     2,     2,     2,     2,
+      12,    19,    11,    20,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,    22,     2,     2,     2,     2,     2,
@@ -456,37 +450,11 @@ static const yytype_uint8 yytranslate[] =
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
        2,     2,     2,     2,     2,     2,     1,     2,     3,     4,
-       5,     8,     9,    10,    11,    12,    17,    18,    23
+       5,     6,     7,     8,     9,    10,    17,    18,    23
 };
 
 #if YYDEBUG
-/* YYPRHS[YYN] -- Index of the first RHS symbol of rule number YYN in
-   YYRHS.  */
-static const yytype_uint8 yyprhs[] =
-{
-       0,     0,     3,     5,     8,     9,    11,    14,    19,    22,
-      26,    28,    31,    33,    35,    38,    42,    46,    50,    54,
-      58,    62,    66,    70,    74,    78,    82,    86,    90,    94,
-     100,   104
-};
-
-/* YYRHS -- A `-1'-separated list of the rules' RHS.  */
-static const yytype_int8 yyrhs[] =
-{
-      30,     0,    -1,    31,    -1,    31,    32,    -1,    -1,    24,
-      -1,    34,    24,    -1,     4,    19,    34,    24,    -1,     4,
-      24,    -1,    25,    33,    26,    -1,    32,    -1,    33,    32,
-      -1,     3,    -1,     4,    -1,    14,    34,    -1,    34,    13,
-      34,    -1,    34,    14,    34,    -1,    34,    15,    34,    -1,
-      34,    16,    34,    -1,    34,     7,    34,    -1,    34,     6,
-      34,    -1,    34,    22,    34,    -1,    34,    11,    34,    -1,
-      34,    10,    34,    -1,    34,     8,    34,    -1,    34,     9,
-      34,    -1,    34,    12,    34,    -1,    34,    18,    34,    -1,
-      34,    17,    34,    -1,    34,    20,    34,    21,    34,    -1,
-      27,    34,    28,    -1,     5,    27,    34,    28,    -1
-};
-
-/* YYRLINE[YYN] -- source line where rule number YYN was defined.  */
+  /* YYRLINE[YYN] -- Source line where rule number YYN was defined.  */
 static const yytype_uint8 yyrline[] =
 {
        0,    53,    53,    57,    58,    62,    63,    64,    65,    66,
@@ -502,65 +470,36 @@ static const yytype_uint8 yyrline[] =
 static const char *const yytname[] =
 {
   "$end", "error", "$undefined", "CONSTANT", "VARIABLE", "FUNCTION",
-  "'>'", "'<'", "NE", "EQ", "LE", "GE", "LEG", "'+'", "'-'", "'*'", "'/'",
-  "OR", "AND", "'='", "'?'", "':'", "'^'", "UMINUS", "';'", "'{'", "'}'",
+  "LEG", "GE", "LE", "EQ", "NE", "'>'", "'<'", "'+'", "'-'", "'*'", "'/'",
+  "AND", "OR", "'='", "'?'", "':'", "'^'", "UMINUS", "';'", "'{'", "'}'",
   "'('", "')'", "$accept", "program", "function", "stmt", "stmt_list",
-  "expr", YY_NULL
+  "expr", YY_NULLPTR
 };
 #endif
 
 # ifdef YYPRINT
-/* YYTOKNUM[YYLEX-NUM] -- Internal token number corresponding to
-   token YYLEX-NUM.  */
+/* YYTOKNUM[NUM] -- (External) token number corresponding to the
+   (internal) symbol number NUM (which must be that of a token).  */
 static const yytype_uint16 yytoknum[] =
 {
-       0,   256,   257,   258,   259,   260,    62,    60,   261,   262,
-     263,   264,   265,    43,    45,    42,    47,   266,   267,    61,
+       0,   256,   257,   258,   259,   260,   261,   262,   263,   264,
+     265,    62,    60,    43,    45,    42,    47,   266,   267,    61,
       63,    58,    94,   268,    59,   123,   125,    40,    41
 };
 # endif
 
-/* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
-static const yytype_uint8 yyr1[] =
-{
-       0,    29,    30,    31,    31,    32,    32,    32,    32,    32,
-      33,    33,    34,    34,    34,    34,    34,    34,    34,    34,
-      34,    34,    34,    34,    34,    34,    34,    34,    34,    34,
-      34,    34
-};
+#define YYPACT_NINF -15
 
-/* YYR2[YYN] -- Number of symbols composing right hand side of rule YYN.  */
-static const yytype_uint8 yyr2[] =
-{
-       0,     2,     1,     2,     0,     1,     2,     4,     2,     3,
-       1,     2,     1,     1,     2,     3,     3,     3,     3,     3,
-       3,     3,     3,     3,     3,     3,     3,     3,     3,     5,
-       3,     4
-};
+#define yypact_value_is_default(Yystate) \
+  (!!((Yystate) == (-15)))
 
-/* YYDEFACT[STATE-NAME] -- Default reduction number in state STATE-NUM.
-   Performed when YYTABLE doesn't specify something else to do.  Zero
-   means the default is an error.  */
-static const yytype_uint8 yydefact[] =
-{
-       4,     0,     2,     1,    12,    13,     0,     0,     5,     0,
-       0,     3,     0,     0,     8,     0,    13,    14,    10,     0,
-       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
-       0,     0,     0,     0,     0,     0,     6,     0,     0,     9,
-      11,    30,    20,    19,    24,    25,    23,    22,    26,    15,
-      16,    17,    18,    28,    27,     0,    21,     7,    31,     0,
-      29
-};
+#define YYTABLE_NINF -1
 
-/* YYDEFGOTO[NTERM-NUM].  */
-static const yytype_int8 yydefgoto[] =
-{
-      -1,     1,     2,    11,    19,    12
-};
+#define yytable_value_is_error(Yytable_value) \
+  0
 
-/* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
-   STATE-NUM.  */
-#define YYPACT_NINF -15
+  /* YYPACT[STATE-NUM] -- Index in YYTABLE of the portion describing
+     STATE-NUM.  */
 static const yytype_int16 yypact[] =
 {
      -15,     2,    33,   -15,   -15,    11,   -14,    36,   -15,    33,
@@ -572,16 +511,35 @@ static const yytype_int16 yypact[] =
      -10
 };
 
-/* YYPGOTO[NTERM-NUM].  */
+  /* YYDEFACT[STATE-NUM] -- Default reduction number in state STATE-NUM.
+     Performed when YYTABLE does not specify something else to do.  Zero
+     means the default is an error.  */
+static const yytype_uint8 yydefact[] =
+{
+       4,     0,     2,     1,    12,    13,     0,     0,     5,     0,
+       0,     3,     0,     0,     8,     0,    13,    14,    10,     0,
+       0,     0,     0,     0,     0,     0,     0,     0,     0,     0,
+       0,     0,     0,     0,     0,     0,     6,     0,     0,     9,
+      11,    30,    26,    22,    23,    25,    24,    20,    19,    15,
+      16,    17,    18,    27,    28,     0,    21,     7,    31,     0,
+      29
+};
+
+  /* YYPGOTO[NTERM-NUM].  */
 static const yytype_int8 yypgoto[] =
 {
      -15,   -15,   -15,    -8,   -15,    -7
 };
 
-/* YYTABLE[YYPACT[STATE-NUM]].  What to do in state STATE-NUM.  If
-   positive, shift that token.  If negative, reduce the rule which
-   number is the opposite.  If YYTABLE_NINF, syntax error.  */
-#define YYTABLE_NINF -1
+  /* YYDEFGOTO[NTERM-NUM].  */
+static const yytype_int8 yydefgoto[] =
+{
+      -1,     1,     2,    11,    19,    12
+};
+
+  /* YYTABLE[YYPACT[STATE-NUM]] -- What to do in state STATE-NUM.  If
+     positive, shift that token.  If negative, reduce the rule whose
+     number is the opposite.  If YYTABLE_NINF, syntax error.  */
 static const yytype_uint8 yytable[] =
 {
       17,    18,     3,    20,    32,    33,    37,    34,    38,    35,
@@ -605,12 +563,6 @@ static const yytype_uint8 yytable[] =
       34,     0,    35
 };
 
-#define yypact_value_is_default(Yystate) \
-  (!!((Yystate) == (-15)))
-
-#define yytable_value_is_error(Yytable_value) \
-  YYID (0)
-
 static const yytype_int8 yycheck[] =
 {
        7,     9,     0,    10,    17,    18,    13,    20,    15,    22,
@@ -634,8 +586,8 @@ static const yytype_int8 yycheck[] =
       20,    -1,    22
 };
 
-/* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
-   symbol of state STATE-NUM.  */
+  /* YYSTOS[STATE-NUM] -- The (internal number of the) accessing
+     symbol of state STATE-NUM.  */
 static const yytype_uint8 yystos[] =
 {
        0,    30,    31,     0,     3,     4,     5,    14,    24,    25,
@@ -647,30 +599,34 @@ static const yytype_uint8 yystos[] =
       34
 };
 
-#define yyerrok		(yyerrstatus = 0)
-#define yyclearin	(yychar = YYEMPTY)
-#define YYEMPTY		(-2)
-#define YYEOF		0
-
-#define YYACCEPT	goto yyacceptlab
-#define YYABORT		goto yyabortlab
-#define YYERROR		goto yyerrorlab
-
-
-/* Like YYERROR except do call yyerror.  This remains here temporarily
-   to ease the transition to the new meaning of YYERROR, for GCC.
-   Once GCC version 2 has supplanted version 1, this can go.  However,
-   YYFAIL appears to be in use.  Nevertheless, it is formally deprecated
-   in Bison 2.4.2's NEWS entry, where a plan to phase it out is
-   discussed.  */
-
-#define YYFAIL		goto yyerrlab
-#if defined YYFAIL
-  /* This is here to suppress warnings from the GCC cpp's
-     -Wunused-macros.  Normally we don't worry about that warning, but
-     some users do, and we want to make it easy for users to remove
-     YYFAIL uses, which will produce warnings from Bison 2.5.  */
-#endif
+  /* YYR1[YYN] -- Symbol number of symbol that rule YYN derives.  */
+static const yytype_uint8 yyr1[] =
+{
+       0,    29,    30,    31,    31,    32,    32,    32,    32,    32,
+      33,    33,    34,    34,    34,    34,    34,    34,    34,    34,
+      34,    34,    34,    34,    34,    34,    34,    34,    34,    34,
+      34,    34
+};
+
+  /* YYR2[YYN] -- Number of symbols on the right hand side of rule YYN.  */
+static const yytype_uint8 yyr2[] =
+{
+       0,     2,     1,     2,     0,     1,     2,     4,     2,     3,
+       1,     2,     1,     1,     2,     3,     3,     3,     3,     3,
+       3,     3,     3,     3,     3,     3,     3,     3,     3,     5,
+       3,     4
+};
+
+
+#define yyerrok         (yyerrstatus = 0)
+#define yyclearin       (yychar = YYEMPTY)
+#define YYEMPTY         (-2)
+#define YYEOF           0
+
+#define YYACCEPT        goto yyacceptlab
+#define YYABORT         goto yyabortlab
+#define YYERROR         goto yyerrorlab
+
 
 #define YYRECOVERING()  (!!yyerrstatus)
 
@@ -687,27 +643,15 @@ do                                                              \
   else                                                          \
     {                                                           \
       yyerror (parse_arg, scanner, YY_("syntax error: cannot back up")); \
-      YYERROR;							\
-    }								\
-while (YYID (0))
+      YYERROR;                                                  \
+    }                                                           \
+while (0)
 
 /* Error token number */
-#define YYTERROR	1
-#define YYERRCODE	256
+#define YYTERROR        1
+#define YYERRCODE       256
 
 
-/* This macro is provided for backward compatibility. */
-#ifndef YY_LOCATION_PRINT
-# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
-#endif
-
-
-/* YYLEX -- calling `yylex' with the right arguments.  */
-#ifdef YYLEX_PARAM
-# define YYLEX yylex (&yylval, YYLEX_PARAM)
-#else
-# define YYLEX yylex (&yylval, parse_arg, scanner)
-#endif
 
 /* Enable debugging if requested.  */
 #if YYDEBUG
@@ -717,54 +661,46 @@ while (YYID (0))
 #  define YYFPRINTF fprintf
 # endif
 
-# define YYDPRINTF(Args)			\
-do {						\
-  if (yydebug)					\
-    YYFPRINTF Args;				\
-} while (YYID (0))
+# define YYDPRINTF(Args)                        \
+do {                                            \
+  if (yydebug)                                  \
+    YYFPRINTF Args;                             \
+} while (0)
+
+/* This macro is provided for backward compatibility. */
+#ifndef YY_LOCATION_PRINT
+# define YY_LOCATION_PRINT(File, Loc) ((void) 0)
+#endif
+
 
-# define YY_SYMBOL_PRINT(Title, Type, Value, Location)			  \
-do {									  \
-  if (yydebug)								  \
-    {									  \
-      YYFPRINTF (stderr, "%s ", Title);					  \
-      yy_symbol_print (stderr,						  \
-		  Type, Value, parse_arg, scanner); \
-      YYFPRINTF (stderr, "\n");						  \
-    }									  \
-} while (YYID (0))
+# define YY_SYMBOL_PRINT(Title, Type, Value, Location)                    \
+do {                                                                      \
+  if (yydebug)                                                            \
+    {                                                                     \
+      YYFPRINTF (stderr, "%s ", Title);                                   \
+      yy_symbol_print (stderr,                                            \
+                  Type, Value, parse_arg, scanner); \
+      YYFPRINTF (stderr, "\n");                                           \
+    }                                                                     \
+} while (0)
 
 
-/*--------------------------------.
-| Print this symbol on YYOUTPUT.  |
-`--------------------------------*/
+/*----------------------------------------.
+| Print this symbol's value on YYOUTPUT.  |
+`----------------------------------------*/
 
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
 static void
 yy_symbol_value_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parse_parm_t *parse_arg, void *scanner)
-#else
-static void
-yy_symbol_value_print (yyoutput, yytype, yyvaluep, parse_arg, scanner)
-    FILE *yyoutput;
-    int yytype;
-    YYSTYPE const * const yyvaluep;
-    parse_parm_t *parse_arg;
-    void *scanner;
-#endif
 {
   FILE *yyo = yyoutput;
   YYUSE (yyo);
-  if (!yyvaluep)
-    return;
   YYUSE (parse_arg);
   YYUSE (scanner);
+  if (!yyvaluep)
+    return;
 # ifdef YYPRINT
   if (yytype < YYNTOKENS)
     YYPRINT (yyoutput, yytoknum[yytype], *yyvaluep);
-# else
-  YYUSE (yyoutput);
 # endif
   YYUSE (yytype);
 }
@@ -774,24 +710,11 @@ yy_symbol_value_print (yyoutput, yytype, yyvaluep, parse_arg, scanner)
 | Print this symbol on YYOUTPUT.  |
 `--------------------------------*/
 
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
 static void
 yy_symbol_print (FILE *yyoutput, int yytype, YYSTYPE const * const yyvaluep, parse_parm_t *parse_arg, void *scanner)
-#else
-static void
-yy_symbol_print (yyoutput, yytype, yyvaluep, parse_arg, scanner)
-    FILE *yyoutput;
-    int yytype;
-    YYSTYPE const * const yyvaluep;
-    parse_parm_t *parse_arg;
-    void *scanner;
-#endif
 {
-  if (yytype < YYNTOKENS)
-    YYFPRINTF (yyoutput, "token %s (", yytname[yytype]);
-  else
-    YYFPRINTF (yyoutput, "nterm %s (", yytname[yytype]);
+  YYFPRINTF (yyoutput, "%s %s (",
+             yytype < YYNTOKENS ? "token" : "nterm", yytname[yytype]);
 
   yy_symbol_value_print (yyoutput, yytype, yyvaluep, parse_arg, scanner);
   YYFPRINTF (yyoutput, ")");
@@ -802,16 +725,8 @@ yy_symbol_print (yyoutput, yytype, yyvaluep, parse_arg, scanner)
 | TOP (included).                                                   |
 `------------------------------------------------------------------*/
 
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
 static void
 yy_stack_print (yytype_int16 *yybottom, yytype_int16 *yytop)
-#else
-static void
-yy_stack_print (yybottom, yytop)
-    yytype_int16 *yybottom;
-    yytype_int16 *yytop;
-#endif
 {
   YYFPRINTF (stderr, "Stack now");
   for (; yybottom <= yytop; yybottom++)
@@ -822,51 +737,42 @@ yy_stack_print (yybottom, yytop)
   YYFPRINTF (stderr, "\n");
 }
 
-# define YY_STACK_PRINT(Bottom, Top)				\
-do {								\
-  if (yydebug)							\
-    yy_stack_print ((Bottom), (Top));				\
-} while (YYID (0))
+# define YY_STACK_PRINT(Bottom, Top)                            \
+do {                                                            \
+  if (yydebug)                                                  \
+    yy_stack_print ((Bottom), (Top));                           \
+} while (0)
 
 
 /*------------------------------------------------.
 | Report that the YYRULE is going to be reduced.  |
 `------------------------------------------------*/
 
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-static void
-yy_reduce_print (YYSTYPE *yyvsp, int yyrule, parse_parm_t *parse_arg, void *scanner)
-#else
 static void
-yy_reduce_print (yyvsp, yyrule, parse_arg, scanner)
-    YYSTYPE *yyvsp;
-    int yyrule;
-    parse_parm_t *parse_arg;
-    void *scanner;
-#endif
+yy_reduce_print (yytype_int16 *yyssp, YYSTYPE *yyvsp, int yyrule, parse_parm_t *parse_arg, void *scanner)
 {
+  unsigned long int yylno = yyrline[yyrule];
   int yynrhs = yyr2[yyrule];
   int yyi;
-  unsigned long int yylno = yyrline[yyrule];
   YYFPRINTF (stderr, "Reducing stack by rule %d (line %lu):\n",
-	     yyrule - 1, yylno);
+             yyrule - 1, yylno);
   /* The symbols being reduced.  */
   for (yyi = 0; yyi < yynrhs; yyi++)
     {
       YYFPRINTF (stderr, "   $%d = ", yyi + 1);
-      yy_symbol_print (stderr, yyrhs[yyprhs[yyrule] + yyi],
-		       &(yyvsp[(yyi + 1) - (yynrhs)])
-		       		       , parse_arg, scanner);
+      yy_symbol_print (stderr,
+                       yystos[yyssp[yyi + 1 - yynrhs]],
+                       &(yyvsp[(yyi + 1) - (yynrhs)])
+                                              , parse_arg, scanner);
       YYFPRINTF (stderr, "\n");
     }
 }
 
-# define YY_REDUCE_PRINT(Rule)		\
-do {					\
-  if (yydebug)				\
-    yy_reduce_print (yyvsp, Rule, parse_arg, scanner); \
-} while (YYID (0))
+# define YY_REDUCE_PRINT(Rule)          \
+do {                                    \
+  if (yydebug)                          \
+    yy_reduce_print (yyssp, yyvsp, Rule, parse_arg, scanner); \
+} while (0)
 
 /* Nonzero means print parse trace.  It is left uninitialized so that
    multiple parsers can coexist.  */
@@ -880,7 +786,7 @@ int yydebug;
 
 
 /* YYINITDEPTH -- initial size of the parser's stacks.  */
-#ifndef	YYINITDEPTH
+#ifndef YYINITDEPTH
 # define YYINITDEPTH 200
 #endif
 
@@ -903,15 +809,8 @@ int yydebug;
 #   define yystrlen strlen
 #  else
 /* Return the length of YYSTR.  */
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
 static YYSIZE_T
 yystrlen (const char *yystr)
-#else
-static YYSIZE_T
-yystrlen (yystr)
-    const char *yystr;
-#endif
 {
   YYSIZE_T yylen;
   for (yylen = 0; yystr[yylen]; yylen++)
@@ -927,16 +826,8 @@ yystrlen (yystr)
 #  else
 /* Copy YYSRC to YYDEST, returning the address of the terminating '\0' in
    YYDEST.  */
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
 static char *
 yystpcpy (char *yydest, const char *yysrc)
-#else
-static char *
-yystpcpy (yydest, yysrc)
-    char *yydest;
-    const char *yysrc;
-#endif
 {
   char *yyd = yydest;
   const char *yys = yysrc;
@@ -966,27 +857,27 @@ yytnamerr (char *yyres, const char *yystr)
       char const *yyp = yystr;
 
       for (;;)
-	switch (*++yyp)
-	  {
-	  case '\'':
-	  case ',':
-	    goto do_not_strip_quotes;
-
-	  case '\\':
-	    if (*++yyp != '\\')
-	      goto do_not_strip_quotes;
-	    /* Fall through.  */
-	  default:
-	    if (yyres)
-	      yyres[yyn] = *yyp;
-	    yyn++;
-	    break;
-
-	  case '"':
-	    if (yyres)
-	      yyres[yyn] = '\0';
-	    return yyn;
-	  }
+        switch (*++yyp)
+          {
+          case '\'':
+          case ',':
+            goto do_not_strip_quotes;
+
+          case '\\':
+            if (*++yyp != '\\')
+              goto do_not_strip_quotes;
+            /* Fall through.  */
+          default:
+            if (yyres)
+              yyres[yyn] = *yyp;
+            yyn++;
+            break;
+
+          case '"':
+            if (yyres)
+              yyres[yyn] = '\0';
+            return yyn;
+          }
     do_not_strip_quotes: ;
     }
 
@@ -1009,11 +900,11 @@ static int
 yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
                 yytype_int16 *yyssp, int yytoken)
 {
-  YYSIZE_T yysize0 = yytnamerr (YY_NULL, yytname[yytoken]);
+  YYSIZE_T yysize0 = yytnamerr (YY_NULLPTR, yytname[yytoken]);
   YYSIZE_T yysize = yysize0;
   enum { YYERROR_VERBOSE_ARGS_MAXIMUM = 5 };
   /* Internationalized format string. */
-  const char *yyformat = YY_NULL;
+  const char *yyformat = YY_NULLPTR;
   /* Arguments of yyformat. */
   char const *yyarg[YYERROR_VERBOSE_ARGS_MAXIMUM];
   /* Number of reported tokens (one for the "unexpected", one per
@@ -1021,10 +912,6 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
   int yycount = 0;
 
   /* There are many possibilities here to consider:
-     - Assume YYFAIL is not used.  It's too flawed to consider.  See
-       <http://lists.gnu.org/archive/html/bison-patches/2009-12/msg00024.html>
-       for details.  YYERROR is fine as it does not invoke this
-       function.
      - If this state is a consistent state with a default action, then
        the only way this function was invoked is if the default action
        is an error action.  In that case, don't check for expected
@@ -1074,7 +961,7 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
                   }
                 yyarg[yycount++] = yytname[yyx];
                 {
-                  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULL, yytname[yyx]);
+                  YYSIZE_T yysize1 = yysize + yytnamerr (YY_NULLPTR, yytname[yyx]);
                   if (! (yysize <= yysize1
                          && yysize1 <= YYSTACK_ALLOC_MAXIMUM))
                     return 2;
@@ -1141,30 +1028,19 @@ yysyntax_error (YYSIZE_T *yymsg_alloc, char **yymsg,
 | Release the memory associated to this symbol.  |
 `-----------------------------------------------*/
 
-/*ARGSUSED*/
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
 static void
 yydestruct (const char *yymsg, int yytype, YYSTYPE *yyvaluep, parse_parm_t *parse_arg, void *scanner)
-#else
-static void
-yydestruct (yymsg, yytype, yyvaluep, parse_arg, scanner)
-    const char *yymsg;
-    int yytype;
-    YYSTYPE *yyvaluep;
-    parse_parm_t *parse_arg;
-    void *scanner;
-#endif
 {
   YYUSE (yyvaluep);
   YYUSE (parse_arg);
   YYUSE (scanner);
-
   if (!yymsg)
     yymsg = "Deleting";
   YY_SYMBOL_PRINT (yymsg, yytype, yyvaluep, yylocationp);
 
+  YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
   YYUSE (yytype);
+  YY_IGNORE_MAYBE_UNINITIALIZED_END
 }
 
 
@@ -1174,57 +1050,18 @@ yydestruct (yymsg, yytype, yyvaluep, parse_arg, scanner)
 | yyparse.  |
 `----------*/
 
-#ifdef YYPARSE_PARAM
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
-int
-yyparse (void *YYPARSE_PARAM)
-#else
-int
-yyparse (YYPARSE_PARAM)
-    void *YYPARSE_PARAM;
-#endif
-#else /* ! YYPARSE_PARAM */
-#if (defined __STDC__ || defined __C99__FUNC__ \
-     || defined __cplusplus || defined _MSC_VER)
 int
 yyparse (parse_parm_t *parse_arg, void *scanner)
-#else
-int
-yyparse (parse_arg, scanner)
-    parse_parm_t *parse_arg;
-    void *scanner;
-#endif
-#endif
 {
 /* The lookahead symbol.  */
 int yychar;
 
 
-#if defined __GNUC__ && 407 <= __GNUC__ * 100 + __GNUC_MINOR__
-/* Suppress an incorrect diagnostic about yylval being uninitialized.  */
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN \
-    _Pragma ("GCC diagnostic push") \
-    _Pragma ("GCC diagnostic ignored \"-Wuninitialized\"")\
-    _Pragma ("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END \
-    _Pragma ("GCC diagnostic pop")
-#else
+/* The semantic value of the lookahead symbol.  */
 /* Default value used for initialization, for pacifying older GCCs
    or non-GCC compilers.  */
-static YYSTYPE yyval_default;
-# define YY_INITIAL_VALUE(Value) = Value
-#endif
-#ifndef YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
-# define YY_IGNORE_MAYBE_UNINITIALIZED_BEGIN
-# define YY_IGNORE_MAYBE_UNINITIALIZED_END
-#endif
-#ifndef YY_INITIAL_VALUE
-# define YY_INITIAL_VALUE(Value) /* Nothing. */
-#endif
-
-/* The semantic value of the lookahead symbol.  */
-YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
+YY_INITIAL_VALUE (static YYSTYPE yyval_default;)
+YYSTYPE yylval YY_INITIAL_VALUE (= yyval_default);
 
     /* Number of syntax errors so far.  */
     int yynerrs;
@@ -1234,8 +1071,8 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
     int yyerrstatus;
 
     /* The stacks and their tools:
-       `yyss': related to states.
-       `yyvs': related to semantic values.
+       'yyss': related to states.
+       'yyvs': related to semantic values.
 
        Refer to the stacks through separate pointers, to allow yyoverflow
        to reallocate them elsewhere.  */
@@ -1303,23 +1140,23 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
 
 #ifdef yyoverflow
       {
-	/* Give user a chance to reallocate the stack.  Use copies of
-	   these so that the &'s don't force the real ones into
-	   memory.  */
-	YYSTYPE *yyvs1 = yyvs;
-	yytype_int16 *yyss1 = yyss;
-
-	/* Each stack pointer address is followed by the size of the
-	   data in use in that stack, in bytes.  This used to be a
-	   conditional around just the two extra args, but that might
-	   be undefined if yyoverflow is a macro.  */
-	yyoverflow (YY_("memory exhausted"),
-		    &yyss1, yysize * sizeof (*yyssp),
-		    &yyvs1, yysize * sizeof (*yyvsp),
-		    &yystacksize);
-
-	yyss = yyss1;
-	yyvs = yyvs1;
+        /* Give user a chance to reallocate the stack.  Use copies of
+           these so that the &'s don't force the real ones into
+           memory.  */
+        YYSTYPE *yyvs1 = yyvs;
+        yytype_int16 *yyss1 = yyss;
+
+        /* Each stack pointer address is followed by the size of the
+           data in use in that stack, in bytes.  This used to be a
+           conditional around just the two extra args, but that might
+           be undefined if yyoverflow is a macro.  */
+        yyoverflow (YY_("memory exhausted"),
+                    &yyss1, yysize * sizeof (*yyssp),
+                    &yyvs1, yysize * sizeof (*yyvsp),
+                    &yystacksize);
+
+        yyss = yyss1;
+        yyvs = yyvs1;
       }
 #else /* no yyoverflow */
 # ifndef YYSTACK_RELOCATE
@@ -1327,22 +1164,22 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
 # else
       /* Extend the stack our own way.  */
       if (YYMAXDEPTH <= yystacksize)
-	goto yyexhaustedlab;
+        goto yyexhaustedlab;
       yystacksize *= 2;
       if (YYMAXDEPTH < yystacksize)
-	yystacksize = YYMAXDEPTH;
+        yystacksize = YYMAXDEPTH;
 
       {
-	yytype_int16 *yyss1 = yyss;
-	union yyalloc *yyptr =
-	  (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
-	if (! yyptr)
-	  goto yyexhaustedlab;
-	YYSTACK_RELOCATE (yyss_alloc, yyss);
-	YYSTACK_RELOCATE (yyvs_alloc, yyvs);
+        yytype_int16 *yyss1 = yyss;
+        union yyalloc *yyptr =
+          (union yyalloc *) YYSTACK_ALLOC (YYSTACK_BYTES (yystacksize));
+        if (! yyptr)
+          goto yyexhaustedlab;
+        YYSTACK_RELOCATE (yyss_alloc, yyss);
+        YYSTACK_RELOCATE (yyvs_alloc, yyvs);
 #  undef YYSTACK_RELOCATE
-	if (yyss1 != yyssa)
-	  YYSTACK_FREE (yyss1);
+        if (yyss1 != yyssa)
+          YYSTACK_FREE (yyss1);
       }
 # endif
 #endif /* no yyoverflow */
@@ -1351,10 +1188,10 @@ YYSTYPE yylval YY_INITIAL_VALUE(yyval_default);
       yyvsp = yyvs + yysize - 1;
 
       YYDPRINTF ((stderr, "Stack size increased to %lu\n",
-		  (unsigned long int) yystacksize));
+                  (unsigned long int) yystacksize));
 
       if (yyss + yystacksize - 1 <= yyssp)
-	YYABORT;
+        YYABORT;
     }
 
   YYDPRINTF ((stderr, "Entering state %d\n", yystate));
@@ -1383,7 +1220,7 @@ yybackup:
   if (yychar == YYEMPTY)
     {
       YYDPRINTF ((stderr, "Reading a token: "));
-      yychar = YYLEX;
+      yychar = yylex (&yylval, parse_arg, scanner);
     }
 
   if (yychar <= YYEOF)
@@ -1448,7 +1285,7 @@ yyreduce:
   yylen = yyr2[yyn];
 
   /* If YYLEN is nonzero, implement the default value of the action:
-     `$$ = $1'.
+     '$$ = $1'.
 
      Otherwise, the following line sets YYVAL to garbage.
      This behavior is undocumented and Bison
@@ -1462,182 +1299,181 @@ yyreduce:
   switch (yyn)
     {
         case 2:
-/* Line 1787 of yacc.c  */
-#line 53 "expr_yacc.y"
+#line 53 "expr_yacc.y" /* yacc.c:1646  */
     { return(0); }
+#line 1305 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 3:
-/* Line 1787 of yacc.c  */
-#line 57 "expr_yacc.y"
-    { expr_run((yyvsp[(2) - (2)].nPtr), (parse_parm_t *) parse_arg); freeNode((yyvsp[(2) - (2)].nPtr)); }
+#line 57 "expr_yacc.y" /* yacc.c:1646  */
+    { expr_run((yyvsp[0].nPtr), (parse_parm_t *) parse_arg); freeNode((yyvsp[0].nPtr)); }
+#line 1311 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 5:
-/* Line 1787 of yacc.c  */
-#line 62 "expr_yacc.y"
+#line 62 "expr_yacc.y" /* yacc.c:1646  */
     { (yyval.nPtr) = expr_opr(';', 2, NULL, NULL); }
+#line 1317 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 6:
-/* Line 1787 of yacc.c  */
-#line 63 "expr_yacc.y"
-    { (yyval.nPtr) = (yyvsp[(1) - (2)].nPtr); }
+#line 63 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = (yyvsp[-1].nPtr); }
+#line 1323 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 7:
-/* Line 1787 of yacc.c  */
-#line 64 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr('=', 2, expr_var((yyvsp[(1) - (4)].varnm)), (yyvsp[(3) - (4)].nPtr)); }
+#line 64 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr('=', 2, expr_var((yyvsp[-3].varnm)), (yyvsp[-1].nPtr)); }
+#line 1329 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 8:
-/* Line 1787 of yacc.c  */
-#line 65 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr('=', 2, expr_var((yyvsp[(1) - (2)].varnm)), expr_var((yyvsp[(1) - (2)].varnm))); }
+#line 65 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr('=', 2, expr_var((yyvsp[-1].varnm)), expr_var((yyvsp[-1].varnm))); }
+#line 1335 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 9:
-/* Line 1787 of yacc.c  */
-#line 66 "expr_yacc.y"
-    { (yyval.nPtr) = (yyvsp[(2) - (3)].nPtr); }
+#line 66 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = (yyvsp[-1].nPtr); }
+#line 1341 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 10:
-/* Line 1787 of yacc.c  */
-#line 70 "expr_yacc.y"
-    { (yyval.nPtr) = (yyvsp[(1) - (1)].nPtr); }
+#line 70 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = (yyvsp[0].nPtr); }
+#line 1347 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 11:
-/* Line 1787 of yacc.c  */
-#line 71 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr(';', 2, (yyvsp[(1) - (2)].nPtr), (yyvsp[(2) - (2)].nPtr)); }
+#line 71 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr(';', 2, (yyvsp[-1].nPtr), (yyvsp[0].nPtr)); }
+#line 1353 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 12:
-/* Line 1787 of yacc.c  */
-#line 75 "expr_yacc.y"
-    { (yyval.nPtr) = expr_con((yyvsp[(1) - (1)].cvalue)); }
+#line 75 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_con((yyvsp[0].cvalue)); }
+#line 1359 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 13:
-/* Line 1787 of yacc.c  */
-#line 76 "expr_yacc.y"
-    { (yyval.nPtr) = expr_var((yyvsp[(1) - (1)].varnm)); }
+#line 76 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_var((yyvsp[0].varnm)); }
+#line 1365 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 14:
-/* Line 1787 of yacc.c  */
-#line 77 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr(UMINUS, 1, (yyvsp[(2) - (2)].nPtr)); }
+#line 77 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr(UMINUS, 1, (yyvsp[0].nPtr)); }
+#line 1371 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 15:
-/* Line 1787 of yacc.c  */
-#line 78 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr('+', 2, (yyvsp[(1) - (3)].nPtr), (yyvsp[(3) - (3)].nPtr)); }
+#line 78 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr('+', 2, (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1377 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 16:
-/* Line 1787 of yacc.c  */
-#line 79 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr('-', 2, (yyvsp[(1) - (3)].nPtr), (yyvsp[(3) - (3)].nPtr)); }
+#line 79 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr('-', 2, (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1383 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 17:
-/* Line 1787 of yacc.c  */
-#line 80 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr('*', 2, (yyvsp[(1) - (3)].nPtr), (yyvsp[(3) - (3)].nPtr)); }
+#line 80 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr('*', 2, (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1389 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 18:
-/* Line 1787 of yacc.c  */
-#line 81 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr('/', 2, (yyvsp[(1) - (3)].nPtr), (yyvsp[(3) - (3)].nPtr)); }
+#line 81 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr('/', 2, (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1395 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 19:
-/* Line 1787 of yacc.c  */
-#line 82 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr('<', 2, (yyvsp[(1) - (3)].nPtr), (yyvsp[(3) - (3)].nPtr)); }
+#line 82 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr('<', 2, (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1401 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 20:
-/* Line 1787 of yacc.c  */
-#line 83 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr('>', 2, (yyvsp[(1) - (3)].nPtr), (yyvsp[(3) - (3)].nPtr)); }
+#line 83 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr('>', 2, (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1407 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 21:
-/* Line 1787 of yacc.c  */
-#line 84 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr('^', 2, (yyvsp[(1) - (3)].nPtr), (yyvsp[(3) - (3)].nPtr)); }
+#line 84 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr('^', 2, (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1413 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 22:
-/* Line 1787 of yacc.c  */
-#line 85 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr(GE,  2, (yyvsp[(1) - (3)].nPtr), (yyvsp[(3) - (3)].nPtr)); }
+#line 85 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr(GE,  2, (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1419 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 23:
-/* Line 1787 of yacc.c  */
-#line 86 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr(LE,  2, (yyvsp[(1) - (3)].nPtr), (yyvsp[(3) - (3)].nPtr)); }
+#line 86 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr(LE,  2, (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1425 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 24:
-/* Line 1787 of yacc.c  */
-#line 87 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr(NE,  2, (yyvsp[(1) - (3)].nPtr), (yyvsp[(3) - (3)].nPtr)); }
+#line 87 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr(NE,  2, (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1431 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 25:
-/* Line 1787 of yacc.c  */
-#line 88 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr(EQ,  2, (yyvsp[(1) - (3)].nPtr), (yyvsp[(3) - (3)].nPtr)); }
+#line 88 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr(EQ,  2, (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1437 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 26:
-/* Line 1787 of yacc.c  */
-#line 89 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr(LEG, 2, (yyvsp[(1) - (3)].nPtr), (yyvsp[(3) - (3)].nPtr)); }
+#line 89 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr(LEG, 2, (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1443 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 27:
-/* Line 1787 of yacc.c  */
-#line 90 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr(AND, 2, (yyvsp[(1) - (3)].nPtr), (yyvsp[(3) - (3)].nPtr)); }
+#line 90 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr(AND, 2, (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1449 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 28:
-/* Line 1787 of yacc.c  */
-#line 91 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr(OR,  2, (yyvsp[(1) - (3)].nPtr), (yyvsp[(3) - (3)].nPtr)); }
+#line 91 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr(OR,  2, (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1455 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 29:
-/* Line 1787 of yacc.c  */
-#line 92 "expr_yacc.y"
-    { (yyval.nPtr) = expr_opr('?', 3, (yyvsp[(1) - (5)].nPtr), (yyvsp[(3) - (5)].nPtr), (yyvsp[(5) - (5)].nPtr)); }
+#line 92 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_opr('?', 3, (yyvsp[-4].nPtr), (yyvsp[-2].nPtr), (yyvsp[0].nPtr)); }
+#line 1461 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 30:
-/* Line 1787 of yacc.c  */
-#line 93 "expr_yacc.y"
-    { (yyval.nPtr) = (yyvsp[(2) - (3)].nPtr); }
+#line 93 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = (yyvsp[-1].nPtr); }
+#line 1467 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
   case 31:
-/* Line 1787 of yacc.c  */
-#line 94 "expr_yacc.y"
-    { (yyval.nPtr) = expr_fun((yyvsp[(1) - (4)].fname), (yyvsp[(3) - (4)].nPtr)); }
+#line 94 "expr_yacc.y" /* yacc.c:1646  */
+    { (yyval.nPtr) = expr_fun((yyvsp[-3].fname), (yyvsp[-1].nPtr)); }
+#line 1473 "expr_yacc.c" /* yacc.c:1646  */
     break;
 
 
-/* Line 1787 of yacc.c  */
-#line 1641 "expr_yacc.c"
+#line 1477 "expr_yacc.c" /* yacc.c:1646  */
       default: break;
     }
   /* User semantic actions sometimes alter yychar, and that requires
@@ -1659,7 +1495,7 @@ yyreduce:
 
   *++yyvsp = yyval;
 
-  /* Now `shift' the result of the reduction.  Determine what state
+  /* Now 'shift' the result of the reduction.  Determine what state
      that goes to, based on the state we popped back to and the rule
      number reduced by.  */
 
@@ -1674,9 +1510,9 @@ yyreduce:
   goto yynewstate;
 
 
-/*------------------------------------.
-| yyerrlab -- here on detecting error |
-`------------------------------------*/
+/*--------------------------------------.
+| yyerrlab -- here on detecting error.  |
+`--------------------------------------*/
 yyerrlab:
   /* Make sure we have latest lookahead translation.  See comments at
      user semantic actions for why this is necessary.  */
@@ -1727,20 +1563,20 @@ yyerrlab:
   if (yyerrstatus == 3)
     {
       /* If just tried and failed to reuse lookahead token after an
-	 error, discard it.  */
+         error, discard it.  */
 
       if (yychar <= YYEOF)
-	{
-	  /* Return failure if at end of input.  */
-	  if (yychar == YYEOF)
-	    YYABORT;
-	}
+        {
+          /* Return failure if at end of input.  */
+          if (yychar == YYEOF)
+            YYABORT;
+        }
       else
-	{
-	  yydestruct ("Error: discarding",
-		      yytoken, &yylval, parse_arg, scanner);
-	  yychar = YYEMPTY;
-	}
+        {
+          yydestruct ("Error: discarding",
+                      yytoken, &yylval, parse_arg, scanner);
+          yychar = YYEMPTY;
+        }
     }
 
   /* Else will try to reuse lookahead token after shifting the error
@@ -1759,7 +1595,7 @@ yyerrorlab:
   if (/*CONSTCOND*/ 0)
      goto yyerrorlab;
 
-  /* Do not reclaim the symbols of the rule which action triggered
+  /* Do not reclaim the symbols of the rule whose action triggered
      this YYERROR.  */
   YYPOPSTACK (yylen);
   yylen = 0;
@@ -1772,29 +1608,29 @@ yyerrorlab:
 | yyerrlab1 -- common code for both syntax error and YYERROR.  |
 `-------------------------------------------------------------*/
 yyerrlab1:
-  yyerrstatus = 3;	/* Each real token shifted decrements this.  */
+  yyerrstatus = 3;      /* Each real token shifted decrements this.  */
 
   for (;;)
     {
       yyn = yypact[yystate];
       if (!yypact_value_is_default (yyn))
-	{
-	  yyn += YYTERROR;
-	  if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
-	    {
-	      yyn = yytable[yyn];
-	      if (0 < yyn)
-		break;
-	    }
-	}
+        {
+          yyn += YYTERROR;
+          if (0 <= yyn && yyn <= YYLAST && yycheck[yyn] == YYTERROR)
+            {
+              yyn = yytable[yyn];
+              if (0 < yyn)
+                break;
+            }
+        }
 
       /* Pop the current state because it cannot handle the error token.  */
       if (yyssp == yyss)
-	YYABORT;
+        YYABORT;
 
 
       yydestruct ("Error: popping",
-		  yystos[yystate], yyvsp, parse_arg, scanner);
+                  yystos[yystate], yyvsp, parse_arg, scanner);
       YYPOPSTACK (1);
       yystate = *yyssp;
       YY_STACK_PRINT (yyss, yyssp);
@@ -1845,14 +1681,14 @@ yyreturn:
       yydestruct ("Cleanup: discarding lookahead",
                   yytoken, &yylval, parse_arg, scanner);
     }
-  /* Do not reclaim the symbols of the rule which action triggered
+  /* Do not reclaim the symbols of the rule whose action triggered
      this YYABORT or YYACCEPT.  */
   YYPOPSTACK (yylen);
   YY_STACK_PRINT (yyss, yyssp);
   while (yyssp != yyss)
     {
       yydestruct ("Cleanup: popping",
-		  yystos[*yyssp], yyvsp, parse_arg, scanner);
+                  yystos[*yyssp], yyvsp, parse_arg, scanner);
       YYPOPSTACK (1);
     }
 #ifndef yyoverflow
@@ -1863,13 +1699,9 @@ yyreturn:
   if (yymsg != yymsgbuf)
     YYSTACK_FREE (yymsg);
 #endif
-  /* Make sure YYID is used.  */
-  return YYID (yyresult);
+  return yyresult;
 }
-
-
-/* Line 2050 of yacc.c  */
-#line 97 "expr_yacc.y"
+#line 97 "expr_yacc.y" /* yacc.c:1906  */
 
 
 #define SIZEOF_NODETYPE ((char *)&p->u.con - (char *)p)
@@ -1965,7 +1797,7 @@ void freeNode(nodeType *p)
   free (p);
 }
 
-void yyerror(void *parse_arg, void *scanner, char *errstr)
+void yyerror(void *parse_arg, void *scanner, const char *errstr)
 {
   fprintf(stdout, "%s!\n", errstr);
 }
diff --git a/src/expr_yacc.h b/src/expr_yacc.h
index bcb0677..5705f8a 100644
--- a/src/expr_yacc.h
+++ b/src/expr_yacc.h
@@ -1,19 +1,19 @@
-/* A Bison parser, made by GNU Bison 2.7.12-4996.  */
+/* A Bison parser, made by GNU Bison 3.0.4.  */
 
 /* Bison interface for Yacc-like parsers in C
-   
-      Copyright (C) 1984, 1989-1990, 2000-2013 Free Software Foundation, Inc.
-   
+
+   Copyright (C) 1984, 1989-1990, 2000-2015 Free Software Foundation, Inc.
+
    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation, either version 3 of the License, or
    (at your option) any later version.
-   
+
    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.
-   
+
    You should have received a copy of the GNU General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
@@ -26,13 +26,13 @@
    special exception, which will cause the skeleton and the resulting
    Bison output files to be licensed under the GNU General Public
    License without this special exception.
-   
+
    This special exception was added by the Free Software Foundation in
    version 2.2 of Bison.  */
 
 #ifndef YY_YY_EXPR_YACC_H_INCLUDED
 # define YY_YY_EXPR_YACC_H_INCLUDED
-/* Enabling traces.  */
+/* Debug traces.  */
 #ifndef YYDEBUG
 # define YYDEBUG 0
 #endif
@@ -40,59 +40,41 @@
 extern int yydebug;
 #endif
 
-/* Tokens.  */
+/* Token type.  */
 #ifndef YYTOKENTYPE
 # define YYTOKENTYPE
-   /* Put the tokens into the symbol table, so that GDB and other debuggers
-      know about them.  */
-   enum yytokentype {
-     CONSTANT = 258,
-     VARIABLE = 259,
-     FUNCTION = 260,
-     NE = 261,
-     EQ = 262,
-     LE = 263,
-     GE = 264,
-     LEG = 265,
-     OR = 266,
-     AND = 267,
-     UMINUS = 268
-   };
+  enum yytokentype
+  {
+    CONSTANT = 258,
+    VARIABLE = 259,
+    FUNCTION = 260,
+    LEG = 261,
+    GE = 262,
+    LE = 263,
+    EQ = 264,
+    NE = 265,
+    AND = 266,
+    OR = 267,
+    UMINUS = 268
+  };
 #endif
 /* Tokens.  */
 #define CONSTANT 258
 #define VARIABLE 259
 #define FUNCTION 260
-#define NE 261
-#define EQ 262
+#define LEG 261
+#define GE 262
 #define LE 263
-#define GE 264
-#define LEG 265
-#define OR 266
-#define AND 267
+#define EQ 264
+#define NE 265
+#define AND 266
+#define OR 267
 #define UMINUS 268
 
+/* Value type.  */
 
 
-#if ! defined YYSTYPE && ! defined YYSTYPE_IS_DECLARED
 
-# define yystype YYSTYPE /* obsolescent; will be withdrawn */
-# define YYSTYPE_IS_DECLARED 1
-#endif
-
-
-#ifdef YYPARSE_PARAM
-#if defined __STDC__ || defined __cplusplus
-int yyparse (void *YYPARSE_PARAM);
-#else
-int yyparse ();
-#endif
-#else /* ! YYPARSE_PARAM */
-#if defined __STDC__ || defined __cplusplus
 int yyparse (parse_parm_t *parse_arg, void *scanner);
-#else
-int yyparse ();
-#endif
-#endif /* ! YYPARSE_PARAM */
 
 #endif /* !YY_YY_EXPR_YACC_H_INCLUDED  */
diff --git a/src/features.c b/src/features.c
index 0e4dff9..4b91b56 100644
--- a/src/features.c
+++ b/src/features.c
@@ -2,6 +2,10 @@
 #  include "config.h"
 #endif
 
+#if defined(HAVE_HDF5_H)
+#include <hdf5.h>
+#endif
+
 #if defined(HAVE_ZLIB_H)
 #include <zlib.h>
 #endif
@@ -26,6 +30,12 @@
 void printFeatures(void)
 {
   fprintf(stderr, "Features:");
+#if defined(ENABLE_DATA)
+  fprintf(stderr, " DATA");
+#endif
+#if defined(ENABLE_NEARPT3)
+  fprintf(stderr, " nearpt3");
+#endif
 #if defined(HAVE_LIBPTHREAD)
   fprintf(stderr, " PTHREADS");
 #endif
@@ -35,6 +45,9 @@ void printFeatures(void)
   fprintf(stderr, "4");
 #endif
 #endif
+#if  defined(HAVE_LIBHDF5)
+  fprintf(stderr, " HDF5");
+#endif
 #if  defined(HAVE_NETCDF4)
   fprintf(stderr, " NC4");
 #if  defined(HAVE_NC4HDF5)
@@ -97,6 +110,18 @@ void printFeatures(void)
 void printLibraries(void)
 {
   fprintf(stderr, "Libraries:");
+#if  defined(HAVE_LIBHDF5)
+  fprintf(stderr, " HDF5");
+#if  defined(H5_VERS_MAJOR)
+  unsigned h5h_majnum = H5_VERS_MAJOR, h5h_minnum = H5_VERS_MINOR, h5h_relnum = H5_VERS_RELEASE;
+  fprintf(stderr, "/%u.%u.%u", h5h_majnum, h5h_minnum, h5h_relnum);
+
+  unsigned h5l_majnum, h5l_minnum, h5l_relnum;
+  H5get_libversion(&h5l_majnum, &h5l_minnum, &h5l_relnum);
+  if ( (h5h_majnum != h5l_majnum) || (h5h_minnum != h5l_minnum) || (h5h_relnum != h5l_relnum) )
+    fprintf(stderr, "(%u.%u.%u)", h5l_majnum, h5l_minnum, h5l_relnum);
+#endif
+#endif
   /*
 #if defined(HAVE_LIBZ)
   {
diff --git a/src/field.c b/src/field.c
index a746f7b..9a81cae 100644
--- a/src/field.c
+++ b/src/field.c
@@ -18,10 +18,8 @@
 #include "cdo.h"
 #include "cdo_int.h"
 #include <cdi.h>
-/* RQ */
-#include "nth_element.h"
+#include "percentiles.h"
 #include "merge_sort2.h"
-/* QR */
 
 double crps_det_integrate(double *a, const double d, const size_t n);
 
@@ -175,7 +173,7 @@ double fldmin(field_t field)
   const size_t len     = field.size;
   const int    nmiss   = field.nmiss;
   const double missval = field.missval;
-  double *array  = field.ptr;
+  const double *restrict array  = field.ptr;
   double rmin = 0;
 
   if ( nmiss > 0 )
@@ -191,6 +189,7 @@ double fldmin(field_t field)
   else
     {
       rmin = array[0];
+      //#pragma simd reduction(min:rmin) 
       for ( i = 1; i < len; i++ ) 
 	if ( array[i] < rmin )  rmin = array[i];
     }
@@ -330,8 +329,8 @@ double fldavg(field_t field)
 }
 
 static
-void prevarsum(const double *restrict array, const double *restrict w, size_t len, const int nmiss, 
-	       double missval, double *rsum, double *rsumw, double *rsumq, double *rsumwq)
+void prevarsum(const double *restrict array, const double *restrict w, size_t len, int nmiss, 
+	       double missval, double *restrict rsum, double *restrict rsumw, double *restrict rsumq, double *restrict rsumwq)
 { 
   size_t i;
   *rsum = *rsumw = 0;
@@ -368,12 +367,12 @@ double fldvar(field_t field)
   const double missval = field.missval;
   double *array  = field.ptr;
   double *w      = field.weight;
-  double rsum, rsumw, rvar;
+  double rsum, rsumw;
   double rsumq, rsumwq;
 
   prevarsum(array, w, len, nmiss, missval, &rsum, &rsumw, &rsumq, &rsumwq);
 
-  rvar = IS_NOT_EQUAL(rsumw, 0) ? (rsumq*rsumw - rsum*rsum) / (rsumw*rsumw) : missval;
+  double rvar = IS_NOT_EQUAL(rsumw, 0) ? (rsumq*rsumw - rsum*rsum) / (rsumw*rsumw) : missval;
   if ( rvar < 0 && rvar > -1.e-5 ) rvar = 0;
 
   return (rvar);
@@ -387,24 +386,21 @@ double fldvar1(field_t field)
   const double missval = field.missval;
   double *array  = field.ptr;
   double *w      = field.weight;
-  double rsum, rsumw, rvar;
+  double rsum, rsumw;
   double rsumq, rsumwq;
 
   prevarsum(array, w, len, nmiss, missval, &rsum, &rsumw, &rsumq, &rsumwq);
 
-  rvar = (rsumw*rsumw > rsumwq) ? (rsumq*rsumw - rsum*rsum) / (rsumw*rsumw - rsumwq) : missval;
+  double rvar = (rsumw*rsumw > rsumwq) ? (rsumq*rsumw - rsum*rsum) / (rsumw*rsumw - rsumwq) : missval;
   if ( rvar < 0 && rvar > -1.e-5 ) rvar = 0;
 
   return (rvar);
 }
 
 
-double fldstd(field_t field)
+double var_to_std(double rvar, double missval)
 {
-  const double missval = field.missval;
-  double rvar, rstd;
-
-  rvar = fldvar(field);
+  double rstd;
 
   if ( DBL_IS_EQUAL(rvar, missval) || rvar < 0 )
     {
@@ -415,27 +411,18 @@ double fldstd(field_t field)
       rstd = IS_NOT_EQUAL(rvar, 0) ? sqrt(rvar) : 0;
     }
 
-  return (rstd);
+  return rstd;
 }
 
-
-double fldstd1(field_t field)
+double fldstd(field_t field)
 {
-  const double missval = field.missval;
-  double rvar, rstd;
+  return var_to_std(fldvar(field), field.missval);
+}
 
-  rvar = fldvar1(field);
 
-  if ( DBL_IS_EQUAL(rvar, missval) || rvar < 0 )
-    {
-      rstd = missval;
-    }
-  else
-    {
-      rstd = IS_NOT_EQUAL(rvar, 0) ? sqrt(rvar) : 0;
-    }
-
-  return (rstd);
+double fldstd1(field_t field)
+{
+  return var_to_std(fldvar1(field), field.missval);
 }
 
 
@@ -545,34 +532,32 @@ void varrms(field_t field, field_t field2, field_t *field3)
 }
 
 /* RQ */
-double fldpctl(field_t field, const int p)
+double fldpctl(field_t field, const double pn)
 {
   const size_t len     = field.size;
   const int    nmiss   = field.nmiss;
   const double missval = field.missval;
   double *array  = field.ptr;
-  double *array2;
-
-  size_t i, j;
   double pctl = missval;
 
   if ( len - nmiss > 0 )
     {
       if ( nmiss > 0 )
         {
-          array2 = (double*) malloc((len - nmiss)*sizeof(double));
+          double *array2 = (double*) Malloc((len - nmiss)*sizeof(double));
 
-          for ( i = 0, j = 0; i < len; i++ ) 
+          size_t j = 0;
+          for ( size_t i = 0; i < len; i++ ) 
             if ( !DBL_IS_EQUAL(array[i], missval) )
               array2[j++] = array[i];
 
-          pctl = nth_element(array2, j, (int)ceil(j*(p/100.0))-1);
+          pctl = percentile(array2, j, pn);
 
-          free(array2);
+          Free(array2);
         }
       else
         {
-          pctl = nth_element(array, len, (int)ceil(len*(p/100.0))-1);
+          pctl = percentile(array, len, pn);
         }
     }
 
diff --git a/src/field.h b/src/field.h
index 2f822bd..9f6f8d8 100644
--- a/src/field.h
+++ b/src/field.h
@@ -18,10 +18,15 @@
 #ifndef _FIELD_H
 #define _FIELD_H
 
-#define  FIELD_NONE 0
-#define  FIELD_ALL  1
-#define  FIELD_PTR  2
-#define  FILED_WGT  3
+double var_to_std(double rvar, double missval);
+
+enum field_flag {
+  FIELD_NONE  =  1,
+  FIELD_PTR   =  2,
+  FIELD_WGT   =  4,
+  FIELD_PTR2  =  8,
+  FIELD_ALL   =  FIELD_PTR | FIELD_WGT
+};
 
 
 #define  FADD(x,y)  (DBL_IS_EQUAL((x),missval1) || DBL_IS_EQUAL((y),missval2) ? missval1 : (x)+(y))
@@ -55,9 +60,11 @@ typedef struct {
   size_t   size;
   int      nsamp;
   int      nmiss;
+  int      nmiss2;
   double   missval;
   double  *weight;
   double  *ptr;
+  double  *ptr2;
 }
 field_t;
 
@@ -81,9 +88,7 @@ double fldstd(field_t field);
 double fldstd1(field_t field);
 double fldvar(field_t field);
 double fldvar1(field_t field);
-/* RQ */
-double fldpctl(field_t field, const int k);
-/* QR */
+double fldpctl(field_t field, const double pn);
 void   fldunm(field_t *field);
 int    fldhvs(field_t *field, const size_t nlevels);
 
@@ -103,10 +108,10 @@ void zonsum(field_t field1, field_t *field2);
 void zonavg(field_t field1, field_t *field2);
 void zonmean(field_t field1, field_t *field2);
 void zonstd(field_t field1, field_t *field2);
+void zonstd1(field_t field1, field_t *field2);
 void zonvar(field_t field1, field_t *field2);
-/* RQ */
+void zonvar1(field_t field1, field_t *field2);
 void zonpctl(field_t field1, field_t *field2, const int k);
-/* QR */
 
 /* fieldmer.c */
 
@@ -117,10 +122,10 @@ void mersum(field_t field1, field_t *field2);
 void meravg(field_t field1, field_t *field2);
 void mermean(field_t field1, field_t *field2);
 void merstd(field_t field1, field_t *field2);
+void merstd1(field_t field1, field_t *field2);
 void mervar(field_t field1, field_t *field2);
-/* RQ */
+void mervar1(field_t field1, field_t *field2);
 void merpctl(field_t field1, field_t *field2, const int k);
-/* QR */
 
 void fldrms(field_t field1, field_t field2, field_t *field3);
 
@@ -138,6 +143,7 @@ void farcsub(field_t *field, const double rconst);
 void farmod(field_t *field, const double divisor);
 
 void farinv(field_t *field);
+void farround(field_t *field);
 
 /* field2.c */
 
@@ -145,22 +151,21 @@ void farfun(field_t *field1, field_t field2, const int function);
 
 void faradd(field_t *field1, field_t field2);
 void farsum(field_t *field1, field_t field2);
+void farsumw(field_t *field1, field_t field2, double w);
 void farsumq(field_t *field1, field_t field2);
+void farsumqw(field_t *field1, field_t field2, double w);
 void farsumtr(field_t *field1, field_t field2, const double refval);
 void farsub(field_t *field1, field_t field2);
 void farmul(field_t *field1, field_t field2);
 void fardiv(field_t *field1, field_t field2);
 void farmin(field_t *field1, field_t field2);
 void farmax(field_t *field1, field_t field2);
-void farvar(field_t *field1, field_t field2, field_t field3);
-void farstd(field_t *field1, field_t field2, field_t field3);
-void farvarx(field_t *field1, field_t field2, field_t field3, const double divisor);
-void farstdx(field_t *field1, field_t field2, field_t field3, const double divisor);
-void farcvar(field_t *field1, field_t field2, const double rconst1);
-void farcstd(field_t *field1, field_t field2, const double rconst1);
-void farcvarx(field_t *field1, field_t field2, const double rconst1, const double divisor);
-void farcstdx(field_t *field1, field_t field2, const double rconst1, const double divisor);
+void farvar(field_t *field1, field_t field2, field_t field3, const double divisor);
+void farstd(field_t *field1, field_t field2, field_t field3, const double divisor);
+void farcvar(field_t *field1, field_t field2, const double rconst1, const double divisor);
+void farcstd(field_t *field1, field_t field2, const double rconst1, const double divisor);
 void farmoq(field_t *field1, field_t field2);
+void farmoqw(field_t *field1, field_t field2, double w);
 void faratan2(field_t *field1, field_t field2);
 
 /* RQ */
diff --git a/src/field2.c b/src/field2.c
index 98f7e26..40b871d 100644
--- a/src/field2.c
+++ b/src/field2.c
@@ -19,9 +19,11 @@
 #include "cdo_int.h"
 #include <cdi.h>
 
+#if 0
 #ifdef __SSE2__
 #include <emmintrin.h>
 #endif
+#endif
 
 void farfun(field_t *field1, field_t field2, const int function)
 {
@@ -41,11 +43,10 @@ void farfun(field_t *field1, field_t field2, const int function)
 static
 void arradd(const size_t n, double * restrict a, const double * restrict b)
 {
-  size_t i;
- 
   // SSE2 version is 15% faster than the original loop (tested with gcc47)
 #if 0
   //#ifdef __SSE2__ /*__SSE2__*/ // bug in this code!!!
+  size_t i;
   const size_t residual =  n % 8;
   const size_t ofs = n - residual;
 
@@ -63,11 +64,23 @@ void arradd(const size_t n, double * restrict a, const double * restrict b)
 
 #else
 
-  for ( i = 0; i < n; i++ ) a[i] += b[i];
+#if defined(_OPENMP)
+#pragma omp parallel for default(none) shared(a,b)
+#endif
+  for ( size_t i = 0; i < n; i++ ) a[i] += b[i];
 
 #endif
 }
 
+static
+void arraddw(const size_t n, double * restrict a, const double * restrict b, double w)
+{
+#if defined(_OPENMP)
+#pragma omp parallel for default(none) shared(a,b,w)
+#endif
+  for ( size_t i = 0; i < n; i++ ) a[i] += w*b[i];
+}
+
 
 void faradd(field_t *field1, field_t field2)
 {
@@ -77,7 +90,6 @@ void faradd(field_t *field1, field_t field2)
   const int    nmiss1   = field1->nmiss;
   const double missval1 = field1->missval;
   double *array1  = field1->ptr;
-  /*  double *weight1 = field1->weight; */
   const int    grid2    = field2.grid;
   const int    nmiss2   = field2.nmiss;
   const double missval2 = field2.missval;
@@ -114,7 +126,6 @@ void farsum(field_t *field1, field_t field2)
   const int    nmiss1   = field1->nmiss;
   const double missval1 = field1->missval;
   double *array1  = field1->ptr;
-  /*  double *weight1 = field1->weight; */
   const int    grid2    = field2.grid;
   const int    nmiss2   = field2.nmiss;
   const double missval2 = field2.missval;
@@ -148,6 +159,48 @@ void farsum(field_t *field1, field_t field2)
     }
 }
 
+
+void farsumw(field_t *field1, field_t field2, double w)
+{
+  size_t   i, len;
+  int          nwpv     = field1->nwpv;
+  const int    grid1    = field1->grid;
+  const int    nmiss1   = field1->nmiss;
+  const double missval1 = field1->missval;
+  double *array1  = field1->ptr;
+  const int    grid2    = field2.grid;
+  const int    nmiss2   = field2.nmiss;
+  const double missval2 = field2.missval;
+  double *array2  = field2.ptr;
+
+  if ( nwpv != 2 ) nwpv = 1;
+
+  len = (size_t) (nwpv*gridInqSize(grid1));
+
+  if ( len != (size_t) (nwpv*gridInqSize(grid2)) )
+    cdoAbort("Fields have different gridsize (%s)", __func__);
+
+  if ( nmiss1 > 0 || nmiss2 > 0 )
+    {
+      for ( i = 0; i < len; i++ )
+	if ( !DBL_IS_EQUAL(array2[i], missval2) )
+	  {
+	    if ( !DBL_IS_EQUAL(array1[i], missval1) )
+	      array1[i] += w*array2[i];
+	    else
+	      array1[i] = w*array2[i];
+	  }
+
+      field1->nmiss = 0;
+      for ( i = 0; i < len; i++ )
+	if ( DBL_IS_EQUAL(array1[i], missval1) ) field1->nmiss++;
+    }
+  else
+    {
+      arraddw(len, array1, array2, w);
+    }
+}
+
 /* 
  * Compute the occurrence of values in field, if they do not equal refval.
  * This can be used to compute the lengths of multiple periods in a timeseries.
@@ -211,7 +264,6 @@ void farsumq(field_t *field1, field_t field2)
   const int    nmiss1   = field1->nmiss;
   const double missval1 = field1->missval;
   double *array1  = field1->ptr;
-  /*  double *weight1 = field1->weight; */
   const int    grid2    = field2.grid;
   const int    nmiss2   = field2.nmiss;
   const double missval2 = field2.missval;
@@ -247,6 +299,49 @@ void farsumq(field_t *field1, field_t field2)
 }
 
 
+void farsumqw(field_t *field1, field_t field2, double w)
+{
+  size_t   i, len;
+  int          nwpv     = field1->nwpv;
+  const int    grid1    = field1->grid;
+  const int    nmiss1   = field1->nmiss;
+  const double missval1 = field1->missval;
+  double *array1  = field1->ptr;
+  const int    grid2    = field2.grid;
+  const int    nmiss2   = field2.nmiss;
+  const double missval2 = field2.missval;
+  double *array2  = field2.ptr;
+
+  if ( nwpv != 2 ) nwpv = 1;
+
+  len = (size_t) (nwpv*gridInqSize(grid1));
+
+  if ( len != (size_t) (nwpv*gridInqSize(grid2)) )
+    cdoAbort("Fields have different gridsize (%s)", __func__);
+
+  if ( nmiss1 > 0 || nmiss2 > 0 )
+    {
+      for ( i = 0; i < len; i++ )
+	if ( !DBL_IS_EQUAL(array2[i], missval2) )
+	  {
+	    if ( !DBL_IS_EQUAL(array1[i], missval1) )
+	      array1[i] += w*array2[i]*array2[i];
+	    else
+	      array1[i] = w*array2[i]*array2[i];
+	  }
+
+      field1->nmiss = 0;
+      for ( i = 0; i < len; i++ )
+	if ( DBL_IS_EQUAL(array1[i], missval1) ) field1->nmiss++;
+    }
+  else
+    {
+      for ( i = 0; i < len; i++ ) 
+	array1[i] += w*array2[i]*array2[i];
+    }
+}
+
+
 void farsub(field_t *field1, field_t field2)
 {
   size_t   i, len;
@@ -456,8 +551,8 @@ void farmax(field_t *field1, field_t field2)
     }
 }
 
-
-void farvar(field_t *field1, field_t field2, field_t field3)
+// not used
+void farvar0(field_t *field1, field_t field2, field_t field3)
 {
   size_t   i, len;
   int          nwpv     = field1->nwpv;
@@ -512,7 +607,7 @@ void farvar(field_t *field1, field_t field2, field_t field3)
 }
 
 
-void farvarx(field_t *field1, field_t field2, field_t field3, const double divisor)
+void farvar(field_t *field1, field_t field2, field_t field3, const double divisor)
 {
   size_t   i, len;
   int          nwpv     = field1->nwpv;
@@ -548,8 +643,8 @@ void farvarx(field_t *field1, field_t field2, field_t field3, const double divis
       }
 }
 
-
-void farstd(field_t *field1, field_t field2, field_t field3)
+// not used
+void farstd0(field_t *field1, field_t field2, field_t field3)
 {
   size_t   i, len;
   int          nwpv     = field1->nwpv;
@@ -565,7 +660,7 @@ void farstd(field_t *field1, field_t field2, field_t field3)
   if ( len != (size_t) (nwpv*gridInqSize(grid2)) )
     cdoAbort("Fields have different gridsize (%s)", __func__);
 
-  farvar(field1, field2, field3);
+  farvar0(field1, field2, field3);
 
   field1->nmiss = 0;
   for ( i = 0; i < len; i++ )
@@ -581,7 +676,7 @@ void farstd(field_t *field1, field_t field2, field_t field3)
 }
 
 
-void farstdx(field_t *field1, field_t field2, field_t field3, const double divisor)
+void farstd(field_t *field1, field_t field2, field_t field3, const double divisor)
 {
   size_t   i, len;
   int          nwpv     = field1->nwpv;
@@ -597,7 +692,7 @@ void farstdx(field_t *field1, field_t field2, field_t field3, const double divis
   if ( len != (size_t) (nwpv*gridInqSize(grid2)) )
     cdoAbort("Fields have different gridsize (%s)", __func__);
 
-  farvarx(field1, field2, field3, divisor);
+  farvar(field1, field2, field3, divisor);
 
   field1->nmiss = 0;
   for ( i = 0; i < len; i++ )
@@ -612,8 +707,8 @@ void farstdx(field_t *field1, field_t field2, field_t field3, const double divis
       }
 }
 
-
-void farcvar(field_t *field1, field_t field2, const double rconst1)
+// not used
+void farcvar0(field_t *field1, field_t field2, const double rconst1)
 {
   size_t   i, len;
   int          nwpv     = field1->nwpv;
@@ -668,7 +763,7 @@ void farcvar(field_t *field1, field_t field2, const double rconst1)
 }
 
 
-void farcvarx(field_t *field1, field_t field2, const double rconst1, const double divisor)
+void farcvar(field_t *field1, field_t field2, const double rconst1, const double divisor)
 {
   size_t   i, len;
   int          nwpv     = field1->nwpv;
@@ -703,8 +798,8 @@ void farcvarx(field_t *field1, field_t field2, const double rconst1, const doubl
       }
 }
 
-
-void farcstd(field_t *field1, field_t field2, const double rconst1)
+// not used
+void farcstd0(field_t *field1, field_t field2, const double rconst1)
 {
   size_t   i, len;
   int          nwpv     = field1->nwpv;
@@ -720,7 +815,7 @@ void farcstd(field_t *field1, field_t field2, const double rconst1)
   if ( len != (size_t) (nwpv*gridInqSize(grid2)) )
     cdoAbort("Fields have different gridsize (%s)", __func__);
 
-  farcvar(field1, field2, rconst1);
+  farcvar0(field1, field2, rconst1);
 
   field1->nmiss = 0;
   for ( i = 0; i < len; i++ )
@@ -736,7 +831,7 @@ void farcstd(field_t *field1, field_t field2, const double rconst1)
 }
 
 
-void farcstdx(field_t *field1, field_t field2, const double rconst1, const double divisor)
+void farcstd(field_t *field1, field_t field2, const double rconst1, const double divisor)
 {
   size_t   i, len;
   int          nwpv     = field1->nwpv;
@@ -752,7 +847,7 @@ void farcstdx(field_t *field1, field_t field2, const double rconst1, const doubl
   if ( len != (size_t) (nwpv*gridInqSize(grid2)) )
     cdoAbort("Fields have different gridsize (%s)", __func__);
 
-  farcvarx(field1, field2, rconst1, divisor);
+  farcvar(field1, field2, rconst1, divisor);
 
   field1->nmiss = 0;
   for ( i = 0; i < len; i++ )
@@ -807,6 +902,45 @@ void farmoq(field_t *field1, field_t field2)
 }
 
 
+void farmoqw(field_t *field1, field_t field2, double w)
+{
+  size_t   i, len;
+  int          nwpv     = field1->nwpv;
+  const int    grid1    = field1->grid;
+  const double missval1 = field1->missval;
+  double *array1  = field1->ptr;
+  const int    grid2    = field2.grid;
+  const int    nmiss2   = field2.nmiss;
+  double missval2 = field2.missval;
+  double *array2  = field2.ptr;
+
+  if ( nwpv != 2 ) nwpv = 1;
+
+  len = (size_t) (nwpv*gridInqSize(grid1));
+
+  if ( len != (size_t) (nwpv*gridInqSize(grid2)) )
+    cdoAbort("Fields have different gridsize (%s)", __func__);
+
+  if ( nmiss2 > 0 )
+    {
+      for ( i = 0; i < len; i++ )
+	if ( !DBL_IS_EQUAL(array2[i], missval2) )
+	  array1[i] = w*array2[i]*array2[i];
+	else
+	  array1[i] = missval1;
+
+      field1->nmiss = 0;
+      for ( i = 0; i < len; i++ )
+	if ( DBL_IS_EQUAL(array1[i], missval1) ) field1->nmiss++;
+    }
+  else
+    {
+      for ( i = 0; i < len; i++ ) 
+	array1[i] = w*array2[i]*array2[i];
+    }
+}
+
+
 /* RQ */
 /**
  * Counts the number of nonmissing values. The result of the operation
@@ -829,7 +963,6 @@ void farcount(field_t *field1, field_t field2)
   const int    nmiss1   = field1->nmiss;
   const double missval1 = field1->missval;
   double *array1  = field1->ptr;
-  /*  double *weight1 = field1->weight; */
   const int    grid2    = field2.grid;
   const int    nmiss2   = field2.nmiss;
   const double missval2 = field2.missval;
diff --git a/src/fieldc.c b/src/fieldc.c
index 782b5bb..5ff2f8d 100644
--- a/src/fieldc.c
+++ b/src/fieldc.c
@@ -137,6 +137,24 @@ void farinv(field_t *field)
 }
 
 
+void farround(field_t *field)
+{
+  int    grid     = field->grid;
+  double missval1 = field->missval;
+  double missval2 = field->missval;
+  double *array   = field->ptr;
+
+  int len = gridInqSize(grid);
+
+  for ( int i = 0; i < len; i++ ) 
+    array[i] = round(array[i]);
+
+  field->nmiss = 0;
+  for ( int i = 0; i < len; i++ )
+    if ( DBL_IS_EQUAL(array[i], missval1) ) field->nmiss++;
+}
+
+
 void farmod(field_t *field, double divisor)
 {
   int i, len;
diff --git a/src/fieldmem.c b/src/fieldmem.c
index 3ca10a8..128ee3f 100644
--- a/src/fieldmem.c
+++ b/src/fieldmem.c
@@ -5,6 +5,7 @@
 #include <cdo.h>
 #include "dmemory.h"
 #include "field.h"
+#include "util.h"
 
 
 void field_init(field_t *field)
@@ -15,28 +16,22 @@ void field_init(field_t *field)
 
 field_t **field_allocate(int vlistID, int ptype, int init)
 {
-  int nvars, nlevel;
-  int varID, zaxisID, levelID;
-  int gridID, gridsize;
-  int nwpv; // number of words per value; real:1  complex:2
-  double missval;
-  field_t **field;
+  int nvars = vlistNvars(vlistID);
 
-  nvars = vlistNvars(vlistID);
+  field_t **field = (field_t **) Malloc(nvars*sizeof(field_t *));
 
-  field = (field_t **) malloc(nvars*sizeof(field_t *));
-
-  for ( varID = 0; varID < nvars; ++varID )
+  for ( int varID = 0; varID < nvars; ++varID )
     {
-      nwpv     = vlistInqNWPV(vlistID, varID);
-      gridID   = vlistInqVarGrid(vlistID, varID);
-      gridsize = gridInqSize(gridID);
-      zaxisID  = vlistInqVarZaxis(vlistID, varID);
-      nlevel   = zaxisInqSize(zaxisID);
-      missval  = vlistInqVarMissval(vlistID, varID);
-
-      field[varID] = (field_t*) malloc(nlevel*sizeof(field_t));
-      for ( levelID = 0; levelID < nlevel; ++levelID )
+      int nwpv     = vlistInqNWPV(vlistID, varID); // number of words per value; real:1  complex:2
+      int gridID   = vlistInqVarGrid(vlistID, varID);
+      int gridsize = gridInqSize(gridID);
+      int zaxisID  = vlistInqVarZaxis(vlistID, varID);
+      int nlevel   = zaxisInqSize(zaxisID);
+      double missval  = vlistInqVarMissval(vlistID, varID);
+
+      field[varID] = (field_t*) Malloc(nlevel*sizeof(field_t));
+
+      for ( int levelID = 0; levelID < nlevel; ++levelID )
 	{
 	  field_init(&field[varID][levelID]);
 
@@ -44,58 +39,63 @@ field_t **field_allocate(int vlistID, int ptype, int init)
 	  field[varID][levelID].grid    = gridID;
 	  field[varID][levelID].nsamp   = 0;
 	  field[varID][levelID].nmiss   = 0;
+	  field[varID][levelID].nmiss2  = 0;
 	  field[varID][levelID].missval = missval;
 	  field[varID][levelID].ptr     = NULL;
+	  field[varID][levelID].ptr2    = NULL;
 	  field[varID][levelID].weight  = NULL;
 
-	  if ( ptype == FIELD_ALL || ptype == FIELD_PTR )
+	  if ( ptype & FIELD_PTR )
 	    {
-	      field[varID][levelID].ptr = (double*) malloc(nwpv*gridsize*sizeof(double));
+	      field[varID][levelID].ptr = (double*) Malloc(nwpv*gridsize*sizeof(double));
 	      if ( init ) memset(field[varID][levelID].ptr, 0, nwpv*gridsize*sizeof(double));
 	    }
 
-	  if ( ptype == FIELD_ALL || ptype == FIELD_PTR )
+	  if ( ptype & FIELD_PTR2 )
+	    {
+	      field[varID][levelID].ptr2 = (double*) Malloc(nwpv*gridsize*sizeof(double));
+	      if ( init ) memset(field[varID][levelID].ptr2, 0, nwpv*gridsize*sizeof(double));
+	    }
+
+	  if ( ptype & FIELD_WGT )
 	    {
-	      field[varID][levelID].weight = (double*) malloc(nwpv*gridsize*sizeof(double));
+	      field[varID][levelID].weight = (double*) Malloc(nwpv*gridsize*sizeof(double));
 	      if ( init ) memset(field[varID][levelID].weight, 0, nwpv*gridsize*sizeof(double));
 	    }    
 	}
     }
 
-  return (field);
+  return field;
 }
 
 
 field_t **field_malloc(int vlistID, int ptype)
 {
-  return (field_allocate(vlistID, ptype, 0));
+  return field_allocate(vlistID, ptype, 0);
 }
 
 
 field_t **field_calloc(int vlistID, int ptype)
 {
-  return (field_allocate(vlistID, ptype, 1));
+  return field_allocate(vlistID, ptype, 1);
 }
 
 
 void field_free(field_t **field, int vlistID)
 {
-  int nvars, nlevel;
-  int varID, levelID;
-
-  nvars = vlistNvars(vlistID);
-
-  for ( varID = 0; varID < nvars; ++varID )
+  int nvars = vlistNvars(vlistID);
+  for ( int varID = 0; varID < nvars; ++varID )
     {
-      nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID, varID));
-      for ( levelID = 0; levelID < nlevel; ++levelID )
+      int nlevel = zaxisInqSize(vlistInqVarZaxis(vlistID, varID));
+      for ( int levelID = 0; levelID < nlevel; ++levelID )
 	{
-	  if ( field[varID][levelID].ptr )    free(field[varID][levelID].ptr);
-       	  if ( field[varID][levelID].weight ) free(field[varID][levelID].weight);
+	  if ( field[varID][levelID].ptr )    Free(field[varID][levelID].ptr);
+	  if ( field[varID][levelID].ptr2 )   Free(field[varID][levelID].ptr2);
+       	  if ( field[varID][levelID].weight ) Free(field[varID][levelID].weight);
 	}
 
-      free(field[varID]);
+      Free(field[varID]);
     }
 
-  free(field);
+  Free(field);
 }
diff --git a/src/fieldmer.c b/src/fieldmer.c
index 6d77ba8..ad65dcd 100644
--- a/src/fieldmer.c
+++ b/src/fieldmer.c
@@ -18,9 +18,8 @@
 #include "cdo.h"
 #include "cdo_int.h"
 #include <cdi.h>
-/* RQ */
-#include "nth_element.h"
-/* QR */
+#include "percentiles.h"
+
 
 void merfun(field_t field1, field_t *field2, int function)
 {
@@ -30,7 +29,9 @@ void merfun(field_t field1, field_t *field2, int function)
   else if ( function == func_mean ) mermean(field1, field2);  
   else if ( function == func_avg )  meravg(field1, field2);  
   else if ( function == func_std )  merstd(field1, field2);  
+  else if ( function == func_std1 ) merstd1(field1, field2);  
   else if ( function == func_var )  mervar(field1, field2);
+  else if ( function == func_var1 ) mervar1(field1, field2);
   else cdoAbort("function %d not implemented!", function);
 }
 
@@ -262,10 +263,42 @@ void meravg(field_t field1, field_t *field2)
   field2->nmiss  = rnmiss;
 }
 
+static
+void prevarsum_mer(const double *restrict array, const double *restrict w, int nx, int ny, int nmiss, 
+	       double missval, double *restrict rsum, double *restrict rsumw, double *restrict rsumq, double *restrict rsumwq)
+{ 
+  *rsum   = 0;
+  *rsumq  = 0;
+  *rsumw  = 0;
+  *rsumwq = 0;
+
+  if ( nmiss > 0 )
+    {
+      for ( int j = 0; j < ny; j++ )
+        if ( !DBL_IS_EQUAL(array[j*nx], missval) &&
+             !DBL_IS_EQUAL(w[j*nx], missval) )
+          {
+            *rsum   += w[j*nx] * array[j*nx];
+            *rsumq  += w[j*nx] * array[j*nx] * array[j*nx];
+            *rsumw  += w[j*nx];
+            *rsumwq += w[j*nx] * w[j*nx];
+          }
+    }
+  else
+    {
+      for ( int j = 0; j < ny; j++ )
+        {
+          *rsum   += w[j*nx] * array[j*nx];
+          *rsumq  += w[j*nx] * array[j*nx] * array[j*nx];
+          *rsumw  += w[j*nx];
+          *rsumwq += w[j*nx] * w[j*nx];
+        }
+    }
+}
+
 
 void mervar(field_t field1, field_t *field2)
 {
-  long   i, j, nx, ny;
   int    rnmiss = 0;
   int    grid    = field1.grid;
   int    nmiss   = field1.nmiss;
@@ -275,37 +308,12 @@ void mervar(field_t field1, field_t *field2)
   double rsum = 0, rsumw = 0, rvar = 0;
   double rsumq = 0, rsumwq = 0;
 
-  nx    = gridInqXsize(grid);
-  ny    = gridInqYsize(grid);
+  int nx = gridInqXsize(grid);
+  int ny = gridInqYsize(grid);
 
-  for ( i = 0; i < nx; i++ )
+  for ( int i = 0; i < nx; i++ )
     {
-      rsum   = 0;
-      rsumq  = 0;
-      rsumw  = 0;
-      rsumwq = 0;
-      if ( nmiss > 0 )
-	{
-	  for ( j = 0; j < ny; j++ )
-	    if ( !DBL_IS_EQUAL(array[j*nx+i], missval) &&
-		 !DBL_IS_EQUAL(w[j*nx+i], missval) )
-	      {
-		rsum   += w[j*nx+i] * array[j*nx+i];
-		rsumq  += w[j*nx+i] * array[j*nx+i] * array[j*nx+i];
-		rsumw  += w[j*nx+i];
-		rsumwq += w[j*nx+i] * w[j*nx+i];
-	      }
-	}
-      else
-	{
-	  for ( j = 0; j < ny; j++ )
-	    {
-	      rsum   += w[j*nx+i] * array[j*nx+i];
-	      rsumq  += w[j*nx+i] * array[j*nx+i] * array[j*nx+i];
-	      rsumw  += w[j*nx+i];
-	      rsumwq += w[j*nx+i] * w[j*nx+i];
-	    }
-	}
+      prevarsum_mer(array+i, w+i, nx, ny, nmiss, missval, &rsum, &rsumw, &rsumq, &rsumwq);
 
       rvar = IS_NOT_EQUAL(rsumw, 0) ? (rsumq*rsumw - rsum*rsum) / (rsumw*rsumw) : missval;
       if ( rvar < 0 && rvar > -1.e-5 ) rvar = 0;
@@ -319,32 +327,76 @@ void mervar(field_t field1, field_t *field2)
 }
 
 
+void mervar1(field_t field1, field_t *field2)
+{
+  int    rnmiss = 0;
+  int    grid    = field1.grid;
+  int    nmiss   = field1.nmiss;
+  double missval = field1.missval;
+  double *array  = field1.ptr;
+  double *w      = field1.weight;
+  double rsum = 0, rsumw = 0, rvar = 0;
+  double rsumq = 0, rsumwq = 0;
+
+  int nx = gridInqXsize(grid);
+  int ny = gridInqYsize(grid);
+
+  for ( int i = 0; i < nx; i++ )
+    {
+      prevarsum_mer(array+i, w+i, nx, ny, nmiss, missval, &rsum, &rsumw, &rsumq, &rsumwq);
+
+      rvar = (rsumw*rsumw > rsumwq) ? (rsumq*rsumw - rsum*rsum) / (rsumw*rsumw - rsumwq) : missval;
+      if ( rvar < 0 && rvar > -1.e-5 ) rvar = 0;
+
+      if ( DBL_IS_EQUAL(rvar, missval) ) rnmiss++;
+
+      field2->ptr[i] = rvar;
+    }
+
+  field2->nmiss  = rnmiss;
+}
+
+
 void merstd(field_t field1, field_t *field2)
 {
-  long   i, nx;
   int    rnmiss = 0;
   int    grid    = field1.grid;
   double missval = field1.missval;
-  double rvar, rstd;
+  double rstd;
 
-  nx    = gridInqXsize(grid);
+  int nx = gridInqXsize(grid);
 
   mervar(field1, field2);
 
-  for ( i = 0; i < nx; i++ )
+  for ( int i = 0; i < nx; i++ )
     {
-      rvar = field2->ptr[i];
+      rstd = var_to_std(field2->ptr[i], missval);
 
-      if ( DBL_IS_EQUAL(rvar, missval) || rvar < 0 )
-	{
-	  rstd = missval;
-	}
-      else
-	{
-	  rstd = IS_NOT_EQUAL(rvar, 0) ? sqrt(rvar) : 0;
-	}
+      if ( DBL_IS_EQUAL(rstd, missval) ) rnmiss++;
+
+      field2->ptr[i] = rstd;
+    }
+
+  field2->nmiss  = rnmiss;
+}
 
-      if ( DBL_IS_EQUAL(rvar, missval) ) rnmiss++;
+
+void merstd1(field_t field1, field_t *field2)
+{
+  int    rnmiss = 0;
+  int    grid    = field1.grid;
+  double missval = field1.missval;
+  double rstd;
+
+  int nx = gridInqXsize(grid);
+
+  mervar1(field1, field2);
+
+  for ( int i = 0; i < nx; i++ )
+    {
+      rstd = var_to_std(field2->ptr[i], missval);
+
+      if ( DBL_IS_EQUAL(rstd, missval) ) rnmiss++;
 
       field2->ptr[i] = rstd;
     }
@@ -355,18 +407,17 @@ void merstd(field_t field1, field_t *field2)
 /* RQ */
 void merpctl(field_t field1, field_t *field2, int p)
 {
-  long   i, j, l, nx, ny;
+  long   i, j, l;
   int    rnmiss = 0;
   int    grid    = field1.grid;
   int    nmiss   = field1.nmiss;
   double missval = field1.missval;
   double *array  = field1.ptr;
-  double *array2;
 
-  nx = gridInqXsize(grid);
-  ny = gridInqYsize(grid);
+  long nx = gridInqXsize(grid);
+  long ny = gridInqYsize(grid);
   
-  array2 = (double*) malloc(nx*sizeof(double));
+  double *array2 = (double*) Malloc(nx*sizeof(double));
   
   if ( nmiss > 0 )
     {
@@ -378,7 +429,7 @@ void merpctl(field_t field1, field_t *field2, int p)
 	    
           if ( l > 0 )
             {
-              field2->ptr[i] = nth_element(array2, l, (int)ceil(l*(p/100.0))-1);
+              field2->ptr[i] = percentile(array2, l, p);
             }
           else
             {
@@ -395,7 +446,7 @@ void merpctl(field_t field1, field_t *field2, int p)
             {
               for ( j = 0; j < ny; j++ )
                 array2[j] = array[j*nx+i];
-              field2->ptr[i] = nth_element(array2, ny, (int)ceil(ny*(p/100.0))-1);
+              field2->ptr[i] = percentile(array2, ny, p);
             }
           else
             {
@@ -405,6 +456,8 @@ void merpctl(field_t field1, field_t *field2, int p)
       	}
     }
 
+  Free(array2);
+
   field2->nmiss = rnmiss;
 }
 /* QR */
diff --git a/src/fieldzon.c b/src/fieldzon.c
index fd7cd0a..bb8ce2e 100644
--- a/src/fieldzon.c
+++ b/src/fieldzon.c
@@ -18,9 +18,7 @@
 #include "cdo.h"
 #include "cdo_int.h"
 #include <cdi.h>
-/* RQ */
-#include "nth_element.h"
-/* QR */
+#include "percentiles.h"
 
 
 void zonfun(field_t field1, field_t *field2, int function)
@@ -32,7 +30,9 @@ void zonfun(field_t field1, field_t *field2, int function)
   else if ( function == func_mean  )  zonmean(field1, field2);  
   else if ( function == func_avg   )  zonavg(field1, field2);  
   else if ( function == func_std   )  zonstd(field1, field2);  
+  else if ( function == func_std1  )  zonstd1(field1, field2);  
   else if ( function == func_var   )  zonvar(field1, field2);
+  else if ( function == func_var1  )  zonvar1(field1, field2);
   else cdoAbort("function %d not implemented!", function);
 }
 
@@ -318,10 +318,43 @@ void zonavg(field_t field1, field_t *field2)
   field2->nmiss  = rnmiss;
 }
 
+static
+void prevarsum_zon(const double *restrict array, int nx, int nmiss,  double missval, 
+                   double *rsum, double *rsumw, double *rsumq, double *rsumwq)
+{
+  double w = 1./nx;
+
+  *rsum   = 0;
+  *rsumq  = 0;
+  *rsumw  = 0;
+  *rsumwq = 0;
+
+  if ( nmiss > 0 )
+    {
+      for ( int i = 0; i < nx; i++ )
+        if ( !DBL_IS_EQUAL(array[i], missval) )
+          {
+            *rsum   += w * array[i];
+            *rsumq  += w * array[i] * array[i];
+            *rsumw  += w;
+            *rsumwq += w * w;
+          }
+    }
+  else
+    {
+      for ( int i = 0; i < nx; i++ )
+        {
+          *rsum   += w * array[i];
+          *rsumq  += w * array[i] * array[i];
+          *rsumw  += w;
+          *rsumwq += w * w;
+        }
+    }
+}
+
 
 void zonvar(field_t field1, field_t *field2)
 {
-  long   i, j, nx, ny;
   int    rnmiss = 0;
   int    grid     = field1.grid;
   int    nmiss    = field1.nmiss;
@@ -330,36 +363,12 @@ void zonvar(field_t field1, field_t *field2)
   double rsum = 0, rsumw = 0, rvar = 0;
   double rsumq = 0, rsumwq = 0;
 
-  nx    = gridInqXsize(grid);
-  ny    = gridInqYsize(grid);
+  int nx = gridInqXsize(grid);
+  int ny = gridInqYsize(grid);
 
-  for ( j = 0; j < ny; j++ )
+  for ( int j = 0; j < ny; j++ )
     {
-      rsum   = 0;
-      rsumq  = 0;
-      rsumw  = 0;
-      rsumwq = 0;
-      if ( nmiss > 0 )
-	{
-	  for ( i = 0; i < nx; i++ )
-	    if ( !DBL_IS_EQUAL(array[j*nx+i], missval1) )
-	      {
-		rsum   += array[j*nx+i];
-		rsumq  += array[j*nx+i] * array[j*nx+i];
-		rsumw  += 1;
-		rsumwq += 1;
-	      }
-	}
-      else
-	{
-	  for ( i = 0; i < nx; i++ )
-	    {
-	      rsum   += array[j*nx+i];
-	      rsumq  += array[j*nx+i] * array[j*nx+i];
-	      rsumw  += 1;
-	      rsumwq += 1;
-	    }
-	}
+      prevarsum_zon(array+j*nx, nx, nmiss, missval1, &rsum, &rsumw, &rsumq, &rsumwq);
 
       rvar = IS_NOT_EQUAL(rsumw, 0) ? (rsumq*rsumw - rsum*rsum) / (rsumw*rsumw) : missval1;
       if ( rvar < 0 && rvar > -1.e-5 ) rvar = 0;
@@ -373,56 +382,98 @@ void zonvar(field_t field1, field_t *field2)
 }
 
 
+void zonvar1(field_t field1, field_t *field2)
+{
+  int    rnmiss = 0;
+  int    grid     = field1.grid;
+  int    nmiss    = field1.nmiss;
+  double missval1 = field1.missval;
+  double *array   = field1.ptr;
+  double rsum = 0, rsumw = 0, rvar = 0;
+  double rsumq = 0, rsumwq = 0;
+
+  int nx = gridInqXsize(grid);
+  int ny = gridInqYsize(grid);
+
+  for ( int j = 0; j < ny; j++ )
+    {
+      prevarsum_zon(array+j*nx, nx, nmiss, missval1, &rsum, &rsumw, &rsumq, &rsumwq);
+
+      rvar = (rsumw*rsumw > rsumwq) ? (rsumq*rsumw - rsum*rsum) / (rsumw*rsumw - rsumwq) : missval1;
+      if ( rvar < 0 && rvar > -1.e-5 ) rvar = 0;
+
+      if ( DBL_IS_EQUAL(rvar, missval1) ) rnmiss++;
+
+      field2->ptr[j] = rvar;
+    }
+
+  field2->nmiss  = rnmiss;
+}
+
+
 void zonstd(field_t field1, field_t *field2)
 {
-  long   j, ny;
   int    rnmiss = 0;
   int    grid    = field1.grid;
   double missval = field1.missval;
-  double rvar, rstd;
+  double rstd;
 
-  ny    = gridInqYsize(grid);
+  int ny = gridInqYsize(grid);
 
   zonvar(field1, field2);
 
-  for ( j = 0; j < ny; j++ )
+  for ( int j = 0; j < ny; j++ )
     {
-      rvar = field2->ptr[j];
+      rstd = var_to_std(field2->ptr[j], missval);
 
-      if ( DBL_IS_EQUAL(rvar, missval) || rvar < 0 )
-	{
-	  rstd = missval;
-	}
-      else
-	{
-	  rstd = IS_NOT_EQUAL(rvar, 0) ? sqrt(rvar) : 0;
-	}
+      if ( DBL_IS_EQUAL(rstd, missval) ) rnmiss++;
+
+      field2->ptr[j] = rstd;
+    }
+
+  field2->nmiss = rnmiss;
+}
+
+
+void zonstd1(field_t field1, field_t *field2)
+{
+  int    rnmiss = 0;
+  int    grid    = field1.grid;
+  double missval = field1.missval;
+  double rstd;
+
+  int ny = gridInqYsize(grid);
 
-      if ( DBL_IS_EQUAL(rvar, missval) ) rnmiss++;
+  zonvar1(field1, field2);
+
+  for ( int j = 0; j < ny; j++ )
+    {
+      rstd = var_to_std(field2->ptr[j], missval);
+
+      if ( DBL_IS_EQUAL(rstd, missval) ) rnmiss++;
 
       field2->ptr[j] = rstd;
     }
 
-  field2->nmiss  = rnmiss;
+  field2->nmiss = rnmiss;
 }
 
 /* RQ */
 void zonpctl(field_t field1, field_t *field2, int p)
 {
-  long   i, j, l, nx, ny;
+  long   i, j, l;
   int    rnmiss = 0;
   int    grid    = field1.grid;
   int    nmiss   = field1.nmiss;
   double missval = field1.missval;
   double *array  = field1.ptr;
-  double *array2;
 
-  nx = gridInqXsize(grid);
-  ny = gridInqYsize(grid);
+  long nx = gridInqXsize(grid);
+  long ny = gridInqYsize(grid);
   
   if ( nmiss > 0 )
     {
-      array2 = (double*) malloc(nx*sizeof(double));
+      double *array2 = (double*) Malloc(nx*sizeof(double));
       
       for ( j = 0; j < ny; j++ )
         {
@@ -432,7 +483,7 @@ void zonpctl(field_t field1, field_t *field2, int p)
 	    
           if ( l > 0 )
             {
-              field2->ptr[j] = nth_element(array2, l, (int)ceil(l*(p/100.0))-1);
+              field2->ptr[j] = percentile(array2, l, p);
             }
           else
             {
@@ -441,7 +492,7 @@ void zonpctl(field_t field1, field_t *field2, int p)
             }
         }
         
-      free(array2);
+      Free(array2);
     }
   else
     {
@@ -449,7 +500,7 @@ void zonpctl(field_t field1, field_t *field2, int p)
         {
           if ( nx > 0 )
             {
-              field2->ptr[j] = nth_element(&array[j*nx], nx, (int)ceil(nx*(p/100.0))-1);
+              field2->ptr[j] = percentile(&array[j*nx], nx, p);
             }
           else
             {
diff --git a/src/functs.h b/src/functs.h
index 7bf0ea2..444d123 100644
--- a/src/functs.h
+++ b/src/functs.h
@@ -48,12 +48,11 @@
 #define  func_lat      99
 
 enum cmp_flag {
-  CMP_CODE     = 1,
-  CMP_NAME     = 2,
-  CMP_GRID     = 4,
-  CMP_NLEVEL   = 8,
-  CMP_GRIDSIZE = 16,
-  CMP_HRD      = CMP_CODE | CMP_GRIDSIZE,
+  CMP_NAME     = 1,
+  CMP_GRID     = 2,
+  CMP_NLEVEL   = 4,
+  CMP_GRIDSIZE = 8,
+  CMP_HRD      = CMP_NAME | CMP_GRIDSIZE,
   CMP_DIM      =            CMP_GRIDSIZE | CMP_NLEVEL | CMP_GRID,
   CMP_ALL      = CMP_NAME | CMP_GRIDSIZE | CMP_NLEVEL | CMP_GRID
 };
diff --git a/src/gradsdeslib.c b/src/gradsdeslib.c
index 9d47b25..7dcb47a 100644
--- a/src/gradsdeslib.c
+++ b/src/gradsdeslib.c
@@ -137,7 +137,7 @@ gaint i,y;
 
   i = y / 4;
   i = (i*4) - y;
-  if (i!=0) return (0);
+  if (i!=0) return 0;
 
   i = y / 100;
   i = (i*100) - y;
@@ -145,7 +145,7 @@ gaint i,y;
 
   i = y / 400;
   i = (i*400) - y;
-  if (i!=0) return (0);
+  if (i!=0) return 0;
 
   return (1);
 }
@@ -350,7 +350,7 @@ gaint swap,mo1,mo2;
   else return (min2-min1);
 }
 
-static char *mons[12] = {"jan","feb","mar","apr","may","jun",
+static const char *mons[12] = {"jan","feb","mar","apr","may","jun",
                          "jul","aug","sep","oct","nov","dec"};
 
 /* Parse an absolute date/time value.  Format is:
@@ -527,7 +527,7 @@ char id[3];
    blank-delimited words in the two strings match.  CR and NULL also
    serve as delimiters.                                               */
 
-gaint cmpwrd (char *ch1, char *ch2) {
+gaint cmpwrd (const char *ch1, const char *ch2) {
 
   while (*ch1==' '||*ch1=='\t') ch1++;  /* Advance past leading blanks.     */
   while (*ch2==' '||*ch2=='\t') ch2++;
@@ -539,7 +539,7 @@ gaint cmpwrd (char *ch1, char *ch2) {
 
   if ( (*ch1==' '||*ch1=='\t'||*ch1=='\0'||*ch1=='\n'||*ch1=='\r') &&
        (*ch2==' '||*ch2=='\t'||*ch2=='\0'||*ch2=='\n'||*ch2=='\r') ) return (1);
-  return (0);
+  return 0;
 }
 
 
@@ -805,7 +805,7 @@ gaint deflin (char *ch, dsets_t *pfi, gaint dim, gaint flag) {
 gadouble *vals,v1,v2;
 
   vals = (gadouble *)galloc(sizeof(gadouble)*6,"vals1");
-  if (vals==NULL) return (-1);
+  if (vals==NULL) return -1;
 
   if ((ch = nxtwrd(ch))==NULL) goto err1;
   if (getdbl(ch,&v1)==NULL) goto err1;
@@ -826,7 +826,7 @@ gadouble *vals,v1,v2;
   pfi->ab2gr[dim] = liconv;
   pfi->gr2ab[dim] = liconv;
   pfi->linear[dim] = 1;
-  return (0);
+  return 0;
 
 err1:
   gaprnt (0,"Open Error:  Missing or invalid dimension");
@@ -854,7 +854,7 @@ gaint i;
   }
 
   vals = (gadouble *)galloc((pfi->dnum[dim]+5)*sizeof(gadouble),"vals2");
-  if (vals==NULL) return (-1);
+  if (vals==NULL) return -1;
 
   vvs = vals;
   *vvs = (gadouble)pfi->dnum[dim];
@@ -876,7 +876,7 @@ gaint i;
   pfi->ab2gr[dim] = lev2gr;
   pfi->gr2ab[dim] = gr2lev;
   pfi->linear[dim] = 0;
-  return (0);
+  return 0;
 
 err1:
   gaprnt (0,"Open Error:  Invalid value in LEVELS data\n");
@@ -1252,7 +1252,7 @@ int read_gradsdes(char *filename, dsets_t *pfi)
   if ( descr == NULL )
     {
       fprintf(stderr, "fopen failed on %s", filename);
-      return (-1);
+      return -1;
     }
 
   /* Copy descriptor file name into gafile structure */
@@ -2054,7 +2054,7 @@ int read_gradsdes(char *filename, dsets_t *pfi)
   } 
   else {
     fprintf(stderr, "Grid data type unsupported!");
-    return (-1);
+    return -1;
   }
 
 /* set the global calendar and check if we are trying to change with a new file...
diff --git a/src/gradsdeslib.h b/src/gradsdeslib.h
index 49168f0..d300ca0 100644
--- a/src/gradsdeslib.h
+++ b/src/gradsdeslib.h
@@ -162,7 +162,7 @@ void gr2t (gadouble *, gadouble, struct dt *);
 char *gafndt (char *, struct dt *, struct dt *, gadouble *, 
               struct gachsub *, struct gaens *, gaint, gaint, gaint *);
 
-gaint cmpwrd (char *ch1, char *ch2);
+gaint cmpwrd (const char *ch1, const char *ch2);
 char *intprs (char *ch, int *val);
 void gabswp (void *r, gaint cnt);
 void gabswp2 (void *r, gaint cnt);
diff --git a/src/grid.c b/src/grid.c
index f5cd0d2..ce90efe 100644
--- a/src/grid.c
+++ b/src/grid.c
@@ -41,12 +41,10 @@ int referenceToGrid(int gridID1);
 static
 void scale_vec(double scalefactor, long nvals, double *restrict values)
 {
-  long n;
-
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) shared(nvals, scalefactor, values)
 #endif
-  for ( n = 0; n < nvals; ++n )
+  for ( long n = 0; n < nvals; ++n )
     {
       values[n] *= scalefactor;
     }
@@ -109,12 +107,12 @@ int gridToZonal(int gridID1)
 
       if ( gridInqYvals(gridID1, NULL) )
 	{
-	  yvals = (double*) malloc(gridsize*sizeof(double));
+	  yvals = (double*) Malloc(gridsize*sizeof(double));
 
 	  gridInqYvals(gridID1, yvals);
 	  gridDefYvals(gridID2, yvals);
 
-	  free(yvals);
+	  Free(yvals);
 	}
     }
   else
@@ -146,12 +144,12 @@ int gridToMeridional(int gridID1)
 
       if ( gridInqXvals(gridID1, NULL) )
 	{
-	  xvals = (double*) malloc(gridsize*sizeof(double));
+	  xvals = (double*) Malloc(gridsize*sizeof(double));
 
 	  gridInqXvals(gridID1, xvals);
 	  gridDefXvals(gridID2, xvals);
 
-	  free(xvals);
+	  Free(xvals);
 	}
 
       gridDefYvals(gridID2, &yval);
@@ -165,9 +163,9 @@ int gridToMeridional(int gridID1)
 }
 
 
-void grid_gen_corners(long n, const double* restrict vals, double* restrict corners)
+void grid_gen_corners(int n, const double* restrict vals, double* restrict corners)
 {
-  long i;
+  int i;
 
   if ( n == 1 )
     {
@@ -185,11 +183,9 @@ void grid_gen_corners(long n, const double* restrict vals, double* restrict corn
 }
 
 
-void grid_gen_bounds(long n, const double* restrict vals, double* restrict bounds)
+void grid_gen_bounds(int n, const double *restrict vals, double *restrict bounds)
 {
-  long i;
-
-  for ( i = 0; i < n-1; ++i )
+  for ( int i = 0; i < n-1; ++i )
     {
       bounds[2*i+1]   = 0.5*(vals[i] + vals[i+1]);
       bounds[2*(i+1)] = 0.5*(vals[i] + vals[i+1]);
@@ -380,23 +376,23 @@ void gridGenRotBounds(int gridID, int nx, int ny,
     }
 }
 
-static
-void gridGenXbounds2D(long nx, long ny, const double* restrict xbounds, double* restrict xbounds2D)
+
+void grid_gen_xbounds2D(int nx, int ny, const double *restrict xbounds, double *restrict xbounds2D)
 {
-  long i, j, index;
+  int index;
   double minlon, maxlon;
 
 #if defined(_OPENMP)
 #pragma omp parallel for default(none)        \
-  shared(nx, ny, xbounds, xbounds2D)	      \
-  private(i, j, minlon, maxlon, index)
+                          shared(nx, ny, xbounds, xbounds2D) \
+                         private(minlon, maxlon, index)
 #endif
-  for ( i = 0; i < nx; ++i )
+  for ( int i = 0; i < nx; ++i )
     {
       minlon = xbounds[2*i  ];
       maxlon = xbounds[2*i+1];
 
-      for ( j = 0; j < ny; ++j )
+      for ( int j = 0; j < ny; ++j )
 	{
 	  index = j*4*nx + 4*i;
 	  xbounds2D[index  ] = minlon;
@@ -407,18 +403,18 @@ void gridGenXbounds2D(long nx, long ny, const double* restrict xbounds, double*
     }
 }
 
-static
-void gridGenYbounds2D(long nx, long ny, const double* restrict ybounds, double* restrict ybounds2D)
+
+void grid_gen_ybounds2D(int nx, int ny, const double *restrict ybounds, double *restrict ybounds2D)
 {
-  long i, j, index;
+  int index;
   double minlat, maxlat;
 
 #if defined(_OPENMP)
 #pragma omp parallel for default(none)        \
-  shared(nx, ny, ybounds, ybounds2D)	      \
-  private(i, j, minlat, maxlat, index)
+                          shared(nx, ny, ybounds, ybounds2D) \
+                         private(minlat, maxlat, index)
 #endif
-  for ( j = 0; j < ny; ++j )
+  for ( int j = 0; j < ny; ++j )
     {
       if ( ybounds[0] > ybounds[1] )
 	{
@@ -431,7 +427,7 @@ void gridGenYbounds2D(long nx, long ny, const double* restrict ybounds, double*
 	  minlat = ybounds[2*j  ];
 	}
 
-      for ( i = 0; i < nx; ++i )
+      for ( int i = 0; i < nx; ++i )
 	{
 	  index = j*4*nx + 4*i;
 	  ybounds2D[index  ] = minlat;
@@ -457,7 +453,7 @@ char *gen_param(const char *fmt, ...)
   va_end(args);
 
   len++;
-  rstr = (char*) malloc(len*sizeof(char));
+  rstr = (char*) Malloc(len*sizeof(char));
   memcpy(rstr, str, len*sizeof(char));
 
   return (rstr);
@@ -503,36 +499,38 @@ static
 void sinusoidal_to_geo(int gridsize, double *xvals, double *yvals)
 {
 #if defined(HAVE_LIBPROJ)
-  projPJ   *libProj;
   char *params[20];
-  int nbpar=0;
   projUV data, res;
   long i;
 
-  nbpar = 0;
-  params[nbpar++] = (char*) "proj=sinu";
-  params[nbpar++] = (char*) "ellps=WGS84";
+  int nbpar = 0;
+  params[nbpar++] = gen_param("proj=sinu");
+  params[nbpar++] = gen_param("ellps=WGS84");
 
   if ( cdoVerbose )
     for ( i = 0; i < nbpar; ++i )
       cdoPrint("Proj.param[%ld] = %s", i+1, params[i]);
 
-  libProj = pj_init(nbpar, params);
-  if ( !libProj )
+  projPJ proj = pj_init(nbpar, params);
+  if ( !proj )
     cdoAbort("proj error: %s", pj_strerrno(pj_errno));
 
-  /* libProj->over = 1; */		/* allow longitude > 180� */
+  for ( i = 0; i < nbpar; ++i ) Free(params[i]);
+
+  /* proj->over = 1; */		/* allow longitude > 180 */
 
   for ( i = 0; i < gridsize; i++ )
     {
       data.u = xvals[i];
       data.v = yvals[i];
-      res = pj_inv(data, libProj);
+      res = pj_inv(data, proj);
       xvals[i] = res.u*RAD2DEG;
       yvals[i] = res.v*RAD2DEG;
       if ( xvals[i] < -9000. || xvals[i] > 9000. ) xvals[i] = -9999.;
       if ( yvals[i] < -9000. || yvals[i] > 9000. ) yvals[i] = -9999.;
     }
+
+  pj_free(proj);
 #else
   cdoAbort("proj4 support not compiled in!");
 #endif
@@ -542,16 +540,14 @@ static
 void laea_to_geo(int gridID, int gridsize, double *xvals, double *yvals)
 {
 #if defined(HAVE_LIBPROJ)
-  projPJ   *libProj;
   char *params[20];
-  int nbpar=0;
   projUV data, res;
   double a, lon_0, lat_0;
   long i;
 
   gridInqLaea(gridID, &a , &lon_0, &lat_0);
 
-  nbpar = 0;
+  int nbpar = 0;
   params[nbpar++] = gen_param("proj=laea");
   if ( a > 0 ) params[nbpar++] = gen_param("a=%g", a);
   params[nbpar++] = gen_param("lon_0=%g", lon_0);
@@ -561,24 +557,26 @@ void laea_to_geo(int gridID, int gridsize, double *xvals, double *yvals)
     for ( i = 0; i < nbpar; ++i )
       cdoPrint("Proj.param[%d] = %s", i+1, params[i]);
 
-  libProj = pj_init(nbpar, &params[0]);
-  if ( !libProj )
+  projPJ proj = pj_init(nbpar, &params[0]);
+  if ( !proj )
     cdoAbort("proj error: %s", pj_strerrno(pj_errno));
 
-  for ( i = 0; i < nbpar; ++i ) free(params[i]);
+  for ( i = 0; i < nbpar; ++i ) Free(params[i]);
 
-  /* libProj->over = 1; */		/* allow longitude > 180� */
+  /* proj->over = 1; */		/* allow longitude > 180 */
 
   for ( i = 0; i < gridsize; i++ )
     {
       data.u = xvals[i];
       data.v = yvals[i];
-      res = pj_inv(data, libProj);
+      res = pj_inv(data, proj);
       xvals[i] = res.u*RAD2DEG;
       yvals[i] = res.v*RAD2DEG;
       if ( xvals[i] < -9000. || xvals[i] > 9000. ) xvals[i] = -9999.;
       if ( yvals[i] < -9000. || yvals[i] > 9000. ) yvals[i] = -9999.;
     }
+
+  pj_free(proj);
 #else
   cdoAbort("proj4 support not compiled in!");
 #endif
@@ -588,16 +586,14 @@ static
 void lcc2_to_geo(int gridID, int gridsize, double *xvals, double *yvals)
 {
 #if defined(HAVE_LIBPROJ)
-  projPJ   *libProj;
   char *params[20];
-  int nbpar=0;
   projUV data, res;
   double a, lon_0, lat_0, lat_1, lat_2;
   long i;
 
   gridInqLcc2(gridID, &a , &lon_0, &lat_0, &lat_1, &lat_2);
 
-  nbpar = 0;
+  int nbpar = 0;
   params[nbpar++] = gen_param("proj=lcc");
   if ( a > 0 ) params[nbpar++] = gen_param("a=%g", a);
   params[nbpar++] = gen_param("lon_0=%g", lon_0);
@@ -609,22 +605,24 @@ void lcc2_to_geo(int gridID, int gridsize, double *xvals, double *yvals)
     for ( i = 0; i < nbpar; ++i )
       cdoPrint("Proj.param[%d] = %s", i+1, params[i]);
   
-  libProj = pj_init(nbpar, &params[0]);
-  if ( !libProj )
+  projPJ proj = pj_init(nbpar, &params[0]);
+  if ( !proj )
     cdoAbort("proj error: %s", pj_strerrno(pj_errno));
 
-  for ( i = 0; i < nbpar; ++i ) free(params[i]);
+  for ( i = 0; i < nbpar; ++i ) Free(params[i]);
 
-  /* libProj->over = 1; */		/* allow longitude > 180� */
+  /* proj->over = 1; */		/* allow longitude > 180 */
   
   for ( i = 0; i < gridsize; i++ )
     {
       data.u = xvals[i];
       data.v = yvals[i];
-      res = pj_inv(data, libProj);
+      res = pj_inv(data, proj);
       xvals[i] = res.u*RAD2DEG;
       yvals[i] = res.v*RAD2DEG;
     }
+
+  pj_free(proj);
 #else
   cdoAbort("proj4 support not compiled in!");
 #endif
@@ -726,8 +724,8 @@ int qu2reg_subarea(int gridsize, int np, double xfirst, double xlast,
 
   for ( j = 0; j < ny; ++j ) nwork += rowlon[j];
 
-  pwork = (double **) malloc(ny*sizeof(double *));
-  work  = (double*) malloc(ny*np4*sizeof(double));
+  pwork = (double **) Malloc(ny*sizeof(double *));
+  work  = (double*) Malloc(ny*np4*sizeof(double));
   wlen = 0;
   pwork[0] = work;
   for ( j = 1; j < ny; ++j )
@@ -786,8 +784,8 @@ int qu2reg_subarea(int gridsize, int np, double xfirst, double xlast,
 	}
     }
 
-  free(work);
-  free(pwork);
+  Free(work);
+  Free(pwork);
 
   return (nx);
 }
@@ -814,7 +812,7 @@ void field2regular(int gridID1, int gridID2, double missval, double *array, int
   ny = gridInqYsize(gridID1);
   np = gridInqNP(gridID1);
 
-  rowlon = (int*) malloc(ny*sizeof(int));
+  rowlon = (int*) Malloc(ny*sizeof(int));
   gridInqRowlon(gridID1, rowlon);
 
   xfirstandlast[0] = 0.;
@@ -835,7 +833,7 @@ void field2regular(int gridID1, int gridID2, double missval, double *array, int
 
   if ( gridInqSize(gridID2) != nx*ny ) Error("Gridsize differ!");
 
-  free(rowlon);
+  Free(rowlon);
 }
 
 
@@ -856,7 +854,7 @@ int gridToRegular(int gridID1)
   ny = gridInqYsize(gridID1);
   np = gridInqNP(gridID1);
 
-  yvals = (double*) malloc(ny*sizeof(double));
+  yvals = (double*) Malloc(ny*sizeof(double));
   gridInqYvals(gridID1, yvals);
 
   xfirstandlast[0] = 0.;
@@ -878,19 +876,19 @@ int gridToRegular(int gridID1)
       grib_get_reduced_row(np4, xfirst, xlast, &row_count, &ilon_first, &ilon_last);
 
       nx = row_count;
-      xvals = (double*) malloc(nx*sizeof(double));
+      xvals = (double*) Malloc(nx*sizeof(double));
       for ( i = 0; i < nx; ++i )
 	{
 	  xvals[i] = ((ilon_first+i)*360.)/np4;
 	  if ( xfirst > xlast ) xvals[i] -= 360.;
 	}
 
-      free(rowlon);
+      Free(rowlon);
     }
   else
     {
       nx = 2*ny;
-      xvals = (double*) malloc(nx*sizeof(double));
+      xvals = (double*) Malloc(nx*sizeof(double));
       for ( i = 0; i < nx; ++i ) xvals[i] = i * 360./nx;
     }
 
@@ -905,8 +903,8 @@ int gridToRegular(int gridID1)
   gridDefYvals(gridID2, yvals);
   gridDefNP(gridID2, np);
 
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
 
   return (gridID2);
 }
@@ -917,10 +915,10 @@ void gridCopyMask(int gridID1, int gridID2, long gridsize)
   if ( gridInqMask(gridID1, NULL) )
     {
       int *mask;
-      mask = (int*) malloc(gridsize*sizeof(int));
+      mask = (int*) Malloc(gridsize*sizeof(int));
       gridInqMask(gridID1, mask);
       gridDefMask(gridID2, mask);
-      free(mask);
+      Free(mask);
     }
 }
 
@@ -945,13 +943,11 @@ int check_range(long n, double *vals, double valid_min, double valid_max)
 
 int gridToCurvilinear(int gridID1, int lbounds)
 {
-  int gridID2;
-  int gridtype, gridsize;
   long index;
 
-  gridtype = gridInqType(gridID1);
-  gridsize = gridInqSize(gridID1);
-  gridID2  = gridCreate(GRID_CURVILINEAR, gridsize);
+  int gridtype = gridInqType(gridID1);
+  size_t gridsize = (size_t) gridInqSize(gridID1);
+  int gridID2  = gridCreate(GRID_CURVILINEAR, (int) gridsize);
   gridDefPrec(gridID2, DATATYPE_FLT32);
 	  
   switch (gridtype)
@@ -964,7 +960,6 @@ int gridToCurvilinear(int gridID1, int lbounds)
     case GRID_SINUSOIDAL:
       {
 	long i, j;
-	int nx, ny;
 	double *xvals = NULL, *yvals = NULL;
 	double *xvals2D, *yvals2D;
 	double *xbounds = NULL, *ybounds = NULL;
@@ -972,8 +967,8 @@ int gridToCurvilinear(int gridID1, int lbounds)
 	char xunits[CDI_MAX_NAME], yunits[CDI_MAX_NAME];
 	double xscale = 1, yscale = 1;
 
-	nx = gridInqXsize(gridID1);
-	ny = gridInqYsize(gridID1);
+	int nx = gridInqXsize(gridID1);
+	int ny = gridInqYsize(gridID1);
 
 	gridInqXunits(gridID1, xunits);
 	gridInqYunits(gridID1, yunits);
@@ -1002,8 +997,8 @@ int gridToCurvilinear(int gridID1, int lbounds)
 	gridDefXsize(gridID2, nx);
 	gridDefYsize(gridID2, ny);
 
-	xvals2D = (double*) malloc(gridsize*sizeof(double));
-	yvals2D = (double*) malloc(gridsize*sizeof(double));
+	xvals2D = (double*) Malloc(gridsize*sizeof(double));
+	yvals2D = (double*) Malloc(gridsize*sizeof(double));
 
 
 	if ( gridtype == GRID_LCC )
@@ -1022,8 +1017,8 @@ int gridToCurvilinear(int gridID1, int lbounds)
 	    if ( ! (gridInqXvals(gridID1, NULL) && gridInqYvals(gridID1, NULL)) )
 	      Error("Grid has no values");
 
-	    xvals = (double*) malloc(nx*sizeof(double));
-	    yvals = (double*) malloc(ny*sizeof(double));
+	    xvals = (double*) Malloc(nx*sizeof(double));
+	    yvals = (double*) Malloc(ny*sizeof(double));
 
 	    gridInqXvals(gridID1, xvals);
 	    gridInqYvals(gridID1, yvals);
@@ -1071,15 +1066,15 @@ int gridToCurvilinear(int gridID1, int lbounds)
 	gridDefXvals(gridID2, xvals2D);
 	gridDefYvals(gridID2, yvals2D);
 
-	if ( xvals2D ) free(xvals2D);
-	if ( yvals2D ) free(yvals2D);
+	if ( xvals2D ) Free(xvals2D);
+	if ( yvals2D ) Free(yvals2D);
 
 	if ( !lbounds ) goto NO_BOUNDS;
 
 	if ( gridtype == GRID_LCC )
 	  {		
-	    xbounds2D = (double*) malloc(4*gridsize*sizeof(double));
-	    ybounds2D = (double*) malloc(4*gridsize*sizeof(double));
+	    xbounds2D = (double*) Malloc(4*gridsize*sizeof(double));
+	    ybounds2D = (double*) Malloc(4*gridsize*sizeof(double));
 
 	    for ( j = 0; j < ny; j++ )
 	      for ( i = 0; i < nx; i++ )
@@ -1104,44 +1099,44 @@ int gridToCurvilinear(int gridID1, int lbounds)
 	    gridDefXbounds(gridID2, xbounds2D);
 	    gridDefYbounds(gridID2, ybounds2D);
 
-	    free(xbounds2D);
-	    free(ybounds2D);
+	    Free(xbounds2D);
+	    Free(ybounds2D);
 	  }
 	else
 	  {
 	    if ( gridInqXbounds(gridID1, NULL) )
 	      {
-		xbounds = (double*) malloc(2*nx*sizeof(double));
+		xbounds = (double*) Malloc(2*nx*sizeof(double));
 		gridInqXbounds(gridID1, xbounds);
 		if ( gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN )
 		  if ( check_range(2*nx, xbounds, -720, 720) )
 		    {
 		      cdoWarning("longitude bounds out of range, skipped!");
-		      free(xbounds);
+		      Free(xbounds);
 		      xbounds = NULL;
 		    }
 	      }
 	    else if ( nx > 1 )
 	      {
-		xbounds = (double*) malloc(2*nx*sizeof(double));
+		xbounds = (double*) Malloc(2*nx*sizeof(double));
 		grid_gen_bounds(nx, xvals, xbounds);
 	      }
 
 	    if ( gridInqYbounds(gridID1, NULL) )
 	      {
-		ybounds = (double*) malloc(2*ny*sizeof(double));
+		ybounds = (double*) Malloc(2*ny*sizeof(double));
 		gridInqYbounds(gridID1, ybounds);
 		if ( gridtype == GRID_LONLAT || gridtype == GRID_GAUSSIAN )
 		  if ( check_range(2*ny, ybounds, -180, 180) )
 		    {
 		      cdoWarning("latitude bounds out of range, skipped!");
-		      free(ybounds);
+		      Free(ybounds);
 		      ybounds = NULL;
 		    }
 	      }
 	    else if ( ny > 1 )
 	      {
-		ybounds = (double*) malloc(2*ny*sizeof(double));
+		ybounds = (double*) Malloc(2*ny*sizeof(double));
 		if ( gridtype == GRID_SINUSOIDAL || 
 		     gridtype == GRID_LAEA       || 
 		     gridtype == GRID_LCC2 )
@@ -1155,8 +1150,8 @@ int gridToCurvilinear(int gridID1, int lbounds)
 
 	    if ( xbounds && ybounds )
 	      {
-		xbounds2D = (double*) malloc(4*gridsize*sizeof(double));
-		ybounds2D = (double*) malloc(4*gridsize*sizeof(double));
+		xbounds2D = (double*) Malloc(4*gridsize*sizeof(double));
+		ybounds2D = (double*) Malloc(4*gridsize*sizeof(double));
 
 		if ( gridIsRotated(gridID1) )
 		  {
@@ -1190,14 +1185,14 @@ int gridToCurvilinear(int gridID1, int lbounds)
 			  {
 			    sinusoidal_to_geo(4*gridsize, xbounds2D, ybounds2D);
 			    /*
-			    xvals2D = (double*) malloc(gridsize*sizeof(double));
+			    xvals2D = (double*) Malloc(gridsize*sizeof(double));
 			    for ( j = 0; j < 4; ++j )
 			      {
 				for ( i = 0; i < gridsize; ++i ) xvals2D[i] = xbounds2D[i*4+j];
 				correct_sinxvals(nx, ny, xvals2D);
 				for ( i = 0; i < gridsize; ++i ) xbounds2D[i*4+j] = xvals2D[i];
 			      }
-			    free(xvals2D);
+			    Free(xvals2D);
 			    */
 			  }
 			else if ( gridtype == GRID_LAEA )
@@ -1207,25 +1202,25 @@ int gridToCurvilinear(int gridID1, int lbounds)
 		      }
 		    else
 		      {
-			gridGenXbounds2D(nx, ny, xbounds, xbounds2D);
-			gridGenYbounds2D(nx, ny, ybounds, ybounds2D);
+			grid_gen_xbounds2D(nx, ny, xbounds, xbounds2D);
+			grid_gen_ybounds2D(nx, ny, ybounds, ybounds2D);
 		      }
 		  }
 		
 		gridDefXbounds(gridID2, xbounds2D);
 		gridDefYbounds(gridID2, ybounds2D);
 		
-		if ( xbounds )  free(xbounds);
-		if ( ybounds )  free(ybounds);
-		if ( xbounds2D) free(xbounds2D);
-		if ( ybounds2D) free(ybounds2D);
+		if ( xbounds )  Free(xbounds);
+		if ( ybounds )  Free(ybounds);
+		if ( xbounds2D) Free(xbounds2D);
+		if ( ybounds2D) Free(ybounds2D);
 	      }
 	  }
 
       NO_BOUNDS:
 
-	if ( xvals ) free(xvals);
-	if ( yvals ) free(yvals);
+	if ( xvals ) Free(xvals);
+	if ( yvals ) Free(yvals);
 
 	gridCopyMask(gridID1, gridID2, gridsize);
 
@@ -1277,11 +1272,11 @@ int gridToUnstructured(int gridID1, int lbounds)
 	gridDefXsize(gridID2, gridsize);
 	gridDefYsize(gridID2, gridsize);
 
-	xvals = (double*) malloc(nx*sizeof(double));
-	yvals = (double*) malloc(ny*sizeof(double));
+	xvals = (double*) Malloc(nx*sizeof(double));
+	yvals = (double*) Malloc(ny*sizeof(double));
 
-	xvals2D = (double*) malloc(gridsize*sizeof(double));
-	yvals2D = (double*) malloc(gridsize*sizeof(double));
+	xvals2D = (double*) Malloc(gridsize*sizeof(double));
+	yvals2D = (double*) Malloc(gridsize*sizeof(double));
 
 	gridInqXvals(gridID1, xvals);
 	gridInqYvals(gridID1, yvals);
@@ -1314,8 +1309,8 @@ int gridToUnstructured(int gridID1, int lbounds)
 	gridDefXvals(gridID2, xvals2D);
 	gridDefYvals(gridID2, yvals2D);
 
-	free(xvals2D);
-	free(yvals2D);
+        Free(xvals2D);
+        Free(yvals2D);
 
 	if ( lbounds )
 	  {
@@ -1324,31 +1319,31 @@ int gridToUnstructured(int gridID1, int lbounds)
 
 	    if ( gridInqXbounds(gridID1, NULL) )
 	      {
-		xbounds = (double*) malloc(2*nx*sizeof(double));
+		xbounds = (double*) Malloc(2*nx*sizeof(double));
 		gridInqXbounds(gridID1, xbounds);
 	      }
 	    else if ( nx > 1 )
 	      {
-		xbounds = (double*) malloc(2*nx*sizeof(double));
+		xbounds = (double*) Malloc(2*nx*sizeof(double));
 		grid_gen_bounds(nx, xvals, xbounds);
 	      }
 
 	    if ( gridInqYbounds(gridID1, NULL) )
 	      {
-		ybounds = (double*) malloc(2*ny*sizeof(double));
+		ybounds = (double*) Malloc(2*ny*sizeof(double));
 		gridInqYbounds(gridID1, ybounds);
 	      }
 	    else if ( ny > 1 )
 	      {
-		ybounds = (double*) malloc(2*ny*sizeof(double));
+		ybounds = (double*) Malloc(2*ny*sizeof(double));
 		grid_gen_bounds(ny, yvals, ybounds);
 		grid_check_lat_borders(2*ny, ybounds);
 	      }
 
 	    if ( xbounds && ybounds )
 	      {
-		xbounds2D = (double*) malloc(4*gridsize*sizeof(double));
-		ybounds2D = (double*) malloc(4*gridsize*sizeof(double));
+		xbounds2D = (double*) Malloc(4*gridsize*sizeof(double));
+		ybounds2D = (double*) Malloc(4*gridsize*sizeof(double));
 
 		if ( gridIsRotated(gridID1) )
 		  {
@@ -1356,22 +1351,22 @@ int gridToUnstructured(int gridID1, int lbounds)
 		  }
 		else
 		  {
-		    gridGenXbounds2D(nx, ny, xbounds, xbounds2D);
-		    gridGenYbounds2D(nx, ny, ybounds, ybounds2D);
+		    grid_gen_xbounds2D(nx, ny, xbounds, xbounds2D);
+		    grid_gen_ybounds2D(nx, ny, ybounds, ybounds2D);
 		  }
 
 		gridDefXbounds(gridID2, xbounds2D);
 		gridDefYbounds(gridID2, ybounds2D);
 
-		free(xbounds);
-		free(ybounds);
-		free(xbounds2D);
-		free(ybounds2D);
+                Free(xbounds);
+                Free(ybounds);
+                Free(xbounds2D);
+                Free(ybounds2D);
 	      }
 	    }
 
-	free(xvals);
-	free(yvals);
+        Free(xvals);
+        Free(yvals);
 
 	gridCopyMask(gridID1, gridID2, gridsize);
 
@@ -1400,13 +1395,13 @@ int gridToUnstructured(int gridID1, int lbounds)
 	ni2 = gridInqGMEni2(gridID1);
 	ni3 = gridInqGMEni3(gridID1);
 
-	imask   = (int*) malloc(gridsize*sizeof(int));
-	xvals   = (double*) malloc(gridsize*sizeof(double));
-	yvals   = (double*) malloc(gridsize*sizeof(double));
+	imask   = (int*) Malloc(gridsize*sizeof(int));
+	xvals   = (double*) Malloc(gridsize*sizeof(double));
+	yvals   = (double*) Malloc(gridsize*sizeof(double));
 	if ( lbounds )
 	  {
-	    xbounds = (double*) malloc(nv*gridsize*sizeof(double));
-	    ybounds = (double*) malloc(nv*gridsize*sizeof(double));
+	    xbounds = (double*) Malloc(nv*gridsize*sizeof(double));
+	    ybounds = (double*) Malloc(nv*gridsize*sizeof(double));
 	  }
 
 	gme_grid(lbounds, gridsize, xvals, yvals, xbounds, ybounds, imask, ni, nd, ni2, ni3);
@@ -1444,11 +1439,11 @@ int gridToUnstructured(int gridID1, int lbounds)
 	gridDefXunits(gridID2, "degrees_east");
 	gridDefYunits(gridID2, "degrees_north");
 
-	free (imask);
-	free (xvals);
-	free (yvals);
-	if ( xbounds ) free (xbounds);
-	if ( ybounds ) free (ybounds);
+        Free(imask);
+        Free(xvals);
+        Free(yvals);
+	if ( xbounds ) Free(xbounds);
+	if ( ybounds ) Free(ybounds);
 	
 	gridCopyMask(gridID1, gridID2, gridsize);
 
@@ -1483,14 +1478,14 @@ int gridCurvilinearToRegular(int gridID1)
   nx = gridInqXsize(gridID1);
   ny = gridInqYsize(gridID1);
 	
-  xvals2D = (double*) malloc(gridsize*sizeof(double));
-  yvals2D = (double*) malloc(gridsize*sizeof(double));
+  xvals2D = (double*) Malloc(gridsize*sizeof(double));
+  yvals2D = (double*) Malloc(gridsize*sizeof(double));
 
   gridInqXvals(gridID1, xvals2D);
   gridInqYvals(gridID1, yvals2D);
 
-  xvals = (double*) malloc(nx*sizeof(double));
-  yvals = (double*) malloc(ny*sizeof(double));
+  xvals = (double*) Malloc(nx*sizeof(double));
+  yvals = (double*) Malloc(ny*sizeof(double));
 
   for ( i = 0; i < nx; i++ ) xvals[i] = xvals2D[i];
   for ( j = 0; j < ny; j++ ) yvals[j] = yvals2D[j*nx];
@@ -1517,8 +1512,8 @@ int gridCurvilinearToRegular(int gridID1)
 	  }
       }
 
-  free(xvals2D);
-  free(yvals2D);
+  Free(xvals2D);
+  Free(yvals2D);
 
   if ( lx && ly )
     {
@@ -1540,8 +1535,8 @@ int gridCurvilinearToRegular(int gridID1)
       gridDefYvals(gridID2, yvals);
     }
 
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
 
   return (gridID2);
 }
@@ -1560,7 +1555,7 @@ int gridGenWeights(int gridID, double *grid_area, double *grid_wgts)
   if ( gridtype == GRID_GME )
     {
       gridID = gridToUnstructured(gridID, 1);	  
-      grid_mask = (int*) malloc(gridsize*sizeof(int));
+      grid_mask = (int*) Malloc(gridsize*sizeof(int));
       gridInqMaskGME(gridID, grid_mask);
     }
 
@@ -1588,7 +1583,7 @@ int gridGenWeights(int gridID, double *grid_area, double *grid_wgts)
       grid_wgts[i] = grid_area[i] / total_area;
     }
   
-  if ( grid_mask ) free(grid_mask);
+  if ( grid_mask ) Free(grid_mask);
 
   return (status);
 }
@@ -1621,8 +1616,8 @@ int gridWeightsOld(int gridID, double *weights)
 	  nlon = gridInqXsize(gridID);
 	  nlat = gridInqYsize(gridID);
 
-	  lons = 1 + (double *) malloc((nlon+2)*sizeof(double));
-	  lats = 1 + (double *) malloc((nlat+2)*sizeof(double));
+	  lons = 1 + (double *) Malloc((nlon+2)*sizeof(double));
+	  lats = 1 + (double *) Malloc((nlat+2)*sizeof(double));
 
 	  gridInqXvals(gridID, lons);
 	  gridInqYvals(gridID, lats);
@@ -1666,8 +1661,8 @@ int gridWeightsOld(int gridID, double *weights)
 	  if( IS_NOT_EQUAL(sumw, 0) )
 	    for( i = 0; i < datapoint; i++ ) weights[i] /= sumw;
 
-	  if ( lons-1 ) free(lons-1);
-	  if ( lats-1 ) free(lats-1);
+	  if ( lons-1 ) Free(lons-1);
+	  if ( lats-1 ) Free(lats-1);
 	}
       else
 	{
@@ -1690,7 +1685,7 @@ int gridWeights(int gridID, double *grid_wgts)
   gridtype = gridInqType(gridID);
   gridsize = gridInqSize(gridID);
   
-  grid_area = (double*) malloc(gridsize*sizeof(double));
+  grid_area = (double*) Malloc(gridsize*sizeof(double));
 
   a_status = 0;
 
@@ -1734,7 +1729,7 @@ int gridWeights(int gridID, double *grid_wgts)
   for ( i = 0; i < gridsize; ++i ) 
     printf("weights: %d %d %d %g %g\n", a_status, w_status, i, grid_area[i], grid_wgts[i]);
   */
-  free(grid_area);
+  Free(grid_area);
 
   return (w_status);
 }
diff --git a/src/grid.h b/src/grid.h
index 9aa3fdb..6d542d1 100644
--- a/src/grid.h
+++ b/src/grid.h
@@ -1,6 +1,10 @@
 #ifndef _GRID_H
 #define _GRID_H
 
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
 #ifndef  M_PI
 #define  M_PI        3.14159265358979323846  /* pi */
 #endif
@@ -18,7 +22,13 @@
 void grid_to_radian(const char *units, long nvals, double *restrict values, const char *description);
 void grid_to_degree(const char *units, long nvals, double *restrict values, const char *description);
 
-void grid_gen_corners(long n, const double* restrict vals, double* restrict corners);
+void grid_gen_corners(int n, const double* restrict vals, double* restrict corners);
+void grid_gen_bounds(int n, const double *restrict vals, double *restrict bounds);
+void grid_check_lat_borders(int n, double *ybounds);
+
+void grid_gen_xbounds2D(int nx, int ny, const double *restrict xbounds, double *restrict xbounds2D);
+void grid_gen_ybounds2D(int nx, int ny, const double *restrict ybounds, double *restrict ybounds2D);
+
 void grid_cell_center_to_bounds_X2D(const char* xunitstr, long xsize, long ysize,
 				    const double* restrict grid_center_lon, double* restrict grid_corner_lon, double dlon);
 void grid_cell_center_to_bounds_Y2D(const char* yunitstr, long xsize, long ysize,
@@ -29,7 +39,7 @@ void gridGenYvals(int gridtype, int ysize, double yfirst, double ylast, double y
 
 int  gridWeights(int gridID, double *weights);
 int  gridGenArea(int gridID, double *area);
-void gaussaw(double pa[], double pw[], int nlat);
+void gaussaw(double pa[], double pw[], size_t nlat);
 
 int referenceToGrid(int gridID);
 int gridToZonal(int gridID);
diff --git a/src/grid_area.c b/src/grid_area.c
index 7b29b93..0c8e3ca 100644
--- a/src/grid_area.c
+++ b/src/grid_area.c
@@ -319,7 +319,7 @@ int gridGenArea(int gridID, double* area)
 	{
 	  lgriddestroy = TRUE;
 	  gridID = gridToUnstructured(gridID, 1);
-	  grid_mask = (int*) malloc(gridsize*sizeof(int));
+	  grid_mask = (int*) Malloc(gridsize*sizeof(int));
 	  gridInqMaskGME(gridID, grid_mask);
 	}
       else
@@ -369,14 +369,14 @@ int gridGenArea(int gridID, double* area)
   gridInqXunits(gridID, xunitstr);
   gridInqYunits(gridID, yunitstr);
 
-  grid_center_lon = (double*) malloc(gridsize*sizeof(double));
-  grid_center_lat = (double*) malloc(gridsize*sizeof(double));
+  grid_center_lon = (double*) Malloc(gridsize*sizeof(double));
+  grid_center_lat = (double*) Malloc(gridsize*sizeof(double));
 
   gridInqXvals(gridID, grid_center_lon);
   gridInqYvals(gridID, grid_center_lat);
 
-  grid_corner_lon = (double*) malloc(nv*gridsize*sizeof(double));
-  grid_corner_lat = (double*) malloc(nv*gridsize*sizeof(double));
+  grid_corner_lon = (double*) Malloc(nv*gridsize*sizeof(double));
+  grid_corner_lat = (double*) Malloc(nv*gridsize*sizeof(double));
 
   if ( gridInqYbounds(gridID, NULL) && gridInqXbounds(gridID, NULL) )
     {
@@ -415,11 +415,10 @@ int gridGenArea(int gridID, double* area)
   progressInit();
 
 #if defined(_OPENMP)
-#pragma omp parallel for default(none)        \
-  shared(findex, gridsize, area, nv, grid_corner_lon, grid_corner_lat, grid_center_lon, grid_center_lat) \
-  private(i)
+#pragma omp parallel for default(none)  \
+  shared(findex,gridsize,area,nv,grid_corner_lon,grid_corner_lat,grid_center_lon,grid_center_lat)
 #endif
-  for ( i = 0; i < gridsize; ++i )
+  for ( int i = 0; i < gridsize; ++i )
     {
       int lprogress = 1;
       if ( cdo_omp_get_thread_num() != 0 ) lprogress = 0;
@@ -444,11 +443,11 @@ int gridGenArea(int gridID, double* area)
       cdoPrint("Total area = %g steradians", total_area);
     }
 
-  free(grid_center_lon);
-  free(grid_center_lat);
-  free(grid_corner_lon);
-  free(grid_corner_lat);
-  if ( grid_mask ) free(grid_mask);
+  Free(grid_center_lon);
+  Free(grid_center_lat);
+  Free(grid_corner_lon);
+  Free(grid_corner_lat);
+  if ( grid_mask ) Free(grid_mask);
 
   return (status);
 }
diff --git a/src/grid_gme.c b/src/grid_gme.c
index 1507d22..f78535c 100644
--- a/src/grid_gme.c
+++ b/src/grid_gme.c
@@ -1,6 +1,4 @@
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
+#include "cdo_int.h"
 
 #ifndef M_PI
 #define M_PI		3.14159265358979323846	/* pi */
@@ -580,9 +578,9 @@ void xd(double *p, int kip1s, int kip1e, int kip2s, int kip2e, int knd,
   tmp9 = pxinfo.dim[1].mult;
   tmp10 = pxinfo.dim[2].mult;
   tmp8 = pxinfo.offset;
-  tmp1 = pxinfo.dim[0].extent;
-  tmp2 = pxinfo.dim[1].extent;
-  tmp6 = pxinfo.dim[2].extent;
+  //tmp1 = pxinfo.dim[0].extent;
+  //tmp2 = pxinfo.dim[1].extent;
+  //tmp6 = pxinfo.dim[2].extent;
   
   for(jd = 1;jd <= knd;jd++) {
     for(j2 = kip2s;j2 <= kip2e;j2++) {
@@ -758,7 +756,7 @@ void glo_coor(double *pxn, double *prlon, double *prlat,
    * icosahedral triangles into mni equal parts.                 
    */  
 
-  if ( (mcosv = (int*) malloc(knd*sizeof(int))) == NULL ) 
+  if ( (mcosv = (int*) Malloc(knd*sizeof(int))) == NULL ) 
     {
       perror("malloc mcosv");
       exit (-1);
@@ -977,7 +975,7 @@ void glo_coor(double *pxn, double *prlon, double *prlat,
         }
     }
   
-  free(mcosv);
+  Free(mcosv);
   
   return;
 } /* glo_coor */
@@ -989,7 +987,7 @@ void initmask(int *mask, int ni, int nd)
 {
   int jd;
 
-  int tmp1, tmp2, tmp3, tmp4, tmp5, tmp6, tmp7, tmp8, tmp9;
+  int tmp1, tmp2, /*tmp3, tmp4, tmp5,*/ tmp6, tmp7, tmp8, tmp9;
 
   int *ptmp1;
   char *ptmp2;
@@ -1019,9 +1017,9 @@ void initmask(int *mask, int ni, int nd)
   maskinfo.dim[2].extent = tmp1;
   maskinfo.dim[2].mult = tmp2;
   maskinfo.offset -= maskinfo.dim[2].mult;
-  tmp4 = maskinfo.dim[1].mult;
-  tmp5 = maskinfo.dim[2].mult;
-  tmp3 = maskinfo.offset;
+  //tmp4 = maskinfo.dim[1].mult;
+  //tmp5 = maskinfo.dim[2].mult;
+  //tmp3 = maskinfo.offset;
   tmp1 = maskinfo.dim[0].extent;
   tmp2 = maskinfo.dim[1].extent;
   tmp9 = maskinfo.dim[2].extent;
@@ -1341,9 +1339,9 @@ void gme_grid(int lbounds, int gridsize, double *rlon, double *rlat,
       exit (-1);
     }
 
-  xn    = (double*) malloc(gridsize*3*sizeof(double));
-  rlonx = (double*) malloc((ni+3)*(ni+3)*nd*sizeof(double));
-  rlatx = (double*) malloc((ni+3)*(ni+3)*nd*sizeof(double));
+  xn    = (double*) Malloc(gridsize*3*sizeof(double));
+  rlonx = (double*) Malloc((ni+3)*(ni+3)*nd*sizeof(double));
+  rlatx = (double*) Malloc((ni+3)*(ni+3)*nd*sizeof(double));
 
   im1s = 0;
   im1e = ni;
@@ -1361,7 +1359,7 @@ void gme_grid(int lbounds, int gridsize, double *rlon, double *rlat,
     {
       struct polygon *poly;
       
-      poly  = (struct polygon*) malloc((ni+1)*(ni+1)*nd*sizeof(struct polygon));
+      poly  = (struct polygon*) Malloc((ni+1)*(ni+1)*nd*sizeof(struct polygon));
 
       neighbours(rlonx,rlatx,im1s-1,im1e+1,im2s-1,im2e+1,nd, poly,im1s,im1e,im2s,im2e,nd);
 
@@ -1381,12 +1379,12 @@ void gme_grid(int lbounds, int gridsize, double *rlon, double *rlat,
 	    }
 	}
       
-      free(poly);
+      Free(poly);
     }
 
-  free(rlatx);
-  free(rlonx);
-  free(xn);
+  Free(rlatx);
+  Free(rlonx);
+  Free(xn);
 }
 
 /*
@@ -1415,42 +1413,42 @@ int main(int argc, char *argv[])
 
   factorni(ni, &ni2, &ni3);  
 
-  if (( poly  = (struct polygon*) malloc((ni+1)*(ni+1)*nd*sizeof(struct polygon))) == NULL) {
+  if (( poly  = (struct polygon*) Malloc((ni+1)*(ni+1)*nd*sizeof(struct polygon))) == NULL) {
     perror("malloc poly");
     exit (-1);
   } 
   
-  if (( xn  = (double*) malloc((ni+1)*(ni+1)*3*nd*sizeof(double))) == NULL) {
+  if (( xn  = (double*) Malloc((ni+1)*(ni+1)*3*nd*sizeof(double))) == NULL) {
     perror("malloc xn");
     exit (-1);
   } 
   
-  if ((rlon = (double*) malloc((ni+1)*(ni+1)*nd*sizeof(double))) == NULL) {
+  if ((rlon = (double*) Malloc((ni+1)*(ni+1)*nd*sizeof(double))) == NULL) {
     perror("malloc rlon");
     exit (-1);
   } 
   
-  if ((rlat = (double*) malloc((ni+1)*(ni+1)*nd*sizeof(double))) == NULL) {
+  if ((rlat = (double*) Malloc((ni+1)*(ni+1)*nd*sizeof(double))) == NULL) {
     perror("malloc rlat");
     exit (-1);
   } 
 
-  if ((rlonx = (double*) malloc((ni+3)*(ni+3)*nd*sizeof(double))) == NULL) {
+  if ((rlonx = (double*) Malloc((ni+3)*(ni+3)*nd*sizeof(double))) == NULL) {
     perror("malloc rlonx");
     exit (-1);
   } 
   
-  if ((rlatx = (double*) malloc((ni+3)*(ni+3)*nd*sizeof(double))) == NULL) {
+  if ((rlatx = (double*) Malloc((ni+3)*(ni+3)*nd*sizeof(double))) == NULL) {
     perror("malloc rlatx");
     exit (-1);
   } 
 
-  if ((mask = (int*) malloc((ni+1)*(ni+1)*nd*sizeof(int))) == NULL) {
+  if ((mask = (int*) Malloc((ni+1)*(ni+1)*nd*sizeof(int))) == NULL) {
     perror("malloc mask");
     exit (-1);
   } 
 
-  if (( area  = (double*) malloc((ni+1)*(ni+1)*nd*sizeof(double))) == NULL) {
+  if (( area  = (double*) Malloc((ni+1)*(ni+1)*nd*sizeof(double))) == NULL) {
     perror("malloc area");
     exit (-1);
   } 
@@ -1577,14 +1575,14 @@ int main(int argc, char *argv[])
     }
   }
 
-  free(poly);
-  free(xn);
-  free(rlon);
-  free(rlat);
-  free(rlonx);
-  free(rlatx);
-  free(mask);
-  free(area);
+  Free(poly);
+  Free(xn);
+  Free(rlon);
+  Free(rlat);
+  Free(rlonx);
+  Free(rlatx);
+  Free(mask);
+  Free(area);
 
   return(0);
 }
diff --git a/src/grid_lcc.c b/src/grid_lcc.c
index 563539e..9992c3f 100644
--- a/src/grid_lcc.c
+++ b/src/grid_lcc.c
@@ -327,6 +327,6 @@ int main(void)
 	}
   }
 			
-  return (0);
+  return 0;
 }
 */
diff --git a/src/grid_rot.c b/src/grid_rot.c
index a17c00f..df2a074 100644
--- a/src/grid_rot.c
+++ b/src/grid_rot.c
@@ -32,9 +32,9 @@ double lamrot_to_lam(double phirot, double lamrot, double polphi, double pollam,
   if ( lamrot > 180.0 ) lamrot -= 360.0;
   zlamrot = DEG2RAD*lamrot;
 
-  if ( polgam > 0 )
+  if ( fabs(polgam) > 0 )
     {
-      zgam  = DEG2RAD*polgam;
+      zgam  = -DEG2RAD*polgam;
       zarg1 = sin(zlampol) *                                               
  	    (- zsinpol*cos(zphirot) * (cos(zlamrot)*cos(zgam) - sin(zlamrot)*sin(zgam)) 
  	     + zcospol*sin(zphirot))                                              
@@ -90,9 +90,9 @@ double phirot_to_phi(double phirot, double lamrot, double polphi, double polgam)
   if ( lamrot > 180.0 ) lamrot -= 360.0;
   zlamrot   = DEG2RAD*lamrot;
 
-  if ( polgam > 0 )
+  if ( fabs(polgam) > 0 )
     {
-      zgam = DEG2RAD*polgam;
+      zgam = -DEG2RAD*polgam;
       zarg = zsinpol*sin(zphirot) +
              zcospol*cos(zphirot)*(cos(zlamrot)*cos(zgam) - sin(zgam)*sin(zlamrot));
     }
@@ -182,13 +182,13 @@ void usvs_to_uv(double us, double vs, double phi, double rla,
     u      : zonaler wind im geographischen system
     v      : merid. wind im geographischen system
   */
-  double zpolphi, zpollam, zrla, zphi, pollamd, zrlas, zarg, zbeta;
+  double zpolphi, zpollam, zrla, pollamd, zrlas, zarg, zbeta;
 
   /* umrechnung von grad in bogenmass */
   zpolphi = polphi*DEG2RAD;
   zpollam = pollam*DEG2RAD;
+  if ( rla < 0.0 ) rla += 360.0;
   zrla    = rla   *DEG2RAD;
-  zphi    = phi   *DEG2RAD;
   pollamd = pollam;
   if ( pollamd < 0.0 ) pollamd += 360.0;
 
@@ -249,6 +249,6 @@ int main(void)
   usvs_to_uv(30.0, 20.0, 30.0, 0.0, polphi, pollam, &x1, &x2);
   printf("usvs_to_uv %g %g %g %g\n", polphi, pollam, x1, x2);
 
-  return (0);
+  return 0;
 }
 */
diff --git a/src/grid_search.c b/src/grid_search.c
new file mode 100644
index 0000000..bb66c84
--- /dev/null
+++ b/src/grid_search.c
@@ -0,0 +1,449 @@
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <float.h>
+#include <math.h>
+
+#include "cdo_int.h"
+#include "dmemory.h"
+#include "util.h"
+#include "grid_search.h"
+
+
+#ifndef  M_PI
+#define  M_PI        3.14159265358979323846264338327950288  /* pi */
+#endif
+
+#define  PI       M_PI
+#define  PI2      (2.0*PI)
+
+
+static int gridsearch_method_nn = GS_KDTREE;
+
+static inline void LLtoXYZ_f(double lon, double lat, float *restrict xyz)
+{
+   double cos_lat = cos(lat);
+   xyz[0] = cos_lat * cos(lon);
+   xyz[1] = cos_lat * sin(lon);
+   xyz[2] = sin(lat);
+}
+
+static
+float square(const float x)
+{
+  return x*x;
+}
+
+static
+float distance(const float *restrict a, const float *restrict b)
+{
+  return (square((a[0]-b[0]))+square((a[1]-b[1]))+square((a[2]-b[2])));
+}
+
+
+void gridsearch_set_method(const char *methodstr)
+{
+  if      ( strcmp(methodstr, "kdtree")  == 0 ) gridsearch_method_nn = GS_KDTREE;
+  else if ( strcmp(methodstr, "nearpt3") == 0 ) gridsearch_method_nn = GS_NEARPT3;
+  else if ( strcmp(methodstr, "full")    == 0 ) gridsearch_method_nn = GS_FULL;
+  else
+    cdoAbort("gridsearch method %s not available!\n", methodstr);
+}
+
+
+struct gridsearch *gridsearch_create_reg2d(unsigned nx, unsigned ny, const double *restrict lons, const double *restrict lats)
+{
+  struct gridsearch *gs = (struct gridsearch *) Calloc(1, sizeof(struct gridsearch));
+
+  gs->nx = nx;
+  gs->ny = ny;
+
+  double *reg2d_center_lon = (double *) Malloc((nx+1)*sizeof(double));
+  double *reg2d_center_lat = (double *) Malloc(ny*sizeof(double));
+
+  memcpy(reg2d_center_lon, lons, (nx+1)*sizeof(double));
+  memcpy(reg2d_center_lat, lats, ny*sizeof(double));
+
+  double *coslon = (double *) Malloc(nx*sizeof(double));
+  double *sinlon = (double *) Malloc(nx*sizeof(double));
+  double *coslat = (double *) Malloc(ny*sizeof(double));
+  double *sinlat = (double *) Malloc(ny*sizeof(double));
+
+  for ( unsigned n = 0; n < nx; ++n )
+    {
+      double rlon = lons[n];
+      if ( rlon > PI2 ) rlon -= PI2;
+      if ( rlon < 0   ) rlon += PI2;
+      coslon[n] = cos(rlon);
+      sinlon[n] = sin(rlon);
+    }
+  for ( unsigned n = 0; n < ny; ++n )
+    {
+      coslat[n] = cos(lats[n]);
+      sinlat[n] = sin(lats[n]);
+    }
+
+  gs->reg2d_center_lon = reg2d_center_lon;
+  gs->reg2d_center_lat = reg2d_center_lat;
+
+  gs->coslon = coslon;
+  gs->sinlon = sinlon;
+  gs->coslat = coslat;
+  gs->sinlat = sinlat;
+
+  return gs;
+}
+
+
+struct kdNode *gs_create_kdtree(unsigned n, const double *restrict lons, const double *restrict lats)
+{
+  struct kd_point *pointlist = (struct kd_point *) Malloc(n * sizeof(struct kd_point));  
+  // see  example_cartesian.c
+  if ( cdoVerbose ) printf("kdtree lib init 3D: n=%d  nthreads=%d\n", n, ompNumThreads);
+  float min[3], max[3];
+  min[0] = min[1] = min[2] =  1e9;
+  max[0] = max[1] = max[2] = -1e9;
+  float *restrict point;
+#if defined(HAVE_OPENMP4)
+#pragma omp simd
+#endif
+  for ( unsigned i = 0; i < n; i++ ) 
+    {
+      point = pointlist[i].point;
+      LLtoXYZ_f(lons[i], lats[i], point);
+      for ( unsigned j = 0; j < 3; ++j )
+        {
+          min[j] = point[j] < min[j] ? point[j] : min[j];
+          max[j] = point[j] > max[j] ? point[j] : max[j];
+        }
+      pointlist[i].index = i;
+    }
+
+  struct kdNode *kdt = kd_buildTree(pointlist, n, min, max, 3, ompNumThreads);
+  if ( pointlist ) Free(pointlist);
+
+  return kdt;
+}
+
+
+void gs_destroy_nearpt3(struct gsNear *near)
+{
+  if ( near )
+    {
+#if defined(ENABLE_NEARPT3)
+      if ( near->nearpt3 ) nearpt3_destroy(near->nearpt3);
+#endif
+      if ( near->pts )
+        {
+          Free(near->pts[0]);
+          Free(near->pts);
+        }
+
+      Free(near);
+    }
+}
+
+
+struct gsNear *gs_create_nearpt3(unsigned n, const double *restrict lons, const double *restrict lats)
+{
+  struct gsNear *near = (struct gsNear *) Calloc(1, sizeof(struct gsNear));
+
+  Coord_T **p = (Coord_T **) Malloc(n*sizeof(Coord_T *));
+  p[0] = (Coord_T *) Malloc(3*n*sizeof(Coord_T));
+  for ( unsigned i = 1; i < n; i++ ) p[i] = p[0] + i*3;
+
+  float point[3];
+
+#if defined(HAVE_OPENMP4)
+#pragma omp simd
+#endif
+  for ( unsigned i = 0; i < n; i++ )
+    {
+      LLtoXYZ_f(lons[i], lats[i], point);
+
+      p[i][0] = NPT3SCALE(point[0]);
+      p[i][1] = NPT3SCALE(point[1]);
+      p[i][2] = NPT3SCALE(point[2]);
+    }
+
+  near->n = n;
+  near->plons = lons;
+  near->plats = lats;
+  near->pts = p;
+#if defined(ENABLE_NEARPT3)
+  near->nearpt3 = nearpt3_preprocess(n, p);
+#else
+  cdoAbort("nearpt3 support not compiled in!");
+#endif
+  
+  return near;
+}
+
+
+void gs_destroy_full(struct gsFull *full)
+{
+  if ( full )
+    {
+      if ( full->pts )
+        {
+          Free(full->pts[0]);
+          Free(full->pts);
+        }
+
+      Free(full);
+    }
+}
+
+
+struct gsFull *gs_create_full(unsigned n, const double *restrict lons, const double *restrict lats)
+{
+  struct gsFull *full = (struct gsFull *) Calloc(1, sizeof(struct gsFull));
+
+  float **p = (float **) Malloc(n*sizeof(float *));
+  p[0] = (float *) Malloc(3*n*sizeof(float));
+  for ( unsigned i = 1; i < n; i++ ) p[i] = p[0] + i*3;
+
+#if defined(HAVE_OPENMP4)
+#pragma omp simd
+#endif
+  for ( unsigned i = 0; i < n; i++ )
+    {
+      LLtoXYZ_f(lons[i], lats[i], p[i]);
+    }
+  
+  full->n = n;
+  full->plons = lons;
+  full->plats = lats;
+  full->pts = p;
+
+  return full;
+}
+
+
+struct gridsearch *gridsearch_create(unsigned n, const double *restrict lons, const double *restrict lats)
+{
+  struct gridsearch *gs = (struct gridsearch *) Calloc(1, sizeof(struct gridsearch));
+
+  gs->n = n;
+  if ( n == 0 ) return gs;
+
+  gs->kdt  = gs_create_kdtree(n, lons, lats);
+
+  return gs;
+}
+
+
+struct gridsearch *gridsearch_create_nn(unsigned n, const double *restrict lons, const double *restrict lats)
+{
+  struct gridsearch *gs = (struct gridsearch *) Calloc(1, sizeof(struct gridsearch));
+
+  gs->method_nn = gridsearch_method_nn;
+  gs->n = n;
+  if ( n == 0 ) return gs;
+
+  if      ( gs->method_nn == GS_KDTREE  ) gs->kdt  = gs_create_kdtree(n, lons, lats);
+  else if ( gs->method_nn == GS_NEARPT3 ) gs->near = gs_create_nearpt3(n, lons, lats);
+  else if ( gs->method_nn == GS_FULL    ) gs->full = gs_create_full(n, lons, lats);
+
+  return gs;
+}
+
+
+void gridsearch_delete(struct gridsearch *gs)
+{
+  if ( gs )
+    {
+      if ( gs->kdt ) kd_destroyTree(gs->kdt);
+      
+      if ( gs->reg2d_center_lon ) Free(gs->reg2d_center_lon);
+      if ( gs->reg2d_center_lat ) Free(gs->reg2d_center_lat);
+
+      if ( gs->coslat ) Free(gs->coslat);
+      if ( gs->coslon ) Free(gs->coslon);
+      if ( gs->sinlat ) Free(gs->sinlat);
+      if ( gs->sinlon ) Free(gs->sinlon);
+
+      if ( gs->near ) gs_destroy_nearpt3(gs->near);
+      if ( gs->full ) gs_destroy_full(gs->full);
+
+      Free(gs);
+    }
+}
+
+static
+double gs_set_range(double *prange)
+{
+  double range;
+
+  if ( prange )
+    range = *prange;
+  else
+    range = SQR(2 * M_PI);     /* This has to be bigger than the presumed
+                                * maximum distance to the NN but smaller
+                                * than once around the sphere. The content
+                                * of this variable is replaced with the
+                                * distance to the NN squared. */
+  return range;
+}
+
+
+kdNode *gs_nearest_kdtree(kdNode *kdt, double lon, double lat, double *prange)
+{
+  if ( kdt == NULL ) return NULL;
+  
+  float range0 = gs_set_range(prange);
+  float range = range0;
+
+  float point[3];
+  LLtoXYZ_f(lon, lat, point);
+
+  kdNode *node = kd_nearest(kdt, point, &range, 3);
+
+  if ( !(range < range0) ) node = NULL;
+  if ( prange ) *prange = range;
+
+  return node;
+}
+
+
+unsigned gs_nearest_nearpt3(struct gsNear *near, double lon, double lat, double *prange)
+{
+  unsigned index = GS_NOT_FOUND;
+  if ( near == NULL ) return index;
+  
+#if defined(ENABLE_NEARPT3)
+  float range0 = gs_set_range(prange);
+
+  float point[3];
+  LLtoXYZ_f(lon, lat, point);
+
+  Coord_T q[3];
+  q[0] = NPT3SCALE(point[0]);
+  q[1] = NPT3SCALE(point[1]);
+  q[2] = NPT3SCALE(point[2]);
+
+  int closestpt = nearpt3_query(near->nearpt3, q);
+
+  if ( closestpt >= 0 )
+    {
+      float point0[3];
+      LLtoXYZ_f(near->plons[closestpt], near->plats[closestpt], point0);
+      
+      float range = distance(point, point0);
+      if ( range < range0 )
+        {
+           index = (unsigned) closestpt;
+           *prange = range;
+        }
+    }
+#else
+  UNUSED(lon);
+  UNUSED(lat);
+  UNUSED(prange);
+#endif
+
+  return index;
+}
+
+
+unsigned gs_nearest_full(struct  gsFull *full, double lon, double lat, double *prange)
+{
+  unsigned index = GS_NOT_FOUND;
+  if ( full == NULL ) return index;
+  
+  float range0 = gs_set_range(prange);
+
+  float point[3];
+  LLtoXYZ_f(lon, lat, point);
+
+  int n = full->n;
+  float **pts = full->pts;
+  int closestpt = -1;
+  float dist = FLT_MAX;
+  for ( int i = 0; i < n; i++ )
+    {
+      float d = distance(point, pts[i]);
+      if ( closestpt < 0 || d < dist || (d<=dist && i < closestpt) )
+        {
+          dist = d;
+          closestpt = i;
+        }
+    }
+
+  if ( closestpt >= 0 )
+    {
+      if ( dist < range0 )
+        {
+          *prange = dist;
+          index = (unsigned) closestpt;
+        }
+    }
+  
+  return index;
+}
+
+
+unsigned gridsearch_nearest(struct gridsearch *gs, double lon, double lat, double *prange)
+{
+  unsigned index = GS_NOT_FOUND;
+
+  if ( gs )
+    {
+      if ( gs->method_nn == GS_KDTREE )
+        {
+          kdNode *node = gs_nearest_kdtree(gs->kdt, lon, lat, prange);
+          if ( node ) index = (int) node->index;
+        }
+      else if ( gs->method_nn == GS_NEARPT3 )
+        {
+          index = gs_nearest_nearpt3(gs->near, lon, lat, prange);
+        }
+      else if ( gs->method_nn == GS_FULL )
+        {
+          index = gs_nearest_full(gs->full, lon, lat, prange);
+        }
+      else
+        {
+          cdoAbort("gridsearch_nearest::method_nn undefined!");
+        }
+    }
+
+  return index;
+}
+
+
+struct pqueue *gridsearch_qnearest(struct gridsearch *gs, double lon, double lat, double *prange, unsigned nnn)
+{
+  if ( gs->kdt == NULL ) return NULL;
+  
+  float point[3];
+  float range0 = gs_set_range(prange);
+  float range = range0;
+  struct pqueue *result = NULL;
+
+  LLtoXYZ_f(lon, lat, point);
+
+  if ( gs )
+    {
+      result = kd_qnearest(gs->kdt, point, &range, nnn, 3);
+      // printf("range %g %g %g %p\n", lon, lat, range, node);
+
+      if ( !(range < range0) )
+        {
+          if ( result )
+            {
+              struct resItem *p;
+              while ( pqremove_min(result, &p) ) Free(p); // Free the result node taken from the heap
+              Free(result->d); // free the heap
+              Free(result);    // and free the heap information structure
+            }
+          result = NULL;
+        }
+      if ( prange ) *prange = range;
+    }
+  
+  return result;
+}
diff --git a/src/grid_search.h b/src/grid_search.h
new file mode 100644
index 0000000..36e5888
--- /dev/null
+++ b/src/grid_search.h
@@ -0,0 +1,53 @@
+#ifndef _GRID_SEARCH_H_
+#define _GRID_SEARCH_H_
+
+#include <limits.h>
+#include "kdtreelib/kdtree.h"
+#include "nearpt3c.h"
+
+#define GS_NOT_FOUND  INT_MAX
+
+
+enum T_GRIDSEARCH_METHOD_NN  {GS_FULL=1, GS_KDTREE, GS_NEARPT3};
+
+struct gsFull {
+  unsigned n;
+  const double *plons;
+  const double *plats;
+  float **pts;
+};
+
+struct gsNear {
+  unsigned n;
+  const double *plons;
+  const double *plats;
+  Coord_T **pts;
+  void *nearpt3;
+};
+
+struct gridsearch {
+  int method_nn;
+  unsigned n;
+  unsigned nx, ny;
+
+  struct gsNear *near;
+
+  struct kdNode *kdt;
+
+  struct gsFull *full;
+
+  // reg2d search
+  double *reg2d_center_lon, *reg2d_center_lat;
+  double *coslat, *sinlat;   // cosine, sine of grid lats (for distance)
+  double *coslon, *sinlon;   // cosine, sine of grid lons (for distance)
+};
+
+
+struct gridsearch *gridsearch_create_reg2d(unsigned nx, unsigned ny, const double *restrict lons, const double *restrict lats);
+struct gridsearch *gridsearch_create(unsigned n, const double *restrict lons, const double *restrict lats);
+struct gridsearch *gridsearch_create_nn(unsigned n, const double *restrict lons, const double *restrict lats);
+void gridsearch_delete(struct gridsearch *gs);
+unsigned gridsearch_nearest(struct gridsearch *gs, double lon, double lat, double *range);
+struct pqueue *gridsearch_qnearest(struct gridsearch *gs, double lon, double lat, double *prange, unsigned nnn);
+
+#endif
diff --git a/src/griddes.c b/src/griddes.c
index b0eab75..7f67be2 100644
--- a/src/griddes.c
+++ b/src/griddes.c
@@ -29,7 +29,7 @@
 #include <sys/stat.h>
 #include <fcntl.h>
 #include <unistd.h>
-
+#include <limits.h>
 
 #include <cdi.h>
 #include "cdo.h"
@@ -37,7 +37,6 @@
 #include "grid.h"
 #include "griddes.h"
 #include "error.h"
-#include "dtypes.h"
 
 /*
 int  extInqPrec(int fileID);
@@ -202,13 +201,13 @@ int gridDefine(griddes_t grid)
 
 	if ( (grid.def_xfirst || grid.def_xlast || grid.def_xinc) && grid.xvals == NULL )
 	  {
-	    grid.xvals = (double*) malloc(grid.xsize*sizeof(double));
+	    grid.xvals = (double*) Malloc(grid.xsize*sizeof(double));
 	    gridGenXvals(grid.xsize, grid.xfirst, grid.xlast, grid.xinc, grid.xvals);
 
 	    if ( grid.genBounds && grid.xbounds == NULL && grid.xsize > 1 )
 	      {
 		grid.nvertex = 2;
-		grid.xbounds = (double*) malloc(grid.xsize*grid.nvertex*sizeof(double));
+		grid.xbounds = (double*) Malloc(grid.xsize*grid.nvertex*sizeof(double));
 		for ( i = 0; i < (int) grid.xsize-1; i++ )
 		  {
 		    grid.xbounds[2*i+1]   = 0.5*(grid.xvals[i] + grid.xvals[i+1]);
@@ -222,13 +221,13 @@ int gridDefine(griddes_t grid)
 	if ( (grid.def_yfirst || grid.def_ylast || grid.def_yinc) && grid.yvals == NULL )
 	  {
 	    if ( ! grid.def_ylast ) grid.ylast = grid.yfirst;
-	    grid.yvals = (double*) malloc(grid.ysize*sizeof(double));
+	    grid.yvals = (double*) Malloc(grid.ysize*sizeof(double));
 	    gridGenYvals(grid.type, grid.ysize, grid.yfirst, grid.ylast, grid.yinc, grid.yvals);
 
 	    if ( grid.genBounds && grid.ybounds == NULL && grid.ysize > 1 )
 	      {
 		grid.nvertex = 2;
-		grid.ybounds = (double*) malloc(grid.ysize*grid.nvertex*sizeof(double));
+		grid.ybounds = (double*) Malloc(grid.ysize*grid.nvertex*sizeof(double));
 		for ( i = 0; i < (int) grid.ysize-1; i++ )
 		  {
 		    grid.ybounds[2*i+1]   = 0.5*(grid.yvals[i] + grid.yvals[i+1]);
@@ -251,13 +250,13 @@ int gridDefine(griddes_t grid)
 	if ( grid.xvals )
 	  {
 	    gridDefXvals(gridID, grid.xvals);
-	    free(grid.xvals);
+	    Free(grid.xvals);
 	  }
 
 	if ( grid.yvals )
 	  {
 	    gridDefYvals(gridID, grid.yvals);
-	    free(grid.yvals);
+	    Free(grid.yvals);
 	  }
 
 	if ( grid.nvertex )
@@ -266,13 +265,13 @@ int gridDefine(griddes_t grid)
 	if ( grid.xbounds )
 	  {
 	    gridDefXbounds(gridID, grid.xbounds);
-	    free(grid.xbounds);
+	    Free(grid.xbounds);
 	  }
 
 	if ( grid.ybounds )
 	  {
 	    gridDefYbounds(gridID, grid.ybounds);
-	    free(grid.ybounds);
+	    Free(grid.ybounds);
 	  }
 
 	if ( grid.isRotated )
@@ -285,7 +284,7 @@ int gridDefine(griddes_t grid)
 	if ( grid.mask )
 	  {
 	    gridDefMask(gridID, grid.mask);
-	    free(grid.mask);
+	    Free(grid.mask);
 	  }
 
 	if ( grid.type == GRID_LAEA )
@@ -331,37 +330,37 @@ int gridDefine(griddes_t grid)
 	if ( grid.xvals )
 	  {
 	    gridDefXvals(gridID, grid.xvals);
-	    free(grid.xvals);
+	    Free(grid.xvals);
 	  }
 
 	if ( grid.yvals )
 	  {
 	    gridDefYvals(gridID, grid.yvals);
-	    free(grid.yvals);
+	    Free(grid.yvals);
 	  }
 
 	if ( grid.area )
 	  {
 	    gridDefArea(gridID, grid.area);
-	    free(grid.area);
+	    Free(grid.area);
 	  }
 
 	if ( grid.xbounds )
 	  {
 	    gridDefXbounds(gridID, grid.xbounds);
-	    free(grid.xbounds);
+	    Free(grid.xbounds);
 	  }
 
 	if ( grid.ybounds )
 	  {
 	    gridDefYbounds(gridID, grid.ybounds);
-	    free(grid.ybounds);
+	    Free(grid.ybounds);
 	  }
 
 	if ( grid.mask )
 	  {
 	    gridDefMask(gridID, grid.mask);
-	    free(grid.mask);
+	    Free(grid.mask);
 	  }
 
 	break;
@@ -394,7 +393,7 @@ int gridDefine(griddes_t grid)
 	if ( grid.mask )
 	  {
 	    gridDefMask(gridID, grid.mask);
-	    free(grid.mask);
+	    Free(grid.mask);
 	  }
 
 	break;
@@ -415,14 +414,14 @@ int gridDefine(griddes_t grid)
 
 	if ( grid.def_xfirst && grid.def_xinc && grid.xvals == NULL )
 	  {
-	    grid.xvals = (double*) malloc(grid.xsize*sizeof(double));
+	    grid.xvals = (double*) Malloc(grid.xsize*sizeof(double));
 	    for ( i = 0; i < grid.xsize; ++i )
 	      grid.xvals[i] = grid.xfirst + i*grid.xinc;
 	  }
 
 	if ( grid.def_yfirst && grid.def_yinc && grid.yvals == NULL )
 	  {
-	    grid.yvals = (double*) malloc(grid.ysize*sizeof(double));
+	    grid.yvals = (double*) Malloc(grid.ysize*sizeof(double));
 	    for ( i = 0; i < grid.ysize; ++i )
 	      grid.yvals[i] = grid.yfirst + i*grid.yinc;
 	  }
@@ -430,13 +429,13 @@ int gridDefine(griddes_t grid)
 	if ( grid.xvals )
 	  {
 	    gridDefXvals(gridID, grid.xvals);
-	    free(grid.xvals);
+	    Free(grid.xvals);
 	  }
 
 	if ( grid.yvals )
 	  {
 	    gridDefYvals(gridID, grid.yvals);
-	    free(grid.yvals);
+	    Free(grid.yvals);
 	  }	
 
 	if ( grid.def_lon_0     == FALSE ) Error("lon_0 undefined!");
@@ -449,7 +448,7 @@ int gridDefine(griddes_t grid)
 	if ( grid.mask )
 	  {
 	    gridDefMask(gridID, grid.mask);
-	    free(grid.mask);
+	    Free(grid.mask);
 	  }
 
 	break;
@@ -489,7 +488,7 @@ int gridDefine(griddes_t grid)
 	if ( grid.mask )
 	  {
 	    gridDefMask(gridID, grid.mask);
-	    free(grid.mask);
+	    Free(grid.mask);
 	  }
 
 	break;
@@ -594,7 +593,7 @@ double *readfield(griddes_t *grid, int record, char *format, char *filename)
   if ( format == NULL )   Error("format undefined!");
   if ( filename == NULL ) Error("file name undefined!");
 
-  vals = (double*) malloc(grid->size*sizeof(double));
+  vals = (double*) Malloc(grid->size*sizeof(double));
 
   if ( strcmp(format, "extra") == 0 )
     {
@@ -629,7 +628,7 @@ double *readfield4(griddes_t *grid, int record, char *format, char *filename)
   if ( format == NULL )   Error("format undefined!");
   if ( filename == NULL ) Error("file name undefined!");
 
-  vals  = (double*) malloc(4*grid->size*sizeof(double));
+  vals  = (double*) Malloc(4*grid->size*sizeof(double));
 
   if ( strcmp(format, "extra") == 0 )
     {
@@ -984,8 +983,8 @@ int gridFromFile(FILE *gfp, const char *dname)
 	  double flat = 0, flon = 0;
 	  if ( grid.size == 0 ) grid.size = grid.xsize * grid.ysize;
 	  
-	  grid.xvals = (double*) malloc(grid.size*sizeof(double));
-	  grid.yvals = (double*) malloc(grid.size*sizeof(double));
+	  grid.xvals = (double*) Malloc(grid.size*sizeof(double));
+	  grid.yvals = (double*) Malloc(grid.size*sizeof(double));
 	  for ( i = 0; i < (int) grid.size; i++ )
 	    {
 	      if ( ! readline(gfp, line, MAX_LINE_LEN) )
@@ -1008,7 +1007,7 @@ int gridFromFile(FILE *gfp, const char *dname)
 	    {
 	      long count = 0;
 	      pline = skipSeparator(pline + len);
-	      grid.mask = (int*) malloc(size*sizeof(int));
+	      grid.mask = (int*) Malloc(size*sizeof(int));
 
 	      for ( i = 0; i < size; i++ )
 		{
@@ -1029,7 +1028,7 @@ int gridFromFile(FILE *gfp, const char *dname)
 
 	      if ( count == size )
 		{
-		  free(grid.mask);
+		  Free(grid.mask);
 		  grid.mask = NULL;
 		}
 	    }
@@ -1050,7 +1049,7 @@ int gridFromFile(FILE *gfp, const char *dname)
 	  if ( size > 0 )
 	    {
 	      pline = skipSeparator(pline + len);
-	      grid.xvals = (double*) malloc(size*sizeof(double));
+	      grid.xvals = (double*) Malloc(size*sizeof(double));
 
 	      for ( i = 0; i < size; i++ )
 		{
@@ -1085,7 +1084,7 @@ int gridFromFile(FILE *gfp, const char *dname)
 	  if ( size > 0 )
 	    {
 	      pline = skipSeparator(pline + len);
-	      grid.yvals = (double*) malloc(size*sizeof(double));
+	      grid.yvals = (double*) Malloc(size*sizeof(double));
 
 	      for ( i = 0; i < size; i++ )
 		{
@@ -1114,6 +1113,7 @@ int gridFromFile(FILE *gfp, const char *dname)
 
 	  if ( grid.nvertex == 0 )
 	    {
+	      if ( grid.type == GRID_LONLAT      ) grid.nvertex = 2;
 	      if ( grid.type == GRID_CURVILINEAR ) grid.nvertex = 4;
 	    }
 
@@ -1125,7 +1125,7 @@ int gridFromFile(FILE *gfp, const char *dname)
 	  if ( size > 0 && grid.nvertex > 0 )
 	    {	  
 	      pline = skipSeparator(pline + len);
-	      grid.xbounds = (double*) malloc(size*grid.nvertex*sizeof(double));
+	      grid.xbounds = (double*) Malloc(size*grid.nvertex*sizeof(double));
 
 	      for ( i = 0; i < (int) (size*grid.nvertex); i++ )
 		{
@@ -1157,6 +1157,7 @@ int gridFromFile(FILE *gfp, const char *dname)
 
 	  if ( grid.nvertex == 0 )
 	    {
+	      if ( grid.type == GRID_LONLAT      ) grid.nvertex = 2;
 	      if ( grid.type == GRID_CURVILINEAR ) grid.nvertex = 4;
 	    }
 
@@ -1168,7 +1169,7 @@ int gridFromFile(FILE *gfp, const char *dname)
 	  if ( size > 0 && grid.nvertex > 0 )
 	    {	  
 	      pline = skipSeparator(pline + len);
-	      grid.ybounds = (double*) malloc(size*grid.nvertex*sizeof(double));
+	      grid.ybounds = (double*) Malloc(size*grid.nvertex*sizeof(double));
 
 	      for ( i = 0; i < (int) (size*grid.nvertex); i++ )
 		{
@@ -1252,7 +1253,7 @@ int input_darray(FILE *gfp, int n_values, double *array)
   int i;
   int read_items;
 
-  if ( n_values <= 0 ) return (0);
+  if ( n_values <= 0 ) return 0;
 
   read_items = 0;
   for ( i = 0; i < n_values; i++ )
@@ -1288,8 +1289,8 @@ int gridFromPingo(FILE *gfp, const char *dname)
       grid.xsize = nlon;
       grid.ysize = nlat;
 
-      grid.xvals = (double*) malloc(grid.xsize*sizeof(double));
-      grid.yvals = (double*) malloc(grid.ysize*sizeof(double));
+      grid.xvals = (double*) Malloc(grid.xsize*sizeof(double));
+      grid.yvals = (double*) Malloc(grid.ysize*sizeof(double));
 
       if ( ! input_ival(gfp, &nlon) ) return (gridID);
       if ( nlon == 2 )
@@ -1357,10 +1358,10 @@ int gridFromPingo(FILE *gfp, const char *dname)
       if ( nlat > 2 ) /* check if gaussian */
 	{
 	  double *yvals, *yw;
-	  yvals = (double*) malloc(grid.ysize*sizeof(double));
-	  yw    = (double*) malloc(grid.ysize*sizeof(double));
+	  yvals = (double*) Malloc(grid.ysize*sizeof(double));
+	  yw    = (double*) Malloc(grid.ysize*sizeof(double));
 	  gaussaw(yvals, yw, grid.ysize);
-	  free(yw);
+	  Free(yw);
 	  for ( i = 0; i < (int) grid.ysize; i++ )
 	    yvals[i] = asin(yvals[i])*RAD2DEG;
 
@@ -1369,7 +1370,7 @@ int gridFromPingo(FILE *gfp, const char *dname)
 		      
 	  if ( i == (int) grid.ysize ) lgauss = TRUE;
 
-	  free(yvals);
+	  Free(yvals);
 	}
 
       if ( lgauss )
@@ -1477,9 +1478,8 @@ int compNlon(int nlat)
 static
 void gen_grid_lonlat(griddes_t *grid, const char *pline, double inc, double lon1, double lon2, double lat1, double lat2)
 {
-  int nlon, nlat, i;
   int gridtype = GRID_LONLAT;
-  char *endptr;
+  int lbounds = TRUE;
 
   if ( *pline != 0 )
     {
@@ -1490,25 +1490,112 @@ void gen_grid_lonlat(griddes_t *grid, const char *pline, double inc, double lon1
 
       if ( ! isdigit((int) *pline) && !ispunct((int) *pline) ) return;
 
-      endptr = (char *) pline;
+      char *endptr = (char *) pline;
       inc = strtod(pline, &endptr);
-      if ( *endptr != 0 ) return;
+      if ( *endptr != 0 )
+        {
+          pline = endptr;
+          if ( *pline == '_' ) pline++;
+          else return;
+          
+          if ( *pline == 0 ) return;
+          if ( *pline == 'c' )
+            {
+              gridtype = GRID_CURVILINEAR;
+              pline++;
+              if ( *pline == '0' )
+                {
+                  lbounds = FALSE;
+                  pline++;
+                }
+            }
+          else if ( *pline == 'u' )
+            {
+              gridtype = GRID_UNSTRUCTURED;
+              pline++;
+              if ( *pline == '0' )
+                {
+                  lbounds = FALSE;
+                  pline++;
+                }
+            }
+          if ( *pline != 0 ) return;          
+        }
 
       if ( inc < 1e-9 ) inc = 1;
     }
 
   grid->type = gridtype;
 
-  nlon = (int) ((lon2 - lon1)/inc + 0.5);
-  nlat = (int) ((lat2 - lat1)/inc + 0.5);
-  grid->xsize = nlon;
-  grid->ysize = nlat;
+  int nlon = (int) ((lon2 - lon1)/inc + 0.5);
+  int nlat = (int) ((lat2 - lat1)/inc + 0.5);
+
+  double *xvals = (double*) Malloc(nlon*sizeof(double));
+  double *yvals = (double*) Malloc(nlat*sizeof(double));
 
-  grid->xvals = (double*) malloc(grid->xsize*sizeof(double));
-  grid->yvals = (double*) malloc(grid->ysize*sizeof(double));
+  for ( int i = 0; i < nlon; ++i ) xvals[i] = lon1 + inc/2 + i*inc;
+  for ( int i = 0; i < nlat; ++i ) yvals[i] = lat1 + inc/2 + i*inc;
 
-  for ( i = 0; i < nlon; ++i ) grid->xvals[i] = lon1 + inc/2 + i*inc;
-  for ( i = 0; i < nlat; ++i ) grid->yvals[i] = lat1 + inc/2 + i*inc;
+  if ( gridtype == GRID_LONLAT )
+    {
+      grid->xsize = nlon;
+      grid->ysize = nlat;
+      grid->xvals = xvals;
+      grid->yvals = yvals;
+      xvals = NULL;
+      yvals = NULL;
+    }
+  else
+    {
+      double gridsize = nlon*nlat;
+      double *xvals2D = (double*) Malloc(gridsize*sizeof(double));
+      double *yvals2D = (double*) Malloc(gridsize*sizeof(double));
+      for ( int j = 0; j < nlat; j++ )
+        for ( int i = 0; i < nlon; i++ )
+          {
+            xvals2D[j*nlon+i] = xvals[i];
+            yvals2D[j*nlon+i] = yvals[j];
+          }
+
+      if ( gridtype == GRID_CURVILINEAR )
+        {
+          grid->xsize = nlon;
+          grid->ysize = nlat;
+        }
+      else
+        {
+          grid->xsize = gridsize;
+          grid->ysize = gridsize;
+          if ( lbounds ) grid->nvertex = 4;
+        }
+      
+      grid->xvals = xvals2D;
+      grid->yvals = yvals2D;
+      
+      if ( lbounds && nlon > 1 && nlat > 1 )
+        {
+          double *xbounds = (double*) Malloc(2*nlon*sizeof(double));
+          grid_gen_bounds(nlon, xvals, xbounds);
+          
+          double *ybounds = (double*) Malloc(2*nlat*sizeof(double));
+          grid_gen_bounds(nlat, yvals, ybounds);
+          grid_check_lat_borders(2*nlat, ybounds);
+
+          double *xbounds2D = (double*) Malloc(4*gridsize*sizeof(double));
+          double *ybounds2D = (double*) Malloc(4*gridsize*sizeof(double));
+
+          grid_gen_xbounds2D(nlon, nlat, xbounds, xbounds2D);
+          grid_gen_ybounds2D(nlon, nlat, ybounds, ybounds2D);
+
+          Free(xbounds);
+          Free(ybounds);
+          grid->xbounds = xbounds2D;
+          grid->ybounds = ybounds2D;
+        }
+   }
+
+  if ( xvals ) Free(xvals);
+  if ( yvals ) Free(yvals);
 }
 
 
@@ -1604,8 +1691,8 @@ int gridFromName(const char *gridname)
 	  grid.type = GRID_LONLAT;
 	  grid.xsize = 1;
 	  grid.ysize = 1;
-	  grid.xvals = (double*) malloc(sizeof(double));
-	  grid.yvals = (double*) malloc(sizeof(double));
+	  grid.xvals = (double*) Malloc(sizeof(double));
+	  grid.yvals = (double*) Malloc(sizeof(double));
 	  grid.xvals[0] = atof(pline);
 	  while ( isdigit((int) *pline) || ispunct((int) *pline) || *pline == '-' ) pline++;
 	  if ( *pline == '_' ) pline++;
@@ -1834,7 +1921,7 @@ int cdoDefineGrid(const char *gridfile)
 	  if ( cdoDebug ) cdoPrint("grid from ASCII file");
 	  gfp = fopen(filename, "r");
 	  //size_t buffersize = 20*1024*1024;
-	  //char *buffer = (char*) malloc(buffersize);
+	  //char *buffer = (char*) Malloc(buffersize);
 	  //setvbuf(gfp, buffer, _IOFBF, buffersize);
 	  gridID = gridFromFile(gfp, filename);
 	  fclose(gfp);
@@ -1852,7 +1939,7 @@ int cdoDefineGrid(const char *gridfile)
       if ( gridID == -1 ) cdoAbort("Invalid grid description file %s!", filename);
     }
 
-  if ( lalloc ) free(filename);
+  if ( lalloc ) Free(filename);
 
   return (gridID);
 }
diff --git a/src/griddes_h5.c b/src/griddes_h5.c
index 7184d75..1725746 100644
--- a/src/griddes_h5.c
+++ b/src/griddes_h5.c
@@ -386,8 +386,8 @@ int gridFromH5file(const char *gridfile)
       grid.ysize = (int)dims_out[0];
       grid.size  = grid.xsize*grid.ysize;
 
-      grid.xvals = (double*) malloc(grid.size*sizeof(double));
-      grid.yvals = (double*) malloc(grid.size*sizeof(double));
+      grid.xvals = (double*) Malloc(grid.size*sizeof(double));
+      grid.yvals = (double*) Malloc(grid.size*sizeof(double));
 
       if ( ftype )
 	{
@@ -397,12 +397,12 @@ int gridFromH5file(const char *gridfile)
       else
 	{
 	  int *iarray, i;
-	  iarray = (int*) malloc(grid.size*sizeof(int));
+	  iarray = (int*) Malloc(grid.size*sizeof(int));
 	  status = H5Dread(lon_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, iarray);
 	  for ( i = 0; i < grid.size; ++i ) grid.xvals[i] = iarray[i];
 	  status = H5Dread(lat_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, iarray);
 	  for ( i = 0; i < grid.size; ++i ) grid.yvals[i] = iarray[i];
-	  free(iarray);
+	  Free(iarray);
 	}
 
       status = H5Sclose(dataspace);
@@ -512,8 +512,8 @@ int gridFromH5file(const char *gridfile)
 	  grid.ysize = (int)dims_out[0];
 	  grid.size  = grid.xsize*grid.ysize;
 
-	  grid.xvals = (double*) malloc(grid.size*sizeof(double));
-	  grid.yvals = (double*) malloc(grid.size*sizeof(double));
+	  grid.xvals = (double*) Malloc(grid.size*sizeof(double));
+	  grid.yvals = (double*) Malloc(grid.size*sizeof(double));
 
 	  if ( ftype )
 	    {
@@ -523,12 +523,12 @@ int gridFromH5file(const char *gridfile)
 	  else
 	    {
 	      int *iarray, i;
-	      iarray = (int*) malloc(grid.size*sizeof(int));
+	      iarray = (int*) Malloc(grid.size*sizeof(int));
 	      status = H5Dread(lon_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, iarray);
 	      for ( i = 0; i < grid.size; ++i ) grid.xvals[i] = iarray[i];
 	      status = H5Dread(lat_id, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, iarray);
 	      for ( i = 0; i < grid.size; ++i ) grid.yvals[i] = iarray[i];
-	      free(iarray);
+	      Free(iarray);
 	    }
 
 	  status = H5Sclose(dataspace);
diff --git a/src/griddes_nc.c b/src/griddes_nc.c
index 02db5ea..7e21d71 100644
--- a/src/griddes_nc.c
+++ b/src/griddes_nc.c
@@ -21,7 +21,6 @@ static void nce(int istat)
   /*
     This routine provides a simple interface to netCDF error message routine.
   */
-
   if ( istat != NC_NOERR ) cdoAbort(nc_strerror(istat));
 }
 #endif
@@ -34,8 +33,10 @@ int cdf_openread(const char *filename)
   int nc_file_id;      /* netCDF grid file id           */
 
   openLock();
-  nce(nc_open(filename, NC_NOWRITE, &nc_file_id));
+  int istat = nc_open(filename, NC_NOWRITE, &nc_file_id);
   openUnlock();
+  if ( istat != NC_NOERR )      
+    cdoAbort("Open failed on %s! %s", filename, nc_strerror(istat));
   fileID = nc_file_id;
 #else
   cdoWarning("netCDF support not compiled in!");
@@ -108,10 +109,10 @@ int gridFromNCfile(const char *gridfile)
 
       /* allocate grid coordinates and read data */
 
-      grid.xvals   = (double*) malloc(grid.size*sizeof(double));
-      grid.yvals   = (double*) malloc(grid.size*sizeof(double));
-      grid.xbounds = (double*) malloc(grid.nvertex*grid.size*sizeof(double));
-      grid.ybounds = (double*) malloc(grid.nvertex*grid.size*sizeof(double));
+      grid.xvals   = (double*) Malloc(grid.size*sizeof(double));
+      grid.yvals   = (double*) Malloc(grid.size*sizeof(double));
+      grid.xbounds = (double*) Malloc(grid.nvertex*grid.size*sizeof(double));
+      grid.ybounds = (double*) Malloc(grid.nvertex*grid.size*sizeof(double));
 
       nce(nc_inq_vartype(nc_file_id, nc_gridlat_id, &xtype));
       if ( xtype == NC_FLOAT )  grid.prec = DATATYPE_FLT32;
@@ -132,14 +133,14 @@ int gridFromNCfile(const char *gridfile)
       if ( nc_inq_varid(nc_file_id, "grid_imask", &nc_gridmask_id) == NC_NOERR )
 	{
 	  int i;
-	  grid.mask = (int*) malloc(grid.size*sizeof(int));
+	  grid.mask = (int*) Malloc(grid.size*sizeof(int));
 	  nce(nc_get_var_int(nc_file_id, nc_gridmask_id, grid.mask));
 	  for ( i = 0; i < grid.size; ++i )
 	    if ( grid.mask[i] != 1 ) break;
 
 	  if ( i == grid.size )
 	    {
-	      free(grid.mask);
+	      Free(grid.mask);
 	      grid.mask = NULL;
 	    }
 	}
@@ -218,6 +219,9 @@ void writeNCgrid(const char *gridfile, int gridID, int *grid_imask)
   if ( gridfile[len-2] == 'n' && gridfile[len-1] == 'c' ) len -= 3;
   nce(nc_put_att_text(nc_file_id, NC_GLOBAL, "title", len, gridfile));
 
+  if ( CDO_Version_Info )
+    nce(nc_put_att_text(nc_file_id, NC_GLOBAL, "CDO", (int)strlen(cdoComment())+1, cdoComment()));
+
   /* define grid size dimension */
 
   nce(nc_def_dim (nc_file_id, "grid_size", gridsize, &nc_gridsize_id));
@@ -308,7 +312,7 @@ void writeNCgrid(const char *gridfile, int gridID, int *grid_imask)
 
   nce(nc_put_var_int(nc_file_id, nc_grdimask_id, grid_imask));
 
-  vals = (double*) malloc(gridInqNvertex(gridID)*gridsize*sizeof(double));
+  vals = (double*) Malloc(gridInqNvertex(gridID)*gridsize*sizeof(double));
 
   gridInqYvals(gridID, vals);
   nce(nc_put_var_double(nc_file_id, nc_gridlat_id, vals));
@@ -322,7 +326,7 @@ void writeNCgrid(const char *gridfile, int gridID, int *grid_imask)
   gridInqXbounds(gridID, vals);
   nce(nc_put_var_double(nc_file_id, nc_gridclon_id, vals));
 
-  free(vals);
+  Free(vals);
 
   nce(nc_close(nc_file_id));
 
diff --git a/src/gridreference.c b/src/gridreference.c
index e05a1d0..7a360b0 100644
--- a/src/gridreference.c
+++ b/src/gridreference.c
@@ -30,6 +30,7 @@
 /*
  * callback function for curl for writing the network retrieved grid file
  */
+#if defined(HAVE_LIBCURL)
 static
 size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
 {
@@ -37,6 +38,7 @@ size_t write_data(void *ptr, size_t size, size_t nmemb, FILE *stream)
   written = fwrite(ptr, size, nmemb, stream);
   return written;
 }
+#endif
 
 /* code from grid_tools.2 */
 int download_gridfile(const char *restrict uri, const char *restrict basename)
diff --git a/src/hetaeta.c b/src/hetaeta.c
index 6c71713..0611913 100644
--- a/src/hetaeta.c
+++ b/src/hetaeta.c
@@ -8,10 +8,7 @@
 #  include <omp.h>
 #endif
 
-#include <math.h>
-#include <stdlib.h>
-#include <stdio.h>
-
+#include "cdo_int.h"
 #include "hetaeta.h"
 
 const double ap0  = 100000.0;
@@ -36,10 +33,9 @@ FILE *old, *new;
 static
 long int_index(long n, double *x1, double x2)
 {
-  long klo, khi, k;
-
-  klo = 0;
-  khi = n-1;
+  long k;
+  long klo = 0;
+  long khi = n-1;
 
   while ( khi-klo > 1 )
     {
@@ -56,24 +52,21 @@ long int_index(long n, double *x1, double x2)
   */
   /* printf("%d %d %g %g %g\n", klo, khi, x1[klo], x1[klo+1], x2); */
 
-  return (klo);
+  return klo;
 }
 
 static
 double esat(double temperature)
 {
   double zes;
-  double es;
-  double tc;
-
-  tc = temperature-273.16;
+  double tc = temperature-273.16;
 
   if ( tc < 0.0 )
     zes = 21.8745584*tc / (temperature-7.66);
   else
     zes = 17.2693882*tc / (temperature-35.86);
 
-  es = 610.78*exp(zes);
+  double es = 610.78*exp(zes);
 
   return es;
 }
@@ -103,19 +96,17 @@ void hetaeta_sc(int ltq, int lpsmod, long ij, long ngp, long nlev1, long nlev2,
   long k, iv, ijk, ijk1, ijk2;
   long jlev = 0, jlevr, jnop;
   long klo;
-  long nlev1p1, nlev2p1;
   long jjblt;
   double zq1, zt1;
   double zdff, zdffl, ztv, zb, zbb, zc, zps;
   double zsump, zsumpp, zsumt, zsumtp;
   double dfi, fiadj = 0, dteta = 0;
   double pbl_lim, pbl_lim_need;
-  double rair_d_cpair;
 
-  rair_d_cpair = rair/cpair;
+  double rair_d_cpair = rair/cpair;
 
-  nlev1p1 = nlev1+1;
-  nlev2p1 = nlev2+1;
+  long nlev1p1 = nlev1+1;
+  long nlev2p1 = nlev2+1;
 
   /******* initialise atmospheric fields in old system */
   
@@ -464,38 +455,26 @@ void hetaeta(int ltq, int ngp, const int *imiss,
              const double *restrict fis2, double *restrict ps2, 
              double *restrict t2, double *restrict q2,
 	     int nvars, double *restrict *restrict vars1, double *restrict *restrict vars2,
-	     double *restrict tscor, double *restrict pscor,
-	     double *restrict secor)
+	     double *restrict tscor, double *restrict pscor, double *restrict secor)
 {
   double epsm1i;
   long jblt;
-  long k, iv, ij;
+  long k, iv;
   long jlev = 0;
   double *zt2 = NULL, *zq2 = NULL;
   double /* *etah1,*/ *ph1, *lnph1, *fi1;
-  double *af1, *bf1, *etaf1, *pf1, *lnpf1;
+  double *pf1, *lnpf1;
   double *tv1, *theta1, *rh1;
-  double *etah2, *ph2, *lnph2, *fi2;
-  double *af2, *bf2, *etaf2, *pf2/*, *lnpf2*/;
+  double *ph2, *lnph2, *fi2;
+  double *pf2/*, *lnpf2*/;
   double *zvar;
   double *rh_pbl = NULL;
   double *theta_pbl = NULL;
   double *rh2;
-  double *w1, *w2;
   double *wgt;
   long *idx;
-  long *jl1, *jl2;
-  long nlev1p1;
-  long nlev2p1;
   int lpsmod = 1;
 #if defined(_OPENMP)
-  double **zt2_2, **zq2_2;
-  double **ph1_2, **lnph1_2, **fi1_2, **pf1_2, **lnpf1_2, **tv1_2, **theta1_2, **rh1_2, **zvar_2;
-  double **ph2_2, **lnph2_2, **fi2_2, **pf2_2;
-  double **rh_pbl_2, **theta_pbl_2, **rh2_2;
-  double **wgt_2;
-  double ***vars_pbl_2;
-  long **idx_2;
   long i;
   extern int ompNumThreads;
   double *vars_pbl[MAX_VARS];
@@ -509,71 +488,67 @@ void hetaeta(int ltq, int ngp, const int *imiss,
   new = fopen("new.dat","w");
 #endif
 
-  nlev1p1 = nlev1+1;
-  nlev2p1 = nlev2+1;
+  long nlev1p1 = nlev1+1;
+  long nlev2p1 = nlev2+1;
 
 #if defined(_OPENMP)
-  ph1_2    = (double **) malloc(ompNumThreads*sizeof(double *));
-  lnph1_2  = (double **) malloc(ompNumThreads*sizeof(double *));
-  fi1_2    = (double **) malloc(ompNumThreads*sizeof(double *));
-
-  pf1_2    = (double **) malloc(ompNumThreads*sizeof(double *));
-  lnpf1_2  = (double **) malloc(ompNumThreads*sizeof(double *));
-  tv1_2    = (double **) malloc(ompNumThreads*sizeof(double *));
-  theta1_2 = (double **) malloc(ompNumThreads*sizeof(double *));
-  rh1_2    = (double **) malloc(ompNumThreads*sizeof(double *));
-  zvar_2   = (double **) malloc(ompNumThreads*sizeof(double *));
-
-  ph2_2    = (double **) malloc(ompNumThreads*sizeof(double *));
-  lnph2_2  = (double **) malloc(ompNumThreads*sizeof(double *));
-  fi2_2    = (double **) malloc(ompNumThreads*sizeof(double *));
-
-  pf2_2    = (double **) malloc(ompNumThreads*sizeof(double *));
-  rh2_2    = (double **) malloc(ompNumThreads*sizeof(double *));
-  wgt_2    = (double **) malloc(ompNumThreads*sizeof(double *));
-  idx_2    = (long **) malloc(ompNumThreads*sizeof(long *));
-
-  if ( ltq )
-    {
-      zt2_2       = (double **) malloc(ompNumThreads*sizeof(double *));
-      zq2_2       = (double **) malloc(ompNumThreads*sizeof(double *));
-      rh_pbl_2    = (double **) malloc(ompNumThreads*sizeof(double *));
-      theta_pbl_2 = (double **) malloc(ompNumThreads*sizeof(double *));
-    }
-
-  if ( nvars > 0 )
-    {
-      vars_pbl_2  = (double ***) malloc(ompNumThreads*sizeof(double **));
-    }
+  double *ph1_2[ompNumThreads];
+  double *lnph1_2[ompNumThreads];
+  double *fi1_2[ompNumThreads];
+
+  double *pf1_2[ompNumThreads];
+  double *lnpf1_2[ompNumThreads];
+  double *tv1_2[ompNumThreads];
+  double *theta1_2[ompNumThreads];
+  double *rh1_2[ompNumThreads];
+  double *zvar_2[ompNumThreads];
+
+  double *ph2_2[ompNumThreads];
+  double *lnph2_2[ompNumThreads];
+  double *fi2_2[ompNumThreads];
+
+  double *pf2_2[ompNumThreads];
+  double *rh2_2[ompNumThreads];
+  double *wgt_2[ompNumThreads];
+  long   *idx_2[ompNumThreads];
+
+  // if ( ltq )
+  double *zt2_2[ompNumThreads];
+  double *zq2_2[ompNumThreads];
+  double *rh_pbl_2[ompNumThreads];
+  double *theta_pbl_2[ompNumThreads];
+
+  // if ( nvars > 0 )
+  double **vars_pbl_2[ompNumThreads];
 
   for ( i = 0; i < ompNumThreads; i++ )
     {
-      ph1_2[i]    = (double*) malloc(nlev1p1*sizeof(double));
-      lnph1_2[i]  = (double*) malloc(nlev1p1*sizeof(double));
-      fi1_2[i]    = (double*) malloc(nlev1p1*sizeof(double));
-
-      pf1_2[i]    = (double*) malloc(nlev1*sizeof(double));
-      lnpf1_2[i]  = (double*) malloc(nlev1*sizeof(double));
-      tv1_2[i]    = (double*) malloc(nlev1*sizeof(double));
-      theta1_2[i] = (double*) malloc(nlev1*sizeof(double));
-      rh1_2[i]    = (double*) malloc(nlev1*sizeof(double));
-      zvar_2[i]   = (double*) malloc(nlev1*sizeof(double));
-
-      ph2_2[i]    = (double*) malloc(nlev2p1*sizeof(double));
-      lnph2_2[i]  = (double*) malloc(nlev2p1*sizeof(double));
-      fi2_2[i]    = (double*) malloc(nlev2p1*sizeof(double));
-
-      pf2_2[i]    = (double*) malloc(nlev2*sizeof(double));
-      rh2_2[i]    = (double*) malloc(nlev2*sizeof(double));
-      wgt_2[i]    = (double*) malloc(nlev2*sizeof(double));
-      idx_2[i]    = (long*) malloc(nlev2*sizeof(long));
+      ph1_2[i]    = (double*) Malloc(nlev1p1*sizeof(double));
+      lnph1_2[i]  = (double*) Malloc(nlev1p1*sizeof(double));
+      fi1_2[i]    = (double*) Malloc(nlev1p1*sizeof(double));
+
+      pf1_2[i]    = (double*) Malloc(nlev1*sizeof(double));
+      lnpf1_2[i]  = (double*) Malloc(nlev1*sizeof(double));
+      tv1_2[i]    = (double*) Malloc(nlev1*sizeof(double));
+      theta1_2[i] = (double*) Malloc(nlev1*sizeof(double));
+      rh1_2[i]    = (double*) Malloc(nlev1*sizeof(double));
+      zvar_2[i]   = (double*) Malloc(nlev1*sizeof(double));
+
+      ph2_2[i]    = (double*) Malloc(nlev2p1*sizeof(double));
+      lnph2_2[i]  = (double*) Malloc(nlev2p1*sizeof(double));
+      fi2_2[i]    = (double*) Malloc(nlev2p1*sizeof(double));
+
+      pf2_2[i]    = (double*) Malloc(nlev2*sizeof(double));
+      rh2_2[i]    = (double*) Malloc(nlev2*sizeof(double));
+      wgt_2[i]    = (double*) Malloc(nlev2*sizeof(double));
+      idx_2[i]    = (long*) Malloc(nlev2*sizeof(long));
 
       if ( ltq )
 	{
-	  zt2_2[i]       = (double*) malloc(nlev2*sizeof(double));
-	  zq2_2[i]       = (double*) malloc(nlev2*sizeof(double));
-	  rh_pbl_2[i]    = (double*) malloc(nlev2*sizeof(double));
-	  theta_pbl_2[i] = (double*) malloc(nlev2*sizeof(double));
+	  zt2_2[i]       = (double*) Malloc(nlev2*sizeof(double));
+	  zq2_2[i]       = (double*) Malloc(nlev2*sizeof(double));
+	  rh_pbl_2[i]    = (double*) Malloc(nlev2*sizeof(double));
+	  theta_pbl_2[i] = (double*) Malloc(nlev2*sizeof(double));
 	}
 
       if ( nvars > 0 )
@@ -583,65 +558,64 @@ void hetaeta(int ltq, int ngp, const int *imiss,
 	      fprintf(stderr, "Too many vars (max = %d)!\n", MAX_VARS);
 	      exit(-1);
 	    }
-	  vars_pbl_2[i]  = (double **) malloc(nvars*sizeof(double *));
+	  vars_pbl_2[i]  = (double **) Malloc(nvars*sizeof(double *));
 	  for ( iv = 0; iv < nvars; ++iv )
-	    vars_pbl_2[i][iv] = (double*) malloc(nlev2*sizeof(double));
+	    vars_pbl_2[i][iv] = (double*) Malloc(nlev2*sizeof(double));
 	}
     }
 #else
-  /* etah1  = (double*) malloc(nlev1p1*sizeof(double)); */
-  ph1    = (double*) malloc(nlev1p1*sizeof(double));
-  lnph1  = (double*) malloc(nlev1p1*sizeof(double));
-  fi1    = (double*) malloc(nlev1p1*sizeof(double));
-
-  pf1    = (double*) malloc(nlev1*sizeof(double));
-  lnpf1  = (double*) malloc(nlev1*sizeof(double));
-  tv1    = (double*) malloc(nlev1*sizeof(double));
-  theta1 = (double*) malloc(nlev1*sizeof(double));
-  rh1    = (double*) malloc(nlev1*sizeof(double));
-  zvar   = (double*) malloc(nlev1*sizeof(double));
-
-  ph2    = (double*) malloc(nlev2p1*sizeof(double));
-  lnph2  = (double*) malloc(nlev2p1*sizeof(double));
-  fi2    = (double*) malloc(nlev2p1*sizeof(double));
-
-  pf2    = (double*) malloc(nlev2*sizeof(double));
-  /* lnpf2  = (double*) malloc(nlev2*sizeof(double)); */
-  rh2    = (double*) malloc(nlev2*sizeof(double));
-  wgt    = (double*) malloc(nlev2*sizeof(double));
-  idx    = (long*) malloc(nlev2*sizeof(long));
+  /* etah1  = (double*) Malloc(nlev1p1*sizeof(double)); */
+  ph1    = (double*) Malloc(nlev1p1*sizeof(double));
+  lnph1  = (double*) Malloc(nlev1p1*sizeof(double));
+  fi1    = (double*) Malloc(nlev1p1*sizeof(double));
+
+  pf1    = (double*) Malloc(nlev1*sizeof(double));
+  lnpf1  = (double*) Malloc(nlev1*sizeof(double));
+  tv1    = (double*) Malloc(nlev1*sizeof(double));
+  theta1 = (double*) Malloc(nlev1*sizeof(double));
+  rh1    = (double*) Malloc(nlev1*sizeof(double));
+  zvar   = (double*) Malloc(nlev1*sizeof(double));
+
+  ph2    = (double*) Malloc(nlev2p1*sizeof(double));
+  lnph2  = (double*) Malloc(nlev2p1*sizeof(double));
+  fi2    = (double*) Malloc(nlev2p1*sizeof(double));
+
+  pf2    = (double*) Malloc(nlev2*sizeof(double));
+  /* lnpf2  = (double*) Malloc(nlev2*sizeof(double)); */
+  rh2    = (double*) Malloc(nlev2*sizeof(double));
+  wgt    = (double*) Malloc(nlev2*sizeof(double));
+  idx    = (long*) Malloc(nlev2*sizeof(long));
 
   if ( ltq )
     {
-      zt2       = (double*) malloc(nlev2*sizeof(double));
-      zq2       = (double*) malloc(nlev2*sizeof(double));
-      rh_pbl    = (double*) malloc(nlev2*sizeof(double));
-      theta_pbl = (double*) malloc(nlev2*sizeof(double));
+      zt2       = (double*) Malloc(nlev2*sizeof(double));
+      zq2       = (double*) Malloc(nlev2*sizeof(double));
+      rh_pbl    = (double*) Malloc(nlev2*sizeof(double));
+      theta_pbl = (double*) Malloc(nlev2*sizeof(double));
     }
 
   if ( nvars > 0 )
     {
-      vars_pbl  = (double **) malloc(nvars*sizeof(double *));
+      vars_pbl  = (double **) Malloc(nvars*sizeof(double *));
       for ( iv = 0; iv < nvars; ++iv )
-	vars_pbl[iv] = (double*) malloc(nlev2*sizeof(double));
+	vars_pbl[iv] = (double*) Malloc(nlev2*sizeof(double));
     }
 #endif
   
-  af1    = (double*) malloc(nlev1*sizeof(double));
-  bf1    = (double*) malloc(nlev1*sizeof(double));
-  etaf1  = (double*) malloc(nlev1*sizeof(double));
-
-  etah2  = (double*) malloc(nlev2p1*sizeof(double));
+  double af1[nlev1];
+  double bf1[nlev1];
+  double etaf1[nlev1];
 
-  af2    = (double*) malloc(nlev2*sizeof(double));
-  bf2    = (double*) malloc(nlev2*sizeof(double));
-  etaf2  = (double*) malloc(nlev2*sizeof(double));
+  double etah2[nlev2p1];
 
-  w1     = (double*) malloc(nlev2*sizeof(double));
-  w2     = (double*) malloc(nlev2*sizeof(double));
-  jl1    = (long*) malloc(nlev2*sizeof(long));
-  jl2    = (long*) malloc(nlev2*sizeof(long));
+  double af2[nlev2];
+  double bf2[nlev2];
+  double etaf2[nlev2];
 
+  double w1[nlev2];
+  double w2[nlev2];
+  long jl1[nlev2];
+  long jl2[nlev2];
 
   /******* set coordinate system ETA's, A's, B's
 	   calculate half and full level ETA
@@ -723,11 +697,11 @@ void hetaeta(int ltq, int ngp, const int *imiss,
 	 ltq, nvars, imiss, ah1, bh1, ps1, nlev1, epsm1i, q1, t1, fis1, fis2, ps2, \
 	 ah2, bh2, nlev2, vars1, vars2, t2, q2, tscor, pscor, secor, jblt) \
   firstprivate(lpsmod) \
-  private(ij, ph1, lnph1, fi1, pf1, lnpf1, tv1, theta1, rh1, zvar, ph2, lnph2, fi2, pf2, rh_pbl, \
+  private(ph1, lnph1, fi1, pf1, lnpf1, tv1, theta1, rh1, zvar, ph2, lnph2, fi2, pf2, rh_pbl, \
           theta_pbl, rh2, wgt, idx, vars_pbl, zt2, zq2) \
   schedule(dynamic,1)
 #endif
-  for ( ij = 0; ij < ngp; ++ij )
+  for ( int ij = 0; ij < ngp; ++ij )
     {
 #if defined(_OPENMP)
       int ompthID = omp_get_thread_num();
@@ -794,137 +768,94 @@ void hetaeta(int ltq, int ngp, const int *imiss,
 #if defined(_OPENMP)
   for ( i = 0; i < ompNumThreads; i++ )
     {
-      free(ph1_2[i]);    
-      free(lnph1_2[i]);  
-      free(fi1_2[i]);    
-
-      free(pf1_2[i]);    
-      free(lnpf1_2[i]);  
-      free(tv1_2[i]);    
-      free(theta1_2[i]); 
-      free(rh1_2[i]);    
-      free(zvar_2[i]);    
-
-      free(ph2_2[i]);       
-      free(lnph2_2[i]);     
-      free(fi2_2[i]);
-
-      free(pf2_2[i]);       
-      /* free(lnpf2_2[i]); */
-      free(rh2_2[i]);      
-      free(wgt_2[i]); 
-      free(idx_2[i]); 
+      Free(ph1_2[i]);    
+      Free(lnph1_2[i]);  
+      Free(fi1_2[i]);    
+
+      Free(pf1_2[i]);    
+      Free(lnpf1_2[i]);  
+      Free(tv1_2[i]);    
+      Free(theta1_2[i]); 
+      Free(rh1_2[i]);    
+      Free(zvar_2[i]);    
+
+      Free(ph2_2[i]);       
+      Free(lnph2_2[i]);     
+      Free(fi2_2[i]);
+
+      Free(pf2_2[i]);       
+      /* Free(lnpf2_2[i]); */
+      Free(rh2_2[i]);      
+      Free(wgt_2[i]); 
+      Free(idx_2[i]); 
 
       if ( ltq )
 	{
-	  free(zt2_2[i]); 
-	  free(zq2_2[i]); 
-	  free(rh_pbl_2[i]); 
-	  free(theta_pbl_2[i]); 
+	  Free(zt2_2[i]); 
+	  Free(zq2_2[i]); 
+	  Free(rh_pbl_2[i]); 
+	  Free(theta_pbl_2[i]); 
 	}   
 
       if ( nvars > 0 )
 	{
 	  for ( iv = 0; iv < nvars; ++iv )
-	    free(vars_pbl_2[i][iv]);
+	    Free(vars_pbl_2[i][iv]);
 	  
-	  free(vars_pbl_2[i]);
+	  Free(vars_pbl_2[i]);
 	}
     }
-
-  free(ph1_2);
-  free(lnph1_2);
-  free(fi1_2);
-
-  free(pf1_2);
-  free(lnpf1_2);
-  free(tv1_2);
-  free(theta1_2);
-  free(rh1_2);
-  free(zvar_2);
-
-  free(ph2_2);
-  free(lnph2_2);
-  free(fi2_2);
-
-  free(pf2_2);
-  free(rh2_2);
-  free(wgt_2);
-  free(idx_2);
-
-  if ( ltq )
-    {
-      free(zt2_2);
-      free(zq2_2);
-      free(rh_pbl_2);
-      free(theta_pbl_2);
-    }
-
-  if ( nvars > 0 )
-    {
-      free(vars_pbl_2);
-    }
 #else
-  /* free(etah1); */     
-  free(ph1);    
-  free(lnph1);  
-  free(fi1);    
-
-  free(pf1);    
-  free(lnpf1);  
-  free(tv1);    
-  free(theta1); 
-  free(rh1);    
-  free(zvar);    
-
-  free(ph2);       
-  free(lnph2);     
-  free(fi2);
-
-  free(pf2);       
-  /* free(lnpf2); */
-  free(rh2);      
-  free(wgt); 
-  free(idx); 
+  /* Free(etah1); */     
+  Free(ph1);    
+  Free(lnph1);  
+  Free(fi1);    
+
+  Free(pf1);    
+  Free(lnpf1);  
+  Free(tv1);    
+  Free(theta1); 
+  Free(rh1);    
+  Free(zvar);    
+
+  Free(ph2);       
+  Free(lnph2);     
+  Free(fi2);
+
+  Free(pf2);       
+  /* Free(lnpf2); */
+  Free(rh2);      
+  Free(wgt); 
+  Free(idx); 
 
   if ( ltq )
     {
-      free(zt2); 
-      free(zq2); 
-      free(rh_pbl); 
-      free(theta_pbl); 
+      Free(zt2); 
+      Free(zq2); 
+      Free(rh_pbl); 
+      Free(theta_pbl); 
     }   
 
   if ( nvars > 0 )
     {
       for ( iv = 0; iv < nvars; ++iv )
-	free(vars_pbl[iv]);
+        Free(vars_pbl[iv]);
 
-      free(vars_pbl);
+      Free(vars_pbl);
     }
 #endif
 
-  free(af1);    
-  free(bf1);    
-  free(etaf1);  
-
-  free(etah2);
-
-  free(af2);       
-  free(bf2);       
-  free(etaf2);     
-
-  free(w1);       
-  free(w2);       
-  free(jl1);      
-  free(jl2);      
-
   return;
 }
 
-/*
+#if defined(TEST_HETAETA)
+#define NGP  (512*1024)
+int ompNumThreads = 2;
+
 int main (int argc, char *argv[])
 {
+  printf("NGP = %d\n", NGP);
+
   double a2[41] = {
        0.00000000000000000,       2000.00000000000000000,       4000.00000000000000000,
     6000.00000000000000000,       8000.00000000000000000,       9976.13671875000000000,
@@ -1011,43 +942,37 @@ int main (int argc, char *argv[])
     0.0,  0.0,  0.4445496,  0.0,  0.0,  0.001098633} ;
 
   double ifis1 = 9.121094, ips1 = 102511.8;
-
-  double *fis1, *ps1;
-  double *fis2, *ps2;
   
-  double *t1, *q1, *u1, *v1, *cl1, *ci1, *cc1;
-  double *t2, *q2, *u2, *v2, *cl2, *ci2, *cc2;
   double *vars1[5];
   double *vars2[5];
 
-  double *tscor, *pscor, *secor; 
   int ij, k;
   int ltq = 1;
 
-  fis1 = (double*) malloc(NGP*sizeof(double));
-  ps1  = (double*) malloc(NGP*sizeof(double));
-  fis2 = (double*) malloc(NGP*sizeof(double));
-  ps2  = (double*) malloc(NGP*sizeof(double));
-
-  tscor  = (double*) malloc(NGP*sizeof(double));
-  pscor  = (double*) malloc(NGP*sizeof(double));
-  secor  = (double*) malloc(NGP*sizeof(double));
-
-  t1  = (double*) malloc(NGP*19*sizeof(double));
-  q1  = (double*) malloc(NGP*19*sizeof(double));
-  u1  = (double*) malloc(NGP*19*sizeof(double));
-  v1  = (double*) malloc(NGP*19*sizeof(double));
-  cl1 = (double*) malloc(NGP*19*sizeof(double));
-  ci1 = (double*) malloc(NGP*19*sizeof(double));
-  cc1 = (double*) malloc(NGP*19*sizeof(double));
-
-  t2  = (double*) malloc(NGP*40*sizeof(double));
-  q2  = (double*) malloc(NGP*40*sizeof(double));
-  u2  = (double*) malloc(NGP*40*sizeof(double));
-  v2  = (double*) malloc(NGP*40*sizeof(double));
-  cl2 = (double*) malloc(NGP*40*sizeof(double));
-  ci2 = (double*) malloc(NGP*40*sizeof(double));
-  cc2 = (double*) malloc(NGP*40*sizeof(double));
+  double *fis1 = (double*) Malloc(NGP*sizeof(double));
+  double *ps1  = (double*) Malloc(NGP*sizeof(double));
+  double *fis2 = (double*) Malloc(NGP*sizeof(double));
+  double *ps2  = (double*) Malloc(NGP*sizeof(double));
+
+  double *tscor  = (double*) Malloc(NGP*sizeof(double));
+  double *pscor  = (double*) Malloc(NGP*sizeof(double));
+  double *secor  = (double*) Malloc(NGP*sizeof(double));
+
+  double *t1  = (double*) Malloc(NGP*19*sizeof(double));
+  double *q1  = (double*) Malloc(NGP*19*sizeof(double));
+  double *u1  = (double*) Malloc(NGP*19*sizeof(double));
+  double *v1  = (double*) Malloc(NGP*19*sizeof(double));
+  double *cl1 = (double*) Malloc(NGP*19*sizeof(double));
+  double *ci1 = (double*) Malloc(NGP*19*sizeof(double));
+  double *cc1 = (double*) Malloc(NGP*19*sizeof(double));
+
+  double *t2  = (double*) Malloc(NGP*40*sizeof(double));
+  double *q2  = (double*) Malloc(NGP*40*sizeof(double));
+  double *u2  = (double*) Malloc(NGP*40*sizeof(double));
+  double *v2  = (double*) Malloc(NGP*40*sizeof(double));
+  double *cl2 = (double*) Malloc(NGP*40*sizeof(double));
+  double *ci2 = (double*) Malloc(NGP*40*sizeof(double));
+  double *cc2 = (double*) Malloc(NGP*40*sizeof(double));
 
   for ( ij = 0; ij < NGP; ++ij )
     {
@@ -1079,13 +1004,10 @@ int main (int argc, char *argv[])
   vars2[3] = ci2;
   vars2[4] = cc2;
 
-  for ( ij = 0; ij < NGP; ++ij )
-    {
-      fis2[ij] = fis1[ij];
-    }
+  for ( ij = 0; ij < NGP; ++ij ) fis2[ij] = fis1[ij];
 
   if ( ltq )
-    hetaeta(ltq, NGP,
+    hetaeta(ltq, NGP, NULL,
 	    19, a1, b1,
 	    fis1, ps1,
 	    t1, q1,
@@ -1095,7 +1017,7 @@ int main (int argc, char *argv[])
 	    5, vars1, vars2,
 	    tscor, pscor, secor);
   else
-    hetaeta(ltq, NGP,
+    hetaeta(ltq, NGP, NULL,
 	    19, a1, b1,
 	    fis1, ps1,
 	    NULL, NULL,
@@ -1105,6 +1027,20 @@ int main (int argc, char *argv[])
 	    5, vars1, vars2,
 	    NULL, NULL, NULL);
 
+  double ot2[40] = {
+    224.226, 212.75, 209.616, 208.895, 210.468, 213.454, 218.091, 220.49, 220.977, 221.114,
+    220.731, 220.803, 223.595, 226.547, 230.566, 234.99, 239.411, 243.722, 248.125, 252.164,
+    256.221, 259.499, 262.082, 264.584, 266.487, 268.319, 269.761, 270.879, 271.881, 273.501,
+    274.932, 276.493, 278.199, 279.638, 280.811, 281.746, 282.613, 283.479, 284.087, 284.343};
+
+  int lerror = 0;
+  for ( k = 0; k < 40; ++k )
+    if ( fabs(t2[k*NGP]-ot2[k]) > 0.001 ) lerror=1;
+
+  if ( lerror )
+    for ( k = 0; k < 40; ++k )
+      printf("%d %g %g %g\n", k, t2[k*NGP], ot2[k], fabs(t2[k*NGP]-ot2[k]));
+
   return 0;
 }
-*/
+#endif
diff --git a/src/hetaeta.h b/src/hetaeta.h
index 9dace37..6cd1d33 100644
--- a/src/hetaeta.h
+++ b/src/hetaeta.h
@@ -1,6 +1,10 @@
 #ifndef _HETAETA_H
 #define _HETAETA_H
 
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
 void hetaeta(int ltq, int ngp, const int *imiss,
 	     int nlev1, const double *restrict ah1, const double *restrict bh1,
              const double *restrict fis1, const double *restrict ps1, 
diff --git a/src/institution.c b/src/institution.c
index a2a1065..c53edd7 100644
--- a/src/institution.c
+++ b/src/institution.c
@@ -38,11 +38,10 @@ int readInstitution(const char *instfile)
   int nvar = 0, maxvar = 4;
   char name[1024], longname[1024];
   int center = UNDEFID, subcenter = UNDEFID;
-  FILE *instfp;
 
-  instfp = fopen(instfile, "r");
+  FILE *instfp = fopen(instfile, "r");
 
-  if ( instfp == NULL ) return (instID);
+  if ( instfp == NULL ) return instID;
 
   while ( readline(instfp, line, 1024) )
     {
@@ -92,18 +91,14 @@ int readInstitution(const char *instfile)
   if ( instID == UNDEFID )
     instID = institutDef(center, subcenter, name, longname);
 
-  return (instID);
+  return instID;
 }
 
 
-void defineInstitution(char *instarg)
+void defineInstitution(const char *instarg)
 {
-  char *instname;
-  int instID;
-
-  instname = instarg;
-
-  instID = readInstitution(instname);
+  const char *instname = instarg;
+  int instID = readInstitution(instname);
 
   if ( instID == UNDEFID )
     instID = institutInq(0, 0, instname, NULL);
diff --git a/src/interpol.c b/src/interpol.c
index 5e08408..2bb727d 100644
--- a/src/interpol.c
+++ b/src/interpol.c
@@ -227,7 +227,7 @@ void intlinarr2(double missval, int lon_is_circular,
 		long nxm, long nym,  const double *restrict fieldm, const double *restrict xm, const double *restrict ym,
 		long gridsize2, double *field, const double *restrict x, const double *restrict y)
 {
-  long i, ii, jj;
+  long ii, jj;
   long gridsize1;
   long nlon1 = nxm;
   double findex = 0;
@@ -236,7 +236,7 @@ void intlinarr2(double missval, int lon_is_circular,
   if ( lon_is_circular ) nlon1--;
   gridsize1 = nlon1*nym;
 
-  grid1_mask = (int*) calloc(1, gridsize1*sizeof(int));
+  grid1_mask = (int*) Calloc(1, gridsize1*sizeof(int));
   for ( jj = 0; jj < nym; ++jj )
     for ( ii = 0; ii < nlon1; ++ii )
       {
@@ -248,9 +248,9 @@ void intlinarr2(double missval, int lon_is_circular,
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) \
   shared(ompNumThreads, field, fieldm, x, y, xm, ym, nxm, nym, gridsize2, missval, findex, nlon1, lon_is_circular, grid1_mask) \
-  private(i, jj, ii)
+  private(jj,ii)
 #endif
-  for ( i = 0; i < gridsize2; ++i )
+  for ( int i = 0; i < gridsize2; ++i )
     {
       int src_add[4];                /*  address for the four source points    */
       long n;
@@ -316,7 +316,7 @@ void intlinarr2(double missval, int lon_is_circular,
  
   if ( findex < gridsize2 ) progressStatus(0, 1, 1);
 
-  if ( grid1_mask ) free(grid1_mask);
+  if ( grid1_mask ) Free(grid1_mask);
 }
 
 static
@@ -367,7 +367,7 @@ void intconarr2(double missval, int lon_is_circular,
 {
   long ndeps;
   int *deps;
-  long i, ii = -1, jj = -1;
+  long ii = -1, jj = -1;
   long gridsize1;
   long nlon1 = nxm;
   long nx, ny;
@@ -380,9 +380,9 @@ void intconarr2(double missval, int lon_is_circular,
   //if ( lon_is_circular ) nlon1--;
   gridsize1 = nx*ny;
 
-  deps = (int*) malloc(gridsize1*sizeof(int));
+  deps = (int*) Malloc(gridsize1*sizeof(int));
 
-  grid1_mask = (int*) calloc(1, gridsize1*sizeof(int));
+  grid1_mask = (int*) Calloc(1, gridsize1*sizeof(int));
   for ( jj = 0; jj < ny; ++jj )
     for ( ii = 0; ii < nx; ++ii )
       {
@@ -410,28 +410,28 @@ void intconarr2(double missval, int lon_is_circular,
   double weight_sum;
 
   double *weight;
-  weight = (double*) malloc(gridsize1*sizeof(double));
+  weight = (double*) Malloc(gridsize1*sizeof(double));
 
   double tgt_area;
   double *area;
-  area = (double*) malloc(gridsize1*sizeof(double));
+  area = (double*) Malloc(gridsize1*sizeof(double));
 
   struct grid_cell *SourceCell;
-  SourceCell = (struct grid_cell*) malloc(gridsize1  * sizeof(struct grid_cell));
+  SourceCell = (struct grid_cell*) Malloc(gridsize1  * sizeof(struct grid_cell));
 
   for ( int n = 0; n <  gridsize1; n++ ) {
     SourceCell[n].num_corners   = 4;
     SourceCell[n].edge_type     = quad_type;
-    SourceCell[n].coordinates_x = (double*) malloc(4 * sizeof(double));
-    SourceCell[n].coordinates_y = (double*) malloc(4 * sizeof(double));
+    SourceCell[n].coordinates_x = (double*) Malloc(4 * sizeof(double));
+    SourceCell[n].coordinates_y = (double*) Malloc(4 * sizeof(double));
   }
 
   struct grid_cell  TargetCell;
 
   TargetCell.num_corners   = nc2;
   TargetCell.edge_type     = quad_type;
-  TargetCell.coordinates_x = (double*) malloc(nc2 * sizeof(double));
-  TargetCell.coordinates_y = (double*) malloc(nc2 * sizeof(double));
+  TargetCell.coordinates_x = (double*) Malloc(nc2 * sizeof(double));
+  TargetCell.coordinates_y = (double*) Malloc(nc2 * sizeof(double));
 
   unsigned const * curr_deps;
 #endif
@@ -440,10 +440,10 @@ void intconarr2(double missval, int lon_is_circular,
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) \
   shared(ompNumThreads, field, fieldm, x, y, xm, ym, nxm, nym, gridsize2, missval, findex, nlon1, lon_is_circular, grid1_mask, nc2) \
-  private(i, jj, ii)
+  private(jj, ii)
 #endif
   */
-  for ( i = 0; i < gridsize2; ++i )
+  for ( int i = 0; i < gridsize2; ++i )
     {
       int src_add[4];                /*  address for the four source points    */
       long n;
@@ -645,14 +645,14 @@ void intconarr2(double missval, int lon_is_circular,
     }
  
 #if defined(HAVE_LIBYAC)
-  free(weight);
-  free(area);
+  Free(weight);
+  Free(area);
 #endif
 
   if ( findex < gridsize2 ) progressStatus(0, 1, 1);
 
-  if ( deps ) free(deps);
-  if ( grid1_mask ) free(grid1_mask);
+  if ( deps ) Free(deps);
+  if ( grid1_mask ) Free(grid1_mask);
 }
 
 
@@ -718,13 +718,13 @@ void intgridbil(field_t *field1, field_t *field2)
   nlon1 = gridInqXsize(gridID1);
   nlat1 = gridInqYsize(gridID1);
 
-  array1_2D = (double **) malloc(nlat1*sizeof(double *));
+  array1_2D = (double **) Malloc(nlat1*sizeof(double *));
   for ( ilat = 0; ilat < nlat1; ilat++ )
     array1_2D[ilat] = array1 + ilat*nlon1;
 
   if ( lon_is_circular ) nlon1 += 1;
-  lon1 = (double*) malloc(nlon1*sizeof(double));
-  lat1 = (double*) malloc(nlat1*sizeof(double));
+  lon1 = (double*) Malloc(nlon1*sizeof(double));
+  lat1 = (double*) Malloc(nlat1*sizeof(double));
   gridInqXvals(gridID1, lon1);
   gridInqYvals(gridID1, lat1);
   if ( lon_is_circular ) lon1[nlon1-1] = 0;
@@ -756,9 +756,9 @@ void intgridbil(field_t *field1, field_t *field2)
       if ( lon2 > lon1[nlon1-1] )
 	{
 	  field  = array1_2D;
-	  array1_2D = (double **) malloc(nlat1*sizeof(double *));
-	  lon1 = (double*) realloc(lon1, (nlon1+1)*sizeof(double));
-	  array = (double*) malloc(nlat1*(nlon1+1)*sizeof(double));
+	  array1_2D = (double **) Malloc(nlat1*sizeof(double *));
+	  lon1 = (double*) Realloc(lon1, (nlon1+1)*sizeof(double));
+	  array = (double*) Malloc(nlat1*(nlon1+1)*sizeof(double));
 
 	  for ( ilat = 0; ilat < nlat1; ilat++ )
 	    {
@@ -768,7 +768,7 @@ void intgridbil(field_t *field1, field_t *field2)
 	      lon1[nlon1] = lon1[0] + 2*M_PI;
 	    }
 	  nlon1++;
-	  free(field);
+	  Free(field);
 	}
 
       if ( lon2 < lon1[0] || lon2 > lon1[nlon1-1] )
@@ -798,8 +798,8 @@ void intgridbil(field_t *field1, field_t *field2)
 
       gridsize2 = gridInqSize(gridID2);
 
-      lon2 = (double*) malloc(gridsize2*sizeof(double));
-      lat2 = (double*) malloc(gridsize2*sizeof(double));
+      lon2 = (double*) Malloc(gridsize2*sizeof(double));
+      lat2 = (double*) Malloc(gridsize2*sizeof(double));
       gridInqXvals(gridID2, lon2);
       gridInqYvals(gridID2, lat2);
 
@@ -824,14 +824,14 @@ void intgridbil(field_t *field1, field_t *field2)
 
       field2->nmiss = nmiss;
 
-      free(lon2);
-      free(lat2);
+      Free(lon2);
+      Free(lat2);
     }
 
-  if (array) free(array);
-  free(lon1);
-  free(lat1);
-  free(array1_2D);
+  if (array) Free(array);
+  Free(lon1);
+  Free(lat1);
+  Free(array1_2D);
 }
 
 
@@ -867,8 +867,8 @@ void intgridcon(field_t *field1, field_t *field2)
   nlon1 = gridInqXsize(gridID1);
   nlat1 = gridInqYsize(gridID1);
 
-  lon1 = (double*) malloc(nlon1*sizeof(double));
-  lat1 = (double*) malloc(nlat1*sizeof(double));
+  lon1 = (double*) Malloc(nlon1*sizeof(double));
+  lat1 = (double*) Malloc(nlat1*sizeof(double));
   gridInqXvals(gridID1, lon1);
   gridInqYvals(gridID1, lat1);
 
@@ -879,8 +879,8 @@ void intgridcon(field_t *field1, field_t *field2)
 
   nlon1b = nlon1 + 1;
   nlat1b = nlat1 + 1;
-  lon1bounds = (double*) malloc(nlon1b*sizeof(double));
-  lat1bounds = (double*) malloc(nlat1b*sizeof(double));
+  lon1bounds = (double*) Malloc(nlon1b*sizeof(double));
+  lat1bounds = (double*) Malloc(nlat1b*sizeof(double));
 
   grid_gen_corners(nlon1, lon1, lon1bounds);
   grid_gen_corners(nlat1, lat1, lat1bounds);
@@ -919,8 +919,8 @@ void intgridcon(field_t *field1, field_t *field2)
 
   if ( gridInqYbounds(gridID2, NULL) && gridInqXbounds(gridID2, NULL) )
     {
-      grid2_corner_lon = (double*) malloc(nc2*gridsize2*sizeof(double));
-      grid2_corner_lat = (double*) malloc(nc2*gridsize2*sizeof(double));
+      grid2_corner_lon = (double*) Malloc(nc2*gridsize2*sizeof(double));
+      grid2_corner_lat = (double*) Malloc(nc2*gridsize2*sizeof(double));
       gridInqXbounds(gridID2, grid2_corner_lon);
       gridInqYbounds(gridID2, grid2_corner_lat);
     }
@@ -952,12 +952,12 @@ void intgridcon(field_t *field1, field_t *field2)
 
   field2->nmiss = nmiss;
 
-  if (grid2_corner_lon) free(grid2_corner_lon);
-  if (grid2_corner_lat) free(grid2_corner_lat);
+  if (grid2_corner_lon) Free(grid2_corner_lon);
+  if (grid2_corner_lat) Free(grid2_corner_lat);
 
-  if (array) free(array);
-  free(lon1);
-  free(lat1);
+  if (array) Free(array);
+  Free(lon1);
+  Free(lat1);
 }
 
 
@@ -1009,8 +1009,8 @@ void interpolate(field_t *field1, field_t *field2)
   out_nlon = gridInqXsize(gridIDo);
   out_nlat = gridInqYsize(gridIDo);
 
-  lon_array = (double*) malloc((nlon + 2) * sizeof(double));
-  lat_array = (double*) malloc((nlat + 2) * sizeof(double));
+  lon_array = (double*) Malloc((nlon + 2) * sizeof(double));
+  lat_array = (double*) Malloc((nlat + 2) * sizeof(double));
   lon = lon_array + 1;
   lat = lat_array + 1;
 
@@ -1061,9 +1061,9 @@ void interpolate(field_t *field1, field_t *field2)
   if ( lat[nlat] < -90 ) lat[nlat] = -99;
   if ( lat[nlat] >  90 ) lat[nlat] =  99;
 
-  lono_array = (double*) malloc((out_nlon < 2 ? 4 : out_nlon + 2) * sizeof(double));
+  lono_array = (double*) Malloc((out_nlon < 2 ? 4 : out_nlon + 2) * sizeof(double));
   lono = lono_array + 1;
-  lato_array = (double*) malloc((out_nlat < 2 ? 4 : out_nlat + 2) * sizeof(double));
+  lato_array = (double*) Malloc((out_nlat < 2 ? 4 : out_nlat + 2) * sizeof(double));
   lato = lato_array + 1;
 
   gridInqXvals(gridIDo, lono);
@@ -1135,13 +1135,13 @@ void interpolate(field_t *field1, field_t *field2)
 
   nxlon = 2*nlon + 1;
   nxlat = 2*nlat + 1;
-  xin_array = (double*) malloc(nxlon * nxlat * sizeof(double));
-  xin = (double **) malloc(nxlat * sizeof(double *));
+  xin_array = (double*) Malloc(nxlon * nxlat * sizeof(double));
+  xin = (double **) Malloc(nxlat * sizeof(double *));
 
   for (ilat = 0; ilat < nxlat; ilat++)
     xin[ilat] = xin_array + ilat * nxlon;
 
-  xlon = (double *) malloc(nxlon * sizeof(double));
+  xlon = (double *) Malloc(nxlon * sizeof(double));
   for ( ilon = 0; ilon < nlon; ilon++ )
     {
       xlon[2*ilon + 1] = lon[ilon];
@@ -1149,7 +1149,7 @@ void interpolate(field_t *field1, field_t *field2)
     }
   xlon[2 * nlon] = (lon[nlon - 1] + lon[nlon]) / 2;
 
-  xlat = (double*) malloc((2 * nlat + 1) * sizeof(double));
+  xlat = (double*) Malloc((2 * nlat + 1) * sizeof(double));
   for ( ilat = 0; ilat < nlat; ilat++ )
     {
       xlat[2*ilat + 1] = lat[ilat];
@@ -1157,18 +1157,18 @@ void interpolate(field_t *field1, field_t *field2)
     }
   xlat[2 * nlat] = (lat[nlat - 1] + lat[nlat]) / 2;
 
-  in0 = (double**) malloc(nlat * sizeof(double*));
+  in0 = (double**) Malloc(nlat * sizeof(double*));
   for (ilat = 0; ilat < nlat; ilat++)
     in0[ilat] = arrayIn + ilat * nlon;
 
-  ilon11 = (long*) malloc(out_nlon * sizeof(long));
-  ilon12 = (long*) malloc(out_nlon * sizeof(long));
-  ilon21 = (long*) malloc(out_nlon * sizeof(long));
-  ilon22 = (long*) malloc(out_nlon * sizeof(long));
-  volon11 = (double*) malloc(out_nlon * sizeof(double));
-  volon12 = (double*) malloc(out_nlon * sizeof(double));
-  volon21 = (double*) malloc(out_nlon * sizeof(double));
-  volon22 = (double*) malloc(out_nlon * sizeof(double));
+  ilon11 = (long*) Malloc(out_nlon * sizeof(long));
+  ilon12 = (long*) Malloc(out_nlon * sizeof(long));
+  ilon21 = (long*) Malloc(out_nlon * sizeof(long));
+  ilon22 = (long*) Malloc(out_nlon * sizeof(long));
+  volon11 = (double*) Malloc(out_nlon * sizeof(double));
+  volon12 = (double*) Malloc(out_nlon * sizeof(double));
+  volon21 = (double*) Malloc(out_nlon * sizeof(double));
+  volon22 = (double*) Malloc(out_nlon * sizeof(double));
 
   for (olon = 0; olon < out_nlon; olon++)
     {
@@ -1193,8 +1193,8 @@ void interpolate(field_t *field1, field_t *field2)
       ilon22[olon] = l22;
     }
 
-  ilat1 = (long*) malloc(out_nlat * sizeof(long));
-  ilat2 = (long*) malloc(out_nlat * sizeof(long));
+  ilat1 = (long*) Malloc(out_nlat * sizeof(long));
+  ilat2 = (long*) Malloc(out_nlat * sizeof(long));
 
   xlat_is_ascending = xlat[0] <= xlat[nxlat - 1];
   for ( olat = 0; olat < out_nlat; olat++ )
@@ -1232,7 +1232,7 @@ void interpolate(field_t *field1, field_t *field2)
       ilat2[olat] = l2;
     }
 
-  xout = (double**) malloc(out_nlat * sizeof(double*));
+  xout = (double**) Malloc(out_nlat * sizeof(double*));
   for (olat = 0; olat < out_nlat; olat++)
     xout[olat] = arrayOut + olat * out_nlon;
 
@@ -1462,26 +1462,26 @@ void interpolate(field_t *field1, field_t *field2)
 
   field2->nmiss = nmiss;
 
-  free(lon_array);
-  free(lat_array);
-  free(lono_array);
-  free(lato_array);
-  free(xin);
-  free(xin_array);
-  free(xlon);
-  free(xlat);
-  free(in0);
-  free(ilon11);
-  free(ilon12);
-  free(ilon21);
-  free(ilon22);
-  free(volon11);
-  free(volon12);
-  free(volon21);
-  free(volon22);
-  free(ilat1);
-  free(ilat2);
-  free(xout);
+  Free(lon_array);
+  Free(lat_array);
+  Free(lono_array);
+  Free(lato_array);
+  Free(xin);
+  Free(xin_array);
+  Free(xlon);
+  Free(xlat);
+  Free(in0);
+  Free(ilon11);
+  Free(ilon12);
+  Free(ilon21);
+  Free(ilon22);
+  Free(volon11);
+  Free(volon12);
+  Free(volon21);
+  Free(volon22);
+  Free(ilat1);
+  Free(ilat2);
+  Free(xout);
 }
 
 
@@ -1537,17 +1537,17 @@ void contrast(void)
 
   if (rec == 1)
     {
-      xin_array = (double*) malloc((nlat + 2) * (nlon + 2) * sizeof(double));
-      xin = (double **) malloc((nlat + 2) * sizeof(double *));
+      xin_array = (double*) Malloc((nlat + 2) * (nlon + 2) * sizeof(double));
+      xin = (double **) Malloc((nlat + 2) * sizeof(double *));
       *xin = *(xin + 1);
       for (ilat = -1; ilat <= nlat; ilat++)
 	xin[ilat] = xin_array + (ilat + 1) * (nlon + 2) + 1;
-      xout = (double **) malloc(nlat * sizeof(double *));
+      xout = (double **) Malloc(nlat * sizeof(double *));
       for (ilat = 0; ilat < nlat; ilat++)
 	xout[ilat] = out[0] + ilat * nlon;
       for (j = 0; j < 17; j++)
 	{
-	  xwork[j] = (double **) malloc(nlat * sizeof(double *));
+	  xwork[j] = (double **) Malloc(nlat * sizeof(double *));
 	  for (ilat = 0; ilat < nlat; ilat++)
 	    xwork[j][ilat] = work[j] + ilat * nlon;
 	}
@@ -2017,9 +2017,9 @@ void contrast(void)
   iter_sum = iter_sum * 0.9 + iter;
   iter_n = iter_n * 0.9 + 1;
 
-  free(xin_array);
-  free(xin);
-  free(xout);
+  Free(xin_array);
+  Free(xin);
+  Free(xout);
   for (j = 0; j < 17; j++)
-    free(xwork[j]);
+    Free(xwork[j]);
 }
diff --git a/src/job.c b/src/job.c
index 88c45bc..bc851ba 100644
--- a/src/job.c
+++ b/src/job.c
@@ -6,16 +6,12 @@
 #define _XOPEN_SOURCE 600 /* gethostname */
 #endif
 
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdlib.h>
+#include "cdo_int.h"
 
 #include <sys/types.h>  /* fstat */
 #include <sys/stat.h>
 #include <unistd.h>
 
-#include "cdo.h"
 
 #if defined(HAVE_LIBDRMAA)
 #  include "drmaa.h"
@@ -59,7 +55,7 @@ static drmaa_job_template_t *create_job_template(const char *expname, const char
   /* determine current path */
 
   size = pathconf(".", _PC_PATH_MAX);
-  if ( (dir = (char*) malloc((size_t)size)) != NULL )
+  if ( (dir = (char*) Malloc((size_t)size)) != NULL )
     {
       ptr = getcwd(dir, (size_t)size);
     }
@@ -71,7 +67,7 @@ static drmaa_job_template_t *create_job_template(const char *expname, const char
   len2 = strlen(GRID_TMPDIR);
   len = len1+len2+2;
 
-  output_path = (char*) malloc(len*sizeof(char));
+  output_path = (char*) Malloc(len*sizeof(char));
   /*
   strcpy(output_path, host);
   strcat(output_path, ":");
@@ -124,7 +120,7 @@ static drmaa_job_template_t *create_job_template(const char *expname, const char
       fprintf (stderr, "name: %-25s \t %s\n", name, value);
     }
 
-  free(dir);
+  Free(dir);
 
   return job;
 }
@@ -583,7 +579,7 @@ int ftprmd(const char *url, const char *path)
 #define  DEFAULT_CDO_REMOTE_PATH  "/client/bin/cdo"
 const char *cdojobfiles  = "ftp_files";
 
-void exp_run(int argc, char *argv[], char *cdoExpName)
+void exp_run(int argc, char *argv[], const char *cdoExpName)
 {
   char commandline[65536];
   int i;
diff --git a/src/kdtreelib/kdtree.h b/src/kdtreelib/kdtree.h
new file mode 100644
index 0000000..398b3f3
--- /dev/null
+++ b/src/kdtreelib/kdtree.h
@@ -0,0 +1,173 @@
+/*! \file kdtree.h
+ * \brief Include file for the kdtree library 
+ */
+
+/*
+  Code from: https://github.com/joergdietrich/libkdtree
+  Uwe Schulzweida, 20150720: changed data pointer to unsigned int
+                             changed *point to point[KD_MAX_DIM]
+                             changed *location to location[KD_MAX_DIM]
+                             changed *min to min[KD_MAX_DIM]
+                             changed *max to max[KD_MAX_DIM]
+                             _compPoints: compare index if points[axis] are equal
+                             replace qsortR by libc:qsort (speedup 25%)
+*/
+#ifndef _KDTREE_H_
+#define _KDTREE_H_
+
+#include <math.h>
+#include <pthread.h>
+#include <stdlib.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <string.h>
+
+#define KD_MAX_DIM 3
+
+typedef struct kd_point {
+    float point[KD_MAX_DIM];
+    unsigned index;
+} kd_point;
+
+/*!
+ * \struct kdNode 
+ * \brief kd-tree node structure definition 
+ */
+typedef struct kdNode {
+    float location[KD_MAX_DIM]; /*!<vector to the node's location */
+    float min[KD_MAX_DIM];      /*!<vector to the min coordinates of the hyperrectangle */
+    float max[KD_MAX_DIM];      /*!<vector to the max coordinates of the hyperrectangle */
+    int split;                  /*!<axis along which the tree bifurcates */
+    unsigned index;             /*!<optional index value */
+    struct kdNode *left;        /*!<the left child of the tree node */
+    struct kdNode *right;       /*!<the right child of the tree node */
+} kdNode;
+
+/*!
+ * \struct resItem
+ * \brief result items, member of a priority queue 
+ */
+typedef struct resItem {
+    struct kdNode *node;        /*!<pointer to a kdNode */
+    float dist_sq;              /*!<distance squared as the priority */
+} resItem;
+
+/*!
+ * \struct pqueue
+ * \brief priority queue (min-max heap)
+ */
+typedef struct pqueue {
+    uint32_t size;              /*!<current length of the queue */
+    uint32_t avail;             /*!<currently allocated queue elements */
+    uint32_t step;              /*!<step size in which new elements are allocated */
+    struct resItem **d;         /*!<pointer to an array of result items */
+} pqueue;
+
+/*!
+ * \struct kd_thread_data
+ * \brief arguments passed to the threaded kd-Tree construction
+ */
+typedef struct kd_thread_data {
+    int max_threads;
+    struct kd_point *points;
+    unsigned long nPoints;
+    float min[KD_MAX_DIM];
+    float max[KD_MAX_DIM];
+    int depth;
+    int dim;
+} kd_thread_data;
+
+
+#define KD_ORDERED   (1)
+#define KD_UNORDERED (0)
+
+/* functions for the priority queue */
+struct pqueue *pqinit(struct pqueue *q, uint32_t n);
+int pqinsert(struct pqueue *q, struct resItem *d);
+struct resItem **pqremove_min(struct pqueue *q, struct resItem **d);
+struct resItem **pqremove_max(struct pqueue *q, struct resItem **d);
+struct resItem **pqpeek_min(struct pqueue *q, struct resItem **d);
+struct resItem **pqpeek_max(struct pqueue *q, struct resItem **d);
+
+
+/* general utility functions */
+void *kd_malloc(size_t size, const char *msg);
+int kd_isleaf(struct kdNode *n);
+/* Cartesian */
+float kd_sqr(float a);
+float kd_min(float x, float y);
+/* Spherical */
+float kd_sph_orth_dist(float *p1, float *p2, int split);
+float kd_sph_dist_sq(float *x, float *y);
+float kd_sph_dist(float *x, float *y);
+float kd_sph_bearing(float *p1, float *p2);
+float kd_sph_xtd(float *p1, float *p2, float *p3);
+
+/* helper functions for debugging */
+void kd_printNode(struct kdNode *node);
+void kd_printTree(struct kdNode *node);
+
+/* Functions for building and destroying trees */
+void kd_freeNode(kdNode * node);
+struct kdNode *kd_allocNode(struct kd_point *points, unsigned long pivot,
+                            float *min, float *max, int dim, int axis);
+void kd_destroyTree(struct kdNode *node);
+struct kd_thread_data *kd_buildArg(struct kd_point *points,
+                                   unsigned long nPoints,
+                                   float *min, float *max,
+                                   int depth, int max_threads,
+                                   int dim);
+struct kdNode *kd_buildTree(struct kd_point *points, unsigned long nPoints,
+                            float *min, float *max, int dim, int max_threads);
+void *kd_doBuildTree(void *threadarg);
+struct kdNode *kd_sph_buildTree(struct kd_point *points,
+                                unsigned long nPoints,
+                                float *min, float *max,
+                                int max_threads);
+void *kd_sph_doBuildTree(void *threadarg);
+
+/* Functions for range searches 
+ * Cartesian
+ */
+int kd_isPointInRect(struct kdNode *node, float *min, float *max, int dim);
+int kd_isRectInRect(struct kdNode *node, float *min, float *max, int dim);
+int kd_rectOverlapsRect(struct kdNode *node, float *min, float *max, int dim);
+struct pqueue *kd_ortRangeSearch(struct kdNode *node, float *min, float *max,
+                                 int dim);
+int kd_doOrtRangeSearch(struct kdNode *node, float *min, float *max, int dim,
+                        struct pqueue *res);
+struct kdNode *kd_nearest(struct kdNode *node, float *p, float *max_dist_sq,
+                          int dim);
+struct pqueue *kd_qnearest(struct kdNode *node, float *p,
+                           float *max_dist_sq, unsigned int q, int dim);
+int kd_doQnearest(struct kdNode *node, float *p,
+                  float *max_dist_sq, unsigned int q, int dim,
+                  struct pqueue *res);
+struct pqueue *kd_range(struct kdNode *node, float *p, float *max_dist_sq,
+                        int dim, int ordered);
+int kd_doRange(struct kdNode *node, float *p, float *max_dist_sq,
+               int dim, struct pqueue *res, int ordered);
+/* spherical */
+int kd_sph_isPointInRect(struct kdNode *node, float *min, float *max);
+int kd_sph_isRectInRect(struct kdNode *node, float *min, float *max);
+int kd_sph_rectOverlapsRect(struct kdNode *node, float *min, float *max);
+struct pqueue *kd_sph_ortRangeSearch(struct kdNode *node, float *min,
+                                     float *max);
+int kd_sph_doOrtRangeSearch(struct kdNode *node, float *min, float *max,
+                            struct pqueue *res);
+struct kdNode *kd_sph_nearest(struct kdNode *node, float *p,
+                              float *max_dist_sq);
+struct pqueue *kd_sph_qnearest(struct kdNode *node, float *p,
+                               float *max_dist_sq, unsigned int q);
+int kd_sph_doQnearest(struct kdNode *node, float *p,
+                      float *max_dist_sq, unsigned int q, struct pqueue *res);
+struct pqueue *kd_sph_range(struct kdNode *node, float *p, float *max_dist_sq,
+                            int ordered);
+int kd_sph_doRange(struct kdNode *node, float *p, float *max_dist_sq,
+                   struct pqueue *res, int ordered);
+
+/* Functions for results heaps */
+int kd_insertResTree(struct kdNode *node, struct pqueue *res);
+
+
+#endif                          /* _KDTREE_H_ */
diff --git a/src/kdtreelib/kdtree_cartesian.c b/src/kdtreelib/kdtree_cartesian.c
new file mode 100644
index 0000000..46181a2
--- /dev/null
+++ b/src/kdtreelib/kdtree_cartesian.c
@@ -0,0 +1,531 @@
+/*!\file kdtree_cartesian.c
+ * \brief Routines specific to the n-dimensional cartesian kd-tree
+ *
+ */
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
+#include "kdtree.h"
+#include "pqueue.h"
+
+/* ********************************************************************
+
+   general utility functions 
+
+   ********************************************************************* */
+
+
+static
+float square(const float x)
+{
+  return x*x;
+}
+
+static
+float kd_dist_sq(const float *restrict a, const float *restrict b, int dim)
+{
+  return (square((a[0]-b[0]))+square((a[1]-b[1]))+square((a[2]-b[2])));
+}
+
+inline float
+kd_dist_sq_ori(float *x, float *y, int dim)
+{
+    int i;
+    float dsq = 0;
+
+    if (!x || !y)
+        return -1;
+
+    for(i = 0; i < dim; i++)
+        dsq += kd_sqr(x[i] - y[i]);
+    return dsq;
+}
+
+inline float
+kd_min(float x, float y)
+{
+    return x < y ? x : y;
+}
+
+
+/* ******************************************************************
+   
+   Functions for building and destroying trees 
+
+   ******************************************************************** */
+
+
+/*! \brief build kd-tree structure
+ *
+ * \param points an array of kd_points (struct with position vector
+ * and data container).
+ *
+ * \param nPoints the length of the points array.
+ *
+ * \param constr a pointer to a void *constructor() function to include
+ * the data container in the tree; optional, can be NULL
+ *
+ * \param destr a pointer to a void destructor() function to free()
+ * the data containers in the tree; optional, can be NULL, but should
+ * be given if the constr argument is non-NULL.
+ *
+ * \param min a vector with the minimum positions of the corners of the
+ * hyperrectangle containing the data.
+ *
+ * \param max a vector with the maximum positions of the corners of
+ * the hyperrectangle containing the data.
+ *
+ * \param dim the dimensionality of the data.
+ *
+ * \param max_threads the maximal number of threads spawned for
+ * construction of the tree. The threads will be unbalanced if this is
+ * not a power of 2.
+ *
+ * \return root node of the tree
+ */
+struct kdNode *
+kd_buildTree(struct kd_point *points, unsigned long nPoints,
+             float *min, float *max, int dim, int max_threads)
+{
+    struct kd_thread_data *my_data;
+    struct kdNode *tree;
+
+    my_data = kd_buildArg(points, nPoints, min, max, 0, max_threads, dim);
+    tree = (kdNode *)kd_doBuildTree(my_data);
+    free(my_data);
+    return tree;
+}
+
+
+/* *******************************************************************
+
+   Functions for range searches 
+  
+   *******************************************************************
+*/
+
+/* Returns 1 if node is a point in the hyperrectangle defined by
+   minimum and maximum vectors min and max. */
+int
+kd_isPointInRect(struct kdNode *node, float *min, float *max, int dim)
+{
+    int i;
+
+    if (node == NULL)
+        return 0;
+
+    for(i = 0; i < dim; i++) {
+        if (node->location[i] < min[i] || node->location[i] > max[i])
+            return 0;
+    }
+    return 1;
+}
+
+/* Returns 1 if the hyperrectangle of node is fully contained within
+   the HR described by the minimum and maximum vectors min and
+   max. Returns 0 otherwise. */
+int
+kd_isRectInRect(struct kdNode *node, float *min, float *max, int dim)
+{
+    int i;
+
+    if (node == NULL)
+        return 0;
+
+    for(i = 0; i < dim; i++) {
+        if (node->min[i] < min[i] || node->max[i] > max[i])
+            return 0;
+    }
+    return 1;
+}
+
+/* Returns 1 if the hyperrectangle of node overlaps the HR described
+   the minimum and maximum vectors min and max. Returns 0
+   otherwise. */
+int
+kd_rectOverlapsRect(struct kdNode *node, float *min, float *max, int dim)
+{
+    int i;
+
+    if (node == NULL)
+        return 0;
+
+    for(i = 0; i < dim; i++) {
+        if ((node->min[i] > max[i] || node->max[i] < min[i]))
+            return 0;
+    }
+    return 1;
+}
+
+/*!
+ * \brief Perform orthogonal range search (get all points in a
+ * hyperrectangle).
+ *
+ * \param node the root node of tree to be searched.
+ *
+ * \param min a vector with the minimum positions of the corners of the
+ * hyperrectangle containing the data.
+ *
+ * \param max a vector with the maximum positions of the corners of
+ * the hyperrectangle containing the data.
+ *
+ * \param dim the dimension of the data.
+ *
+ * \return  Pointer to a priority queue, NULL in case of problems.
+*/
+struct pqueue *
+kd_ortRangeSearch(struct kdNode *node, float *min, float *max, int dim)
+{
+    struct pqueue *res;
+    uint32_t i;
+
+    if ((res = pqinit(NULL, 1)) == NULL)
+        return NULL;
+    if (!kd_doOrtRangeSearch(node, min, max, dim, res)) {
+        for(i = 0; i < res->size; i++) {
+            free(res->d[i]);
+        }
+        free(res->d);
+        free(res);
+        return NULL;
+    }
+    return res;
+}
+
+/* This is the orthogonal range search. Returns 1 if okay, 0 in case
+   of problems. */
+int
+kd_doOrtRangeSearch(struct kdNode *node, float *min, float *max,
+                    int dim, struct pqueue *res)
+{
+
+    if (node == NULL)
+        return 1;
+
+    if (kd_isleaf(node) && kd_isPointInRect(node, min, max, dim)) {
+        return kd_insertResTree(node, res);
+    } else {
+        if (kd_isRectInRect(node->left, min, max, dim)) {
+            if (!kd_insertResTree(node->left, res))
+                return 0;
+        } else {
+            if (kd_rectOverlapsRect(node->left, min, max, dim))
+                if (!kd_doOrtRangeSearch(node->left, min, max, dim, res))
+                    return 0;
+        }
+        if (kd_isRectInRect(node->right, min, max, dim)) {
+            if (!kd_insertResTree(node->right, res))
+                return 0;
+        } else {
+            if (kd_rectOverlapsRect(node->right, min, max, dim))
+                if (!kd_doOrtRangeSearch(node->right, min, max, dim, res))
+                    return 0;
+        }
+    }
+    return 1;
+}
+
+/*! 
+ * \brief Find the nearest neighbor of a point.
+ *
+ * \param node the root node of the tree to be searched.
+ *
+ * \param p a vector to the point whose nearest neighbor is sought.
+ *
+ * \param max_dist_sq the square of the maximum distance to the
+ * nearest neighbor.
+ *
+ * \param dim the dimension of the data.
+ *
+ * \return A pointer to node containing the nearest neighbor.
+ * max_dist_sq is set to the square of the distance to the nearest
+ * neigbor.
+ */
+struct kdNode *
+kd_nearest(struct kdNode *node, float *p, float *max_dist_sq, int dim)
+{
+    struct kdNode *nearer, *further, *nearest = NULL, *tmp, *tmp_nearest;
+    float dist_sq, tmp_dist_sq, dx;
+
+    if (!node)
+        return NULL;
+
+    if (p[node->split] < node->location[node->split]) {
+        nearer = node->left;
+        further = node->right;
+    } else {
+        nearer = node->right;
+        further = node->left;
+    }
+    tmp = kd_nearest(nearer, p, max_dist_sq, dim);
+    if (tmp)
+        nearest = tmp;
+    else
+        nearest = node;
+
+    dist_sq = kd_dist_sq(nearest->location, p, dim);
+    if (*max_dist_sq > dist_sq)
+	*max_dist_sq = dist_sq;
+
+    if (!further)
+        return nearest;
+
+    dx = kd_min(fabs(p[node->split] - further->min[node->split]),
+                fabs(p[node->split] - further->max[node->split]));
+    if (*max_dist_sq > kd_sqr(dx)) {
+        /*
+         * some part of the further hyper-rectangle is in the search
+         * radius, search the further node 
+         */
+        tmp = kd_nearest(further, p, max_dist_sq, dim);
+        if (tmp)
+            tmp_nearest = tmp;
+        else
+            tmp_nearest = further;
+
+        tmp_dist_sq = kd_dist_sq(tmp_nearest->location, p, dim);
+        if (tmp_dist_sq < dist_sq) {
+            nearest = tmp_nearest;
+            dist_sq = tmp_dist_sq;
+            *max_dist_sq = kd_min(dist_sq, *max_dist_sq);
+        }
+        // Uwe Schulzweida
+        else if (tmp_dist_sq <= dist_sq && tmp_nearest->index < nearest->index) {
+            nearest = tmp_nearest;
+            dist_sq = tmp_dist_sq;
+            *max_dist_sq = kd_min(dist_sq, *max_dist_sq);
+        }
+    }
+    return nearest;
+}
+
+/*! 
+ * \brief Return the q nearest-neighbors to a point.
+ *
+ * \param node the root node of the tree to be searched.
+ *
+ * \param p a vector to the point whose nearest neighbors are sought.
+ *
+ * \param max_dist_sq the square of the maximum distance to the
+ * nearest neighbors.
+ *
+ * \param q the maximum number of points to be retured.
+ *
+ * \param dim the dimension of the data.
+ *
+ * \return A pointer to a priority queue of the points found, or NULL
+ * in case of problems.
+ */
+struct pqueue *
+kd_qnearest(struct kdNode *node, float *p,
+            float *max_dist_sq, unsigned int q, int dim)
+{
+    struct pqueue *res;
+    uint32_t i;
+
+    if ((res = pqinit(NULL, q + 2)) == NULL)
+        return NULL;
+    if (!kd_doQnearest(node, p, max_dist_sq, q + 1, dim, res)) {
+        for(i = 0; i < res->size; i++) {
+            free(res->d[i]);
+        }
+        free(res->d);
+        free(res);
+        return NULL;
+    }
+    return res;
+}
+
+/* *
+ * This is the q nearest-neighbor search.
+ *
+ * This is a modification of the range search in which the maximum
+ * search radius is decreased to the maximum of the queue as soon as
+ * the queue is filled.
+ *
+ * return 1 if okay, zero in case of problems
+ */
+// Uwe Schulzweida: extract kd_check_dist() from kd_doQnearest()
+static int
+kd_check_dist(struct kdNode *node, float *p,
+              float *max_dist_sq, unsigned int q, int dim, struct pqueue *res)
+{
+    struct resItem *point, *item;
+    float dist_sq;
+
+    dist_sq = kd_dist_sq(node->location, p, dim);
+    if (dist_sq < *max_dist_sq && kd_isleaf(node)) {
+        if ((point = (struct resItem *) kd_malloc(sizeof(struct resItem), "kd_doQnearest: "))
+            == NULL)
+            return 0;
+        point->node = node;
+        point->dist_sq = dist_sq;
+        pqinsert(res, point);
+    }
+    /*
+    else if (res->size > 1 && dist_sq <= *max_dist_sq && kd_isleaf(node)) {
+        pqpeek_max(res, &item);
+        if ( node->index < item->node->index )
+          {
+            item->node = node;
+            item->dist_sq = dist_sq;
+          }
+    }
+    */
+
+    if (res->size > q) {
+        pqremove_max(res, &item);
+        free(item);
+        if (res->size > 1) {
+            /*
+             * Only inspect the queue if there are items left 
+             */
+            pqpeek_max(res, &item);
+            *max_dist_sq = item->dist_sq;
+        } else {
+            /*
+             * Nothing was found within the max search radius 
+             */
+            *max_dist_sq = 0;
+        }
+    }
+
+    return 1;
+}
+
+int
+kd_doQnearest(struct kdNode *node, float *p,
+              float *max_dist_sq, unsigned int q, int dim, struct pqueue *res)
+{
+    struct kdNode *nearer, *further;
+    float dx;
+
+    if (!node) return 1;
+
+    if (!kd_check_dist(node, p, max_dist_sq, q, dim, res)) return 0;
+
+    if (p[node->split] < node->location[node->split]) {
+        nearer = node->left;
+        further = node->right;
+    } else {
+        nearer = node->right;
+        further = node->left;
+    }
+    if (!kd_doQnearest(nearer, p, max_dist_sq, q, dim, res)) return 0;
+
+    if (!further) return 1;
+
+    dx = kd_min(fabs(p[node->split] - further->min[node->split]),
+                fabs(p[node->split] - further->max[node->split]));
+    if (*max_dist_sq > kd_sqr(dx)) {
+        /*
+         * some part of the further hyper-rectangle is in the search
+         * radius, search the further node 
+         */
+        if (!kd_doQnearest(further, p, max_dist_sq, q, dim, res)) return 0;
+
+        if (!kd_check_dist(node, p, max_dist_sq, q, dim, res)) return 0;
+    }
+    return 1;
+}
+
+
+/*!
+ * \brief Perform a range search around a point.
+ *
+ * \param node the root node of the tree to be searched.
+ *
+ * \param p the location of the point around which the search is carried out .
+ *
+ * \param max_dist_sq the square of the radius of the hypersphere.
+ *
+ * \param dim the dimension of the data.  \param ordered determines
+ * whether the result list should be ordered in increasing distance
+ * (KD_ORDERED) or unordered (KD_UNORDERED).
+ *
+ * \return A pointer to a priority queue containing the points found,
+ * NULL in case of problems.
+ */
+struct pqueue *
+kd_range(struct kdNode *node, float *p, float *max_dist_sq,
+         int dim, int ordered)
+{
+    struct pqueue *res;
+    uint32_t i;
+
+    if ((res = pqinit(NULL, 1)) == NULL)
+        return NULL;
+    if (!kd_doRange(node, p, max_dist_sq, dim, res, ordered)) {
+        for(i = 0; i < res->size; i++) {
+            free(res->d[i]);
+        }
+        free(res->d);
+        free(res);
+        return NULL;
+    }
+    return res;
+}
+
+
+/* This is the range search. Returns 1 if okay, 0 in case of problems */
+int
+kd_doRange(struct kdNode *node, float *p, float *max_dist_sq,
+           int dim, struct pqueue *res, int ordered)
+{
+
+    struct kdNode *nearer, *further;
+    struct resItem *point;
+    float dist_sq, dx;
+
+    if (!node)
+        return 1;
+
+    dist_sq = kd_dist_sq(node->location, p, dim);
+    if (dist_sq < *max_dist_sq && kd_isleaf(node)) {
+        if ((point = (struct resItem *)kd_malloc(sizeof(struct resItem), "kd_doRange:"))
+            == NULL)
+            return 0;
+        point->node = node;
+        point->dist_sq = ordered ? dist_sq : -1;
+        pqinsert(res, point);
+    }
+
+    if (p[node->split] < node->location[node->split]) {
+        nearer = node->left;
+        further = node->right;
+    } else {
+        nearer = node->right;
+        further = node->left;
+    }
+    if (!kd_doRange(nearer, p, max_dist_sq, dim, res, ordered))
+        return 0;
+
+    if (!further)
+        return 1;
+
+    dx = kd_min(fabs(p[node->split] - further->min[node->split]),
+                fabs(p[node->split] - further->max[node->split]));
+    if (*max_dist_sq > kd_sqr(dx)) {
+        /*
+         * some part of the further hyper-rectangle is in the search
+         * radius, search the further node 
+         */
+        if (!kd_doRange(further, p, max_dist_sq, dim, res, ordered))
+            return 0;
+        dist_sq = kd_dist_sq(node->location, p, dim);
+
+        if (dist_sq < *max_dist_sq && kd_isleaf(node)) {
+            if ((point = (struct resItem *)kd_malloc(sizeof(struct resItem), "kd_doRange: "))
+                == NULL)
+                return 0;
+            point->node = node;
+            point->dist_sq = ordered ? dist_sq : -1;
+            pqinsert(res, point);
+        }
+
+    }
+    return 1;
+}
+
+/* End range searching functions */
diff --git a/src/kdtreelib/kdtree_common.c b/src/kdtreelib/kdtree_common.c
new file mode 100644
index 0000000..25c2927
--- /dev/null
+++ b/src/kdtreelib/kdtree_common.c
@@ -0,0 +1,340 @@
+/*!\file kdtree_common.c
+ * \brief Routines common to the Cartesian and spherical kd-tree versions
+ *
+ */
+
+#include "kdtree.h"
+#include "pqueue.h"
+
+
+extern int pmergesort(void *base, size_t nmemb, size_t size,
+                      int (*compar) (const void *, const void *),
+                      int max_threads);
+
+
+/* ********************************************************************
+
+   general utility functions 
+
+   ********************************************************************* */
+
+void *
+kd_malloc(size_t size, const char *msg)
+{
+    void *ptr;
+    if ((ptr = malloc(size)) == NULL)
+        perror(msg);
+    return ptr;
+}
+
+float
+kd_sqr(float x)
+{
+    return x == 0.0 ? 0.0 : x * x;
+}
+
+int
+kd_isleaf(struct kdNode *n)
+{
+    return (n->left || n->right) ? 0 : 1;
+}
+
+/* end utility functions */
+
+/* *******************************************************************
+   
+   Helper functions for debugging
+
+   ******************************************************************* */
+
+void
+kd_printNode(struct kdNode *node)
+{
+    if (!node) {
+        fprintf(stderr, "Node is empty.\n");
+        return;
+    }
+    printf("Node %p at (%f, %f)\n", (void *) node, node->location[0],
+           node->location[1]);
+
+    printf("Split axis: %d\n", node->split);
+    printf("Corners: (%f, %f)\t(%f, %f)\n", node->min[0], node->min[1],
+           node->max[0], node->max[1]);
+    printf("Children: %p\t%p\n", (void *) node->left, (void *) node->right);
+    printf("Index: %u\n", node->index);
+
+    printf("\n");
+
+}
+
+void
+kd_printTree(struct kdNode *node)
+{
+    if (node == NULL)
+        return;
+
+    kd_printTree(node->left);
+    if (kd_isleaf(node) )
+        printf("%f\t%f\n", node->location[0], node->location[1]);
+    kd_printTree(node->right);
+}
+
+/* End helper functions */
+
+/* ******************************************************************
+   
+   Functions for building and destroying trees 
+
+   ******************************************************************** */
+
+static int
+_compPoints0(const void *p1, const void *p2)
+{
+    struct kd_point *a = (struct kd_point *) p1;
+    struct kd_point *b = (struct kd_point *) p2;
+
+    if      (a->point[0] > b->point[0]) return  1;
+    else if (a->point[0] < b->point[0]) return -1;
+    else
+      {
+        if      ( a->index > b->index ) return  1;
+        else if ( a->index < b->index ) return -1;
+
+        return 0;
+      }
+}
+
+static int
+_compPoints1(const void *p1, const void *p2)
+{
+    struct kd_point *a = (struct kd_point *) p1;
+    struct kd_point *b = (struct kd_point *) p2;
+
+    if      (a->point[1] > b->point[1]) return  1;
+    else if (a->point[1] < b->point[1]) return -1;
+    else
+      {
+        if      ( a->index > b->index ) return  1;
+        else if ( a->index < b->index ) return -1;
+
+        return 0;
+      }
+}
+
+static int
+_compPoints2(const void *p1, const void *p2)
+{
+    struct kd_point *a = (struct kd_point *) p1;
+    struct kd_point *b = (struct kd_point *) p2;
+
+    if      (a->point[2] > b->point[2]) return  1;
+    else if (a->point[2] < b->point[2]) return -1;
+    else
+      {
+        if      ( a->index > b->index ) return  1;
+        else if ( a->index < b->index ) return -1;
+
+        return 0;
+      }
+}
+
+void *
+kd_doBuildTree(void *threadarg)
+{
+    int sortaxis;
+    unsigned long pivot;
+    float tmpMinLeft[KD_MAX_DIM], tmpMaxLeft[KD_MAX_DIM], tmpMinRight[KD_MAX_DIM], tmpMaxRight[KD_MAX_DIM];
+    struct kdNode *node;
+    struct kd_point *points;
+    unsigned long nPoints;
+    float *min, *max;
+    int depth, dim, max_threads;
+    pthread_t threads[2];
+    pthread_attr_t attr;
+    struct kd_thread_data *argleft, *argright;
+    struct kd_thread_data *my_data = (struct kd_thread_data *) threadarg;
+
+    points = my_data->points;
+    nPoints = my_data->nPoints;
+    min = my_data->min;
+    max = my_data->max;
+    depth = my_data->depth;
+    max_threads = my_data->max_threads;
+    dim = my_data->dim;
+
+    pthread_attr_init(&attr);
+    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
+
+    sortaxis = depth % dim;
+
+    if (nPoints == 1) {
+        if ((node = kd_allocNode(points, 0, min, max, sortaxis, dim)) == NULL)
+            return NULL;
+        node->index = points[0].index;
+        return node;
+    }
+
+    /*
+     * If this iteration is allowed to start more threads, we first
+     * use them to parallelize the sorting 
+     */
+    int (*qcomp) (const void *, const void *);
+    if      ( sortaxis == 0 ) qcomp = _compPoints0;
+    else if ( sortaxis == 1 ) qcomp = _compPoints1;
+    else                      qcomp = _compPoints2;
+
+    pmergesort(points, nPoints, sizeof(struct kd_point), qcomp, max_threads);
+
+    pivot = nPoints / 2;
+    if ((node = kd_allocNode(points, pivot, min, max, sortaxis, dim)) == NULL)
+        return NULL;
+
+    memcpy(tmpMinLeft, min, dim * sizeof(float));
+    memcpy(tmpMaxLeft, max, dim * sizeof(float));
+    tmpMaxLeft[sortaxis] = node->location[sortaxis];
+    argleft =
+        kd_buildArg(points, pivot, tmpMinLeft, tmpMaxLeft,
+                    depth + 1, max_threads / 2, dim);
+    if (!argleft) {
+        kd_destroyTree(node);
+        return NULL;
+    }
+    if (max_threads > 1) {
+        pthread_create(&threads[0], &attr, kd_doBuildTree, (void *) argleft);
+    } else {
+        node->left = (kdNode *)kd_doBuildTree((void *) argleft);
+        free(argleft);
+        if (!node->left) {
+            kd_destroyTree(node);
+            return NULL;
+        }
+    }
+
+    memcpy(tmpMinRight, min, dim * sizeof(float));
+    memcpy(tmpMaxRight, max, dim * sizeof(float));
+    tmpMinRight[sortaxis] = node->location[sortaxis];
+    argright = kd_buildArg(&points[pivot], nPoints - pivot,
+                           tmpMinRight, tmpMaxRight, depth + 1,
+                           max_threads / 2, dim);
+    if (!argright) {
+        kd_destroyTree(node);
+        return NULL;
+    }
+    if (max_threads > 1) {
+        pthread_create(&threads[1], &attr, kd_doBuildTree, (void *) argright);
+    } else {
+        node->right = (kdNode *)kd_doBuildTree((void *) argright);
+        free(argright);
+        if (!node->right) {
+            kd_destroyTree(node);
+            return NULL;
+        }
+    }
+    if (max_threads > 1) {
+        pthread_join(threads[0], (void **) (&node->left));
+        free(argleft);
+        pthread_join(threads[1], (void **) (&node->right));
+        free(argright);
+        if (!node->left || !node->right) {
+            kd_destroyTree(node);
+            return NULL;
+        }
+    }
+    return (void *) node;
+}
+
+
+void
+kd_freeNode(kdNode *node)
+{
+    if ( node ) free(node);
+    return;
+}
+
+
+struct kd_thread_data *
+kd_buildArg(struct kd_point *points,
+            unsigned long nPoints,
+            float *min, float *max,
+            int depth, int max_threads, int dim)
+{
+    struct kd_thread_data *d;
+
+    if ((d = (kd_thread_data *)kd_malloc(sizeof(kd_thread_data), "kd_thread_data")) == NULL)
+        return NULL;
+    d->points = points;
+    d->nPoints = nPoints;
+    memcpy(d->min, min, dim*sizeof(float));
+    memcpy(d->max, max, dim*sizeof(float));
+    d->depth = depth;
+    d->max_threads = max_threads;
+    d->dim = dim;
+    return d;
+}
+
+
+struct kdNode *
+kd_allocNode(struct kd_point *points, unsigned long pivot,
+             float *min, float *max, int axis, int dim)
+{
+    struct kdNode *node;
+
+    if ((node = (kdNode *)kd_malloc(sizeof(kdNode), "kd_allocNode (node): ")) == NULL)
+        return NULL;
+    node->split = axis;
+    memcpy(node->location, points[pivot].point, dim * sizeof(float));
+    memcpy(node->min, min, dim * sizeof(float));
+    memcpy(node->max, max, dim * sizeof(float));
+    node->left = node->right = NULL;
+    node->index = 0;
+    return node;
+}
+
+/*!
+ * \brief free the kd-tree data structure, 
+ *
+ * \param node the root node of the tree to be destroyed
+ *
+ * \param *destr a pointer to the destructor function for the data container.
+ *
+ * \return This function does not return a value
+ */
+void
+kd_destroyTree(struct kdNode *node)
+{
+    if (node == NULL)
+        return;
+
+    kd_destroyTree(node->left);
+    kd_destroyTree(node->right);
+    kd_freeNode(node);
+}
+
+/* end of tree construction and destruction */
+
+/* Functions dealing with result heaps */
+
+/* Insert the sub-tree starting at node into the result heap res */
+int
+kd_insertResTree(struct kdNode *node, struct pqueue *res)
+{
+    struct resItem *point;
+
+    if (node == NULL)
+        return 1;
+
+    if (!kd_insertResTree(node->left, res))
+        return 0;
+    if (kd_isleaf(node)) {
+        if ((point = (struct resItem *)kd_malloc(sizeof(struct resItem), "kd_insertResTree: "))
+            == NULL)
+            return 0;
+
+        point->node = node;
+        point->dist_sq = -1;
+        pqinsert(res, point);
+    }
+    if (!kd_insertResTree(node->right, res))
+        return 0;
+    return 1;
+}
diff --git a/src/kdtreelib/kdtree_spherical.c b/src/kdtreelib/kdtree_spherical.c
new file mode 100644
index 0000000..511790b
--- /dev/null
+++ b/src/kdtreelib/kdtree_spherical.c
@@ -0,0 +1,687 @@
+/*!\file kdtree_spherical.c
+ * \brief Routines specific to the 2-dimensional spherical kd-tree
+ *
+ */
+
+#include "kdtree.h"
+#include "pqueue.h"
+
+/* ********************************************************************
+
+   general utility functions 
+
+   ********************************************************************* */
+inline float
+kd_sph_dist_sq(float *x, float *y)
+{
+    float ds;
+    /*float arg;*/
+
+    if (!x || !y)
+        return -1;
+
+    ds = acos(sin(x[1]) * sin(y[1]) +
+               cos(x[1]) * cos(y[1]) * cos(x[0] - y[0]));
+    /*    arg = sqrt(kd_sqr(sin((x[1] - y[1])/2)) + cos(x[1]) * cos(y[1]) *
+	       kd_sqr(sin((x[0] - y[0])/2)));
+	       ds = 2 * asin(arg);
+    */
+    return kd_sqr(ds);
+}
+
+inline float
+kd_sph_dist(float *x, float *y)
+{
+    float ds;
+
+    if (!x || !y)
+        return -1;
+
+    ds = acos(sin(x[1]) * sin(y[1]) +
+               cos(x[1]) * cos(y[1]) * cos(x[0] - y[0]));
+    return ds;
+}
+
+float
+kd_sph_bearing(float *p1, float *p2)
+{
+    float x, y;
+    
+    x = cos(p1[1]) * sin(p2[1]) - sin(p1[1]) * cos(p2[1]) * cos(p2[0] - p1[0]);
+    y = sin(p2[0] - p1[0]) * cos(p2[1]);
+    return atan2(y, x);
+}
+
+
+/*! \brief Compute cross-track distance
+ * \param p1 a point
+ *
+ * \param p2 a second point defining a great circle from p1
+ *
+ * \param p3 a third point whose distance from the great circle we compute
+ *
+ * \return distance of p3 from the great circle connecting p1 and p2. 
+ */
+float 
+kd_sph_xtd(float *p1, float *p2, float *p3)
+{
+    float d13, theta13, theta12;
+    
+    d13 = kd_sph_dist(p1, p3);
+    theta13 = kd_sph_bearing(p1, p3);
+    theta12 = kd_sph_bearing(p1, p2);
+    return asin(sin(d13) * sin(theta13 - theta12));
+}
+
+
+float
+kd_sph_orth_dist(float *p1, float *p2, int split)
+{
+
+    float ra2, dec2;
+    float dx;
+
+    if (split == 1) {
+        ra2 = p1[0];
+        dec2 = p2[1];
+    } else {
+        ra2 = p2[0];
+        dec2 = p1[1];
+    }
+    dx = acos(sin(p1[1]) * sin(dec2) +
+              cos(p1[1]) * cos(dec2) * cos(p1[0] - ra2));
+    return dx;
+}
+
+/* end utility functions */
+
+/* ******************************************************************
+   
+   Functions for building and destroying trees 
+
+   ******************************************************************** */
+
+/*! \brief build kd-tree structure
+ *
+ * \param points an array of kd_points (struct with position vector
+ * and data container).
+ *
+ * \param nPoints the length of the points array.
+ *
+ * \param constr a pointer to a void *constructor() function to include
+ * data container in tree; optional, can be NULL
+ *
+ * \param destr a pointer to a void destructor() function to free()
+ * data container in the tree; optional, can be NULL, but should be
+ * given if the constr argument is non-NULL.
+ *
+ * \param min a vector with the minimum positions of the corners of the
+ * hyperrectangle containing the data.
+ *
+ * \param max a vector with the maximum positions of the corners of
+ * the hyperrectangle containing the data.
+ *
+ * \param max_threads the maximal number of threads spawned for
+ * construction of the tree. The threads will be unbalanced if this is
+ * not a power of 2.
+ *
+ * \return root node of the tree
+ */
+struct kdNode *
+kd_sph_buildTree(struct kd_point *points, unsigned long nPoints,
+                 float *min, float *max, int max_threads)
+{
+    struct kd_thread_data *my_data;
+    struct kdNode *tree;
+
+    my_data = kd_buildArg(points, nPoints, min, max, 0,max_threads, 2);
+    tree = (kdNode *)kd_doBuildTree(my_data);
+    free(my_data);
+    return tree;
+}
+
+
+/* end of tree construction and destruction */
+
+
+/* *******************************************************************
+
+   Functions for range searches 
+  
+   *******************************************************************
+*/
+
+/* Returns 1 if node is a point in the hyperrectangle defined by
+   minimum and maximum vectors min and max. */
+int
+kd_sph_isPointInRect(struct kdNode *node, float *min, float *max)
+{
+    if (node == NULL)
+        return 0;
+
+    if (node->location[1] < min[1] || node->location[1] > max[1])
+	return 0;
+
+    if (min[0] < 0 && node->location[0] > M_PI) {
+	if (node->location[0] - 2 * M_PI < min[0] || 
+	    node->location[0] - 2 * M_PI > max[0])
+	    return 0;
+    } else {
+	if (node->location[0] < min[0] || node->location[0] > max[0]) 
+	    return 0;
+    }
+    
+    return 1;
+}
+
+/* Returns 1 if the hyperrectangle of node is fully contained within
+   the HR described by the minimum and maximum vectors min and
+   max. Returns 0 otherwise. */
+int
+kd_sph_isRectInRect(struct kdNode *node, float *min, float *max)
+{
+    if (node == NULL)
+        return 0;
+
+    /* if (min[0] < 0 && node->min[0] > M_PI) {
+	if (node->min[0] - 2 * M_PI < min[0] || node->max[0] > max[0])
+	    return 0;
+    } else {
+	if (node->min[0] < min[0] || node->max[0] > max[0] )
+	    return 0;
+    }
+    if (node->min[1] < min[1] || node->max[1] > max[1])
+	return 0;
+    */
+    
+    /* If node is fully contained all corners must be points inside
+       the rectangle */ 
+    struct kd_point *point;
+    struct kdNode *tmpNode;
+    point = (kd_point *)kd_malloc(sizeof(kd_point), "kd_point in RectInRect");
+    point->index = 0;
+    point->point[0] = node->min[0];
+    point->point[1] = node->min[1];
+    tmpNode = kd_allocNode(point, 0, point->point, point->point, 0, 2);
+    if (!kd_sph_isPointInRect(tmpNode, min, max)) {
+	kd_destroyTree(tmpNode);	
+	free(point);
+	return 0;
+    }
+    point->point[0] = node->min[0];
+    point->point[1] = node->max[1];
+    tmpNode = kd_allocNode(point, 0, point->point, point->point, 0, 2);
+    if (!kd_sph_isPointInRect(tmpNode, min, max)) {
+	kd_destroyTree(tmpNode);	
+	free(point);
+	return 0;
+    }
+    point->point[0] = node->max[0];
+    point->point[1] = node->min[1];
+    tmpNode = kd_allocNode(point, 0, point->point, point->point, 0, 2);
+    if (!kd_sph_isPointInRect(tmpNode, min, max)) {
+	kd_destroyTree(tmpNode);	
+	free(point);
+	return 0;
+    }
+    point->point[0] = node->max[0];
+    point->point[1] = node->max[1];
+    tmpNode = kd_allocNode(point, 0, point->point, point->point, 0, 2);
+    if (!kd_sph_isPointInRect(tmpNode, min, max)) {
+	kd_destroyTree(tmpNode);	
+	free(point);
+	return 0;
+    }
+    kd_destroyTree(tmpNode);	
+    free(point);
+
+    return 1;
+}
+
+/* Returns 1 if the hyperrectangle of node overlaps the HR described
+   by the minimum and maximum vectors min and max. Returns 0
+   otherwise. */
+int
+kd_sph_rectOverlapsRect(struct kdNode *node, float *min, float *max)
+{
+    if (node == NULL)
+        return 0;
+
+    if (node->min[1] > max[1] || node->max[1] < min[1])
+	return 0;
+
+    if ((node->min[0]> max[0]) || (node->max[0] <  min[0]))
+	return 0;
+
+    return 1;
+}
+
+
+/*!
+ * \brief Perform orthogonal range search (get all points in a
+ * hyperrectangle).
+ *
+ * \param node the root node of tree to be searched.
+ *
+ * \param min a vector with the minimum positions of the corners of the
+ * hyperrectangle containing the data.
+ *
+ * \param max a vector with the maximum positions of the corners of
+ * the hyperrectangle containing the data.
+ *
+ * \return  Pointer to a priority queue, NULL in case of problems.
+ *
+ * Rectangle must not cross the meridian!
+*/
+struct pqueue *
+kd_sph_ortRangeSearch(struct kdNode *node, float *min, float *max)
+{
+    struct pqueue *res;
+    uint32_t i;
+
+    if ((res = pqinit(NULL, 1)) == NULL)
+        return NULL;
+    if (!kd_sph_doOrtRangeSearch(node, min, max, res)) {
+        for(i = 0; i < res->size; i++) {
+            free(res->d[i]);
+        }
+        free(res->d);
+        free(res);
+        return NULL;
+    }
+    return res;
+}
+
+
+/* This is the orthogonal range search. Returns 1 if okay, 0 in case
+   of problems. */
+int
+kd_sph_doOrtRangeSearch(struct kdNode *node, float *min, float *max,
+                        struct pqueue *res)
+{
+
+    if (node == NULL)
+        return 1;
+
+    if (kd_isleaf(node) && kd_sph_isPointInRect(node, min, max)) {
+        return kd_insertResTree(node, res);
+    } else {
+        if (kd_sph_isRectInRect(node->left, min, max)) {
+            if (!kd_insertResTree(node->left, res))
+                return 0;
+        } else {
+            if (kd_sph_rectOverlapsRect(node->left, min, max))
+                if (!kd_sph_doOrtRangeSearch(node->left, min, max, res))
+                    return 0;
+        }
+        if (kd_sph_isRectInRect(node->right, min, max)) {
+            if (!kd_insertResTree(node->right, res))
+                return 0;
+        } else {
+            if (kd_sph_rectOverlapsRect(node->right, min, max))
+                if (!kd_sph_doOrtRangeSearch(node->right, min, max, res))
+                    return 0;
+        }
+    }
+    return 1;
+}
+
+
+/*! 
+ * \brief Find the nearest neighbor of a point.
+ *
+ * \param node the root node of the tree to be searched.
+ *
+ * \param p a vector to the point whose nearest neighbor is sought.
+ *
+ * \param max_dist_sq the square of the maximum distance to the
+ * nearest neighbor.
+ *
+ * \return A pointer to node containing the nearest neighbor.
+ * max_dist_sq is set to the square of the distance to the nearest
+ * neigbor.
+ */
+struct kdNode *
+kd_sph_nearest(struct kdNode *node, float *p, float *max_dist_sq)
+{
+    struct kdNode *nearer, *further, *nearest, *tmp, *tmp_nearest;
+    float dist_sq, tmp_dist_sq, dx;
+    float p1[2], p2[2];
+
+    if (!node)
+        return NULL;
+
+    /* This is a "<" sign, not the kd_sph_lt function because the tree
+       is constructed assuming a Cartesian geometry. */
+    if (p[node->split] < node->location[node->split]) {
+        nearer = node->left;
+        further = node->right;
+    } else {
+        nearer = node->right;
+        further = node->left;
+    }
+    tmp = kd_sph_nearest(nearer, p, max_dist_sq);
+    if (tmp)
+        nearest = tmp;
+    else
+        nearest = node;
+
+    dist_sq = kd_sph_dist_sq(nearest->location, p);
+    if (*max_dist_sq > dist_sq)
+	*max_dist_sq = dist_sq;
+
+    if (!further)
+        return nearest;
+
+    p1[0] = further->min[0];
+    p1[1] = further->max[1];
+    p2[0] = further->max[0];
+    p2[1] = further->min[1];
+    
+    if (node->split == 0)
+	/* We need to know the distance between the point p and the
+	   vertical lines delineating the rectangle. These lines are
+	   great circles so we need to know the cross-track
+	   distance. */
+	dx = kd_min(kd_sqr(kd_sph_xtd(further->min, p1, p)),
+		    kd_sqr(kd_sph_xtd(p2, further->max, p)));
+    else
+	/* We need to know the distance between the point p and the
+	   horizontal lines delineating the rectangle. Since the
+	   latitudes are not great circles, the shortest distance runs
+	   along the longitude of point p. */
+	dx = kd_min(kd_sqr(kd_sph_orth_dist(further->min, p, 1)),
+		    kd_sqr(kd_sph_orth_dist(further->max, p, 1)));
+
+    if (*max_dist_sq > dx) {
+        /*
+         * some part of the further hyper-rectangle is in the search
+         * radius, search the further node 
+         */
+        tmp = kd_sph_nearest(further, p, max_dist_sq);
+        if (tmp)
+            tmp_nearest = tmp;
+        else
+            tmp_nearest = further;
+
+        tmp_dist_sq = kd_sph_dist_sq(tmp_nearest->location, p);
+        if (tmp_dist_sq < dist_sq) {
+            nearest = tmp_nearest;
+            dist_sq = tmp_dist_sq;
+            *max_dist_sq = kd_min(dist_sq, *max_dist_sq);
+        }
+    }
+    return nearest;
+}
+
+
+/*! 
+ * \brief Return the q nearest-neighbors to a point.
+ *
+ * \param node the root node of the tree to be searched.
+ *
+ * \param p a vector to the point whose nearest neighbors are sought.
+ *
+ * \param max_dist_sq the square of the maximum distance to the
+ * nearest neighbors.
+ *
+ * \param q the maximum number of points to be retured.
+ *
+ * \return A pointer to a priority queue of the points found, or NULL
+ * in case of problems.
+ */
+struct pqueue *
+kd_sph_qnearest(struct kdNode *node, float *p,
+                float *max_dist_sq, unsigned int q)
+{
+    struct pqueue *res;
+    uint32_t i;
+
+    if ((res = pqinit(NULL, q + 2)) == NULL)
+        return NULL;
+    if (!kd_sph_doQnearest(node, p, max_dist_sq, q + 1, res)) {
+        for(i = 0; i < res->size; i++) {
+            free(res->d[i]);
+        }
+        free(res->d);
+        free(res);
+        return NULL;
+    }
+    return res;
+}
+
+/* *
+ * This is the q nearest-neighbor search.
+ *
+ * This is a modification of the range search in which the maximum
+ * search radius is decreased to the maximum of the queue as soon as
+ * the queue is filled.
+ *
+ * return 1 if okay, zero in case of problems
+ */
+int
+kd_sph_doQnearest(struct kdNode *node, float *p, float *max_dist_sq,
+                  unsigned int q, struct pqueue *res)
+{
+    struct kdNode *nearer, *further;
+    struct resItem *point, *item;
+    float dist_sq, dx;
+    float p1[2], p2[2];
+
+    if (!node)
+        return 1;
+
+    dist_sq = kd_sph_dist_sq(node->location, p);
+    if (dist_sq < *max_dist_sq && kd_isleaf(node)) {
+        if ((point = (struct resItem *)kd_malloc(sizeof(struct resItem), "kd_sph_doQnearest: "))
+            == NULL)
+            return 0;
+        point->node = node;
+        point->dist_sq = dist_sq;
+        pqinsert(res, point);
+    }
+    if (res->size > q) {
+        pqremove_max(res, &item);
+        free(item);
+        if (res->size > 1) {
+            /*
+             * Only inspect the queue if there are items left 
+             */
+            pqpeek_max(res, &item);
+            *max_dist_sq = item->dist_sq;
+        } else {
+            /*
+             * Nothing was found within the max search radius 
+             */
+            *max_dist_sq = 0;
+        }
+    }
+
+    if (p[node->split] < node->location[node->split]) {
+        nearer = node->left;
+        further = node->right;
+    } else {
+        nearer = node->right;
+        further = node->left;
+    }
+    if (!kd_sph_doQnearest(nearer, p, max_dist_sq, q, res))
+        return 0;
+
+    if (!further)
+        return 1;
+
+    p1[0] = further->min[0];
+    p1[1] = further->max[1];
+    p2[0] = further->max[0];
+    p2[1] = further->min[1];
+    
+    if (node->split == 0)
+	/* We need to know the distance between the point p and the
+	   vertical lines delineating the rectangle. These lines are
+	   great circles so we need to know the cross-track
+	   distance. */
+	dx = kd_min(kd_sqr(kd_sph_xtd(further->min, p1, p)),
+		    kd_sqr(kd_sph_xtd(p2, further->max, p)));
+    else
+	/* We need to know the distance between the point p and the
+	   horizontal lines delineating the rectangle. Since the
+	   latitudes are not great circles, the shortest distance runs
+	   along the longitude of point p. */
+	dx = kd_min(kd_sqr(kd_sph_orth_dist(further->min, p, 1)),
+		    kd_sqr(kd_sph_orth_dist(further->max, p, 1)));
+
+    if (*max_dist_sq > dx) {
+        /*
+         * some part of the further hyper-rectangle is in the search
+         * radius, search the further node 
+         */
+        if (!kd_sph_doQnearest(further, p, max_dist_sq, q, res))
+            return 0;
+        dist_sq = kd_sph_dist_sq(node->location, p);
+
+        if (dist_sq < *max_dist_sq && kd_isleaf(node)) {
+            if ((point =
+                 (struct resItem *)kd_malloc(sizeof(struct resItem), "kd_sph_doQnearest: "))
+                == NULL)
+                return 0;
+            point->node = node;
+            point->dist_sq = dist_sq;
+            pqinsert(res, point);
+        }
+        if (res->size > q) {
+            pqremove_max(res, &item);
+            free(item);
+            if (res->size > 1) {
+                /*
+                 * Only inspect the queue if there are items left 
+                 */
+                pqpeek_max(res, &item);
+                *max_dist_sq = item->dist_sq;
+            } else {
+                /*
+                 * Nothing was found within the max search radius 
+                 */
+                *max_dist_sq = 0;
+            }
+        }
+    }
+    return 1;
+}
+
+
+/*!
+ * \brief Perform a range search around a point.
+ *
+ * \param node the root node of the tree to be searched.
+ *
+ * \param p the location of the point around which the search is carried out .
+ *
+ * \param max_dist_sq the square of the radius of the hypersphere.
+ *
+ * \param ordered determines whether the result list should be ordered
+ * in increasing distance (KD_ORDERED) or unordered (KD_UNORDERED).
+ *
+ * \return A pointer to a priority queue containing the points found,
+ * NULL in case of problems.
+ */
+struct pqueue *
+kd_sph_range(struct kdNode *node, float *p, float *max_dist_sq, int ordered)
+{
+    struct pqueue *res;
+    uint32_t i;
+
+    if ((res = pqinit(NULL, 1)) == NULL)
+        return NULL;
+    if (!kd_sph_doRange(node, p, max_dist_sq, res, ordered)) {
+        for(i = 0; i < res->size; i++) {
+            free(res->d[i]);
+        }
+        free(res->d);
+        free(res);
+        return NULL;
+    }
+    return res;
+}
+
+
+/* This is the range search. Returns 1 if okay, 0 in case of problems */
+int
+kd_sph_doRange(struct kdNode *node, float *p, float *max_dist_sq,
+               struct pqueue *res, int ordered)
+{
+
+    struct kdNode *nearer, *further;
+    struct resItem *point;
+    float dist_sq, dx;
+    float p1[2], p2[2];
+
+    if (!node)
+        return 1;
+
+    dist_sq = kd_sph_dist_sq(node->location, p);
+    if (dist_sq < *max_dist_sq && kd_isleaf(node)) {
+        if ((point = (struct resItem *)kd_malloc(sizeof(struct resItem), "kd_sph_doRange:"))
+            == NULL)
+            return 0;
+        point->node = node;
+        point->dist_sq = ordered ? dist_sq : -1;
+        pqinsert(res, point);
+    }
+
+    if (p[node->split] < node->location[node->split]) {
+        nearer = node->left;
+        further = node->right;
+    } else {
+        nearer = node->right;
+        further = node->left;
+    }
+    if (!kd_sph_doRange(nearer, p, max_dist_sq, res, ordered))
+        return 0;
+
+    if (!further)
+        return 1;
+
+    p1[0] = further->min[0];
+    p1[1] = further->max[1];
+    p2[0] = further->max[0];
+    p2[1] = further->min[1];
+    
+    if (node->split == 0)
+	/* We need to know the distance between the point p and the
+	   vertical lines delineating the rectangle. These lines are
+	   great circles so we need to know the cross-track
+	   distance. */
+	dx = kd_min(kd_sqr(kd_sph_xtd(further->min, p1, p)),
+		    kd_sqr(kd_sph_xtd(p2, further->max, p)));
+    else
+	/* We need to know the distance between the point p and the
+	   horizontal lines delineating the rectangle. Since the
+	   latitudes are not great circles, the shortest distance runs
+	   along the longitude of point p. */
+	dx = kd_min(kd_sqr(kd_sph_orth_dist(further->min, p, 1)),
+		    kd_sqr(kd_sph_orth_dist(further->max, p, 1)));
+
+    if (*max_dist_sq > dx) {
+        /*
+         * some part of the further hyper-rectangle is in the search
+         * radius, search the further node 
+         */
+        if (!kd_sph_doRange(further, p, max_dist_sq, res, ordered))
+            return 0;
+        dist_sq = kd_sph_dist_sq(node->location, p);
+
+        if (dist_sq < *max_dist_sq && kd_isleaf(node)) {
+            if ((point =
+                 (struct resItem *)kd_malloc(sizeof(struct resItem), "kd_sph_doRange: "))
+                == NULL)
+                return 0;
+            point->node = node;
+            point->dist_sq = ordered ? dist_sq : -1;
+            pqinsert(res, point);
+        }
+
+    }
+    return 1;
+}
+
+/* End range searching functions */
diff --git a/src/kdtreelib/pmergesort.c b/src/kdtreelib/pmergesort.c
new file mode 100644
index 0000000..31bd897
--- /dev/null
+++ b/src/kdtreelib/pmergesort.c
@@ -0,0 +1,158 @@
+#include <pthread.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+typedef struct param_t {
+    char *a;
+    char *b;
+    size_t first;
+    size_t nmemb;
+    size_t size;
+    int (*cmp) (const void *, const void *);
+    int max_threads;
+} param_t;
+
+
+void pm_buildparams(struct param_t *p, void *a, void *b, size_t first,
+                    size_t nmemb, size_t size,
+                    int (*cmp) (const void *, const void *),
+                    int max_threads);
+int pmergesort(void *base, size_t nmemb, size_t size,
+               int (*compar) (const void *, const void *),
+               int max_threads);
+void *mergesort_t(void *args);
+
+
+int
+pmergesort(void *base, size_t nmemb, size_t size,
+           int (*compar) (const void *, const void *),
+           int max_threads)
+{
+    void *tmp;
+    param_t args;
+
+    if ((tmp = calloc(nmemb, size)) == NULL) {
+        perror("malloc");
+        return 0;
+    }
+    args.a = (char *) base;
+    args.b = (char *) tmp;
+    args.first = 0;
+    args.nmemb = nmemb;
+    args.size = size;
+    args.cmp = compar;
+    args.max_threads = max_threads;
+
+    mergesort_t(&args);
+
+    free(tmp);
+    return 1;
+}
+
+void
+pm_buildparams(struct param_t *p, void *a, void *b, size_t first,
+               size_t nmemb, size_t size,
+               int (*cmp) (const void *, const void *),
+               int max_threads)
+{
+
+    p->a = (char *)a;
+    p->b = (char *)b;
+    p->first = first;
+    p->nmemb = nmemb;
+    p->size = size;
+    p->cmp = cmp;
+    p->max_threads = max_threads;
+}
+
+
+void *
+mergesort_t(void *args)
+{
+    size_t i, li, ri;
+    struct param_t larg, rarg;
+    pthread_t thr[2];
+    param_t *mya = (param_t *) args;
+
+    if (mya->max_threads < 2) {
+        /*
+         * Reached maximum number of threads allocated to this
+         * branch. Proceed with sequential sort of this chunk. 
+         */
+        qsort(mya->a + mya->first * mya->size, mya->nmemb, mya->size, mya->cmp);
+    } else {
+        /*
+         * Start two new threads, each sorting half of array a 
+         */
+        pm_buildparams(&larg, mya->a, mya->b, mya->first, mya->nmemb / 2,
+                       mya->size, mya->cmp, mya->max_threads / 2);
+        /*
+         * Recursively sort the left half 
+         */
+        if (pthread_create(&thr[0], NULL, mergesort_t, (void *) &larg)) {
+            perror("pthread_create");
+            return NULL;
+        }
+
+        pm_buildparams(&rarg, mya->a, mya->b, mya->first + mya->nmemb / 2,
+                       mya->nmemb - mya->nmemb / 2, mya->size,
+                       mya->cmp, mya->max_threads / 2);
+        /*
+         * Recursively sort the right half 
+         */
+        if (pthread_create(&thr[1], NULL, mergesort_t, (void *) &rarg)) {
+            perror("pthread_create");
+            return NULL;
+        }
+
+        pthread_join(thr[0], NULL);
+        pthread_join(thr[1], NULL);
+
+        /*
+         * Merge the two sorted chunks of array a into array b 
+         */
+        li = larg.first;
+        ri = rarg.first;
+        for(i = mya->first; i < mya->first + mya->nmemb; i++) {
+            if (li >= larg.first + larg.nmemb) {
+                /*
+                 * We already copied everything from the left chunk,
+                 * now copy from the right 
+                 */
+                memcpy(mya->b + i * mya->size, mya->a + ri * mya->size,
+                       mya->size);
+                ri++;
+            } else if (ri >= rarg.first + rarg.nmemb) {
+                /*
+                 * We already copied everything from the right chunk,
+                 * now copy from the left 
+                 */
+                memcpy(mya->b + i * mya->size, mya->a + li * mya->size,
+                       mya->size);
+                li++;
+            }
+            /*
+             * We can still copy from both chunks, copy the smaller
+             * element 
+             */
+            else if (mya->cmp(mya->a + li * mya->size,
+                              mya->a + ri * mya->size) < 1) {
+                memcpy(mya->b + i * mya->size, mya->a + li * mya->size,
+                       mya->size);
+                li++;
+            } else {
+                memcpy(mya->b + i * mya->size, mya->a + ri * mya->size,
+                       mya->size);
+                ri++;
+            }
+        }
+        /*
+         * Now b is sorted, copy it back to a 
+         */
+        memcpy(mya->a + mya->size * mya->first,
+               mya->b + mya->size * mya->first, mya->size * mya->nmemb);
+    }
+    return NULL;
+}
diff --git a/src/kdtreelib/pqueue.c b/src/kdtreelib/pqueue.c
new file mode 100644
index 0000000..9fdfc2c
--- /dev/null
+++ b/src/kdtreelib/pqueue.c
@@ -0,0 +1,533 @@
+/*!\file pqueue.c
+ * \brief Two-ended priority queues (min-max heap)
+ *
+ * Implementation of a min-max heap (two-ended priority queue) as
+ * introduced by Atkinson et al. (1986), Communications of the ACM 10,
+ * 996.
+ */
+
+#include "pqueue.h"
+
+
+
+/**********************************************************************
+ *
+ *  We start with some general helper functions 
+ *
+ */
+
+/*
+   Returns the floor form of a binary logarithm for a 32 bit integer.
+   -1 is returned if n is 0.
+   Ripped off wikipedia.
+*/
+inline int
+floorLog2(uint32_t n)
+{
+    uint32_t pos = 0;
+    if (n >= 1 << 16) {
+        n >>= 16;
+        pos += 16;
+    }
+    if (n >= 1 << 8) {
+        n >>= 8;
+        pos += 8;
+    }
+    if (n >= 1 << 4) {
+        n >>= 4;
+        pos += 4;
+    }
+    if (n >= 1 << 2) {
+        n >>= 2;
+        pos += 2;
+    }
+    if (n >= 1 << 1)
+        pos += 1;
+    if (n == 0)
+        return -1;
+    return pos;
+}
+
+
+/* 
+   Returns 1 if i is a max-sorted level, return 0 otherwise
+   (min-sorted level). 
+*/
+inline int
+is_max_level(int i)
+{
+    return floorLog2(i) % 2;
+}
+
+
+
+/* Swap nodes i and j in the priority queue q */
+void
+pq_swap_nodes(struct pqueue *q, uint32_t i, uint32_t j)
+{
+    struct resItem *tmp;
+
+    tmp = q->d[i];
+    q->d[i] = q->d[j];
+    q->d[j] = tmp;
+}
+
+
+/* Return the array index of the maximum node */
+uint32_t
+get_max_index(struct pqueue *q)
+{
+
+    uint32_t i;
+    if (!q)
+        return 0;
+
+    switch (q->size) {
+    case 1:{
+            /*
+             * Empty queue 
+             */
+            i = 0;
+            break;
+        }
+    case 2:{
+            /*
+             * this is the only element (min and max) 
+             */
+            i = 1;
+            break;
+        }
+    case 3:{
+            /*
+             * This is the only element on the max level 
+             */
+            i = 2;
+            break;
+        }
+    default:{
+            /*
+             * Return the greater of the two elements on the max level 
+             */
+            if (PQPRIO(q->d[2]) > PQPRIO(q->d[3]))
+                i = 2;
+            else
+                i = 3;
+        }
+    }
+    return i;
+}
+
+
+/* End of general helper functions */
+
+/* 
+ *
+ *  Functions to support insertion 
+ *
+ */
+
+/* Move a node up the tree */
+void
+bubble_up_min(struct pqueue *q, uint32_t i)
+{
+    /*
+     * if node has a grandparent 
+     */
+    if (i > 3 && PQPRIO(q->d[i]) < PQPRIO(q->d[i / 4])) {
+        pq_swap_nodes(q, i, i / 4);
+        bubble_up_min(q, i / 4);
+    }
+}
+
+
+void
+bubble_up_max(struct pqueue *q, uint32_t i)
+{
+    /*
+     * if node has a grandparent 
+     */
+    if (i > 3 && PQPRIO(q->d[i]) > PQPRIO(q->d[i / 4])) {
+        pq_swap_nodes(q, i, i / 4);
+        bubble_up_max(q, i / 4);
+    }
+}
+
+
+void
+bubble_up(struct pqueue *q, uint32_t i)
+{
+    if (!is_max_level(i)) {
+        if (i > 1 && PQPRIO(q->d[i]) > PQPRIO(q->d[i / 2])) {
+            pq_swap_nodes(q, i, i / 2);
+            bubble_up_max(q, i / 2);
+        } else {
+            bubble_up_min(q, i);
+        }
+    } else {
+        if (i > 1 && PQPRIO(q->d[i]) < PQPRIO(q->d[i / 2])) {
+            pq_swap_nodes(q, i, i / 2);
+            bubble_up_min(q, i / 2);
+        } else {
+            bubble_up_max(q, i);
+        }
+    }
+}
+
+
+/*
+ *
+ * Functions to support node removal
+ *
+ */
+
+/* Get index of the smallest child or grandchild of q->d[i].
+   Caller must ensure that q->d[i] has at least one child. */
+uint32_t
+pq_get_min_child_index(struct pqueue *q, uint32_t i)
+{
+    uint32_t m;
+
+    /*
+     * First Child 
+     */
+    m = 2 * i;
+    /*
+     * Second Child 
+     */
+    if (q->size > 2 * i + 1)
+        if (PQPRIO(q->d[m]) > PQPRIO(q->d[2 * i + 1]))
+            m = 2 * i + 1;
+    /*
+     * First child of first child 
+     */
+    if (q->size > 4 * i)
+        if (PQPRIO(q->d[m]) > PQPRIO(q->d[4 * i]))
+            m = 4 * i;
+    /*
+     * Second child of first child 
+     */
+    if (q->size > 4 * i + 1)
+        if (PQPRIO(q->d[m]) > PQPRIO(q->d[4 * i + 1]))
+            m = 4 * i + 1;
+    /*
+     * First Child of second child 
+     */
+    if (q->size > 2 * (2 * i + 1))
+        if (PQPRIO(q->d[m]) > PQPRIO(q->d[2 * (2 * i + 1)]))
+            m = 2 * (2 * i + 1);
+    /*
+     * Second child of second child 
+     */
+    if (q->size > 2 * (2 * i + 1) + 1)
+        if (PQPRIO(q->d[m]) > PQPRIO(q->d[2 * (2 * i + 1) + 1]))
+            m = 2 * (2 * i + 1) + 1;
+    return m;
+}
+
+/* Get index of the largest children and grandchildren of q->d[i].
+   Caller must ensure that q->d[i] has at least one child. */
+uint32_t
+pq_get_max_child_index(struct pqueue * q, uint32_t i)
+{
+    uint32_t m;
+
+    /*
+     * First Child 
+     */
+    m = 2 * i;
+    /*
+     * Second Child 
+     */
+    if (q->size > 2 * i + 1)
+        if (PQPRIO(q->d[m]) < PQPRIO(q->d[2 * i + 1]))
+            m = 2 * i + 1;
+    /*
+     * First child of first child 
+     */
+    if (q->size > 4 * i)
+        if (PQPRIO(q->d[m]) < PQPRIO(q->d[4 * i]))
+            m = 4 * i;
+    /*
+     * Second child of first child 
+     */
+    if (q->size > 4 * i + 1)
+        if (PQPRIO(q->d[m]) < PQPRIO(q->d[4 * i + 1]))
+            m = 4 * i + 1;
+    /*
+     * First Child of second child 
+     */
+    if (q->size > 2 * (2 * i + 1))
+        if (PQPRIO(q->d[m]) < PQPRIO(q->d[2 * (2 * i + 1)]))
+            m = 2 * (2 * i + 1);
+    /*
+     * Second child of second child 
+     */
+    if (q->size > 2 * (2 * i + 1) + 1)
+        if (PQPRIO(q->d[m]) < PQPRIO(q->d[2 * (2 * i + 1) + 1]))
+            m = 2 * (2 * i + 1) + 1;
+    return m;
+}
+
+
+/* Move a node down the tree */
+void
+trickle_down(struct pqueue *q, uint32_t i)
+{
+    if (is_max_level(i))
+        trickle_down_max(q, i);
+    else
+        trickle_down_min(q, i);
+}
+
+
+void
+trickle_down_max(struct pqueue *q, uint32_t i)
+{
+    uint32_t m;
+
+    /*
+     * if A[i] has children 
+     */
+    if (q->size > 2 * i) {
+        /*
+         * m := Index of the largest child or grandchild of A[i] 
+         */
+        m = pq_get_max_child_index(q, i);
+        /*
+         * if A[m] is a grandchild of A[i] 
+         */
+        if (m / 4 == i) {
+            if (PQPRIO(q->d[m]) > PQPRIO(q->d[i]))
+                pq_swap_nodes(q, i, m);
+            if (PQPRIO(q->d[m]) < PQPRIO(q->d[m / 2]))
+                pq_swap_nodes(q, m, m / 2);
+            trickle_down_max(q, m);
+        } else {
+            /*
+             * A[m] is a child of A[i] 
+             */
+            if (PQPRIO(q->d[m]) > PQPRIO(q->d[i]))
+                pq_swap_nodes(q, i, m);
+        }
+    }
+}
+
+void
+trickle_down_min(struct pqueue *q, uint32_t i)
+{
+    uint32_t m;
+
+    /*
+     * if A[i] has children 
+     */
+    if (q->size > 2 * i) {
+        /*
+         * m := Index of the smallest child or grandchild of A[i] 
+         */
+        m = pq_get_min_child_index(q, i);
+        /*
+         * if A[m] is a grandchild of A[i] 
+         */
+        if (m / 4 == i) {
+            if (PQPRIO(q->d[m]) < PQPRIO(q->d[i]))
+                pq_swap_nodes(q, i, m);
+            if (PQPRIO(q->d[m]) > PQPRIO(q->d[m / 2]))
+                pq_swap_nodes(q, m, m / 2);
+            trickle_down_min(q, m);
+        } else {
+            /*
+             * A[m] is a child of A[i] 
+             */
+            if (PQPRIO(q->d[m]) < PQPRIO(q->d[i]))
+                pq_swap_nodes(q, i, m);
+        }
+    }
+}
+
+
+
+
+/* 
+ ***********************************************************************
+ *
+ *                USER FUNCTIONS
+ *
+ ***********************************************************************
+ */
+
+/*!
+ * \brief Initialize priority queue
+ *
+ * \param q a pointer to a priority queue, or NULL if the queue
+ * should be initialized.
+ *
+ * \param n the number of queue items for which memory should be
+ * preallocated. If you insert more than n items to the queue,
+ * another n items will be allocated automatically.
+ *
+ * \return Pointer to priority queue, NULL in case of error.
+ *
+ */
+struct pqueue *
+pqinit(struct pqueue *q, uint32_t n)
+{
+    struct pqueue *tmp = q;
+
+    if (!q && !(q = (pqueue *)malloc(sizeof(struct pqueue)))) {
+        return NULL;
+    }
+    if (!(q->d = (struct resItem **)malloc(sizeof(struct resItem *) * n))) {
+        if (!tmp)
+            free(q);
+        return NULL;
+    }
+    q->avail = q->step = n;
+    q->size = 1;
+    return q;
+}
+
+
+/*!                  
+ * \brief Insert an item into the queue.
+ *
+ * \param q a pointer to a priority queue.
+ *
+ * \param d the datum to be inserted.
+ *
+ * \return 1 if the item has been inserted, 0 if the item could not be
+ * appended. Either the queue pointer provided was NULL, or the
+ * function was unable to allocate the amount of memory needed for the
+ * new item.
+ */
+int
+pqinsert(struct pqueue *q, struct resItem *d)
+{
+    struct resItem **tmp;
+    uint32_t i, newsize;
+
+    if (!q)
+        return 0;
+
+    /*
+     * allocate more memory if necessary 
+     */
+    if (q->size >= q->avail) {
+        newsize = q->size + q->step;
+        if (!(tmp = (struct resItem **)realloc(q->d, sizeof(struct resItem *) * newsize))) {
+            return 0;
+        };
+        q->d = tmp;
+        q->avail = newsize;
+    }
+
+    /*
+     * insert item 
+     */
+    i = q->size++;
+    q->d[i] = d;
+    bubble_up(q, i);
+    return 1;
+}
+
+
+/*!
+ * \brief remove the highest-ranking (minimum) item from the queue.
+ *
+ * \param q a pointer to a priority queue.
+ *  
+ * \param d a pointer to the struct resItem * variable that will hold the datum
+ * corresponding to the queue item removed.
+ *
+ * \return non-NULL if an item has been removed. The variable that d
+ * points to now contains the datum associated with the item in
+ * question; or NULL if item could be removed. Either the queue
+ * pointer provided was NULL, or the queue was empty. The chunk of
+ * memory that d points to has not been modified.
+ */
+struct resItem **
+pqremove_min(struct pqueue *q, struct resItem **d)
+{
+    if (!q || q->size == 1)
+        return NULL;
+    *d = q->d[1];
+    q->d[1] = q->d[--q->size];
+    trickle_down(q, 1);
+    return d;
+}
+
+
+/*!
+ * \brief remove the lowest-ranking (maximum) item from the queue.
+ *
+ * \param q a pointer to a priority queue.
+ *
+ * \param d a pointer to the struct resItem * variable that will hold the datum
+ * corresponding to the queue item removed.
+ *
+ * \return non-NULL if an item has been removed. The variable that d
+ * points to now contains the datum associated with the item in
+ * question; or NULL if item could be removed. Either the queue
+ * pointer provided was NULL, or the queue was empty. The chunk of
+ * memory that d points to has not been modified.
+ */
+struct resItem **
+pqremove_max(struct pqueue *q, struct resItem **d)
+{
+    uint32_t i;
+
+    if (!q || q->size == 1)
+        return NULL;
+    i = get_max_index(q);
+    *d = q->d[i];
+    q->d[i] = q->d[--q->size];
+    trickle_down(q, i);
+    return d;
+}
+
+
+/*!
+ * \brief access highest-ranking (minimum) item without removing it.
+ *
+ * \param q a pointer to a priority queue.
+ *
+ * \param d a pointer to the struct resItem * variable that will hold the datum
+ * corresponding to the highest-ranking item.
+ *                
+ * \return non-NULL in case of success. The variable that d points to
+ * now contains the datum associated with the highest-ranking item;
+ * NULL in case of failure. Either the queue pointer provided was
+ * NULL, or the queue was empty. The chunk of memory that d points to
+ * has not been modified.
+ */
+struct resItem **
+pqpeek_min(struct pqueue *q, struct resItem **d)
+{
+    if (!q || q->size == 1)
+        return NULL;
+    *d = q->d[1];
+    return d;
+}
+
+
+/*!
+ * \brief access lowest-ranking (maximum) item without removing it.
+ *
+ * \param q a pointer to a priority queue.
+ *
+ * \param d a pointer to the struct resItem * variable that will hold the datum
+ * corresponding to the highest-ranking item.
+ *                
+ * \return non-NULL in case of success. The variable that d points to
+ * now contains the datum associated with the highest-ranking item;
+ * NULL in case of failure. Either the queue pointer provided was
+ * NULL, or the queue was empty. The chunk of memory that d points to
+ * has not been modified.
+ */
+struct resItem **
+pqpeek_max(struct pqueue *q, struct resItem **d)
+{
+    if (!q || q->size == 1)
+        return NULL;
+    *d = q->d[get_max_index(q)];
+    return d;
+}
diff --git a/src/kdtreelib/pqueue.h b/src/kdtreelib/pqueue.h
new file mode 100644
index 0000000..68d85df
--- /dev/null
+++ b/src/kdtreelib/pqueue.h
@@ -0,0 +1,24 @@
+#include "kdtree.h"
+
+#ifndef _PQUEUE_H
+#define _PQUEUE_H
+
+#include <stdint.h>
+#include <stdlib.h>
+
+#define PQPRIO(p) (p->dist_sq)
+
+int floorLog2(uint32_t n);
+int is_max_level(int i);
+uint32_t get_max_index(struct pqueue *q);
+uint32_t pq_get_min_child_index(struct pqueue *q, uint32_t i);
+uint32_t pq_get_max_child_index(struct pqueue *q, uint32_t i);
+void pq_swap_nodes(struct pqueue *q, uint32_t i, uint32_t j);
+void trickle_down(struct pqueue *q, uint32_t i);
+void trickle_down_min(struct pqueue *q, uint32_t i);
+void trickle_down_max(struct pqueue *q, uint32_t i);
+void bubble_up(struct pqueue *q, uint32_t i);
+void bubble_up_min(struct pqueue *q, uint32_t i);
+void bubble_up_max(struct pqueue *q, uint32_t i);
+
+#endif
diff --git a/src/kvlist.c b/src/kvlist.c
index ccc9b75..0315c14 100644
--- a/src/kvlist.c
+++ b/src/kvlist.c
@@ -56,7 +56,7 @@
 #include <ctype.h>
 #include <errno.h>
 #include <assert.h>
-
+#include "cdo_int.h"
 
 #define MAX_KVLISTS    4096
 #define MAX_KVELEMENTS 1024
@@ -153,7 +153,7 @@ char *readLineFromBuffer(char *buffer, size_t *buffersize, char *line, size_t le
 static
 void pfree(void *ptr)
 {
-  if ( ptr ) free(ptr);
+  if ( ptr ) Free(ptr);
 }
 
 static
@@ -276,6 +276,8 @@ void *kvlParseFile(const char *filename)
 
   assert(filename != NULL);
 
+  filesize = fileSize(filename);
+
   fp = fopen(filename, "r");
   if ( fp == NULL )
     {
@@ -283,12 +285,7 @@ void *kvlParseFile(const char *filename)
       return (kvl);
     }
 
-  /* file size */
-  fseek(fp, 0L, SEEK_END);
-  filesize = (size_t) ftell(fp);
-  fseek(fp, 0L, SEEK_SET);
-
-  buffer = (char*) malloc(filesize);
+  buffer = (char*) Malloc(filesize);
   nitems = fread(buffer, 1, filesize, fp);
 
   fclose(fp);
@@ -299,7 +296,7 @@ void *kvlParseFile(const char *filename)
       return (kvl);
     }
  
-  kvl = (kvl_t*) calloc(1, sizeof(kvl_t));
+  kvl = (kvl_t*) Calloc(1, sizeof(kvl_t));
   kvl->buffer = buffer;
   kvl->buffersize = filesize;
   kvl->filename = strdup(filename);
@@ -319,7 +316,7 @@ void kvlDelete(void *kvlist)
   pfree(kvl->filename);
   pfree(kvl->buffer);
 
-  free(kvl);
+  Free(kvl);
 }
 
 
@@ -426,6 +423,6 @@ int main(int argc, char *argv[])
 
   kvlDelete(kvlist);
 
-  return (0);
+  return 0;
 }
 */
diff --git a/src/list.c b/src/list.c
index b2ca445..3158d76 100644
--- a/src/list.c
+++ b/src/list.c
@@ -46,7 +46,7 @@ LIST *listNew(int type)
     }
   else
     {
-      list = (LIST*) malloc(sizeof(LIST));
+      list = (LIST*) Malloc(sizeof(LIST));
       listInit(list, type);
     }
 
@@ -58,8 +58,8 @@ void listDelete(LIST *list)
 {
   if ( list )
     {
-      if ( list->array ) free(list->array);
-      free(list);
+      if ( list->array ) Free(list->array);
+      Free(list);
     }
 }
 
@@ -76,9 +76,9 @@ static void listCheck(LIST *list, int num)
     {
       list->nalloc += list->allinc;
       if ( list->type == INT_LIST )
-	list->array = (int*) realloc(list->array, list->nalloc*sizeof(int));
+	list->array = (int*) Realloc(list->array, list->nalloc*sizeof(int));
       else
-	list->array = (double*) realloc(list->array, list->nalloc*sizeof(double));
+	list->array = (double*) Realloc(list->array, list->nalloc*sizeof(double));
     }
 }
 
diff --git a/src/magics_template_parser.c b/src/magics_template_parser.c
index 4c48f78..dc4c23e 100644
--- a/src/magics_template_parser.c
+++ b/src/magics_template_parser.c
@@ -165,7 +165,7 @@ int SetMagicsParameterValue( char *param_name, char *param_type, char *param_val
 		split_str_count = StringSplitWithSeperator( param_value, sep_char, &split_str );
 		if( split_str_count )
 		  {
-		    float_param_list = (double*) malloc(sizeof(double) * split_str_count );
+		    float_param_list = (double*) Malloc(sizeof(double) * split_str_count );
 			for( i = 0; i < split_str_count; i++ )
 			  {
 #if 0
@@ -174,8 +174,8 @@ int SetMagicsParameterValue( char *param_name, char *param_type, char *param_val
 				float_param_list[i] = atof( split_str[i] );			
 			  }
 			mag_set1r( param_name, float_param_list, split_str_count );		
-			free( float_param_list );
-			free( split_str );
+			Free( float_param_list );
+			Free( split_str );
 		  }
 
 	  }
@@ -194,14 +194,14 @@ int SetMagicsParameterValue( char *param_name, char *param_type, char *param_val
 		split_str_count = StringSplitWithSeperator( param_value, sep_char, &split_str );
 		if( split_str_count )
 		  {
-		    int_param_list = (double*) malloc(sizeof( int ) * split_str_count );
+		    int_param_list = (double*) Malloc(sizeof( int ) * split_str_count );
 			for( i = 0; i < split_str_count; i++ )
 			{
 				int_param_list[i] = atoi( split_str[i] );			
 			}
 			mag_set1i( param_name, int_param_list, split_str_count );		
-			free( int_param_list );
-			free( split_str );
+			Free( int_param_list );
+			Free( split_str );
 		  }
 	  }
 
@@ -229,7 +229,7 @@ int SetMagicsParameterValue( char *param_name, char *param_type, char *param_val
 		  fprintf( stderr, "Input strarr is %s split str count is %d Sep char is %s\n",param_value, split_str_count, sep_char );
 		
 		mag_set1c( param_name, (const char**)split_str, split_str_count );		
-		free( split_str );
+		Free( split_str );
 	  }
 	else 
 	  {
diff --git a/src/merge_sort2.c b/src/merge_sort2.c
index ffcfe3d..9dfce43 100644
--- a/src/merge_sort2.c
+++ b/src/merge_sort2.c
@@ -71,7 +71,7 @@ void sort_par(long num_links, double *restrict add1, int parent, int par_depth)
 	     "       in this implementation of merge sort\n");
     }
 
-  idx = (long*) malloc(num_links*sizeof(long));
+  idx = (long*) Malloc(num_links*sizeof(long));
 
   /* SPLIT AND SORT THE DATA FRAGMENTS */
   add_srt[0] = 0;                  add_srt[1] = num_links/nsplit;
@@ -127,7 +127,7 @@ void sort_par(long num_links, double *restrict add1, int parent, int par_depth)
     //    merge_time += end-start;
   }
 
-  tmp = (double*) malloc(num_links*sizeof(double));
+  tmp = (double*) Malloc(num_links*sizeof(double));
 
 #if defined(_OPENMP)
 #pragma omp parallel for if ( depth < par_depth /* && num_links > 4096*/ ) \
@@ -138,8 +138,8 @@ void sort_par(long num_links, double *restrict add1, int parent, int par_depth)
   
   memcpy(add1,tmp,num_links*sizeof(double));
   
-  free(tmp);
-  free(idx);
+  Free(tmp);
+  Free(idx);
 
   tmp=NULL;
 
diff --git a/src/merge_sort2.h b/src/merge_sort2.h
index aca0f13..87c9e8b 100644
--- a/src/merge_sort2.h
+++ b/src/merge_sort2.h
@@ -3,12 +3,9 @@
 
 /* MERGE SORT DEFINES */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include <string.h>
+#include "cdo_int.h"
+
 #include <time.h>
-#include "cdo.h"
 
 #if defined(_OPENMP)
 #include <omp.h>
diff --git a/src/modules.c b/src/modules.c
index 9af638b..aaa413f 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -19,11 +19,8 @@
 #  include "config.h"
 #endif
 
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h>
 #include <cdi.h>
-#include "cdo.h"
+#include "cdo_int.h"
 #include "operator_help.h"
 #include "modules.h"
 #include "error.h"
@@ -32,12 +29,12 @@
 #define  MAX_MOD_OPERATORS  128         /* maximum number of operators for a module */
 
 typedef struct {
-  void  *(*func)(void *);               /* Module                   */
-  char **help;                          /* Help                     */
-  char  *operators[MAX_MOD_OPERATORS];  /* Operator names           */
-  short  number;                        /* Allowed number type      */
-  short  streamInCnt;                   /* Number of input streams  */
-  short  streamOutCnt;                  /* Number of output streams */
+  void  *(*func)(void *);                     /* Module                   */
+  const char **help;                          /* Help                     */
+  const char  *operators[MAX_MOD_OPERATORS];  /* Operator names           */
+  short  number;                              /* Allowed number type      */
+  short  streamInCnt;                         /* Number of input streams  */
+  short  streamOutCnt;                        /* Number of output streams */
 }
 modules_t;
 
@@ -55,6 +52,7 @@ void *CDIwrite(void *argument);
 void *Change(void *argument);
 void *Change_e5slm(void *argument);
 void *Cloudlayer(void *argument);
+void *CMOR(void *argument);
 void *Collgrid(void *argument);
 void *Command(void *argument);
 void *Comp(void *argument);
@@ -187,6 +185,7 @@ void *Timcount(void *argument);
 void *Timpctl(void *argument);
 void *Timselpctl(void *argument);
 void *Timselstat(void *argument);
+void *XTimstat(void *argument);
 void *Timstat(void *argument);
 void *Timstat2(void *argument);
 void *Timstat3(void *argument);
@@ -202,6 +201,7 @@ void *Varrms(void *argument);
 void *Vertintml(void *argument);
 void *Vertintap(void *argument);
 void *Vertstat(void *argument);
+void *Vertcum(void *argument);
 void *Vertwind(void *argument);
 void *Wind(void *argument);
 void *Writegrid(void *argument);
@@ -287,6 +287,7 @@ void *Maggraph(void *argument);
 #define  ChangeOperators        {"chcode", "chtabnum", "chparam", "chname", "chunit", "chlevel", "chlevelc", "chlevelv", "chltype"}
 #define  Change_e5slmOperators  {"change_e5slm", "change_e5lsm", "change_e5mask"}
 #define  CloudlayerOperators    {"cloudlayer"}
+#define  CMOROperators          {"cmor"}
 #define  CollgridOperators      {"collgrid"}
 #define  CommandOperators       {"command", "com", "cmd"}
 #define  CompOperators          {"eq",  "ne",  "le",  "lt",  "ge",  "gt"}
@@ -318,7 +319,7 @@ void *Maggraph(void *argument);
 #define  FCOperators            {"fc2sp", "sp2fc", "fc2gp", "gp2fc"}
 #define  FiledesOperators       {"filedes", "griddes", "griddes2", "zaxisdes", "vct", "vct2", "pardes", \
                                  "vlist", "partab", "partab2", "spartab"}
-#define  FillmissOperators      {"fillmiss","fillmiss2"}
+#define  FillmissOperators      {"fillmiss", "fillmiss2"}
 #define  FilterOperators        {"bandpass", "highpass", "lowpass"}
 #define  FldrmsOperators        {"fldrms"}
 #define  FldstatOperators       {"fldmin", "fldmax", "fldsum", "fldmean", "fldavg", "fldstd", "fldstd1", "fldvar", "fldvar1", "fldpctl"}
@@ -327,7 +328,7 @@ void *Maggraph(void *argument);
 #define  FourierOperators       {"fourier"}
 #define  GengridOperators       {"gengrid"}
 #define  GradsdesOperators      {"gradsdes", "dumpmap"}
-#define  GridboxstatOperators   {"gridboxmin", "gridboxmax", "gridboxsum", "gridboxmean", "gridboxavg", "gridboxvar", "gridboxstd"}
+#define  GridboxstatOperators   {"gridboxmin", "gridboxmax", "gridboxsum", "gridboxmean", "gridboxavg", "gridboxstd", "gridboxstd1", "gridboxvar", "gridboxvar1"}
 #define  GridcellOperators      {"gridarea", "gridweights", "gridmask", "griddx", "griddy"}
 #define  GridsearchOperators    {"testpointsearch", "testcellsearch"}
 #define  HarmonicOperators      {"harmonic"}
@@ -358,7 +359,7 @@ void *Maggraph(void *argument);
 #define  MergeOperators         {"merge"}
 #define  MergegridOperators     {"mergegrid"}
 #define  MergetimeOperators     {"mergetime"}
-#define  MerstatOperators       {"mermin", "mermax", "mersum", "mermean", "meravg", "mervar", "merstd", "merpctl"}
+#define  MerstatOperators       {"mermin", "mermax", "mersum", "mermean", "meravg", "merstd", "merstd1", "mervar", "mervar1", "merpctl"}
 #define  MonarithOperators      {"monadd", "monsub", "monmul", "mondiv"}
 #define  MrotuvOperators        {"mrotuv"}
 #define  MrotuvbOperators       {"mrotuvb"}
@@ -374,18 +375,25 @@ void *Maggraph(void *argument);
 #define  PressureOperators      {"pressure_fl", "pressure_hl", "deltap"}
 #define  RegresOperators        {"regres"}
 #define  RemapOperators         {"remap"}
-#define    RemapgridOperators   {"remapycon", "remapcon", "remapbil", "remapbic", "remapdis", "remapnn", "remaplaf", "remapcon2", "remapsum"}
-#define    GenweightsOperators  {"genycon", "gencon", "genbil", "genbic", "gendis", "gennn", "genlaf", "gencon2"}
+#define  RemapbilOperators      {"remapbil", "genbil"}
+#define  RemapbicOperators      {"remapbic", "genbic"}
+#define  RemapnnOperators       {"remapnn", "gennn"}
+#define  RemapdisOperators      {"remapdis", "gendis"}
+#define  RemapyconOperators     {"remapycon", "genycon"}
+#define  RemapconOperators      {"remapcon", "gencon"}
+#define  Remapcon2Operators     {"remapcon2", "gencon2"}
+#define  RemaplafOperators      {"remaplaf", "genlaf"}
+#define    RemapgridOperators   {"remapsum"}
 #define  RemapetaOperators      {"remapeta", "remapeta_s", "remapeta_z"}
 #define  ReplaceOperators       {"replace"}
 #define  ReplacevaluesOperators {"setvals", "setrtoc", "setrtoc2"}
 #define  RhopotOperators        {"rhopot"}
 #define  RotuvOperators         {"rotuvb"}
 #define  RunpctlOperators       {"runpctl"}
-#define  RunstatOperators       {"runmin",  "runmax",  "runsum",  "runmean",  "runavg",  "runstd",  "runstd1",  "runvar",  "runvar1"}
+#define  RunstatOperators       {"runmin", "runmax", "runsum", "runmean", "runavg", "runstd", "runstd1", "runvar", "runvar1"}
 #define  SeascountOperators     {"seascount"}
 #define  SeaspctlOperators      {"seaspctl"}
-#define  SeasstatOperators      {"seasmin",  "seasmax",  "seassum",  "seasmean",  "seasavg",  "seasvar",  "seasstd"}
+#define  SeasstatOperators      {"seasmin", "seasmax", "seassum", "seasmean", "seasavg", "seasstd", "seasstd1", "seasvar", "seasvar1"}
 #define  SelboxOperators        {"sellonlatbox", "selindexbox"}
 #define  SelectOperators        {"select", "delete"}
 #define  SelvarOperators        {"selparam", "selcode", "selname", "selstdname", "sellevel", "sellevidx", "selgrid", \
@@ -400,6 +408,7 @@ void *Maggraph(void *argument);
 #define  SetgridOperators       {"setgrid", "setgridtype", "setgridarea", "setgridmask", "unsetgridmask", "setgridnumber", "setgriduri"}
 #define  SethaloOperators       {"sethalo", "tpnhalo"}
 #define  SetmissOperators       {"setmissval", "setctomiss", "setmisstoc", "setrtomiss", "setvrange"}
+#define  SetmisstonnOperators   {"setmisstonn", "setmisstodis"}
 #define  Setpartab0Operators    {"setpartab"}
 #define  SetpartabOperators     {"setpartabc", "setpartabp", "setpartabn"}
 #define  SetrcanameOperators    {"setrcaname"}
@@ -410,7 +419,7 @@ void *Maggraph(void *argument);
                                  "showparam", "showname", "showstdname", "showlevel", "showltype", "showformat"}
 #define  SinfoOperators         {"sinfo", "sinfop", "sinfon", "sinfoc", "seinfo", "seinfop", "seinfon", "seinfoc"}
 #define  Smooth9Operators       {"smooth9"}
-#define  SortOperators          {"sortcode", "sortname", "sortlevel"}
+#define  SortOperators          {"sortcode", "sortparam", "sortname", "sortlevel"}
 #define  SorttimestampOperators {"sorttimestamp", "sorttaxis"}
 #define  SpecinfoOperators      {"specinfo"}
 #define  SpectralOperators      {"gp2sp", "gp2spl", "sp2gp", "sp2gpl", "sp2sp", "spcut"}
@@ -442,6 +451,9 @@ void *Maggraph(void *argument);
 #define    HourpctlOperators    {"hourpctl"}
 #define  TimselpctlOperators    {"timselpctl"}
 #define  TimselstatOperators    {"timselmin", "timselmax", "timselsum", "timselmean", "timselavg", "timselvar", "timselvar1", "timselstd", "timselstd1"}
+#define  XTimstatOperators      {"xtimmin",  "xtimmax",  "xtimsum",  "xtimmean",  "xtimavg",  "xtimvar",  "xtimvar1",  "xtimstd",  "xtimstd1", \
+                                 "xyearmin", "xyearmax", "xyearsum", "xyearmean", "xyearavg", "xyearvar", "xyearvar1", "xyearstd", "xyearstd1", \
+                                 "xmonmin",  "xmonmax",  "xmonsum",  "xmonmean",  "xmonavg",  "xmonvar",  "xmonvar1",  "xmonstd",  "xmonstd1"}
 #define  TimstatOperators       {"timmin",  "timmax",  "timsum",  "timmean",  "timavg",  "timvar",  "timvar1",  "timstd",  "timstd1"}
 #define    YearstatOperators    {"yearmin", "yearmax", "yearsum", "yearmean", "yearavg", "yearvar", "yearvar1", "yearstd", "yearstd1"}
 #define    MonstatOperators     {"monmin",  "monmax",  "monsum",  "monmean",  "monavg",  "monvar",  "monvar1",  "monstd",  "monstd1"}
@@ -461,7 +473,8 @@ void *Maggraph(void *argument);
 #define  VarrmsOperators        {"varrms"}
 #define  VertintmlOperators     {"ml2pl", "ml2hl", "ml2plx", "ml2hlx", "ml2pl_lp", "ml2hl_lp", "ml2plx_lp", "ml2hlx_lp"}
 #define  VertintapOperators     {"ap2pl", "ap2plx", "ap2pl_lp", "ap2plx_lp"}
-#define  VertstatOperators      {"vertmin", "vertmax", "vertsum", "vertint", "vertmean", "vertavg", "vertvar", "vertstd"}
+#define  VertstatOperators      {"vertmin", "vertmax", "vertsum", "vertint", "vertmean", "vertavg", "vertstd", "vertstd1", "vertvar", "vertvar1"}
+#define  VertcumOperators       {"vertcum", "vertcumhl"}
 #define  VertwindOperators      {"vertwind"}
 #define  WindOperators          {"uv2dv", "uv2dvl", "dv2uv", "dv2uvl", "dv2ps"}
 #define  WritegridOperators     {"writegrid"}
@@ -480,8 +493,8 @@ void *Maggraph(void *argument);
 #define  YmonpctlOperators      {"ymonpctl"}
 #define  YmonstatOperators      {"ymonmin", "ymonmax", "ymonsum", "ymonmean", "ymonavg", "ymonstd", "ymonstd1", "ymonvar", "ymonvar1"}
 #define  YseaspctlOperators     {"yseaspctl"}
-#define  YseasstatOperators     {"yseasmin", "yseasmax", "yseassum", "yseasmean", "yseasavg", "yseasvar", "yseasstd"}
-#define  ZonstatOperators       {"zonmin", "zonmax", "zonrange", "zonsum", "zonmean", "zonavg", "zonvar", "zonstd", "zonpctl"}
+#define  YseasstatOperators     {"yseasmin", "yseasmax", "yseassum", "yseasmean", "yseasavg", "yseasstd", "yseasstd1", "yseasvar", "yseasvar1"}
+#define  ZonstatOperators       {"zonmin", "zonmax", "zonrange", "zonsum", "zonmean", "zonavg", "zonstd", "zonstd1", "zonvar", "zonvar1", "zonpctl"}
 
 #define  EcaCfdOperators        {"eca_cfd"}
 #define  EcaCsuOperators        {"eca_csu"}
@@ -559,6 +572,7 @@ static modules_t Modules[] =
   { Change,         ChangeHelp,        ChangeOperators,        CDI_REAL,  1,  1 },
   { Change_e5slm,   NULL,              Change_e5slmOperators,  CDI_REAL,  1,  1 },
   { Cloudlayer,     NULL,              CloudlayerOperators,    CDI_REAL,  1,  1 },
+  { CMOR,           NULL,              CMOROperators,          CDI_REAL,  1,  0 },
   { Collgrid,       CollgridHelp,      CollgridOperators,      CDI_REAL, -1,  1 },
   { Command,        NULL,              CommandOperators,       CDI_REAL,  1,  0 },
   { Comp,           CompHelp,          CompOperators,          CDI_REAL,  2,  1 },
@@ -573,7 +587,7 @@ static modules_t Modules[] =
   { Derivepar,      DeriveparHelp,     DeriveparOperators,     CDI_REAL,  1,  1 },
   { Detrend,        DetrendHelp,       DetrendOperators,       CDI_REAL,  1,  1 },
   { Diff,           DiffHelp,          DiffOperators,          CDI_REAL,  2,  0 },
-  { Distgrid,       DistgridHelp,      DistgridOperators,       CDI_REAL,  1,  1 },
+  { Distgrid,       DistgridHelp,      DistgridOperators,      CDI_REAL,  1,  1 },
   { Duplicate,      DuplicateHelp,     DuplicateOperators,     CDI_REAL,  1,  1 },
   { Echam5ini,      NULL,              Echam5iniOperators,     CDI_REAL,  1,  1 },
   { Enlarge,        EnlargeHelp,       EnlargeOperators,       CDI_REAL,  1,  1 },
@@ -584,11 +598,11 @@ static modules_t Modules[] =
   { Eofcoeff,       EofcoeffHelp,      EofcoeffOperators,      CDI_REAL,  2, -1 },
   { Eofcoeff3d,     EofcoeffHelp,      Eofcoeff3dOperators,    CDI_REAL,  2, -1 },
   { EOFs,           EOFsHelp,          EOFsOperators,          CDI_REAL,  1,  2 },
-  { EOF3d,          NULL,              EOF3dOperators,         CDI_REAL,  1,  2 },
+  { EOF3d,          EOFsHelp,          EOF3dOperators,         CDI_REAL,  1,  2 },
   { Expr,           ExprHelp,          ExprOperators,          CDI_REAL,  1,  1 },
   { FC,             NULL,              FCOperators,            CDI_REAL,  1,  1 },
   { Filedes,        FiledesHelp,       FiledesOperators,       CDI_BOTH,  1,  0 },
-  { Fillmiss,       FillmissHelp,      FillmissOperators,      CDI_REAL,  1,  1 },
+  { Fillmiss,       NULL,              FillmissOperators,      CDI_REAL,  1,  1 },
   { Filter,         FilterHelp,        FilterOperators,        CDI_REAL,  1,  1 },
   { Fldrms,         NULL,              FldrmsOperators,        CDI_REAL,  2,  1 },
   { Fldstat,        FldstatHelp,       FldstatOperators,       CDI_REAL,  1,  1 },
@@ -623,7 +637,7 @@ static modules_t Modules[] =
   { Maskbox,        MaskboxHelp,       MaskboxOperators,       CDI_REAL,  1,  1 },
   { Maskbox,        MaskregionHelp,    MaskregionOperators,    CDI_REAL,  1,  1 },
   { Mastrfu,        MastrfuHelp,       MastrfuOperators,       CDI_REAL,  1,  1 },
-  { Math,           MathHelp,          MathOperators,          CDI_REAL,  1,  1 },
+  { Math,           MathHelp,          MathOperators,          CDI_BOTH,  1,  1 },
   { Merge,          MergeHelp,         MergeOperators,         CDI_REAL, -1,  1 },
   { Mergetime,      MergeHelp,         MergetimeOperators,     CDI_REAL, -1,  1 },
   { Mergegrid,      MergegridHelp,     MergegridOperators,     CDI_REAL,  2,  1 },
@@ -641,8 +655,15 @@ static modules_t Modules[] =
   { Pressure,       NULL,              PressureOperators,      CDI_REAL,  1,  1 },
   { Regres,         RegresHelp,        RegresOperators,        CDI_REAL,  1,  1 },
   { Remap,          RemapHelp,         RemapOperators,         CDI_REAL,  1,  1 },
-  { Remap,          RemapgridHelp,     RemapgridOperators,     CDI_REAL,  1,  1 },
-  { Remap,          GenweightsHelp,    GenweightsOperators,    CDI_REAL,  1,  1 },
+  { Remap,          RemapbilHelp,      RemapbilOperators,      CDI_REAL,  1,  1 },
+  { Remap,          RemapbicHelp,      RemapbicOperators,      CDI_REAL,  1,  1 },
+  { Remap,          RemapnnHelp,       RemapnnOperators,       CDI_REAL,  1,  1 },
+  { Remap,          RemapdisHelp,      RemapdisOperators,      CDI_REAL,  1,  1 },
+  { Remap,          RemapyconHelp,     RemapyconOperators,     CDI_REAL,  1,  1 },
+  { Remap,          RemapconHelp,      RemapconOperators,      CDI_REAL,  1,  1 },
+  { Remap,          Remapcon2Help,     Remapcon2Operators,     CDI_REAL,  1,  1 },
+  { Remap,          RemaplafHelp,      RemaplafOperators,      CDI_REAL,  1,  1 },
+  { Remap,          NULL,              RemapgridOperators,     CDI_REAL,  1,  1 },
   { Remapeta,       RemapetaHelp,      RemapetaOperators,      CDI_REAL,  1,  1 },
   { Replace,        ReplaceHelp,       ReplaceOperators,       CDI_REAL,  2,  1 },
   { Replacevalues,  ReplacevaluesHelp, ReplacevaluesOperators, CDI_REAL,  1,  1 },
@@ -665,6 +686,7 @@ static modules_t Modules[] =
   { Setgrid,        SetgridHelp,       SetgridOperators,       CDI_BOTH,  1,  1 },
   { Sethalo,        SethaloHelp,       SethaloOperators,       CDI_REAL,  1,  1 },
   { Setmiss,        SetmissHelp,       SetmissOperators,       CDI_REAL,  1,  1 },
+  { Fillmiss,       SetmissHelp,       SetmisstonnOperators,   CDI_REAL,  1,  1 },
   { Setpartab,      SetHelp,           Setpartab0Operators,    CDI_REAL,  1,  1 },
   { Setpartab,      SetpartabHelp,     SetpartabOperators,     CDI_REAL,  1,  1 },
   { Setrcaname,     NULL,              SetrcanameOperators,    CDI_REAL,  1,  1 },
@@ -705,6 +727,7 @@ static modules_t Modules[] =
   { Timselpctl,     TimselpctlHelp,    TimselpctlOperators,    CDI_REAL,  3,  1 },
   { Timsort,        TimsortHelp,       TimsortOperators,       CDI_REAL,  1,  1 },
   { Timselstat,     TimselstatHelp,    TimselstatOperators,    CDI_REAL,  1,  1 },
+  { XTimstat,       NULL,              XTimstatOperators,      CDI_BOTH,  1,  1 },
   { Timstat,        TimstatHelp,       TimstatOperators,       CDI_BOTH,  1,  1 },
   { Timstat,        YearstatHelp,      YearstatOperators,      CDI_BOTH,  1,  1 },
   { Timstat,        MonstatHelp,       MonstatOperators,       CDI_BOTH,  1,  1 },
@@ -722,15 +745,16 @@ static modules_t Modules[] =
   { Vardup,         NULL,              VardupOperators,        CDI_REAL,  1,  1 },
   { Vargen,         VargenHelp,        VargenOperators,        CDI_REAL,  0,  1 },
   { Varrms,         NULL,              VarrmsOperators,        CDI_REAL,  2,  1 },
-  { Vertintml,      IntvertHelp,       VertintmlOperators,     CDI_REAL,  1,  1 },
-  { Vertintap,      NULL,              VertintapOperators,     CDI_REAL,  1,  1 },
+  { Vertintml,      VertintmlHelp,     VertintmlOperators,     CDI_REAL,  1,  1 },
+  { Vertintap,      VertintapHelp,     VertintapOperators,     CDI_REAL,  1,  1 },
   { Vertstat,       VertstatHelp,      VertstatOperators,      CDI_REAL,  1,  1 },
+  { Vertcum,        NULL,              VertcumOperators,       CDI_REAL,  1,  1 },
   { Vertwind,       NULL,              VertwindOperators,      CDI_REAL,  1,  1 },
   { Wind,           WindHelp,          WindOperators,          CDI_REAL,  1,  1 },
   { Writegrid,      NULL,              WritegridOperators,     CDI_REAL,  1,  1 },  /* no cdi output */
   { Writerandom,    NULL,              WriterandomOperators,   CDI_REAL,  1,  1 },
   { YAR,            NULL,              YAROperators,           CDI_REAL,  1,  1 },
-  { Yearmonstat,    YearmonmeanHelp,   YearmonstatOperators,   CDI_REAL,  1,  1 },
+  { Yearmonstat,    YearmonstatHelp,   YearmonstatOperators,   CDI_REAL,  1,  1 },
   { Ydayarith,      YdayarithHelp,     YdayarithOperators,     CDI_REAL,  2,  1 },
   { Ydaypctl,       YdaypctlHelp,      YdaypctlOperators,      CDI_REAL,  3,  1 },
   { Ydaystat,       YdaystatHelp,      YdaystatOperators,      CDI_REAL,  1,  1 },
@@ -795,7 +819,7 @@ static modules_t Modules[] =
 							       
 static int NumModules = sizeof(Modules) / sizeof(Modules[0]);
 
-static char *opalias[][2] =
+static const char *opalias[][2] =
 {
   {"anomaly",             "ymonsub"    },
   {"deltap_fl",           "deltap"     },
@@ -874,12 +898,11 @@ int similar(const char *a, const char *b, int alen, int blen)
 }
 
 
-char *operatorAlias(char *operatorName)
+const char *operatorAlias(char *operatorName)
 {
-  char *operatorNameNew;
   int i;
 
-  operatorNameNew = operatorName;
+  const char *operatorNameNew = operatorName;
 
   for ( i = 0; i < nopalias; i++ )
     {
@@ -893,11 +916,11 @@ char *operatorAlias(char *operatorName)
       operatorNameNew = opalias[i][1];
     }
 
-  return (operatorNameNew);
+  return operatorNameNew;
 }
 
 static
-int operatorInqModID(char *operatorName)
+int operatorInqModID(const char *operatorName)
 {
   int i, j, modID = -1;
 
@@ -905,7 +928,6 @@ int operatorInqModID(char *operatorName)
     {
       for ( i = 0; i < NumModules; i++ )
 	{
-	  j = 0;
 	  for ( j = 0; j < MAX_MOD_OPERATORS; j++ )
 	    {
 	      if ( Modules[i].operators[j] == NULL ) break;
@@ -928,10 +950,9 @@ int operatorInqModID(char *operatorName)
 
   if ( modID == -1 )
     {
-      FILE *fp;
       int nbyte;
       int error = TRUE;
-      fp = fopen(operatorName, "r");
+      FILE *fp = fopen(operatorName, "r");
       if ( fp )
 	{
 	  fclose(fp);
@@ -975,42 +996,37 @@ int operatorInqModID(char *operatorName)
     if ( ! Modules[modID].func )
       Error("Module for operator >%s< not installed!", operatorName);
 
-  return (modID);
+  return modID;
 }
 
 void *(*operatorModule(char *operatorName))(void *)
 {
-  int modID;
-  modID = operatorInqModID(operatorName);
-  return (Modules[modID].func);
+  int modID = operatorInqModID(operatorName);
+  return Modules[modID].func;
 }
 
-char **operatorHelp(char *operatorName)
+const char **operatorHelp(char *operatorName)
 {
-  int modID;
-  modID = operatorInqModID(operatorName);
-  return (Modules[modID].help);
+  int modID = operatorInqModID(operatorName);
+  return Modules[modID].help;
 }
 
 int operatorStreamInCnt(char *operatorName)
 {
-  int modID;
-  modID = operatorInqModID(operatorAlias(operatorName));
-  return (Modules[modID].streamInCnt);
+  int modID = operatorInqModID(operatorAlias(operatorName));
+  return Modules[modID].streamInCnt;
 }
 
 int operatorStreamOutCnt(char *operatorName)
 {
-  int modID;
-  modID = operatorInqModID(operatorAlias(operatorName));
-  return (Modules[modID].streamOutCnt);
+  int modID = operatorInqModID(operatorAlias(operatorName));
+  return Modules[modID].streamOutCnt;
 }
 
 int operatorStreamNumber(char *operatorName)
 {
-  int modID;
-  modID = operatorInqModID(operatorAlias(operatorName));
-  return (Modules[modID].number);
+  int modID = operatorInqModID(operatorAlias(operatorName));
+  return Modules[modID].number;
 }
 
 int cmpname(const void *s1, const void *s2)
@@ -1018,13 +1034,13 @@ int cmpname(const void *s1, const void *s2)
   char **c1 = (char **) s1;
   char **c2 = (char **) s2;
 
-  return (strcmp((const char *)*c1, (const char *)*c2));
+  return strcmp((const char *)*c1, (const char *)*c2);
 }
 
 void operatorPrintAll(void)
 {
   int i, j, nbyte, nop = 0;
-  char *opernames[4096];
+  const char *opernames[4096];
   FILE *pout = stderr;
 
   for ( i = 0; i < NumModules; i++ )
diff --git a/src/modules.h b/src/modules.h
index 8a1f1cf..6021381 100644
--- a/src/modules.h
+++ b/src/modules.h
@@ -20,7 +20,7 @@
 
 void *(*operatorModule(char *operatorName))(void *);
 
-char **operatorHelp(char *operatorName);
+const char **operatorHelp(char *operatorName);
 
 int operatorStreamInCnt(char *operatorName);
 int operatorStreamOutCnt(char *operatorName);
diff --git a/src/namelist.c b/src/namelist.c
index 066243d..8cb3c04 100644
--- a/src/namelist.c
+++ b/src/namelist.c
@@ -15,18 +15,16 @@
   GNU General Public License for more details.
 */
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdarg.h>
-
+#include "cdo_int.h"
 #include "namelist.h"
 
-#if ! defined(strdup)
+
+#ifndef strdupx
+#ifndef strdup
 char *strdup(const char *s);
 #endif
-int readline(FILE *fp, char *line, int len);
+#define strdupx  strdup
+#endif
 
 
 #define  func_1         -1 /* nptype */
@@ -65,7 +63,7 @@ namelist_t *namelistNew(const char *name)
 {
   namelist_t *namelist;
 
-  namelist = (namelist_t*) malloc(sizeof(namelist_t));
+  namelist = (namelist_t*) Malloc(sizeof(namelist_t));
 
   namelist_init(namelist, name);
 
@@ -81,22 +79,22 @@ void namelistDelete(namelist_t *nml)
     {
       for ( i = 0; i < nml->size; i++ )
 	{
-	  if ( nml->entry[i]->name ) free(nml->entry[i]->name);
+	  if ( nml->entry[i]->name ) Free(nml->entry[i]->name);
 	  if ( nml->entry[i]->type == NML_WORD )
 	    for ( iocc = 0; iocc < nml->entry[i]->occ; iocc++ )
 	      {
 		if ( ((char **)nml->entry[i]->ptr)[iocc] )
 		  {
-		    free(((char **)nml->entry[i]->ptr)[iocc]);
+		    Free(((char **)nml->entry[i]->ptr)[iocc]);
 		    ((char **)nml->entry[i]->ptr)[iocc] = NULL;
 		  }
 	      }
 
-	  free(nml->entry[i]);
+	  Free(nml->entry[i]);
 	}
       
-      if ( nml->name ) free(nml->name);
-      free(nml);
+      if ( nml->name ) Free(nml->name);
+      Free(nml);
     }
 }
 
@@ -114,7 +112,7 @@ void namelistReset(namelist_t *nml)
 	      {
 		if ( ((char **)nml->entry[i]->ptr)[iocc] )
 		  {
-		    free(((char **)nml->entry[i]->ptr)[iocc]);
+		    Free(((char **)nml->entry[i]->ptr)[iocc]);
 		    ((char **)nml->entry[i]->ptr)[iocc] = NULL;
 		  }
 	      }
@@ -178,10 +176,10 @@ int namelistAdd(namelist_t *nml, const char *name, int type, int dis, void *ptr,
   if ( nml->size >= MAX_NML_ENTRY )
     {
       fprintf(stderr, "Too many namelist entries in %s! (Max = %d)\n", nml->name, MAX_NML_ENTRY);
-      return (-1);
+      return -1;
     }
 
-  nml_entry = (nml_entry_t*) malloc(sizeof(nml_entry_t));
+  nml_entry = (nml_entry_t*) Malloc(sizeof(nml_entry_t));
 
   nml_entry->name = strdup(name);
   nml_entry->type = type;
@@ -341,7 +339,7 @@ void rdnlsgl(namelist_t *nml, void *var, int ntyp, int nlen, int *nocc)
 	  if ( *nocc < nlen )
 	    {
 	      len = nml->line.namitl - nml->line.namitf + 1;
-	      ((char **)var)[*nocc] = (char*) calloc((size_t)len+1, sizeof(char));
+	      ((char **)var)[*nocc] = (char*) Calloc((size_t)len+1, sizeof(char));
 	      for ( i = 0; i < len; i++ )
 		((char **)var)[*nocc][i] = nml->line.lineac[nml->line.namitf+i];
 	      *nocc += 1;
@@ -384,7 +382,7 @@ void rdnlsgl(namelist_t *nml, void *var, int ntyp, int nlen, int *nocc)
       if ( *nocc < nlen )
 	{
 	  len = nml->line.namitl - nml->line.namitf + 1;
-	  ((char **)var)[*nocc] = (char*) calloc((size_t)len+1, sizeof(char));
+	  ((char **)var)[*nocc] = (char*) Calloc((size_t)len+1, sizeof(char));
 	  for ( i = 0; i < len; i++ )
 	    ((char **)var)[*nocc][i] = nml->line.lineac[nml->line.namitf+i];
 	  *nocc += 1;
diff --git a/src/nearpt3c.h b/src/nearpt3c.h
new file mode 100644
index 0000000..867db6e
--- /dev/null
+++ b/src/nearpt3c.h
@@ -0,0 +1,17 @@
+//typedef unsigned short int Coord_T;
+//typedef short int Coord_T;
+//typedef unsigned int Coord_T;
+typedef float Coord_T;
+
+#define NPT3SFACT 32000
+#define NPT3SCALE(x) (0.5+(x+1)*NPT3SFACT)
+
+#if defined(__cplusplus)
+extern "C" {
+#endif
+void *nearpt3_preprocess(const int nfixpts, Coord_T **pts);
+int nearpt3_query(void *g, const Coord_T *q);
+void nearpt3_destroy(void *g);
+#if defined(__cplusplus)
+}
+#endif
diff --git a/src/normal.c b/src/normal.c
index d028489..6cad107 100644
--- a/src/normal.c
+++ b/src/normal.c
@@ -1,5 +1,6 @@
 #include <cdi.h>
 #include "cdo.h"
+#include "util.h"
 
 void nospec(int vlistID)
 {
diff --git a/src/nth_element.c b/src/nth_element.c
index 7627b6c..7cdead0 100644
--- a/src/nth_element.c
+++ b/src/nth_element.c
@@ -22,7 +22,7 @@
 
 #define SWAP(a, b) {t = (a); (a) = (b); (b) = t;}
 
-double nth_element(double array[], int length, int n)
+double nth_element(double *array, int length, int n)
 {
   int i, j, k = 0, l = length-1, m;
   double a,t;
@@ -45,12 +45,9 @@ double nth_element(double array[], int length, int n)
           m = (k+l) >> 1; 
           SWAP(array[m],array[k+1]);
           
-          if ( array[k] > array[l] ) 
-            SWAP(array[k], array[l])
-          if ( array[k+1] > array[l] ) 
-            SWAP(array[k+1], array[l])
-          if ( array[k] > array[k+1] ) 
-            SWAP(array[k], array[k+1])
+          if ( array[k]   > array[l] )   SWAP(array[k],   array[l])
+          if ( array[k+1] > array[l] )   SWAP(array[k+1], array[l])
+          if ( array[k]   > array[k+1] ) SWAP(array[k],   array[k+1])
 
           i = k+1; 
           j = l;
diff --git a/src/nth_element.h b/src/nth_element.h
index 0ccba51..8df96aa 100644
--- a/src/nth_element.h
+++ b/src/nth_element.h
@@ -34,6 +34,6 @@
  * @author Ralf Quast
  * @version 1.0
  */
-double nth_element(double array[], int length, int n);
+double nth_element(double *array, int length, int n);
 
 #endif /*NTH_ELEMENT_H_*/
diff --git a/src/operator_help.h b/src/operator_help.h
index 31473ba..94c7c16 100644
--- a/src/operator_help.h
+++ b/src/operator_help.h
@@ -1,6 +1,6 @@
 /* Automatically created with makedoc, don't edit! */
 
-static char *InfoHelp[] = {
+static const char *InfoHelp[] = {
     "NAME",
     "    info, infon, map - Information and simple statistics",
     "",
@@ -32,7 +32,7 @@ static char *InfoHelp[] = {
     NULL
 };
 
-static char *SinfoHelp[] = {
+static const char *SinfoHelp[] = {
     "NAME",
     "    sinfo, sinfon - Short information",
     "",
@@ -64,7 +64,7 @@ static char *SinfoHelp[] = {
     NULL
 };
 
-static char *DiffHelp[] = {
+static const char *DiffHelp[] = {
     "NAME",
     "    diff, diffn - Compare two datasets field by field",
     "",
@@ -72,9 +72,8 @@ static char *DiffHelp[] = {
     "    <operator>  ifile1 ifile2",
     "",
     "DESCRIPTION",
-    "    Compares the contents of two datasets field by field. The input",
-    "    datasets need to have the same structure and its fields need to have ",
-    "    the same header information and dimensions.",
+    "    Compares the contents of two datasets field by field. The input datasets need to have the",
+    "    same structure and its fields need to have the same header information and dimensions.",
     "",
     "OPERATORS",
     "    diff   Compare two datasets listed by parameter id",
@@ -94,7 +93,7 @@ static char *DiffHelp[] = {
     NULL
 };
 
-static char *NinfoHelp[] = {
+static const char *NinfoHelp[] = {
     "NAME",
     "    npar, nlevel, nyear, nmon, ndate, ntime - ",
     "    Print the number of parameters, levels or times",
@@ -122,7 +121,7 @@ static char *NinfoHelp[] = {
     NULL
 };
 
-static char *ShowinfoHelp[] = {
+static const char *ShowinfoHelp[] = {
     "NAME",
     "    showformat, showcode, showname, showstdname, showlevel, showltype, showyear, ",
     "    showmon, showdate, showtime, showtimestamp - Show variables, levels or times",
@@ -159,7 +158,7 @@ static char *ShowinfoHelp[] = {
     NULL
 };
 
-static char *FiledesHelp[] = {
+static const char *FiledesHelp[] = {
     "NAME",
     "    pardes, griddes, zaxisdes, vct - Dataset description",
     "",
@@ -184,7 +183,7 @@ static char *FiledesHelp[] = {
     NULL
 };
 
-static char *CopyHelp[] = {
+static const char *CopyHelp[] = {
     "NAME",
     "    copy, cat - Copy datasets",
     "",
@@ -205,7 +204,7 @@ static char *CopyHelp[] = {
     NULL
 };
 
-static char *ReplaceHelp[] = {
+static const char *ReplaceHelp[] = {
     "NAME",
     "    replace - Replace variables",
     "",
@@ -218,7 +217,7 @@ static char *ReplaceHelp[] = {
     NULL
 };
 
-static char *DuplicateHelp[] = {
+static const char *DuplicateHelp[] = {
     "NAME",
     "    duplicate - Duplicates a dataset",
     "",
@@ -234,7 +233,7 @@ static char *DuplicateHelp[] = {
     NULL
 };
 
-static char *MergegridHelp[] = {
+static const char *MergegridHelp[] = {
     "NAME",
     "    mergegrid - Merge grid",
     "",
@@ -250,7 +249,7 @@ static char *MergegridHelp[] = {
     NULL
 };
 
-static char *MergeHelp[] = {
+static const char *MergeHelp[] = {
     "NAME",
     "    merge, mergetime - Merge datasets",
     "",
@@ -281,7 +280,7 @@ static char *MergeHelp[] = {
     NULL
 };
 
-static char *SplitHelp[] = {
+static const char *SplitHelp[] = {
     "NAME",
     "    splitcode, splitparam, splitname, splitlevel, splitgrid, splitzaxis, ",
     "    splittabnum - Split a dataset",
@@ -330,7 +329,7 @@ static char *SplitHelp[] = {
     NULL
 };
 
-static char *SplittimeHelp[] = {
+static const char *SplittimeHelp[] = {
     "NAME",
     "    splithour, splitday, splitseas, splityear, splityearmon, splitmon - ",
     "    Split timesteps of a dataset",
@@ -375,7 +374,7 @@ static char *SplittimeHelp[] = {
     NULL
 };
 
-static char *SplitselHelp[] = {
+static const char *SplitselHelp[] = {
     "NAME",
     "    splitsel - Split selected timesteps",
     "",
@@ -401,7 +400,7 @@ static char *SplitselHelp[] = {
     NULL
 };
 
-static char *DistgridHelp[] = {
+static const char *DistgridHelp[] = {
     "NAME",
     "    distgrid - Distribute horizontal grid",
     "",
@@ -410,10 +409,11 @@ static char *DistgridHelp[] = {
     "",
     "DESCRIPTION",
     "    This operator distributes a dataset into smaller pieces. Each output file contains a different region of the horizontal ",
-    "    source grid. A target grid region contains a regular longitude/latitude box of the source grid. Only rectilinear source ",
-    "    grids are supported by this operator. The number of different regions can be specified with the parameter nx and ny.",
-    "    The output files will be named <obase><xxx><suffix> where suffix is the filename extension derived from the file format. ",
-    "    xxx will have five digits with the number of the target region.",
+    "    source grid. A target grid region contains a structured longitude/latitude box of the source grid. Only rectilinear and",
+    "    curvilinear source grids are supported by this operator.",
+    "    The number of different regions can be specified with the parameter nx and ny. The output files will be named ",
+    "    <obase><xxx><suffix> where suffix is the filename extension derived from the file format. xxx will have five digits with ",
+    "    the number of the target region.",
     "",
     "PARAMETER",
     "    nx  INTEGER  Number of regions in x direction",
@@ -425,20 +425,22 @@ static char *DistgridHelp[] = {
     NULL
 };
 
-static char *CollgridHelp[] = {
+static const char *CollgridHelp[] = {
     "NAME",
     "    collgrid - Collect horizontal grid",
     "",
     "SYNOPSIS",
-    "    collgrid[,names]  ifiles ofile",
+    "    collgrid[,nx[,names]]  ifiles ofile",
     "",
     "DESCRIPTION",
     "    This operator collects the data of the input files to one output file. ",
     "    All input files need to have the same variables and the same number of timesteps on a different",
-    "    horizonal grid region. A source region must be a rectilinear longitude/latitude grid box.",
+    "    horizonal grid region. A source region must be a structured longitude/latitude grid box.",
+    "    The parameter nx needs to be specified only for curvilinear grids.",
     "",
     "PARAMETER",
-    "    names  STRING  Comma separated list of variable names [default: all variables]",
+    "    nx     INTEGER  Number of regions in x direction, only needed for curvilinear grids",
+    "    names  STRING   Comma separated list of variable names [default: all variables]",
     "",
     "NOTE",
     "    This operator needs to open all input files simultaneously.",
@@ -446,7 +448,7 @@ static char *CollgridHelp[] = {
     NULL
 };
 
-static char *SelectHelp[] = {
+static const char *SelectHelp[] = {
     "NAME",
     "    select, delete - Select fields",
     "",
@@ -486,7 +488,7 @@ static char *SelectHelp[] = {
     NULL
 };
 
-static char *SelvarHelp[] = {
+static const char *SelvarHelp[] = {
     "NAME",
     "    selparam, delparam, selcode, delcode, selname, delname, selstdname, sellevel, ",
     "    sellevidx, selgrid, selzaxis, selzaxisname, selltype, seltabnum - Select fields",
@@ -555,7 +557,7 @@ static char *SelvarHelp[] = {
     NULL
 };
 
-static char *SeltimeHelp[] = {
+static const char *SeltimeHelp[] = {
     "NAME",
     "    seltimestep, seltime, selhour, selday, selmon, selyear, selseas, seldate, ",
     "    selsmon - Select timesteps",
@@ -610,7 +612,7 @@ static char *SeltimeHelp[] = {
     NULL
 };
 
-static char *SelboxHelp[] = {
+static const char *SelboxHelp[] = {
     "NAME",
     "    sellonlatbox, selindexbox - Select a box of a field",
     "",
@@ -625,6 +627,7 @@ static char *SelboxHelp[] = {
     "    sellonlatbox  Select a longitude/latitude box",
     "                  Selects a regular longitude/latitude box. The user has to give the longitudes and latitudes of the ",
     "                  edges of the box. Considered are only those grid cells with the grid center inside the lon/lat box.",
+    "                  For rotated lon/lat grids the parameter needs to be rotated coordinates.",
     "    selindexbox   Select an index box",
     "                  Selects an index box. The user has to give the indexes of the edges of the box. The index of the ",
     "                  left edge may be greater then that of the right edge.",
@@ -641,7 +644,7 @@ static char *SelboxHelp[] = {
     NULL
 };
 
-static char *CondHelp[] = {
+static const char *CondHelp[] = {
     "NAME",
     "    ifthen, ifnotthen - Conditional select one field",
     "",
@@ -668,7 +671,7 @@ static char *CondHelp[] = {
     NULL
 };
 
-static char *Cond2Help[] = {
+static const char *Cond2Help[] = {
     "NAME",
     "    ifthenelse - Conditional select  two fields",
     "",
@@ -690,7 +693,7 @@ static char *Cond2Help[] = {
     NULL
 };
 
-static char *CondcHelp[] = {
+static const char *CondcHelp[] = {
     "NAME",
     "    ifthenc, ifnotthenc - Conditional select a constant",
     "",
@@ -717,7 +720,7 @@ static char *CondcHelp[] = {
     NULL
 };
 
-static char *CompHelp[] = {
+static const char *CompHelp[] = {
     "NAME",
     "    eq, ne, le, lt, ge, gt - Comparison of two fields",
     "",
@@ -760,7 +763,7 @@ static char *CompHelp[] = {
     NULL
 };
 
-static char *CompcHelp[] = {
+static const char *CompcHelp[] = {
     "NAME",
     "    eqc, nec, lec, ltc, gec, gtc - Comparison of a field with a constant",
     "",
@@ -803,7 +806,7 @@ static char *CompcHelp[] = {
     NULL
 };
 
-static char *SetpartabHelp[] = {
+static const char *SetpartabHelp[] = {
     "NAME",
     "    setpartabp, setpartabn - Set parameter table",
     "",
@@ -853,7 +856,7 @@ static char *SetpartabHelp[] = {
     NULL
 };
 
-static char *SetHelp[] = {
+static const char *SetHelp[] = {
     "NAME",
     "    setpartab, setcode, setparam, setname, setunit, setlevel, setltype - ",
     "    Set field info",
@@ -897,7 +900,7 @@ static char *SetHelp[] = {
     NULL
 };
 
-static char *SettimeHelp[] = {
+static const char *SettimeHelp[] = {
     "NAME",
     "    setdate, settime, setday, setmon, setyear, settunits, settaxis, setreftime, ",
     "    setcalendar, shifttime - Set time",
@@ -953,7 +956,7 @@ static char *SettimeHelp[] = {
     NULL
 };
 
-static char *ChangeHelp[] = {
+static const char *ChangeHelp[] = {
     "NAME",
     "    chcode, chparam, chname, chunit, chlevel, chlevelc, chlevelv - ",
     "    Change field header",
@@ -1000,7 +1003,7 @@ static char *ChangeHelp[] = {
     NULL
 };
 
-static char *SetgridHelp[] = {
+static const char *SetgridHelp[] = {
     "NAME",
     "    setgrid, setgridtype, setgridarea - Set grid information",
     "",
@@ -1038,7 +1041,7 @@ static char *SetgridHelp[] = {
     NULL
 };
 
-static char *SetzaxisHelp[] = {
+static const char *SetzaxisHelp[] = {
     "NAME",
     "    setzaxis, genlevelbounds - Set z-axis information",
     "",
@@ -1062,7 +1065,7 @@ static char *SetzaxisHelp[] = {
     NULL
 };
 
-static char *SetgattHelp[] = {
+static const char *SetgattHelp[] = {
     "NAME",
     "    setgatt, setgatts - Set global attribute",
     "",
@@ -1090,7 +1093,7 @@ static char *SetgattHelp[] = {
     NULL
 };
 
-static char *InvertHelp[] = {
+static const char *InvertHelp[] = {
     "NAME",
     "    invertlat - Invert latitudes",
     "",
@@ -1102,7 +1105,7 @@ static char *InvertHelp[] = {
     NULL
 };
 
-static char *InvertlevHelp[] = {
+static const char *InvertlevHelp[] = {
     "NAME",
     "    invertlev - Invert levels",
     "",
@@ -1110,11 +1113,11 @@ static char *InvertlevHelp[] = {
     "    invertlev  ifile ofile",
     "",
     "DESCRIPTION",
-    "    This operator inverts the levels of all non hybrid 3D variables.",
+    "    This operator inverts the levels of all 3D variables.",
     NULL
 };
 
-static char *MaskregionHelp[] = {
+static const char *MaskregionHelp[] = {
     "NAME",
     "    maskregion - Mask regions",
     "",
@@ -1137,7 +1140,7 @@ static char *MaskregionHelp[] = {
     NULL
 };
 
-static char *MaskboxHelp[] = {
+static const char *MaskboxHelp[] = {
     "NAME",
     "    masklonlatbox, maskindexbox - Mask a box",
     "",
@@ -1170,7 +1173,7 @@ static char *MaskboxHelp[] = {
     NULL
 };
 
-static char *SetboxHelp[] = {
+static const char *SetboxHelp[] = {
     "NAME",
     "    setclonlatbox, setcindexbox - Set a box to constant",
     "",
@@ -1205,7 +1208,7 @@ static char *SetboxHelp[] = {
     NULL
 };
 
-static char *EnlargeHelp[] = {
+static const char *EnlargeHelp[] = {
     "NAME",
     "    enlarge - Enlarge fields",
     "",
@@ -1225,9 +1228,10 @@ static char *EnlargeHelp[] = {
     NULL
 };
 
-static char *SetmissHelp[] = {
+static const char *SetmissHelp[] = {
     "NAME",
-    "    setmissval, setctomiss, setmisstoc, setrtomiss, setvrange - Set missing value",
+    "    setmissval, setctomiss, setmisstoc, setrtomiss, setvrange, setmisstonn, ",
+    "    setmisstodis - Set missing value",
     "",
     "SYNOPSIS",
     "    setmissval,newmiss  ifile ofile",
@@ -1235,6 +1239,8 @@ static char *SetmissHelp[] = {
     "    setmisstoc,c  ifile ofile",
     "    setrtomiss,rmin,rmax  ifile ofile",
     "    setvrange,rmin,rmax  ifile ofile",
+    "    setmisstonn  ifile ofile",
+    "    setmisstodis[,neighbors]  ifile ofile",
     "",
     "DESCRIPTION",
     "    This module sets part of a field to missing value or missing values",
@@ -1242,36 +1248,45 @@ static char *SetmissHelp[] = {
     "    chosen operator.",
     "",
     "OPERATORS",
-    "    setmissval  Set a new missing value",
-    "                         / newmiss   if i(t,x) EQ miss",
-    "                o(t,x) = ",
-    "                         \\ i(t,x)    if i(t,x) NE miss",
-    "    setctomiss  Set constant to missing value",
-    "                         / miss   if i(t,x) EQ c",
-    "                o(t,x) = ",
-    "                         \\ i(t,x) if i(t,x) NE c",
-    "    setmisstoc  Set missing value to constant",
-    "                         / c      if i(t,x) EQ miss",
-    "                o(t,x) = ",
-    "                         \\ i(t,x) if i(t,x) NE miss",
-    "    setrtomiss  Set range to missing value",
-    "                         / miss   if i(t,x) GE rmin AND i(t,x) LE rmax",
-    "                o(t,x) = ",
-    "                         \\ i(t,x) if i(t,x) LT rmin OR  i(t,x) GT rmax",
-    "    setvrange   Set valid range",
-    "                         / miss   if i(t,x) LT rmin OR  i(t,x) GT rmax",
-    "                o(t,x) = ",
-    "                         \\ i(t,x) if i(t,x) GE rmin AND i(t,x) LE rmax",
+    "    setmissval    Set a new missing value",
+    "                           / newmiss   if i(t,x) EQ miss",
+    "                  o(t,x) = ",
+    "                           \\ i(t,x)    if i(t,x) NE miss",
+    "    setctomiss    Set constant to missing value",
+    "                           / miss   if i(t,x) EQ c",
+    "                  o(t,x) = ",
+    "                           \\ i(t,x) if i(t,x) NE c",
+    "    setmisstoc    Set missing value to constant",
+    "                           / c      if i(t,x) EQ miss",
+    "                  o(t,x) = ",
+    "                           \\ i(t,x) if i(t,x) NE miss",
+    "    setrtomiss    Set range to missing value",
+    "                           / miss   if i(t,x) GE rmin AND i(t,x) LE rmax",
+    "                  o(t,x) = ",
+    "                           \\ i(t,x) if i(t,x) LT rmin OR  i(t,x) GT rmax",
+    "    setvrange     Set valid range",
+    "                           / miss   if i(t,x) LT rmin OR  i(t,x) GT rmax",
+    "                  o(t,x) = ",
+    "                           \\ i(t,x) if i(t,x) GE rmin AND i(t,x) LE rmax",
+    "    setmisstonn   Set missing value to nearest neighbor",
+    "                  Set all missing values to the nearest non missing value.",
+    "                           / i(t,y) if i(t,x) EQ miss AND i(t,y) NE miss",
+    "                  o(t,x) = ",
+    "                           \\ i(t,x) if i(t,x) NE miss",
+    "    setmisstodis  Set missing value to distance-weighted average",
+    "                  Set all missing values to the distance-weighted average of the nearest non missing values.",
+    "                  The default number of nearest neighbors is 4.",
     "",
     "PARAMETER",
-    "    newmiss  FLOAT  New missing value",
-    "    c        FLOAT  Constant",
-    "    rmin     FLOAT  Lower bound",
-    "    rmax     FLOAT  Upper bound",
+    "    neighbors  INTEGER  Number of nearest neighbors",
+    "    newmiss    FLOAT    New missing value",
+    "    c          FLOAT    Constant",
+    "    rmin       FLOAT    Lower bound",
+    "    rmax       FLOAT    Upper bound",
     NULL
 };
 
-static char *ExprHelp[] = {
+static const char *ExprHelp[] = {
     "NAME",
     "    expr, exprf, aexpr, aexprf - Evaluate expressions",
     "",
@@ -1339,7 +1354,7 @@ static char *ExprHelp[] = {
     NULL
 };
 
-static char *MathHelp[] = {
+static const char *MathHelp[] = {
     "NAME",
     "    abs, int, nint, pow, sqr, sqrt, exp, ln, log10, sin, cos, tan, asin, acos, ",
     "    reci - Mathematical functions",
@@ -1385,7 +1400,7 @@ static char *MathHelp[] = {
     NULL
 };
 
-static char *ArithcHelp[] = {
+static const char *ArithcHelp[] = {
     "NAME",
     "    addc, subc, mulc, divc - Arithmetic with a constant",
     "",
@@ -1411,7 +1426,7 @@ static char *ArithcHelp[] = {
     NULL
 };
 
-static char *ArithHelp[] = {
+static const char *ArithHelp[] = {
     "NAME",
     "    add, sub, mul, div, min, max, atan2 - Arithmetic on two datasets",
     "",
@@ -1421,8 +1436,8 @@ static char *ArithHelp[] = {
     "DESCRIPTION",
     "    This module performs simple arithmetic of two datasets.",
     "    The number of fields in ifile1 should be the same as in ifile2.",
+    "    The fields in ofile inherit the meta data from ifile1.",
     "    One of the input files can contain only one timestep or one variable.",
-    "    The fields in ofile inherit the meta data from ifile1 or ifile2.",
     "",
     "OPERATORS",
     "    add    Add two fields",
@@ -1445,7 +1460,7 @@ static char *ArithHelp[] = {
     NULL
 };
 
-static char *MonarithHelp[] = {
+static const char *MonarithHelp[] = {
     "NAME",
     "    monadd, monsub, monmul, mondiv - Monthly arithmetic",
     "",
@@ -1472,7 +1487,7 @@ static char *MonarithHelp[] = {
     NULL
 };
 
-static char *YhourarithHelp[] = {
+static const char *YhourarithHelp[] = {
     "NAME",
     "    yhouradd, yhoursub, yhourmul, yhourdiv - Multi-year hourly arithmetic",
     "",
@@ -1499,7 +1514,7 @@ static char *YhourarithHelp[] = {
     NULL
 };
 
-static char *YdayarithHelp[] = {
+static const char *YdayarithHelp[] = {
     "NAME",
     "    ydayadd, ydaysub, ydaymul, ydaydiv - Multi-year daily arithmetic",
     "",
@@ -1526,7 +1541,7 @@ static char *YdayarithHelp[] = {
     NULL
 };
 
-static char *YmonarithHelp[] = {
+static const char *YmonarithHelp[] = {
     "NAME",
     "    ymonadd, ymonsub, ymonmul, ymondiv - Multi-year monthly arithmetic",
     "",
@@ -1552,7 +1567,7 @@ static char *YmonarithHelp[] = {
     NULL
 };
 
-static char *YseasarithHelp[] = {
+static const char *YseasarithHelp[] = {
     "NAME",
     "    yseasadd, yseassub, yseasmul, yseasdiv - Multi-year seasonal arithmetic",
     "",
@@ -1578,7 +1593,7 @@ static char *YseasarithHelp[] = {
     NULL
 };
 
-static char *ArithdaysHelp[] = {
+static const char *ArithdaysHelp[] = {
     "NAME",
     "    muldpm, divdpm, muldpy, divdpy - Arithmetic with days",
     "",
@@ -1602,7 +1617,7 @@ static char *ArithdaysHelp[] = {
     NULL
 };
 
-static char *ConsecstatHelp[] = {
+static const char *ConsecstatHelp[] = {
     "NAME",
     "    consecsum, consects - Consecute timestep periods",
     "",
@@ -1629,7 +1644,7 @@ static char *ConsecstatHelp[] = {
     NULL
 };
 
-static char *EnsstatHelp[] = {
+static const char *EnsstatHelp[] = {
     "NAME",
     "    ensmin, ensmax, enssum, ensmean, ensavg, ensstd, ensstd1, ensvar, ensvar1, ",
     "    enspctl - Statistical values over an ensemble",
@@ -1681,7 +1696,7 @@ static char *EnsstatHelp[] = {
     NULL
 };
 
-static char *Ensstat2Help[] = {
+static const char *Ensstat2Help[] = {
     "NAME",
     "    ensrkhistspace, ensrkhisttime, ensroc - Statistical values over an ensemble",
     "",
@@ -1721,7 +1736,7 @@ static char *Ensstat2Help[] = {
     NULL
 };
 
-static char *EnsvalHelp[] = {
+static const char *EnsvalHelp[] = {
     "NAME",
     "    enscrps, ensbrs - Ensemble validation tools",
     "",
@@ -1784,7 +1799,7 @@ static char *EnsvalHelp[] = {
     NULL
 };
 
-static char *FldstatHelp[] = {
+static const char *FldstatHelp[] = {
     "NAME",
     "    fldmin, fldmax, fldsum, fldmean, fldavg, fldstd, fldstd1, fldvar, fldvar1, ",
     "    fldpctl - Statistical values over a field",
@@ -1851,10 +1866,10 @@ static char *FldstatHelp[] = {
     NULL
 };
 
-static char *ZonstatHelp[] = {
+static const char *ZonstatHelp[] = {
     "NAME",
-    "    zonmin, zonmax, zonsum, zonmean, zonavg, zonvar, zonstd, zonpctl - ",
-    "    Zonal statistical values",
+    "    zonmin, zonmax, zonsum, zonmean, zonavg, zonstd, zonstd1, zonvar, zonvar1, ",
+    "    zonpctl - Zonal statistical values",
     "",
     "SYNOPSIS",
     "    <operator>  ifile ofile",
@@ -1877,10 +1892,14 @@ static char *ZonstatHelp[] = {
     "             For every latitude the mean over all longitudes is computed.",
     "    zonavg   Zonal average",
     "             For every latitude the average over all longitudes is computed.",
-    "    zonvar   Zonal variance",
-    "             For every latitude the variance over all longitudes is computed.",
     "    zonstd   Zonal standard deviation",
-    "             For every latitude the standard deviation over all longitudes is computed.",
+    "             For every latitude the standard deviation over all longitudes is computed. Divisor is n.",
+    "    zonstd1  Zonal standard deviation",
+    "             For every latitude the standard deviation over all longitudes is computed. Divisor is (n-1). ",
+    "    zonvar   Zonal variance",
+    "             For every latitude the variance over all longitudes is computed. Divisor is n.",
+    "    zonvar1  Zonal variance",
+    "             For every latitude the variance over all longitudes is computed. Divisor is (n-1).",
     "    zonpctl  Zonal percentiles",
     "             For every latitude the pth percentile over all longitudes is computed.",
     "",
@@ -1889,10 +1908,10 @@ static char *ZonstatHelp[] = {
     NULL
 };
 
-static char *MerstatHelp[] = {
+static const char *MerstatHelp[] = {
     "NAME",
-    "    mermin, mermax, mersum, mermean, meravg, mervar, merstd, merpctl - ",
-    "    Meridional statistical values",
+    "    mermin, mermax, mersum, mermean, meravg, merstd, merstd1, mervar, mervar1, ",
+    "    merpctl - Meridional statistical values",
     "",
     "SYNOPSIS",
     "    <operator>  ifile ofile",
@@ -1915,10 +1934,14 @@ static char *MerstatHelp[] = {
     "             For every longitude the area weighted mean over all latitudes is computed.",
     "    meravg   Meridional average",
     "             For every longitude the area weighted average over all latitudes is computed.",
-    "    mervar   Meridional variance",
-    "             For every longitude the variance over all latitudes is computed.",
     "    merstd   Meridional standard deviation",
-    "             For every longitude the standard deviation over all latitudes is computed.",
+    "             For every longitude the standard deviation over all latitudes is computed. Divisor is n.",
+    "    merstd1  Meridional standard deviation",
+    "             For every longitude the standard deviation over all latitudes is computed. Divisor is (n-1).",
+    "    mervar   Meridional variance",
+    "             For every longitude the variance over all latitudes is computed. Divisor is n.",
+    "    mervar1  Meridional variance",
+    "             For every longitude the variance over all latitudes is computed. Divisor is (n-1).",
     "    merpctl  Meridional percentiles",
     "             For every longitude the pth percentile over all latitudes is computed.",
     "",
@@ -1927,10 +1950,10 @@ static char *MerstatHelp[] = {
     NULL
 };
 
-static char *GridboxstatHelp[] = {
+static const char *GridboxstatHelp[] = {
     "NAME",
-    "    gridboxmin, gridboxmax, gridboxsum, gridboxmean, gridboxavg, gridboxvar, ",
-    "    gridboxstd - Statistical values over grid boxes",
+    "    gridboxmin, gridboxmax, gridboxsum, gridboxmean, gridboxavg, gridboxstd, ",
+    "    gridboxstd1, gridboxvar, gridboxvar1 - Statistical values over grid boxes",
     "",
     "SYNOPSIS",
     "    <operator>,nx,ny  ifile ofile",
@@ -1943,12 +1966,23 @@ static char *GridboxstatHelp[] = {
     "",
     "OPERATORS",
     "    gridboxmin   Gridbox minimum",
+    "                 Minimum value of the selected grid boxes.",
     "    gridboxmax   Gridbox maximum",
+    "                 Maximum value of the selected grid boxes.",
     "    gridboxsum   Gridbox sum",
+    "                 Sum of the selected grid boxes.",
     "    gridboxmean  Gridbox mean",
+    "                 Mean of the selected grid boxes.",
     "    gridboxavg   Gridbox average",
-    "    gridboxvar   Gridbox variance",
+    "                 Average of the selected grid boxes.",
     "    gridboxstd   Gridbox standard deviation",
+    "                 Standard deviation of the selected grid boxes. Divisor is n.",
+    "    gridboxstd1  Gridbox standard deviation",
+    "                 Standard deviation of the selected grid boxes. Divisor is (n-1).",
+    "    gridboxvar   Gridbox variance",
+    "                 Variance of the selected grid boxes. Divisor is n.",
+    "    gridboxvar1  Gridbox variance",
+    "                 Variance of the selected grid boxes. Divisor is (n-1).",
     "",
     "PARAMETER",
     "    nx  INTEGER  Number of grid boxes in x direction",
@@ -1956,10 +1990,10 @@ static char *GridboxstatHelp[] = {
     NULL
 };
 
-static char *VertstatHelp[] = {
+static const char *VertstatHelp[] = {
     "NAME",
-    "    vertmin, vertmax, vertsum, vertmean, vertavg, vertvar, vertstd - ",
-    "    Vertical statistical values",
+    "    vertmin, vertmax, vertsum, vertmean, vertavg, vertstd, vertstd1, vertvar, ",
+    "    vertvar1 - Vertical statistical values",
     "",
     "SYNOPSIS",
     "    <operator>  ifile ofile",
@@ -1980,14 +2014,18 @@ static char *VertstatHelp[] = {
     "              For every gridpoint the layer weighted mean over all levels is computed.",
     "    vertavg   Vertical average",
     "              For every gridpoint the layer weighted average over all levels is computed.",
-    "    vertvar   Vertical variance",
-    "              For every gridpoint the variance over all levels is computed.",
     "    vertstd   Vertical standard deviation",
-    "              For every gridpoint the standard deviation over all levels is computed.",
+    "              For every gridpoint the standard deviation over all levels is computed. Divisor is n.",
+    "    vertstd1  Vertical standard deviation",
+    "              For every gridpoint the standard deviation over all levels is computed. Divisor is (n-1).",
+    "    vertvar   Vertical variance",
+    "              For every gridpoint the variance over all levels is computed. Divisor is n.",
+    "    vertvar1  Vertical variance",
+    "              For every gridpoint the variance over all levels is computed. Divisor is (n-1).",
     NULL
 };
 
-static char *TimselstatHelp[] = {
+static const char *TimselstatHelp[] = {
     "NAME",
     "    timselmin, timselmax, timselsum, timselmean, timselavg, timselstd, ",
     "    timselstd1, timselvar, timselvar1 - Time range statistical values",
@@ -2055,7 +2093,7 @@ static char *TimselstatHelp[] = {
     NULL
 };
 
-static char *TimselpctlHelp[] = {
+static const char *TimselpctlHelp[] = {
     "NAME",
     "    timselpctl - Time range percentile values",
     "",
@@ -2086,7 +2124,7 @@ static char *TimselpctlHelp[] = {
     NULL
 };
 
-static char *RunstatHelp[] = {
+static const char *RunstatHelp[] = {
     "NAME",
     "    runmin, runmax, runsum, runmean, runavg, runstd, runstd1, runvar, runvar1 - ",
     "    Running statistical values",
@@ -2137,7 +2175,7 @@ static char *RunstatHelp[] = {
     NULL
 };
 
-static char *RunpctlHelp[] = {
+static const char *RunpctlHelp[] = {
     "NAME",
     "    runpctl - Running percentile values",
     "",
@@ -2156,7 +2194,7 @@ static char *RunpctlHelp[] = {
     NULL
 };
 
-static char *TimstatHelp[] = {
+static const char *TimstatHelp[] = {
     "NAME",
     "    timmin, timmax, timsum, timmean, timavg, timstd, timstd1, timvar, timvar1 - ",
     "    Statistical values over all timesteps",
@@ -2200,7 +2238,7 @@ static char *TimstatHelp[] = {
     NULL
 };
 
-static char *TimpctlHelp[] = {
+static const char *TimpctlHelp[] = {
     "NAME",
     "    timpctl - Percentile values over all timesteps",
     "",
@@ -2226,7 +2264,7 @@ static char *TimpctlHelp[] = {
     NULL
 };
 
-static char *HourstatHelp[] = {
+static const char *HourstatHelp[] = {
     "NAME",
     "    hourmin, hourmax, hoursum, hourmean, houravg, hourstd, hourstd1, hourvar, ",
     "    hourvar1 - Hourly statistical values",
@@ -2280,7 +2318,7 @@ static char *HourstatHelp[] = {
     NULL
 };
 
-static char *HourpctlHelp[] = {
+static const char *HourpctlHelp[] = {
     "NAME",
     "    hourpctl - Hourly percentile values",
     "",
@@ -2309,7 +2347,7 @@ static char *HourpctlHelp[] = {
     NULL
 };
 
-static char *DaystatHelp[] = {
+static const char *DaystatHelp[] = {
     "NAME",
     "    daymin, daymax, daysum, daymean, dayavg, daystd, daystd1, dayvar, dayvar1 - ",
     "    Daily statistical values",
@@ -2363,7 +2401,7 @@ static char *DaystatHelp[] = {
     NULL
 };
 
-static char *DaypctlHelp[] = {
+static const char *DaypctlHelp[] = {
     "NAME",
     "    daypctl - Daily percentile values",
     "",
@@ -2392,7 +2430,7 @@ static char *DaypctlHelp[] = {
     NULL
 };
 
-static char *MonstatHelp[] = {
+static const char *MonstatHelp[] = {
     "NAME",
     "    monmin, monmax, monsum, monmean, monavg, monstd, monstd1, monvar, monvar1 - ",
     "    Monthly statistical values",
@@ -2446,7 +2484,7 @@ static char *MonstatHelp[] = {
     NULL
 };
 
-static char *MonpctlHelp[] = {
+static const char *MonpctlHelp[] = {
     "NAME",
     "    monpctl - Monthly percentile values",
     "",
@@ -2475,7 +2513,7 @@ static char *MonpctlHelp[] = {
     NULL
 };
 
-static char *YearmonmeanHelp[] = {
+static const char *YearmonstatHelp[] = {
     "NAME",
     "    yearmonmean - Yearly mean from monthly data",
     "",
@@ -2497,7 +2535,7 @@ static char *YearmonmeanHelp[] = {
     NULL
 };
 
-static char *YearstatHelp[] = {
+static const char *YearstatHelp[] = {
     "NAME",
     "    yearmin, yearmax, yearsum, yearmean, yearavg, yearstd, yearstd1, yearvar, ",
     "    yearvar1 - Yearly statistical values",
@@ -2554,7 +2592,7 @@ static char *YearstatHelp[] = {
     NULL
 };
 
-static char *YearpctlHelp[] = {
+static const char *YearpctlHelp[] = {
     "NAME",
     "    yearpctl - Yearly percentile values",
     "",
@@ -2583,10 +2621,10 @@ static char *YearpctlHelp[] = {
     NULL
 };
 
-static char *SeasstatHelp[] = {
+static const char *SeasstatHelp[] = {
     "NAME",
-    "    seasmin, seasmax, seassum, seasmean, seasavg, seasvar, seasstd - ",
-    "    Seasonal statistical values",
+    "    seasmin, seasmax, seassum, seasmean, seasavg, seasstd, seasstd1, seasvar, ",
+    "    seasvar1 - Seasonal statistical values",
     "",
     "SYNOPSIS",
     "    <operator>  ifile ofile",
@@ -2620,18 +2658,26 @@ static char *SeasstatHelp[] = {
     "              For every adjacent sequence t_1, ...,t_n of timesteps of the same season it is",
     "              ",
     "              o(t,x) = avg{i(t',x), t1 < t' <= tn}",
+    "    seasstd   Seasonal standard deviation",
+    "              Divisor is n. For every adjacent sequence t_1, ...,t_n of timesteps of the same season it is",
+    "              ",
+    "              o(t,x) = std{i(t',x), t1 < t' <= tn}",
+    "    seasstd1  Seasonal standard deviation",
+    "              Divisor is (n-1). For every adjacent sequence t_1, ...,t_n of timesteps of the same season it is",
+    "              ",
+    "              o(t,x) = std1{i(t',x), t1 < t' <= tn}",
     "    seasvar   Seasonal variance",
-    "              For every adjacent sequence t_1, ...,t_n of timesteps of the same season it is",
+    "              Divisor is n. For every adjacent sequence t_1, ...,t_n of timesteps of the same season it is",
     "              ",
     "              o(t,x) = var{i(t',x), t1 < t' <= tn}",
-    "    seasstd   Seasonal standard deviation",
-    "              For every adjacent sequence t_1, ...,t_n of timesteps of the same season it is",
+    "    seasvar1  Seasonal variance",
+    "              Divisor is (n-1). For every adjacent sequence t_1, ...,t_n of timesteps of the same season it is",
     "              ",
-    "              o(t,x) = std{i(t',x), t1 < t' <= tn}",
+    "              o(t,x) = var1{i(t',x), t1 < t' <= tn}",
     NULL
 };
 
-static char *SeaspctlHelp[] = {
+static const char *SeaspctlHelp[] = {
     "NAME",
     "    seaspctl - Seasonal percentile values",
     "",
@@ -2660,7 +2706,7 @@ static char *SeaspctlHelp[] = {
     NULL
 };
 
-static char *YhourstatHelp[] = {
+static const char *YhourstatHelp[] = {
     "NAME",
     "    yhourmin, yhourmax, yhoursum, yhourmean, yhouravg, yhourstd, yhourstd1, ",
     "    yhourvar, yhourvar1 - Multi-year hourly statistical values",
@@ -2722,7 +2768,7 @@ static char *YhourstatHelp[] = {
     NULL
 };
 
-static char *YdaystatHelp[] = {
+static const char *YdaystatHelp[] = {
     "NAME",
     "    ydaymin, ydaymax, ydaysum, ydaymean, ydayavg, ydaystd, ydaystd1, ydayvar, ",
     "    ydayvar1 - Multi-year daily statistical values",
@@ -2784,7 +2830,7 @@ static char *YdaystatHelp[] = {
     NULL
 };
 
-static char *YdaypctlHelp[] = {
+static const char *YdaypctlHelp[] = {
     "NAME",
     "    ydaypctl - Multi-year daily percentile values",
     "",
@@ -2813,7 +2859,7 @@ static char *YdaypctlHelp[] = {
     NULL
 };
 
-static char *YmonstatHelp[] = {
+static const char *YmonstatHelp[] = {
     "NAME",
     "    ymonmin, ymonmax, ymonsum, ymonmean, ymonavg, ymonstd, ymonstd1, ymonvar, ",
     "    ymonvar1 - Multi-year monthly statistical values",
@@ -2875,7 +2921,7 @@ static char *YmonstatHelp[] = {
     NULL
 };
 
-static char *YmonpctlHelp[] = {
+static const char *YmonpctlHelp[] = {
     "NAME",
     "    ymonpctl - Multi-year monthly percentile values",
     "",
@@ -2906,10 +2952,10 @@ static char *YmonpctlHelp[] = {
     NULL
 };
 
-static char *YseasstatHelp[] = {
+static const char *YseasstatHelp[] = {
     "NAME",
-    "    yseasmin, yseasmax, yseassum, yseasmean, yseasavg, yseasvar, yseasstd - ",
-    "    Multi-year seasonal statistical values",
+    "    yseasmin, yseasmax, yseassum, yseasmean, yseasavg, yseasstd, yseasstd1, ",
+    "    yseasvar, yseasvar1 - Multi-year seasonal statistical values",
     "",
     "SYNOPSIS",
     "    <operator>  ifile ofile",
@@ -2946,20 +2992,30 @@ static char *YseasstatHelp[] = {
     "               o(2,x) = avg{i(t,x), month(i(t)) = 03, 04, 05}",
     "               o(3,x) = avg{i(t,x), month(i(t)) = 06, 07, 08}",
     "               o(4,x) = avg{i(t,x), month(i(t)) = 09, 10, 11}",
-    "    yseasvar   Multi-year seasonal variance",
-    "               o(1,x) = var{i(t,x), month(i(t)) = 12, 01, 02}",
-    "               o(2,x) = var{i(t,x), month(i(t)) = 03, 04, 05}",
-    "               o(3,x) = var{i(t,x), month(i(t)) = 06, 07, 08}",
-    "               o(4,x) = var{i(t,x), month(i(t)) = 09, 10, 11}",
     "    yseasstd   Multi-year seasonal standard deviation",
     "               o(1,x) = std{i(t,x), month(i(t)) = 12, 01, 02}",
     "               o(2,x) = std{i(t,x), month(i(t)) = 03, 04, 05}",
     "               o(3,x) = std{i(t,x), month(i(t)) = 06, 07, 08}",
     "               o(4,x) = std{i(t,x), month(i(t)) = 09, 10, 11}",
+    "    yseasstd1  Multi-year seasonal standard deviation",
+    "               o(1,x) = std1{i(t,x), month(i(t)) = 12, 01, 02}",
+    "               o(2,x) = std1{i(t,x), month(i(t)) = 03, 04, 05}",
+    "               o(3,x) = std1{i(t,x), month(i(t)) = 06, 07, 08}",
+    "               o(4,x) = std1{i(t,x), month(i(t)) = 09, 10, 11}",
+    "    yseasvar   Multi-year seasonal variance",
+    "               o(1,x) = var{i(t,x), month(i(t)) = 12, 01, 02}",
+    "               o(2,x) = var{i(t,x), month(i(t)) = 03, 04, 05}",
+    "               o(3,x) = var{i(t,x), month(i(t)) = 06, 07, 08}",
+    "               o(4,x) = var{i(t,x), month(i(t)) = 09, 10, 11}",
+    "    yseasvar1  Multi-year seasonal variance",
+    "               o(1,x) = var1{i(t,x), month(i(t)) = 12, 01, 02}",
+    "               o(2,x) = var1{i(t,x), month(i(t)) = 03, 04, 05}",
+    "               o(3,x) = var1{i(t,x), month(i(t)) = 06, 07, 08}",
+    "               o(4,x) = var1{i(t,x), month(i(t)) = 09, 10, 11}",
     NULL
 };
 
-static char *YseaspctlHelp[] = {
+static const char *YseaspctlHelp[] = {
     "NAME",
     "    yseaspctl - Multi-year seasonal percentile values",
     "",
@@ -2991,7 +3047,7 @@ static char *YseaspctlHelp[] = {
     NULL
 };
 
-static char *YdrunstatHelp[] = {
+static const char *YdrunstatHelp[] = {
     "NAME",
     "    ydrunmin, ydrunmax, ydrunsum, ydrunmean, ydrunavg, ydrunstd, ydrunstd1, ",
     "    ydrunvar, ydrunvar1 - Multi-year daily running statistical values",
@@ -3063,7 +3119,7 @@ static char *YdrunstatHelp[] = {
     NULL
 };
 
-static char *YdrunpctlHelp[] = {
+static const char *YdrunpctlHelp[] = {
     "NAME",
     "    ydrunpctl - Multi-year daily running percentile values",
     "",
@@ -3103,7 +3159,7 @@ static char *YdrunpctlHelp[] = {
     NULL
 };
 
-static char *FldcorHelp[] = {
+static const char *FldcorHelp[] = {
     "NAME",
     "    fldcor - Correlation in grid space",
     "",
@@ -3125,7 +3181,7 @@ static char *FldcorHelp[] = {
     NULL
 };
 
-static char *TimcorHelp[] = {
+static const char *TimcorHelp[] = {
     "NAME",
     "    timcor - Correlation over time",
     "",
@@ -3146,7 +3202,7 @@ static char *TimcorHelp[] = {
     NULL
 };
 
-static char *FldcovarHelp[] = {
+static const char *FldcovarHelp[] = {
     "NAME",
     "    fldcovar - Covariance in grid space",
     "",
@@ -3167,7 +3223,7 @@ static char *FldcovarHelp[] = {
     NULL
 };
 
-static char *TimcovarHelp[] = {
+static const char *TimcovarHelp[] = {
     "NAME",
     "    timcovar - Covariance over time",
     "",
@@ -3187,7 +3243,7 @@ static char *TimcovarHelp[] = {
     NULL
 };
 
-static char *RegresHelp[] = {
+static const char *RegresHelp[] = {
     "NAME",
     "    regres - Regression",
     "",
@@ -3202,7 +3258,7 @@ static char *RegresHelp[] = {
     NULL
 };
 
-static char *DetrendHelp[] = {
+static const char *DetrendHelp[] = {
     "NAME",
     "    detrend - Detrend time series",
     "",
@@ -3219,7 +3275,7 @@ static char *DetrendHelp[] = {
     NULL
 };
 
-static char *TrendHelp[] = {
+static const char *TrendHelp[] = {
     "NAME",
     "    trend - Trend of time series",
     "",
@@ -3236,7 +3292,7 @@ static char *TrendHelp[] = {
     NULL
 };
 
-static char *SubtrendHelp[] = {
+static const char *SubtrendHelp[] = {
     "NAME",
     "    subtrend - Subtract a trend",
     "",
@@ -3252,7 +3308,7 @@ static char *SubtrendHelp[] = {
     NULL
 };
 
-static char *EOFsHelp[] = {
+static const char *EOFsHelp[] = {
     "NAME",
     "    eof, eoftime, eofspatial, eof3d - Empirical Orthogonal Functions",
     "",
@@ -3310,7 +3366,7 @@ static char *EOFsHelp[] = {
     NULL
 };
 
-static char *EofcoeffHelp[] = {
+static const char *EofcoeffHelp[] = {
     "NAME",
     "    eofcoeff - Principal coefficients of EOFs",
     "",
@@ -3337,178 +3393,336 @@ static char *EofcoeffHelp[] = {
     NULL
 };
 
-static char *RemapgridHelp[] = {
+static const char *RemapbilHelp[] = {
     "NAME",
-    "    remapbil, remapbic, remapdis, remapnn, remapcon, remapcon2, remaplaf - ",
-    "    SCRIP grid interpolation",
+    "    remapbil, genbil - Bilinear interpolation",
     "",
     "SYNOPSIS",
     "    <operator>,grid  ifile ofile",
     "",
     "DESCRIPTION",
-    "    This module contains operators to remap all input fields to a new horizontal grid.",
-    "    Each operator uses a different remapping method. The interpolation is based",
-    "    on an adapted SCRIP library version. For a detailed description of the remapping ",
-    "    methods see SCRIP.",
+    "    This module contains operators for a bilinear remapping of fields between grids in spherical coordinates.",
+    "    The interpolation is based on an adapted SCRIP library version. ",
+    "    For a detailed description of the interpolation method see SCRIP.",
+    "    This interpolation method only works on quadrilateral curvilinear source grids.",
+    "",
+    "OPERATORS",
+    "    remapbil  Bilinear interpolation",
+    "              Performs a bilinear interpolation on all input fields.",
+    "    genbil    Generate bilinear interpolation weights",
+    "              Generates bilinear interpolation weights for the first input field and writes the",
+    "              result to a file. The format of this file is netCDF following the SCRIP convention.",
+    "              Use the operator remap to apply this remapping weights to a data file with the same source grid.",
+    "",
+    "PARAMETER",
+    "    grid  STRING  Target grid description file or name",
+    "",
+    "ENVIRONMENT",
+    "    REMAP_EXTRAPOLATE",
+    "        This variable is used to switch the extrapolation feature 'on' or 'off'.",
+    "        By default the extrapolation is enabled for circular grids.",
+    NULL
+};
+
+static const char *RemapbicHelp[] = {
+    "NAME",
+    "    remapbic, genbic - Bicubic interpolation",
+    "",
+    "SYNOPSIS",
+    "    <operator>,grid  ifile ofile",
+    "",
+    "DESCRIPTION",
+    "    This module contains operators for a bicubic remapping of fields between grids in spherical coordinates.",
+    "    The interpolation is based on an adapted SCRIP library version. ",
+    "    For a detailed description of the interpolation method see SCRIP.",
+    "    This interpolation method only works on quadrilateral curvilinear source grids.",
+    "",
+    "OPERATORS",
+    "    remapbic  Bicubic interpolation",
+    "              Performs a bicubic interpolation on all input fields.",
+    "    genbic    Generate bicubic interpolation weights",
+    "              Generates bicubic interpolation weights for the first input field and writes the",
+    "              result to a file. The format of this file is netCDF following the SCRIP convention.",
+    "              Use the operator remap to apply this remapping weights to a data file with the same source grid.",
+    "",
+    "PARAMETER",
+    "    grid  STRING  Target grid description file or name",
+    "",
+    "ENVIRONMENT",
+    "    REMAP_EXTRAPOLATE",
+    "        This variable is used to switch the extrapolation feature 'on' or 'off'.",
+    "        By default the extrapolation is enabled for circular grids.",
+    NULL
+};
+
+static const char *RemapnnHelp[] = {
+    "NAME",
+    "    remapnn, gennn - Nearest neighbor remapping",
+    "",
+    "SYNOPSIS",
+    "    <operator>,grid  ifile ofile",
+    "",
+    "DESCRIPTION",
+    "    This module contains operators for a nearest neighbor remapping of fields between grids",
+    "    in spherical coordinates.",
+    "",
+    "OPERATORS",
+    "    remapnn  Nearest neighbor remapping",
+    "             Performs a nearest neighbor remapping on all input fields.",
+    "    gennn    Generate nearest neighbor remap weights",
+    "             Generates nearest neighbor remapping weights for the first input field and writes the result to a file.",
+    "             The format of this file is netCDF following the SCRIP convention.",
+    "             Use the operator remap to apply this remapping weights to a data file with the same source grid.",
+    "",
+    "PARAMETER",
+    "    grid  STRING  Target grid description file or name",
+    "",
+    "ENVIRONMENT",
+    "    REMAP_EXTRAPOLATE    ",
+    "        This variable is used to switch the extrapolation feature 'on' or 'off'.",
+    "        By default the extrapolation is enabled for this remapping method.",
+    "    CDO_GRIDSEARCH_RADIUS",
+    "        Grid search radius in degree, default 180 degree.",
+    NULL
+};
+
+static const char *RemapdisHelp[] = {
+    "NAME",
+    "    remapdis, gendis - Distance-weighted average remapping",
+    "",
+    "SYNOPSIS",
+    "    remapdis,grid[,neighbors]  ifile ofile",
+    "    gendis,grid  ifile ofile",
+    "",
+    "DESCRIPTION",
+    "    This module contains operators for a distance-weighted average remapping of the four",
+    "    nearest neighbor values of fields between grids in spherical coordinates.",
+    "    The interpolation is based on an adapted SCRIP library version. ",
+    "    For a detailed description of the interpolation method see SCRIP.",
+    "",
+    "OPERATORS",
+    "    remapdis  Distance-weighted average remapping",
+    "              Performs a distance-weighted average remapping of the nearest neighbors value on all input fields.",
+    "              The default number of nearest neighbors is 4.",
+    "    gendis    Generate distance-weighted average remap weights",
+    "              Generates distance-weighted average remapping weights of the four nearest neighbor",
+    "              values for the first input field and writes the result to a file.",
+    "              The format of this file is netCDF following the SCRIP convention.",
+    "              Use the operator remap to apply this remapping weights to a data file with the same source grid.",
+    "",
+    "PARAMETER",
+    "    grid       STRING   Target grid description file or name",
+    "    neighbors  INTEGER  Number of nearest neighbors",
+    "",
+    "ENVIRONMENT",
+    "    REMAP_EXTRAPOLATE    ",
+    "        This variable is used to switch the extrapolation feature 'on' or 'off'.",
+    "        By default the extrapolation is enabled for this remapping method.",
+    "    CDO_GRIDSEARCH_RADIUS",
+    "        Grid search radius in degree, default 180 degree.",
+    NULL
+};
+
+static const char *RemapyconHelp[] = {
+    "NAME",
+    "    remapycon, genycon - First order conservative remapping",
+    "",
+    "SYNOPSIS",
+    "    <operator>,grid  ifile ofile",
+    "",
+    "DESCRIPTION",
+    "    This module contains operators for a first order conservative remapping of fields between grids in spherical coordinates.",
+    "    The operators in this module uses code from the YAC software package to compute the conservative remapping weights.",
+    "    For a detailed description of the interpolation method see YAC.",
+    "    The interpolation method is completely general and can be used for any grid on a sphere.",
     "    The search algorithm for the conservative remapping requires that no grid cell occurs more than once. ",
     "",
     "OPERATORS",
-    "    remapbil   Bilinear interpolation",
-    "               Performs a bilinear interpolation on all input fields.",
-    "               This interpolation method only works on quadrilateral curvilinear grids.",
-    "    remapbic   Bicubic interpolation",
-    "               Performs a bicubic interpolation on all input fields.",
-    "               This interpolation method only works on quadrilateral curvilinear grids.",
-    "    remapdis   Distance-weighted average remapping",
-    "               Performs a distance-weighted average remapping of the four nearest neighbor ",
-    "               values on all input fields.",
-    "    remapnn    Nearest neighbor remapping",
-    "               Performs a nearest neighbor remapping on all input fields.",
-    "    remapcon   First order conservative remapping",
+    "    remapycon  First order conservative remapping",
     "               Performs a first order conservative remapping on all input fields.",
-    "    remapcon2  Second order conservative remapping",
-    "               Performs a second order conservative remapping on all input fields.",
-    "    remaplaf   Largest area fraction remapping",
-    "               Performs a largest area fraction remapping on all input fields.",
+    "    genycon    Generate 1st order conservative remap weights",
+    "               Generates first order conservative remapping weights for the first input field and",
+    "               writes the result to a file. The format of this file is netCDF following the SCRIP convention.",
+    "               Use the operator remap to apply this remapping weights to a data file with the same source grid.",
     "",
     "PARAMETER",
     "    grid  STRING  Target grid description file or name",
     "",
     "ENVIRONMENT",
-    "    CDO_REMAP_NORM   ",
+    "    CDO_REMAP_NORM",
     "        This variable is used to choose the normalization of the conservative interpolation. ",
-    "        By default @env{CDO_REMAP_NORM} is set to 'fracarea'. 'fracarea' uses the sum of the",
+    "        By default CDO_REMAP_NORM is set to 'fracarea'. 'fracarea' uses the sum of the",
     "        non-masked source cell intersected areas to normalize each target cell field value.",
     "        This results in a reasonable flux value but the flux is not locally conserved.",
     "        The option 'destarea' uses the total target cell area to normalize each target cell",
     "        field value. Local flux conservation is ensured, but unreasonable flux values may result.",
-    "    REMAP_EXTRAPOLATE",
-    "        This variable is used to switch the extrapolation feature 'on' or 'off'.",
-    "        By default the extrapolation is enabled for remapdis, remapnn and for circular grids.",
-    "    REMAP_AREA_MIN   ",
+    "    REMAP_AREA_MIN",
+    "        This variable is used to set the minimum destination area fraction. The default",
+    "        of this variable is 0.0.",
+    NULL
+};
+
+static const char *RemapconHelp[] = {
+    "NAME",
+    "    remapcon, gencon - First order conservative remapping",
+    "",
+    "SYNOPSIS",
+    "    <operator>,grid  ifile ofile",
+    "",
+    "DESCRIPTION",
+    "    This module contains operators for a first order conservative remapping of fields between grids in spherical coordinates.",
+    "    The interpolation is based on an adapted SCRIP library version. ",
+    "    For a detailed description of the interpolation method see SCRIP.",
+    "    The interpolation method is completely general and can be used for any grid on a sphere.",
+    "    The search algorithm for the conservative remapping requires that no grid cell occurs more than once. ",
+    "",
+    "OPERATORS",
+    "    remapcon  First order conservative remapping",
+    "              Performs a first order conservative remapping on all input fields.",
+    "    gencon    Generate 1st order conservative remap weights",
+    "              Generates first order conservative remapping weights for the first input field and",
+    "              writes the result to a file. The format of this file is netCDF following the SCRIP convention.",
+    "              Use the operator remap to apply this remapping weights to a data file with the same source grid.",
+    "",
+    "PARAMETER",
+    "    grid  STRING  Target grid description file or name",
+    "",
+    "ENVIRONMENT",
+    "    CDO_REMAP_NORM",
+    "        This variable is used to choose the normalization of the conservative interpolation. ",
+    "        By default CDO_REMAP_NORM is set to 'fracarea'. 'fracarea' uses the sum of the",
+    "        non-masked source cell intersected areas to normalize each target cell field value.",
+    "        This results in a reasonable flux value but the flux is not locally conserved.",
+    "        The option 'destarea' uses the total target cell area to normalize each target cell",
+    "        field value. Local flux conservation is ensured, but unreasonable flux values may result.",
+    "    REMAP_AREA_MIN",
     "        This variable is used to set the minimum destination area fraction. The default",
     "        of this variable is 0.0.",
-    "    CDO_REMAP_RADIUS ",
-    "        Remap search radius in degree, default 180 degree.",
     "",
     "NOTE",
-    "    For this module the author has converted the original Fortran 90 SCRIP ",
-    "    software to ANSI C99. If there are any problems send a bug report to CDO and",
-    "    not to SCRIP!",
+    "    The SCRIP conservative remapping method doesn't work correctly for some grid combinations.",
+    "    Please use remapycon or genycon in case of problems. ",
     NULL
 };
 
-static char *GenweightsHelp[] = {
+static const char *Remapcon2Help[] = {
     "NAME",
-    "    genbil, genbic, gendis, gennn, gencon, gencon2, genlaf - ",
-    "    Generate SCRIP grid interpolation weights",
+    "    remapcon2, gencon2 - Second order conservative remapping",
     "",
     "SYNOPSIS",
-    "    <operator>,grid  ifile ofile",
+    "    remapcon2,grid  ifile ofile",
+    "    gencon2,grid2  ifile ofile",
     "",
     "DESCRIPTION",
-    "    Interpolation between different horizontal grids can be a very time-consuming ",
-    "    process. Especially if the data are on an unstructured or a large grid. ",
-    "    In this case the SCRIP interpolation process can be split ",
-    "    into two parts. Firstly the generation of the interpolation weights, which is ",
-    "    the most time-consuming part. These interpolation weights can be reused for ",
-    "    every remapping process with the operator remap. This method should be ",
-    "    used only if all input fields are on the same grid and a possibly",
-    "    mask (missing values) does not change. This module contains operators to ",
-    "    generate SCRIP interpolation weights of the first input field.",
-    "    Each operator is using a different interpolation method.",
+    "    This module contains operators for a second order conservative remapping of fields between grids in spherical coordinates.",
+    "    The interpolation is based on an adapted SCRIP library version. ",
+    "    For a detailed description of the interpolation method see SCRIP.",
+    "    The interpolation method is completely general and can be used for any grid on a sphere.",
+    "    The search algorithm for the conservative remapping requires that no grid cell occurs more than once. ",
     "",
     "OPERATORS",
-    "    genbil   Generate bilinear interpolation weights",
-    "             Generates bilinear interpolation weights and writes the result to a file. ",
-    "             This interpolation method only works on quadrilateral curvilinear grids.",
-    "    genbic   Generate bicubic interpolation weights",
-    "             Generates bicubic interpolation weights and writes the result to a file.",
-    "             This interpolation method only works on quadrilateral curvilinear grids.",
-    "    gendis   Generate distance-weighted average remap weights",
-    "             Generates distance-weighted average remapping weights of the four",
-    "             nearest neighbor values and writes the result to a file.",
-    "    gennn    Generate nearest neighbor remap weights",
-    "             Generates nearest neighbor remapping weights and writes the result to a file.",
-    "    gencon   Generate 1st order conservative remap weights",
-    "             Generates first order conservative remapping weights and",
-    "             writes the result to a file.",
-    "    gencon2  Generate 2nd order conservative remap weights",
-    "             Generates second order conservative remapping weights and",
-    "             writes the result to a file.",
-    "    genlaf   Generate largest area fraction remap weights",
-    "             Generates largest area fraction remapping weights and",
-    "             writes the result to a file.",
+    "    remapcon2  Second order conservative remapping",
+    "               Performs a second order conservative remapping on all input fields.",
+    "    gencon2    Generate 2nd order conservative remap weights",
+    "               Generates second order conservative remapping weights for the first input field and",
+    "               writes the result to a file. The format of this file is netCDF following the SCRIP convention.",
+    "               Use the operator remap to apply this remapping weights to a data file with the same source grid.",
     "",
     "PARAMETER",
     "    grid  STRING  Target grid description file or name",
     "",
     "ENVIRONMENT",
-    "    CDO_REMAP_NORM   ",
+    "    CDO_REMAP_NORM",
     "        This variable is used to choose the normalization of the conservative interpolation. ",
-    "        By default @env{CDO_REMAP_NORM} is set to 'fracarea'. 'fracarea' uses the sum of the",
+    "        By default CDO_REMAP_NORM is set to 'fracarea'. 'fracarea' uses the sum of the",
     "        non-masked source cell intersected areas to normalize each target cell field value.",
     "        This results in a reasonable flux value but the flux is not locally conserved.",
     "        The option 'destarea' uses the total target cell area to normalize each target cell",
     "        field value. Local flux conservation is ensured, but unreasonable flux values may result.",
-    "    REMAP_EXTRAPOLATE",
-    "        This variable is used to switch the extrapolation feature 'on' or 'off'.",
-    "        By default the extrapolation is enabled for remapdis, remapnn",
-    "        and for circular grids.",
-    "    REMAP_AREA_MIN   ",
+    "    REMAP_AREA_MIN",
     "        This variable is used to set the minimum destination area fraction. The default",
     "        of this variable is 0.0.",
-    "    CDO_REMAP_RADIUS ",
-    "        Remap search radius in degree, default 180 degree.",
     "",
     "NOTE",
-    "    For this module the author has converted the original Fortran 90 SCRIP software to ",
-    "    ANSI C99. If there are any problems send a bug report to CDO and not to SCRIP!",
+    "    The SCRIP conservative remapping method doesn't work correctly for some grid combinations.",
+    NULL
+};
+
+static const char *RemaplafHelp[] = {
+    "NAME",
+    "    remaplaf, genlaf - Largest area fraction remapping",
+    "",
+    "SYNOPSIS",
+    "    <operator>,grid  ifile ofile",
+    "",
+    "DESCRIPTION",
+    "    This module contains operators for a largest area fraction remapping of fields between grids in spherical coordinates.",
+    "    The operators in this module uses code from the YAC software package to compute the largest area fraction.",
+    "    For a detailed description of the interpolation method see YAC.",
+    "    The interpolation method is completely general and can be used for any grid on a sphere.",
+    "    The search algorithm for this remapping method requires that no grid cell occurs more than once. ",
+    "",
+    "OPERATORS",
+    "    remaplaf  Largest area fraction remapping",
+    "              Performs a largest area fraction remapping on all input fields.",
+    "    genlaf    Generate largest area fraction remap weights",
+    "              Generates largest area fraction remapping weights for the first input field and",
+    "              writes the result to a file. The format of this file is netCDF following the SCRIP convention.",
+    "              Use the operator remap to apply this remapping weights to a data file with the same source grid.",
+    "",
+    "PARAMETER",
+    "    grid  STRING  Target grid description file or name",
+    "",
+    "ENVIRONMENT",
+    "    REMAP_AREA_MIN",
+    "        This variable is used to set the minimum destination area fraction. The default",
+    "        of this variable is 0.0.",
     NULL
 };
 
-static char *RemapHelp[] = {
+static const char *RemapHelp[] = {
     "NAME",
-    "    remap - SCRIP grid remapping",
+    "    remap - Grid remapping",
     "",
     "SYNOPSIS",
     "    remap,grid,weights  ifile ofile",
     "",
     "DESCRIPTION",
+    "    Interpolation between different horizontal grids can be a very time-consuming ",
+    "    process. Especially if the data are on an unstructured and/or a large grid. ",
+    "    In this case the interpolation process can be split into two parts.",
+    "    Firstly the generation of the interpolation weights, which is the most time-consuming part.",
+    "    These interpolation weights can be reused for every remapping process with the operator remap.",
     "    This operator remaps all input fields to a new horizontal grid. The remap type and ",
     "    the interpolation weights of one input grid are read from a netCDF file. More weights ",
     "    are computed if the input fields are on different grids. The netCDF file with the ",
-    "    weights should follow the SCRIP convention. Normally these weights come from ",
-    "    a previous call to module GENWEIGHTS or were created by the original SCRIP package.",
+    "    weights should follow the SCRIP convention. Normally these weights come from a previous",
+    "    call to one of the genXXX operators (e.g. genbil) or were created by the original SCRIP package.",
     "",
     "PARAMETER",
     "    grid     STRING  Target grid description file or name",
     "    weights  STRING  Interpolation weights (SCRIP netCDF file)",
     "",
     "ENVIRONMENT",
-    "    CDO_REMAP_NORM   ",
+    "    CDO_REMAP_NORM       ",
     "        This variable is used to choose the normalization of the conservative interpolation. ",
-    "        By default @env{CDO_REMAP_NORM} is set to 'fracarea'. 'fracarea' uses the sum of the",
+    "        By default CDO_REMAP_NORM is set to 'fracarea'. 'fracarea' uses the sum of the",
     "        non-masked source cell intersected areas to normalize each target cell field value.",
     "        This results in a reasonable flux value but the flux is not locally conserved.",
     "        The option 'destarea' uses the total target cell area to normalize each target cell",
     "        field value. Local flux conservation is ensured, but unreasonable flux values may result.",
-    "    REMAP_EXTRAPOLATE",
+    "    REMAP_EXTRAPOLATE    ",
     "        This variable is used to switch the extrapolation feature 'on' or 'off'.",
     "        By default the extrapolation is enabled for remapdis, remapnn and for circular grids.",
-    "    REMAP_AREA_MIN   ",
+    "    REMAP_AREA_MIN       ",
     "        This variable is used to set the minimum destination area fraction. The default",
     "        of this variable is 0.0.",
-    "    CDO_REMAP_RADIUS ",
-    "        Remap search radius in degree, default 180 degree.",
-    "",
-    "NOTE",
-    "    For this module the author has converted the original Fortran 90 SCRIP software to",
-    "    ANSI C99. If there are any problems send a bug report to CDO and not to SCRIP!",
+    "    CDO_GRIDSEARCH_RADIUS",
+    "        Grid search radius in degree, default 180 degree.",
     NULL
 };
 
-static char *RemapetaHelp[] = {
+static const char *RemapetaHelp[] = {
     "NAME",
     "    remapeta - Remap vertical hybrid level",
     "",
@@ -3567,7 +3781,7 @@ static char *RemapetaHelp[] = {
     NULL
 };
 
-static char *IntvertHelp[] = {
+static const char *VertintmlHelp[] = {
     "NAME",
     "    ml2pl, ml2hl - Vertical interpolation",
     "",
@@ -3576,7 +3790,7 @@ static char *IntvertHelp[] = {
     "    ml2hl,hlevels  ifile ofile",
     "",
     "DESCRIPTION",
-    "    Interpolate 3D variables on hybrid model levels to pressure or height levels.",
+    "    Interpolate 3D variables on hybrid sigma pressure level to pressure or height levels.",
     "    The input file should contain the log. surface pressure or the surface pressure.",
     "    To interpolate the temperature, the surface geopotential is also needed.",
     "    The pressure, temperature, and surface geopotential are identified by their GRIB1 code number",
@@ -3588,9 +3802,9 @@ static char *IntvertHelp[] = {
     "",
     "OPERATORS",
     "    ml2pl  Model to pressure level interpolation",
-    "           Interpolates 3D variables on hybrid model levels to pressure levels.",
+    "           Interpolates 3D variables on hybrid sigma pressure level to pressure level.",
     "    ml2hl  Model to height level interpolation",
-    "           Interpolates 3D variables on hybrid model levels to height levels.",
+    "           Interpolates 3D variables on hybrid sigma pressure level to height level.",
     "           The procedure is the same as for the operator mh2pl except for",
     "           the pressure levels being calculated from the heights by:",
     "           plevel = 101325*exp(hlevel/-7000)",
@@ -3602,26 +3816,31 @@ static char *IntvertHelp[] = {
     "ENVIRONMENT",
     "    EXTRAPOLATE",
     "        If set to 1 extrapolate missing values.",
+    NULL
+};
+
+static const char *VertintapHelp[] = {
+    "NAME",
+    "    ap2pl - Vertical interpolation",
+    "",
+    "SYNOPSIS",
+    "    ap2pl,plevels  ifile ofile",
+    "",
+    "DESCRIPTION",
+    "    Interpolate 3D variables on hybrid sigma height coordinates to pressure levels.",
+    "    The input file must contain the 3D air pressure. The air pressure is identified",
+    "    by the netCDF CF standard name air_pressure.",
+    "    This operator requires all variables on the same horizontal grid.",
+    "",
+    "PARAMETER",
+    "    plevels  FLOAT  Pressure levels in pascal",
     "",
     "NOTE",
-    "    The netCDF CF convention for vertical hybrid coordinates is not supported, yet!",
-    "    The vertical coordinate definition of a netCDF file has to follow the ECHAM convention.",
-    "    This means:",
-    "    - the dimension of the full level coordinate and the corresponding variable is called mlev,",
-    "    - the dimension of the half level coordinate and the corresponding variable is called ilev (ilev must have one element more than mlev)",
-    "    - the hybrid vertical coefficient a is given in units of Pa and called hyai (hyam for level midpoints)",
-    "    - the hybrid vertical coefficient b is given in units of 1 and called hybi (hybm for level midpoints)",
-    "    - the mlev variable has a borders attribute containing the character string 'ilev'",
-    "    ",
-    "    Use the sinfo command to test if your vertical coordinate system is recognized as hybrid system.",
-    "    ",
-    "    In case this operator complains about not finding any data on hybrid model levels you may wish",
-    "    to use the setzaxis command to generate a zaxis description which conforms to the ECHAM convention.",
-    "    See section \"1.4 Z-axis description\" for an example how to define a hybrid Z-axis.",
+    "    This is a specific implementation for netCDF files from the ICON model, it may not work with data from other sources.",
     NULL
 };
 
-static char *IntlevelHelp[] = {
+static const char *IntlevelHelp[] = {
     "NAME",
     "    intlevel - Linear level interpolation",
     "",
@@ -3636,7 +3855,7 @@ static char *IntlevelHelp[] = {
     NULL
 };
 
-static char *Intlevel3dHelp[] = {
+static const char *Intlevel3dHelp[] = {
     "NAME",
     "    intlevel3d, intlevelx3d - ",
     "    Linear level interpolation from/to 3d vertical coordinates",
@@ -3658,7 +3877,7 @@ static char *Intlevel3dHelp[] = {
     NULL
 };
 
-static char *InttimeHelp[] = {
+static const char *InttimeHelp[] = {
     "NAME",
     "    inttime, intntime - Time interpolation",
     "",
@@ -3685,7 +3904,7 @@ static char *InttimeHelp[] = {
     NULL
 };
 
-static char *IntyearHelp[] = {
+static const char *IntyearHelp[] = {
     "NAME",
     "    intyear - Year interpolation",
     "",
@@ -3709,7 +3928,7 @@ static char *IntyearHelp[] = {
     NULL
 };
 
-static char *SpectralHelp[] = {
+static const char *SpectralHelp[] = {
     "NAME",
     "    sp2gp, sp2gpl, gp2sp, gp2spl, sp2sp - Spectral transformation",
     "",
@@ -3754,7 +3973,7 @@ static char *SpectralHelp[] = {
     NULL
 };
 
-static char *WindHelp[] = {
+static const char *WindHelp[] = {
     "NAME",
     "    dv2uv, dv2uvl, uv2dv, uv2dvl, dv2ps - Wind transformation",
     "",
@@ -3807,7 +4026,7 @@ static char *WindHelp[] = {
     NULL
 };
 
-static char *ImportbinaryHelp[] = {
+static const char *ImportbinaryHelp[] = {
     "NAME",
     "    import_binary - Import binary data sets",
     "",
@@ -3835,7 +4054,7 @@ static char *ImportbinaryHelp[] = {
     NULL
 };
 
-static char *ImportcmsafHelp[] = {
+static const char *ImportcmsafHelp[] = {
     "NAME",
     "    import_cmsaf - Import CM-SAF HDF5 files",
     "",
@@ -3884,7 +4103,7 @@ static char *ImportcmsafHelp[] = {
     NULL
 };
 
-static char *ImportamsrHelp[] = {
+static const char *ImportamsrHelp[] = {
     "NAME",
     "    import_amsr - Import AMSR binary files",
     "",
@@ -3904,7 +4123,7 @@ static char *ImportamsrHelp[] = {
     NULL
 };
 
-static char *InputHelp[] = {
+static const char *InputHelp[] = {
     "NAME",
     "    input, inputsrv, inputext - Formatted input",
     "",
@@ -3939,7 +4158,7 @@ static char *InputHelp[] = {
     NULL
 };
 
-static char *OutputHelp[] = {
+static const char *OutputHelp[] = {
     "NAME",
     "    output, outputf, outputint, outputsrv, outputext - Formatted output",
     "",
@@ -3979,7 +4198,7 @@ static char *OutputHelp[] = {
     NULL
 };
 
-static char *OutputtabHelp[] = {
+static const char *OutputtabHelp[] = {
     "NAME",
     "    outputtab - Table output",
     "",
@@ -4019,7 +4238,7 @@ static char *OutputtabHelp[] = {
     NULL
 };
 
-static char *GradsdesHelp[] = {
+static const char *GradsdesHelp[] = {
     "NAME",
     "    gradsdes - GrADS data descriptor file",
     "",
@@ -4042,7 +4261,7 @@ static char *GradsdesHelp[] = {
     NULL
 };
 
-static char *AfterburnerHelp[] = {
+static const char *AfterburnerHelp[] = {
     "NAME",
     "    after - ECHAM standard post processor",
     "",
@@ -4135,7 +4354,7 @@ static char *AfterburnerHelp[] = {
     NULL
 };
 
-static char *FilterHelp[] = {
+static const char *FilterHelp[] = {
     "NAME",
     "    bandpass, lowpass, highpass - Time series filtering",
     "",
@@ -4181,7 +4400,7 @@ static char *FilterHelp[] = {
     NULL
 };
 
-static char *GridcellHelp[] = {
+static const char *GridcellHelp[] = {
     "NAME",
     "    gridarea, gridweights - Grid cell quantities",
     "",
@@ -4208,7 +4427,7 @@ static char *GridcellHelp[] = {
     NULL
 };
 
-static char *Smooth9Help[] = {
+static const char *Smooth9Help[] = {
     "NAME",
     "    smooth9 - 9 point smoothing",
     "",
@@ -4229,7 +4448,7 @@ static char *Smooth9Help[] = {
     NULL
 };
 
-static char *ReplacevaluesHelp[] = {
+static const char *ReplacevaluesHelp[] = {
     "NAME",
     "    setvals, setrtoc, setrtoc2 - Replace variable values",
     "",
@@ -4262,7 +4481,7 @@ static char *ReplacevaluesHelp[] = {
     NULL
 };
 
-static char *TimsortHelp[] = {
+static const char *TimsortHelp[] = {
     "NAME",
     "    timsort - Timsort",
     "",
@@ -4277,24 +4496,30 @@ static char *TimsortHelp[] = {
     NULL
 };
 
-static char *VargenHelp[] = {
+static const char *VargenHelp[] = {
     "NAME",
-    "    const, random, stdatm - Generate a field",
+    "    const, random, topo, for, stdatm - Generate a field",
     "",
     "SYNOPSIS",
     "    const,const,grid  ofile",
     "    random,grid[,seed]  ofile",
+    "    topo[,grid]  ofile",
+    "    for,start,end[,inc]  ofile",
     "    stdatm,levels  ofile",
     "",
     "DESCRIPTION",
-    "    Generates a dataset with one or more fields. The field size is specified by the user given grid description.",
-    "    According to the chosen operator all field elements are constant or filled with random numbers.",
+    "    Generates a dataset with one or more fields",
     "",
     "OPERATORS",
     "    const   Create a constant field",
     "            Creates a constant field. All field elements of the grid have the same value.",
     "    random  Create a field with random numbers",
     "            Creates a field with rectangularly distrubuted random numbers in the interval [0,1].",
+    "    topo    Create a field with topography",
+    "            Creates a field with topography data, per default on a global half degree grid.",
+    "    for     Create a time series",
+    "            Creates a time series with field size 1 and field elements beginning with a start value in time step 1",
+    "            which is increased from one time step to the next.",
     "    stdatm  Create values for pressure and temperature for hydrostatic atmosphere",
     "            Creates pressure and temperature values for the given list of vertical levels.",
     "            The formulars are:",
@@ -4320,11 +4545,14 @@ static char *VargenHelp[] = {
     "    const   FLOAT   Constant",
     "    seed    INTEGER The seed for a new sequence of pseudo-random numbers [default: 1]",
     "    grid    STRING  Target grid description file or name",
+    "    start   FLOAT   Start value of the loop",
+    "    end     FLOAT   End value of the loop",
+    "    inc     FLOAT   Increment of the loop [default: 1]",
     "    levels  FLOAT   Target levels in metre above surface",
     NULL
 };
 
-static char *RotuvbHelp[] = {
+static const char *RotuvbHelp[] = {
     "NAME",
     "    rotuvb - Rotation",
     "",
@@ -4341,7 +4569,7 @@ static char *RotuvbHelp[] = {
     NULL
 };
 
-static char *MastrfuHelp[] = {
+static const char *MastrfuHelp[] = {
     "NAME",
     "    mastrfu - Mass stream function",
     "",
@@ -4355,7 +4583,7 @@ static char *MastrfuHelp[] = {
     NULL
 };
 
-static char *DeriveparHelp[] = {
+static const char *DeriveparHelp[] = {
     "NAME",
     "    sealevelpressure - Sea level pressure",
     "",
@@ -4365,26 +4593,10 @@ static char *DeriveparHelp[] = {
     "DESCRIPTION",
     "    This operator computes the sea level pressure (air_pressure_at_sea_level). Required input fields",
     "    are surface_air_pressure, surface_geopotential and air_temperature on hybrid sigma pressure levels.",
-    "",
-    "NOTE",
-    "    The netCDF CF convention for vertical hybrid coordinates is not supported, yet!",
-    "    The vertical coordinate definition of a netCDF file has to follow the ECHAM convention.",
-    "    This means:",
-    "    - the dimension of the full level coordinate and the corresponding variable is called mlev,",
-    "    - the dimension of the half level coordinate and the corresponding variable is called ilev (ilev must have one element more than mlev)",
-    "    - the hybrid vertical coefficient a is given in units of Pa and called hyai (hyam for level midpoints)",
-    "    - the hybrid vertical coefficient b is given in units of 1 and called hybi (hybm for level midpoints)",
-    "    - the mlev variable has a borders attribute containing the character string 'ilev'",
-    "    ",
-    "    Use the sinfo command to test if your vertical coordinate system is recognized as hybrid system.",
-    "    ",
-    "    In case this operator complains about not finding any data on hybrid model levels you may wish",
-    "    to use the setzaxis command to generate a zaxis description which conforms to the ECHAM convention.",
-    "    See section \"1.4 Z-axis description\" for an example how to define a hybrid Z-axis.",
     NULL
 };
 
-static char *AdisitHelp[] = {
+static const char *AdisitHelp[] = {
     "NAME",
     "    adisit, adipot - Potential temperature to in-situ temperature and vice versa",
     "",
@@ -4415,7 +4627,7 @@ static char *AdisitHelp[] = {
     NULL
 };
 
-static char *RhopotHelp[] = {
+static const char *RhopotHelp[] = {
     "NAME",
     "    rhopot - Calculates potential density",
     "",
@@ -4433,7 +4645,7 @@ static char *RhopotHelp[] = {
     NULL
 };
 
-static char *HistogramHelp[] = {
+static const char *HistogramHelp[] = {
     "NAME",
     "    histcount, histsum, histmean, histfreq - Histogram",
     "",
@@ -4465,7 +4677,7 @@ static char *HistogramHelp[] = {
     NULL
 };
 
-static char *SethaloHelp[] = {
+static const char *SethaloHelp[] = {
     "NAME",
     "    sethalo - Set the left and right bounds of a field",
     "",
@@ -4485,7 +4697,7 @@ static char *SethaloHelp[] = {
     NULL
 };
 
-static char *WctHelp[] = {
+static const char *WctHelp[] = {
     "NAME",
     "    wct - Windchill temperature",
     "",
@@ -4503,7 +4715,7 @@ static char *WctHelp[] = {
     NULL
 };
 
-static char *FdnsHelp[] = {
+static const char *FdnsHelp[] = {
     "NAME",
     "    fdns - Frost days where no snow index per time period",
     "",
@@ -4521,7 +4733,7 @@ static char *FdnsHelp[] = {
     NULL
 };
 
-static char *StrwinHelp[] = {
+static const char *StrwinHelp[] = {
     "NAME",
     "    strwin - Strong wind days index per time period",
     "",
@@ -4544,7 +4756,7 @@ static char *StrwinHelp[] = {
     NULL
 };
 
-static char *StrbreHelp[] = {
+static const char *StrbreHelp[] = {
     "NAME",
     "    strbre - Strong breeze days index per time period",
     "",
@@ -4563,7 +4775,7 @@ static char *StrbreHelp[] = {
     NULL
 };
 
-static char *StrgalHelp[] = {
+static const char *StrgalHelp[] = {
     "NAME",
     "    strgal - Strong gale days index per time period",
     "",
@@ -4582,7 +4794,7 @@ static char *StrgalHelp[] = {
     NULL
 };
 
-static char *HurrHelp[] = {
+static const char *HurrHelp[] = {
     "NAME",
     "    hurr - Hurricane days index per time period",
     "",
@@ -4601,28 +4813,7 @@ static char *HurrHelp[] = {
     NULL
 };
 
-static char *FillmissHelp[] = {
-    "NAME",
-    "    fillmiss, fillmiss2 - Fill missing values",
-    "",
-    "SYNOPSIS",
-    "    fillmiss  ifile ofile",
-    "    fillmiss2[,maxiter]  ifile ofile",
-    "",
-    "DESCRIPTION",
-    "",
-    "OPERATORS",
-    "    fillmiss   Fill missing values",
-    "               Fill missing values by bilinear interpolation of the neightbours.",
-    "    fillmiss2  Fill missing values",
-    "               Fill missing values by using the neares value from up/down/left/right neightbours. ",
-    "",
-    "PARAMETER",
-    "    maxiter  INTEGER  Number of iterations to perform this nearest neightbours replacement",
-    NULL
-};
-
-static char *EcaCddHelp[] = {
+static const char *EcaCddHelp[] = {
     "NAME",
     "    eca_cdd - Consecutive dry days index per time period",
     "",
@@ -4643,7 +4834,7 @@ static char *EcaCddHelp[] = {
     NULL
 };
 
-static char *EcaCfdHelp[] = {
+static const char *EcaCfdHelp[] = {
     "NAME",
     "    eca_cfd - Consecutive frost days index per time period",
     "",
@@ -4661,7 +4852,7 @@ static char *EcaCfdHelp[] = {
     NULL
 };
 
-static char *EcaCsuHelp[] = {
+static const char *EcaCsuHelp[] = {
     "NAME",
     "    eca_csu - Consecutive summer days index per time period",
     "",
@@ -4683,7 +4874,7 @@ static char *EcaCsuHelp[] = {
     NULL
 };
 
-static char *EcaCwdHelp[] = {
+static const char *EcaCwdHelp[] = {
     "NAME",
     "    eca_cwd - Consecutive wet days index per time period",
     "",
@@ -4704,7 +4895,7 @@ static char *EcaCwdHelp[] = {
     NULL
 };
 
-static char *EcaCwdiHelp[] = {
+static const char *EcaCwdiHelp[] = {
     "NAME",
     "    eca_cwdi - Cold wave duration index wrt mean of reference period",
     "",
@@ -4730,7 +4921,7 @@ static char *EcaCwdiHelp[] = {
     NULL
 };
 
-static char *EcaCwfiHelp[] = {
+static const char *EcaCwfiHelp[] = {
     "NAME",
     "    eca_cwfi - Cold-spell days index wrt 10th percentile of reference period",
     "",
@@ -4738,17 +4929,14 @@ static char *EcaCwfiHelp[] = {
     "    eca_cwfi[,nday]  ifile1 ifile2 ofile",
     "",
     "DESCRIPTION",
-    "    Let ifile1 be a time series of the daily mean temperature TG, and ",
-    "    ifile2 be the 10th percentile TGn10 of daily mean temperatures",
-    "    for any period used as reference. Then counted is the number of days",
-    "    where, in intervals of at least nday consecutive days, TG < TGn10. The",
-    "    number nday is an optional parameter with default nday = 6. A further",
-    "    output variable is the number of cold-spell periods longer than or",
-    "    equal to nday days.",
-    "    TGn10 is calculated as the 10th percentile of daily mean temperatures of a five ",
-    "    day window centred on each calendar day of a given climate reference period.",
-    "    Note that both TG and TGn10 have to be given in the same units.",
-    "    The date information of a timestep in ofile is the date of",
+    "    Let ifile1 be a time series of the daily mean temperature TG, and ifile2 be the 10th",
+    "    percentile TGn10 of daily mean temperatures for any period used as reference. ",
+    "    Then counted is the number of days where, in intervals of at least nday consecutive days,",
+    "    TG < TGn10. The number nday is an optional parameter with default nday = 6.",
+    "    A further output variable is the number of cold-spell periods longer than or equal to nday days.",
+    "    TGn10 is calculated as the 10th percentile of daily mean temperatures of a five day window ",
+    "    centred on each calendar day of a given climate reference period. Note that both TG and TGn10 ",
+    "    have to be given in the same units. The date information of a timestep in ofile is the date of",
     "    the last contributing timestep in ifile1.",
     "    The following variables are created: ",
     "    - cold_spell_days_index_wrt_10th_percentile_of_reference_period",
@@ -4759,7 +4947,7 @@ static char *EcaCwfiHelp[] = {
     NULL
 };
 
-static char *EcaEtrHelp[] = {
+static const char *EcaEtrHelp[] = {
     "NAME",
     "    eca_etr - Intra-period extreme temperature range",
     "",
@@ -4778,7 +4966,7 @@ static char *EcaEtrHelp[] = {
     NULL
 };
 
-static char *EcaFdHelp[] = {
+static const char *EcaFdHelp[] = {
     "NAME",
     "    eca_fd - Frost days index per time period",
     "",
@@ -4796,7 +4984,7 @@ static char *EcaFdHelp[] = {
     NULL
 };
 
-static char *EcaGslHelp[] = {
+static const char *EcaGslHelp[] = {
     "NAME",
     "    eca_gsl - Thermal Growing season length index",
     "",
@@ -4831,7 +5019,7 @@ static char *EcaGslHelp[] = {
     NULL
 };
 
-static char *EcaHdHelp[] = {
+static const char *EcaHdHelp[] = {
     "NAME",
     "    eca_hd - Heating degree days per time period",
     "",
@@ -4854,7 +5042,7 @@ static char *EcaHdHelp[] = {
     NULL
 };
 
-static char *EcaHwdiHelp[] = {
+static const char *EcaHwdiHelp[] = {
     "NAME",
     "    eca_hwdi - Heat wave duration index wrt mean of reference period",
     "",
@@ -4880,7 +5068,7 @@ static char *EcaHwdiHelp[] = {
     NULL
 };
 
-static char *EcaHwfiHelp[] = {
+static const char *EcaHwfiHelp[] = {
     "NAME",
     "    eca_hwfi - Warm spell days index wrt 90th percentile of reference period",
     "",
@@ -4909,7 +5097,7 @@ static char *EcaHwfiHelp[] = {
     NULL
 };
 
-static char *EcaIdHelp[] = {
+static const char *EcaIdHelp[] = {
     "NAME",
     "    eca_id - Ice days index per time period",
     "",
@@ -4927,7 +5115,7 @@ static char *EcaIdHelp[] = {
     NULL
 };
 
-static char *EcaR75pHelp[] = {
+static const char *EcaR75pHelp[] = {
     "NAME",
     "    eca_r75p - Moderate wet days wrt 75th percentile of reference period",
     "",
@@ -4946,7 +5134,7 @@ static char *EcaR75pHelp[] = {
     NULL
 };
 
-static char *EcaR75ptotHelp[] = {
+static const char *EcaR75ptotHelp[] = {
     "NAME",
     "    eca_r75ptot - Precipitation percent due to R75p days",
     "",
@@ -4966,7 +5154,7 @@ static char *EcaR75ptotHelp[] = {
     NULL
 };
 
-static char *EcaR90pHelp[] = {
+static const char *EcaR90pHelp[] = {
     "NAME",
     "    eca_r90p - Wet days wrt 90th percentile of reference period",
     "",
@@ -4985,7 +5173,7 @@ static char *EcaR90pHelp[] = {
     NULL
 };
 
-static char *EcaR90ptotHelp[] = {
+static const char *EcaR90ptotHelp[] = {
     "NAME",
     "    eca_r90ptot - Precipitation percent due to R90p days",
     "",
@@ -5005,7 +5193,7 @@ static char *EcaR90ptotHelp[] = {
     NULL
 };
 
-static char *EcaR95pHelp[] = {
+static const char *EcaR95pHelp[] = {
     "NAME",
     "    eca_r95p - Very wet days wrt 95th percentile of reference period",
     "",
@@ -5024,7 +5212,7 @@ static char *EcaR95pHelp[] = {
     NULL
 };
 
-static char *EcaR95ptotHelp[] = {
+static const char *EcaR95ptotHelp[] = {
     "NAME",
     "    eca_r95ptot - Precipitation percent due to R95p days",
     "",
@@ -5044,7 +5232,7 @@ static char *EcaR95ptotHelp[] = {
     NULL
 };
 
-static char *EcaR99pHelp[] = {
+static const char *EcaR99pHelp[] = {
     "NAME",
     "    eca_r99p - Extremely wet days wrt 99th percentile of reference period",
     "",
@@ -5063,7 +5251,7 @@ static char *EcaR99pHelp[] = {
     NULL
 };
 
-static char *EcaR99ptotHelp[] = {
+static const char *EcaR99ptotHelp[] = {
     "NAME",
     "    eca_r99ptot - Precipitation percent due to R99p days",
     "",
@@ -5083,7 +5271,7 @@ static char *EcaR99ptotHelp[] = {
     NULL
 };
 
-static char *EcaPdHelp[] = {
+static const char *EcaPdHelp[] = {
     "NAME",
     "    eca_pd, eca_r10mm, eca_r20mm - Precipitation days index per time period",
     "",
@@ -5117,7 +5305,7 @@ static char *EcaPdHelp[] = {
     NULL
 };
 
-static char *EcaRr1Help[] = {
+static const char *EcaRr1Help[] = {
     "NAME",
     "    eca_rr1 - Wet days index per time period",
     "",
@@ -5136,7 +5324,7 @@ static char *EcaRr1Help[] = {
     NULL
 };
 
-static char *EcaRx1dayHelp[] = {
+static const char *EcaRx1dayHelp[] = {
     "NAME",
     "    eca_rx1day - Highest one day precipitation amount per time period",
     "",
@@ -5158,7 +5346,7 @@ static char *EcaRx1dayHelp[] = {
     NULL
 };
 
-static char *EcaRx5dayHelp[] = {
+static const char *EcaRx5dayHelp[] = {
     "NAME",
     "    eca_rx5day - Highest five-day precipitation amount per time period",
     "",
@@ -5179,7 +5367,7 @@ static char *EcaRx5dayHelp[] = {
     NULL
 };
 
-static char *EcaSdiiHelp[] = {
+static const char *EcaSdiiHelp[] = {
     "NAME",
     "    eca_sdii - Simple daily intensity index per time period",
     "",
@@ -5198,7 +5386,7 @@ static char *EcaSdiiHelp[] = {
     NULL
 };
 
-static char *EcaSuHelp[] = {
+static const char *EcaSuHelp[] = {
     "NAME",
     "    eca_su - Summer days index per time period",
     "",
@@ -5218,7 +5406,7 @@ static char *EcaSuHelp[] = {
     NULL
 };
 
-static char *EcaTg10pHelp[] = {
+static const char *EcaTg10pHelp[] = {
     "NAME",
     "    eca_tg10p - Cold days percent wrt 10th percentile of reference period",
     "",
@@ -5240,7 +5428,7 @@ static char *EcaTg10pHelp[] = {
     NULL
 };
 
-static char *EcaTg90pHelp[] = {
+static const char *EcaTg90pHelp[] = {
     "NAME",
     "    eca_tg90p - Warm days percent wrt 90th percentile of reference period",
     "",
@@ -5262,7 +5450,7 @@ static char *EcaTg90pHelp[] = {
     NULL
 };
 
-static char *EcaTn10pHelp[] = {
+static const char *EcaTn10pHelp[] = {
     "NAME",
     "    eca_tn10p - Cold nights percent wrt 10th percentile of reference period",
     "",
@@ -5284,7 +5472,7 @@ static char *EcaTn10pHelp[] = {
     NULL
 };
 
-static char *EcaTn90pHelp[] = {
+static const char *EcaTn90pHelp[] = {
     "NAME",
     "    eca_tn90p - Warm nights percent wrt 90th percentile of reference period",
     "",
@@ -5303,7 +5491,7 @@ static char *EcaTn90pHelp[] = {
     NULL
 };
 
-static char *EcaTrHelp[] = {
+static const char *EcaTrHelp[] = {
     "NAME",
     "    eca_tr - Tropical nights index per time period",
     "",
@@ -5323,7 +5511,7 @@ static char *EcaTrHelp[] = {
     NULL
 };
 
-static char *EcaTx10pHelp[] = {
+static const char *EcaTx10pHelp[] = {
     "NAME",
     "    eca_tx10p - Very cold days percent wrt 10th percentile of reference period",
     "",
@@ -5345,7 +5533,7 @@ static char *EcaTx10pHelp[] = {
     NULL
 };
 
-static char *EcaTx90pHelp[] = {
+static const char *EcaTx90pHelp[] = {
     "NAME",
     "    eca_tx90p - Very warm days percent wrt 90th percentile of reference period",
     "",
diff --git a/src/percentiles.c b/src/percentiles.c
index 9e8ab2a..58d7ced 100644
--- a/src/percentiles.c
+++ b/src/percentiles.c
@@ -1,426 +1,141 @@
-/*
-  This file is part of CDO. CDO is a collection of Operators to
-  manipulate and analyse Climate model Data.
-
-  Copyright (C) 2006 Brockmann Consult
-  See COPYING file for copying and redistribution conditions.
-
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; version 2 of the License.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-*/
-
-#include <assert.h>
-#include <stdlib.h>
 #include <math.h>
-
-#include <cdi.h>
-#include "cdo.h"
-#include "cdo_int.h"
-#include "nth_element.h"
+#include <string.h>
+#include "util.h"
 #include "percentiles.h"
+#include "nth_element.h"
 
-#define NBINS_DEFAULT   101
-#define NBINS_MINIMUM    11
-
-#define DBL_CAPACITY(n) ((int)(((n) * sizeof(int)) / sizeof(double)))
-#define DBL_PTR(p)      ((double *) (p))
-#define INT_PTR(p)      ((int *) (p))
-
-
-static int histGetEnvNBins()
-{
-  const char *str = getenv("CDO_PCTL_NBINS");
-  
-  return str != NULL ? MAX(atoi(str), NBINS_MINIMUM) : NBINS_DEFAULT;
-}
-
-
-static void histDefBounds(HISTOGRAM *hist, double a, double b)
-{
-  int i;
-  
-  assert( hist != NULL );
-  assert( hist->nbins > 0 );
-  
-  hist->min   = MIN(a, b);
-  hist->max   = MAX(a, b);
-  hist->step  = (hist->max - hist->min) / hist->nbins;
-  hist->nsamp = 0;
-
-  for ( i = 0; i < hist->nbins; i++ )
-    INT_PTR(hist->ptr)[i] = 0;
-}
-
-
-static void histBinValue(HISTOGRAM *hist, double value)
-{
-  int bin;
-  
-  assert( hist->step > 0 );
-
-  bin = MIN((int)((value - hist->min) / hist->step), hist->nbins - 1);
-  if ( bin >= 0 && bin < hist->nbins )
-    INT_PTR(hist->ptr)[bin]++;
-}
+enum percentile_methods {NRANK=1, NIST, NUMPY};
+enum interpolation_methods {LINEAR=1, LOWER, HIGHER, NEAREST};
 
+static int percentile_method = NRANK;
+static int interpolation_method = LINEAR;
 
-static void histBin(HISTOGRAM *hist)
+static
+double percentile_nrank(double *array, int len, double pn)
 {
-  int i;
-  double *values;
-  
-  assert( hist->nsamp == DBL_CAPACITY(hist->nbins) );
-
-  values = (double*) malloc(hist->nsamp * sizeof(double));
-
-  for ( i = 0; i < hist->nsamp; i++ )
-    values[i] = DBL_PTR(hist->ptr)[i];
-  for ( i = 0; i < hist->nbins; i++ )
-    INT_PTR(hist->ptr)[i] = 0;
-  for ( i = 0; i < hist->nsamp; i++ )
-    histBinValue(hist, values[i]);
-      
-  free(values);
+  int irank = (int)ceil(len*(pn/100.0));
+  if ( irank <   1 ) irank = 1;
+  if ( irank > len ) irank = len;
+  return nth_element(array, len, irank-1);
 }
 
-
-static int histAddValue(HISTOGRAM *hist, double value)
+static
+double percentile_nist(double *array, int len, double pn)
 {
-  assert( hist != NULL );
-  assert( hist->nbins > 0 );
-
-  /* 2011-08-01 Uwe Schulzweida: added check for rounding errors */
-  if ( value < hist->min && (hist->min-value) < 1e5 ) value = hist->min;
-  if ( value > hist->max && (value-hist->max) < 1e5 ) value = hist->max;
-
-  if ( IS_EQUAL(hist->min, hist->max) )
-    return 0;
-  if ( value < hist->min || value > hist->max )
-    return 1;
-
-  if ( hist->nsamp < DBL_CAPACITY(hist->nbins) )
-    {
-      DBL_PTR(hist->ptr)[hist->nsamp] = value;
-      hist->nsamp++;
-    } 
-  else if ( hist->nsamp > DBL_CAPACITY(hist->nbins) )
-    {
-      histBinValue(hist, value);
-      hist->nsamp++;
-    }
+  double rank = (len+1)*(pn/100.0);
+  int k = (int) rank;
+  double d = rank - k;
+  double percentil = 0;
+  if      ( k ==   0 ) percentil = nth_element(array, len, 0);
+  else if ( k >= len ) percentil = nth_element(array, len, len-1);
   else
     {
-      histBin(hist);
-      histBinValue(hist, value);
-      hist->nsamp++; 
+      double vk1 = nth_element(array, len, k);
+      double vk  = array[k-1];
+      percentil = vk + d*(vk1 - vk);
     }
-  
-  return 0;
-}
-
 
-static double histGetPercentile(const HISTOGRAM *hist, double p)
-{
-  double s, t;
-  int i = 0, count = 0;
-  
-  assert( hist != NULL );
-  assert( hist->nsamp > 0 );
-  assert( hist->nbins > 0 );
-  assert( p >= 0 );
-  assert( p <= 100 );
-  
-  s = hist->nsamp * (p / 100.0);
-  
-  if ( hist->nsamp > DBL_CAPACITY(hist->nbins) )
-    { 
-      do count += INT_PTR(hist->ptr)[i++]; while ( count < s );
-  
-      assert( i > 0 );
-      assert( i - 1 < hist->nbins );
-      assert( INT_PTR(hist->ptr)[i - 1] > 0 );
-      assert( hist->step > 0.0 );
-  
-      t = (count - s) / INT_PTR(hist->ptr)[i - 1];
-      return hist->min + (i - t) * hist->step;
-    }
-  else
-    {
-      return (double)nth_element(DBL_PTR(hist->ptr), hist->nsamp, (int)ceil(s) - 1);
-    } 
+  return percentil;
 }
 
-
-HISTOGRAM_SET *hsetCreate(int nvars)
+static
+double percentile_numpy(double *array, int len, double pn)
 {
-  int varID;
-  HISTOGRAM_SET *hset;
-  
-  assert( nvars > 0);
-  
-  hset = (HISTOGRAM_SET*) malloc(sizeof(HISTOGRAM_SET));
-  if ( hset == NULL )
-    cdoAbort("Not enough memory (%s)", __func__);
-    
-  hset->nvars   = nvars;
-  hset->nlevels = (int*) malloc(nvars * sizeof(int));
-  hset->grids   = (int*) malloc(nvars * sizeof(int));
-  hset->histograms = (HISTOGRAM ***) malloc(nvars * sizeof(HISTOGRAM **));
-  if ( hset->histograms == NULL )
-    cdoAbort("Not enough memory (%s)", __func__);
-  
-  for ( varID = 0; varID < nvars; varID++ )
-    {
-      hset->nlevels[varID]    = 0;
-      hset->grids[varID]      = 0;
-      hset->histograms[varID] = NULL;
-    }
-  
-  return hset;
-}
-
-
-void hsetCreateVarLevels(HISTOGRAM_SET *hset, int varID, int nlevels, int grid)
-{
-  int nvars, nhists, nbins, levelID, histID;
-  HISTOGRAM *hists;
-  
-  nbins = histGetEnvNBins();
-  
-  assert( hset != NULL );
-  assert( nlevels > 0 );
-  assert( nbins   > 0 );
-  
-  nvars = hset->nvars;
-
-  assert( nvars > 0 );
-  
-  if ( varID < 0 || varID >= nvars )
-    cdoAbort("Illegal argument: varID %d is undefined (%s)", varID, __func__);
-    
-  nhists = gridInqSize(grid);
-  
-  assert( nhists > 0 );
-    
-  hset->nlevels[varID] = nlevels;
-  hset->grids[varID]   = grid;
-
-  hset->histograms[varID] = (HISTOGRAM **) malloc(nlevels * sizeof(HISTOGRAM *));
-  if ( hset->histograms[varID] == NULL )
-    cdoAbort("Not enough memory (%s)", __func__);
-
-  for ( levelID = 0; levelID < nlevels; levelID++ )
+  double rank = (len-1)*(pn/100.0) + 1;
+  int k = (int) rank;
+  double d = rank - k;
+  double percentil = 0;
+  if      ( k ==   0 ) percentil = nth_element(array, len, 0);
+  else if ( k >= len ) percentil = nth_element(array, len, len-1);
+  else
     {
-      hists = hset->histograms[varID][levelID] = (HISTOGRAM*) malloc(nhists * sizeof(HISTOGRAM));
-      if ( hists == NULL )
-        cdoAbort("Not enough memory (%s)", __func__);
-        
-      for ( histID = 0; histID < nhists; histID++ )
+      if ( interpolation_method == LINEAR )
         {
-          hists[histID].min = 0.0;
-          hists[histID].max = 0.0;
-          hists[histID].step = 0.0;
-          hists[histID].nbins = nbins;
-          hists[histID].nsamp = 0;
-
-          hists[histID].ptr = (int*) malloc(nbins * sizeof(int));
-          if ( hists[histID].ptr == NULL )
-            cdoAbort("Not enough memory (%s)", __func__);
+          double vk1 = nth_element(array, len, k);
+          double vk  = array[k-1];
+          percentil = vk + d*(vk1 - vk);
         }
-    }
-}
+      else
+        {
+          int irank = 0;
+          if      ( interpolation_method == LOWER   ) irank = (int) floor(rank);
+          else if ( interpolation_method == HIGHER  ) irank = (int) ceil(rank);
+          else if ( interpolation_method == NEAREST ) irank = (int) round(rank);
+          // numpy is using around(), with rounds to the nearest even value
 
+          if ( irank <   1 ) irank = 1;
+          if ( irank > len ) irank = len;
 
-void hsetDestroy(HISTOGRAM_SET *hset)
-{
-  int varID, levelID, histID, nhists;
-  
-  if ( hset != NULL )
-    {
-      for ( varID = hset->nvars; varID-- > 0; )
-        {
-          nhists = gridInqSize(hset->grids[varID]);
-          for ( levelID = hset->nlevels[varID]; levelID-- > 0; )
-            {
-              for ( histID = nhists; histID-- > 0; )
-                free(hset->histograms[varID][levelID][histID].ptr);
-              free(hset->histograms[varID][levelID]);
-            }
-          free(hset->histograms[varID]);
+          percentil = nth_element(array, len, irank-1);
         }
-      
-      free(hset->histograms);
-      free(hset->grids);
-      free(hset->nlevels);
-      free(hset);
-      
-      hset = NULL;  
     }
+
+  return percentil;
 }
 
 
-void hsetDefVarLevelBounds(HISTOGRAM_SET *hset, int varID, int levelID, const field_t *field1, const field_t *field2)
+double percentile(double *array, int len, double pn)
 {
-  const double *array1 = field1->ptr;
-  const double *array2 = field2->ptr;
+  double percentil = 0;
   
-  int i, nvars, nlevels, nhists, grid;
-  double a, b;
-  HISTOGRAM *hists;
-  
-  assert( hset   != NULL );
-  assert( field1 != NULL );
-  assert( field2 != NULL );
-  assert( array1 != NULL );
-  assert( array2 != NULL );
-     
-  nvars = hset->nvars;
-  
-  assert( nvars > 0 );
-  
-  if ( varID < 0 || varID >= nvars )
-    cdoAbort("Illegal argument: varID %d is undefined (%s)", varID, __func__);
+  if      ( percentile_method == NRANK ) percentil = percentile_nrank(array, len, pn);
+  else if ( percentile_method == NIST  ) percentil = percentile_nist(array, len, pn);
+  else if ( percentile_method == NUMPY ) percentil = percentile_numpy(array, len, pn);
+  else cdoAbort("Internal error: percentile method %d not implemented!", percentile_method);
 
-  nlevels = hset->nlevels[varID];
-  
-  assert( nlevels > 0 );
-  
-  if ( levelID < 0 || levelID >= nlevels )
-    cdoAbort("Illegal argument: levelID %d is undefined (%s)", levelID, __func__);
-
-  grid = hset->grids[varID];
-  
-  if ( grid != field1->grid || grid != field2->grid )
-    cdoAbort("Grids are different", __func__);
-  
-  hists  = hset->histograms[varID][levelID];
-  
-  assert( hists != NULL );
-  
-  nhists = gridInqSize(grid);
-  
-  assert( nhists > 0 );
-         
-  for ( i = 0; i < nhists; i++ )
-    {
-      a = array1[i];
-      b = array2[i];
-      
-      if ( DBL_IS_EQUAL(a, field1->missval) || DBL_IS_EQUAL(b, field2->missval) || DBL_IS_EQUAL(a, b) )
-        histDefBounds(&hists[i], 0.0, 0.0);
-      else  
-        histDefBounds(&hists[i], a, b);
-    }
+  return percentil;
 }
 
 
-void hsetAddVarLevelValues(HISTOGRAM_SET *hset, int varID, int levelID, const field_t *field)
+void percentile_set_method(const char *methodstr)
 {
-  const double *array = field->ptr;
-  int i, grid, nvars, nlevels, nhists, nign = 0;
-  HISTOGRAM *hists;
-  
-  assert( hset  != NULL );
-  assert( field != NULL );
-  assert( array != NULL );
-  
-  nvars = hset->nvars;
-  
-  assert( nvars > 0 );
-  
-  if ( varID < 0 || varID >= nvars )
-    cdoAbort("Illegal argument: varID %d is undefined (%s)", varID, __func__);
-
-  nlevels = hset->nlevels[varID];
-  
-  assert( nlevels > 0);
-  
-  if ( levelID < 0 || levelID >= nlevels )
-    cdoAbort("Illegal argument: levelID %d is undefined (%s)", levelID, __func__);
-    
-  grid = hset->grids[varID];
-  if ( grid != field->grid )
-    cdoAbort("Grids are different", __func__);
-
-  hists  = hset->histograms[varID][levelID];
-  
-  assert( hists != NULL );
-  
-  nhists = gridInqSize(grid);
-  
-  assert( nhists > 0 );
-  
-  if ( field->nmiss )
-    {
-      for ( i = 0; i < nhists; i++ )
-        if ( !DBL_IS_EQUAL(array[i], field->missval) )
-          nign += histAddValue(&hists[i], array[i]);
-    }
-  else
-    {
-      for ( i = 0; i < nhists; i++ )
-        nign += histAddValue(&hists[i], array[i]); 
-    }
-    
-  if ( nign )  
-    cdoWarning("%d out of %d grid values are out of bounds and have been ignored (%s)", nign, nhists, __func__);
+  char *methodname = strdup(methodstr);
+  strtolower(methodname);
+
+  if      ( strcmp("nrank", methodname) == 0 ) percentile_method = NRANK;
+  else if ( strcmp("nist",  methodname) == 0 ) percentile_method = NIST;
+  else if ( strcmp("numpy", methodname) == 0 ) percentile_method = NUMPY;
+  else if ( strcmp("numpy_linear",  methodname) == 0 ) {percentile_method = NUMPY; interpolation_method = LINEAR;}
+  else if ( strcmp("numpy_lower",   methodname) == 0 ) {percentile_method = NUMPY; interpolation_method = LOWER;}
+  else if ( strcmp("numpy_higher",  methodname) == 0 ) {percentile_method = NUMPY; interpolation_method = HIGHER;}
+  else if ( strcmp("numpy_nearest", methodname) == 0 ) {percentile_method = NUMPY; interpolation_method = NEAREST;}
+  else cdoAbort("Percentile method %s not available!", methodstr);
 }
 
 
-void hsetGetVarLevelPercentiles(field_t *field, const HISTOGRAM_SET *hset, int varID, int levelID, double p)
+void percentile_check_number(double pn)
 {
-  double *array = field->ptr;
-  int i, nvars, nlevels, nhists, grid;
-  HISTOGRAM *hists;
-  
-  assert( hset  != NULL );
-  assert( field != NULL );
-  assert( array != NULL );
-  
-  nvars = hset->nvars;
-
-  assert( nvars > 0 );
-    
-  if ( varID < 0 || varID >= nvars )
-    cdoAbort("Illegal argument: varID %d is undefined (%s)", varID, __func__);
-
-  nlevels = hset->nlevels[varID];
-
-  assert( nlevels > 0 );
-  
-  if ( levelID < 0 || levelID >= nlevels )
-    cdoAbort("Illegal argument: levelID %d is undefined (%s)", levelID, __func__);
-
-  grid = hset->grids[varID];
-  
-  if ( grid != field->grid )
-    cdoAbort("Grids are different (%s)", __func__);
-
-  hists  = hset->histograms[varID][levelID];
-
-  assert( hists != NULL );
-
-  nhists = gridInqSize(grid);
-
-  assert( nhists > 0 );
- 
-  field->nmiss = 0;
-  for ( i = 0; i < nhists; i++ )
-    {
-      if ( hists[i].nsamp )
-        {
-          array[i] = histGetPercentile(&hists[i], p);
-        }
-      else
-        {
-          array[i] = field->missval;
-          field->nmiss++;
-        }
-    } 
+  if ( pn < 0 || pn > 100 )
+    cdoAbort("Percentile number %g out of range! Percentiles must be in the range [0,100].", pn);
 }
+
+/*
+  CDO check
+#/bin/sh
+CDO=cdo
+#
+cdo -f nc input,r5x1 testfile <<EOF
+ 15 20 35 40 50
+EOF
+cdo -f nc input,r6x1 testfile <<EOF
+ 15 20 35 40 50 55
+EOF
+#
+PERS="30 40 50 75 100"
+METS="nrank nist numpy numpy_lower numpy_higher numpy_nearest"
+#
+for MET in $METS; do
+    for PER in $PERS; do
+        echo "$MET: $PER"
+        $CDO -s --percentile $MET output -fldpctl,$PER testfile 
+    done
+done
+*/
+/*
+  numpy check
+#python with numpy 1.9.0
+import numpy as np
+np.version.version
+a=np.array([15, 20, 35, 40, 50, 55])
+for p in [30, 40, 50, 75, 100] : print np.percentile(a, p, interpolation='linear')
+*/
diff --git a/src/percentiles.h b/src/percentiles.h
index 5f455eb..5f5503c 100644
--- a/src/percentiles.h
+++ b/src/percentiles.h
@@ -1,50 +1,8 @@
-/*
-  This file is part of CDO. CDO is a collection of Operators to
-  manipulate and analyse Climate model Data.
+#ifndef _PERCENTILES_H
+#define _PERCENTILES_H
 
-  Copyright (C) 2006 Brockmann Consult
-  See COPYING file for copying and redistribution conditions.
+double percentile(double *array, int len, double pn);
+void percentile_set_method(const char *methodstr);
+void percentile_check_number(double pn);
 
-  This program is free software; you can redistribute it and/or modify
-  it under the terms of the GNU General Public License as published by
-  the Free Software Foundation; version 2 of the License.
-
-  This program is distributed in the hope that it will be useful,
-  but WITHOUT ANY WARRANTY; without even the implied warranty of
-  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-  GNU General Public License for more details.
-*/
-
-#ifndef PERCENTILES_H_
-#define PERCENTILES_H_
-
-#include "field.h"
-
-typedef struct {
-  double min;
-  double max;
-  double step;
-  int    nbins;
-  int    nsamp;
-  void  *ptr;
-}
-HISTOGRAM;
-
-typedef struct {
-  int    nvars;
-  int   *nlevels;
-  int   *grids;
-  HISTOGRAM ***histograms;
-}
-HISTOGRAM_SET;
-
-
-HISTOGRAM_SET *hsetCreate(int nvars);
-void hsetCreateVarLevels(HISTOGRAM_SET *hset, int varID, int nlevels, int nhists);
-void hsetDestroy(HISTOGRAM_SET *hset);
-
-void hsetDefVarLevelBounds(HISTOGRAM_SET *hset, int varID, int levelID, const field_t *min, const field_t *max);
-void hsetAddVarLevelValues(HISTOGRAM_SET *histField, int varID, int levelID, const field_t *field);
-void hsetGetVarLevelPercentiles(field_t *field, const HISTOGRAM_SET *hset, int varID, int levelID, double pn); 
-
-#endif /*PERCENTILES_H_*/
+#endif /* _PERCENTILES_H */
diff --git a/src/percentiles.c b/src/percentiles_hist.c
similarity index 90%
copy from src/percentiles.c
copy to src/percentiles_hist.c
index 9e8ab2a..8b83a56 100644
--- a/src/percentiles.c
+++ b/src/percentiles_hist.c
@@ -22,8 +22,8 @@
 #include <cdi.h>
 #include "cdo.h"
 #include "cdo_int.h"
-#include "nth_element.h"
 #include "percentiles.h"
+#include "percentiles_hist.h"
 
 #define NBINS_DEFAULT   101
 #define NBINS_MINIMUM    11
@@ -77,7 +77,7 @@ static void histBin(HISTOGRAM *hist)
   
   assert( hist->nsamp == DBL_CAPACITY(hist->nbins) );
 
-  values = (double*) malloc(hist->nsamp * sizeof(double));
+  values = (double*) Malloc(hist->nsamp * sizeof(double));
 
   for ( i = 0; i < hist->nsamp; i++ )
     values[i] = DBL_PTR(hist->ptr)[i];
@@ -86,7 +86,7 @@ static void histBin(HISTOGRAM *hist)
   for ( i = 0; i < hist->nsamp; i++ )
     histBinValue(hist, values[i]);
       
-  free(values);
+  Free(values);
 }
 
 
@@ -127,7 +127,6 @@ static int histAddValue(HISTOGRAM *hist, double value)
 
 static double histGetPercentile(const HISTOGRAM *hist, double p)
 {
-  double s, t;
   int i = 0, count = 0;
   
   assert( hist != NULL );
@@ -136,10 +135,11 @@ static double histGetPercentile(const HISTOGRAM *hist, double p)
   assert( p >= 0 );
   assert( p <= 100 );
   
-  s = hist->nsamp * (p / 100.0);
   
   if ( hist->nsamp > DBL_CAPACITY(hist->nbins) )
     { 
+      double s = hist->nsamp * (p / 100.0);
+
       do count += INT_PTR(hist->ptr)[i++]; while ( count < s );
   
       assert( i > 0 );
@@ -147,12 +147,12 @@ static double histGetPercentile(const HISTOGRAM *hist, double p)
       assert( INT_PTR(hist->ptr)[i - 1] > 0 );
       assert( hist->step > 0.0 );
   
-      t = (count - s) / INT_PTR(hist->ptr)[i - 1];
+      double t = (count - s) / INT_PTR(hist->ptr)[i - 1];
       return hist->min + (i - t) * hist->step;
     }
   else
     {
-      return (double)nth_element(DBL_PTR(hist->ptr), hist->nsamp, (int)ceil(s) - 1);
+      return percentile(DBL_PTR(hist->ptr), hist->nsamp, p);
     } 
 }
 
@@ -164,14 +164,14 @@ HISTOGRAM_SET *hsetCreate(int nvars)
   
   assert( nvars > 0);
   
-  hset = (HISTOGRAM_SET*) malloc(sizeof(HISTOGRAM_SET));
+  hset = (HISTOGRAM_SET*) Malloc(sizeof(HISTOGRAM_SET));
   if ( hset == NULL )
     cdoAbort("Not enough memory (%s)", __func__);
     
   hset->nvars   = nvars;
-  hset->nlevels = (int*) malloc(nvars * sizeof(int));
-  hset->grids   = (int*) malloc(nvars * sizeof(int));
-  hset->histograms = (HISTOGRAM ***) malloc(nvars * sizeof(HISTOGRAM **));
+  hset->nlevels = (int*) Malloc(nvars * sizeof(int));
+  hset->grids   = (int*) Malloc(nvars * sizeof(int));
+  hset->histograms = (HISTOGRAM ***) Malloc(nvars * sizeof(HISTOGRAM **));
   if ( hset->histograms == NULL )
     cdoAbort("Not enough memory (%s)", __func__);
   
@@ -211,13 +211,13 @@ void hsetCreateVarLevels(HISTOGRAM_SET *hset, int varID, int nlevels, int grid)
   hset->nlevels[varID] = nlevels;
   hset->grids[varID]   = grid;
 
-  hset->histograms[varID] = (HISTOGRAM **) malloc(nlevels * sizeof(HISTOGRAM *));
+  hset->histograms[varID] = (HISTOGRAM **) Malloc(nlevels * sizeof(HISTOGRAM *));
   if ( hset->histograms[varID] == NULL )
     cdoAbort("Not enough memory (%s)", __func__);
 
   for ( levelID = 0; levelID < nlevels; levelID++ )
     {
-      hists = hset->histograms[varID][levelID] = (HISTOGRAM*) malloc(nhists * sizeof(HISTOGRAM));
+      hists = hset->histograms[varID][levelID] = (HISTOGRAM*) Malloc(nhists * sizeof(HISTOGRAM));
       if ( hists == NULL )
         cdoAbort("Not enough memory (%s)", __func__);
         
@@ -229,7 +229,7 @@ void hsetCreateVarLevels(HISTOGRAM_SET *hset, int varID, int nlevels, int grid)
           hists[histID].nbins = nbins;
           hists[histID].nsamp = 0;
 
-          hists[histID].ptr = (int*) malloc(nbins * sizeof(int));
+          hists[histID].ptr = (int*) Malloc(nbins * sizeof(int));
           if ( hists[histID].ptr == NULL )
             cdoAbort("Not enough memory (%s)", __func__);
         }
@@ -249,16 +249,16 @@ void hsetDestroy(HISTOGRAM_SET *hset)
           for ( levelID = hset->nlevels[varID]; levelID-- > 0; )
             {
               for ( histID = nhists; histID-- > 0; )
-                free(hset->histograms[varID][levelID][histID].ptr);
-              free(hset->histograms[varID][levelID]);
+                Free(hset->histograms[varID][levelID][histID].ptr);
+              Free(hset->histograms[varID][levelID]);
             }
-          free(hset->histograms[varID]);
+          Free(hset->histograms[varID]);
         }
       
-      free(hset->histograms);
-      free(hset->grids);
-      free(hset->nlevels);
-      free(hset);
+      Free(hset->histograms);
+      Free(hset->grids);
+      Free(hset->nlevels);
+      Free(hset);
       
       hset = NULL;  
     }
diff --git a/src/percentiles.h b/src/percentiles_hist.h
similarity index 94%
copy from src/percentiles.h
copy to src/percentiles_hist.h
index 5f455eb..f27c39a 100644
--- a/src/percentiles.h
+++ b/src/percentiles_hist.h
@@ -15,8 +15,8 @@
   GNU General Public License for more details.
 */
 
-#ifndef PERCENTILES_H_
-#define PERCENTILES_H_
+#ifndef PERCENTILES_HIST_H_
+#define PERCENTILES_HIST_H_
 
 #include "field.h"
 
@@ -47,4 +47,4 @@ void hsetDefVarLevelBounds(HISTOGRAM_SET *hset, int varID, int levelID, const fi
 void hsetAddVarLevelValues(HISTOGRAM_SET *histField, int varID, int levelID, const field_t *field);
 void hsetGetVarLevelPercentiles(field_t *field, const HISTOGRAM_SET *hset, int varID, int levelID, double pn); 
 
-#endif /*PERCENTILES_H_*/
+#endif /* PERCENTILES_HIST_H_ */
diff --git a/src/pipe.c b/src/pipe.c
index fcab419..8ca8f67 100644
--- a/src/pipe.c
+++ b/src/pipe.c
@@ -31,6 +31,7 @@
 #include "pstream_int.h"
 #include <cdi.h>
 #include "cdo.h"
+#include "cdo_int.h"
 #include "error.h"
 #include "dmemory.h"
 
@@ -91,28 +92,28 @@ void pipe_init(pipe_t *pipe)
   pipe->usedata = TRUE;
   pipe->pstreamptr_in = 0;
 
-  pipe->mutex = (pthread_mutex_t*) malloc(sizeof(pthread_mutex_t));
+  pipe->mutex = (pthread_mutex_t*) Malloc(sizeof(pthread_mutex_t));
   pthread_mutex_init(pipe->mutex, &m_attr);
 
-  pipe->tsDef = (pthread_cond_t*) malloc(sizeof(pthread_cond_t));
+  pipe->tsDef = (pthread_cond_t*) Malloc(sizeof(pthread_cond_t));
   pthread_cond_init(pipe->tsDef, &c_attr);
-  pipe->tsInq = (pthread_cond_t*) malloc(sizeof(pthread_cond_t));
+  pipe->tsInq = (pthread_cond_t*) Malloc(sizeof(pthread_cond_t));
   pthread_cond_init(pipe->tsInq, &c_attr);
 
-  pipe->recDef = (pthread_cond_t*) malloc(sizeof(pthread_cond_t));
+  pipe->recDef = (pthread_cond_t*) Malloc(sizeof(pthread_cond_t));
   pthread_cond_init(pipe->recDef, &c_attr);
-  pipe->recInq = (pthread_cond_t*) malloc(sizeof(pthread_cond_t));
+  pipe->recInq = (pthread_cond_t*) Malloc(sizeof(pthread_cond_t));
   pthread_cond_init(pipe->recInq, &c_attr);
   
-  pipe->vlistDef = (pthread_cond_t*) malloc(sizeof(pthread_cond_t));
+  pipe->vlistDef = (pthread_cond_t*) Malloc(sizeof(pthread_cond_t));
   pthread_cond_init(pipe->vlistDef, &c_attr);
-  pipe->isclosed = (pthread_cond_t*) malloc(sizeof(pthread_cond_t));
+  pipe->isclosed = (pthread_cond_t*) Malloc(sizeof(pthread_cond_t));
   pthread_cond_init(pipe->isclosed, &c_attr);
 
-  pipe->writeCond = (pthread_cond_t*) malloc(sizeof(pthread_cond_t));
+  pipe->writeCond = (pthread_cond_t*) Malloc(sizeof(pthread_cond_t));
   pthread_cond_init(pipe->writeCond, &c_attr);
 
-  pipe->readCond = (pthread_cond_t*) malloc(sizeof(pthread_cond_t));
+  pipe->readCond = (pthread_cond_t*) Malloc(sizeof(pthread_cond_t));
   pthread_cond_init(pipe->readCond, &c_attr);
 
   pthread_mutexattr_destroy(&m_attr);
@@ -124,7 +125,7 @@ pipe_t *pipeNew()
 {
   pipe_t *pipe;
 
-  pipe = (pipe_t*) malloc(sizeof(pipe_t));
+  pipe = (pipe_t*) Malloc(sizeof(pipe_t));
 
   pipe_init(pipe);
 
@@ -136,16 +137,16 @@ void pipeDelete(pipe_t *pipe)
 {
   if ( pipe )
     {
-      if ( pipe->mutex )     free(pipe->mutex);
-      if ( pipe->tsDef )     free(pipe->tsDef);
-      if ( pipe->tsInq )     free(pipe->tsInq);
-      if ( pipe->recDef )    free(pipe->recDef);
-      if ( pipe->recInq )    free(pipe->recInq);
-      if ( pipe->vlistDef )  free(pipe->vlistDef);
-      if ( pipe->isclosed )  free(pipe->isclosed);
-      if ( pipe->writeCond ) free(pipe->writeCond);
-      if ( pipe->readCond )  free(pipe->readCond);
-      free(pipe);
+      if ( pipe->mutex )     Free(pipe->mutex);
+      if ( pipe->tsDef )     Free(pipe->tsDef);
+      if ( pipe->tsInq )     Free(pipe->tsInq);
+      if ( pipe->recDef )    Free(pipe->recDef);
+      if ( pipe->recInq )    Free(pipe->recInq);
+      if ( pipe->vlistDef )  Free(pipe->vlistDef);
+      if ( pipe->isclosed )  Free(pipe->isclosed);
+      if ( pipe->writeCond ) Free(pipe->writeCond);
+      if ( pipe->readCond )  Free(pipe->readCond);
+      Free(pipe);
     }
 }
 
@@ -381,7 +382,7 @@ int pipeInqRecord(pstream_t *pstreamptr, int *varID, int *levelID)
 
   pthread_cond_signal(pipe->recInq);
 
-  return (0);
+  return 0;
 }
 
 
diff --git a/src/printinfo.h b/src/printinfo.h
index 997f893..c68c2ec 100644
--- a/src/printinfo.h
+++ b/src/printinfo.h
@@ -1,3 +1,5 @@
+// This file is used in CDI and CDO !!!
+
 #define DATE_FORMAT "%5.4d-%2.2d-%2.2d"
 #define TIME_FORMAT "%2.2d:%2.2d:%2.2d"
 
@@ -6,22 +8,21 @@ void uuid2str(const unsigned char uuid[CDI_UUID_SIZE], char *uuidstr);
 static inline
 int cdiUUIDIsNull(const unsigned char uuid[CDI_UUID_SIZE])
 {
-  static unsigned char uuid_nil[CDI_UUID_SIZE];
-  return !memcmp(uuid, uuid_nil, CDI_UUID_SIZE);
+  int isNull = 1;
+  for (size_t i = 0; i < CDI_UUID_SIZE; ++i)
+    isNull &= (uuid[i] == 0);
+  return isNull;
 }
 
 
 void datetime2str(int date, int time, char *datetimestr, int maxlen)
 {
   int year, month, day;
-  int hour, minute, second;
-  int len;
-
   cdiDecodeDate(date, &year, &month, &day);
+  int hour, minute, second;
   cdiDecodeTime(time, &hour, &minute, &second);
 
-  len = sprintf(datetimestr, DATE_FORMAT "T" TIME_FORMAT, year, month, day, hour, minute, second);
-
+  int len = sprintf(datetimestr, DATE_FORMAT "T" TIME_FORMAT, year, month, day, hour, minute, second);
   if ( len > ( maxlen-1) )
     fprintf(stderr, "Internal problem (%s): sizeof input string is too small!\n", __func__);
 }
@@ -30,12 +31,9 @@ void datetime2str(int date, int time, char *datetimestr, int maxlen)
 void date2str(int date, char *datestr, int maxlen)
 {
   int year, month, day;
-  int len;
-
   cdiDecodeDate(date, &year, &month, &day);
 
-  len = sprintf(datestr, DATE_FORMAT, year, month, day);
-
+  int len = sprintf(datestr, DATE_FORMAT, year, month, day);
   if ( len > ( maxlen-1) )
     fprintf(stderr, "Internal problem (%s): sizeof input string is too small!\n", __func__);
 }
@@ -44,12 +42,9 @@ void date2str(int date, char *datestr, int maxlen)
 void time2str(int time, char *timestr, int maxlen)
 {
   int hour, minute, second;
-  int len;
-
   cdiDecodeTime(time, &hour, &minute, &second);
 
-  len = sprintf(timestr, TIME_FORMAT, hour, minute, second);
-
+  int len = sprintf(timestr, TIME_FORMAT, hour, minute, second);
   if ( len > ( maxlen-1) )
     fprintf(stderr, "Internal problem (%s): sizeof input string is too small!\n", __func__);
 }
@@ -57,9 +52,7 @@ void time2str(int time, char *timestr, int maxlen)
 
 void printFiletype(int streamID, int vlistID)
 {
-  int filetype;
-
-  filetype = streamInqFiletype(streamID);
+  int filetype = streamInqFiletype(streamID);
 
   switch ( filetype )
     {
@@ -132,12 +125,9 @@ void printFiletype(int streamID, int vlistID)
 
   if ( filetype == FILETYPE_GRB2 )
     {
-      int nvars, varID;
       int comptype;
-
-      nvars = vlistNvars(vlistID);
-
-      for ( varID = 0; varID < nvars; varID++ )
+      int nvars = vlistNvars(vlistID);
+      for ( int varID = 0; varID < nvars; varID++ )
 	{
 	  comptype = vlistInqVarCompType(vlistID, varID);
 	  if ( comptype )
@@ -407,14 +397,13 @@ void printGridInfo(int vlistID)
 static
 void printZaxisInfo(int vlistID)
 {
-  int nzaxis, index;
   int zaxisID, zaxistype, levelsize, levelID;
   int ltype;
   double *levels = NULL;
   char zaxisname[CDI_MAX_NAME], zname[CDI_MAX_NAME], zunits[CDI_MAX_NAME];
 
-  nzaxis = vlistNzaxis(vlistID);
-  for ( index = 0; index < nzaxis; index++)
+  int nzaxis = vlistNzaxis(vlistID);
+  for ( int index = 0; index < nzaxis; index++)
     {
       double zfirst = 0, zlast = 0, zinc = 0;
       zaxisID   = vlistZaxis(vlistID, index);
@@ -483,6 +472,21 @@ void printZaxisInfo(int vlistID)
           fprintf(stdout, "\n");
         }
 
+      if ( zaxistype == ZAXIS_HYBRID )
+        {
+          char psname[CDI_MAX_NAME];
+          psname[0] = 0;
+          zaxisInqPsName(zaxisID, psname);
+          int vctsize = zaxisInqVctSize(zaxisID);
+          if ( vctsize || psname[0] )
+            {
+	      fprintf(stdout, "%33s :", "available");
+              if ( vctsize   ) fprintf(stdout, " vct");
+              if ( psname[0] ) fprintf(stdout, "  ps: %s", psname);
+              fprintf(stdout, "\n");
+            }
+        }
+
       if ( zaxistype == ZAXIS_REFERENCE )
         {
           int number   = zaxisInqNumber(zaxisID);
@@ -509,6 +513,20 @@ void printZaxisInfo(int vlistID)
     }
 }
 
+static
+void printSubtypeInfo(int vlistID)
+{
+  int nsubtypes = vlistNsubtypes(vlistID);
+  for ( int index = 0; index < nsubtypes; index++)
+    {
+      int subtypeID = vlistSubtype(vlistID, index);
+      int subtypesize = subtypeInqSize(subtypeID);
+      // subtypePrint(subtypeID);
+      fprintf(stdout, "  %4d : %-24s :", vlistSubtypeIndex(vlistID, subtypeID)+1, "tiles");
+      fprintf(stdout, " ntiles=%d", subtypesize);
+      fprintf(stdout, "\n");
+    }
+}
 
 static
 int printDateTime(int ntimeout, int vdate, int vtime)
@@ -535,7 +553,6 @@ int printDateTime(int ntimeout, int vdate, int vtime)
 static
 int printDot(int ndotout, int *nfact, int *ncout)
 {
-
   //printf("ncout %d %d %d\n",*ncout, (*ncout)%(*nfact), *nfact);
   if ( (*ncout)%(*nfact) == 0 )
     {
@@ -554,7 +571,7 @@ int printDot(int ndotout, int *nfact, int *ncout)
 
   (*ncout)++;
 
-  return (ndotout);
+  return ndotout;
 }
 
 static
@@ -616,10 +633,13 @@ void printTimesteps(int streamID, int taxisID, int verbose)
       fprintf(stdout, "\n");
 
       ntimeout = 0;
-      int toff = tsID%4;
-      if ( toff > 0 ) toff = 4 - toff;
-      for ( int i = 0; i < toff; ++i ) next_vdatetime = next_vdatetime->next;
-
+      int toff = 0;
+      if ( tsID > 2*NUM_TIMESTEP )
+        {
+          toff = tsID%4;
+          if ( toff > 0 ) toff = 4 - toff;
+          for ( int i = 0; i < toff; ++i ) next_vdatetime = next_vdatetime->next;
+        }
       for ( int i = toff; i < nvdatetime; ++i )
 	{
 	  vdate = next_vdatetime->vdate;
diff --git a/src/process.c b/src/process.c
index 4def4b8..a6b4af6 100644
--- a/src/process.c
+++ b/src/process.c
@@ -100,13 +100,11 @@ pthread_mutex_t processMutex = PTHREAD_MUTEX_INITIALIZER;
 
 int processCreate(void)
 {
-  int processID;
-
 #if defined(HAVE_LIBPTHREAD)
   pthread_mutex_lock(&processMutex);
 #endif
 
-  processID = NumProcess++;
+  int processID = NumProcess++;
   NumProcessActive++;
 
 #if defined(HAVE_LIBPTHREAD)
@@ -135,7 +133,7 @@ int processCreate(void)
 
   Process[processID].noper        = 0;
 
-  return (processID);
+  return processID;
 }
 
 
@@ -163,7 +161,7 @@ int processSelf(void)
 
 #endif
 
-  return (processID);
+  return processID;
 }
 
 
@@ -179,7 +177,7 @@ int processNums(void)
   pthread_mutex_unlock(&processMutex);  
 #endif
 
-  return (pnums);
+  return pnums;
 }
 
 
@@ -195,7 +193,7 @@ int processNumsActive(void)
   pthread_mutex_unlock(&processMutex);  
 #endif
 
-  return (pnums);
+  return pnums;
 }
 
 
@@ -209,20 +207,19 @@ void processAddNvals(off_t nvals)
 
 off_t processInqNvals(int processID)
 {
-  return (Process[processID].nvals);
+  return Process[processID].nvals;
 }
 
 
 void processAddStream(int streamID)
 {
   int processID = processSelf();
-  int sindex;
 
   if ( pstreamIsPipe(streamID) ) Process[processID].nchild++;
-  sindex = Process[processID].nstream++;
+  int sindex = Process[processID].nstream++;
 
   if ( sindex >= MAX_STREAM )
-    Error("limit of %d streams per process reached (processID = %d)!", MAX_STREAM, processID);
+    Error("Limit of %d streams per process reached (processID = %d)!", MAX_STREAM, processID);
 
   Process[processID].streams[sindex] = streamID;
 }
@@ -230,6 +227,7 @@ void processAddStream(int streamID)
 
 void processDelStream(int streamID)
 {
+  UNUSED(streamID);
 }
 
 
@@ -241,7 +239,7 @@ void processDefCputime(int processID, double cputime)
 
 double processInqCputime(int processID)
 {
-  return (Process[processID].cputime);
+  return Process[processID].cputime;
 }
 
 
@@ -272,7 +270,7 @@ int processInqStreamNum(void)
 {
   int processID = processSelf();
 
-  return (Process[processID].nstream);
+  return Process[processID].nstream;
 }
 
 
@@ -280,7 +278,7 @@ int processInqChildNum(void)
 {
   int processID = processSelf();
 
-  return (Process[processID].nchild);
+  return Process[processID].nchild;
 }
 
 
@@ -294,7 +292,7 @@ int processInqStreamID(int streamindex)
 
 const char *processInqOpername2(int processID)
 {
-  return (Process[processID].operatorName);
+  return Process[processID].operatorName;
 }
 
 
@@ -302,7 +300,7 @@ const char *processInqOpername(void)
 {
   int processID = processSelf();
 
-  return (Process[processID].operatorName);
+  return Process[processID].operatorName;
 }
 
 
@@ -321,7 +319,10 @@ const char *processInqPrompt(void)
 {
   int processID = processSelf();
 
-  return (Process[processID].prompt);
+  const char *prompt = "cdo";
+  if (Process[processID].prompt[0] ) prompt = Process[processID].prompt;
+
+  return prompt;
 }
 
 #if defined(HAVE_GLOB_H)
@@ -337,7 +338,7 @@ int get_glob_flags(void)
   glob_flags |= GLOB_TILDE;
 #endif
 
-  return (glob_flags);
+  return glob_flags;
 }
 #endif
 
@@ -382,11 +383,10 @@ argument_t *glob_pattern(const char *restrict string)
 int cdoStreamCnt(void)
 {
   int processID = processSelf();
-  int cnt;
 
-  cnt = Process[processID].streamCnt;
+  int cnt = Process[processID].streamCnt;
 
-  return (cnt);
+  return cnt;
 }
 
 
@@ -397,7 +397,7 @@ const argument_t *cdoStreamName(int cnt)
   if ( cnt > Process[processID].streamCnt || cnt < 0 )
     Error("count %d out of range!", cnt);
 
-  return (&(Process[processID].streamNames[cnt]));
+  return &(Process[processID].streamNames[cnt]);
 }
 
 
@@ -405,32 +405,30 @@ const char *processOperator(void)
 {
   int processID = processSelf();
 
-  return (Process[processID].xoperator);
+  return Process[processID].xoperator;
 }
 
 static
 char *getOperatorArg(const char *xoperator)
 {
-  char *commapos;
   char *operatorArg = NULL;
-  size_t len;
 
   if ( xoperator )
     {
-      commapos = strchr(xoperator, ',');
+      char *commapos = (char *)strchr(xoperator, ',');
 
       if ( commapos )
         {
-          len = strlen(commapos+1);
+          size_t len = strlen(commapos+1);
           if ( len )
             {
-              operatorArg = (char*) malloc(len+1);
+              operatorArg = (char*) Malloc(len+1);
               strcpy(operatorArg, commapos+1);
             }
         }
     }
 
-  return (operatorArg);
+  return operatorArg;
 }
 
 static int skipInputStreams(int argc, char *argv[], int globArgc, int nstreams);
@@ -438,17 +436,12 @@ static int skipInputStreams(int argc, char *argv[], int globArgc, int nstreams);
 static
 int getGlobArgc(int argc, char *argv[], int globArgc)
 {
-  int streamInCnt;
-  int streamOutCnt;
-  char *opername;
-  char *comma_position;
-
-  opername = &argv[globArgc][1];
-  comma_position = strchr(opername, ',');
+  char *opername = &argv[globArgc][1];
+  char *comma_position = strchr(opername, ',');
   if ( comma_position ) *comma_position = 0;
 
-  streamInCnt  = operatorStreamInCnt(opername);
-  streamOutCnt = operatorStreamOutCnt(opername);
+  int streamInCnt  = operatorStreamInCnt(opername);
+  int streamOutCnt = operatorStreamOutCnt(opername);
 
   if ( streamInCnt == -1 ) streamInCnt = 1;
 
@@ -461,7 +454,7 @@ int getGlobArgc(int argc, char *argv[], int globArgc)
     globArgc = skipInputStreams(argc, argv, globArgc, streamInCnt);
   if ( comma_position ) *comma_position = ',';
 
-  return (globArgc);
+  return globArgc;
 }
 
 static
@@ -484,7 +477,7 @@ int skipInputStreams(int argc, char *argv[], int globArgc, int nstreams)
       nstreams--;
     }
 
-  return (globArgc);
+  return globArgc;
 }
 
 static
@@ -505,7 +498,7 @@ int getStreamCnt(int argc, char *argv[])
       streamCnt++;
     }
 
-  return (streamCnt);
+  return streamCnt;
 }
 
 static
@@ -527,7 +520,7 @@ void setStreamNames(int argc, char *argv[])
           globArgc = getGlobArgc(argc, argv, globArgc);
           len = 0;
           for ( i = globArgcStart; i < globArgc; i++ ) len += strlen(argv[i]) + 1;
-          streamname = (char*) calloc(1, len);
+          streamname = (char*) Calloc(1, len);
           for ( i = globArgcStart; i < globArgc; i++ )
             {
               strcat(streamname, argv[i]);
@@ -537,7 +530,7 @@ void setStreamNames(int argc, char *argv[])
           Process[processID].streamNames[Process[processID].streamCnt].args = streamname;
           ac = globArgc - globArgcStart;
           //printf("setStreamNames:  ac %d  streamname1: %s\n", ac, streamname);
-          Process[processID].streamNames[Process[processID].streamCnt].argv = (char **) malloc(ac*sizeof(char *));
+          Process[processID].streamNames[Process[processID].streamCnt].argv = (char **) Malloc(ac*sizeof(char *));
           for ( i = 0; i < ac; ++i )
             Process[processID].streamNames[Process[processID].streamCnt].argv[i] = argv[i+globArgcStart];
           Process[processID].streamNames[Process[processID].streamCnt].argc = ac;
@@ -547,11 +540,11 @@ void setStreamNames(int argc, char *argv[])
       else
         {
           len = strlen(argv[globArgc]) + 1;
-          streamname = (char*) malloc(len);
+          streamname = (char*) Malloc(len);
           strcpy(streamname, argv[globArgc]);
           Process[processID].streamNames[Process[processID].streamCnt].args = streamname;
           ac = 1;
-          Process[processID].streamNames[Process[processID].streamCnt].argv = (char **) malloc(ac*sizeof(char *));
+          Process[processID].streamNames[Process[processID].streamCnt].argv = (char **) Malloc(ac*sizeof(char *));
           Process[processID].streamNames[Process[processID].streamCnt].argv[0] = argv[globArgc];
           Process[processID].streamNames[Process[processID].streamCnt].argc = ac;
           Process[processID].streamNames[Process[processID].streamCnt].args = streamname;
@@ -625,10 +618,10 @@ int expand_wildcards(int processID, int streamCnt)
       int i;
       streamCnt = streamCnt - 1 + glob_arg->argc;
 
-      free(Process[processID].streamNames[0].argv);
-      free(Process[processID].streamNames[0].args);
+      Free(Process[processID].streamNames[0].argv);
+      Free(Process[processID].streamNames[0].args);
 
-      Process[processID].streamNames = (argument_t*) realloc(Process[processID].streamNames, streamCnt*sizeof(argument_t));
+      Process[processID].streamNames = (argument_t*) Realloc(Process[processID].streamNames, streamCnt*sizeof(argument_t));
           
       // move output streams to the end
       for ( i = 1; i < Process[processID].streamCnt; ++i )
@@ -636,7 +629,7 @@ int expand_wildcards(int processID, int streamCnt)
 
       for ( i = 0; i < glob_arg->argc; ++i )
         {
-          Process[processID].streamNames[i].argv    = (char **) malloc(sizeof(char *));
+          Process[processID].streamNames[i].argv    = (char **) Malloc(sizeof(char *));
           Process[processID].streamNames[i].argc    = 1;
           Process[processID].streamNames[i].argv[0] = strdupx(glob_arg->argv[i]);
           Process[processID].streamNames[i].args    = strdupx(glob_arg->argv[i]);
@@ -645,7 +638,7 @@ int expand_wildcards(int processID, int streamCnt)
       Process[processID].streamCnt = streamCnt;
     }
 
-  free(glob_arg);
+  Free(glob_arg);
 #endif
 
   return 1;
@@ -721,18 +714,14 @@ int checkStreamCnt(void)
   if ( streamInCnt == 1 && streamInCnt0 == -1 )
     status = expand_wildcards(processID, streamCnt);
 
-  return (status);
+  return status;
 }
 
 static
 void setStreams(int argc, char *argv[])
 {
   int processID = processSelf();
-  int streamCnt;
-  int status;
-  int i;
-
-  streamCnt = getStreamCnt(argc, argv);
+  int streamCnt = getStreamCnt(argc, argv);
 
   Process[processID].nvals = 0;
   Process[processID].nvars = 0;
@@ -740,8 +729,8 @@ void setStreams(int argc, char *argv[])
 
   Process[processID].streamCnt  = 0; /* filled in setStreamNames */
   if ( streamCnt )
-    Process[processID].streamNames = (argument_t*) malloc(streamCnt*sizeof(argument_t));
-  for ( i = 0; i < streamCnt; i++ )
+    Process[processID].streamNames = (argument_t*) Malloc(streamCnt*sizeof(argument_t));
+  for ( int i = 0; i < streamCnt; i++ )
     {
       Process[processID].streamNames[i].argc = 0;
       Process[processID].streamNames[i].argv = NULL;
@@ -750,7 +739,7 @@ void setStreams(int argc, char *argv[])
 
   setStreamNames(argc, argv);
 
-  status = checkStreamCnt();
+  int status = checkStreamCnt();
 
   if ( status == 0 && Process[processID].streamCnt != streamCnt )
     Error("Internal problem with stream count %d %d", Process[processID].streamCnt, streamCnt);
@@ -806,6 +795,7 @@ void processDefVarNum(int nvars, int streamID)
 {
   int processID = processSelf();
 
+  UNUSED(streamID);
   /*  if ( streamID == Process[processID].streams[0] ) */
     Process[processID].nvars += nvars;
 }
@@ -815,13 +805,15 @@ int processInqVarNum(void)
 {
   int processID = processSelf();
 
-  return (Process[processID].nvars);
+  return Process[processID].nvars;
 }
 
 
 void processDefTimesteps(int streamID)
 {
   int processID = processSelf();
+  
+  UNUSED(streamID);
   /*
   int i;
   printf("streamID %d %d %d %d\n", streamID, Process[processID].streams[0], Process[processID].streams[1], processID);
@@ -838,7 +830,7 @@ int processInqTimesteps(void)
 {
   int processID = processSelf();
 
-  return (Process[processID].ntimesteps);
+  return Process[processID].ntimesteps;
 }
 
 
@@ -864,7 +856,7 @@ int operatorArgc(void)
 {
   int processID = processSelf();
 
-  return (Process[processID].oargc);
+  return Process[processID].oargc;
 }
 
 
@@ -872,7 +864,7 @@ char **operatorArgv(void)
 {
   int processID = processSelf();
 
-  return (Process[processID].oargv);
+  return Process[processID].oargv;
 }
 
 
@@ -891,9 +883,8 @@ void operatorCheckArgc(int numargs)
 void operatorInputArg(const char *enter)
 {
   int processID = processSelf();
-  int oargc;
 
-  oargc = Process[processID].oargc;
+  int oargc = Process[processID].oargc;
 
   if ( oargc == 0 )
     {
@@ -934,7 +925,7 @@ void operatorInputArg(const char *enter)
                   while ( pline[len] != ' '  && pline[len] != ',' &&
                           pline[len] != '\\' && len < linelen ) len++;
 
-                  Process[processID].oargv[oargc] = (char*) malloc(len+1);
+                  Process[processID].oargv[oargc] = (char*) Malloc(len+1);
                   memcpy(Process[processID].oargv[oargc], pline, len);
                   Process[processID].oargv[oargc][len] = '\0';
                   oargc++;
@@ -956,21 +947,17 @@ int cdoOperatorAdd(const char *name, int f1, int f2, const char *enter)
   int processID = processSelf();
   int operID = Process[processID].noper;
 
-  if ( operID < MAX_OPERATOR )
-    {
-      Process[processID].oper[operID].f1     = f1;
-      Process[processID].oper[operID].f2     = f2;
-      Process[processID].oper[operID].name   = name;
-      Process[processID].oper[operID].enter  = enter;
+  if ( operID >= MAX_OPERATOR )
+    cdoAbort("Maximum number of %d operators reached!", MAX_OPERATOR);
 
-      Process[processID].noper++;
-    }
-  else
-    {
-      cdoAbort("Maximum of %d operators reached!", MAX_OPERATOR);
-    }
+  Process[processID].oper[operID].f1     = f1;
+  Process[processID].oper[operID].f2     = f2;
+  Process[processID].oper[operID].name   = name;
+  Process[processID].oper[operID].enter  = enter;
+
+  Process[processID].noper++;
 
-  return (operID);
+  return operID;
 }
 
 
@@ -993,7 +980,7 @@ int cdoOperatorID(void)
       cdoAbort("Operator not initialized!");
     }
 
-  return (operID);
+  return operID;
 }
 
 
@@ -1001,7 +988,7 @@ int cdoOperatorF1(int operID)
 {
   int processID = processSelf();
 
-  return (Process[processID].oper[operID].f1);
+  return Process[processID].oper[operID].f1;
 }
 
 
@@ -1009,7 +996,7 @@ int cdoOperatorF2(int operID)
 {
   int processID = processSelf();
 
-  return (Process[processID].oper[operID].f2);
+  return Process[processID].oper[operID].f2;
 }
 
 
@@ -1017,7 +1004,7 @@ const char *cdoOperatorName(int operID)
 {
   int processID = processSelf();
 
-  return (Process[processID].oper[operID].name);
+  return Process[processID].oper[operID].name;
 }
 
 
@@ -1025,7 +1012,7 @@ const char *cdoOperatorEnter(int operID)
 {
   int processID = processSelf();
 
-  return (Process[processID].oper[operID].enter);
+  return Process[processID].oper[operID].enter;
 }
 
 
@@ -1033,5 +1020,5 @@ int cdoStreamNumber()
 {
   int processID = processSelf();
 
-  return (operatorStreamNumber(Process[processID].operatorName));
+  return operatorStreamNumber(Process[processID].operatorName);
 }
diff --git a/src/pstream.c b/src/pstream.c
index 9e3f028..9c222e5 100644
--- a/src/pstream.c
+++ b/src/pstream.c
@@ -35,7 +35,6 @@ int pclose(FILE *stream);
 #include <cdi.h>
 #include "cdo.h"
 #include "cdo_int.h"
-#include "dtypes.h"
 #include "modules.h"
 #include "pstream_int.h"
 #include "cdo_int.h"
@@ -100,19 +99,19 @@ void pstream_list_new(void)
 {
   assert(_pstreamList == NULL);
 
-  _pstreamList = (pstreamPtrToIdx*) malloc(_pstream_max*sizeof(pstreamPtrToIdx));
+  _pstreamList = (pstreamPtrToIdx*) Malloc(_pstream_max*sizeof(pstreamPtrToIdx));
 }
 
 static
 void pstream_list_delete(void)
 {
-  if ( _pstreamList ) free(_pstreamList);
+  if ( _pstreamList ) Free(_pstreamList);
 }
 
 static
 void pstream_init_pointer(void)
 {  
-  for ( int i = 0; i < _pstream_max; i++ )
+  for ( int i = 0; i < _pstream_max; ++i )
     {
       _pstreamList[i].next = _pstreamList + i + 1;
       _pstreamList[i].idx  = i;
@@ -149,8 +148,7 @@ pstream_t *pstream_to_pointer(int idx)
 static
 int pstream_from_pointer(pstream_t *ptr)
 {
-  int      idx = -1;
-  pstreamPtrToIdx *newptr;
+  int idx = -1;
 
   if ( ptr )
     {
@@ -158,7 +156,7 @@ int pstream_from_pointer(pstream_t *ptr)
 
       if ( _pstreamAvail )
 	{
-	  newptr        = _pstreamAvail;
+	  pstreamPtrToIdx *newptr = _pstreamAvail;
 	  _pstreamAvail = _pstreamAvail->next;
 	  newptr->next  = 0;
 	  idx	        = newptr->idx;
@@ -208,9 +206,7 @@ void pstream_init_entry(pstream_t *pstreamptr)
 static
 pstream_t *pstream_new_entry(void)
 {
-  pstream_t *pstreamptr;
-
-  pstreamptr = (pstream_t*) malloc(sizeof(pstream_t));
+  pstream_t *pstreamptr = (pstream_t*) Malloc(sizeof(pstream_t));
 
   if ( pstreamptr ) pstream_init_entry(pstreamptr);
 
@@ -220,13 +216,11 @@ pstream_t *pstream_new_entry(void)
 static
 void pstream_delete_entry(pstream_t *pstreamptr)
 {
-  int idx;
-
-  idx = pstreamptr->self;
+  int idx = pstreamptr->self;
 
   PSTREAM_LOCK();
 
-  free(pstreamptr);
+  Free(pstreamptr);
 
   _pstreamList[idx].next = _pstreamAvail;
   _pstreamList[idx].ptr  = 0;
@@ -241,14 +235,12 @@ void pstream_delete_entry(pstream_t *pstreamptr)
 static
 void pstream_initialize(void)
 {
-  char *env;
-
 #if defined(HAVE_LIBPTHREAD)
   /* initialize global API mutex lock */
   pthread_mutex_init(&_pstream_mutex, NULL);
 #endif
 
-  env = getenv("PSTREAM_DEBUG");
+  char *env = getenv("PSTREAM_DEBUG");
   if ( env ) PSTREAM_Debug = atoi(env);
 
   env = getenv("PSTREAM_MAX");
@@ -268,10 +260,10 @@ void pstream_initialize(void)
 static
 int pstreamFindID(const char *name)
 {
-  int pstreamID;
   pstream_t *pstreamptr;
+  int pstreamID;
 
-  for ( pstreamID = 0; pstreamID < _pstream_max; pstreamID++ )
+  for ( pstreamID = 0; pstreamID < _pstream_max; ++pstreamID )
     {
       pstreamptr = pstream_to_pointer(pstreamID);
 
@@ -288,9 +280,7 @@ int pstreamFindID(const char *name)
 
 int pstreamIsPipe(int pstreamID)
 {
-  pstream_t *pstreamptr;
-
-  pstreamptr = pstream_to_pointer(pstreamID);
+  pstream_t *pstreamptr = pstream_to_pointer(pstreamID);
 
   return (pstreamptr->ispipe);
 }
@@ -298,19 +288,14 @@ int pstreamIsPipe(int pstreamID)
 
 int pstreamOpenRead(const argument_t *argument)
 {
-  int ispipe = FALSE;
-  int fileID;
-  int pstreamID;
-  pstream_t *pstreamptr;
-
   PSTREAM_INIT();
 
-  pstreamptr = pstream_new_entry();
+  pstream_t *pstreamptr = pstream_new_entry();
   if ( ! pstreamptr ) Error("No memory");
 
-  pstreamID = pstreamptr->self;
+  int pstreamID = pstreamptr->self;
 
-  ispipe = argument->args[0] == '-';
+  int ispipe = argument->args[0] == '-';
   /*
   printf("pstreamOpenRead: args >%s<\n", argument->args);
   for ( int i = 0; i < argument->argc; ++i )
@@ -322,7 +307,7 @@ int pstreamOpenRead(const argument_t *argument)
       char *operatorArg;
       char *operatorName;
       char *newarg;
-      char *pipename = (char*) malloc(16);
+      char *pipename = (char*) Malloc(16);
       int rval;
       pthread_t thrID;
       pthread_attr_t attr;
@@ -330,17 +315,17 @@ int pstreamOpenRead(const argument_t *argument)
       size_t len;
       size_t stacksize;
       int status;
-      argument_t *newargument = (argument_t*) malloc(sizeof(argument_t));
+      argument_t *newargument = (argument_t*) Malloc(sizeof(argument_t));
 
       newargument->argc = argument->argc + 1;
-      newargument->argv = (char **) malloc(newargument->argc*sizeof(char *));
+      newargument->argv = (char **) Malloc(newargument->argc*sizeof(char *));
       memcpy(newargument->argv, argument->argv, argument->argc*sizeof(char *));
 
       operatorArg  = argument->argv[0];
       operatorName = getOperatorName(operatorArg);
 
       len = strlen(argument->args);
-      newarg = (char*) malloc(len+16);
+      newarg = (char*) Malloc(len+16);
       strcpy(newarg, argument->args);
       sprintf(pipename, "(pipe%d.%d)", processSelf() + 1, processInqChildNum() + 1);
       newarg[len] = ' ';
@@ -363,21 +348,21 @@ int pstreamOpenRead(const argument_t *argument)
 	cdoPrint("Started child process \"%s\".", newarg+1);
 
       status = pthread_attr_init(&attr);
-      if ( status ) SysError("pthread_attr_init failed for '%s'\n", newarg+1);
+      if ( status ) SysError("pthread_attr_init failed for '%s'", newarg+1);
       status = pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_JOINABLE);
-      if ( status ) SysError("pthread_attr_setdetachstate failed for '%s'\n", newarg+1);
+      if ( status ) SysError("pthread_attr_setdetachstate failed for '%s'", newarg+1);
       /*
       param.sched_priority = 0;
       status = pthread_attr_setschedparam(&attr, &param);
-      if ( status ) SysError("pthread_attr_setschedparam failed for '%s'\n", newarg+1);
+      if ( status ) SysError("pthread_attr_setschedparam failed for '%s'", newarg+1);
       */
       /* status = pthread_attr_setinheritsched(&attr, PTHREAD_EXPLICIT_SCHED); */
-      /* if ( status ) SysError("pthread_attr_setinheritsched failed for '%s'\n", newarg+1); */
+      /* if ( status ) SysError("pthread_attr_setinheritsched failed for '%s'", newarg+1); */
 
       pthread_attr_getscope(&attr, &pthreadScope);
 
       /* status = pthread_attr_setscope(&attr, PTHREAD_SCOPE_PROCESS); */
-      /* if ( status ) SysError("pthread_attr_setscope failed for '%s'\n", newarg+1); */
+      /* if ( status ) SysError("pthread_attr_setscope failed for '%s'", newarg+1); */
       /* If system scheduling scope is specified, then the thread is scheduled against all threads in the system */
       /* pthread_attr_setscope(&attr, PTHREAD_SCOPE_SYSTEM); */
 
@@ -392,10 +377,10 @@ int pstreamOpenRead(const argument_t *argument)
       if ( rval != 0 )
 	{
 	  errno = rval;
-	  SysError("pthread_create failed for '%s'\n", newarg+1);
+	  SysError("pthread_create failed for '%s'", newarg+1);
 	}
 
-      /* free(operatorName); */
+      /* Free(operatorName); */
       processAddStream(pstreamID);
       /*      pipeInqInfo(pstreamID); */
       if ( PSTREAM_Debug ) Message("pipe %s", pipename);
@@ -451,7 +436,7 @@ int pstreamOpenRead(const argument_t *argument)
 		  if ( nfiles == 0 ) cdoAbort("No imput file found in %s", pch);
 
 		  pstreamptr->mfiles = nfiles;
-		  pstreamptr->mfnames = (char **) malloc(nfiles*sizeof(char *));
+		  pstreamptr->mfnames = (char **) Malloc(nfiles*sizeof(char *));
 		  
 		  rewind(fp);
 
@@ -472,7 +457,7 @@ int pstreamOpenRead(const argument_t *argument)
 		  char line[65536];
 
 		  pstreamptr->mfiles = nfiles;
-		  pstreamptr->mfnames = (char **) malloc(nfiles*sizeof(char *));
+		  pstreamptr->mfnames = (char **) Malloc(nfiles*sizeof(char *));
 		  
 		  strcpy(line, pch);
 		  for ( i = 0; i < len; i++ ) if ( line[i] == ',' ) line[i] = 0;
@@ -509,7 +494,7 @@ int pstreamOpenRead(const argument_t *argument)
 	      pclose(pfp);
 
 	      pstreamptr->mfiles = nfiles;
-	      pstreamptr->mfnames = (char **) malloc(nfiles*sizeof(char *));
+	      pstreamptr->mfnames = (char **) Malloc(nfiles*sizeof(char *));
 
 	      for ( j = 0; j < nfiles; j++ )
 		pstreamptr->mfnames[j] = fnames[j];
@@ -519,14 +504,14 @@ int pstreamOpenRead(const argument_t *argument)
       if ( pstreamptr->mfiles )
 	{
 	  len = strlen(pstreamptr->mfnames[0]);
-	  filename = (char*) malloc(len+1);
+	  filename = (char*) Malloc(len+1);
 	  strcpy(filename, pstreamptr->mfnames[0]);
 	  pstreamptr->nfiles = 1;
 	}
       else
 	{
 	  len = strlen(argument->args);
-	  filename = (char*) malloc(len+1);
+	  filename = (char*) Malloc(len+1);
 	  strcpy(filename, argument->args);
 	}
 
@@ -538,7 +523,7 @@ int pstreamOpenRead(const argument_t *argument)
       else
 	pthread_mutex_lock(&streamOpenReadMutex);
 #endif
-      fileID = streamOpenRead(filename);
+      int fileID = streamOpenRead(filename);
       if ( fileID < 0 ) cdiOpenError(fileID, "Open failed on >%s<", filename);
 
       if ( cdoDefaultFileType == CDI_UNDEFID )
@@ -626,14 +611,12 @@ void query_user_exit(const char *argument)
 
 int pstreamOpenWrite(const argument_t *argument, int filetype)
 {
-  int fileID;
   int pstreamID = -1;
-  int ispipe;
   pstream_t *pstreamptr;
 
   PSTREAM_INIT();
 
-  ispipe = strncmp(argument->args, "(pipe", 5) == 0;
+  int ispipe = strncmp(argument->args, "(pipe", 5) == 0;
 
   if ( ispipe )
     {
@@ -651,7 +634,7 @@ int pstreamOpenWrite(const argument_t *argument, int filetype)
     }
   else
     {
-      char *filename = (char*) malloc(strlen(argument->args)+1);
+      char *filename = (char*) Malloc(strlen(argument->args)+1);
 
       pstreamptr = pstream_new_entry();
       if ( ! pstreamptr ) Error("No memory");
@@ -679,7 +662,7 @@ int pstreamOpenWrite(const argument_t *argument, int filetype)
       else
 	pthread_mutex_lock(&streamOpenWriteMutex);
 #endif
-      fileID = streamOpenWrite(argument->args, filetype);
+      int fileID = streamOpenWrite(argument->args, filetype);
 #if defined(HAVE_LIBPTHREAD)
       if ( cdoLockIO )
 	pthread_mutex_unlock(&streamMutex);
@@ -741,12 +724,9 @@ int pstreamOpenWrite(const argument_t *argument, int filetype)
 
 int pstreamOpenAppend(const argument_t *argument)
 {
-  int fileID;
   int pstreamID = -1;
-  int ispipe;
-  pstream_t *pstreamptr;
 
-  ispipe = strncmp(argument->args, "(pipe", 5) == 0;
+  int ispipe = strncmp(argument->args, "(pipe", 5) == 0;
 
   if ( ispipe )
     {
@@ -755,9 +735,9 @@ int pstreamOpenAppend(const argument_t *argument)
     }
   else
     {
-      char *filename = (char*) malloc(strlen(argument->args)+1);
+      char *filename = (char*) Malloc(strlen(argument->args)+1);
 
-      pstreamptr = pstream_new_entry();
+      pstream_t *pstreamptr = pstream_new_entry();
       if ( ! pstreamptr ) Error("No memory");
 
       pstreamID = pstreamptr->self;
@@ -771,7 +751,7 @@ int pstreamOpenAppend(const argument_t *argument)
       else
 	pthread_mutex_lock(&streamOpenReadMutex);
 #endif
-      fileID = streamOpenAppend(argument->args);
+      int fileID = streamOpenAppend(argument->args);
 #if defined(HAVE_LIBPTHREAD)
       if ( cdoLockIO )
 	pthread_mutex_unlock(&streamMutex);
@@ -797,9 +777,7 @@ int pstreamOpenAppend(const argument_t *argument)
 
 void pstreamClose(int pstreamID)
 {
-  pstream_t *pstreamptr;
-
-  pstreamptr = pstream_to_pointer(pstreamID);
+  pstream_t *pstreamptr = pstream_to_pointer(pstreamID);
 
   if ( pstreamptr == NULL )
     Error("Internal problem, stream %d not open!", pstreamID);
@@ -835,13 +813,13 @@ void pstreamClose(int pstreamID)
 	  pthread_join(pstreamptr->wthreadID, NULL);
 
 	  pthread_mutex_lock(pipe->mutex);
-	  if ( pstreamptr->name ) free(pstreamptr->name);
+	  if ( pstreamptr->name ) Free(pstreamptr->name);
 	  if ( pstreamptr->argument )
 	    {
 	      argument_t *argument = (argument_t *) (pstreamptr->argument);
-	      if ( argument->argv ) free(argument->argv);
-	      if ( argument->args ) free(argument->args);
-	      free(argument);
+	      if ( argument->argv ) Free(argument->argv);
+	      if ( argument->args ) Free(argument->args);
+	      Free(argument);
 	    }
 	  vlistDestroy(pstreamptr->vlistID);
 	  pthread_mutex_unlock(pipe->mutex);
@@ -878,7 +856,7 @@ void pstreamClose(int pstreamID)
   else
     {
       if ( PSTREAM_Debug )
-	Message("%s fileID %d\n", pstreamptr->name, pstreamptr->fileID);
+	Message("%s fileID %d", pstreamptr->name, pstreamptr->fileID);
 
       if ( pstreamptr->mode == 'r' )
 	{
@@ -906,13 +884,13 @@ void pstreamClose(int pstreamID)
 
       if ( pstreamptr->name )
 	{
-	  free(pstreamptr->name);
+	  Free(pstreamptr->name);
 	  pstreamptr->name = NULL;
 	}
 
       if ( pstreamptr->varlist )
 	{
-	  free(pstreamptr->varlist);
+	  Free(pstreamptr->varlist);
 	  pstreamptr->varlist = NULL;
 	}
 
@@ -923,10 +901,9 @@ void pstreamClose(int pstreamID)
 
 int pstreamInqVlist(int pstreamID)
 {
-  int vlistID;
-  pstream_t *pstreamptr;
+  pstream_t *pstreamptr = pstream_to_pointer(pstreamID);
 
-  pstreamptr = pstream_to_pointer(pstreamID);
+  int vlistID = -1;
 
 #if defined(HAVE_LIBPTHREAD)
   if ( pstreamptr->ispipe )
@@ -948,6 +925,10 @@ int pstreamInqVlist(int pstreamID)
 #endif
       if ( processNums() == 1 && ompNumThreads == 1 ) timer_stop(timer_read);
 
+      int nsubtypes = vlistNsubtypes(vlistID);
+      if ( nsubtypes > 0 )
+        cdoWarning("Subtypes are unsupported, the processing results are possibly wrong!");
+
       if ( cdoDefaultTimeType != CDI_UNDEFID )
 	taxisDefType(vlistInqTaxis(vlistID), cdoDefaultTimeType);
 
@@ -962,38 +943,13 @@ int pstreamInqVlist(int pstreamID)
 
   processDefVarNum(vlistNvars(vlistID), pstreamID);
 
-  return (vlistID);
-}
-
-static
-const char *cdoComment(void)
-{
-  static char comment[256];
-  static int init = 0;
-  int size = 0;
-
-  if ( ! init )
-    {
-      init = 1;
-
-      size = strlen(CDO_Version);
-
-      strncat(comment, CDO_Version, size);
-      comment[size] = 0;
-    }
-
-  return (comment);
+  return vlistID;
 }
 
 static
 void pstreamDefVarlist(pstream_t *pstreamptr, int vlistID)
 {
-  int varID, nvars;
-  int laddoffset, lscalefactor;
-  int datatype, filetype;
-  varlist_t *varlist;
-
-  filetype = pstreamptr->filetype;
+  int filetype = pstreamptr->filetype;
 
   if ( pstreamptr->vlistID != -1 )
     cdoAbort("Internal problem, vlist already defined!");
@@ -1001,10 +957,10 @@ void pstreamDefVarlist(pstream_t *pstreamptr, int vlistID)
   if ( pstreamptr->varlist != NULL )
     cdoAbort("Internal problem, varlist already allocated!");
 
-  nvars = vlistNvars(vlistID);
-  varlist = (varlist_t*) malloc(nvars*sizeof(varlist_t));
+  int nvars = vlistNvars(vlistID);
+  varlist_t *varlist = (varlist_t*) Malloc(nvars*sizeof(varlist_t));
 
-  for ( varID = 0; varID < nvars; ++varID )
+  for ( int varID = 0; varID < nvars; ++varID )
     {
       varlist[varID].gridsize    = gridInqSize(vlistInqVarGrid(vlistID, varID));
       varlist[varID].datatype    = vlistInqVarDatatype(vlistID, varID);
@@ -1014,10 +970,10 @@ void pstreamDefVarlist(pstream_t *pstreamptr, int vlistID)
 
       varlist[varID].check_datarange = FALSE;
 
-      laddoffset   = IS_NOT_EQUAL(varlist[varID].addoffset, 0);
-      lscalefactor = IS_NOT_EQUAL(varlist[varID].scalefactor, 1);
+      int laddoffset   = IS_NOT_EQUAL(varlist[varID].addoffset, 0);
+      int lscalefactor = IS_NOT_EQUAL(varlist[varID].scalefactor, 1);
 
-      datatype = varlist[varID].datatype;
+      int datatype = varlist[varID].datatype;
 
       if ( filetype == FILETYPE_NC || filetype == FILETYPE_NC2 || filetype == FILETYPE_NC4 || filetype == FILETYPE_NC4C )
 	{
@@ -1055,9 +1011,7 @@ void pstreamDefVarlist(pstream_t *pstreamptr, int vlistID)
 
 void pstreamDefVlist(int pstreamID, int vlistID)
 {
-  pstream_t *pstreamptr;
-
-  pstreamptr = pstream_to_pointer(pstreamID);
+  pstream_t *pstreamptr = pstream_to_pointer(pstreamID);
 
 #if defined(HAVE_LIBPTHREAD)
   if ( pstreamptr->ispipe )
@@ -1094,7 +1048,14 @@ void pstreamDefVlist(int pstreamID, int vlistID)
 	    vlistDefVarChunkType(vlistID, varID, cdoChunkType);
 	}
 
-      vlistDefAttTxt(vlistID, CDI_GLOBAL, "CDO", (int)strlen(cdoComment())+1, cdoComment());
+      if ( CDO_CMOR_Mode )
+        {
+          cdo_def_tracking_id(vlistID, "tracking_id");
+          cdo_def_creation_date(vlistID);
+        }
+
+      if ( CDO_Version_Info )
+        vlistDefAttTxt(vlistID, CDI_GLOBAL, "CDO", (int)strlen(cdoComment())+1, cdoComment());
 
 #if defined(_OPENMP)
       if ( ompNumThreads > 1 )
@@ -1138,7 +1099,7 @@ int pstreamInqRecord(int pstreamID, int *varID, int *levelID)
       if ( processNums() == 1 && ompNumThreads == 1 ) timer_stop(timer_read);
     }
 
-  return (0);
+  return 0;
 }
 
 
@@ -1173,11 +1134,9 @@ void pstreamDefRecord(int pstreamID, int varID, int levelID)
 
 void pstreamReadRecord(int pstreamID, double *data, int *nmiss)
 {
-  pstream_t *pstreamptr;
-
   if ( data == NULL ) cdoAbort("Data pointer not allocated (pstreamReadRecord)!");
 
-  pstreamptr = pstream_to_pointer(pstreamID);
+  pstream_t *pstreamptr = pstream_to_pointer(pstreamID);
 
 #if defined(HAVE_LIBPTHREAD)
   if ( pstreamptr->ispipe )
@@ -1200,21 +1159,16 @@ void pstreamReadRecord(int pstreamID, double *data, int *nmiss)
 
 void pstreamCheckDatarange(pstream_t *pstreamptr, int varID, double *array, int nmiss)
 {
-  long i, ivals, gridsize;
-  int datatype;
-  double missval, addoffset, scalefactor;
-  double arrmin, arrmax, smin, smax;
-  double vmin = 0, vmax = 0;
-
-  gridsize    = pstreamptr->varlist[varID].gridsize;
-  datatype    = pstreamptr->varlist[varID].datatype;
-  missval     = pstreamptr->varlist[varID].missval;
-  addoffset   = pstreamptr->varlist[varID].addoffset;
-  scalefactor = pstreamptr->varlist[varID].scalefactor;
-
-  ivals   = 0;
-  arrmin  =  1.e300;
-  arrmax  = -1.e300;
+  long i;
+  long   gridsize    = pstreamptr->varlist[varID].gridsize;
+  int    datatype    = pstreamptr->varlist[varID].datatype;
+  double missval     = pstreamptr->varlist[varID].missval;
+  double addoffset   = pstreamptr->varlist[varID].addoffset;
+  double scalefactor = pstreamptr->varlist[varID].scalefactor;
+
+  long ivals   = 0;
+  double arrmin  =  1.e300;
+  double arrmax  = -1.e300;
   if ( nmiss > 0 )
     {
       for ( i = 0; i < gridsize; ++i )
@@ -1239,8 +1193,8 @@ void pstreamCheckDatarange(pstream_t *pstreamptr, int varID, double *array, int
 
   if ( ivals > 0 )
     {
-      smin = (arrmin - addoffset)/scalefactor;
-      smax = (arrmax - addoffset)/scalefactor;
+      double smin = (arrmin - addoffset)/scalefactor;
+      double smax = (arrmax - addoffset)/scalefactor;
 
       if ( datatype == DATATYPE_INT8  || datatype == DATATYPE_UINT8 ||
 	   datatype == DATATYPE_INT16 || datatype == DATATYPE_UINT16 )
@@ -1249,6 +1203,8 @@ void pstreamCheckDatarange(pstream_t *pstreamptr, int varID, double *array, int
 	  smax = (int) round(smax);
 	}
 
+      double vmin = 0, vmax = 0;
+
       if      ( datatype == DATATYPE_INT8   ) { vmin =        -128.; vmax =        127.; }
       else if ( datatype == DATATYPE_UINT8  ) { vmin =           0.; vmax =        255.; }
       else if ( datatype == DATATYPE_INT16  ) { vmin =      -32768.; vmax =      32767.; }
@@ -1269,11 +1225,9 @@ void pstreamCheckDatarange(pstream_t *pstreamptr, int varID, double *array, int
 
 void pstreamWriteRecord(int pstreamID, double *data, int nmiss)
 {
-  pstream_t *pstreamptr;
+  if ( data == NULL ) cdoAbort("Data pointer not allocated (%s)!", __func__);
 
-  if ( data == NULL ) cdoAbort("Data pointer not allocated (pstreamWriteRecord)!");
-
-  pstreamptr = pstream_to_pointer(pstreamID);
+  pstream_t *pstreamptr = pstream_to_pointer(pstreamID);
 
 #if defined(HAVE_LIBPTHREAD)
   if ( pstreamptr->ispipe )
@@ -1305,11 +1259,9 @@ void pstreamWriteRecord(int pstreamID, double *data, int nmiss)
 
 void pstreamWriteRecordF(int pstreamID, float *data, int nmiss)
 {
-  pstream_t *pstreamptr;
+  if ( data == NULL ) cdoAbort("Data pointer not allocated (%s)!", __func__);
 
-  if ( data == NULL ) cdoAbort("Data pointer not allocated (pstreamWriteRecord)!");
-
-  pstreamptr = pstream_to_pointer(pstreamID);
+  pstream_t *pstreamptr = pstream_to_pointer(pstreamID);
 
 #if defined(HAVE_LIBPTHREAD)
   if ( pstreamptr->ispipe )
@@ -1341,10 +1293,9 @@ void pstreamWriteRecordF(int pstreamID, float *data, int nmiss)
 
 int pstreamInqTimestep(int pstreamID, int tsID)
 {
-  int nrecs = 0;
-  pstream_t *pstreamptr;
+  pstream_t *pstreamptr = pstream_to_pointer(pstreamID);
 
-  pstreamptr = pstream_to_pointer(pstreamID);
+  int nrecs = 0;
 
 #if defined(HAVE_LIBPTHREAD)
   if ( pstreamptr->ispipe )
@@ -1379,7 +1330,7 @@ int pstreamInqTimestep(int pstreamID, int tsID)
 	  streamClose(pstreamptr->fileID);
 
 	  len = strlen(pstreamptr->mfnames[nfile]);
-	  filename = (char*) malloc(len+1);
+	  filename = (char*) Malloc(len+1);
 	  strcpy(filename, pstreamptr->mfnames[nfile]);
 	  pstreamptr->nfiles++;
 
@@ -1406,7 +1357,7 @@ int pstreamInqTimestep(int pstreamID, int tsID)
 #endif
 	  if ( fileID < 0 ) cdiOpenError(fileID, "Open failed on >%s<", filename);
 
-	  free(pstreamptr->name);
+	  Free(pstreamptr->name);
 
 	  pstreamptr->name   = filename;
 	  pstreamptr->fileID = fileID;
@@ -1438,9 +1389,7 @@ int pstreamInqTimestep(int pstreamID, int tsID)
 
 void pstreamDefTimestep(int pstreamID, int tsID)
 {
-  pstream_t *pstreamptr;
-
-  pstreamptr = pstream_to_pointer(pstreamID);
+  pstream_t *pstreamptr = pstream_to_pointer(pstreamID);
 
 #if defined(HAVE_LIBPTHREAD)
   if ( pstreamptr->ispipe )
@@ -1473,13 +1422,11 @@ void pstreamDefTimestep(int pstreamID, int tsID)
 
 void pstreamCopyRecord(int pstreamIDdest, int pstreamIDsrc)
 {
-  pstream_t *pstreamptr_dest, *pstreamptr_src;
-
   if ( PSTREAM_Debug )
     Message("pstreamIDdest = %d  pstreamIDsrc = %d", pstreamIDdest, pstreamIDsrc);
 
-  pstreamptr_dest = pstream_to_pointer(pstreamIDdest);
-  pstreamptr_src  = pstream_to_pointer(pstreamIDsrc);
+  pstream_t *pstreamptr_dest = pstream_to_pointer(pstreamIDdest);
+  pstream_t *pstreamptr_src  = pstream_to_pointer(pstreamIDsrc);
 
   if ( pstreamptr_dest->ispipe || pstreamptr_src->ispipe )
     cdoAbort("This operator can't be combined with other operators!");
@@ -1567,7 +1514,6 @@ void processClosePipes(void)
 void cdoFinish(void)
 {
   int processID = processSelf();
-  INT64 nvals;
   int nvars, ntimesteps;
   char memstring[32] = {""};
   double s_utime, s_stime;
@@ -1580,7 +1526,7 @@ void cdoFinish(void)
     Message("process %d  thread %ld", processID, pthread_self());
 #endif
 
-  nvals = processInqNvals(processID);
+  int64_t nvals = processInqNvals(processID);
   nvars = processInqVarNum();
   ntimesteps = processInqTimesteps();
 
@@ -1591,13 +1537,13 @@ void cdoFinish(void)
       reset_text_color(stderr);
       if ( nvals > 0 )
 	{
-	  if ( sizeof(INT64) > sizeof(long) )
+	  if ( sizeof(int64_t) > sizeof(long) )
 #if defined(_WIN32)
 	    fprintf(stderr, "Processed %I64d value%s from %d variable%s",
 #else
 	    fprintf(stderr, "Processed %jd value%s from %d variable%s",
 #endif
-		    nvals, ADD_PLURAL(nvals), nvars, ADD_PLURAL(nvars));
+		    (intmax_t) nvals, ADD_PLURAL(nvals), nvars, ADD_PLURAL(nvars));
 	  else
 	    fprintf(stderr, "Processed %ld value%s from %d variable%s",
 		    (long) nvals, ADD_PLURAL(nvals), nvars, ADD_PLURAL(nvars));
@@ -1688,11 +1634,10 @@ void cdoFinish(void)
 
 int pstreamInqFiletype(int pstreamID)
 {
-  int filetype;
-  pstream_t *pstreamptr;
-
-  pstreamptr = pstream_to_pointer(pstreamID);
+  pstream_t *pstreamptr = pstream_to_pointer(pstreamID);
 
+  int filetype;
+  
 #if defined(HAVE_LIBPTHREAD)
   if ( pstreamptr->ispipe )
     filetype = pstreamptr->filetype;
@@ -1706,10 +1651,9 @@ int pstreamInqFiletype(int pstreamID)
 
 int pstreamInqByteorder(int pstreamID)
 {
-  int byteorder;
-  pstream_t *pstreamptr;
+  pstream_t *pstreamptr = pstream_to_pointer(pstreamID);
 
-  pstreamptr = pstream_to_pointer(pstreamID);
+  int byteorder;
 
 #if defined(HAVE_LIBPTHREAD)
   if ( pstreamptr->ispipe )
@@ -1723,9 +1667,7 @@ int pstreamInqByteorder(int pstreamID)
 
 void pstreamInqGRIBinfo(int pstreamID, int *intnum, float *fltnum, off_t *bignum)
 {
-  pstream_t *pstreamptr;
-
-  pstreamptr = pstream_to_pointer(pstreamID);
+  pstream_t *pstreamptr = pstream_to_pointer(pstreamID);
 
   streamInqGRIBinfo(pstreamptr->fileID, intnum, fltnum, bignum);
 }
diff --git a/src/readline.c b/src/readline.c
index c74cebc..4bfdfb0 100644
--- a/src/readline.c
+++ b/src/readline.c
@@ -34,7 +34,7 @@ int readline(FILE *fp, char *line, int len)
     }
   line[ipos] = 0;
 
-  if ( feof(fp) && ipos == 0 ) return (0);
+  if ( feof(fp) && ipos == 0 ) return 0;
 
   return (1);
 }
diff --git a/src/realtime.c b/src/realtime.c
index adcc31a..a19ade9 100644
--- a/src/realtime.c
+++ b/src/realtime.c
@@ -42,7 +42,7 @@ int util_cputime(double *user_time, double *system_time)
 #endif
 #endif
 
-  return (0);
+  return 0;
 }
 
 double util_walltime(void)
diff --git a/src/remap.h b/src/remap.h
index 439bc5a..d85435d 100644
--- a/src/remap.h
+++ b/src/remap.h
@@ -148,6 +148,7 @@ typedef struct {
 remapvars_t;
 
 typedef struct {
+  int      nused;
   int      gridID;
   int      gridsize;
   int      nmiss;
@@ -161,6 +162,7 @@ remap_t;
 #define  REMAP_WRITE_REMAP      2
 #define  REMAP_MAX_ITER         3
 #define  REMAP_NUM_SRCH_BINS    4
+#define  REMAP_GENWEIGHTS       5
 
 void remap_set_threshhold(double threshhold);
 void remap_set_int(int remapvar, int value);
@@ -183,15 +185,16 @@ void remap_laf(double *restrict dst_array, double missval, long dst_size, long n
 void remap_sum(double *restrict dst_array, double missval, long dst_size, long num_links, double *restrict map_wts,
 	       long num_wts, const int *restrict dst_add, const int *restrict src_add, const double *restrict src_array);
 
-void scrip_remap_weights_bilinear(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
-void scrip_remap_weights_bicubic(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
-void scrip_remap_weights_distwgt(int num_neighbors, remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
-void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
-void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
+void scrip_remap_bilinear_weights(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
+void scrip_remap_bicubic_weights(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
+void remap_distwgt_weights(unsigned num_neighbors, remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
+void scrip_remap_conserv_weights(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
+void remap_conserv_weights(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv);
 
-void scrip_remap_bilinear(remapgrid_t* src_grid, remapgrid_t* tgt_grid, const double* restrict src_array, double* restrict tgt_array, double missval);
-void scrip_remap_bicubic(remapgrid_t *src_grid, remapgrid_t *tgt_grid, const double* restrict src_array, double* restrict tgt_array, double missval);
-void remap_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, const double* restrict src_array, double* restrict tgt_array, double missval);
+void scrip_remap_bilinear(remapgrid_t *src_grid, remapgrid_t *tgt_grid, const double *restrict src_array, double *restrict tgt_array, double missval);
+void scrip_remap_bicubic(remapgrid_t *src_grid, remapgrid_t *tgt_grid, const double *restrict src_array, double *restrict tgt_array, double missval);
+void remap_distwgt(unsigned num_neighbors, remapgrid_t *src_grid, remapgrid_t *tgt_grid, const double *restrict src_array, double *restrict tgt_array, double missval);
+void remap_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, const double *restrict src_array, double *restrict tgt_array, double missval);
 
 
 void resize_remap_vars(remapvars_t *rv, int increment);
@@ -231,5 +234,6 @@ int grid_search(remapgrid_t *src_grid, int *restrict src_add, double *restrict s
 int find_ij_weights(double plon, double plat, double* restrict src_lats, double* restrict src_lons, double *ig, double *jg);
 int rect_grid_search(long *ii, long *jj, double x, double y, long nxm, long nym, const double *restrict xm, const double *restrict ym);
 
+void remapgrid_get_lonlat(remapgrid_t *grid, unsigned cell_add, double *plon, double *plat);
 
 #endif  /* _REMAP_H */
diff --git a/src/remap_bicubic_scrip.c b/src/remap_bicubic_scrip.c
index 079d1dd..947904f 100644
--- a/src/remap_bicubic_scrip.c
+++ b/src/remap_bicubic_scrip.c
@@ -79,11 +79,10 @@ void bicubic_remap(double* restrict tgt_point, const double* restrict src_array,
 
   -----------------------------------------------------------------------
 */
-void scrip_remap_weights_bicubic(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv)
+void scrip_remap_bicubic_weights(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv)
 {
   /*   Local variables */
   int  search_result;
-  long tgt_cell_add;        /*  destination addresss                   */
   int src_add[4];      /*  address for the four source points     */
   double src_lats[4];  /*  latitudes  of four bilinear corners    */
   double src_lons[4];  /*  longitudes of four bilinear corners    */
@@ -105,7 +104,10 @@ void scrip_remap_weights_bicubic(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
 
   long tgt_grid_size = tgt_grid->size;
 
-  weightlinks4_t *weightlinks = (weightlinks4_t *) malloc(tgt_grid_size*sizeof(weightlinks4_t));
+  weightlinks4_t *weightlinks = (weightlinks4_t *) Malloc(tgt_grid_size*sizeof(weightlinks4_t));
+  weightlinks[0].addweights = (addweight4_t *) Malloc(4*tgt_grid_size*sizeof(addweight4_t));
+  for ( unsigned tgt_cell_add = 1; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+    weightlinks[tgt_cell_add].addweights = weightlinks[0].addweights + 4*tgt_cell_add;
 
   /* Loop over destination grid */
 
@@ -113,19 +115,16 @@ void scrip_remap_weights_bicubic(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
 
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) \
-  shared(ompNumThreads, cdoVerbose, weightlinks, remap_grid_type, tgt_grid_size, src_grid, tgt_grid, rv, findex) \
-  private(tgt_cell_add, src_add, src_lats, src_lons, wgts, plat, plon, search_result)
+  shared(weightlinks, remap_grid_type, tgt_grid_size, src_grid, tgt_grid, rv, findex) \
+  private(src_add, src_lats, src_lons, wgts, plat, plon, search_result)
 #endif
-  for ( tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+  for ( long tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
     {
-      int lprogress = 1;
-      if ( cdo_omp_get_thread_num() != 0 ) lprogress = 0;
-
 #if defined(_OPENMP)
 #include "pragma_omp_atomic_update.h"
 #endif
       findex++;
-      if ( lprogress ) progressStatus(0, 1, findex/tgt_grid_size);
+      if ( cdo_omp_get_thread_num() == 0 ) progressStatus(0, 1, findex/tgt_grid_size);
 
       weightlinks[tgt_cell_add].nlinks = 0;	
 
@@ -195,7 +194,7 @@ void scrip_remap_weights_bicubic(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
 
   weightlinks2remaplinks4(tgt_grid_size, weightlinks, rv);
 
-  if ( weightlinks ) free(weightlinks);
+  if ( weightlinks ) Free(weightlinks);
 
 } /* scrip_remap_weights_bicubic */
 
@@ -210,7 +209,6 @@ void scrip_remap_bicubic(remapgrid_t *src_grid, remapgrid_t *tgt_grid, const dou
 {
   /*   Local variables */
   int  search_result;
-  long tgt_cell_add;        /*  destination addresss                 */
   int src_add[4];      /*  address for the four source points   */
   double src_lats[4];  /*  latitudes  of four bilinear corners  */
   double src_lons[4];  /*  longitudes of four bilinear corners  */
@@ -229,9 +227,9 @@ void scrip_remap_bicubic(remapgrid_t *src_grid, remapgrid_t *tgt_grid, const dou
   if ( src_grid->rank != 2 )
     cdoAbort("Can not do bicubic interpolation when source grid rank != 2"); 
 
-  double *grad1_lat    = (double*) malloc(src_grid->size*sizeof(double));
-  double *grad1_lon    = (double*) malloc(src_grid->size*sizeof(double));
-  double *grad1_latlon = (double*) malloc(src_grid->size*sizeof(double));
+  double *grad1_lat    = (double*) Malloc(src_grid->size*sizeof(double));
+  double *grad1_lon    = (double*) Malloc(src_grid->size*sizeof(double));
+  double *grad1_latlon = (double*) Malloc(src_grid->size*sizeof(double));
 
   remap_gradients(*src_grid, src_array, grad1_lat, grad1_lon, grad1_latlon);
 
@@ -241,19 +239,16 @@ void scrip_remap_bicubic(remapgrid_t *src_grid, remapgrid_t *tgt_grid, const dou
 
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) \
-  shared(ompNumThreads, cdoVerbose, remap_grid_type, tgt_grid_size, src_grid, tgt_grid, src_array, tgt_array, missval, grad1_lat, grad1_lon, grad1_latlon, findex) \
-  private(tgt_cell_add, src_add, src_lats, src_lons, wgts, plat, plon, search_result)
+  shared(remap_grid_type, tgt_grid_size, src_grid, tgt_grid, src_array, tgt_array, missval, grad1_lat, grad1_lon, grad1_latlon, findex) \
+  private(src_add, src_lats, src_lons, wgts, plat, plon, search_result)
 #endif
-  for ( tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+  for ( long tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
     {
-      int lprogress = 1;
-      if ( cdo_omp_get_thread_num() != 0 ) lprogress = 0;
-
 #if defined(_OPENMP)
 #include "pragma_omp_atomic_update.h"
 #endif
       findex++;
-      if ( lprogress ) progressStatus(0, 1, findex/tgt_grid_size);
+      if ( cdo_omp_get_thread_num() == 0 ) progressStatus(0, 1, findex/tgt_grid_size);
 
       tgt_array[tgt_cell_add] = missval;
 
@@ -323,8 +318,8 @@ void scrip_remap_bicubic(remapgrid_t *src_grid, remapgrid_t *tgt_grid, const dou
         }
     }
 
-  free(grad1_lat);
-  free(grad1_lon);
-  free(grad1_latlon);
+  Free(grad1_lat);
+  Free(grad1_lon);
+  Free(grad1_latlon);
 
 } /* scrip_remap_bicubic */
diff --git a/src/remap_bilinear_scrip.c b/src/remap_bilinear_scrip.c
index cea2d4e..425bc2e 100644
--- a/src/remap_bilinear_scrip.c
+++ b/src/remap_bilinear_scrip.c
@@ -12,7 +12,7 @@
 /* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
 
 
-int find_ij_weights(double plon, double plat, double* restrict src_lats, double* restrict src_lons, double *ig, double *jg)
+int find_ij_weights(double plon, double plat, double *restrict src_lats, double *restrict src_lons, double *ig, double *jg)
 {
   int lfound = 0;
   long iter;                     /*  iteration counters   */
@@ -79,7 +79,7 @@ int find_ij_weights(double plon, double plat, double* restrict src_lats, double*
 
   if ( iter < remap_max_iter ) lfound = 1;
 
-  return (lfound);
+  return lfound;
 }
 
 static
@@ -104,7 +104,7 @@ int num_src_points(const int* restrict mask, const int src_add[4], double src_la
 	src_lats[n] = 0.;
     }
 
-  return (icount);
+  return icount;
 }
 
 static
@@ -146,7 +146,7 @@ void bilinear_warning(double plon, double plat, double iw, double jw, int* src_a
 }
 
 static
-void bilinear_remap(double* restrict tgt_point, const double* restrict src_array, const double wgts[4], const int src_add[4])
+void bilinear_remap(double* restrict tgt_point, const double *restrict src_array, const double wgts[4], const int src_add[4])
 {
   // *tgt_point = 0.;
   // for ( int n = 0; n < 4; ++n ) *tgt_point += src_array[src_add[n]]*wgts[n];
@@ -161,16 +161,14 @@ void bilinear_remap(double* restrict tgt_point, const double* restrict src_array
 
   -----------------------------------------------------------------------
 */
-void scrip_remap_weights_bilinear(remapgrid_t* src_grid, remapgrid_t* tgt_grid, remapvars_t* rv)
+void scrip_remap_bilinear_weights(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv)
 {
   /*   Local variables */
   int  search_result;
-  long tgt_cell_add;             /*  destination addresss                   */
   int src_add[4];                /*  address for the four source points     */
   double src_lats[4];            /*  latitudes  of four bilinear corners    */
   double src_lons[4];            /*  longitudes of four bilinear corners    */
   double wgts[4];                /*  bilinear weights for four corners      */
-  double plat, plon;             /*  lat/lon coords of destination point    */
   extern int timer_remap_bil;
   int remap_grid_type = src_grid->remap_grid_type;
 
@@ -187,7 +185,10 @@ void scrip_remap_weights_bilinear(remapgrid_t* src_grid, remapgrid_t* tgt_grid,
 
   long tgt_grid_size = tgt_grid->size;
 
-  weightlinks_t *weightlinks = (weightlinks_t *) malloc(tgt_grid_size*sizeof(weightlinks_t));
+  weightlinks_t *weightlinks = (weightlinks_t *) Malloc(tgt_grid_size*sizeof(weightlinks_t));
+  weightlinks[0].addweights = (addweight_t *) Malloc(4*tgt_grid_size*sizeof(addweight_t));
+  for ( unsigned tgt_cell_add = 1; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+    weightlinks[tgt_cell_add].addweights = weightlinks[0].addweights + 4*tgt_cell_add;
 
   double findex = 0;
 
@@ -195,27 +196,24 @@ void scrip_remap_weights_bilinear(remapgrid_t* src_grid, remapgrid_t* tgt_grid,
 
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) \
-  shared(ompNumThreads, cdoVerbose, weightlinks, remap_grid_type, tgt_grid_size, src_grid, tgt_grid, rv, findex) \
-  private(tgt_cell_add, src_add, src_lats, src_lons, wgts, plat, plon, search_result)    \
+  shared(weightlinks, remap_grid_type, tgt_grid_size, src_grid, tgt_grid, rv, findex) \
+  private(src_add, src_lats, src_lons, wgts, search_result)    \
   schedule(static)
 #endif
-  for ( tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+  for ( long tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
     {
-      int lprogress = 1;
-      if ( cdo_omp_get_thread_num() != 0 ) lprogress = 0;
-
 #if defined(_OPENMP)
 #include "pragma_omp_atomic_update.h"
 #endif
       findex++;
-      if ( lprogress ) progressStatus(0, 1, findex/tgt_grid_size);
+      if ( cdo_omp_get_thread_num() == 0 ) progressStatus(0, 1, findex/tgt_grid_size);
 
       weightlinks[tgt_cell_add].nlinks = 0;	
 
       if ( ! tgt_grid->mask[tgt_cell_add] ) continue;
 
-      plat = tgt_grid->cell_center_lat[tgt_cell_add];
-      plon = tgt_grid->cell_center_lon[tgt_cell_add];
+      double plon = 0, plat = 0;
+      remapgrid_get_lonlat(tgt_grid, tgt_cell_add, &plon, &plat);
 
       /* Find nearest square of grid points on source grid  */
       if ( remap_grid_type == REMAP_GRID_TYPE_REG2D )
@@ -247,7 +245,7 @@ void scrip_remap_weights_bilinear(remapgrid_t* src_grid, remapgrid_t* tgt_grid,
 	      /* Successfully found iw,jw - compute weights */
 	      set_bilinear_weights(iw, jw, wgts);
 
-	      store_weightlinks(4, src_add, wgts, tgt_cell_add, weightlinks);
+	      store_weightlinks(0, 4, src_add, wgts, tgt_cell_add, weightlinks);
 	    }
           else
 	    {
@@ -269,14 +267,14 @@ void scrip_remap_weights_bilinear(remapgrid_t* src_grid, remapgrid_t* tgt_grid,
 
 	      tgt_grid->cell_frac[tgt_cell_add] = 1.;
 
-	      store_weightlinks(4, src_add, wgts, tgt_cell_add, weightlinks);
+	      store_weightlinks(0, 4, src_add, wgts, tgt_cell_add, weightlinks);
 	    }
         }
     }
 
-  weightlinks2remaplinks(tgt_grid_size, weightlinks, rv);
+  weightlinks2remaplinks(0, tgt_grid_size, weightlinks, rv);
 
-  if ( weightlinks ) free(weightlinks);
+  if ( weightlinks ) Free(weightlinks);
 
   if ( cdoTimer ) timer_stop(timer_remap_bil);
 } /* scrip_remap_weights_bilinear */
@@ -288,17 +286,14 @@ void scrip_remap_weights_bilinear(remapgrid_t* src_grid, remapgrid_t* tgt_grid,
 
   -----------------------------------------------------------------------
 */
-void scrip_remap_bilinear(remapgrid_t* src_grid, remapgrid_t* tgt_grid, const double* restrict src_array, double* restrict tgt_array, double missval)
+void scrip_remap_bilinear(remapgrid_t *src_grid, remapgrid_t *tgt_grid, const double *restrict src_array, double *restrict tgt_array, double missval)
 {
   /*   Local variables */
   int  search_result;
-  long tgt_grid_size;
-  long tgt_cell_add;             /*  destination addresss                   */
   int src_add[4];                /*  address for the four source points     */
   double src_lats[4];            /*  latitudes  of four bilinear corners    */
   double src_lons[4];            /*  longitudes of four bilinear corners    */
   double wgts[4];                /*  bilinear weights for four corners      */
-  double plat, plon;             /*  lat/lon coords of destination point    */
   extern int timer_remap_bil;
   int remap_grid_type = src_grid->remap_grid_type;
 
@@ -308,7 +303,7 @@ void scrip_remap_bilinear(remapgrid_t* src_grid, remapgrid_t* tgt_grid, const do
 
   progressInit();
 
-  tgt_grid_size = tgt_grid->size;
+  long tgt_grid_size = tgt_grid->size;
 
   /* Compute mappings from source to target grid */
 
@@ -321,30 +316,24 @@ void scrip_remap_bilinear(remapgrid_t* src_grid, remapgrid_t* tgt_grid, const do
 
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) \
-  shared(ompNumThreads, cdoVerbose, cdoSilentMode, remap_grid_type, tgt_grid_size, src_grid, tgt_grid, src_array, tgt_array, missval, findex) \
-  private(tgt_cell_add, src_add, src_lats, src_lons, wgts, plat, plon, search_result)    \
+  shared(cdoSilentMode, remap_grid_type, tgt_grid_size, src_grid, tgt_grid, src_array, tgt_array, missval, findex) \
+  private(src_add, src_lats, src_lons, wgts, search_result)    \
   schedule(static)
 #endif
-  for ( tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+  for ( long tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
     {
-      int lprogress = 1;
-      if ( cdo_omp_get_thread_num() != 0 ) lprogress = 0;
-
-      if ( !cdoSilentMode )
-	{
 #if defined(_OPENMP)
 #include "pragma_omp_atomic_update.h"
 #endif
-	  findex++;
-	  if ( lprogress ) progressStatus(0, 1, findex/tgt_grid_size);
-	}
+      findex++;
+      if ( cdo_omp_get_thread_num() == 0 ) progressStatus(0, 1, findex/tgt_grid_size);
 
       tgt_array[tgt_cell_add] = missval;
 
       if ( ! tgt_grid->mask[tgt_cell_add] ) continue;
 
-      plat = tgt_grid->cell_center_lat[tgt_cell_add];
-      plon = tgt_grid->cell_center_lon[tgt_cell_add];
+      double plon = 0, plat = 0;
+      remapgrid_get_lonlat(tgt_grid, tgt_cell_add, &plon, &plat);
 
       /* Find nearest square of grid points on source grid  */
       if ( remap_grid_type == REMAP_GRID_TYPE_REG2D )
diff --git a/src/remap_conserv.c b/src/remap_conserv.c
index 528fca6..85b3bf3 100644
--- a/src/remap_conserv.c
+++ b/src/remap_conserv.c
@@ -128,14 +128,11 @@ void boundbox_from_corners_reg2d(long grid_add, const int *restrict grid_dims, c
 				 const double *restrict corner_lat, double *restrict bound_box)
 {
   long nx = grid_dims[0];
-  long ix, iy;
-  double clat1, clat2;
+  long iy = grid_add/nx;
+  long ix = grid_add - iy*nx;
 
-  iy = grid_add/nx;
-  ix = grid_add - iy*nx;
-
-  clat1 = corner_lat[iy  ];
-  clat2 = corner_lat[iy+1];
+  double clat1 = corner_lat[iy  ];
+  double clat2 = corner_lat[iy+1];
 
   if ( clat2 > clat1 )
     {
@@ -497,12 +494,10 @@ int get_lonlat_circle_index(remapgrid_t *remap_grid)
 }
 
 
-
 static
 void normalize_weights(remapgrid_t *tgt_grid, remapvars_t *rv)
 {
   /* Include centroids in weights and normalize using destination area if requested */
-  long n;
   long num_wts = rv->num_wts;
   long num_links = rv->num_links;
   long tgt_cell_add;       /* current linear address for target grid cell   */
@@ -516,9 +511,9 @@ void normalize_weights(remapgrid_t *tgt_grid, remapvars_t *rv)
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) \
   shared(num_wts, num_links, rv, tgt_grid)	\
-  private(n, tgt_cell_add, norm_factor)
+  private(tgt_cell_add, norm_factor)
 #endif
-      for ( n = 0; n < num_links; ++n )
+      for ( long n = 0; n < num_links; ++n )
 	{
 	  tgt_cell_add = rv->tgt_cell_add[n];
 
@@ -538,9 +533,9 @@ void normalize_weights(remapgrid_t *tgt_grid, remapvars_t *rv)
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) \
   shared(num_wts, num_links, rv, tgt_grid)	\
-  private(n, tgt_cell_add, norm_factor)
+  private(tgt_cell_add, norm_factor)
 #endif
-      for ( n = 0; n < num_links; ++n )
+      for ( long n = 0; n < num_links; ++n )
 	{
 	  tgt_cell_add = rv->tgt_cell_add[n];
 
@@ -558,7 +553,7 @@ void normalize_weights(remapgrid_t *tgt_grid, remapvars_t *rv)
 }
 
 
-void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv)
+void remap_conserv_weights(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv)
 {
   /* local variables */
 
@@ -568,7 +563,6 @@ void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapva
   long   src_num_cell_corners;
   long   tgt_num_cell_corners;
   long   src_cell_add;       /* current linear address for source grid cell   */
-  long   tgt_cell_add;       /* current linear address for target grid cell   */
   long   k;                  /* generic counters                        */
   long   nbins;
   long   num_wts;
@@ -642,13 +636,13 @@ void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapva
   struct grid_cell* tgt_grid_cell2[ompNumThreads];  
   for ( i = 0; i < ompNumThreads; ++i )
     {
-      tgt_grid_cell2[i] = (struct grid_cell*) malloc(sizeof(struct grid_cell));
+      tgt_grid_cell2[i] = (struct grid_cell*) Malloc(sizeof(struct grid_cell));
       tgt_grid_cell2[i]->array_size      = tgt_num_cell_corners;
       tgt_grid_cell2[i]->num_corners     = tgt_num_cell_corners;
       tgt_grid_cell2[i]->edge_type       = tgt_edge_type;
-      tgt_grid_cell2[i]->coordinates_x   = (double*) malloc(tgt_num_cell_corners*sizeof(double));
-      tgt_grid_cell2[i]->coordinates_y   = (double*) malloc(tgt_num_cell_corners*sizeof(double));
-      tgt_grid_cell2[i]->coordinates_xyz = (double*) malloc(3*tgt_num_cell_corners*sizeof(double));
+      tgt_grid_cell2[i]->coordinates_x   = (double*) Malloc(tgt_num_cell_corners*sizeof(double));
+      tgt_grid_cell2[i]->coordinates_y   = (double*) Malloc(tgt_num_cell_corners*sizeof(double));
+      tgt_grid_cell2[i]->coordinates_xyz = (double*) Malloc(3*tgt_num_cell_corners*sizeof(double));
     }
 
   struct grid_cell* src_grid_cells;
@@ -677,7 +671,7 @@ void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapva
 
   int* srch_add2[ompNumThreads];
   for ( i = 0; i < ompNumThreads; ++i )
-    srch_add2[i] = (int*) malloc(src_grid_size*sizeof(int));
+    srch_add2[i] = (int*) Malloc(src_grid_size*sizeof(int));
 
   srch_corners = src_num_cell_corners;
 
@@ -698,7 +692,7 @@ void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapva
       //printf("src_grid   lon: %g %g lat: %g %g\n", RAD2DEG*src_grid_bound_box[2],RAD2DEG*src_grid_bound_box[3],RAD2DEG*src_grid_bound_box[0],RAD2DEG*src_grid_bound_box[1] );
     }
 
-  weightlinks_t *weightlinks = (weightlinks_t *) malloc(tgt_grid_size*sizeof(weightlinks_t));
+  weightlinks_t *weightlinks = (weightlinks_t *) Malloc(tgt_grid_size*sizeof(weightlinks_t));
   
   double findex = 0;
 
@@ -708,29 +702,27 @@ void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapva
   /* Loop over destination grid */
 
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) \
+#pragma omp parallel for schedule(dynamic) default(none)                   \
   shared(ompNumThreads, lyac, nbins, num_wts, src_remap_grid_type, tgt_remap_grid_type, src_grid_bound_box,	\
 	 src_edge_type, tgt_edge_type, partial_areas2, partial_weights2,  \
          rv, cdoVerbose, max_srch_cells2, tgt_num_cell_corners, target_cell_type, \
          weightlinks, \
-         srch_corners, src_grid, tgt_grid, tgt_grid_size, src_grid_size,	\
+         srch_corners, src_grid, tgt_grid, tgt_grid_size, src_grid_size, nx, \
 	 overlap_buffer2, src_grid_cells2, srch_add2, tgt_grid_cell2, findex, sum_srch_cells, sum_srch_cells2) \
   private(srch_add, tgt_grid_cell, tgt_area, k, num_srch_cells, max_srch_cells,  \
-	  partial_areas, partial_weights, overlap_buffer, src_grid_cells, src_cell_add, tgt_cell_add, ioffset)
+	  partial_areas, partial_weights, overlap_buffer, src_grid_cells, src_cell_add, ioffset)
 #endif
-  for ( tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+  for ( long tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
     {
       double partial_weight;
       long n, num_weights, num_weights_old;
       int ompthID = cdo_omp_get_thread_num();
-      int lprogress = 1;
-      if ( ompthID != 0 ) lprogress = 0;
 
 #if defined(_OPENMP)
 #include "pragma_omp_atomic_update.h"
 #endif
       findex++;
-      if ( lprogress ) progressStatus(0, 1, findex/tgt_grid_size);
+      if ( ompthID == 0 ) progressStatus(0, 1, findex/tgt_grid_size);
 
       weightlinks[tgt_cell_add].nlinks = 0;	
 
@@ -788,10 +780,8 @@ void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapva
       if ( tgt_remap_grid_type == REMAP_GRID_TYPE_REG2D )
 	{
 	  long nx = tgt_grid->dims[0];
-	  long ix, iy;
-
-	  iy = tgt_cell_add/nx;
-	  ix = tgt_cell_add - iy*nx;
+	  long iy = tgt_cell_add/nx;
+	  long ix = tgt_cell_add - iy*nx;
 
 	  tgt_grid_cell->coordinates_x[0] = tgt_grid->reg2d_corner_lon[ix  ];
 	  tgt_grid_cell->coordinates_y[0] = tgt_grid->reg2d_corner_lat[iy  ];
@@ -841,13 +831,12 @@ void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapva
 
       if ( num_srch_cells > max_srch_cells )
 	{
-	  partial_areas   = (double*) realloc(partial_areas,   num_srch_cells*sizeof(double));
+          partial_areas   = (double*) realloc(partial_areas,   num_srch_cells*sizeof(double));
 	  partial_weights = (double*) realloc(partial_weights, num_srch_cells*sizeof(double));
-
-	  overlap_buffer = (struct grid_cell*) realloc(overlap_buffer, num_srch_cells*sizeof(struct grid_cell));
+          overlap_buffer = (struct grid_cell*) realloc(overlap_buffer, num_srch_cells*sizeof(struct grid_cell));
 	  src_grid_cells = (struct grid_cell*) realloc(src_grid_cells, num_srch_cells*sizeof(struct grid_cell));
 
-	  for ( n = max_srch_cells; n < num_srch_cells; ++n )
+          for ( n = max_srch_cells; n < num_srch_cells; ++n )
 	    {
 	      overlap_buffer[n].array_size      = 0;
 	      overlap_buffer[n].num_corners     = 0;
@@ -865,7 +854,7 @@ void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapva
 	      src_grid_cells[n].coordinates_x   = (double*) malloc(srch_corners*sizeof(double));
 	      src_grid_cells[n].coordinates_y   = (double*) malloc(srch_corners*sizeof(double));
 	      src_grid_cells[n].coordinates_xyz = (double*) malloc(3*srch_corners*sizeof(double));
-	    }
+            }
 
 	  max_srch_cells = num_srch_cells;
 
@@ -1063,7 +1052,7 @@ void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapva
 	  tgt_grid->cell_frac[tgt_cell_add] += partial_weight;
 	}
 
-      store_weightlinks(num_weights, srch_add, partial_weights, tgt_cell_add, weightlinks);
+      store_weightlinks(1, num_weights, srch_add, partial_weights, tgt_cell_add, weightlinks);
 
       tgt_grid->cell_area[tgt_cell_add] = tgt_area; 
       // printf("area %d %g %g\n", tgt_cell_add, tgt_grid->cell_area[tgt_cell_add], tgt_area);
@@ -1084,35 +1073,33 @@ void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapva
 	{
 	  if ( overlap_buffer2[i][n].array_size > 0 )
 	    {
-	      free(overlap_buffer2[i][n].coordinates_x);
-	      free(overlap_buffer2[i][n].coordinates_y);
-	      if ( overlap_buffer2[i][n].coordinates_xyz ) free(overlap_buffer2[i][n].coordinates_xyz);
-	      if ( overlap_buffer2[i][n].edge_type ) free(overlap_buffer2[i][n].edge_type);
+	      Free(overlap_buffer2[i][n].coordinates_x);
+	      Free(overlap_buffer2[i][n].coordinates_y);
+	      if ( overlap_buffer2[i][n].coordinates_xyz ) Free(overlap_buffer2[i][n].coordinates_xyz);
+	      if ( overlap_buffer2[i][n].edge_type ) Free(overlap_buffer2[i][n].edge_type);
 	    }
+
+	  Free(src_grid_cells2[i][n].coordinates_x);
+	  Free(src_grid_cells2[i][n].coordinates_y);
+	  Free(src_grid_cells2[i][n].coordinates_xyz);
 	}
-      for ( n = 0; n < max_srch_cells2[i]; n++ )
-	{
-	  free(src_grid_cells2[i][n].coordinates_x);
-	  free(src_grid_cells2[i][n].coordinates_y);
-	  free(src_grid_cells2[i][n].coordinates_xyz);
-	}
-      free(src_grid_cells2[i]);
-      free(overlap_buffer2[i]);
+      Free(src_grid_cells2[i]);
+      Free(overlap_buffer2[i]);
 
-      free(partial_areas2[i]);
-      free(partial_weights2[i]);
+      Free(partial_areas2[i]);
+      Free(partial_weights2[i]);
 
-      free(tgt_grid_cell2[i]->coordinates_x);
-      free(tgt_grid_cell2[i]->coordinates_y);
-      free(tgt_grid_cell2[i]->coordinates_xyz);
-      free(tgt_grid_cell2[i]);
+      Free(tgt_grid_cell2[i]->coordinates_x);
+      Free(tgt_grid_cell2[i]->coordinates_y);
+      Free(tgt_grid_cell2[i]->coordinates_xyz);
+      Free(tgt_grid_cell2[i]);
 
-      free(srch_add2[i]);
+      Free(srch_add2[i]);
     }
 
-  weightlinks2remaplinks(tgt_grid_size, weightlinks, rv);
+  weightlinks2remaplinks(1, tgt_grid_size, weightlinks, rv);
 
-  if ( weightlinks ) free(weightlinks);
+  if ( weightlinks ) Free(weightlinks);
 
   /* Normalize using destination area if requested */
   normalize_weights(tgt_grid, rv);
@@ -1147,7 +1134,7 @@ void remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapva
       for ( n = 0; n < num_links; ++n )
 	{
 	  src_cell_add = rv->src_cell_add[n];
-	  tgt_cell_add = rv->tgt_cell_add[n];
+	  long tgt_cell_add = rv->tgt_cell_add[n];
 
 	  if ( rv->wts[n*num_wts] < -0.01 )
 	    cdoPrint("Map weight < 0! grid1idx=%d grid2idx=%d nlink=%d wts=%g",
diff --git a/src/remap_conserv_scrip.c b/src/remap_conserv_scrip.c
index 5813b19..7dee2ea 100644
--- a/src/remap_conserv_scrip.c
+++ b/src/remap_conserv_scrip.c
@@ -11,7 +11,6 @@
 #include "grid.h"
 #include "remap.h"
 #include "remap_store_link_cnsrv.h"
-#include "util.h"  /* progressStatus */
 
 /* #define  BABY_STEP  0.001 */ /* original value */
 #define  BABY_STEP  0.001
@@ -104,8 +103,8 @@ void pole_intersection(long *location, double *intrsct_lat, double *intrsct_lon,
 
   /* Convert coordinates */
 
-  srch_corner_x = (double*) malloc(srch_corners*num_srch_cells*sizeof(double));
-  srch_corner_y = (double*) malloc(srch_corners*num_srch_cells*sizeof(double));
+  srch_corner_x = (double*) Malloc(srch_corners*num_srch_cells*sizeof(double));
+  srch_corner_y = (double*) Malloc(srch_corners*num_srch_cells*sizeof(double));
 
   if ( beglat > ZERO )
     {
@@ -276,8 +275,8 @@ void pole_intersection(long *location, double *intrsct_lat, double *intrsct_lon,
 
       if ( s1 >= ONE )
 	{
-          free(srch_corner_y);
-          free(srch_corner_x);
+          Free(srch_corner_y);
+          Free(srch_corner_x);
           *luse_last = FALSE;
           return;
 	}
@@ -422,8 +421,8 @@ void pole_intersection(long *location, double *intrsct_lat, double *intrsct_lon,
 
     } /* intrsct_loop */
 
-  free(srch_corner_y);
-  free(srch_corner_x);
+  Free(srch_corner_y);
+  Free(srch_corner_x);
 
   /*
      If segment manages to cross over pole, shift the beginning 
@@ -1138,7 +1137,6 @@ static
 void normalize_weights(remapgrid_t *tgt_grid, remapvars_t *rv, double *src_centroid_lat, double *src_centroid_lon)
 {
   /* Include centroids in weights and normalize using destination area if requested */
-  long n;
   long num_links = rv->num_links;
   long src_cell_add;       /* current linear address for source grid cell   */
   long tgt_cell_add;       /* current linear address for target grid cell   */
@@ -1153,9 +1151,9 @@ void normalize_weights(remapgrid_t *tgt_grid, remapvars_t *rv, double *src_centr
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) \
   shared(num_links, rv, weights, tgt_grid, src_centroid_lat, src_centroid_lon)		\
-  private(n, src_cell_add, tgt_cell_add, norm_factor)
+  private(src_cell_add, tgt_cell_add, norm_factor)
 #endif
-      for ( n = 0; n < num_links; ++n )
+      for ( long n = 0; n < num_links; ++n )
 	{
 	  src_cell_add = rv->src_cell_add[n]; tgt_cell_add = rv->tgt_cell_add[n];
 
@@ -1175,9 +1173,9 @@ void normalize_weights(remapgrid_t *tgt_grid, remapvars_t *rv, double *src_centr
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) \
   shared(num_links, rv, weights, tgt_grid, src_centroid_lat, src_centroid_lon)		\
-  private(n, src_cell_add, tgt_cell_add, norm_factor)
+  private(src_cell_add, tgt_cell_add, norm_factor)
 #endif
-      for ( n = 0; n < num_links; ++n )
+      for ( long n = 0; n < num_links; ++n )
 	{
 	  src_cell_add = rv->src_cell_add[n]; tgt_cell_add = rv->tgt_cell_add[n];
 
@@ -1197,9 +1195,9 @@ void normalize_weights(remapgrid_t *tgt_grid, remapvars_t *rv, double *src_centr
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) \
   shared(num_links, rv, weights, tgt_grid, src_centroid_lat, src_centroid_lon)	\
-  private(n, src_cell_add, norm_factor)
+  private(src_cell_add, norm_factor)
 #endif
-      for ( n = 0; n < num_links; ++n )
+      for ( long n = 0; n < num_links; ++n )
 	{
 	  src_cell_add = rv->src_cell_add[n];;
 
@@ -1219,7 +1217,7 @@ void normalize_weights(remapgrid_t *tgt_grid, remapvars_t *rv, double *src_centr
 
   -----------------------------------------------------------------------
 */
-void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv)
+void scrip_remap_conserv_weights(remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv)
 {
   /* local variables */
 
@@ -1293,7 +1291,7 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
 
   if ( remap_store_link_fast )
     {
-      grid_store = (grid_store_t*) malloc(sizeof(grid_store_t));
+      grid_store = (grid_store_t*) Malloc(sizeof(grid_store_t));
       grid_store_init(grid_store, tgt_grid->size);
     }
 
@@ -1313,10 +1311,10 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
 
   if ( ! remap_store_link_fast )
     {
-      link_add1[0] = (int*) malloc(src_grid_size*sizeof(int));
-      link_add1[1] = (int*) malloc(src_grid_size*sizeof(int));
-      link_add2[0] = (int*) malloc(tgt_grid_size*sizeof(int));
-      link_add2[1] = (int*) malloc(tgt_grid_size*sizeof(int));
+      link_add1[0] = (int*) Malloc(src_grid_size*sizeof(int));
+      link_add1[1] = (int*) Malloc(src_grid_size*sizeof(int));
+      link_add2[0] = (int*) Malloc(tgt_grid_size*sizeof(int));
+      link_add2[1] = (int*) Malloc(tgt_grid_size*sizeof(int));
 
 #if defined(SX)
 #pragma vdir nodep
@@ -1339,10 +1337,10 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
 
   /* Initialize centroid arrays */
 
-  src_centroid_lat = (double*) malloc(src_grid_size*sizeof(double));
-  src_centroid_lon = (double*) malloc(src_grid_size*sizeof(double));
-  tgt_centroid_lat = (double*) malloc(tgt_grid_size*sizeof(double));
-  tgt_centroid_lon = (double*) malloc(tgt_grid_size*sizeof(double));
+  src_centroid_lat = (double*) Malloc(src_grid_size*sizeof(double));
+  src_centroid_lon = (double*) Malloc(src_grid_size*sizeof(double));
+  tgt_centroid_lat = (double*) Malloc(tgt_grid_size*sizeof(double));
+  tgt_centroid_lon = (double*) Malloc(tgt_grid_size*sizeof(double));
 
   for ( n = 0; n < src_grid_size; ++n )
     {
@@ -1372,15 +1370,15 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
     max_srch_cells2[i] = 0;
 
   for ( i = 0; i < ompNumThreads; ++i )
-    srch_add2[i] = (int*) malloc(tgt_grid_size*sizeof(int));
+    srch_add2[i] = (int*) Malloc(tgt_grid_size*sizeof(int));
 
   srch_corners    = tgt_num_cell_corners;
 
   if ( cdoTimer ) timer_start(timer_remap_con_l1);
 
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) \
-  shared(ompNumThreads, nbins, num_wts, src_centroid_lon, src_centroid_lat, \
+#pragma omp parallel for default(none) \
+  shared(nbins, num_wts, src_centroid_lon, src_centroid_lat, \
          remap_store_link_fast, grid_store, link_add1, link_add2, rv, cdoVerbose, max_subseg, \
 	 srch_corner_lat2, srch_corner_lon2, max_srch_cells2, 		\
 	 src_num_cell_corners,	srch_corners, src_grid, tgt_grid, tgt_grid_size, src_grid_size, srch_add2, findex) \
@@ -1393,14 +1391,12 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
   for ( src_cell_add = 0; src_cell_add < src_grid_size; ++src_cell_add )
     {
       int ompthID = cdo_omp_get_thread_num();
-      int lprogress = 1;
-      if ( ompthID != 0 ) lprogress = 0;
 
 #if defined(_OPENMP)
 #include "pragma_omp_atomic_update.h"
 #endif
       findex++;
-      if ( lprogress ) progressStatus(0, 0.5, findex/src_grid_size);
+      if ( ompthID == 0 ) progressStatus(0, 0.5, findex/src_grid_size);
 
       srch_add = srch_add2[ompthID];
 
@@ -1423,7 +1419,7 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
 
       if ( num_srch_cells > max_srch_cells )
 	{
-	  srch_corner_lat = (double*) realloc(srch_corner_lat, srch_corners*num_srch_cells*sizeof(double));
+          srch_corner_lat = (double*) realloc(srch_corner_lat, srch_corners*num_srch_cells*sizeof(double));
 	  srch_corner_lon = (double*) realloc(srch_corner_lon, srch_corners*num_srch_cells*sizeof(double));
 
 	  max_srch_cells  = num_srch_cells;
@@ -1573,12 +1569,12 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
 
   for ( i = 0; i < ompNumThreads; ++i )
     {
-      free(srch_corner_lon2[i]);
-      free(srch_corner_lat2[i]);
+      Free(srch_corner_lon2[i]);
+      Free(srch_corner_lat2[i]);
     }
 
   for ( i = 0; i < ompNumThreads; ++i )
-    free(srch_add2[i]);
+    Free(srch_add2[i]);
 
   /* Integrate around each cell on target grid */
 
@@ -1592,7 +1588,7 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
     max_srch_cells2[i] = 0;
 
   for ( i = 0; i < ompNumThreads; ++i )
-    srch_add2[i] = (int*) malloc(src_grid_size*sizeof(int));
+    srch_add2[i] = (int*) Malloc(src_grid_size*sizeof(int));
 
   srch_corners    = src_num_cell_corners;
   max_srch_cells  = 0;
@@ -1604,8 +1600,8 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
   findex = 0;
 
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) \
-  shared(ompNumThreads, nbins, num_wts, tgt_centroid_lon, tgt_centroid_lat, \
+#pragma omp parallel for default(none) \
+  shared(nbins, num_wts, tgt_centroid_lon, tgt_centroid_lat, \
          remap_store_link_fast, grid_store, link_add1, link_add2, rv, cdoVerbose, max_subseg, \
 	 srch_corner_lat2, srch_corner_lon2, max_srch_cells2, 		\
 	 tgt_num_cell_corners, srch_corners, src_grid, tgt_grid, tgt_grid_size, src_grid_size, srch_add2, findex) \
@@ -1618,14 +1614,12 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
   for ( tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
     {
       int ompthID = cdo_omp_get_thread_num();
-      int lprogress = 1;
-      if ( ompthID != 0 ) lprogress = 0;
 
 #if defined(_OPENMP)
 #include "pragma_omp_atomic_update.h"
 #endif
       findex++;
-      if ( lprogress ) progressStatus(0.5, 0.5, findex/tgt_grid_size);
+      if ( ompthID == 0 ) progressStatus(0.5, 0.5, findex/tgt_grid_size);
 
       srch_add = srch_add2[ompthID];
 
@@ -1801,12 +1795,12 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
 
   for ( i = 0; i < ompNumThreads; ++i )
     {
-      free(srch_corner_lon2[i]);
-      free(srch_corner_lat2[i]);
+      Free(srch_corner_lon2[i]);
+      Free(srch_corner_lat2[i]);
     }
 
   for ( i = 0; i < ompNumThreads; ++i )
-    free(srch_add2[i]);
+    Free(srch_add2[i]);
 
   /*
      Correct for situations where N/S pole not explicitly included in
@@ -1823,7 +1817,7 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
   if ( remap_store_link_fast )
     {
       grid_store_delete(grid_store);
-      free(grid_store);
+      Free(grid_store);
     }
 
 
@@ -1959,17 +1953,17 @@ void scrip_remap_weights_conserv(remapgrid_t *src_grid, remapgrid_t *tgt_grid, r
 	}
     } // lcheck
 
-  free(src_centroid_lat);
-  free(src_centroid_lon);
-  free(tgt_centroid_lat);
-  free(tgt_centroid_lon);
+  Free(src_centroid_lat);
+  Free(src_centroid_lon);
+  Free(tgt_centroid_lat);
+  Free(tgt_centroid_lon);
 
   if ( ! remap_store_link_fast )
     {
-      free(link_add1[0]);
-      free(link_add1[1]);
-      free(link_add2[0]);
-      free(link_add2[1]);
+      Free(link_add1[0]);
+      Free(link_add1[1]);
+      Free(link_add2[0]);
+      Free(link_add2[1]);
     }
 
   if ( cdoTimer ) timer_stop(timer_remap_con);
diff --git a/src/remap_distwgt.c b/src/remap_distwgt.c
new file mode 100644
index 0000000..e5b0f9c
--- /dev/null
+++ b/src/remap_distwgt.c
@@ -0,0 +1,564 @@
+#if defined(_OPENMP)
+#include <omp.h> // omp_get_wtime
+#endif
+
+#include "cdo.h"
+#include "cdo_int.h"
+#include "grid.h"
+#include "remap.h"
+#include "remap_store_link.h"
+#include "grid_search.h"
+
+//  Interpolation using a distance-weighted average
+
+static
+void nbr_store_distance(int nadd, double distance, int num_neighbors, int *restrict nbr_add, double *restrict nbr_dist)
+{
+  if ( num_neighbors == 1 )
+    {
+      if ( distance < nbr_dist[0] || (distance <= nbr_dist[0] && nadd < nbr_add[0]) )
+	{
+	  nbr_add[0]  = nadd;
+	  nbr_dist[0] = distance;
+	}
+    }
+  else
+    {
+      int n, nchk;
+      for ( nchk = 0; nchk < num_neighbors; ++nchk )
+	{
+	  if ( distance < nbr_dist[nchk] || (distance <= nbr_dist[nchk] && nadd < nbr_add[nchk]) )
+	    {
+	      for ( n = num_neighbors-1; n > nchk; --n )
+		{
+		  nbr_add[n]  = nbr_add[n-1];
+		  nbr_dist[n] = nbr_dist[n-1];
+		}
+	      nbr_add[nchk]  = nadd;
+	      nbr_dist[nchk] = distance;
+	      break;
+	    }
+	}
+    }
+}
+
+static
+void nbr_check_distance(unsigned num_neighbors, const int *restrict nbr_add, double *restrict nbr_dist)
+{
+  double distance;
+
+  // If distance is zero, set to small number
+  for ( unsigned nchk = 0; nchk < num_neighbors; ++nchk )
+    {
+      if ( nbr_add[nchk] >= 0 )
+	{
+	  distance = nbr_dist[nchk];
+	  if ( IS_EQUAL(distance, 0.) ) distance = TINY;
+	  nbr_dist[nchk] = distance;
+	}
+    }
+}
+
+
+double nbr_compute_weights(unsigned num_neighbors, const int *restrict src_grid_mask, int *restrict nbr_mask, const int *restrict nbr_add, double *restrict nbr_dist)
+{
+  // Compute weights based on inverse distance if mask is false, eliminate those points
+
+  double dist_tot = 0.; // sum of neighbor distances (for normalizing)
+
+  if ( src_grid_mask )
+    {
+      for ( unsigned n = 0; n < num_neighbors; ++n )
+        {
+          nbr_mask[n] = FALSE;
+          if ( nbr_add[n] >= 0 )
+            if ( src_grid_mask[nbr_add[n]] )
+              {
+                nbr_dist[n] = ONE/nbr_dist[n];
+                dist_tot = dist_tot + nbr_dist[n];
+                nbr_mask[n] = TRUE;
+              }
+        }
+    }
+  else
+    {
+      for ( unsigned n = 0; n < num_neighbors; ++n )
+        {
+          nbr_mask[n] = FALSE;
+          if ( nbr_add[n] >= 0 )
+            {
+              nbr_dist[n] = ONE/nbr_dist[n];
+              dist_tot = dist_tot + nbr_dist[n];
+              nbr_mask[n] = TRUE;
+            }
+        }
+    }
+
+  return dist_tot;
+}
+
+
+unsigned nbr_normalize_weights(unsigned num_neighbors, double dist_tot, const int *restrict nbr_mask, int *restrict nbr_add, double *restrict nbr_dist)
+{
+  // Normalize weights and store the link
+
+  unsigned nadds = 0;
+
+  for ( unsigned n = 0; n < num_neighbors; ++n )
+    {
+      if ( nbr_mask[n] )
+        {
+          nbr_dist[nadds] = nbr_dist[n]/dist_tot;
+          nbr_add[nadds]  = nbr_add[n];
+          nadds++;
+        }
+    }
+
+  return nadds;
+}
+
+static
+double get_search_radius(void)
+{
+  extern double gridsearch_radius;
+
+  double search_radius = gridsearch_radius;
+
+  if ( search_radius <    0. ) search_radius = 0.;
+  if ( search_radius >  180. ) search_radius = 180.;
+
+  search_radius = search_radius*DEG2RAD;
+
+  return search_radius;
+}
+
+//  This routine finds the closest num_neighbor points to a search point and computes a distance to each of the neighbors.
+
+#define MAX_SEARCH_CELLS 25
+static
+void grid_search_nbr_reg2d(struct gridsearch *gs, int num_neighbors, remapgrid_t *src_grid, int *restrict nbr_add, double *restrict nbr_dist, 
+			   double plon, double plat, const int *restrict src_grid_dims)
+{
+  /*
+    Output variables:
+
+    int nbr_add[num_neighbors]     ! address of each of the closest points
+    double nbr_dist[num_neighbors] ! distance to each of the closest points
+
+    Input variables:
+
+    double plat,         ! latitude  of the search point
+    double plon,         ! longitude of the search point
+  */
+  int lfound;
+  int n, nadd;
+  long ii, jj;
+  int i, j, ix;
+  int src_add[MAX_SEARCH_CELLS];
+  int *src_add_tmp = NULL;
+  int *psrc_add = src_add;
+  int num_add = 0;
+  double distance;   //  Angular distance
+  double cos_search_radius = cos(get_search_radius());
+  double coslat_dst = cos(plat);  // cos(lat)  of the search point
+  double coslon_dst = cos(plon);  // cos(lon)  of the search point
+  double sinlat_dst = sin(plat);  // sin(lat)  of the search point
+  double sinlon_dst = sin(plon);  // sin(lon)  of the search point
+  double *restrict coslon = gs->coslon;
+  double *restrict sinlon = gs->sinlon;
+  double *restrict coslat = gs->coslat;
+  double *restrict sinlat = gs->sinlat;
+  double *restrict src_center_lon = gs->reg2d_center_lon;
+  double *restrict src_center_lat = gs->reg2d_center_lat;
+
+  long nx = src_grid_dims[0];
+  long ny = src_grid_dims[1];
+
+  long nxm = nx;
+  if ( src_grid->is_cyclic ) nxm++;
+
+  if ( plon < src_center_lon[0]     ) plon += PI2;
+  if ( plon > src_center_lon[nxm-1] ) plon -= PI2;
+
+  lfound = rect_grid_search(&ii, &jj, plon, plat, nxm, ny, src_center_lon, src_center_lat);
+
+  if ( lfound )
+    {
+      if ( src_grid->is_cyclic && ii == (nxm-1) ) ii = 0;
+
+      long k;
+      for ( k = 3; k < 10000; k+=2 )
+        if ( num_neighbors <= ((k-2)*(k-2)) ) break;
+
+      if ( (k*k) > MAX_SEARCH_CELLS ) psrc_add = src_add_tmp = (int *) malloc(k*k*sizeof(int));
+
+      k /= 2;
+
+      int j0 = jj-k;
+      int jn = jj+k;
+      int i0 = ii-k;
+      int in = ii+k;
+      if ( j0 < 0 ) j0 = 0;
+      if ( jn >= ny ) jn = ny-1;
+      if ( (in-i0) > nx ) { i0 = 0; in = nx-1; }
+      
+      for ( j = j0; j <= jn; ++j )
+	for ( i = i0; i <= in; ++i )
+	  {
+	    ix = i;
+	    
+	    if ( src_grid->is_cyclic )
+	      {
+		if ( ix <   0 ) ix += nx;
+		if ( ix >= nx ) ix -= nx;
+	      }
+
+	    if ( ix >= 0 && ix < nx && j >= 0 && j < ny )
+	      psrc_add[num_add++] = j*nx+ix;
+	  }
+    }
+
+  // Initialize distance and address arrays
+  for ( n = 0; n < num_neighbors; ++n )
+    {
+      nbr_add[n]  = -1;
+      nbr_dist[n] = BIGNUM;
+    }
+
+  if ( lfound )
+    {
+      int ix, iy;
+
+      for ( int na = 0; na < num_add; ++na )
+	{
+	  nadd = psrc_add[na];
+
+	  iy = nadd/nx;
+	  ix = nadd - iy*nx;
+
+	  // Find distance to this point
+	  distance =  sinlat_dst*sinlat[iy] + coslat_dst*coslat[iy]*
+	             (coslon_dst*coslon[ix] + sinlon_dst*sinlon[ix]);
+
+	  // Check that distance is inside the range of -1 to 1, otherwise the result of acos(distance) is NaN
+	  if ( distance > 1. ) distance =  1.;
+
+	  if ( distance >= cos_search_radius )
+	    {
+	      distance = acos(distance);
+
+	      // Store the address and distance if this is one of the smallest four so far
+	      nbr_store_distance(nadd, distance, num_neighbors, nbr_add, nbr_dist);
+	    }
+	}
+
+      nbr_check_distance(num_neighbors, nbr_add, nbr_dist);
+
+      if ( src_add_tmp ) free(src_add_tmp);
+    }
+  else if ( src_grid->lextrapolate )
+    {
+      int search_result;
+
+      if ( num_neighbors < 4 )
+	{
+	  int nbr4_add[4];
+	  double nbr4_dist[4];
+	  for ( n = 0; n < num_neighbors; ++n ) nbr4_add[n] = -1;
+	  search_result = grid_search_reg2d_nn(nx, ny, nbr4_add, nbr4_dist, plat, plon, src_center_lat, src_center_lon);
+	  if ( search_result < 0 )
+	    {
+	      for ( n = 0; n < num_neighbors; ++n ) nbr_add[n]  = nbr4_add[n];
+	      for ( n = 0; n < num_neighbors; ++n ) nbr_dist[n] = nbr4_dist[n];
+	    }
+	}
+      else
+	{
+	  search_result = grid_search_reg2d_nn(nx, ny, nbr_add, nbr_dist, plat, plon, src_center_lat, src_center_lon);
+	}
+
+      if ( search_result >= 0 )
+	for ( n = 0; n < num_neighbors; ++n ) nbr_add[n] = -1;
+    }
+} // grid_search_nbr_reg2d
+
+
+void grid_search_nbr(struct gridsearch *gs, int num_neighbors, int *restrict nbr_add, double *restrict nbr_dist, double plon, double plat)
+{
+  /*
+    Output variables:
+
+    int nbr_add[num_neighbors]     ! address of each of the closest points
+    double nbr_dist[num_neighbors] ! distance to each of the closest points
+
+    Input variables:
+
+    double plat,         ! latitude  of the search point
+    double plon,         ! longitude of the search point
+  */
+
+  double search_radius = get_search_radius();
+
+  // Initialize distance and address arrays
+  for ( int n = 0; n < num_neighbors; ++n ) nbr_add[n]  = -1;
+  for ( int n = 0; n < num_neighbors; ++n ) nbr_dist[n] = BIGNUM;
+
+  int ndist = num_neighbors;
+  ndist = ndist*2; // check some more points if distance is the same use the smaller index (nadd)
+  if ( ndist > (int)gs->n ) ndist = gs->n;
+  double dist[ndist];
+  int    adds[ndist];
+
+  const double range0 = SQR(2*search_radius);
+  double range = range0;
+
+  int j = 0;
+
+  if ( num_neighbors == 1 )
+    {
+      unsigned nadd = gridsearch_nearest(gs, plon, plat, &range);
+      if ( nadd != GS_NOT_FOUND )
+        {
+          //if ( range < range0 )
+            {
+              dist[j] = sqrt(range);
+              adds[j] = nadd;
+              j++;
+            }
+        }
+    }
+  else
+    {
+      struct pqueue *gs_result = gridsearch_qnearest(gs, plon, plat, &range, ndist);
+      if ( gs_result )
+        {
+          unsigned nadd;
+          struct resItem *p;
+          while ( pqremove_min(gs_result, &p) )
+            {
+              nadd  = p->node->index;
+              range = p->dist_sq;
+              Free(p); // Free the result node taken from the heap
+              
+              if ( range < range0 )
+                {
+                  dist[j] = sqrt(range);
+                  adds[j] = nadd;
+                  j++;
+                }
+            }
+          Free(gs_result->d); // free the heap
+          Free(gs_result);    // and free the heap information structure
+        }
+    }
+  
+  ndist = j;
+
+  for ( j = 0; j < ndist; ++j )
+    nbr_store_distance(adds[j], dist[j], num_neighbors, nbr_add, nbr_dist);
+
+  nbr_check_distance(num_neighbors, nbr_add, nbr_dist);
+
+} // grid_search_nbr
+
+//  This routine computes the inverse-distance weights for a nearest-neighbor interpolation.
+
+void remap_distwgt_weights(unsigned num_neighbors, remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv)
+{
+  int remap_grid_type = src_grid->remap_grid_type;
+
+  if ( cdoVerbose ) cdoPrint("Called %s()", __func__);
+
+  progressInit();
+
+  // Compute mappings from source to target grid
+
+  unsigned src_grid_size = src_grid->size;
+  unsigned tgt_grid_size = tgt_grid->size;
+  unsigned nx = src_grid->dims[0];
+  unsigned ny = src_grid->dims[1];
+
+  weightlinks_t *weightlinks = (weightlinks_t *) Malloc(tgt_grid_size*sizeof(weightlinks_t));
+  weightlinks[0].addweights = (addweight_t *) Malloc(num_neighbors*tgt_grid_size*sizeof(addweight_t));
+  for ( unsigned tgt_cell_add = 1; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+    weightlinks[tgt_cell_add].addweights = weightlinks[0].addweights + num_neighbors*tgt_cell_add;
+
+  int nbr_mask[num_neighbors];    // mask at nearest neighbors
+  int nbr_add[num_neighbors];     // source address at nearest neighbors
+  double nbr_dist[num_neighbors]; // angular distance four nearest neighbors
+
+#if defined(_OPENMP)
+  double start = 0;
+  if ( cdoVerbose ) start = omp_get_wtime();
+#endif
+
+  struct gridsearch *gs = NULL;
+  if ( remap_grid_type == REMAP_GRID_TYPE_REG2D )
+    gs = gridsearch_create_reg2d(nx, ny, src_grid->reg2d_center_lon, src_grid->reg2d_center_lat);
+  else if ( num_neighbors == 1 )
+    gs = gridsearch_create_nn(src_grid_size, src_grid->cell_center_lon, src_grid->cell_center_lat);
+  else
+    gs = gridsearch_create(src_grid_size, src_grid->cell_center_lon, src_grid->cell_center_lat);
+
+#if defined(_OPENMP)
+  if ( cdoVerbose ) printf("gridsearch created: %.2f seconds\n", omp_get_wtime()-start);
+  if ( cdoVerbose ) start = omp_get_wtime();
+#endif
+
+  // Loop over destination grid
+
+  double findex = 0;
+
+#if defined(_OPENMP)
+#pragma omp parallel for default(none) \
+  shared(gs, weightlinks, num_neighbors, remap_grid_type, src_grid, tgt_grid, tgt_grid_size, findex) \
+  private(nbr_mask, nbr_add, nbr_dist)
+#endif
+  for ( unsigned tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+    {
+#if defined(_OPENMP)
+#include "pragma_omp_atomic_update.h"
+#endif
+      findex++;
+      if ( cdo_omp_get_thread_num() == 0 ) progressStatus(0, 1, findex/tgt_grid_size);
+      
+      weightlinks[tgt_cell_add].nlinks = 0;	
+
+      if ( ! tgt_grid->mask[tgt_cell_add] ) continue;
+	
+      double plon = 0, plat = 0;
+      remapgrid_get_lonlat(tgt_grid, tgt_cell_add, &plon, &plat);
+
+      // Find nearest grid points on source grid and distances to each point
+      if ( remap_grid_type == REMAP_GRID_TYPE_REG2D )
+	grid_search_nbr_reg2d(gs, num_neighbors, src_grid, nbr_add, nbr_dist, 
+			      plon, plat, src_grid->dims);
+      else
+        grid_search_nbr(gs, num_neighbors, nbr_add, nbr_dist, plon, plat);
+
+      // Compute weights based on inverse distance if mask is false, eliminate those points
+      double dist_tot = nbr_compute_weights(num_neighbors, src_grid->mask, nbr_mask, nbr_add, nbr_dist);
+
+      // Normalize weights and store the link
+      unsigned nadds = nbr_normalize_weights(num_neighbors, dist_tot, nbr_mask, nbr_add, nbr_dist);
+
+      for ( unsigned n = 0; n < nadds; ++n )
+        if ( nbr_mask[n] ) tgt_grid->cell_frac[tgt_cell_add] = ONE;
+
+      store_weightlinks(0, nadds, nbr_add, nbr_dist, tgt_cell_add, weightlinks);
+    }
+
+  progressStatus(0, 1, 1);
+
+  if ( gs ) gridsearch_delete(gs);
+
+  weightlinks2remaplinks(0, tgt_grid_size, weightlinks, rv);
+
+  if ( weightlinks ) Free(weightlinks);
+
+#if defined(_OPENMP)
+  if ( cdoVerbose ) printf("gridsearch nearest: %.2f seconds\n", omp_get_wtime()-start);
+#endif
+
+} // remap_distwgt_weights
+
+static
+void distwgt_remap(double* restrict tgt_point, const double* restrict src_array, long nadds, const double wgts[4], const int src_add[4])
+{
+  *tgt_point = 0.;
+  for ( int n = 0; n < nadds; ++n ) *tgt_point += src_array[src_add[n]]*wgts[n];
+}
+
+
+void remap_distwgt(unsigned num_neighbors, remapgrid_t *src_grid, remapgrid_t *tgt_grid, const double* restrict src_array, double* restrict tgt_array, double missval)
+{
+  int src_remap_grid_type = src_grid->remap_grid_type;
+
+  if ( cdoVerbose ) cdoPrint("Called %s()", __func__);
+
+  progressInit();
+
+  // Compute mappings from source to target grid 
+
+  unsigned src_grid_size = src_grid->size;
+  unsigned tgt_grid_size = tgt_grid->size;
+  unsigned nx = src_grid->dims[0];
+  unsigned ny = src_grid->dims[1];
+
+  int nbr_mask[num_neighbors];    // mask at nearest neighbors
+  int nbr_add[num_neighbors];     // source address at nearest neighbors
+  double nbr_dist[num_neighbors]; // angular distance four nearest neighbors
+
+#if defined(_OPENMP)
+  double start = 0;
+  if ( cdoVerbose ) start = omp_get_wtime();
+#endif
+
+  struct gridsearch *gs = NULL;
+  if ( src_remap_grid_type == REMAP_GRID_TYPE_REG2D )
+    gs = gridsearch_create_reg2d(nx, ny, src_grid->reg2d_center_lon, src_grid->reg2d_center_lat);
+  else if ( num_neighbors == 1 )
+    gs = gridsearch_create_nn(src_grid_size, src_grid->cell_center_lon, src_grid->cell_center_lat);
+  else
+    gs = gridsearch_create(src_grid_size, src_grid->cell_center_lon, src_grid->cell_center_lat);
+
+#if defined(_OPENMP)
+  if ( cdoVerbose ) printf("gridsearch created: %.2f seconds\n", omp_get_wtime()-start);
+  if ( cdoVerbose ) start = omp_get_wtime();
+#endif
+
+  // Loop over destination grid
+
+  double findex = 0;
+
+#if defined(_OPENMP)
+#pragma omp parallel for default(none) \
+  shared(gs, num_neighbors, src_remap_grid_type, src_grid, tgt_grid, tgt_grid_size, findex) \
+  shared(src_array, tgt_array, missval) \
+  private(nbr_mask, nbr_add, nbr_dist)
+#endif
+  for ( unsigned tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+    {
+#if defined(_OPENMP)
+#include "pragma_omp_atomic_update.h"
+#endif
+      findex++;
+      if ( cdo_omp_get_thread_num() == 0 ) progressStatus(0, 1, findex/tgt_grid_size);
+      
+      tgt_array[tgt_cell_add] = missval;
+
+      if ( ! tgt_grid->mask[tgt_cell_add] ) continue;
+
+      double plon = 0, plat = 0;
+      remapgrid_get_lonlat(tgt_grid, tgt_cell_add, &plon, &plat);
+
+      // Find nearest grid points on source grid and distances to each point
+      if ( src_remap_grid_type == REMAP_GRID_TYPE_REG2D )
+	grid_search_nbr_reg2d(gs, num_neighbors, src_grid, nbr_add, nbr_dist, 
+			      plon, plat, src_grid->dims);
+      else
+        grid_search_nbr(gs, num_neighbors, nbr_add, nbr_dist, plon, plat);
+      
+      // Compute weights based on inverse distance if mask is false, eliminate those points
+      double dist_tot = nbr_compute_weights(num_neighbors, src_grid->mask, nbr_mask, nbr_add, nbr_dist);
+
+      // Normalize weights and store the link
+      unsigned nadds = nbr_normalize_weights(num_neighbors, dist_tot, nbr_mask, nbr_add, nbr_dist);
+
+      for ( unsigned n = 0; n < nadds; ++n )
+        if ( nbr_mask[n] ) tgt_grid->cell_frac[tgt_cell_add] = ONE;
+
+      if ( nadds > 1 ) sort_add_and_wgts(nadds, nbr_add, nbr_dist);
+
+      if ( nadds ) distwgt_remap(&tgt_array[tgt_cell_add], src_array, nadds, nbr_dist, nbr_add);
+    }
+
+  progressStatus(0, 1, 1);
+
+  if ( gs ) gridsearch_delete(gs);
+
+#if defined(_OPENMP)
+  if ( cdoVerbose ) printf("gridsearch nearest: %.2f seconds\n", omp_get_wtime()-start);
+#endif
+
+} // remap_distwgt
diff --git a/src/remap_distwgt_scrip.c b/src/remap_distwgt_scrip.c
deleted file mode 100644
index 552c959..0000000
--- a/src/remap_distwgt_scrip.c
+++ /dev/null
@@ -1,513 +0,0 @@
-#include "cdo.h"
-#include "cdo_int.h"
-#include "grid.h"
-#include "remap.h"
-#include "remap_store_link.h"
-
-
-/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
-/*                                                                         */
-/*      INTERPOLATION USING A DISTANCE-WEIGHTED AVERAGE                    */
-/*                                                                         */
-/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
-
-static
-void get_restrict_add(remapgrid_t *src_grid, double plat, const int *restrict src_bin_add, int *minadd, int *maxadd)
-{
-  int n, n2;
-  int min_add = 0, max_add = 0, nm1, np1;
-  int nbins;
-  restr_t rlat;
-  restr_t *bin_lats = src_grid->bin_lats;
-
-  nbins = src_grid->num_srch_bins;
-
-  rlat = RESTR_SCALE(plat);
-
-  for ( n = 0; n < nbins; ++n )
-    {
-      n2 = n<<1;
-      if ( rlat >= bin_lats[n2  ] && rlat <= bin_lats[n2+1] )
-	{
-	  min_add = src_bin_add[n2  ];
-	  max_add = src_bin_add[n2+1];
-
-	  nm1 = MAX(n-1, 0);
-	  np1 = MIN(n+1, nbins-1);
-
-	  min_add = MIN(min_add, src_bin_add[2*nm1  ]);
-	  max_add = MAX(max_add, src_bin_add[2*nm1+1]);
-	  min_add = MIN(min_add, src_bin_add[2*np1  ]);
-	  max_add = MAX(max_add, src_bin_add[2*np1+1]);
-	}
-    }
-
-  *minadd = min_add;
-  *maxadd = max_add;
-  /*
-  if ( cdoVerbose )
-    printf("plon %g plat %g min_add %ld max_add %ld diff %ld\n",
-	   plon, plat, min_add, max_add, max_add-min_add);
-  */
-}
-
-static
-void nbr_store_distance(int nadd, double distance, int num_neighbors, int *restrict nbr_add, double *restrict nbr_dist)
-{
-  if ( num_neighbors == 1 )
-    {
-      // if ( (distance+1.e-10) < nbr_dist[0] || ((fabs(distance-nbr_dist[0]) < 1.e-10) && nadd < nbr_add[0]) )
-      if ( distance < nbr_dist[0] || (distance <= nbr_dist[0] && nadd < nbr_add[0]) )
-	{
-	  nbr_add[0]  = nadd;
-	  nbr_dist[0] = distance;
-	}
-    }
-  else
-    {
-      int n, nchk;
-      for ( nchk = 0; nchk < num_neighbors; ++nchk )
-	{
-	  if ( distance < nbr_dist[nchk] )
-	    {
-	      for ( n = num_neighbors-1; n > nchk; --n )
-		{
-		  nbr_add[n]  = nbr_add[n-1];
-		  nbr_dist[n] = nbr_dist[n-1];
-		}
-	      nbr_add[nchk]  = nadd;
-	      nbr_dist[nchk] = distance;
-	      break;
-	    }
-	}
-    }
-}
-
-static
-void nbr_check_distance(int num_neighbors, const int *restrict nbr_add, double *restrict nbr_dist)
-{
-  int nchk;
-  double distance;
-
-  /* Uwe Schulzweida: if distance is zero, set to small number */
-  for ( nchk = 0; nchk < num_neighbors; ++nchk )
-    {
-      if ( nbr_add[nchk] >= 0 )
-	{
-	  distance = nbr_dist[nchk];
-	  if ( IS_EQUAL(distance, 0.) ) distance = TINY;
-	  nbr_dist[nchk] = distance;
-	}
-    }
-}
-
-
-static
-double get_search_radius(void)
-{
-  double search_radius;
-  extern double remap_search_radius;
-
-  search_radius = remap_search_radius;
-
-  if ( search_radius <    0. ) search_radius = 0.;
-  if ( search_radius >  180. ) search_radius = 180.;
-
-  search_radius = cos(search_radius*DEG2RAD);
-
-  return (search_radius);
-}
-
-/*
-   This routine finds the closest num_neighbor points to a search 
-   point and computes a distance to each of the neighbors.
-*/
-static
-void grid_search_nbr_reg2d(int num_neighbors, remapgrid_t *src_grid, int *restrict nbr_add, double *restrict nbr_dist, 
-			   double plat, double plon, const int *restrict src_grid_dims,
-			   const double *restrict sinlat, const double *restrict coslat,
-			   const double *restrict sinlon, const double *restrict coslon,
-			   const double *restrict src_center_lat, const double *restrict src_center_lon)
-{
-  /*
-    Output variables:
-
-    int nbr_add[num_neighbors]     ! address of each of the closest points
-    double nbr_dist[num_neighbors] ! distance to each of the closest points
-
-    Input variables:
-
-    double plat,         ! latitude  of the search point
-    double plon,         ! longitude of the search point
-  */
-  /*  Local variables */
-  int lfound;
-  int n, nadd;
-  int nx, nxm, ny;
-  long ii, jj;
-  int i, j, ix;
-  int src_add[25];
-  int num_add = 0;
-  double distance;   //  Angular distance
-  double search_radius = get_search_radius();
-  double coslat_dst = cos(plat);  // cos(lat)  of the search point
-  double coslon_dst = cos(plon);  // cos(lon)  of the search point
-  double sinlat_dst = sin(plat);  // sin(lat)  of the search point
-  double sinlon_dst = sin(plon);  // sin(lon)  of the search point
-  nx = src_grid_dims[0];
-  ny = src_grid_dims[1];
-
-  nxm = nx;
-  if ( src_grid->is_cyclic ) nxm++;
-
-  if ( plon < src_center_lon[0]     ) plon += PI2;
-  if ( plon > src_center_lon[nxm-1] ) plon -= PI2;
-
-  lfound = rect_grid_search(&ii, &jj, plon, plat, nxm, ny, src_center_lon, src_center_lat);
-
-  if ( lfound )
-    {
-      if ( src_grid->is_cyclic && ii == (nxm-1) ) ii = 0;
-
-      for ( j = (jj-2); j <= (jj+2); ++j )
-	for ( i = (ii-2); i <= (ii+2); ++i )
-	  {
-	    ix = i;
-	    
-	    if ( src_grid->is_cyclic )
-	      {
-		if ( ix <   0 ) ix += nx;
-		if ( ix >= nx ) ix -= nx;
-	      }
-
-	    if ( ix >= 0 && ix < nx && j >= 0 && j < ny )
-	      src_add[num_add++] = j*nx+ix;
-	  }
-      /*
-      num_add = 0;
-
-      for ( j = (jj-1); j <= jj; ++j )
-	for ( i = (ii-1); i <= ii; ++i )
-	  {
-	    ix = i;
-	    if ( src_grid->is_cyclic && ix == (nxm-1) ) ix = 0;
-
-	    src_add[num_add++] = j*nx+ix;
-	  }
-      */
-    }
-
-  /* Initialize distance and address arrays */
-  for ( n = 0; n < num_neighbors; ++n )
-    {
-      nbr_add[n]  = -1;
-      nbr_dist[n] = BIGNUM;
-    }
-
-  if ( lfound )
-    {
-      int ix, iy;
-
-      for ( int na = 0; na < num_add; ++na )
-	{
-	  nadd = src_add[na];
-
-	  iy = nadd/nx;
-	  ix = nadd - iy*nx;
-
-	  /* Find distance to this point */
-	  distance =  sinlat_dst*sinlat[iy] + coslat_dst*coslat[iy]*
-	             (coslon_dst*coslon[ix] + sinlon_dst*sinlon[ix]);
-	  /*
-	  distance =  sinlat_dst*sinlat[nadd] + coslat_dst*coslat[nadd]*
-	             (coslon_dst*coslon[nadd] + sinlon_dst*sinlon[nadd]);
-	  */
-	  /* 2008-07-30 Uwe Schulzweida: check that distance is inside the range of -1 to 1,
-	                                 otherwise the result of acos(distance) is NaN */
-	  if ( distance >  1. ) distance =  1.;
-
-	  if ( distance >= search_radius )
-	    {
-	      distance = acos(distance);
-
-	      /* Store the address and distance if this is one of the smallest four so far */
-	      nbr_store_distance(nadd, distance, num_neighbors, nbr_add, nbr_dist);
-	    }
-	}
-
-      nbr_check_distance(num_neighbors, nbr_add, nbr_dist);
-    }
-  else if ( src_grid->lextrapolate )
-    {
-      int search_result;
-
-      if ( num_neighbors < 4 )
-	{
-	  int nbr4_add[4];
-	  double nbr4_dist[4];
-	  for ( n = 0; n < num_neighbors; ++n ) nbr4_add[n] = -1;
-	  search_result = grid_search_reg2d_nn(nx, ny, nbr4_add, nbr4_dist, plat, plon, src_center_lat, src_center_lon);
-	  if ( search_result < 0 )
-	    {
-	      for ( n = 0; n < num_neighbors; ++n ) nbr_add[n]  = nbr4_add[n];
-	      for ( n = 0; n < num_neighbors; ++n ) nbr_dist[n] = nbr4_dist[n];
-	    }
-	}
-      else
-	{
-	  search_result = grid_search_reg2d_nn(nx, ny, nbr_add, nbr_dist, plat, plon, src_center_lat, src_center_lon);
-	}
-
-      if ( search_result >= 0 )
-	for ( n = 0; n < num_neighbors; ++n ) nbr_add[n] = -1;
-    }
-}  /*  grid_search_nbr_reg2d  */
-
-static
-void grid_search_nbr(int num_neighbors, remapgrid_t *src_grid, int *restrict nbr_add, double *restrict nbr_dist, 
-		     double plat, double plon, const int *restrict src_bin_add,
-		     const double *restrict sinlat, const double *restrict coslat,
-		     const double *restrict sinlon, const double *restrict coslon)
-{
-  /*
-    Output variables:
-
-    int nbr_add[num_neighbors]     ! address of each of the closest points
-    double nbr_dist[num_neighbors] ! distance to each of the closest points
-
-    Input variables:
-
-    int src_bin_add[][2]  ! search bins for restricting search
-
-    double plat,         ! latitude  of the search point
-    double plon,         ! longitude of the search point
-  */
-  /*  Local variables */
-  int n, nadd;
-  int min_add, max_add;
-  double search_radius = get_search_radius();
-  double coslat_dst = cos(plat);  // cos(lat)  of the search point
-  double coslon_dst = cos(plon);  // cos(lon)  of the search point
-  double sinlat_dst = sin(plat);  // sin(lat)  of the search point
-  double sinlon_dst = sin(plon);  // sin(lon)  of the search point
-  /* Loop over source grid and find nearest neighbors                         */
-  /* restrict the search using search bins expand the bins to catch neighbors */
-
-  get_restrict_add(src_grid, plat, src_bin_add, &min_add, &max_add);
-
-  /* Initialize distance and address arrays */
-  for ( n = 0; n < num_neighbors; ++n ) nbr_add[n]  = -1;
-  for ( n = 0; n < num_neighbors; ++n ) nbr_dist[n] = BIGNUM;
-
-  int i, ndist = max_add - min_add + 1;
-
-  if ( ndist <= 0 ) return;
-
-  double distance;     /* Angular distance */
-  double *dist = (double*) malloc(ndist*sizeof(double));
-  int    *adds = (int*) malloc(ndist*sizeof(int));
-
-  int j = 0;
-  for ( i = 0; i < ndist; ++i )
-    {
-      nadd = min_add+i;
-      /* Find distance to this point */
-      distance =  sinlat_dst*sinlat[nadd] + coslat_dst*coslat[nadd]*
-	         (coslon_dst*coslon[nadd] + sinlon_dst*sinlon[nadd]);
-      /* 2008-07-30 Uwe Schulzweida: check that distance is inside the range of -1 to 1,
-                                     otherwise the result of acos(distance) is NaN */
-      if ( distance >  1. ) distance =  1.;
-
-      if ( distance >= search_radius )
-	{
-	  dist[j] = distance;
-	  adds[j] = nadd;
-	  j++;
-	}
-    }
-  ndist = j;
-
-#if defined(HAVE_OPENMP4)
-  //#pragma omp simd aligned(dist:16)
-#pragma omp simd
-#endif
-  for ( j = 0; j < ndist; ++j )
-    dist[j] = acos(dist[j]);
-
-  for ( j = 0; j < ndist; ++j )
-    nbr_store_distance(adds[j], dist[j], num_neighbors, nbr_add, nbr_dist);
-
-  free(adds);
-  free(dist);
-
-  nbr_check_distance(num_neighbors, nbr_add, nbr_dist);
-
-}  /*  grid_search_nbr  */
-
-/*
-  -----------------------------------------------------------------------------------------
-
-   This routine computes the inverse-distance weights for a nearest-neighbor interpolation.
-
-  -----------------------------------------------------------------------------------------
-*/
-void scrip_remap_weights_distwgt(int num_neighbors, remapgrid_t *src_grid, remapgrid_t *tgt_grid, remapvars_t *rv)
-{
-  /*  Local variables */
-  long n, nadds;
-  long tgt_cell_add;              /* destination address                         */
-  double dist_tot;                /* sum of neighbor distances (for normalizing) */
-  double *coslat, *sinlat;        /* cosine, sine of grid lats (for distance)    */
-  double *coslon, *sinlon;        /* cosine, sine of grid lons (for distance)    */
-  double plat, plon;              /* lat/lon coords of destination point         */
-  int remap_grid_type = src_grid->remap_grid_type;
-
-  if ( cdoVerbose ) cdoPrint("Called %s()", __func__);
-
-  progressInit();
-
-  /* Compute mappings from source to target grid */
-
-  long src_grid_size = src_grid->size;
-  long tgt_grid_size = tgt_grid->size;
-
-  weightlinks_t *weightlinks = (weightlinks_t *) malloc(tgt_grid_size*sizeof(weightlinks_t));
-
-  /* Compute cos, sin of lat/lon on source grid for distance calculations */
-
-  if ( remap_grid_type == REMAP_GRID_TYPE_REG2D )
-    {
-      long nx = src_grid->dims[0];
-      long ny = src_grid->dims[1];
-
-      coslat = (double*) malloc(ny*sizeof(double));
-      coslon = (double*) malloc(nx*sizeof(double));
-      sinlat = (double*) malloc(ny*sizeof(double));
-      sinlon = (double*) malloc(nx*sizeof(double));
-
-      double *center_lon = src_grid->reg2d_center_lon;
-      double *center_lat = src_grid->reg2d_center_lat;
-
-      for ( n = 0; n < nx; ++n )
-	{
-	  double rlon = center_lon[n];
-	  if ( rlon > PI2  ) rlon -= PI2;
-	  if ( rlon < ZERO ) rlon += PI2;
-	  coslon[n] = cos(rlon);
-	  sinlon[n] = sin(rlon);
-	}
-      for ( n = 0; n < ny; ++n )
-	{
-	  coslat[n] = cos(center_lat[n]);
-	  sinlat[n] = sin(center_lat[n]);
-	}
-    }
-  else
-    {
-      coslat = (double*) malloc(src_grid_size*sizeof(double));
-      coslon = (double*) malloc(src_grid_size*sizeof(double));
-      sinlat = (double*) malloc(src_grid_size*sizeof(double));
-      sinlon = (double*) malloc(src_grid_size*sizeof(double));
-
-      double *center_lon = src_grid->cell_center_lon;
-      double *center_lat = src_grid->cell_center_lat;
-
-#if defined(_OPENMP)
-#pragma omp parallel for default(none) shared(center_lon, center_lat, src_grid_size, coslat, coslon, sinlat, sinlon)
-#endif
-      for ( n = 0; n < src_grid_size; ++n )
-	{
-	  coslon[n] = cos(center_lon[n]);
-	  sinlon[n] = sin(center_lon[n]);
-	  coslat[n] = cos(center_lat[n]);
-	  sinlat[n] = sin(center_lat[n]);
-	}
-    }
-
-  /* Loop over destination grid  */
-
-  double findex = 0;
-
-#if defined(_OPENMP)
-#pragma omp parallel for default(none) \
-  shared(ompNumThreads, weightlinks, num_neighbors, remap_grid_type, src_grid, tgt_grid, rv, tgt_grid_size, coslat, coslon, sinlat, sinlon, findex) \
-  private(tgt_cell_add, n, nadds, dist_tot, plat, plon)
-#endif
-  for ( tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
-    {
-      int nbr_mask[num_neighbors];    /* mask at nearest neighbors                   */
-      int nbr_add[num_neighbors];     /* source address at nearest neighbors         */
-      double nbr_dist[num_neighbors]; /* angular distance four nearest neighbors     */
-      int lprogress = 1;
-      if ( cdo_omp_get_thread_num() != 0 ) lprogress = 0;
-
-#if defined(_OPENMP)
-#include "pragma_omp_atomic_update.h"
-#endif
-      findex++;
-      if ( lprogress ) progressStatus(0, 1, findex/tgt_grid_size);
-
-      weightlinks[tgt_cell_add].nlinks = 0;	
-
-      if ( ! tgt_grid->mask[tgt_cell_add] ) continue;
-	
-      plat = tgt_grid->cell_center_lat[tgt_cell_add];
-      plon = tgt_grid->cell_center_lon[tgt_cell_add];
-
-      /* Find nearest grid points on source grid and distances to each point */
-      if ( remap_grid_type == REMAP_GRID_TYPE_REG2D )
-	grid_search_nbr_reg2d(num_neighbors, src_grid, nbr_add, nbr_dist, 
-			      plat, plon, src_grid->dims,
-			      sinlat, coslat, sinlon, coslon,
-			      src_grid->reg2d_center_lat, src_grid->reg2d_center_lon);
-      else
-	grid_search_nbr(num_neighbors, src_grid, nbr_add, nbr_dist, 
-			plat, plon, src_grid->bin_addr,
-			sinlat, coslat, sinlon, coslon);
-
-      /* Compute weights based on inverse distance if mask is false, eliminate those points */
-
-      dist_tot = 0.;
-      for ( n = 0; n < num_neighbors; ++n )
-	{
-	  // printf("tgt_cell_add %ld %ld %d %g\n", tgt_cell_add, n, nbr_add[n], nbr_dist[n]);
-	  nbr_mask[n] = FALSE;
-
-	  /* Uwe Schulzweida: check if nbr_add is valid */
-	  if ( nbr_add[n] >= 0 )
-	    if ( src_grid->mask[nbr_add[n]] )
-	      {
-		nbr_dist[n] = ONE/nbr_dist[n];
-		dist_tot = dist_tot + nbr_dist[n];
-		nbr_mask[n] = TRUE;
-	      }
-	}
-
-      /* Normalize weights and store the link */
-
-      nadds = 0;
-      for ( n = 0; n < num_neighbors; ++n )
-	{
-          if ( nbr_mask[n] )
-	    {
-	      nbr_dist[nadds] = nbr_dist[n]/dist_tot;
-	      nbr_add[nadds]  = nbr_add[n];
-	      nadds++;
-
-	      tgt_grid->cell_frac[tgt_cell_add] = ONE;
-	    }
-	}
-
-      store_weightlinks(nadds, nbr_add, nbr_dist, tgt_cell_add, weightlinks);
-    }
-
-  free(coslat);
-  free(coslon);
-  free(sinlat);
-  free(sinlon);
-
-  weightlinks2remaplinks(tgt_grid_size, weightlinks, rv);
-
-  if ( weightlinks ) free(weightlinks);
-
-}  /* scrip_remap_weights_distwgt */
diff --git a/src/remap_scrip_io.c b/src/remap_scrip_io.c
index dbadc58..951b05d 100644
--- a/src/remap_scrip_io.c
+++ b/src/remap_scrip_io.c
@@ -16,7 +16,7 @@
 
 
 void remapgrid_init(remapgrid_t *grid);
-void remapGridRealloc(int map_type, remapgrid_t *grid);
+void remapgrid_alloc(int map_type, remapgrid_t *grid);
 
 
 #if defined(HAVE_LIBNETCDF)
@@ -79,17 +79,14 @@ void write_remap_scrip(const char *interp_file, int map_type, int submap_type, i
 
   int nc_dims2_id[2];       /* netCDF ids for 2d array dims             */
 
-  char *map_name = "SCRIP remapping with CDO";
+  const char *map_name = "SCRIP remapping with CDO";
   char normalize_opt[64] = "unknown";
   char map_method[64] = "unknown";
   char tmp_string[64] = "unknown";
-  char history[1024] = "date and time";
   char src_grid_name[64] = "source grid";
   char tgt_grid_name[64] = "dest grid";
-  char *src_grid_units = "radians";
-  char *tgt_grid_units = "radians";
-  time_t date_and_time_in_sec;
-  struct tm *date_and_time;
+  const char *src_grid_units = "radians";
+  const char *tgt_grid_units = "radians";
   long i;
   int lgridarea = FALSE;
   int writemode = NC_CLOBBER;
@@ -153,16 +150,13 @@ void write_remap_scrip(const char *interp_file, int map_type, int submap_type, i
     cdoAbort("Number of remap links is 0, no remap weights found!");
 
   {
-    size_t filesize;
-    size_t nele1, nele2;
-
-    nele1 = 4*8 + 4;
-    nele2 = 4*8 + 4;
+    size_t nele1 = 4*8 + 4;
+    size_t nele2 = 4*8 + 4;
     if ( src_grid.lneed_cell_corners ) nele1 += src_grid.num_cell_corners*2*8;
     if ( tgt_grid.lneed_cell_corners ) nele2 += tgt_grid.num_cell_corners*2*8;
-    filesize = src_grid.size*(nele1) +
-               tgt_grid.size*(nele2) +
-               rv.num_links*(4 + 4 + rv.num_wts*8);
+    size_t filesize = src_grid.size*(nele1) +
+                      tgt_grid.size*(nele2) +
+                      rv.num_links*(4 + 4 + rv.num_wts*8);
 
     if ( cdoVerbose )
       cdoPrint("Filesize for remap weights: ~%lu", (unsigned long) filesize);
@@ -193,18 +187,6 @@ void write_remap_scrip(const char *interp_file, int map_type, int submap_type, i
   if ( map_type == MAP_TYPE_CONSERV && submap_type == SUBMAP_TYPE_NONE )
     nce(nc_put_att_int(nc_file_id, NC_GLOBAL, "remap_order", NC_INT, 1L, &remap_order));
 
-  /* History */
-  date_and_time_in_sec = time(NULL);
-
-  if ( date_and_time_in_sec != -1 )
-    {
-      date_and_time = localtime(&date_and_time_in_sec);
-      (void) strftime(history, 1024, "%d %b %Y : ", date_and_time);
-      strcat(history, commandLine());
-    }
-
-  nce(nc_put_att_text(nc_file_id, NC_GLOBAL, "history", strlen(history), history));
-
   /* File convention */
   strcpy(tmp_string, "SCRIP");
   nce(nc_put_att_text(nc_file_id, NC_GLOBAL, "conventions", strlen(tmp_string), tmp_string));
@@ -216,6 +198,20 @@ void write_remap_scrip(const char *interp_file, int map_type, int submap_type, i
   gridName(gridInqType(tgt_grid.gridID), tgt_grid_name);
   nce(nc_put_att_text(nc_file_id, NC_GLOBAL, "dest_grid", strlen(tgt_grid_name), tgt_grid_name));
 
+  /* History */
+  time_t date_and_time_in_sec = time(NULL);
+  if ( date_and_time_in_sec != -1 )
+    {
+      char history[1024] = "date and time";
+      struct tm *date_and_time = localtime(&date_and_time_in_sec);
+      (void) strftime(history, 1024, "%d %b %Y : ", date_and_time);
+      strcat(history, commandLine());
+      nce(nc_put_att_text(nc_file_id, NC_GLOBAL, "history", strlen(history), history));
+    }
+
+  if ( CDO_Version_Info )
+    nce(nc_put_att_text(nc_file_id, NC_GLOBAL, "CDO", (int)strlen(cdoComment())+1, cdoComment()));
+
   /* Prepare netCDF dimension info */
 
   /* Define grid size dimensions */
@@ -637,8 +633,8 @@ void read_remap_scrip(const char *interp_file, int gridID1, int gridID2, int *ma
       gridID1_gme_c = gridToUnstructured(gridID1, 1);
     }
 
-  remapGridRealloc(rv->map_type, src_grid);
-  remapGridRealloc(rv->map_type, tgt_grid);
+  remapgrid_alloc(rv->map_type, src_grid);
+  remapgrid_alloc(rv->map_type, tgt_grid);
 
   if ( gridInqType(gridID1) == GRID_GME ) gridInqMaskGME(gridID1_gme_c, src_grid->vgpm);    
 
@@ -651,10 +647,10 @@ void read_remap_scrip(const char *interp_file, int gridID1, int gridID2, int *ma
 
   /* Allocate address and weight arrays for mapping 1 */
 
-  rv->src_cell_add = (int*) malloc(rv->num_links*sizeof(int));
-  rv->tgt_cell_add = (int*) malloc(rv->num_links*sizeof(int));
+  rv->src_cell_add = (int*) Malloc(rv->num_links*sizeof(int));
+  rv->tgt_cell_add = (int*) Malloc(rv->num_links*sizeof(int));
 
-  rv->wts = (double*) malloc(rv->num_wts*rv->num_links*sizeof(double));
+  rv->wts = (double*) Malloc(rv->num_wts*rv->num_links*sizeof(double));
 
   /* Get variable ids */
 
diff --git a/src/remap_search_latbins.c b/src/remap_search_latbins.c
index aeb1218..3cc896a 100644
--- a/src/remap_search_latbins.c
+++ b/src/remap_search_latbins.c
@@ -1,4 +1,4 @@
-#include "cdo.h"
+#include "cdo_int.h"
 #include "remap.h"
 /*
 #if defined(_OPENMP)
@@ -43,7 +43,7 @@ void calc_bin_addr_omp(long gridsize, long nbins, const restr_t* restrict bin_la
   restr_t cell_bound_box_lat1, cell_bound_box_lat2;
 #if defined(_OPENMP)
   extern int ompNumThreads;
-  restr_t (*omp_bin_addr)[ompNumThreads] = malloc(nbins*sizeof(*omp_bin_addr));
+  restr_t (*omp_bin_addr)[ompNumThreads] = Malloc(nbins*sizeof(*omp_bin_addr));
 
   for ( int ompthID = 0; ompthID < ompNumThreads; ++ompthID )
     for ( n = 0; n < nbins; ++n )
@@ -101,7 +101,7 @@ void calc_bin_addr_omp(long gridsize, long nbins, const restr_t* restrict bin_la
 	}
     }
 
-  free(omp_bin_addr);
+  Free(omp_bin_addr);
 #endif
 }
 */
@@ -121,7 +121,7 @@ void calc_lat_bins(remapgrid_t* src_grid, remapgrid_t* tgt_grid, int map_type)
 
   if ( nbins > 0 )
     {
-      bin_lats = src_grid->bin_lats = (restr_t*) realloc(src_grid->bin_lats, 2*nbins*sizeof(restr_t));
+      bin_lats = src_grid->bin_lats = (restr_t*) Realloc(src_grid->bin_lats, 2*nbins*sizeof(restr_t));
 
       for ( n = 0; n < nbins; ++n )
 	{
@@ -130,28 +130,28 @@ void calc_lat_bins(remapgrid_t* src_grid, remapgrid_t* tgt_grid, int map_type)
 	  bin_lats[n2+1] = RESTR_SCALE((n+1)*dlat - PIH);
 	}
 
-      src_grid->bin_addr = (int*) realloc(src_grid->bin_addr, 2*nbins*sizeof(int));
+      src_grid->bin_addr = (int*) Realloc(src_grid->bin_addr, 2*nbins*sizeof(int));
 
       calc_bin_addr(src_grid->size, nbins, bin_lats, src_grid->cell_bound_box, src_grid->bin_addr);
 
       if ( map_type == MAP_TYPE_CONSERV || map_type == MAP_TYPE_CONSERV_YAC )
 	{
-	  tgt_grid->bin_addr = (int*) realloc(tgt_grid->bin_addr, 2*nbins*sizeof(int));
+	  tgt_grid->bin_addr = (int*) Realloc(tgt_grid->bin_addr, 2*nbins*sizeof(int));
 
 	  calc_bin_addr(tgt_grid->size, nbins, bin_lats, tgt_grid->cell_bound_box, tgt_grid->bin_addr);
 
-	  free(src_grid->bin_lats); src_grid->bin_lats = NULL;
+	  Free(src_grid->bin_lats); src_grid->bin_lats = NULL;
 	}
    }
 
   if ( map_type == MAP_TYPE_CONSERV_YAC )
     {
-      free(tgt_grid->cell_bound_box); tgt_grid->cell_bound_box = NULL;
+      Free(tgt_grid->cell_bound_box); tgt_grid->cell_bound_box = NULL;
     }
  
   if ( map_type == MAP_TYPE_DISTWGT )
     {
-      free(src_grid->cell_bound_box); src_grid->cell_bound_box = NULL;
+      Free(src_grid->cell_bound_box); src_grid->cell_bound_box = NULL;
     }
 }
 
diff --git a/src/remap_search_reg2d.c b/src/remap_search_reg2d.c
index 2d9d571..34092bb 100644
--- a/src/remap_search_reg2d.c
+++ b/src/remap_search_reg2d.c
@@ -1,8 +1,7 @@
-#include "cdo.h"
+#include "cdo_int.h"
 #include "remap.h"
 
 
-long find_element(double x, long nelem, const double *restrict array);
 int rect_grid_search(long *ii, long *jj, double x, double y, long nxm, long nym, const double *restrict xm, const double *restrict ym);
 
 
@@ -44,7 +43,7 @@ int grid_search_reg2d_nn(long nx, long ny, int *restrict nbr_add, double *restri
 	}
     }
 
-  sincoslon = (double*) malloc(nx*sizeof(double));
+  sincoslon = (double*) Malloc(nx*sizeof(double));
 
   for ( ii = 0; ii < nx; ++ii )
     sincoslon[ii] = coslon_dst*cos(src_center_lon[ii]) + sinlon_dst*sin(src_center_lon[ii]);
@@ -86,7 +85,7 @@ int grid_search_reg2d_nn(long nx, long ny, int *restrict nbr_add, double *restri
 	}
     }
 
-  free(sincoslon);
+  Free(sincoslon);
 
   for ( n = 0; n < 4; ++n ) nbr_dist[n] = ONE/(nbr_dist[n] + TINY);
   distance = 0.0;
@@ -120,23 +119,21 @@ int grid_search_reg2d(remapgrid_t *src_grid, int *restrict src_add, double *rest
   */
   /*  Local variables */
   int search_result = 0;
-  int lfound;
   long n;
-  long nx, nxm, ny;
   long ii, iix, jj;
 
   for ( n = 0; n < 4; ++n ) src_add[n] = 0;
 
-  nx = src_grid_dims[0];
-  ny = src_grid_dims[1];
+  long nx = src_grid_dims[0];
+  long ny = src_grid_dims[1];
 
-  nxm = nx;
+  long nxm = nx;
   if ( src_grid->is_cyclic ) nxm++;
 
   if ( /*plon < 0   &&*/ plon < src_center_lon[0]     ) plon += PI2;
   if ( /*plon > PI2 &&*/ plon > src_center_lon[nxm-1] ) plon -= PI2;
 
-  lfound = rect_grid_search(&ii, &jj, plon, plat, nxm, ny, src_center_lon, src_center_lat);
+  int lfound = rect_grid_search(&ii, &jj, plon, plat, nxm, ny, src_center_lon, src_center_lat);
 
   if ( lfound )
     {
diff --git a/src/remap_store_link.c b/src/remap_store_link.c
index e2a5a8e..f8d808b 100644
--- a/src/remap_store_link.c
+++ b/src/remap_store_link.c
@@ -3,7 +3,6 @@
 #include "remap.h"
 #include "remap_store_link.h"
 
-
 static
 int cmp_adds(const void *s1, const void *s2)
 {
@@ -31,9 +30,9 @@ int cmp_adds4(const void *s1, const void *s2)
 }
 
 static
-void sort_addweights(size_t num_weights, addweight_t *addweights)
+void sort_addweights(unsigned num_weights, addweight_t *addweights)
 {
-  size_t n;
+  unsigned n;
 
   for ( n = 1; n < num_weights; ++n )
     if ( addweights[n].add < addweights[n-1].add ) break;
@@ -43,9 +42,9 @@ void sort_addweights(size_t num_weights, addweight_t *addweights)
 }
 
 static
-void sort_addweights4(size_t num_weights, addweight4_t *addweights)
+void sort_addweights4(unsigned num_weights, addweight4_t *addweights)
 {
-  size_t n;
+  unsigned n;
 
   for ( n = 1; n < num_weights; ++n )
     if ( addweights[n].add < addweights[n-1].add ) break;
@@ -55,111 +54,122 @@ void sort_addweights4(size_t num_weights, addweight4_t *addweights)
 }
 
 
-void sort_add_and_wgts(size_t num_weights, int *src_add, double *wgts)
+void sort_add_and_wgts(unsigned num_weights, int *src_add, double *wgts)
 {
-  size_t n;
+  unsigned n;
 
   for ( n = 1; n < num_weights; ++n )
     if ( src_add[n] < src_add[n-1] ) break;
   if ( n == num_weights ) return;
 
-  addweight_t addweights[num_weights];
-
-  for ( n = 0; n < num_weights; ++n )
+  if ( num_weights )
     {
-      addweights[n].add    = src_add[n];
-      addweights[n].weight = wgts[n];
-    }
+      addweight_t addweights[num_weights];
 
-  qsort(addweights, num_weights, sizeof(addweight_t), cmp_adds);
+      for ( n = 0; n < num_weights; ++n )
+        {
+          addweights[n].add    = src_add[n];
+          addweights[n].weight = wgts[n];
+        }
 
-  for ( n = 0; n < num_weights; ++n )
-    {
-      src_add[n] = addweights[n].add;
-      wgts[n]    = addweights[n].weight;
-    }  
+      qsort(addweights, num_weights, sizeof(addweight_t), cmp_adds);
+
+      for ( n = 0; n < num_weights; ++n )
+        {
+          src_add[n] = addweights[n].add;
+          wgts[n]    = addweights[n].weight;
+        }  
+    }
 }
 
 
-void sort_add_and_wgts4(size_t num_weights, int *src_add, double wgts[4][4])
+void sort_add_and_wgts4(unsigned num_weights, int *src_add, double wgts[4][4])
 {
-  size_t n;
+  unsigned n;
 
   for ( n = 1; n < num_weights; ++n )
     if ( src_add[n] < src_add[n-1] ) break;
   if ( n == num_weights ) return;
 
-  addweight4_t addweights[num_weights];
-
-  for ( n = 0; n < num_weights; ++n )
+  if ( num_weights )
     {
-      addweights[n].add       = src_add[n];
-      for ( long k = 0; k < 4; ++k )
-	addweights[n].weight[k] = wgts[n][k];
+      addweight4_t addweights[num_weights];
+
+      for ( n = 0; n < num_weights; ++n )
+        {
+          addweights[n].add       = src_add[n];
+          for ( unsigned k = 0; k < 4; ++k )
+            addweights[n].weight[k] = wgts[n][k];
+        }
+
+      qsort(addweights, num_weights, sizeof(addweight4_t), cmp_adds4);
+
+      for ( n = 0; n < num_weights; ++n )
+        {
+          src_add[n] = addweights[n].add;
+          for ( unsigned k = 0; k < 4; ++k )
+            wgts[n][k] = addweights[n].weight[k];
+        }
     }
-
-  qsort(addweights, num_weights, sizeof(addweight4_t), cmp_adds4);
-
-  for ( n = 0; n < num_weights; ++n )
-    {
-      src_add[n] = addweights[n].add;
-      for ( long k = 0; k < 4; ++k )
-	wgts[n][k] = addweights[n].weight[k];
-    }  
 }
 
 
-void store_weightlinks(long num_weights, int *srch_add, double *weights, long cell_add, weightlinks_t *weightlinks)
+void store_weightlinks(int lalloc, unsigned num_weights, int *srch_add, double *weights, unsigned cell_add, weightlinks_t *weightlinks)
 {
   weightlinks[cell_add].nlinks = 0;
   weightlinks[cell_add].offset = 0;
 
   if ( num_weights )
     {
-      addweight_t *addweights = (addweight_t *) malloc(num_weights*sizeof(addweight_t));
-      for ( long n = 0; n < num_weights; ++n )
+      addweight_t *addweights = NULL;
+      if ( lalloc )
+        addweights = (addweight_t *) Malloc(num_weights*sizeof(addweight_t));
+      else
+        addweights = weightlinks[cell_add].addweights;
+
+      for ( unsigned n = 0; n < num_weights; ++n )
 	{
 	  addweights[n].add    = srch_add[n];
 	  addweights[n].weight = weights[n];
 	}
 
-      sort_addweights(num_weights, addweights);
+      if ( num_weights > 1 ) sort_addweights(num_weights, addweights);
 
-      weightlinks[cell_add].addweights = addweights;
-      weightlinks[cell_add].nlinks     = num_weights;
+      weightlinks[cell_add].nlinks = num_weights;
+
+      if ( lalloc ) weightlinks[cell_add].addweights = addweights;
     }
 }
 
 
-void store_weightlinks4(long num_weights, int *srch_add, double weights[4][4], long cell_add, weightlinks4_t *weightlinks)
+void store_weightlinks4(unsigned num_weights, int *srch_add, double weights[4][4], unsigned cell_add, weightlinks4_t *weightlinks)
 {
   weightlinks[cell_add].nlinks = 0;
   weightlinks[cell_add].offset = 0;
 
   if ( num_weights )
     {
-      addweight4_t *addweights = (addweight4_t *) malloc(num_weights*sizeof(addweight4_t));
-      for ( long n = 0; n < num_weights; ++n )
+      addweight4_t *addweights = weightlinks[cell_add].addweights;
+
+      for ( unsigned n = 0; n < num_weights; ++n )
 	{
 	  addweights[n].add       = srch_add[n];
-	  for ( long k = 0; k < 4; ++k )
+	  for ( unsigned k = 0; k < 4; ++k )
 	    addweights[n].weight[k] = weights[n][k];
 	}
 
       sort_addweights4(num_weights, addweights);
 
-      weightlinks[cell_add].addweights = addweights;
       weightlinks[cell_add].nlinks     = num_weights;
     }
 }
 
 
-void weightlinks2remaplinks(long tgt_grid_size, weightlinks_t *weightlinks, remapvars_t *rv)
+void weightlinks2remaplinks(int lalloc, unsigned tgt_grid_size, weightlinks_t *weightlinks, remapvars_t *rv)
 {
-  long tgt_cell_add;
-  long nlinks = 0;
+  unsigned nlinks = 0;
 
-  for ( tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+  for ( unsigned tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
     {
       if ( weightlinks[tgt_cell_add].nlinks )
 	{
@@ -172,40 +182,53 @@ void weightlinks2remaplinks(long tgt_grid_size, weightlinks_t *weightlinks, rema
   rv->num_links = nlinks;
   if ( nlinks )
     {
-      rv->src_cell_add = (int*) malloc(nlinks*sizeof(int));
-      rv->tgt_cell_add = (int*) malloc(nlinks*sizeof(int));
-      rv->wts          = (double*) malloc(nlinks*sizeof(double));
+      rv->src_cell_add = (int*) Malloc(nlinks*sizeof(int));
+      rv->tgt_cell_add = (int*) Malloc(nlinks*sizeof(int));
+      rv->wts          = (double*) Malloc(nlinks*sizeof(double));
+      int *restrict src_cell_adds = rv->src_cell_add;
+      int *restrict tgt_cell_adds = rv->tgt_cell_add;
+      double *restrict wts = rv->wts;
 
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) \
-  shared(rv, weightlinks)		 \
-  private(tgt_cell_add)
+#pragma omp parallel for schedule(static) default(none) shared(src_cell_adds,tgt_cell_adds,wts,weightlinks,tgt_grid_size) 
 #endif
-      for ( tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+      for ( unsigned tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
 	{
-	  long num_links = weightlinks[tgt_cell_add].nlinks;
+	  unsigned num_links = weightlinks[tgt_cell_add].nlinks;
 	  if ( num_links )
 	    {
-	      long offset    = weightlinks[tgt_cell_add].offset;
-	      for ( long ilink = 0; ilink < num_links; ++ilink )
+	      unsigned offset = weightlinks[tgt_cell_add].offset;
+              addweight_t *addweights = weightlinks[tgt_cell_add].addweights;
+ 	      for ( unsigned ilink = 0; ilink < num_links; ++ilink )
 		{
-		  rv->src_cell_add[offset+ilink] = weightlinks[tgt_cell_add].addweights[ilink].add;
-		  rv->tgt_cell_add[offset+ilink] = tgt_cell_add;
-		  rv->wts[offset+ilink] = weightlinks[tgt_cell_add].addweights[ilink].weight;
+		  src_cell_adds[offset+ilink] = addweights[ilink].add;
+		  tgt_cell_adds[offset+ilink] = tgt_cell_add;
+		  wts[offset+ilink] = addweights[ilink].weight;
 		}
-	      free(weightlinks[tgt_cell_add].addweights);
-	    }
+            }
 	}
+
+      if ( lalloc )
+        {
+          for ( unsigned tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+            {
+              unsigned num_links = weightlinks[tgt_cell_add].nlinks;
+              if ( num_links ) Free(weightlinks[tgt_cell_add].addweights);
+            }
+        }
+      else
+        {
+          Free(weightlinks[0].addweights);
+        }
     }
 }
 
 
-void weightlinks2remaplinks4(long tgt_grid_size, weightlinks4_t *weightlinks, remapvars_t *rv)
+void weightlinks2remaplinks4(unsigned tgt_grid_size, weightlinks4_t *weightlinks, remapvars_t *rv)
 {
-  long tgt_cell_add;
-  long nlinks = 0;
+  unsigned nlinks = 0;
 
-  for ( tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+  for ( unsigned tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
     {
       if ( weightlinks[tgt_cell_add].nlinks )
 	{
@@ -218,31 +241,33 @@ void weightlinks2remaplinks4(long tgt_grid_size, weightlinks4_t *weightlinks, re
   rv->num_links = nlinks;
   if ( nlinks )
     {
-      rv->src_cell_add = (int*) malloc(nlinks*sizeof(int));
-      rv->tgt_cell_add = (int*) malloc(nlinks*sizeof(int));
-      rv->wts          = (double*) malloc(4*nlinks*sizeof(double));
+      rv->src_cell_add = (int*) Malloc(nlinks*sizeof(int));
+      rv->tgt_cell_add = (int*) Malloc(nlinks*sizeof(int));
+      rv->wts          = (double*) Malloc(4*nlinks*sizeof(double));
+      int *restrict src_cell_adds = rv->src_cell_add;
+      int *restrict tgt_cell_adds = rv->tgt_cell_add;
+      double *restrict wts = rv->wts;
 
 #if defined(_OPENMP)
-#pragma omp parallel for default(shared) \
-  shared(rv, weightlinks)		 \
-  private(tgt_cell_add)
+#pragma omp parallel for default(none) shared(src_cell_adds,tgt_cell_adds,wts,weightlinks,tgt_grid_size)
 #endif
-      for ( tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
+      for ( unsigned tgt_cell_add = 0; tgt_cell_add < tgt_grid_size; ++tgt_cell_add )
 	{
-	  long num_links = weightlinks[tgt_cell_add].nlinks;
+	  unsigned num_links = weightlinks[tgt_cell_add].nlinks;
 	  if ( num_links )
 	    {
-	      long offset    = weightlinks[tgt_cell_add].offset;
+	      unsigned offset = weightlinks[tgt_cell_add].offset;
 	      addweight4_t *addweights = weightlinks[tgt_cell_add].addweights;
-	      for ( long ilink = 0; ilink < num_links; ++ilink )
+	      for ( unsigned ilink = 0; ilink < num_links; ++ilink )
 		{
-		  rv->src_cell_add[offset+ilink] = addweights[ilink].add;
-		  rv->tgt_cell_add[offset+ilink] = tgt_cell_add;
-		  for ( long k = 0; k < 4; ++k )
-		    rv->wts[(offset+ilink)*4+k] = addweights[ilink].weight[k];
+		  src_cell_adds[offset+ilink] = addweights[ilink].add;
+		  tgt_cell_adds[offset+ilink] = tgt_cell_add;
+		  for ( unsigned k = 0; k < 4; ++k )
+		    wts[(offset+ilink)*4+k] = addweights[ilink].weight[k];
 		}
-	      free(addweights);
-	    }
+            }
 	}
+
+      Free(weightlinks[0].addweights);
     }
 }
diff --git a/src/remap_store_link.h b/src/remap_store_link.h
index e6ef089..84f0329 100644
--- a/src/remap_store_link.h
+++ b/src/remap_store_link.h
@@ -15,24 +15,24 @@ typedef struct
 } addweight4_t;
 
 typedef struct {
-  int nlinks;
-  int offset;
+  unsigned nlinks;
+  unsigned offset;
   addweight_t *addweights;
 } weightlinks_t;
 
 typedef struct {
-  int nlinks;
-  int offset;
+  unsigned nlinks;
+  unsigned offset;
   addweight4_t *addweights;
 } weightlinks4_t;
 
 
-void store_weightlinks(long num_weights, int *srch_add, double *weights, long cell_add, weightlinks_t *weightlinks);
-void store_weightlinks4(long num_weights, int *srch_add, double weights[4][4], long cell_add, weightlinks4_t *weightlinks);
-void weightlinks2remaplinks(long tgt_grid_size, weightlinks_t *weightlinks, remapvars_t *rv);
-void weightlinks2remaplinks4(long tgt_grid_size, weightlinks4_t *weightlinks, remapvars_t *rv);
-void sort_add_and_wgts(size_t num_weights, int *src_add, double *wgts);
-void sort_add_and_wgts4(size_t num_weights, int *src_add, double wgts[4][4]);
+void store_weightlinks(int lalloc, unsigned num_weights, int *srch_add, double *weights, unsigned cell_add, weightlinks_t *weightlinks);
+void store_weightlinks4(unsigned num_weights, int *srch_add, double weights[4][4], unsigned cell_add, weightlinks4_t *weightlinks);
+void weightlinks2remaplinks(int lalloc, unsigned tgt_grid_size, weightlinks_t *weightlinks, remapvars_t *rv);
+void weightlinks2remaplinks4(unsigned tgt_grid_size, weightlinks4_t *weightlinks, remapvars_t *rv);
+void sort_add_and_wgts(unsigned num_weights, int *src_add, double *wgts);
+void sort_add_and_wgts4(unsigned num_weights, int *src_add, double wgts[4][4]);
 
 
 #endif  /* _REMAP_STORE_LINK */
diff --git a/src/remap_store_link_cnsrv.c b/src/remap_store_link_cnsrv.c
index 26df1d9..9a714ca 100644
--- a/src/remap_store_link_cnsrv.c
+++ b/src/remap_store_link_cnsrv.c
@@ -31,9 +31,9 @@ void grid_store_init(grid_store_t* grid_store, long gridsize)
 	    grid_store->blk_size, grid_store->max_size%grid_store->blk_size, 
 	    grid_store->max_size, grid_store->nblocks);
 
-  grid_store->blksize = (int*) malloc(grid_store->nblocks*sizeof(int));
-  grid_store->nlayers = (int*) malloc(grid_store->nblocks*sizeof(int));
-  grid_store->layers  = (grid_layer_t **) malloc(grid_store->nblocks*sizeof(grid_layer_t *));
+  grid_store->blksize = (int*) Malloc(grid_store->nblocks*sizeof(int));
+  grid_store->nlayers = (int*) Malloc(grid_store->nblocks*sizeof(int));
+  grid_store->layers  = (grid_layer_t **) Malloc(grid_store->nblocks*sizeof(grid_layer_t *));
 
   nblocks = grid_store->nblocks;
   for ( iblk = 0; iblk < nblocks; ++iblk )
@@ -68,9 +68,9 @@ void grid_store_delete(grid_store_t* grid_store)
 	    }
 	      
 	  grid_layer_f = grid_layer;
-	  free(grid_layer->grid2_link);
+	  Free(grid_layer->grid2_link);
 	  grid_layer = grid_layer->next;
-	  free(grid_layer_f);
+	  Free(grid_layer_f);
 	}
       /*
       if ( cdoVerbose )
@@ -81,9 +81,9 @@ void grid_store_delete(grid_store_t* grid_store)
       */
     }
 
-  free(grid_store->blksize);
-  free(grid_store->layers);
-  free(grid_store->nlayers);  
+  Free(grid_store->blksize);
+  Free(grid_store->layers);
+  Free(grid_store->nlayers);  
 }
 
 /*
@@ -103,7 +103,7 @@ void store_link_cnsrv_fast(remapvars_t* rv, long add1, long add2, long num_wts,
   long ilayer, i, iblk, iadd2;
   long nlayer, blksize;
   int lstore_link;
-  grid_layer_t *grid_layer, **grid_layer2;
+  grid_layer_t *grid_layer = NULL, **grid_layer2;
 
   /*  If all weights are ZERO, do not bother storing the link */
 
@@ -159,9 +159,9 @@ void store_link_cnsrv_fast(remapvars_t* rv, long add1, long add2, long num_wts,
     }
   else
     {
-      grid_layer = (grid_layer_t*) malloc(sizeof(grid_layer_t));
+      grid_layer = (grid_layer_t*) Malloc(sizeof(grid_layer_t));
       grid_layer->next = NULL;
-      grid_layer->grid2_link = (int*) malloc(grid_store->blksize[iblk]*sizeof(int));
+      grid_layer->grid2_link = (int*) Malloc(grid_store->blksize[iblk]*sizeof(int));
 
       blksize = grid_store->blksize[iblk];
       for ( i = 0; i < blksize; ++i )
diff --git a/src/remaplib.c b/src/remaplib.c
index 2858c45..dfb8321 100644
--- a/src/remaplib.c
+++ b/src/remaplib.c
@@ -58,13 +58,13 @@
 #include "grid.h"
 #include "remap.h"
 #include "remap_store_link_cnsrv.h"
-#include "util.h"  /* progressStatus */
 
 
 #define IS_REG2D_GRID(gridID)  (!gridIsRotated(gridID) && (gridInqType(gridID) == GRID_LONLAT || gridInqType(gridID) == GRID_GAUSSIAN))
 
 
 
+static int  remap_gen_weights     = TRUE;
 static int  remap_write_remap     = FALSE;
 static int  remap_num_srch_bins   = 180;
 #define  DEFAULT_MAX_ITER  100
@@ -76,6 +76,7 @@ void remap_set_int(int remapvar, int value)
   else if ( remapvar == REMAP_WRITE_REMAP     ) remap_write_remap     = value;
   else if ( remapvar == REMAP_MAX_ITER        ) remap_max_iter        = value;
   else if ( remapvar == REMAP_NUM_SRCH_BINS   ) remap_num_srch_bins   = value;
+  else if ( remapvar == REMAP_GENWEIGHTS      ) remap_gen_weights     = value;
   else      cdoAbort("Unsupported remap variable (%d)!", remapvar);
 }
 
@@ -83,26 +84,26 @@ double intlin(double x, double y1, double x1, double y2, double x2);
 
 void remapGridFree(remapgrid_t *grid)
 {
-  if ( grid->vgpm ) free(grid->vgpm);
-  if ( grid->mask ) free(grid->mask);
+  if ( grid->vgpm ) Free(grid->vgpm);
+  if ( grid->mask ) Free(grid->mask);
 
-  if ( grid->reg2d_center_lat ) free(grid->reg2d_center_lat);
-  if ( grid->reg2d_center_lon ) free(grid->reg2d_center_lon);
-  if ( grid->reg2d_corner_lat ) free(grid->reg2d_corner_lat);
-  if ( grid->reg2d_corner_lon ) free(grid->reg2d_corner_lon);
+  if ( grid->reg2d_center_lat ) Free(grid->reg2d_center_lat);
+  if ( grid->reg2d_center_lon ) Free(grid->reg2d_center_lon);
+  if ( grid->reg2d_corner_lat ) Free(grid->reg2d_corner_lat);
+  if ( grid->reg2d_corner_lon ) Free(grid->reg2d_corner_lon);
 
-  if ( grid->cell_center_lat ) free(grid->cell_center_lat);
-  if ( grid->cell_center_lon ) free(grid->cell_center_lon);
-  if ( grid->cell_corner_lat ) free(grid->cell_corner_lat);
-  if ( grid->cell_corner_lon ) free(grid->cell_corner_lon);
+  if ( grid->cell_center_lat ) Free(grid->cell_center_lat);
+  if ( grid->cell_center_lon ) Free(grid->cell_center_lon);
+  if ( grid->cell_corner_lat ) Free(grid->cell_corner_lat);
+  if ( grid->cell_corner_lon ) Free(grid->cell_corner_lon);
 
-  if ( grid->cell_area ) free(grid->cell_area);
-  if ( grid->cell_frac ) free(grid->cell_frac);
+  if ( grid->cell_area ) Free(grid->cell_area);
+  if ( grid->cell_frac ) Free(grid->cell_frac);
 
-  if ( grid->cell_bound_box ) free(grid->cell_bound_box);
+  if ( grid->cell_bound_box ) Free(grid->cell_bound_box);
 
-  if ( grid->bin_addr ) free(grid->bin_addr);
-  if ( grid->bin_lats ) free(grid->bin_lats);
+  if ( grid->bin_addr ) Free(grid->bin_addr);
+  if ( grid->bin_lats ) Free(grid->bin_lats);
 
 } /* remapGridFree */
 
@@ -114,13 +115,12 @@ void remapVarsFree(remapvars_t *rv)
 
   if ( rv->pinit == TRUE )
     {
-      rv->pinit = FALSE;
-
+      rv->pinit    = FALSE;
       rv->sort_add = FALSE;
 
-      if ( rv->src_cell_add ) free(rv->src_cell_add);
-      if ( rv->tgt_cell_add ) free(rv->tgt_cell_add);
-      if ( rv->wts ) free(rv->wts);
+      if ( rv->src_cell_add ) Free(rv->src_cell_add);
+      if ( rv->tgt_cell_add ) Free(rv->tgt_cell_add);
+      if ( rv->wts ) Free(rv->wts);
 
       if ( rv->links.option == TRUE )
 	{
@@ -128,17 +128,17 @@ void remapVarsFree(remapvars_t *rv)
 
 	  if ( rv->links.num_blks )
 	    {
-	      free(rv->links.num_links);
+	      Free(rv->links.num_links);
 	      num_blks = rv->links.num_blks;
 	      for ( i = 0; i < num_blks; ++i )
 		{
-		  free(rv->links.src_add[i]);
-		  free(rv->links.dst_add[i]);
-		  free(rv->links.w_index[i]);
+		  Free(rv->links.src_add[i]);
+		  Free(rv->links.dst_add[i]);
+		  Free(rv->links.w_index[i]);
 		}
-	      free(rv->links.src_add);
-	      free(rv->links.dst_add);
-	      free(rv->links.w_index);
+	      Free(rv->links.src_add);
+	      Free(rv->links.dst_add);
+	      Free(rv->links.w_index);
 	    }
 	}
     }
@@ -184,28 +184,28 @@ void remapgrid_init(remapgrid_t *grid)
 
 /*****************************************************************************/
 
-void remapGridRealloc(int map_type, remapgrid_t *grid)
+void remapgrid_alloc(int map_type, remapgrid_t *grid)
 {
   long nalloc;
 
   if ( grid->nvgp )
-    grid->vgpm   = (int*) realloc(grid->vgpm, grid->nvgp*sizeof(int));
+    grid->vgpm   = (int*) Malloc(grid->nvgp*sizeof(int));
 
-  grid->mask     = (int*) realloc(grid->mask, grid->size*sizeof(int));
+  grid->mask     = (int*) Malloc(grid->size*sizeof(int));
 
   if ( remap_write_remap == TRUE || grid->remap_grid_type != REMAP_GRID_TYPE_REG2D )
     {
-      grid->cell_center_lon = (double*) realloc(grid->cell_center_lon, grid->size*sizeof(double));
-      grid->cell_center_lat = (double*) realloc(grid->cell_center_lat, grid->size*sizeof(double));
+      grid->cell_center_lon = (double*) Malloc(grid->size*sizeof(double));
+      grid->cell_center_lat = (double*) Malloc(grid->size*sizeof(double));
     }
 
   if ( map_type == MAP_TYPE_CONSERV || map_type == MAP_TYPE_CONSERV_YAC )
     {
-      grid->cell_area = (double*) realloc(grid->cell_area, grid->size*sizeof(double));
+      grid->cell_area = (double*) Malloc(grid->size*sizeof(double));
       memset(grid->cell_area, 0, grid->size*sizeof(double));
     }
 
-  grid->cell_frac = (double*) realloc(grid->cell_frac, grid->size*sizeof(double));
+  grid->cell_frac = (double*) Malloc(grid->size*sizeof(double));
   memset(grid->cell_frac, 0, grid->size*sizeof(double));
 
   if ( grid->lneed_cell_corners )
@@ -218,10 +218,10 @@ void remapGridRealloc(int map_type, remapgrid_t *grid)
 	{
 	  nalloc = grid->num_cell_corners*grid->size;
 
-	  grid->cell_corner_lon = (double*) realloc(grid->cell_corner_lon, nalloc*sizeof(double));
+	  grid->cell_corner_lon = (double*) Malloc(nalloc*sizeof(double));
 	  memset(grid->cell_corner_lon, 0, nalloc*sizeof(double));
 
-	  grid->cell_corner_lat = (double*) realloc(grid->cell_corner_lat, nalloc*sizeof(double));  
+	  grid->cell_corner_lat = (double*) Malloc(nalloc*sizeof(double));  
 	  memset(grid->cell_corner_lat, 0, nalloc*sizeof(double));
 	}
     }
@@ -232,15 +232,15 @@ static
 void boundbox_from_corners(long size, long nc, const double *restrict corner_lon,
 			   const double *restrict corner_lat, restr_t *restrict bound_box)
 {
-  long i4, inc, i, j;
+  long i4, inc, j;
   restr_t clon, clat;
 
 #if defined(_OPENMP)
 #pragma omp parallel for default(none)        \
   shared(bound_box, corner_lat, corner_lon, nc, size)	\
-  private(i4, inc, i, j, clon, clat)
+  private(i4, inc, j, clon, clat)
 #endif
-  for ( i = 0; i < size; ++i )
+  for ( long i = 0; i < size; ++i )
     {
       i4 = i<<2; // *4
       inc = i*nc;
@@ -266,16 +266,16 @@ static
 void boundbox_from_center(int lonIsCyclic, long size, long nx, long ny, const double *restrict center_lon,
 			  const double *restrict center_lat, restr_t *restrict bound_box)
 {
-  long n4, i, j, k, n, ip1, jp1;
+  long n4, i, j, k, ip1, jp1;
   long n_add, e_add, ne_add;
   restr_t tmp_lats[4], tmp_lons[4];  /* temps for computing bounding boxes */
 
 #if defined(_OPENMP)
 #pragma omp parallel for default(none)        \
   shared(lonIsCyclic, size, nx, ny, center_lon, center_lat, bound_box)	\
-  private(n4, i, j, k, n, ip1, jp1, n_add, e_add, ne_add, tmp_lats, tmp_lons)
+  private(n4, i, j, k, ip1, jp1, n_add, e_add, ne_add, tmp_lats, tmp_lons)
 #endif
-  for ( n = 0; n < size; n++ )
+  for ( long n = 0; n < size; n++ )
     {
       n4 = n<<2;
 
@@ -371,17 +371,34 @@ void check_lon_range2(long nc, long nlons, double *corners, double *centers)
     }
 }
 
+
+void remapgrid_get_lonlat(remapgrid_t *grid, unsigned cell_add, double *plon, double *plat)
+{
+  if ( grid->remap_grid_type == REMAP_GRID_TYPE_REG2D )
+    {
+      unsigned nx = grid->dims[0];
+      unsigned iy = cell_add/nx;
+      unsigned ix = cell_add - iy*nx;
+      *plat = grid->reg2d_center_lat[iy];
+      *plon = grid->reg2d_center_lon[ix];
+      if ( *plon < 0 ) *plon += PI2;
+    }
+  else
+    {
+      *plat = grid->cell_center_lat[cell_add];
+      *plon = grid->cell_center_lon[cell_add];
+    }
+}
+
 static
 void check_lon_range(long nlons, double *lons)
 {
-  long n;
-
   assert(lons != NULL);
 
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) shared(nlons, lons)
 #endif
-  for ( n = 0; n < nlons; ++n )
+  for ( long n = 0; n < nlons; ++n )
     {
       // remove missing values
       if ( lons[n] < -PI2 ) lons[n] = 0;
@@ -395,14 +412,12 @@ void check_lon_range(long nlons, double *lons)
 static
 void check_lat_range(long nlats, double *lats)
 {
-  long n;
-
   assert(lats != NULL);
 
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) shared(nlats, lats)
 #endif
-  for ( n = 0; n < nlats; ++n )
+  for ( long n = 0; n < nlats; ++n )
     {
       if ( lats[n] >  PIH ) lats[n] =  PIH;
       if ( lats[n] < -PIH ) lats[n] = -PIH;
@@ -412,14 +427,14 @@ void check_lat_range(long nlats, double *lats)
 static
 void check_lon_boundbox_range(long nlons, restr_t *bound_box)
 {
-  long n, n4;
+  long n4;
 
   assert(bound_box != NULL);
 
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) shared(nlons, bound_box) private(n4)
 #endif
-  for ( n = 0; n < nlons; ++n )
+  for ( long n = 0; n < nlons; ++n )
     {
       n4 = n<<2;
       if ( RESTR_ABS(bound_box[n4+3] - bound_box[n4+2]) > RESTR_SCALE(PI) )
@@ -433,14 +448,14 @@ void check_lon_boundbox_range(long nlons, restr_t *bound_box)
 static
 void check_lat_boundbox_range(long nlats, restr_t *restrict bound_box, double *restrict lats)
 {
-  long n, n4;
+  long n4;
 
   assert(bound_box != NULL);
 
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) shared(nlats, bound_box, lats) private(n4)
 #endif
-  for ( n = 0; n < nlats; ++n )
+  for ( long n = 0; n < nlats; ++n )
     {
       n4 = n<<2;
       if ( RESTR_SCALE(lats[n]) < bound_box[n4  ] ) bound_box[n4  ] = RESTR_SCALE(-PIH);
@@ -452,21 +467,18 @@ static
 int expand_lonlat_grid(int gridID)
 {
   char units[CDI_MAX_NAME];
-  int gridIDnew;
-  long nx, ny, nxp4, nyp4;
-  double *xvals, *yvals;
 
-  nx = gridInqXsize(gridID);
-  ny = gridInqYsize(gridID);
-  nxp4 = nx+4;
-  nyp4 = ny+4;
+  long nx = gridInqXsize(gridID);
+  long ny = gridInqYsize(gridID);
+  long nxp4 = nx+4;
+  long nyp4 = ny+4;
 
-  xvals = (double*) malloc(nxp4*sizeof(double));
-  yvals = (double*) malloc(nyp4*sizeof(double));
+  double *xvals = (double*) Malloc(nxp4*sizeof(double));
+  double *yvals = (double*) Malloc(nyp4*sizeof(double));
   gridInqXvals(gridID, xvals+2);
   gridInqYvals(gridID, yvals+2);
 
-  gridIDnew = gridCreate(GRID_LONLAT, nxp4*nyp4);
+  int gridIDnew = gridCreate(GRID_LONLAT, nxp4*nyp4);
   gridDefXsize(gridIDnew, nxp4);
   gridDefYsize(gridIDnew, nyp4);
 	      
@@ -488,8 +500,8 @@ int expand_lonlat_grid(int gridID)
   gridDefXvals(gridIDnew, xvals);
   gridDefYvals(gridIDnew, yvals);
 
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
 
   if ( gridIsRotated(gridID) )
     {
@@ -498,32 +510,28 @@ int expand_lonlat_grid(int gridID)
       gridDefAngle(gridIDnew, gridInqAngle(gridID));
     }
 
-  return(gridIDnew);
+  return gridIDnew;
 }
 
 static
 int expand_curvilinear_grid(int gridID)
 {
   char units[CDI_MAX_NAME];
-  int gridIDnew;
-  long gridsize, gridsize_new;
-  long nx, ny, nxp4, nyp4;
   long i, j;
-  double *xvals, *yvals;
 
-  gridsize = gridInqSize(gridID);
-  nx = gridInqXsize(gridID);
-  ny = gridInqYsize(gridID);
-  nxp4 = nx+4;
-  nyp4 = ny+4;
-  gridsize_new = gridsize + 4*(nx+2) + 4*(ny+2);
+  long gridsize = gridInqSize(gridID);
+  long nx = gridInqXsize(gridID);
+  long ny = gridInqYsize(gridID);
+  long nxp4 = nx+4;
+  long nyp4 = ny+4;
+  int gridsize_new = gridsize + 4*(nx+2) + 4*(ny+2);
 
-  xvals = (double*) malloc(gridsize_new*sizeof(double));
-  yvals = (double*) malloc(gridsize_new*sizeof(double));
+  double *xvals = (double*) Malloc(gridsize_new*sizeof(double));
+  double *yvals = (double*) Malloc(gridsize_new*sizeof(double));
   gridInqXvals(gridID, xvals);
   gridInqYvals(gridID, yvals);
 
-  gridIDnew = gridCreate(GRID_CURVILINEAR, nxp4*nyp4);
+  int gridIDnew = gridCreate(GRID_CURVILINEAR, nxp4*nyp4);
   gridDefXsize(gridIDnew, nxp4);
   gridDefYsize(gridIDnew, nyp4);
 
@@ -579,10 +587,10 @@ int expand_curvilinear_grid(int gridID)
   gridDefXvals(gridIDnew, xvals);
   gridDefYvals(gridIDnew, yvals);
   
-  free(xvals);
-  free(yvals);
+  Free(xvals);
+  Free(yvals);
 
-  return(gridIDnew);
+  return gridIDnew;
 }
 
 /*****************************************************************************/
@@ -606,22 +614,20 @@ static
 void remap_define_reg2d(int gridID, remapgrid_t *grid)
 {
   char unitstr[CDI_MAX_NAME];
-  long nx, nxm, ny;
-  long nxp1, nyp1;
 
-  nx = grid->dims[0];
-  ny = grid->dims[1];
+  long nx = grid->dims[0];
+  long ny = grid->dims[1];
 
-  nxp1 = nx + 1;
-  nyp1 = ny + 1;
+  long nxp1 = nx + 1;
+  long nyp1 = ny + 1;
 
-  nxm = nx;
+  long nxm = nx;
   if ( grid->is_cyclic ) nxm++;
 
   if ( grid->size != nx*ny ) cdoAbort("Internal error, wrong dimensions!");
 
-  grid->reg2d_center_lon = (double*) realloc(grid->reg2d_center_lon, nxm*sizeof(double));
-  grid->reg2d_center_lat = (double*) realloc(grid->reg2d_center_lat,  ny*sizeof(double));
+  grid->reg2d_center_lon = (double*) Malloc(nxm*sizeof(double));
+  grid->reg2d_center_lat = (double*) Malloc( ny*sizeof(double));
  
   grid->reg2d_center_lon[0] = 0;
   grid->reg2d_center_lat[0] = 0;
@@ -637,8 +643,8 @@ void remap_define_reg2d(int gridID, remapgrid_t *grid)
 
   if ( grid->is_cyclic ) grid->reg2d_center_lon[nx] = grid->reg2d_center_lon[0] + PI2;
 
-  grid->reg2d_corner_lon = (double*) malloc(nxp1*sizeof(double));
-  grid->reg2d_corner_lat = (double*) malloc(nyp1*sizeof(double));
+  grid->reg2d_corner_lon = (double*) Malloc(nxp1*sizeof(double));
+  grid->reg2d_corner_lat = (double*) Malloc(nyp1*sizeof(double));
 
   grid_gen_corners(nx, grid->reg2d_center_lon, grid->reg2d_corner_lon);
   grid_gen_corners(ny, grid->reg2d_center_lat, grid->reg2d_corner_lat);
@@ -700,7 +706,7 @@ void remap_define_grid(int map_type, int gridID, remapgrid_t *grid)
   else
     grid->num_cell_corners = 4;
 
-  remapGridRealloc(map_type, grid);
+ remapgrid_alloc(map_type, grid);
 
   /* Initialize logical mask */
 
@@ -711,15 +717,17 @@ void remap_define_grid(int map_type, int gridID, remapgrid_t *grid)
 
   if ( gridInqMask(gridID, NULL) )
     {
-      int *mask = (int*) malloc(gridsize*sizeof(int));
+      int *mask = (int*) Malloc(gridsize*sizeof(int));
       gridInqMask(gridID, mask);
       for ( i = 0; i < gridsize; ++i )
 	if ( mask[i] == 0 ) grid->mask[i] = FALSE;
-      free(mask);
+      Free(mask);
     }
 
   if ( remap_write_remap == FALSE && grid->remap_grid_type == REMAP_GRID_TYPE_REG2D ) return;
 
+  if ( !(gridInqXvals(gridID, NULL) && gridInqYvals(gridID, NULL)) )
+    cdoAbort("Grid cell center coordinates missing!");
 
   gridInqXvals(gridID, grid->cell_center_lon);
   gridInqYvals(gridID, grid->cell_center_lat);
@@ -730,7 +738,7 @@ void remap_define_grid(int map_type, int gridID, remapgrid_t *grid)
 
   if ( grid->lneed_cell_corners )
     {
-      if ( gridInqYbounds(gridID, NULL) && gridInqXbounds(gridID, NULL) )
+      if ( gridInqXbounds(gridID, NULL) && gridInqYbounds(gridID, NULL) )
 	{
 	  gridInqXbounds(gridID, grid->cell_corner_lon);
 	  gridInqYbounds(gridID, grid->cell_corner_lat);
@@ -742,7 +750,7 @@ void remap_define_grid(int map_type, int gridID, remapgrid_t *grid)
 	}
       else
 	{
-	  cdoAbort("Grid corner missing!");
+	  cdoAbort("Grid cell corner coordinates missing!");
 	}
     }
 
@@ -784,7 +792,7 @@ static
 void cell_bounding_boxes(remapgrid_t *grid, int remap_grid_basis)
 {
   if ( remap_grid_basis == REMAP_GRID_BASIS_SRC || grid->luse_cell_corners )
-    grid->cell_bound_box = (restr_t*) realloc(grid->cell_bound_box, 4*grid->size*sizeof(restr_t));
+    grid->cell_bound_box = (restr_t*) Malloc(4*grid->size*sizeof(restr_t));
 
   if ( grid->luse_cell_corners )
     {
@@ -841,6 +849,7 @@ void cell_bounding_boxes(remapgrid_t *grid, int remap_grid_basis)
 
 void remap_grids_init(int map_type, int lextrapolate, int gridID1, remapgrid_t *src_grid, int gridID2, remapgrid_t *tgt_grid)
 {
+  int lbounds = TRUE;
   int reg2d_src_gridID = gridID1;
   int reg2d_tgt_gridID = gridID2;
 
@@ -855,12 +864,18 @@ void remap_grids_init(int map_type, int lextrapolate, int gridID1, remapgrid_t *
       // src_grid->remap_grid_type = 0;
     }
 
-  if ( map_type == MAP_TYPE_CONSERV_YAC && src_grid->remap_grid_type == REMAP_GRID_TYPE_REG2D )
+  if ( src_grid->remap_grid_type == REMAP_GRID_TYPE_REG2D )
     {
-      if ( IS_REG2D_GRID(gridID2) ) tgt_grid->remap_grid_type = REMAP_GRID_TYPE_REG2D;
+      if ( IS_REG2D_GRID(gridID2) && map_type == MAP_TYPE_CONSERV_YAC ) tgt_grid->remap_grid_type = REMAP_GRID_TYPE_REG2D;
       // else src_grid->remap_grid_type = -1;
     }
 
+  if ( remap_gen_weights == FALSE && IS_REG2D_GRID(gridID2) && tgt_grid->remap_grid_type != REMAP_GRID_TYPE_REG2D )
+    {
+      if ( map_type == MAP_TYPE_DISTWGT ) tgt_grid->remap_grid_type = REMAP_GRID_TYPE_REG2D;
+      if ( map_type == MAP_TYPE_BILINEAR && src_grid->remap_grid_type == REMAP_GRID_TYPE_REG2D ) tgt_grid->remap_grid_type = REMAP_GRID_TYPE_REG2D;
+    }
+
   if ( lextrapolate > 0 )
     src_grid->lextrapolate = TRUE;
   else
@@ -922,7 +937,7 @@ void remap_grids_init(int map_type, int lextrapolate, int gridID1, remapgrid_t *
 	gridInqType(src_grid->gridID) == GRID_LAEA || 
 	gridInqType(src_grid->gridID) == GRID_SINUSOIDAL) )
     {
-      src_grid->gridID = gridID1 = gridToCurvilinear(src_grid->gridID, 1);
+      src_grid->gridID = gridID1 = gridToCurvilinear(src_grid->gridID, lbounds);
     }
 
   if ( !src_grid->lextrapolate && gridInqSize(src_grid->gridID) > 1 &&
@@ -932,22 +947,6 @@ void remap_grids_init(int map_type, int lextrapolate, int gridID1, remapgrid_t *
       src_grid->gridID = gridID1 = expand_curvilinear_grid(gridID1);
     }
 
-  if ( map_type == MAP_TYPE_DISTWGT )
-    {
-      if ( gridInqType(src_grid->gridID) == GRID_UNSTRUCTURED )
-	{
-	  src_grid->luse_cell_corners  = TRUE;
-	  src_grid->lneed_cell_corners = FALSE; /* full grid search */
-	}
-      /* not used !
-      if ( gridInqType(tgt_grid->gridID) == GRID_UNSTRUCTURED )
-	{
-	  tgt_grid->luse_cell_corners  = TRUE;
-	  tgt_grid->lneed_cell_corners = FALSE;
-	}
-      */
-    }
-
   //if ( src_grid->remap_grid_type != REMAP_GRID_TYPE_REG2D )
     remap_define_grid(map_type, gridID1, src_grid);
 
@@ -962,7 +961,11 @@ void remap_grids_init(int map_type, int lextrapolate, int gridID1, remapgrid_t *
     {
       remap_define_reg2d(reg2d_src_gridID, src_grid);
     }
-  else
+  else if ( tgt_grid->remap_grid_type == REMAP_GRID_TYPE_REG2D )
+    {
+      remap_define_reg2d(reg2d_tgt_gridID, tgt_grid);
+    }
+  else if ( map_type != MAP_TYPE_DISTWGT )
     {
       cell_bounding_boxes(src_grid, REMAP_GRID_BASIS_SRC);
       cell_bounding_boxes(tgt_grid, REMAP_GRID_BASIS_TGT);
@@ -1036,10 +1039,10 @@ void remap_vars_init(int map_type, long src_grid_size, long tgt_grid_size, remap
   /*  Allocate address and weight arrays for mapping 1 */
   if ( map_type == MAP_TYPE_CONSERV )
     {
-      rv->src_cell_add = (int*) realloc(rv->src_cell_add, rv->max_links*sizeof(int));
-      rv->tgt_cell_add = (int*) realloc(rv->tgt_cell_add, rv->max_links*sizeof(int));
+      rv->src_cell_add = (int*) Malloc(rv->max_links*sizeof(int));
+      rv->tgt_cell_add = (int*) Malloc(rv->max_links*sizeof(int));
 
-      rv->wts = (double*) realloc(rv->wts, rv->num_wts*rv->max_links*sizeof(double));
+      rv->wts = (double*) Malloc(rv->num_wts*rv->max_links*sizeof(double));
     }
 
   rv->links.option    = FALSE;
@@ -1070,15 +1073,14 @@ void resize_remap_vars(remapvars_t *rv, int increment)
 
   if ( rv->max_links )
     {
-      rv->src_cell_add = (int*) realloc(rv->src_cell_add, rv->max_links*sizeof(int));
-      rv->tgt_cell_add = (int*) realloc(rv->tgt_cell_add, rv->max_links*sizeof(int));
+      rv->src_cell_add = (int*) Realloc(rv->src_cell_add, rv->max_links*sizeof(int));
+      rv->tgt_cell_add = (int*) Realloc(rv->tgt_cell_add, rv->max_links*sizeof(int));
 
-      rv->wts = (double*) realloc(rv->wts, rv->num_wts*rv->max_links*sizeof(double));
+      rv->wts = (double*) Realloc(rv->wts, rv->num_wts*rv->max_links*sizeof(double));
     }
 
 } /* resize_remap_vars */
 
-
 /*
   -----------------------------------------------------------------------
 
@@ -1195,14 +1197,14 @@ long get_max_add(long num_links, long size, const int *restrict add)
   long max_add;
   int *isum;
 
-  isum = (int*) malloc(size*sizeof(int));
+  isum = (int*) Malloc(size*sizeof(int));
   memset(isum, 0, size*sizeof(int));
 
   for ( n = 0; n < num_links; ++n ) isum[add[n]]++;
 
   max_add = 0;
   for ( i = 0; i < size; ++i ) if ( isum[i] > max_add ) max_add = isum[i];
-  free(isum);
+  Free(isum);
 
   return (max_add);
 }
@@ -1274,16 +1276,16 @@ void remap_laf(double *restrict dst_array, double missval, long dst_size, long n
   max_cls = get_max_add(num_links, dst_size, dst_add);
 
 #if defined(_OPENMP)
-  src_cls2 = (double **) malloc(ompNumThreads*sizeof(double *));
-  src_wts2 = (double **) malloc(ompNumThreads*sizeof(double *));
+  src_cls2 = (double **) Malloc(ompNumThreads*sizeof(double *));
+  src_wts2 = (double **) Malloc(ompNumThreads*sizeof(double *));
   for ( i = 0; i < ompNumThreads; ++i )
     {
-      src_cls2[i] = (double*) malloc(max_cls*sizeof(double));
-      src_wts2[i] = (double*) malloc(max_cls*sizeof(double));
+      src_cls2[i] = (double*) Malloc(max_cls*sizeof(double));
+      src_wts2[i] = (double*) Malloc(max_cls*sizeof(double));
     }
 #else
-  src_cls = (double*) malloc(max_cls*sizeof(double));
-  src_wts = (double*) malloc(max_cls*sizeof(double));
+  src_cls = (double*) Malloc(max_cls*sizeof(double));
+  src_wts = (double*) Malloc(max_cls*sizeof(double));
 #endif
 
   for ( n = 0; n < num_links; ++n )
@@ -1292,7 +1294,7 @@ void remap_laf(double *restrict dst_array, double missval, long dst_size, long n
 #if defined(_OPENMP)
 #pragma omp parallel for default(none) \
   shared(dst_size, src_cls2, src_wts2, num_links, dst_add, src_add, src_array, map_wts, num_wts, dst_array, max_cls)					\
-  private(i, n, k, src_cls, src_wts, ncls, imax, wts) \
+  private(n, k, src_cls, src_wts, ncls, imax, wts) \
   schedule(dynamic,1)
 #endif
   for ( i = 0; i < dst_size; ++i )
@@ -1380,15 +1382,15 @@ void remap_laf(double *restrict dst_array, double missval, long dst_size, long n
 #if defined(_OPENMP)
   for ( i = 0; i < ompNumThreads; ++i )
     {
-      free(src_cls2[i]);
-      free(src_wts2[i]);
+      Free(src_cls2[i]);
+      Free(src_wts2[i]);
     }
 
-  free(src_cls2);
-  free(src_wts2);
+  Free(src_cls2);
+  Free(src_wts2);
 #else
-  free(src_cls);
-  free(src_wts);
+  Free(src_cls);
+  Free(src_wts);
 #endif
 }
 
@@ -1449,7 +1451,6 @@ void remap_stat(int remap_order, remapgrid_t src_grid, remapgrid_t tgt_grid, rem
   long n, ns, i;
   long idiff, imax, imin, icount;
   int *tgt_count;
-  double minval, maxval, sum;
 	  
   if ( remap_order == 2 )
     cdoPrint("Second order mapping from grid1 to grid2:");
@@ -1458,9 +1459,9 @@ void remap_stat(int remap_order, remapgrid_t src_grid, remapgrid_t tgt_grid, rem
   cdoPrint("----------------------------------------");
 
   ns = 0;
-  sum = 0;
-  minval =  DBL_MAX;
-  maxval = -DBL_MAX;
+  double sum = 0;
+  double minval =  DBL_MAX;
+  double maxval = -DBL_MAX;
   for ( n = 0; n < src_grid.size; ++n )
     {
       if ( !DBL_IS_EQUAL(array1[n], missval) )
@@ -1518,7 +1519,7 @@ void remap_stat(int remap_order, remapgrid_t src_grid, remapgrid_t tgt_grid, rem
   cdoPrint("number of sparse matrix entries %d", rv.num_links);
   cdoPrint("total number of dest cells %d", tgt_grid.size);
 
-  tgt_count = (int*) malloc(tgt_grid.size*sizeof(int));
+  tgt_count = (int*) Malloc(tgt_grid.size*sizeof(int));
 
   for ( n = 0; n < tgt_grid.size; ++n ) tgt_count[n] = 0;
 
@@ -1563,7 +1564,7 @@ void remap_stat(int remap_order, remapgrid_t src_grid, remapgrid_t tgt_grid, rem
 	}
     }
 
-  free(tgt_count);
+  Free(tgt_count);
 
   if ( rv.sort_add )
     cdoPrint("Sparse matrix entries are explicitly sorted.");
@@ -1575,7 +1576,7 @@ void remap_stat(int remap_order, remapgrid_t src_grid, remapgrid_t tgt_grid, rem
 void remap_gradients(remapgrid_t grid, const double *restrict array, double *restrict grad_lat,
 		     double *restrict grad_lon, double *restrict grad_latlon)
 {
-  long n, nx, ny, grid_size;
+  long nx, ny, grid_size;
   long i, j, ip1, im1, jp1, jm1, in, is, ie, iw, ine, inw, ise, isw;
   double delew, delns;
   double grad_lat_zero, grad_lon_zero;
@@ -1590,9 +1591,9 @@ void remap_gradients(remapgrid_t grid, const double *restrict array, double *res
 #if defined(_OPENMP)
 #pragma omp parallel for default(none)        \
   shared(grid_size, grad_lat, grad_lon, grad_latlon, grid, nx, ny, array) \
-  private(n, i, j, ip1, im1, jp1, jm1, in, is, ie, iw, ine, inw, ise, isw, delew, delns, grad_lat_zero, grad_lon_zero)
+  private(i, j, ip1, im1, jp1, jm1, in, is, ie, iw, ine, inw, ise, isw, delew, delns, grad_lat_zero, grad_lon_zero)
 #endif
-  for ( n = 0; n < grid_size; ++n )
+  for ( long n = 0; n < grid_size; ++n )
     {
       grad_lat[n] = ZERO;
       grad_lon[n] = ZERO;
@@ -1810,17 +1811,17 @@ void reorder_links(remapvars_t *rv)
 
       printf("num_links %ld  max_links %ld  num_blks %ld\n", rv->num_links, max_links, num_blks);
 
-      rv->links.num_links = (int*) malloc(num_blks*sizeof(int));
-      rv->links.dst_add   = (int **) malloc(num_blks*sizeof(int *));
-      rv->links.src_add   = (int **) malloc(num_blks*sizeof(int *));
-      rv->links.w_index   = (int **) malloc(num_blks*sizeof(int *));
+      rv->links.num_links = (int*) Malloc(num_blks*sizeof(int));
+      rv->links.dst_add   = (int **) Malloc(num_blks*sizeof(int *));
+      rv->links.src_add   = (int **) Malloc(num_blks*sizeof(int *));
+      rv->links.w_index   = (int **) Malloc(num_blks*sizeof(int *));
     }
 
   for ( j = 0; j < num_blks; j++ )
     {
-      rv->links.dst_add[j] = (int*) malloc(max_links*sizeof(int));
-      rv->links.src_add[j] = (int*) malloc(max_links*sizeof(int));
-      rv->links.w_index[j] = (int*) malloc(max_links*sizeof(int));
+      rv->links.dst_add[j] = (int*) Malloc(max_links*sizeof(int));
+      rv->links.src_add[j] = (int*) Malloc(max_links*sizeof(int));
+      rv->links.w_index[j] = (int*) Malloc(max_links*sizeof(int));
     }
 
   for ( j = 0; j < num_blks; j++ )
diff --git a/src/remapsort.c b/src/remapsort.c
index 6d6b30d..e3b072e 100644
--- a/src/remapsort.c
+++ b/src/remapsort.c
@@ -6,12 +6,7 @@
 #include <omp.h>
 #endif
 
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-
-#include "cdo.h"
+#include "cdo_int.h"
 #include "remap.h"
 
 /*****************************************************************************/
@@ -291,20 +286,20 @@ void sort_add(long num_links, long num_wts, int *restrict add1, int *restrict ad
 
   if ( num_links <= 1 ) return;
 
-  idx = (int*) malloc(num_links*sizeof(int));
+  idx = (int*) Malloc(num_links*sizeof(int));
   for ( i = 0; i < num_links; ++i ) idx[i] = i;
 
   remap_heapsort(num_links, add1, add2, idx);
 
-  wgt_tmp = (double*) malloc(num_wts*num_links*sizeof(double));
+  wgt_tmp = (double*) Malloc(num_wts*num_links*sizeof(double));
   memcpy(wgt_tmp, weights, num_wts*num_links*sizeof(double));
 
   for ( i = 0; i < num_links; ++i )
     for ( n = 0; n < num_wts; ++n )
       weights[num_wts*i+n] = wgt_tmp[num_wts*idx[i]+n];
 
-  free(wgt_tmp);
-  free(idx);
+  Free(wgt_tmp);
+  Free(idx);
 
   if ( cdoVerbose ) 
     if ( !isSorted(add1, add2, num_links) ) fprintf(stderr, ">>>> sort_add failed!!!\n");
@@ -624,7 +619,7 @@ void sort_par(long num_links, long num_wts, int *restrict add1, int *restrict ad
       exit(-1);
     }
 
-  idx = (long*) malloc(num_links*sizeof(long));
+  idx = (long*) Malloc(num_links*sizeof(long));
 
   /* SPLIT AND SORT THE DATA FRAGMENTS */
   /*
@@ -664,7 +659,7 @@ void sort_par(long num_links, long num_wts, int *restrict add1, int *restrict ad
 
 #if defined(_OPENMP)
 #pragma omp parallel for if ( depth < par_depth ) \
-        private(i, n, m, wgttmp, who_am_i)   \
+        private(n, m, wgttmp, who_am_i)    \
         shared(weights) num_threads(2)
 #endif
   for ( i=0; i < nsplit; i++ )
@@ -679,7 +674,7 @@ void sort_par(long num_links, long num_wts, int *restrict add1, int *restrict ad
       //	       who_am_i,parent,my_depth,omp_get_thread_num()+1,omp_get_num_threads());
 #endif
             
-      wgttmp = (double*) malloc(num_wts*nl[i]*sizeof(double));
+      wgttmp = (double*) Malloc(num_wts*nl[i]*sizeof(double));
        
       for ( m = 0; m < nl[i]; m++ )
 	for ( n = 0; n < num_wts; n++ )                      
@@ -691,7 +686,7 @@ void sort_par(long num_links, long num_wts, int *restrict add1, int *restrict ad
 	for ( n = 0; n < num_wts; n++ )
 	  weights[num_wts*(add_srt[i]+m)+n] = wgttmp[num_wts*m+n];
 
-      free(wgttmp);
+      Free(wgttmp);
     }
 
   /* ********************************* */
@@ -702,7 +697,7 @@ void sort_par(long num_links, long num_wts, int *restrict add1, int *restrict ad
                                                               /* ********************** */
   merge_lists(nl,add1s[0],add2s[0],add1s[1],add2s[1], idx);   /* MERGE THE SEGMENTS     */
                                                               /* ********************** */
-  tmp = (int*) malloc(num_links*sizeof(int));
+  tmp = (int*) Malloc(num_links*sizeof(int));
   
 #if defined(_OPENMP)
 #pragma omp parallel for if ( depth < par_depth ) private(i) num_threads(2)
@@ -725,10 +720,10 @@ void sort_par(long num_links, long num_wts, int *restrict add1, int *restrict ad
   for ( i = 0; i < num_links; i++ )
     add2[i] = tmp[i];
   
-  free(tmp);
+  Free(tmp);
   tmp = NULL;
   
-  tmp2 = (double*) malloc(num_links*num_wts*sizeof(double));
+  tmp2 = (double*) Malloc(num_links*num_wts*sizeof(double));
   
 #if defined(_OPENMP)
 #pragma omp parallel for if ( depth < par_depth ) private(i,n) num_threads(2)
@@ -744,10 +739,10 @@ void sort_par(long num_links, long num_wts, int *restrict add1, int *restrict ad
     for ( n = 0; n < num_wts; n++ )
       weights[num_wts*i+n] = tmp2[num_wts*i+n];
   
-  free(tmp2);
+  Free(tmp2);
   tmp2 = NULL;
   
-  free(idx);
+  Free(idx);
 }
 
 
diff --git a/src/specspace.c b/src/specspace.c
index 81e32fc..cd9e866 100644
--- a/src/specspace.c
+++ b/src/specspace.c
@@ -16,7 +16,6 @@ void uv2dv(double *fu, double *fv, double *sd, double *sv,
            double *pol2, double *pol3, int klev, int nlat, int nt);
 void dv2uv(double *d, double *o, double *u, double *v, double *f, double *g,
 	   int nt, int nsp, int nlev);
-void dv2ps(const double * restrict div, double * restrict pot, long nlev, long ntr);
 
 void after_legini_full(int ntr, int nlat, double *restrict poli, double *restrict pold, double *restrict pdev,
 		       double *restrict pol2, double *restrict pol3, double *restrict coslat);
@@ -32,12 +31,12 @@ void grid2spec(SPTRANS *sptrans, int gridIDin, double *arrayIn, int gridIDout, d
   int waves = ntr + 1;
   int nfc   = waves * 2;
 
-  double *fpwork = (double*) malloc(nlat*nfc*nlev*sizeof(double));
+  double *fpwork = (double*) Malloc(nlat*nfc*nlev*sizeof(double));
 
   gp2fc(sptrans->trig, sptrans->ifax, arrayIn, fpwork, nlat, nlon, nlev, nfc);
   fc2sp(fpwork, arrayOut, sptrans->pold, nlev, nlat, nfc, ntr);
 
-  free(fpwork);
+  Free(fpwork);
 }
 	   
    
@@ -50,12 +49,12 @@ void spec2grid(SPTRANS *sptrans, int gridIDin, double *arrayIn, int gridIDout, d
   int waves = ntr + 1;
   int nfc   = waves * 2;
 
-  double *fpwork = (double*) malloc(nlat*nfc*nlev*sizeof(double));
+  double *fpwork = (double*) Malloc(nlat*nfc*nlev*sizeof(double));
 
   sp2fc(arrayIn, fpwork, sptrans->poli, nlev, nlat, nfc, ntr);
   fc2gp(sptrans->trig, sptrans->ifax, fpwork, arrayOut, nlat, nlon, nlev, nfc);
 
-  free(fpwork);
+  Free(fpwork);
 }
 
 
@@ -129,7 +128,7 @@ void speccut(int gridIDin, double *arrayIn, double *arrayOut, int *waves)
 
 SPTRANS *sptrans_new(int nlon, int nlat, int ntr, int flag)
 {
-  SPTRANS *sptrans = (SPTRANS*) malloc(sizeof(SPTRANS));
+  SPTRANS *sptrans = (SPTRANS*) Malloc(sizeof(SPTRANS));
 
   sptrans->nlon = nlon;
   sptrans->nlat = nlat;
@@ -138,16 +137,16 @@ SPTRANS *sptrans_new(int nlon, int nlat, int ntr, int flag)
   int nsp = (ntr + 1)*(ntr + 2);
   sptrans->poldim = nsp / 2 * nlat;
 
-  sptrans->trig = (double*) malloc(nlon * sizeof(double));
+  sptrans->trig = (double*) Malloc(nlon * sizeof(double));
   fft_set(sptrans->trig, sptrans->ifax, nlon);
 
-  sptrans->poli = (double*) malloc(sptrans->poldim * sizeof(double));
-  sptrans->pold = (double*) malloc(sptrans->poldim * sizeof(double));
+  sptrans->poli = (double*) Malloc(sptrans->poldim * sizeof(double));
+  sptrans->pold = (double*) Malloc(sptrans->poldim * sizeof(double));
   
   if ( flag )
     {
-      sptrans->pol2 = (double*) malloc(sptrans->poldim * sizeof(double));
-      sptrans->pol3 = (double*) malloc(sptrans->poldim * sizeof(double));
+      sptrans->pol2 = (double*) Malloc(sptrans->poldim * sizeof(double));
+      sptrans->pol3 = (double*) Malloc(sptrans->poldim * sizeof(double));
     }
   else
     {
@@ -155,8 +154,8 @@ SPTRANS *sptrans_new(int nlon, int nlat, int ntr, int flag)
       sptrans->pol3 = NULL;
     }
 
-  sptrans->coslat  = (double*) malloc(nlat * sizeof(double));
-  sptrans->rcoslat = (double*) malloc(nlat * sizeof(double));
+  sptrans->coslat  = (double*) Malloc(nlat * sizeof(double));
+  sptrans->rcoslat = (double*) Malloc(nlat * sizeof(double));
 
   if ( flag )
     after_legini_full(ntr, nlat, sptrans->poli, sptrans->pold, NULL,
@@ -175,30 +174,30 @@ void sptrans_delete(SPTRANS *sptrans)
 {
   if ( sptrans )
     {
-      if ( sptrans->trig ) { free(sptrans->trig);  sptrans->trig = NULL; }
-      if ( sptrans->poli ) { free(sptrans->poli);  sptrans->poli = NULL; }
-      if ( sptrans->pold ) { free(sptrans->pold);  sptrans->pold = NULL; }
-      if ( sptrans->pol2 ) { free(sptrans->pol2);  sptrans->pol2 = NULL; }
-      if ( sptrans->pol3 ) { free(sptrans->pol3);  sptrans->pol3 = NULL; }
-      if ( sptrans->coslat  ) { free(sptrans->coslat);   sptrans->coslat = NULL; }
-      if ( sptrans->rcoslat ) { free(sptrans->rcoslat);  sptrans->rcoslat = NULL; }
-
-      free(sptrans); sptrans = NULL;
+      if ( sptrans->trig ) { Free(sptrans->trig);  sptrans->trig = NULL; }
+      if ( sptrans->poli ) { Free(sptrans->poli);  sptrans->poli = NULL; }
+      if ( sptrans->pold ) { Free(sptrans->pold);  sptrans->pold = NULL; }
+      if ( sptrans->pol2 ) { Free(sptrans->pol2);  sptrans->pol2 = NULL; }
+      if ( sptrans->pol3 ) { Free(sptrans->pol3);  sptrans->pol3 = NULL; }
+      if ( sptrans->coslat  ) { Free(sptrans->coslat);   sptrans->coslat = NULL; }
+      if ( sptrans->rcoslat ) { Free(sptrans->rcoslat);  sptrans->rcoslat = NULL; }
+
+      Free(sptrans); sptrans = NULL;
     }
 }
 
 
 DVTRANS *dvtrans_new(int ntr)
 {
-  DVTRANS *dvtrans = (DVTRANS*) malloc(sizeof(DVTRANS));
+  DVTRANS *dvtrans = (DVTRANS*) Malloc(sizeof(DVTRANS));
 
   dvtrans->ntr = ntr;
 
   int dimsp = (ntr + 1)*(ntr + 2);
   dvtrans->fdim = dimsp / 2;
 
-  dvtrans->f1 = (double*) malloc(dvtrans->fdim * sizeof(double));
-  dvtrans->f2 = (double*) malloc(dvtrans->fdim * sizeof(double));
+  dvtrans->f1 = (double*) Malloc(dvtrans->fdim * sizeof(double));
+  dvtrans->f2 = (double*) Malloc(dvtrans->fdim * sizeof(double));
 
   geninx(ntr, dvtrans->f1, dvtrans->f2);
 
@@ -210,10 +209,10 @@ void dvtrans_delete(DVTRANS *dvtrans)
 {
   if ( dvtrans )
     {
-      if ( dvtrans->f1 ) { free(dvtrans->f1);  dvtrans->f1 = NULL; }
-      if ( dvtrans->f2 ) { free(dvtrans->f2);  dvtrans->f2 = NULL; }
+      if ( dvtrans->f1 ) { Free(dvtrans->f1);  dvtrans->f1 = NULL; }
+      if ( dvtrans->f2 ) { Free(dvtrans->f2);  dvtrans->f2 = NULL; }
 
-      free(dvtrans); dvtrans = NULL;
+      Free(dvtrans); dvtrans = NULL;
     }
 }
 
@@ -234,8 +233,8 @@ void trans_uv2dv(SPTRANS *sptrans, int nlev,
   int waves = ntr + 1;
   int nfc   = waves * 2;
 
-  double *fpwork1 = (double*) malloc(nlat*nfc*nlev*sizeof(double));
-  double *fpwork2 = (double*) malloc(nlat*nfc*nlev*sizeof(double));
+  double *fpwork1 = (double*) Malloc(nlat*nfc*nlev*sizeof(double));
+  double *fpwork2 = (double*) Malloc(nlat*nfc*nlev*sizeof(double));
 
   gp2fc(sptrans->trig, sptrans->ifax, gu, fpwork1, nlat, nlon, nlev, nfc);
   gp2fc(sptrans->trig, sptrans->ifax, gv, fpwork2, nlat, nlon, nlev, nfc);
@@ -245,8 +244,8 @@ void trans_uv2dv(SPTRANS *sptrans, int nlev,
 
   uv2dv(fpwork1, fpwork2, sd, svo, sptrans->pol2, sptrans->pol3, nlev, nlat, ntr);
 
-  free(fpwork1);
-  free(fpwork2);
+  Free(fpwork1);
+  Free(fpwork2);
 }
 
 
@@ -272,7 +271,7 @@ void trans_dv2uv(SPTRANS *sptrans, DVTRANS *dvtrans, int nlev,
 
   dv2uv(sd, svo, su, sv, dvtrans->f1, dvtrans->f2, ntr, dimsp, nlev);
 
-  double *fpwork = (double*) malloc(nlat*nfc*nlev*sizeof(double));
+  double *fpwork = (double*) Malloc(nlat*nfc*nlev*sizeof(double));
 
   sp2fc(su, fpwork, sptrans->poli, nlev, nlat, nfc, ntr);
   scaluv(fpwork, sptrans->rcoslat, nlat, nfc*nlev);
@@ -282,6 +281,6 @@ void trans_dv2uv(SPTRANS *sptrans, DVTRANS *dvtrans, int nlev,
   scaluv(fpwork, sptrans->rcoslat, nlat, nfc*nlev);
   fc2gp(sptrans->trig, sptrans->ifax, fpwork, gv, nlat, nlon, nlev, nfc);
 
-  free(fpwork);
+  Free(fpwork);
 }
 
diff --git a/src/statistic.c b/src/statistic.c
index ddf0b02..775269d 100644
--- a/src/statistic.c
+++ b/src/statistic.c
@@ -4,6 +4,9 @@
 /* HEADER FOR PARALLEL EIGEN SOLUTION */
 /*  -->SEE END OF ROUTINE             */
 /* ********************************** */
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -68,13 +71,13 @@ void eigen_solution_of_symmetric_matrix (double **a, double *eig_val,
   int i, j;
   double temp;
   
-  e = (double*) malloc(n * sizeof(double));
+  e = (double*) Malloc(n * sizeof(double));
   
   make_symmetric_matrix_triangular (a, n, eig_val, e);
   
   eigen_solution_of_triangular_matrix (eig_val, e, n, a, prompt);
   
-  free (e);
+  Free(e);
 
   for (i = 0; i < n; i++)
     for (j = i + 1; j < n; j++)
@@ -335,14 +338,14 @@ int solution_of_linear_equation (double **a, double *b, int n)
   int sign;
   int not_singular;
   
-  index = (int*) malloc(n * sizeof(int));
+  index = (int*) Malloc(n * sizeof(int));
   
   not_singular = lu_decomposition (a, n, index, &sign);
   
   if (not_singular)
     lu_backsubstitution (a, n, index, b);
   
-  free (index);
+  Free(index);
   
   return not_singular;
 }
@@ -356,8 +359,8 @@ int inverse_of_matrix (double **a, double **b, int n)
   int not_singular;
   double *col;
   
-  index = (int*) malloc(n * sizeof(int));
-  col = (double*) malloc(n * sizeof(double));
+  index = (int*) Malloc(n * sizeof(int));
+  col = (double*) Malloc(n * sizeof(double));
   
   not_singular = lu_decomposition (a, n, index, &sign);
   
@@ -374,8 +377,8 @@ int inverse_of_matrix (double **a, double **b, int n)
         }
     }
   
-  free (index);
-  free (col);
+  Free(index);
+  Free(col);
 
   return not_singular;
 }
@@ -387,7 +390,7 @@ int lu_decomposition (double **a, int n, int *index, int *sign)
   double big, sum, temp;
   double *v;
   
-  v = (double*) malloc(n * sizeof(double));
+  v = (double*) Malloc(n * sizeof(double));
   *sign = 1;
   for (i = 0; i < n; i++)
     {
@@ -445,7 +448,7 @@ int lu_decomposition (double **a, int n, int *index, int *sign)
         }
     }
 
-  free (v);
+  Free(v);
 
   return 1;
 }
@@ -553,12 +556,12 @@ void ft(double *real, double *imag, int n, int sign)
   
   if (!work_r)
     {
-      work_r = (double*) malloc(n * sizeof(double));
+      work_r = (double*) Malloc(n * sizeof(double));
       /* free_at_exit (work_r); */
     }
   if (!work_i)
     {
-      work_i = (double*) malloc(n * sizeof(double));
+      work_i = (double*) Malloc(n * sizeof(double));
       /* free_at_exit (work_i); */
     }
   
@@ -1279,8 +1282,8 @@ void annihilate_1side(double **M, long i, long j, long n)
 
   i--; j--;
 
-  double *restrict mi = (double*) malloc(n*sizeof(double));
-  double *restrict mj = (double*) malloc(n*sizeof(double));
+  double *restrict mi = (double*) Malloc(n*sizeof(double));
+  double *restrict mj = (double*) Malloc(n*sizeof(double));
 
   if ( ! mj || ! mi) 
     fprintf(stderr, "ERROR: allocation error - cannot allocate memory\n"
@@ -1307,13 +1310,12 @@ void annihilate_1side(double **M, long i, long j, long n)
 
   if ( tmp < fnorm_precision ) {
 #if defined(_OPENMP)
-#pragma omp critical 
+#pragma omp atomic
 #endif
-    {
-      n_finished++;
-    }
-    free(mi);
-    free(mj);
+    n_finished++;
+
+    Free(mi);
+    Free(mj);
     return;
   }
   
@@ -1333,8 +1335,8 @@ void annihilate_1side(double **M, long i, long j, long n)
   for ( r = 0; r < n; r++ ) Mi[r] = mi[r];
   for ( r = 0; r < n; r++ ) Mj[r] = mj[r];
 
-  free(mi);
-  free(mj);
+  Free(mi);
+  Free(mj);
 
   return;
 }
@@ -1351,8 +1353,8 @@ int jacobi_1side(double **M, double *A, long n)
 
   if ( n > 0 )
     {
-      annihilations_buff = (int*) malloc(n*n*2*sizeof(int));
-      annihilations = (int**) malloc((n*n)*sizeof(int*));
+      annihilations_buff = (int*) Malloc(n*n*2*sizeof(int));
+      annihilations = (int**) Malloc((n*n)*sizeof(int*));
     }
 
   for(i=0;i<n*n;i++)
@@ -1397,7 +1399,7 @@ int jacobi_1side(double **M, double *A, long n)
     if ( n%2 == 1 ) {
       for ( m = 0; m < n; m++ ) {
 #if defined(_OPENMP)
-#pragma omp parallel for private(i,idx,i_ann,j_ann) shared(M,annihilations,n) reduction(+:n_finished)
+#pragma omp parallel for private(idx,i_ann,j_ann) shared(M,annihilations,n,n_finished)
 #endif
         for ( i = 0; i < n/2; i++) {
           idx = m*(n/2)+i;
@@ -1411,7 +1413,7 @@ int jacobi_1side(double **M, double *A, long n)
     else { // n%2 == 0                                                                               
       for( m = 0; m < n; m++) {
 #if defined(_OPENMP)
-#pragma omp parallel for private(i,idx,i_ann,j_ann) shared(M,annihilations,n) reduction(+:n_finished)
+#pragma omp parallel for private(idx,i_ann,j_ann) shared(M,annihilations,n,n_finished)
 #endif
         for( i = 0; i < n/2-(m%2); i++) {
 	  idx = m/2 * ( n/2 + n/2-1);
@@ -1462,8 +1464,8 @@ int jacobi_1side(double **M, double *A, long n)
 
   heap_sort(A,M,n);
   
-  if ( annihilations      ) free(annihilations);
-  if ( annihilations_buff ) free(annihilations_buff);
+  if ( annihilations      ) Free(annihilations);
+  if ( annihilations_buff ) Free(annihilations_buff);
   
   return n_iter;
 }
diff --git a/src/statistic.h b/src/statistic.h
index d6fa55e..941f3cf 100644
--- a/src/statistic.h
+++ b/src/statistic.h
@@ -2,6 +2,10 @@
 
 #define _STATISTIC_H
 
+#if defined(HAVE_CONFIG_H)
+#include "config.h"
+#endif
+
 void eigen_solution_of_symmetric_matrix (double **a, double *eig_val, int n, const char *prompt);
 int solution_of_linear_equation (double **a, double *b, int n);
 int inverse_of_matrix (double **a, double **b, int n);
diff --git a/src/stdnametable.c b/src/stdnametable.c
index 4ac54ce..cabcb73 100644
--- a/src/stdnametable.c
+++ b/src/stdnametable.c
@@ -8,9 +8,9 @@ typedef struct
 {
   int   varid;
   int   echamcode;
-  char *name;
-  char *stdname;     /* Standard name */
-  char *units;       /* Units         */
+  const char *name;
+  const char *stdname;     /* Standard name */
+  const char *units;       /* Units         */
 }
 stdnametable_t;
 
diff --git a/src/table.c b/src/table.c
index f7bef07..f506f96 100644
--- a/src/table.c
+++ b/src/table.c
@@ -22,45 +22,36 @@
 
 #include <cdi.h>
 #include "cdo.h"
+#include "util.h"
 #include "error.h"
 
 
-#ifndef  UNDEFID
-#define  UNDEFID  CDI_UNDEFID
-#endif
-
-
-int defineTable(char *tablearg)
+int defineTable(const char *tablearg)
 {
-  char *tablename;
-  int tableID = UNDEFID;
+  int tableID = CDI_UNDEFID;
+  const char *tablename = tablearg;
 
-  tablename = tablearg;
+  if ( fileExists(tablename) ) tableID = tableRead(tablename);
 
-  tableID = tableRead(tablename);
-
-  if ( tableID == UNDEFID )
+  if ( tableID == CDI_UNDEFID )
     {
       char *tablepath = getenv("CD_TABLEPATH");
-
       if ( tablepath )
 	{
-	  char *tablefile = NULL;
 	  int len = sizeof(tablepath) + sizeof(tablename) + 3;
-	  tablefile = (char*) malloc(len);
+	  char tablefile[len];
 	  strcpy(tablefile, tablepath);
 	  strcat(tablefile, "/");
 	  strcat(tablefile, tablename);
-	  tableID = tableRead(tablefile);
-	  free(tablefile);
+	  if ( fileExists(tablename) ) tableID = tableRead(tablefile);
 	}
     }
 
-  if ( tableID == UNDEFID )
+  if ( tableID == CDI_UNDEFID )
     tableID = tableInq(-1, 0, tablename);
 
-  if ( tableID == UNDEFID )
+  if ( tableID == CDI_UNDEFID )
     Error("table <%s> not found", tablename);
 
-  return (tableID);
+  return tableID;
 }
diff --git a/src/template_parser.c b/src/template_parser.c
index 706fee9..f6b4617 100644
--- a/src/template_parser.c
+++ b/src/template_parser.c
@@ -58,7 +58,7 @@ int template_parser(  char *Filename, const char *varname )
 
         xmlCleanupParser();
 
-        return (0);
+        return 0;
 }
 
 
diff --git a/src/text.c b/src/text.c
index 6c52340..a43a3b0 100644
--- a/src/text.c
+++ b/src/text.c
@@ -1,5 +1,5 @@
-#include <stdio.h>
 #include "cdo.h"
+#include "cdo_int.h"
 
 
 void set_text_color(FILE *fp, int attr, int fg)
diff --git a/src/text.h b/src/text.h
index a9c9b4f..db06e76 100644
--- a/src/text.h
+++ b/src/text.h
@@ -1,6 +1,8 @@
 #ifndef _TEXT_H
 #define _TEXT_H
 
+#include <stdio.h>
+
 #define RESET		0
 #define BRIGHT 		1
 #define DIM		2
diff --git a/src/userlog.c b/src/userlog.c
index b27ca65..1317ce3 100644
--- a/src/userlog.c
+++ b/src/userlog.c
@@ -2,8 +2,9 @@
 #  include "config.h"
 #endif
 
-#include <stdio.h>
-#include <string.h>
+#include "cdo_int.h"
+#include "process.h"
+
 #include <time.h>
 /* #include <pwd.h> */
 #include <sys/types.h>
@@ -11,11 +12,6 @@
 #include <unistd.h>  /* write, close */
 #include <fcntl.h>
 #include <errno.h>
-#include <stdlib.h>  /* qsort */
-
-#include "cdo.h"
-#include "dtypes.h"
-#include "process.h"
 
 #if ! defined(VERSION)
 #  define  VERSION  "0.0.1"
@@ -277,14 +273,14 @@ int flt2ibm(float x, unsigned char *ibm) {
                                       ((int)xb[1]<<16) + \
                                       ((int)xb[2]<<8)  + \
                                       ((int)xb[3])))
-#define  GET_UINT8(xb)        ((INT64) (((INT64)xb[0]<<56) + \
-                                        ((INT64)xb[1]<<48) + \
-                                        ((INT64)xb[2]<<40) + \
-                                        ((INT64)xb[3]<<32) + \
-                                        ((INT64)xb[4]<<24) + \
-                                        ((INT64)xb[5]<<16) + \
-                                        ((INT64)xb[6]<<8)  + \
-					((INT64)xb[7])))
+#define  GET_UINT8(xb)        ((int64_t) (((int64_t)xb[0]<<56) + \
+                                         ((int64_t)xb[1]<<48) + \
+                                         ((int64_t)xb[2]<<40) + \
+                                         ((int64_t)xb[3]<<32) + \
+                                         ((int64_t)xb[4]<<24) + \
+                                         ((int64_t)xb[5]<<16) + \
+                                         ((int64_t)xb[6]<<8)  + \
+					 ((int64_t)xb[7])))
 
 #define  PUT_UINT4(xb, iv)    ((*(xb)   = (iv) >> 24), \
                                (*(xb+1) = (iv) >> 16), \
@@ -317,7 +313,7 @@ void cdologs(int noper)
   int date = 0, ncdo = 0, nhours = 0;
   int date0 = 0, ncdo0, noper0, nhours0;
   double cputime0;
-  INT64 nvals0;
+  int64_t nvals0;
   unsigned char logbuf[LOGSSIZE];
   unsigned char *logdate   =  logbuf;
   unsigned char *logncdo   = &logbuf[4];
@@ -463,7 +459,7 @@ void dumplogs(const char *logfilename)
   int nlogs;
   int i;
   double cputime0;
-  INT64 nvals0;
+  int64_t nvals0;
   unsigned char logbuf[LOGSSIZE];
   unsigned char *logdate   =  logbuf;
   unsigned char *logncdo   = &logbuf[4];
@@ -498,7 +494,7 @@ void dumplogs(const char *logfilename)
 
   if ( bufsize > 0 )
     {
-      buffer = (unsigned char*) malloc(bufsize);
+      buffer = (unsigned char*) Malloc(bufsize);
 
       status = (int) read(logfileno, buffer, bufsize);
 
@@ -513,7 +509,7 @@ void dumplogs(const char *logfilename)
 	  nvals0   = GET_UINT8(lognvals);
 	  nhours0  = GET_UINT4(lognhours);
 
-	  if ( sizeof(INT64) > sizeof(long) )
+	  if ( sizeof(int64_t) > sizeof(long) )
 	    fprintf(stdout, "%8d %10d %10d %19lld %10d %8.2f\n",
 		    date0, ncdo0, noper0, (long long)nvals0, nhours0, cputime0);
 	  else
@@ -521,7 +517,7 @@ void dumplogs(const char *logfilename)
 		    date0, ncdo0, noper0, (long)nvals0, nhours0, cputime0);
 	}
 
-      free(buffer);
+      Free(buffer);
     }
 
   close(logfileno);
@@ -541,7 +537,7 @@ void daylogs(const char *logfilename)
   int nlogs;
   int i;
   double cputime0;
-  INT64 nvals0;
+  int64_t nvals0;
   unsigned char logbuf[LOGSSIZE];
   unsigned char *logdate   =  logbuf;
   unsigned char *logncdo   = &logbuf[4];
@@ -571,7 +567,7 @@ void daylogs(const char *logfilename)
 
   if ( bufsize > 0 )
     {
-      buffer = (unsigned char*) malloc(bufsize);
+      buffer = (unsigned char*) Malloc(bufsize);
 
       status = (int) read(logfileno, buffer, bufsize);
 
@@ -591,7 +587,7 @@ void daylogs(const char *logfilename)
 		  date0, noper0, (int)(8*nvals0/(1024*1024)), (int) (nhours0*3600.+cputime0));
 	}
 
-      free(buffer);
+      Free(buffer);
     }
 
   close(logfileno);
@@ -610,7 +606,7 @@ void monlogs(const char *logfilename)
   int nlogs;
   int i;
   double cputime0;
-  INT64 nvals0;
+  int64_t nvals0;
   unsigned char logbuf[LOGSSIZE];
   unsigned char *logdate   =  logbuf;
   unsigned char *logncdo   = &logbuf[4];
@@ -643,7 +639,7 @@ void monlogs(const char *logfilename)
 
   if ( bufsize > 0 )
     {
-      buffer = (unsigned char*) malloc(bufsize);
+      buffer = (unsigned char*) Malloc(bufsize);
 
       status = (int) read(logfileno, buffer, bufsize);
 
@@ -681,7 +677,7 @@ void monlogs(const char *logfilename)
       fprintf(stdout, "%6d   %12u %12d %12d\n",
 	      ymon0, noper, (int)(8*size/(1024*1024*1024)), (int) (cputime/3600));
       
-      free(buffer);
+      Free(buffer);
     }
 
   close(logfileno);
@@ -706,7 +702,7 @@ void cdologo(int noper)
   int nhours = 0;
   int nhours0 = 0;
   double cputime0 = 0;
-  INT64 nvals0 = 0;
+  int64_t nvals0 = 0;
   unsigned char logbuf[LOGOSIZE];
   unsigned char *logname   =  logbuf;
   unsigned char *lognocc   = &logbuf[16];
@@ -772,7 +768,7 @@ void cdologo(int noper)
   bufsize = (size_t) filestat.st_size;
 
   newbufsize = bufsize + noper*logsize;
-  buffer = (unsigned char*) malloc(newbufsize);
+  buffer = (unsigned char*) Malloc(newbufsize);
   if ( bufsize > 0 )
     status = (int) read(logfileno, buffer, bufsize);
 
@@ -820,7 +816,7 @@ void cdologo(int noper)
   status = (int) lseek(logfileno, 0, SEEK_SET);
   status = (int) write(logfileno, buffer, bufsize);
 
-  free(buffer);
+  Free(buffer);
 
  endlabel:
 
@@ -844,7 +840,7 @@ void cdologo(int noper)
 typedef struct
 {
   int      nocc;
-  INT64    nvals;
+  int64_t  nvals;
   double   time;
   double   perc;
   char     name[128];
@@ -855,8 +851,8 @@ static
 int cmplognocc(const void *s1, const void *s2)
 {
   int cmp = 0;
-  const loginfo_t *x = s1;
-  const loginfo_t *y = s2;
+  const loginfo_t *x = (const loginfo_t *) s1;
+  const loginfo_t *y = (const loginfo_t *) s2;
 
   if      ( x->nocc < y->nocc ) cmp =  1;
   else if ( x->nocc > y->nocc ) cmp = -1;
@@ -868,8 +864,8 @@ static
 int cmplognvals(const void *s1, const void *s2)
 {
   int cmp = 0;
-  const loginfo_t *x = s1;
-  const loginfo_t *y = s2;
+  const loginfo_t *x = (const loginfo_t *) s1;
+  const loginfo_t *y = (const loginfo_t *) s2;
 
   if      ( x->nvals < y->nvals ) cmp =  1;
   else if ( x->nvals > y->nvals ) cmp = -1;
@@ -881,8 +877,8 @@ static
 int cmplogtime(const void *s1, const void *s2)
 {
   int cmp = 0;
-  const loginfo_t *x = s1;
-  const loginfo_t *y = s2;
+  const loginfo_t *x = (const loginfo_t *) s1;
+  const loginfo_t *y = (const loginfo_t *) s2;
 
   if      ( x->time < y->time ) cmp =  1;
   else if ( x->time > y->time ) cmp = -1;
@@ -894,8 +890,8 @@ static
 int cmplogperc(const void *s1, const void *s2)
 {
   int cmp = 0;
-  const loginfo_t *x = s1;
-  const loginfo_t *y = s2;
+  const loginfo_t *x = (const loginfo_t *) s1;
+  const loginfo_t *y = (const loginfo_t *) s2;
 
   if      ( x->perc < y->perc ) cmp =  1;
   else if ( x->perc > y->perc ) cmp = -1;
@@ -906,8 +902,8 @@ int cmplogperc(const void *s1, const void *s2)
 static
 int cmplogname(const void *s1, const void *s2)
 {
-  const loginfo_t *x = s1;
-  const loginfo_t *y = s2;
+  const loginfo_t *x = (const loginfo_t *)s1;
+  const loginfo_t *y = (const loginfo_t *)s2;
 
   return (strcmp(x->name, y->name));
 }
@@ -924,7 +920,7 @@ void dumplogo(const char *logfilename, int dumptype)
   int i;
   int mem;
   double cputime0;
-  INT64 nvals0;
+  int64_t nvals0;
   unsigned char logbuf[LOGOSIZE];
   unsigned char *logname   =  logbuf;
   unsigned char *lognocc   = &logbuf[16];
@@ -960,14 +956,14 @@ void dumplogo(const char *logfilename, int dumptype)
   if ( bufsize > 0 )
     {
       fprintf(stdout, "# num name                     call        mem [GB]    time [h]     perc [s]\n");
-      buffer = (unsigned char*) malloc(bufsize);
+      buffer = (unsigned char*) Malloc(bufsize);
 
       status = (int) read(logfileno, buffer, bufsize);
 
       nlogs = bufsize / logsize;
 
-      logInfo    = (loginfo_t **) malloc(nlogs*sizeof(loginfo_t *));
-      logInfo[0] = (loginfo_t*) malloc(nlogs*sizeof(loginfo_t));
+      logInfo    = (loginfo_t **) Malloc(nlogs*sizeof(loginfo_t *));
+      logInfo[0] = (loginfo_t*) Malloc(nlogs*sizeof(loginfo_t));
       for ( i = 1; i < nlogs; i++ ) logInfo[i] = logInfo[0] + i;
 
       for ( i = 0; i < nlogs; i++ )
@@ -999,7 +995,7 @@ void dumplogo(const char *logfilename, int dumptype)
       for ( i = 0; i < nlogs; i++ )
 	{
 	  mem = (int)(8*logInfo[i]->nvals/(1024*1024*1024));
-	  if ( sizeof(INT64) > sizeof(long) )
+	  if ( sizeof(int64_t) > sizeof(long) )
 	    fprintf(stdout, "%4d  %-16s %12d %12d %12.3f %12.3f\n", i+1, logInfo[i]->name, 
 		    logInfo[i]->nocc, mem, logInfo[i]->time, logInfo[i]->perc);
 	  else
@@ -1007,9 +1003,9 @@ void dumplogo(const char *logfilename, int dumptype)
 		    logInfo[i]->nocc, mem, logInfo[i]->time, logInfo[i]->perc);
 	}
 
-      free(logInfo[0]);
-      free(logInfo);
-      free(buffer);
+      Free(logInfo[0]);
+      Free(logInfo);
+      Free(buffer);
     }
 
   close(logfileno);
diff --git a/src/util.c b/src/util.c
index f29d70c..4339f61 100644
--- a/src/util.c
+++ b/src/util.c
@@ -51,15 +51,14 @@
 /* refactor: moved here from *.c */
 
 int CDO_opterr = 0;      // refactor: moved here from cdo_getopt.c
-char *CDO_optarg = NULL; // refactor: moved here from cdo_getopt.c
+const char *CDO_optarg = NULL; // refactor: moved here from cdo_getopt.c
 int CDO_optind = 1;      // refactor: moved here from cdo_getopt.c
-int remap_genweights = TRUE;  // refactor: moved here from Remap.c
 
 
 /* refactor: moved here from cdo.c */
 
 char *Progname;
-char CDO_Version[] = "Climate Data Operators version "VERSION" (http://mpimet.mpg.de/cdo)"; // refactor: moved here from cdo.c
+const char *CDO_Version = "Climate Data Operators version " VERSION" (http://mpimet.mpg.de/cdo)";
 
 int ompNumThreads = 1;
 
@@ -67,7 +66,7 @@ int stdin_is_tty  = 0;
 int stdout_is_tty = 0;
 int stderr_is_tty = 0;
 
-char* cdoGridSearchDir   = NULL;
+char *cdoGridSearchDir   = NULL;
 
 int cdoDefaultFileType   = CDI_UNDEFID;
 int cdoDefaultDataType   = CDI_UNDEFID;
@@ -81,6 +80,9 @@ int cdoCheckDatarange    = FALSE;
 
 int CDO_Color            = FALSE;
 int CDO_Use_FFTW         = TRUE;
+int CDO_Version_Info     = TRUE;
+int CDO_CMOR_Mode        = FALSE;
+
 int cdoDiag              = FALSE;
 
 int CDO_Reduce_Dim       = FALSE;
@@ -108,11 +110,31 @@ char **cdoVarnames       = NULL;
 char CDO_File_Suffix[32];
 
 int cdoExpMode           = -1;
-char *cdoExpName         = NULL;
+const char *cdoExpName         = NULL;
 
 int timer_read, timer_write;
 
 
+
+const char *cdoComment(void)
+{
+  static char comment[256];
+  static int init = 0;
+
+  if ( ! init )
+    {
+      init = 1;
+
+      int size = strlen(CDO_Version);
+
+      strncat(comment, CDO_Version, size);
+      comment[size] = 0;
+    }
+
+  return comment;
+}
+
+
 #if defined(HAVE_FNMATCH_H)
 int wildcardmatch(const char *pattern, const char *string)
 {
@@ -147,13 +169,11 @@ int wildcardmatch(const char *w, const char *s)
 
 int cdo_omp_get_thread_num(void)
 {
-  int threadnum = 0;
-
 #if defined(_OPENMP)
-  threadnum = omp_get_thread_num();
+  return omp_get_thread_num();
+#else
+  return 0;
 #endif
-
-  return (threadnum);
 }
 
 
@@ -183,7 +203,7 @@ char *getOperator(const char *argument)
     {
       len = 1 + strlen(argument);
 
-      operatorArg = (char*) malloc(len);
+      operatorArg = (char*) Malloc(len);
 
       memcpy(operatorArg, argument, len);
     }
@@ -203,21 +223,22 @@ char *getOperatorName(const char *operatorArg)
     {
       if ( operatorArg[0] == '-' ) operatorArg++;
 
-      commapos = strchr(operatorArg, ',');
+      commapos = (char *)strchr(operatorArg, ',');
 
       if ( commapos )
         len = commapos - operatorArg;
       else
         len = strlen(operatorArg);
 
-      operatorName = (char*) malloc(len+1);
+      operatorName = (char*) Malloc(len+1);
 
       memcpy(operatorName, operatorArg, len);
       operatorName[len] = '\0';
     }
 
   /*  return (operatorName); */
-  return (operatorAlias(operatorName));
+  char * alias = operatorAlias(operatorName);
+  return alias;
 }
 
 
@@ -225,10 +246,10 @@ argument_t *file_argument_new(const char *filename)
 {
   argument_t *argument;
 
-  argument = (argument_t*) calloc(1, sizeof(argument_t));
+  argument = (argument_t*) Calloc(1, sizeof(argument_t));
 
   argument->argc = 1;
-  argument->argv = (char **) calloc(1, sizeof(char *));
+  argument->argv = (char **) Calloc(1, sizeof(char *));
   argument->argv[0] = (char *) filename;
   argument->args = (char *) filename;
 
@@ -243,9 +264,9 @@ void file_argument_free(argument_t *argument)
       if ( argument->argc )
         {
           assert(argument->argc == 1);
-          free(argument->argv);
+          Free(argument->argv);
         }
-      free(argument);
+      Free(argument);
     }
 }
 
@@ -254,16 +275,16 @@ argument_t *argument_new(size_t argc, size_t len)
 {
   argument_t *argument;
 
-  argument = (argument_t*) calloc(1, sizeof(argument_t));
+  argument = (argument_t*) Calloc(1, sizeof(argument_t));
 
   if ( argc > 0 )
     {
       argument->argc = argc;
-      argument->argv = (char **) calloc(argc, sizeof(char *));
+      argument->argv = (char **) Calloc(argc, sizeof(char *));
     }
 
   if ( len > 0 )
-    argument->args = (char*) calloc(len, sizeof(char));
+    argument->args = (char*) Calloc(len, sizeof(char));
 
   return (argument);
 }
@@ -280,23 +301,23 @@ void argument_free(argument_t *argument)
             {
               if ( argument->argv[i] )
                 {
-                  free(argument->argv[i]);
+                  Free(argument->argv[i]);
                   argument->argv[i] = NULL;
                 }
             }
 
-          free(argument->argv);
+          Free(argument->argv);
           argument->argv = NULL;
           argument->argc = 0;
         }
 
       if ( argument->args )
         {
-          free(argument->args);
+          Free(argument->args);
           argument->args = NULL;
         }
 
-      free(argument);
+      Free(argument);
     }
 }
 
@@ -327,7 +348,7 @@ char *getFileArg(char *argument)
         {
           parg = blankpos + 1;
           len = strlen(parg);
-          fileArg = (char*) malloc(len+1);
+          fileArg = (char*) Malloc(len+1);
           strcpy(fileArg, parg);
         }
     }
@@ -407,27 +428,33 @@ int parameter2intlist(const char *string)
 const char *seas_name_dec[4] = {"DJF", "MAM", "JJA", "SON"};
 const char *seas_name_jan[4] = {"JFM", "AMJ", "JAS", "OND"};
 
+static int season_start = START_DEC;
+
 int get_season_start(void)
 {
-  int season_start = START_DEC;
-  char *envstr;
+  static int lgetenv = TRUE;
 
-  envstr = getenv("CDO_SEASON_START");
-  if ( envstr )
+  if ( lgetenv )
     {
-      if      ( strcmp(envstr, "DEC") == 0 ) season_start = START_DEC;
-      else if ( strcmp(envstr, "JAN") == 0 ) season_start = START_JAN;
-      
-      if ( cdoVerbose )
+      lgetenv = FALSE;
+  
+      char *envstr = getenv("CDO_SEASON_START");
+      if ( envstr )
         {
-          if      ( season_start == START_DEC )
-            cdoPrint("Set SEASON_START to December");
-          else if ( season_start == START_JAN )
-            cdoPrint("Set SEASON_START to January");
+          if      ( strcmp(envstr, "DEC") == 0 ) season_start = START_DEC;
+          else if ( strcmp(envstr, "JAN") == 0 ) season_start = START_JAN;
+      
+          if ( cdoVerbose )
+            {
+              if      ( season_start == START_DEC )
+                cdoPrint("Set SEASON_START to December");
+              else if ( season_start == START_JAN )
+                cdoPrint("Set SEASON_START to January");
+            }
         }
     }
 
-  return (season_start);
+  return season_start;
 }
 
 
@@ -442,25 +469,52 @@ void get_season_name(const char *seas_name[])
 }
 
 
+int month_to_season(int month)
+{
+  int season_start = get_season_start();
+  int seas = -1;
+
+  if ( month < 0 || month > 16 ) cdoAbort("Month %d out of range!", month);
+
+  if ( season_start == START_DEC )
+    {
+      if ( month <= 12 )
+        seas = (month % 12) / 3;
+      else
+        seas = month - 13;
+    }
+  else
+    {
+      if ( month <= 12 )
+        seas = (month - 1) / 3;
+      else
+        seas = month - 13;
+    }
+
+  if ( seas < 0 || seas > 3 ) cdoAbort("Season %d out of range!", seas+1);
+
+  return seas;
+}
+
 //#include <sys/types.h>
 #include <sys/stat.h>
 //#include <unistd.h>
 
-int fileExists(const char *filename)
+int fileExists(const char *restrict filename)
 {
   int status = 0;
   struct stat buf;
 
   if ( stat(filename, &buf) == 0 )
     {
-      if ( buf.st_size > 0 ) status = 1;
+      if ( S_ISREG(buf.st_mode) && buf.st_size > 0 ) status = 1;
     }
 
-  return (status);
+  return status;
 }
 
 
-int userFileOverwrite(const char *filename)
+int userFileOverwrite(const char *restrict filename)
 {
   int status = 0, len;
   char line[1024], *pline;
@@ -590,29 +644,20 @@ int str2datatype(const char *datatypestr)
 }
 
 
-off_t filesize(const char *filename)
+off_t fileSize(const char *restrict filename)
 {
-  FILE *fp;
-  off_t pos = 0;
+  off_t filesize = 0;
 
   if ( filename[0] == '(' && filename[1] == 'p' )
     {
     }
   else
     {
-      fp = fopen(filename, "r");
-      if ( fp == NULL )
-        {
-          fprintf(stderr, "Open failed on %s\n", filename);
-        }
-      else
-        {
-          fseek(fp, 0L, SEEK_END);
-          pos = ftello(fp);
-        }
+      struct stat buf;
+      if ( stat(filename, &buf) == 0 ) filesize = buf.st_size;
     }
   
-  return pos;
+  return filesize;
 }
 
 
@@ -695,7 +740,7 @@ void cdoGenFileSuffix(char *filesuffix, size_t maxlen, int filetype, int vlistID
 
               if ( len > 2 )
                 {
-                  char *result = strrchr(refname, '.');
+                  char *result = (char *)strrchr(refname, '.');
                   if ( result != NULL && result[1] != 0 )
                     {
                       int firstchar = tolower(result[1]);
diff --git a/src/util.h b/src/util.h
index 8794c04..33444c8 100644
--- a/src/util.h
+++ b/src/util.h
@@ -18,6 +18,8 @@
 #ifndef _UTIL_H
 #define _UTIL_H
 
+#include <stdio.h>
+#include "percentiles.h"
 
 /* dummy use of unused parameters to silence compiler warnings */
 #define  UNUSED(x) (void)x
@@ -32,7 +34,11 @@
 #undef   MAX
 #define  MAX(a,b)  ((a) > (b) ? (a) : (b))
 
-#define  ADD_PLURAL(n)  ((n)>1 ? "s" : "")
+#undef   SQR
+#define  SQR(a)    ((a)*(a))
+
+
+#define  ADD_PLURAL(n)  ((n)!=1 ? "s" : "")
 
 #define  UNCHANGED_RECORD  (processSelf() == 0 && cdoStreamName(0)->argv[0][0] != '-' && cdoRegulargrid == FALSE && cdoDefaultFileType == -1 && cdoDefaultDataType == -1 && cdoDefaultByteorder == -1 )
 
@@ -44,11 +50,11 @@ extern int CDO_Reset_History;
 extern int timer_read, timer_write; // refactor: both pstream.c and CDIread.c CDIwrite.c defined in cdo.c
 
 extern int   CDO_optind;
-extern char *CDO_optarg;
+extern const char *CDO_optarg;
 extern int CDO_opterr;
 extern int remap_genweights;
 
-extern char *cdoExpName;
+extern const char *cdoExpName;
 extern int ompNumThreads;
 
 extern int stdin_is_tty;
@@ -86,15 +92,15 @@ extern int cdoExpMode;
 
 extern int CDO_Color;
 extern int CDO_Use_FFTW;
+extern int CDO_Version_Info;
+extern int CDO_CMOR_Mode;
 extern int cdoDiag;
 
 extern int cdoNumVarnames;
 extern char **cdoVarnames;
 extern char CDO_File_Suffix[32]; // refactor: added keyword extern
 
-
-/* moved here from *.c */
-extern char CDO_Version[]; // refactor: moved here from pstream.c
+extern const char *CDO_Version;
 
 
 typedef struct {
@@ -113,6 +119,7 @@ void        argument_fill(argument_t *argument, int argc, char *argv[]);
 char *getProgname(char *string);
 char *getOperator(const char *argument);
 char *getOperatorName(const char *xoperator);
+const char *cdoComment(void);
 
 argument_t makeArgument(int argc, char *argv[]);
 char *getFileArg(char *argument);
@@ -120,6 +127,7 @@ char *getFileArg(char *argument);
 enum {START_DEC, START_JAN};
 int get_season_start(void);
 void get_season_name(const char *seas_name[]);
+int month_to_season(int month);
 
 void init_is_tty(void);
 
@@ -175,6 +183,8 @@ int     cdoFiletype(void);
 
 void    cdoInqHistory(int fileID);
 void    cdoDefHistory(int fileID, char *histstring);
+void cdo_def_tracking_id(int vlistID, const char *uuid_attribute);
+void cdo_def_creation_date(int vlistID);
 
 int     cdoDefineGrid(const char *gridfile);
 int     cdoDefineZaxis(const char *zaxisfile);
@@ -182,7 +192,7 @@ int     cdoDefineZaxis(const char *zaxisfile);
 int     vlistInqNWPV(int vlistID, int varID);
 int     vlistIsSzipped(int vlistID);
 int     vlist_check_gridsize(int vlistID);
-
+int     vlist_get_psvarid(int vlistID, int zaxisID);
 
 void cdoGenFileSuffix(char *filesuffix, size_t maxlen, int filetype, int vlistID, const char *refname);
 
@@ -198,7 +208,7 @@ int cdo_omp_get_thread_num(void);
 void strtolower(char *str);
 
 /* refactor: moved here from cdo.c */
-void exp_run(int argc, char *argv[], char *cdoExpName); // job.c
+void exp_run(int argc, char *argv[], const char *cdoExpName); // job.c
 void printFeatures(void); // features.c
 void printLibraries(void);  // features.c  
 
diff --git a/src/zaxis.c b/src/zaxis.c
index f9484a4..68e1b3b 100644
--- a/src/zaxis.c
+++ b/src/zaxis.c
@@ -110,17 +110,17 @@ int zaxisDefine(zaxis_t zaxis)
   if ( zaxis.vals )
     {
       zaxisDefLevels(zaxisID, zaxis.vals);
-      free(zaxis.vals);
+      Free(zaxis.vals);
     }
   if ( zaxis.lbounds )
     {
       zaxisDefLbounds(zaxisID, zaxis.lbounds);
-      free(zaxis.lbounds);
+      Free(zaxis.lbounds);
     }
   if ( zaxis.ubounds )
     {
       zaxisDefUbounds(zaxisID, zaxis.ubounds);
-      free(zaxis.ubounds);
+      Free(zaxis.ubounds);
     }
 
   if ( zaxis.name[0] )     zaxisDefName(zaxisID, zaxis.name);
@@ -237,7 +237,7 @@ int zaxisFromFile(FILE *gfp, const char *dname)
 	    {
 	      pline = skipSeparator(pline + len);
 	  
-	      zaxis.vals = (double*) malloc(zaxis.size*sizeof(double));
+	      zaxis.vals = (double*) Malloc(zaxis.size*sizeof(double));
 	      for ( i = 0; i < zaxis.size; i++ )
 		{
 		  pline = skipSeparator(pline);
@@ -271,7 +271,7 @@ int zaxisFromFile(FILE *gfp, const char *dname)
 	    {
 	      pline = skipSeparator(pline + len);
 	  
-	      zaxis.vct = (double*) malloc(zaxis.vctsize*sizeof(double));
+	      zaxis.vct = (double*) Malloc(zaxis.vctsize*sizeof(double));
 	      for ( i = 0; i < zaxis.vctsize; i++ )
 		{
 		  pline = skipSeparator(pline);
@@ -305,7 +305,7 @@ int zaxisFromFile(FILE *gfp, const char *dname)
 	    {
 	      pline = skipSeparator(pline + len);
 	  
-	      zaxis.lbounds = (double*) malloc(zaxis.size*sizeof(double));
+	      zaxis.lbounds = (double*) Malloc(zaxis.size*sizeof(double));
 	      for ( i = 0; i < zaxis.size; i++ )
 		{
 		  pline = skipSeparator(pline);
@@ -339,7 +339,7 @@ int zaxisFromFile(FILE *gfp, const char *dname)
 	    {
 	      pline = skipSeparator(pline + len);
 	  
-	      zaxis.ubounds = (double*) malloc(zaxis.size*sizeof(double));
+	      zaxis.ubounds = (double*) Malloc(zaxis.size*sizeof(double));
 	      for ( i = 0; i < zaxis.size; i++ )
 		{
 		  pline = skipSeparator(pline);
@@ -387,7 +387,7 @@ int zaxisFromName(const char *zaxisname)
     {
       zaxis.type = ZAXIS_SURFACE;
       zaxis.size = 1;
-      zaxis.vals = (double*) malloc(zaxis.size*sizeof(double));
+      zaxis.vals = (double*) Malloc(zaxis.size*sizeof(double));
       zaxis.vals[0] = 0;
     }
 
diff --git a/test/Afterburner.test.in b/test/Afterburner.test.in
index 86b714e..bb22d5a 100644
--- a/test/Afterburner.test.in
+++ b/test/Afterburner.test.in
@@ -1,15 +1,16 @@
 #! @SHELL@
 #
 AFTERTESTFILE=ECHAM5_T42L19.grb
-if [ -f "$CDOTESTDATA/$AFTERTESTFILE" ]; then
-echo 1..4 # Number of tests to be executed.
+if [ -f "$CDOTESTDATA/$AFTERTESTFILE" -a "@ENABLE_CGRIBEX@" = yes ]; then
+  echo 1..4 # Number of tests to be executed.
 else
-echo 1..1 # Number of tests to be executed.
+  echo 1..1 # Number of tests to be executed.
 fi
 #
 test -n "$CDO"      || CDO=cdo
 test -n "$DATAPATH" || DATAPATH=./data
 #
+ABSLIMMAX=0.0001
 CDOOUT=cout
 CDOERR=cerr
 FORMAT=""
@@ -27,7 +28,7 @@ echo "$CDOCOMMAND"
 echo $SELECT | $CDOCOMMAND
 test $? -eq 0 || let RSTAT+=1
 #
-$CDO diff $OFILE $RFILE > $CDOOUT 2> $CDOERR
+$CDO diff,$ABSLIMMAX $OFILE $RFILE > $CDOOUT 2> $CDOERR
 test $? -eq 0 || let RSTAT+=1
 test -s $CDOOUT && let RSTAT+=1
 cat $CDOOUT $CDOERR
@@ -39,7 +40,7 @@ let NTEST+=1
 rm -f $OFILE
 rm -f $CDOOUT $CDOERR
 ######################################################
-if [ -f "$CDOTESTDATA/$AFTERTESTFILE" ]; then
+if [ -f "$CDOTESTDATA/$AFTERTESTFILE" -a "@ENABLE_CGRIBEX@" = yes ]; then
 ######################################################
 SELECT=bot
 IFILE=$CDOTESTDATA/$AFTERTESTFILE
@@ -63,7 +64,7 @@ $CDOCOMMAND << EOR
 EOR
 test $? -eq 0 || let RSTAT+=1
 #
-$CDO diff $OFILE $RFILE > $CDOOUT 2> $CDOERR
+$CDO diff,$ABSLIMMAX $OFILE $RFILE > $CDOOUT 2> $CDOERR
 test $? -eq 0 || let RSTAT+=1
 test -s $CDOOUT && let RSTAT+=1
 cat $CDOOUT $CDOERR
@@ -94,7 +95,7 @@ $CDOCOMMAND << EOR
 EOR
 test $? -eq 0 || let RSTAT+=1
 #
-$CDO diff $OFILE $RFILE > $CDOOUT 2> $CDOERR
+$CDO diff,$ABSLIMMAX $OFILE $RFILE > $CDOOUT 2> $CDOERR
 test $? -eq 0 || let RSTAT+=1
 test -s $CDOOUT && let RSTAT+=1
 cat $CDOOUT $CDOERR
@@ -125,7 +126,7 @@ $CDOCOMMAND << EOR
 EOR
 test $? -eq 0 || let RSTAT+=1
 #
-$CDO diff $OFILE $RFILE > $CDOOUT 2> $CDOERR
+$CDO diff,$ABSLIMMAX $OFILE $RFILE > $CDOOUT 2> $CDOERR
 test $? -eq 0 || let RSTAT+=1
 test -s $CDOOUT && let RSTAT+=1
 cat $CDOOUT $CDOERR
diff --git a/test/Enspctl.test.in b/test/Enspctl.test.in
new file mode 100644
index 0000000..ee6dd33
--- /dev/null
+++ b/test/Enspctl.test.in
@@ -0,0 +1,47 @@
+#! @SHELL@
+echo 1..1 # Number of tests to be executed.
+#
+test -n "$CDO"      || CDO=cdo
+test -n "$DATAPATH" || DATAPATH=./data
+#
+CDOOUT=cout
+CDOERR=cerr
+PCTLS="1 20 25 33 50 66 75 80 99 100"
+#
+IFILE=$DATAPATH/ts_mm_5years
+export CDO_FILE_SUFFIX=NULL
+$CDO splityear $IFILE ts_year
+IFILE="ts_year????"
+#
+NTEST=1
+RSTAT=0
+echo "Running test: $NTEST"
+#
+for PCTL in $PCTLS; do
+  RFILE=$DATAPATH/enspctl${PCTL}_ref
+  OFILE=enspctl${STAT}_res
+
+  CDOTEST="enspctl"
+  CDOCOMMAND="$CDO enspctl,${PCTL} $IFILE $OFILE"
+
+  echo "$CDOCOMMAND"
+
+  $CDOCOMMAND
+  test $? -eq 0 || let RSTAT+=1
+
+  $CDO diff $OFILE $RFILE > $CDOOUT 2> $CDOERR
+  test $? -eq 0 || let RSTAT+=1
+  test -s $CDOOUT && let RSTAT+=1
+  cat $CDOOUT $CDOERR
+
+#  let NTEST+=1
+  rm -f $OFILE
+done
+#
+test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
+test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
+#
+rm -f $CDOOUT $CDOERR
+rm -f $IFILE
+#
+exit 0
diff --git a/test/Ensstat.test.in b/test/Ensstat.test.in
new file mode 100644
index 0000000..32149f5
--- /dev/null
+++ b/test/Ensstat.test.in
@@ -0,0 +1,47 @@
+#! @SHELL@
+echo 1..9 # Number of tests to be executed.
+#
+test -n "$CDO"      || CDO=cdo
+test -n "$DATAPATH" || DATAPATH=./data
+#
+CDOOUT=cout
+CDOERR=cerr
+STATS="min max sum avg mean std std1 var var1"
+#
+IFILE=$DATAPATH/ts_mm_5years
+export CDO_FILE_SUFFIX=NULL
+$CDO splityear $IFILE ts_year
+IFILE="ts_year????"
+#
+NTEST=1
+#
+for STAT in $STATS; do
+  RSTAT=0
+  RFILE=$DATAPATH/ymon${STAT}_ref
+  OFILE=ens${STAT}_res
+
+  CDOTEST="ens$STAT"
+  CDOCOMMAND="$CDO ens${STAT} $IFILE $OFILE"
+
+  echo "Running test: $NTEST"
+  echo "$CDOCOMMAND"
+
+  $CDOCOMMAND
+  test $? -eq 0 || let RSTAT+=1
+
+  $CDO diff $OFILE $RFILE > $CDOOUT 2> $CDOERR
+  test $? -eq 0 || let RSTAT+=1
+  test -s $CDOOUT && let RSTAT+=1
+  cat $CDOOUT $CDOERR
+
+  test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
+  test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
+
+  let NTEST+=1
+  rm -f $OFILE
+done
+#
+rm -f $CDOOUT $CDOERR
+rm -f $IFILE
+#
+exit 0
diff --git a/test/File.test.in b/test/File.test.in
index aa3af33..3df3321 100644
--- a/test/File.test.in
+++ b/test/File.test.in
@@ -10,7 +10,7 @@ FORMATS="srv ext ieg grb grb2 nc nc2 nc4"
 #
 NTEST=1
 #
-for OPERATOR in write read; do
+for OPERATOR in write copy; do
   for FORMAT in $FORMATS; do
     RSTAT=0
 
@@ -35,7 +35,7 @@ for OPERATOR in write read; do
       FILEFORMAT=GRIB
       ENABLED_TEST=no
     fi
-    if [  "@ENABLE_GRIBAPI@" = no -a "${FORMAT}" = grb2 ] ; then
+    if [ "@ENABLE_GRIBAPI@" = no -a "${FORMAT}" = grb2 ] ; then
       FILEFORMAT=GRIB_API
       ENABLED_TEST=no
     fi
@@ -65,20 +65,26 @@ for OPERATOR in write read; do
           test $? -eq 0 || let RSTAT+=1
           test -s $FILE || let RSTAT+=1
           cat $CDOOUT $CDOERR
+
+          $CDO diff,0.0001 $FILE $RFILE > $CDOOUT 2> $CDOERR
+          test $? -eq 0 || let RSTAT+=1
+          test -s $CDOOUT && let RSTAT+=1
+          cat $CDOOUT $CDOERR
         else
-          CDOCOMMAND="$CDO cdi${OPERATOR} $FILE"
+          OFILE=file_${DATATYPE}_${FORMAT}_res
+          CDOCOMMAND="$CDO ${OPERATOR} $FILE $OFILE"
           echo "$CDOCOMMAND"
 
           $CDOCOMMAND  > $CDOOUT 2> $CDOERR
           test $? -eq 0 || let RSTAT+=1
           cat $CDOOUT $CDOERR
 
-          $CDO diff,0.0001 $FILE $RFILE > $CDOOUT 2> $CDOERR
+          $CDO diff,0.0001 $FILE $OFILE > $CDOOUT 2> $CDOERR
           test $? -eq 0 || let RSTAT+=1
           test -s $CDOOUT && let RSTAT+=1
           cat $CDOOUT $CDOERR
 
-	  rm -f $FILE
+	  rm -f $FILE $OFILE
         fi
       done
 
diff --git a/test/Fldpctl.test.in b/test/Fldpctl.test.in
new file mode 100644
index 0000000..33a0dec
--- /dev/null
+++ b/test/Fldpctl.test.in
@@ -0,0 +1,45 @@
+#! @SHELL@
+echo 1..1 # Number of tests to be executed.
+#
+test -n "$CDO"      || CDO=cdo
+test -n "$DATAPATH" || DATAPATH=./data
+#
+CDOOUT=cout
+CDOERR=cerr
+FORMAT="-f srv -b 32"
+#
+PCTLS="1 20 25 33 50 66 75 80 99 100"
+#
+IFILE=$DATAPATH/t21_geosp_tsurf.grb
+#
+NTEST=1
+RSTAT=0
+echo "Running test: $NTEST"
+#
+for PCTL in $PCTLS; do
+  RFILE=$DATAPATH/fldpctl${PCTL}_ref
+  OFILE=fldpctl${STAT}_res
+
+  CDOTEST="fldpctl"
+  CDOCOMMAND="$CDO $FORMAT fldpctl,${PCTL} $IFILE $OFILE"
+
+  echo "$CDOCOMMAND"
+
+  $CDOCOMMAND
+  test $? -eq 0 || let RSTAT+=1
+
+  $CDO diff $OFILE $RFILE > $CDOOUT 2> $CDOERR
+  test $? -eq 0 || let RSTAT+=1
+  test -s $CDOOUT && let RSTAT+=1
+  cat $CDOOUT $CDOERR
+
+#  let NTEST+=1
+  rm -f $OFILE
+done
+#
+test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
+test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
+#
+rm -f $CDOOUT $CDOERR
+#
+exit 0
diff --git a/test/Fldstat.test.in b/test/Fldstat.test.in
new file mode 100644
index 0000000..b19a46d
--- /dev/null
+++ b/test/Fldstat.test.in
@@ -0,0 +1,45 @@
+#! @SHELL@
+echo 1..9 # Number of tests to be executed.
+#
+test -n "$CDO"      || CDO=cdo
+test -n "$DATAPATH" || DATAPATH=./data
+#
+CDOOUT=cout
+CDOERR=cerr
+FORMAT="-f srv -b 32"
+#
+STATS="min max sum avg mean std std1 var var1"
+#
+IFILE=$DATAPATH/t21_geosp_tsurf.grb
+#
+NTEST=1
+#
+for STAT in $STATS; do
+  RSTAT=0
+  RFILE=$DATAPATH/fld${STAT}_ref
+  OFILE=fld${STAT}_res
+
+  CDOTEST="fld$STAT"
+  CDOCOMMAND="$CDO $FORMAT fld${STAT} $IFILE $OFILE"
+
+  echo "Running test: $NTEST"
+  echo "$CDOCOMMAND"
+
+  $CDOCOMMAND
+  test $? -eq 0 || let RSTAT+=1
+
+  $CDO diff $OFILE $RFILE > $CDOOUT 2> $CDOERR
+  test $? -eq 0 || let RSTAT+=1
+  test -s $CDOOUT && let RSTAT+=1
+  cat $CDOOUT $CDOERR
+
+  test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
+  test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
+
+  let NTEST+=1
+  rm -f $OFILE
+done
+#
+rm -f $CDOOUT $CDOERR
+#
+exit 0
diff --git a/test/Genweights.test.in b/test/Genweights.test.in
index a8bf4f6..80e71a8 100644
--- a/test/Genweights.test.in
+++ b/test/Genweights.test.in
@@ -9,6 +9,7 @@ test -n "$CDO"      || CDO=cdo
 test -n "$DATAPATH" || DATAPATH=./data
 #
 ABSLIMMAX=0.001
+ABSLIMDIS=0.2
 ABSLIMYCON=0.25
 CDOOUT=cout
 CDOERR=cerr
@@ -28,6 +29,7 @@ for GRIDTYPE in "regular" "curvilinear" "unstructured"; do
     if [ "$USER" = "m214003" ]; then RMODS="dis nn $RMODS"; fi
     for RMOD in $RMODS; do
       ABSLIM=$ABSLIMMAX
+      if [ $RMOD = dis ];  then ABSLIM=$ABSLIMDIS; fi
       if [ $RMOD = ycon ]; then ABSLIM=$ABSLIMYCON; fi
       RSTAT=0
       OFILE=${GRID}_${RMOD}
@@ -52,7 +54,11 @@ for GRIDTYPE in "regular" "curvilinear" "unstructured"; do
         cat $CDOOUT $CDOERR
 
         test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
-        test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
+        if [ $RMOD = dis ]; then
+          test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST # TODO check depends on optimization"
+        else
+          test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
+        fi
       else
         test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST # SKIP netCDF not enabled"
       fi
diff --git a/test/Makefile.am b/test/Makefile.am
index 0ea0e00..2c543bc 100644
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -12,8 +12,8 @@ TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
 
 # tests which should pass
 TESTS = File.test Read_grib.test Read_netcdf.test Copy_netcdf.test Cat.test Gridarea.test Detrend.test \
-        Genweights.test Remap.test Select.test Spectral.test Timstat.test Vertint.test Afterburner.test Arith.test \
-        Gradsdes.test wildcard.test
+        Genweights.test Remap.test Select.test Spectral.test Ymonstat.test Timstat.test Ensstat.test \
+        Enspctl.test Fldstat.test Fldpctl.test Vertint.test Afterburner.test Arith.test Gradsdes.test wildcard.test
 
 # tests which should fail
 XFAIL_TESTS = 
diff --git a/test/Makefile.in b/test/Makefile.in
index 298aef7..3d6bc8d 100644
--- a/test/Makefile.in
+++ b/test/Makefile.in
@@ -86,9 +86,12 @@ DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
 	$(srcdir)/Gridarea.test.in $(srcdir)/Genweights.test.in \
 	$(srcdir)/Remap.test.in $(srcdir)/Select.test.in \
 	$(srcdir)/Spectral.test.in $(srcdir)/Timstat.test.in \
-	$(srcdir)/Vertint.test.in $(srcdir)/Afterburner.test.in \
-	$(srcdir)/Detrend.test.in $(srcdir)/Arith.test.in \
-	$(srcdir)/Gradsdes.test.in $(srcdir)/wildcard.test.in README
+	$(srcdir)/Vertint.test.in $(srcdir)/Ymonstat.test.in \
+	$(srcdir)/Fldstat.test.in $(srcdir)/Fldpctl.test.in \
+	$(srcdir)/Ensstat.test.in $(srcdir)/Enspctl.test.in \
+	$(srcdir)/Afterburner.test.in $(srcdir)/Detrend.test.in \
+	$(srcdir)/Arith.test.in $(srcdir)/Gradsdes.test.in \
+	$(srcdir)/wildcard.test.in README
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
 am__aclocal_m4_deps = $(top_srcdir)/m4/acx_options.m4 \
 	$(top_srcdir)/m4/ax_pthread.m4 $(top_srcdir)/m4/libtool.m4 \
@@ -102,8 +105,9 @@ CONFIG_HEADER = $(top_builddir)/src/config.h
 CONFIG_CLEAN_FILES = File.test Read_grib.test Read_netcdf.test \
 	Copy_netcdf.test Cat.test Gridarea.test Genweights.test \
 	Remap.test Select.test Spectral.test Timstat.test Vertint.test \
-	Afterburner.test Detrend.test Arith.test Gradsdes.test \
-	wildcard.test
+	Ymonstat.test Fldstat.test Fldpctl.test Ensstat.test \
+	Enspctl.test Afterburner.test Detrend.test Arith.test \
+	Gradsdes.test wildcard.test
 CONFIG_CLEAN_VPATH_FILES =
 AM_V_P = $(am__v_P_ at AM_V@)
 am__v_P_ = $(am__v_P_ at AM_DEFAULT_V@)
@@ -342,6 +346,7 @@ CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
 CLDFLAGS = @CLDFLAGS@
 CLIBS = @CLIBS@
+CMOR_LIBS = @CMOR_LIBS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CURL_INCLUDE = @CURL_INCLUDE@
@@ -387,7 +392,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-JASPER_LIBS = @JASPER_LIBS@
 LD = @LD@
 LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
@@ -513,8 +517,8 @@ TEST_LOG_DRIVER = env AM_TAP_AWK='$(AWK)' $(SHELL) \
 
 # tests which should pass
 TESTS = File.test Read_grib.test Read_netcdf.test Copy_netcdf.test Cat.test Gridarea.test Detrend.test \
-        Genweights.test Remap.test Select.test Spectral.test Timstat.test Vertint.test Afterburner.test Arith.test \
-        Gradsdes.test wildcard.test
+        Genweights.test Remap.test Select.test Spectral.test Ymonstat.test Timstat.test Ensstat.test \
+        Enspctl.test Fldstat.test Fldpctl.test Vertint.test Afterburner.test Arith.test Gradsdes.test wildcard.test
 
 
 #        $(top_srcdir)/test/test_Remap.sh \
@@ -587,6 +591,16 @@ Timstat.test: $(top_builddir)/config.status $(srcdir)/Timstat.test.in
 	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 Vertint.test: $(top_builddir)/config.status $(srcdir)/Vertint.test.in
 	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+Ymonstat.test: $(top_builddir)/config.status $(srcdir)/Ymonstat.test.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+Fldstat.test: $(top_builddir)/config.status $(srcdir)/Fldstat.test.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+Fldpctl.test: $(top_builddir)/config.status $(srcdir)/Fldpctl.test.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+Ensstat.test: $(top_builddir)/config.status $(srcdir)/Ensstat.test.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+Enspctl.test: $(top_builddir)/config.status $(srcdir)/Enspctl.test.in
+	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 Afterburner.test: $(top_builddir)/config.status $(srcdir)/Afterburner.test.in
 	cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
 Detrend.test: $(top_builddir)/config.status $(srcdir)/Detrend.test.in
diff --git a/test/Remap.test.in b/test/Remap.test.in
index 85fdff2..ea20428 100644
--- a/test/Remap.test.in
+++ b/test/Remap.test.in
@@ -9,6 +9,7 @@ test -n "$CDO"      || CDO=cdo
 test -n "$DATAPATH" || DATAPATH=./data
 #
 ABSLIMMAX=0.001
+ABSLIMDIS=0.2
 ABSLIMYCON=0.25
 CDOOUT=cout
 CDOERR=cerr
@@ -28,6 +29,7 @@ for GRIDTYPE in "regular" "curvilinear" "unstructured"; do
     if [ "$USER" = "m214003" ]; then RMODS="dis nn $RMODS"; fi
     for RMOD in $RMODS; do
       ABSLIM=$ABSLIMMAX
+      if [ $RMOD = dis ];  then ABSLIM=$ABSLIMDIS; fi
       if [ $RMOD = ycon ]; then ABSLIM=$ABSLIMYCON; fi
       RSTAT=0
       OFILE=${GRID}_${RMOD}
@@ -48,7 +50,11 @@ for GRIDTYPE in "regular" "curvilinear" "unstructured"; do
       cat $CDOOUT $CDOERR
 
       test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
-      test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
+      if [ $RMOD = dis ]; then
+        test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST # TODO check depends on optimization"
+      else
+        test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
+      fi
 
       let NTEST+=1
       rm -f $OFILE
diff --git a/test/Ymonstat.test.in b/test/Ymonstat.test.in
new file mode 100644
index 0000000..0cafacb
--- /dev/null
+++ b/test/Ymonstat.test.in
@@ -0,0 +1,42 @@
+#! @SHELL@
+echo 1..9 # Number of tests to be executed.
+#
+test -n "$CDO"      || CDO=cdo
+test -n "$DATAPATH" || DATAPATH=./data
+#
+CDOOUT=cout
+CDOERR=cerr
+STATS="min max sum avg mean std std1 var var1"
+#
+IFILE=$DATAPATH/ts_mm_5years
+NTEST=1
+#
+for STAT in $STATS; do
+  RSTAT=0
+  RFILE=$DATAPATH/ymon${STAT}_ref
+  OFILE=ymon${STAT}_res
+
+  CDOTEST="ymon$STAT"
+  CDOCOMMAND="$CDO ymon${STAT} $IFILE $OFILE"
+
+  echo "Running test: $NTEST"
+  echo "$CDOCOMMAND"
+
+  $CDOCOMMAND
+  test $? -eq 0 || let RSTAT+=1
+
+  $CDO diff $OFILE $RFILE > $CDOOUT 2> $CDOERR
+  test $? -eq 0 || let RSTAT+=1
+  test -s $CDOOUT && let RSTAT+=1
+  cat $CDOOUT $CDOERR
+
+  test $RSTAT -eq 0 && echo "ok $NTEST - $CDOTEST"
+  test $RSTAT -eq 0 || echo "not ok $NTEST - $CDOTEST"
+
+  let NTEST+=1
+  rm -f $OFILE
+done
+#
+rm -f $CDOOUT $CDOERR
+#
+exit 0
diff --git a/test/data/._netcdf_testfile01.nc b/test/data/._netcdf_testfile01.nc
deleted file mode 100644
index 308c64b..0000000
Binary files a/test/data/._netcdf_testfile01.nc and /dev/null differ
diff --git a/test/data/Makefile.am b/test/data/Makefile.am
index 6ba987b..ed23996 100644
--- a/test/data/Makefile.am
+++ b/test/data/Makefile.am
@@ -4,7 +4,11 @@ INPUTDATA = ts_mm_5years hl_l19.grb t21_geosp_tsurf.grb bathy4.grb pl_data pl_da
 FILE_REF     = file_F32_srv_ref
 GRIB_REF     = grib_testfile01_sinfo_ref grib_testfile01_info_ref grib_testfile02_sinfo_ref grib_testfile02_info_ref
 NETCDF_REF   = netcdf_testfile01_sinfon_ref netcdf_testfile01_infon_ref netcdf_testfile02_sinfon_ref netcdf_testfile02_infon_ref
+YMONSTAT_REF = ymonmin_ref ymonmax_ref ymonsum_ref ymonavg_ref ymonmean_ref ymonstd_ref ymonstd1_ref ymonvar_ref ymonvar1_ref
 TIMSTAT_REF  = timmin_ref timmax_ref timsum_ref timavg_ref timmean_ref timstd_ref timstd1_ref timvar_ref timvar1_ref
+FLDSTAT_REF  = fldmin_ref fldmax_ref fldsum_ref fldavg_ref fldmean_ref fldstd_ref fldstd1_ref fldvar_ref fldvar1_ref
+FLDPSTAT_REF = fldpctl1_ref fldpctl20_ref fldpctl25_ref fldpctl33_ref fldpctl50_ref fldpctl66_ref fldpctl75_ref fldpctl80_ref fldpctl99_ref fldpctl100_ref
+ENSPSTAT_REF = enspctl1_ref enspctl20_ref enspctl25_ref enspctl33_ref enspctl50_ref enspctl66_ref enspctl75_ref enspctl80_ref enspctl99_ref enspctl100_ref
 SPECTRAL_REF = sp2gp_ref sp2gpl_ref gp2sp_ref gp2spl_ref
 VERTINT_REF  = ml2pl_ref
 REMAP_REF    = n16_bic_ref n16_bil_ref n16_con_ref n16_ycon_ref n16_laf_ref n16_nn_ref n16_dis_ref \
@@ -13,4 +17,4 @@ SELECT_REF   = select1_ref select2_ref select3_ref select4_ref select5_ref
 DETREND_REF  = detrend_ref
 GRADSDES_REF = pl_data.ctl pl_data.gmp
 
-EXTRA_DIST = $(INPUTDATA) $(FILE_REF) $(GRIB_REF) $(NETCDF_REF) $(TIMSTAT_REF) $(SPECTRAL_REF) $(VERTINT_REF) $(REMAP_REF) $(SELECT_REF) $(DETREND_REF) $(GRADSDES_REF)
+EXTRA_DIST = $(INPUTDATA) $(FILE_REF) $(GRIB_REF) $(NETCDF_REF) $(YMONSTAT_REF) $(TIMSTAT_REF) $(FLDSTAT_REF) $(FLDPSTAT_REF) $(ENSPSTAT_REF) $(SPECTRAL_REF) $(VERTINT_REF) $(REMAP_REF) $(SELECT_REF) $(DETREND_REF) $(GRADSDES_REF)
diff --git a/test/data/Makefile.in b/test/data/Makefile.in
index b2f54cd..b74aa9d 100644
--- a/test/data/Makefile.in
+++ b/test/data/Makefile.in
@@ -128,6 +128,7 @@ CCDEPMODE = @CCDEPMODE@
 CFLAGS = @CFLAGS@
 CLDFLAGS = @CLDFLAGS@
 CLIBS = @CLIBS@
+CMOR_LIBS = @CMOR_LIBS@
 CPP = @CPP@
 CPPFLAGS = @CPPFLAGS@
 CURL_INCLUDE = @CURL_INCLUDE@
@@ -173,7 +174,6 @@ INSTALL_DATA = @INSTALL_DATA@
 INSTALL_PROGRAM = @INSTALL_PROGRAM@
 INSTALL_SCRIPT = @INSTALL_SCRIPT@
 INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
-JASPER_LIBS = @JASPER_LIBS@
 LD = @LD@
 LDFLAGS = @LDFLAGS@
 LIBOBJS = @LIBOBJS@
@@ -291,7 +291,11 @@ INPUTDATA = ts_mm_5years hl_l19.grb t21_geosp_tsurf.grb bathy4.grb pl_data pl_da
 FILE_REF = file_F32_srv_ref
 GRIB_REF = grib_testfile01_sinfo_ref grib_testfile01_info_ref grib_testfile02_sinfo_ref grib_testfile02_info_ref
 NETCDF_REF = netcdf_testfile01_sinfon_ref netcdf_testfile01_infon_ref netcdf_testfile02_sinfon_ref netcdf_testfile02_infon_ref
+YMONSTAT_REF = ymonmin_ref ymonmax_ref ymonsum_ref ymonavg_ref ymonmean_ref ymonstd_ref ymonstd1_ref ymonvar_ref ymonvar1_ref
 TIMSTAT_REF = timmin_ref timmax_ref timsum_ref timavg_ref timmean_ref timstd_ref timstd1_ref timvar_ref timvar1_ref
+FLDSTAT_REF = fldmin_ref fldmax_ref fldsum_ref fldavg_ref fldmean_ref fldstd_ref fldstd1_ref fldvar_ref fldvar1_ref
+FLDPSTAT_REF = fldpctl1_ref fldpctl20_ref fldpctl25_ref fldpctl33_ref fldpctl50_ref fldpctl66_ref fldpctl75_ref fldpctl80_ref fldpctl99_ref fldpctl100_ref
+ENSPSTAT_REF = enspctl1_ref enspctl20_ref enspctl25_ref enspctl33_ref enspctl50_ref enspctl66_ref enspctl75_ref enspctl80_ref enspctl99_ref enspctl100_ref
 SPECTRAL_REF = sp2gp_ref sp2gpl_ref gp2sp_ref gp2spl_ref
 VERTINT_REF = ml2pl_ref
 REMAP_REF = n16_bic_ref n16_bil_ref n16_con_ref n16_ycon_ref n16_laf_ref n16_nn_ref n16_dis_ref \
@@ -300,7 +304,7 @@ REMAP_REF = n16_bic_ref n16_bil_ref n16_con_ref n16_ycon_ref n16_laf_ref n16_nn_
 SELECT_REF = select1_ref select2_ref select3_ref select4_ref select5_ref
 DETREND_REF = detrend_ref
 GRADSDES_REF = pl_data.ctl pl_data.gmp
-EXTRA_DIST = $(INPUTDATA) $(FILE_REF) $(GRIB_REF) $(NETCDF_REF) $(TIMSTAT_REF) $(SPECTRAL_REF) $(VERTINT_REF) $(REMAP_REF) $(SELECT_REF) $(DETREND_REF) $(GRADSDES_REF)
+EXTRA_DIST = $(INPUTDATA) $(FILE_REF) $(GRIB_REF) $(NETCDF_REF) $(YMONSTAT_REF) $(TIMSTAT_REF) $(FLDSTAT_REF) $(FLDPSTAT_REF) $(ENSPSTAT_REF) $(SPECTRAL_REF) $(VERTINT_REF) $(REMAP_REF) $(SELECT_REF) $(DETREND_REF) $(GRADSDES_REF)
 all: all-am
 
 .SUFFIXES:
diff --git a/test/data/enspctl100_ref b/test/data/enspctl100_ref
new file mode 100644
index 0000000..8b3b8b0
Binary files /dev/null and b/test/data/enspctl100_ref differ
diff --git a/test/data/enspctl1_ref b/test/data/enspctl1_ref
new file mode 100644
index 0000000..fb583bd
Binary files /dev/null and b/test/data/enspctl1_ref differ
diff --git a/test/data/enspctl20_ref b/test/data/enspctl20_ref
new file mode 100644
index 0000000..fb583bd
Binary files /dev/null and b/test/data/enspctl20_ref differ
diff --git a/test/data/enspctl25_ref b/test/data/enspctl25_ref
new file mode 100644
index 0000000..3ee37fc
Binary files /dev/null and b/test/data/enspctl25_ref differ
diff --git a/test/data/enspctl33_ref b/test/data/enspctl33_ref
new file mode 100644
index 0000000..3ee37fc
Binary files /dev/null and b/test/data/enspctl33_ref differ
diff --git a/test/data/enspctl50_ref b/test/data/enspctl50_ref
new file mode 100644
index 0000000..a0245b9
Binary files /dev/null and b/test/data/enspctl50_ref differ
diff --git a/test/data/enspctl66_ref b/test/data/enspctl66_ref
new file mode 100644
index 0000000..5249a04
Binary files /dev/null and b/test/data/enspctl66_ref differ
diff --git a/test/data/enspctl75_ref b/test/data/enspctl75_ref
new file mode 100644
index 0000000..5249a04
Binary files /dev/null and b/test/data/enspctl75_ref differ
diff --git a/test/data/enspctl80_ref b/test/data/enspctl80_ref
new file mode 100644
index 0000000..5249a04
Binary files /dev/null and b/test/data/enspctl80_ref differ
diff --git a/test/data/enspctl99_ref b/test/data/enspctl99_ref
new file mode 100644
index 0000000..8b3b8b0
Binary files /dev/null and b/test/data/enspctl99_ref differ
diff --git a/test/data/fldavg_ref b/test/data/fldavg_ref
new file mode 100644
index 0000000..49b1c93
Binary files /dev/null and b/test/data/fldavg_ref differ
diff --git a/test/data/fldmax_ref b/test/data/fldmax_ref
new file mode 100644
index 0000000..71f2c23
Binary files /dev/null and b/test/data/fldmax_ref differ
diff --git a/test/data/fldmean_ref b/test/data/fldmean_ref
new file mode 100644
index 0000000..49b1c93
Binary files /dev/null and b/test/data/fldmean_ref differ
diff --git a/test/data/fldmin_ref b/test/data/fldmin_ref
new file mode 100644
index 0000000..409e83f
Binary files /dev/null and b/test/data/fldmin_ref differ
diff --git a/test/data/fldpctl100_ref b/test/data/fldpctl100_ref
new file mode 100644
index 0000000..71f2c23
Binary files /dev/null and b/test/data/fldpctl100_ref differ
diff --git a/test/data/fldpctl1_ref b/test/data/fldpctl1_ref
new file mode 100644
index 0000000..68cd0d2
Binary files /dev/null and b/test/data/fldpctl1_ref differ
diff --git a/test/data/fldpctl20_ref b/test/data/fldpctl20_ref
new file mode 100644
index 0000000..aeb839e
Binary files /dev/null and b/test/data/fldpctl20_ref differ
diff --git a/test/data/fldpctl25_ref b/test/data/fldpctl25_ref
new file mode 100644
index 0000000..11950ef
Binary files /dev/null and b/test/data/fldpctl25_ref differ
diff --git a/test/data/fldpctl33_ref b/test/data/fldpctl33_ref
new file mode 100644
index 0000000..3acd270
Binary files /dev/null and b/test/data/fldpctl33_ref differ
diff --git a/test/data/fldpctl50_ref b/test/data/fldpctl50_ref
new file mode 100644
index 0000000..0fc2b70
Binary files /dev/null and b/test/data/fldpctl50_ref differ
diff --git a/test/data/fldpctl66_ref b/test/data/fldpctl66_ref
new file mode 100644
index 0000000..23ae67a
Binary files /dev/null and b/test/data/fldpctl66_ref differ
diff --git a/test/data/fldpctl75_ref b/test/data/fldpctl75_ref
new file mode 100644
index 0000000..c413199
Binary files /dev/null and b/test/data/fldpctl75_ref differ
diff --git a/test/data/fldpctl80_ref b/test/data/fldpctl80_ref
new file mode 100644
index 0000000..0246866
Binary files /dev/null and b/test/data/fldpctl80_ref differ
diff --git a/test/data/fldpctl99_ref b/test/data/fldpctl99_ref
new file mode 100644
index 0000000..01aca02
Binary files /dev/null and b/test/data/fldpctl99_ref differ
diff --git a/test/data/fldstd1_ref b/test/data/fldstd1_ref
new file mode 100644
index 0000000..69ffb5a
Binary files /dev/null and b/test/data/fldstd1_ref differ
diff --git a/test/data/fldstd_ref b/test/data/fldstd_ref
new file mode 100644
index 0000000..a942027
Binary files /dev/null and b/test/data/fldstd_ref differ
diff --git a/test/data/fldsum_ref b/test/data/fldsum_ref
new file mode 100644
index 0000000..97dc3a0
Binary files /dev/null and b/test/data/fldsum_ref differ
diff --git a/test/data/fldvar1_ref b/test/data/fldvar1_ref
new file mode 100644
index 0000000..a5f26d8
Binary files /dev/null and b/test/data/fldvar1_ref differ
diff --git a/test/data/fldvar_ref b/test/data/fldvar_ref
new file mode 100644
index 0000000..c38c975
Binary files /dev/null and b/test/data/fldvar_ref differ
diff --git a/test/data/ymonavg_ref b/test/data/ymonavg_ref
new file mode 100644
index 0000000..f5da236
Binary files /dev/null and b/test/data/ymonavg_ref differ
diff --git a/test/data/ymonmax_ref b/test/data/ymonmax_ref
new file mode 100644
index 0000000..f69c7fe
Binary files /dev/null and b/test/data/ymonmax_ref differ
diff --git a/test/data/ymonmean_ref b/test/data/ymonmean_ref
new file mode 100644
index 0000000..f5da236
Binary files /dev/null and b/test/data/ymonmean_ref differ
diff --git a/test/data/ymonmin_ref b/test/data/ymonmin_ref
new file mode 100644
index 0000000..fc7e017
Binary files /dev/null and b/test/data/ymonmin_ref differ
diff --git a/test/data/ymonstd1_ref b/test/data/ymonstd1_ref
new file mode 100644
index 0000000..1d9fd7c
Binary files /dev/null and b/test/data/ymonstd1_ref differ
diff --git a/test/data/ymonstd_ref b/test/data/ymonstd_ref
new file mode 100644
index 0000000..75913de
Binary files /dev/null and b/test/data/ymonstd_ref differ
diff --git a/test/data/ymonsum_ref b/test/data/ymonsum_ref
new file mode 100644
index 0000000..caf5a86
Binary files /dev/null and b/test/data/ymonsum_ref differ
diff --git a/test/data/ymonvar1_ref b/test/data/ymonvar1_ref
new file mode 100644
index 0000000..4887e39
Binary files /dev/null and b/test/data/ymonvar1_ref differ
diff --git a/test/data/ymonvar_ref b/test/data/ymonvar_ref
new file mode 100644
index 0000000..291bcca
Binary files /dev/null and b/test/data/ymonvar_ref differ

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-science/packages/cdo.git



More information about the debian-science-commits mailing list